diff mbox

[v4,07/13] ARM: at91: pm: find and remap the pmc

Message ID 1453911072-23608-8-git-send-email-alexandre.belloni@free-electrons.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexandre Belloni Jan. 27, 2016, 4:11 p.m. UTC
To avoid relying on at91_pmc_read(), find the pmc node and remap it
locally.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 arch/arm/mach-at91/pm.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

Comments

kernel test robot Jan. 27, 2016, 5:55 p.m. UTC | #1
Hi Alexandre,

[auto build test ERROR on clk/clk-next]
[also build test ERROR on v4.5-rc1 next-20160127]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Alexandre-Belloni/ARM-at91-PMC-driver-rework/20160128-002052
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: arm-at91_dt_defconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   include/linux/of.h: In function 'at91_pm_init':
>> arch/arm/mach-at91/pm.c:403:40: error: atmel_pmc_ids causes a section type conflict with ramc_ids
    static __initconst struct of_device_id atmel_pmc_ids[] = {
                                           ^
   arch/arm/mach-at91/pm.c:320:40: note: 'ramc_ids' was declared here
    static const struct of_device_id const ramc_ids[] __initconst = {
                                           ^

vim +403 arch/arm/mach-at91/pm.c

   397	
   398		/* Copy the pm suspend handler to SRAM */
   399		at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
   400				&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
   401	}
   402	
 > 403	static __initconst struct of_device_id atmel_pmc_ids[] = {
   404		{ .compatible = "atmel,at91rm9200-pmc"  },
   405		{ .compatible = "atmel,at91sam9260-pmc" },
   406		{ .compatible = "atmel,at91sam9g45-pmc" },

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Stephen Boyd Jan. 28, 2016, 8:33 a.m. UTC | #2
On 01/27, Alexandre Belloni wrote:
> @@ -399,13 +400,33 @@ static void __init at91_pm_sram_init(void)
>  			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
>  }
>  
> +static __initconst struct of_device_id atmel_pmc_ids[] = {

The kbuild error is weird, but __initconst should come right
before the equals sign (=). Plus it should actually be const.

> +	{ .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)
Alexandre Belloni Jan. 28, 2016, 8:38 a.m. UTC | #3
On 28/01/2016 at 00:33:47 -0800, Stephen Boyd wrote :
> On 01/27, Alexandre Belloni wrote:
> > @@ -399,13 +400,33 @@ static void __init at91_pm_sram_init(void)
> >  			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
> >  }
> >  
> > +static __initconst struct of_device_id atmel_pmc_ids[] = {
> 
> The kbuild error is weird, but __initconst should come right
> before the equals sign (=). Plus it should actually be const.
> 

Yeah, I sent v5, right after v4. I had that change but forgot to squash
it.

> > +	{ .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)
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
diff mbox

Patch

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index db32bf846cef..0a87c98337a9 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -35,6 +35,8 @@ 
 #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
@@ -87,7 +89,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) {
@@ -101,8 +103,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;
@@ -145,8 +146,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();
 }
@@ -399,13 +400,33 @@  static void __init at91_pm_sram_init(void)
 			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
 }
 
+static __initconst struct of_device_id atmel_pmc_ids[] = {
+	{ .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)
 {
-	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;
+	}
+
+	at91_pm_sram_init();
+
 	if (at91_suspend_sram_fn)
 		suspend_set_ops(&at91_pm_ops);
 	else