Skip to content

Commit

Permalink
Merge tag 'at91-ab-4.6-drivers' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/abelloni/linux into next/drivers

From Alexandre Belloni:

"This is a rework of the PMC driver. It touches multiple subsystems so
the easiest path is through arm-soc."

drivers update for 4.6:
 - Big PMC rework that touches clk, PM, usb

* tag 'at91-ab-4.6-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux:
  clk: at91: remove useless includes
  clk: at91: pmc: remove useless capacities handling
  clk: at91: pmc: drop at91_pmc_base
  usb: gadget: atmel: access the PMC using regmap
  ARM: at91: remove useless includes and function prototypes
  ARM: at91: pm: move idle functions to pm.c
  ARM: at91: pm: find and remap the pmc
  ARM: at91: pm: simply call at91_pm_init
  clk: at91: pmc: move pmc structures to C file
  clk: at91: pmc: merge at91_pmc_init in atmel_pmc_probe
  clk: at91: remove IRQ handling and use polling
  clk: at91: make use of syscon/regmap internally
  clk: at91: make use of syscon to share PMC registers in several drivers

Signed-off-by: Olof Johansson <olof@lixom.net>
  • Loading branch information
Olof Johansson committed Feb 25, 2016
2 parents 962f08f + 0002ca1 commit f628c64
Show file tree
Hide file tree
Showing 24 changed files with 724 additions and 1,294 deletions.
1 change: 1 addition & 0 deletions arch/arm/mach-at91/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ config HAVE_AT91_USB_CLK
config COMMON_CLK_AT91
bool
select COMMON_CLK
select MFD_SYSCON

config HAVE_AT91_SMD
bool
Expand Down
2 changes: 0 additions & 2 deletions arch/arm/mach-at91/at91rm9200.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <linux/of_platform.h>

#include <asm/mach/arch.h>
#include <asm/system_misc.h>

#include "generic.h"
#include "soc.h"
Expand All @@ -33,7 +32,6 @@ static void __init at91rm9200_dt_device_init(void)

of_platform_populate(NULL, of_default_bus_match_table, NULL, soc_dev);

arm_pm_idle = at91rm9200_idle;
at91rm9200_pm_init();
}

Expand Down
2 changes: 0 additions & 2 deletions arch/arm/mach-at91/at91sam9.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ static void __init at91sam9_common_init(void)
soc_dev = soc_device_to_device(soc);

of_platform_populate(NULL, of_default_bus_match_table, NULL, soc_dev);

arm_pm_idle = at91sam9_idle;
}

static void __init at91sam9_dt_device_init(void)
Expand Down
13 changes: 2 additions & 11 deletions arch/arm/mach-at91/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,18 @@
#ifndef _AT91_GENERIC_H
#define _AT91_GENERIC_H

#include <linux/of.h>
#include <linux/reboot.h>

/* Map io */
extern void __init at91_map_io(void);
extern void __init at91_alt_map_io(void);

/* idle */
extern void at91rm9200_idle(void);
extern void at91sam9_idle(void);

#ifdef CONFIG_PM
extern void __init at91rm9200_pm_init(void);
extern void __init at91sam9260_pm_init(void);
extern void __init at91sam9g45_pm_init(void);
extern void __init at91sam9x5_pm_init(void);
extern void __init sama5_pm_init(void);
#else
static inline void __init at91rm9200_pm_init(void) { }
static inline void __init at91sam9260_pm_init(void) { }
static inline void __init at91sam9g45_pm_init(void) { }
static inline void __init at91sam9x5_pm_init(void) { }
static inline void __init sama5_pm_init(void) { }
#endif

#endif /* _AT91_GENERIC_H */
70 changes: 59 additions & 11 deletions arch/arm/mach-at91/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@
#include <asm/mach/irq.h>
#include <asm/fncpy.h>
#include <asm/cacheflush.h>
#include <asm/system_misc.h>

#include "generic.h"
#include "pm.h"

static void __iomem *pmc;

/*
* FIXME: this is needed to communicate between the pinctrl driver and
* the PM implementation in the machine. Possibly part of the PM
Expand Down Expand Up @@ -87,7 +90,7 @@ static int at91_pm_verify_clocks(void)
unsigned long scsr;
int i;

scsr = at91_pmc_read(AT91_PMC_SCSR);
scsr = readl(pmc + AT91_PMC_SCSR);

/* USB must not be using PLLB */
if ((scsr & at91_pm_data.uhp_udp_mask) != 0) {
Expand All @@ -101,8 +104,7 @@ static int at91_pm_verify_clocks(void)

if ((scsr & (AT91_PMC_PCK0 << i)) == 0)
continue;

css = at91_pmc_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
css = readl(pmc + AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
if (css != AT91_PMC_CSS_SLOW) {
pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css);
return 0;
Expand Down Expand Up @@ -145,8 +147,8 @@ static void at91_pm_suspend(suspend_state_t state)
flush_cache_all();
outer_disable();

at91_suspend_sram_fn(at91_pmc_base, at91_ramc_base[0],
at91_ramc_base[1], pm_data);
at91_suspend_sram_fn(pmc, at91_ramc_base[0],
at91_ramc_base[1], pm_data);

outer_resume();
}
Expand Down Expand Up @@ -353,6 +355,21 @@ static __init void at91_dt_ramc(void)
at91_pm_set_standby(standby);
}

void at91rm9200_idle(void)
{
/*
* Disable the processor clock. The processor will be automatically
* re-enabled by an interrupt or by a reset.
*/
writel(AT91_PMC_PCK, pmc + AT91_PMC_SCDR);
}

void at91sam9_idle(void)
{
writel(AT91_PMC_PCK, pmc + AT91_PMC_SCDR);
cpu_do_idle();
}

static void __init at91_pm_sram_init(void)
{
struct gen_pool *sram_pool;
Expand Down Expand Up @@ -399,13 +416,36 @@ static void __init at91_pm_sram_init(void)
&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
}

static void __init at91_pm_init(void)
static const struct of_device_id atmel_pmc_ids[] __initconst = {
{ .compatible = "atmel,at91rm9200-pmc" },
{ .compatible = "atmel,at91sam9260-pmc" },
{ .compatible = "atmel,at91sam9g45-pmc" },
{ .compatible = "atmel,at91sam9n12-pmc" },
{ .compatible = "atmel,at91sam9x5-pmc" },
{ .compatible = "atmel,sama5d3-pmc" },
{ .compatible = "atmel,sama5d2-pmc" },
{ /* sentinel */ },
};

static void __init at91_pm_init(void (*pm_idle)(void))
{
at91_pm_sram_init();
struct device_node *pmc_np;

if (at91_cpuidle_device.dev.platform_data)
platform_device_register(&at91_cpuidle_device);

pmc_np = of_find_matching_node(NULL, atmel_pmc_ids);
pmc = of_iomap(pmc_np, 0);
if (!pmc) {
pr_err("AT91: PM not supported, PMC not found\n");
return;
}

if (pm_idle)
arm_pm_idle = pm_idle;

at91_pm_sram_init();

if (at91_suspend_sram_fn)
suspend_set_ops(&at91_pm_ops);
else
Expand All @@ -424,29 +464,37 @@ void __init at91rm9200_pm_init(void)
at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP;
at91_pm_data.memctrl = AT91_MEMCTRL_MC;

at91_pm_init();
at91_pm_init(at91rm9200_idle);
}

void __init at91sam9260_pm_init(void)
{
at91_dt_ramc();
at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
return at91_pm_init();
at91_pm_init(at91sam9_idle);
}

void __init at91sam9g45_pm_init(void)
{
at91_dt_ramc();
at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP;
at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
return at91_pm_init();
at91_pm_init(at91sam9_idle);
}

void __init at91sam9x5_pm_init(void)
{
at91_dt_ramc();
at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
return at91_pm_init();
at91_pm_init(at91sam9_idle);
}

void __init sama5_pm_init(void)
{
at91_dt_ramc();
at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
at91_pm_init(NULL);
}
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/sama5.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static void __init sama5_dt_device_init(void)
soc_dev = soc_device_to_device(soc);

of_platform_populate(NULL, of_default_bus_match_table, NULL, soc_dev);
at91sam9x5_pm_init();
sama5_pm_init();
}

static const char *const sama5_dt_board_compat[] __initconst = {
Expand Down
Loading

0 comments on commit f628c64

Please sign in to comment.