Skip to contentSkip to conversation

ARM: davinci: PM: cleanup init, add DT support

PATCH Superseded Kevin Hilman 2 participants 8 messages Nov 15, 2016 – Nov 16, 2016 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover ARM: davinci: PM: cleanup init, add DT support

This series removes the fake platform_device used to initialize PM on legacy davinci platforms, and also adds PM support for DT platforms.

Tested with legacy boot on da850-evm, and DT boot on da850-lcdk. Used RTC to wake from suspend-to-RAM: e.g. rtcwake -m mem -s 4 -d /dev/rtc0

Changes since v1:
- separated support for DT platfroms into separate patch
- misc. cleanup, re-structuring

Kevin Hilman (3):
ARM: davinci: PM: rework init, support DT platforms
ARM: davinci: PM: cleanup: remove references to pdata
ARM: davinci: PM: support da8xx DT platforms

 arch/arm/mach-davinci/board-da850-evm.c    |  17 +----
 arch/arm/mach-davinci/board-mityomapl138.c |  16 +----
 arch/arm/mach-davinci/common.c             |   1 -
 arch/arm/mach-davinci/da850.c              |  38 -----------
 arch/arm/mach-davinci/da8xx-dt.c           |   1 +
 arch/arm/mach-davinci/include/mach/da8xx.h |   1 -
 arch/arm/mach-davinci/pm.c                 | 102 ++++++++++++++++-------------
 7 files changed, 60 insertions(+), 116 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH v2 1/3 ARM: davinci: PM: rework init, support DT platforms

Remove fake platform device used for PM init. Move pdata values which are common across all current platforms into pm.c.

Also, since PM is only used on da8xx, remove davinci_pm_init() from common init code, and only use in da850/omapl138 board files that are currently creating the fake platform_device.

---
 arch/arm/mach-davinci/board-da850-evm.c    | 17 +-------
 arch/arm/mach-davinci/board-mityomapl138.c | 16 +------
 arch/arm/mach-davinci/common.c             |  1 -
 arch/arm/mach-davinci/da850.c              | 38 -----------------
 arch/arm/mach-davinci/include/mach/da8xx.h |  1 -
 arch/arm/mach-davinci/pm.c                 | 67 ++++++++++++++++++------------
 6 files changed, 42 insertions(+), 98 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +1 -16
index 8e4539f69fdc..4e88723c23c7 100644
@@ -196,18 +196,6 @@ static struct platform_device da850_evm_norflash_device = {
 	.resource	= da850_evm_norflash_resource,
 };
 
-static struct davinci_pm_config da850_pm_pdata = {
-	.sleepcount = 128,
-};
-
-static struct platform_device da850_pm_device = {
-	.name           = "pm-davinci",
-	.dev = {
-		.platform_data	= &da850_pm_pdata,
-	},
-	.id             = -1,
-};
-
 /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
  * (128K blocks). It may be used instead of the (default) SPI flash
  * to boot, using TI's tools to install the secondary boot loader
@@ -1453,10 +1441,7 @@ static __init void da850_evm_init(void)
 	if (ret)
 		pr_warn("%s: cpuidle registration failed: %d\n", __func__, ret);
 
-	ret = da850_register_pm(&da850_pm_device);
-	if (ret)
-		pr_warn("%s: suspend registration failed: %d\n", __func__, ret);
-
+	davinci_pm_init();
 	da850_vpif_init();
 
 	ret = spi_register_board_info(da850evm_spi_info,
arch/arm/mach-davinci/board-mityomapl138.c +1 -15
index bc4e63fa9808..9e7388ba413c 100644
@@ -498,18 +498,6 @@ static void __init mityomapl138_config_emac(void)
 		pr_warn("emac registration failed: %d\n", ret);
 }
 
-static struct davinci_pm_config da850_pm_pdata = {
-	.sleepcount = 128,
-};
-
-static struct platform_device da850_pm_device = {
-	.name	= "pm-davinci",
-	.dev = {
-		.platform_data  = &da850_pm_pdata,
-	},
-	.id	= -1,
-};
-
 static void __init mityomapl138_init(void)
 {
 	int ret;
@@ -555,9 +543,7 @@ static void __init mityomapl138_init(void)
 	if (ret)
 		pr_warn("cpuidle registration failed: %d\n", ret);
 
-	ret = da850_register_pm(&da850_pm_device);
-	if (ret)
-		pr_warn("suspend registration failed: %d\n", ret);
+	davinci_pm_init();
 }
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
arch/arm/mach-davinci/common.c +0 -1
index 049025f6d531..9f9fbfa6da0d 100644
@@ -118,6 +118,5 @@ void __init davinci_common_init(struct davinci_soc_info *soc_info)
 void __init davinci_init_late(void)
 {
 	davinci_cpufreq_init();
-	davinci_pm_init();
 	davinci_clk_disable_unused();
 }
arch/arm/mach-davinci/da850.c +0 -38
index ed3d0e9f72ac..28771923199f 100644
@@ -1172,44 +1172,6 @@ static int da850_round_armrate(struct clk *clk, unsigned long rate)
 }
 #endif
 
-int __init da850_register_pm(struct platform_device *pdev)
-{
-	int ret;
-	struct davinci_pm_config *pdata = pdev->dev.platform_data;
-
-	ret = davinci_cfg_reg(DA850_RTC_ALARM);
-	if (ret)
-		return ret;
-
-	pdata->ddr2_ctlr_base = da8xx_get_mem_ctlr();
-	pdata->deepsleep_reg = DA8XX_SYSCFG1_VIRT(DA8XX_DEEPSLEEP_REG);
-	pdata->ddrpsc_num = DA8XX_LPSC1_EMIF3C;
-
-	pdata->cpupll_reg_base = ioremap(DA8XX_PLL0_BASE, SZ_4K);
-	if (!pdata->cpupll_reg_base)
-		return -ENOMEM;
-
-	pdata->ddrpll_reg_base = ioremap(DA850_PLL1_BASE, SZ_4K);
-	if (!pdata->ddrpll_reg_base) {
-		ret = -ENOMEM;
-		goto no_ddrpll_mem;
-	}
-
-	pdata->ddrpsc_reg_base = ioremap(DA8XX_PSC1_BASE, SZ_4K);
-	if (!pdata->ddrpsc_reg_base) {
-		ret = -ENOMEM;
-		goto no_ddrpsc_mem;
-	}
-
-	return platform_device_register(pdev);
-
-no_ddrpsc_mem:
-	iounmap(pdata->ddrpll_reg_base);
-no_ddrpll_mem:
-	iounmap(pdata->cpupll_reg_base);
-	return ret;
-}
-
 /* VPIF resource, platform data */
 static u64 da850_vpif_dma_mask = DMA_BIT_MASK(32);
 
arch/arm/mach-davinci/include/mach/da8xx.h +0 -1
index f9f9713aacdd..3d7a13789661 100644
@@ -101,7 +101,6 @@ int da8xx_register_gpio(void *pdata);
 int da850_register_cpufreq(char *async_clk);
 int da8xx_register_cpuidle(void);
 void __iomem *da8xx_get_mem_ctlr(void);
-int da850_register_pm(struct platform_device *pdev);
 int da850_register_sata(unsigned long refclkpn);
 int da850_register_vpif(void);
 int da850_register_vpif_display
arch/arm/mach-davinci/pm.c +40 -27

95 lines not on this page · raw message

Signature · 1 line
2.9.3
Applied
#2 lore raw

PATCH v2 1/3 ARM: davinci: PM: rework init, support DT platforms

Quoted 26 lines · Kevin Hilman

Remove fake platform device used for PM init. Move pdata values which are common across all current platforms into pm.c.

Also, since PM is only used on da8xx, remove davinci_pm_init() from common init code, and only use in da850/omapl138 board files that are currently creating the fake platform_device.

arch/arm/mach-davinci/pm.c +3 -1
index 8929569b1f8a..3f1fb191c03f 100644
@@ -21,15 +21,23 @@
 
 #include <mach/common.h>
 #include <mach/da8xx.h>
-#include "sram.h"
+#include <mach/mux.h>
 #include <mach/pm.h>
 
 #include "clock.h"
+#include "psc.h"
+#include "sram.h"
 

arch/arm/mach-davinci/pm.c line 39

Quoted 10 lines
arch/arm/mach-davinci/pm.c +6 -1
+#define DA850_PLL1_BASE		0x01e1a000
 #define DEEPSLEEP_SLEEPCOUNT_MASK	0xFFFF
+#define DEEPSLEEP_SLEEPCOUNT		128
 
 static void (*davinci_sram_suspend) (struct davinci_pm_config *);
-static struct davinci_pm_config *pdata;
+static struct davinci_pm_config pm_config = {
+	.sleepcount = DEEPSLEEP_SLEEPCOUNT,
+	.ddrpsc_num = DA8XX_LPSC1_EMIF3C,
+};

I added an empty line here while applying. This was pointed to by checkpatch --strict

arch/arm/mach-davinci/pm.c line 40

Quoted 1 line
arch/arm/mach-davinci/pm.c +1 -0
+static struct davinci_pm_config *pdata = &pm_config;

And also adjusted the subject line since there is no DT support being added in this patch anymore. New subject line:

ARM: davinci: PM: rework init, remove platform device

Applied to v4.10/cleanup

Thanks,
Sekhar

#3 lore raw

PATCH v2 2/3 ARM: davinci: PM: cleanup: remove references to pdata

In reply to Kevin Hilman

Since the PM core code is no longer using a fake platform_device or platform_data, remove references to 'pdata'.

No functional changes.

---
 arch/arm/mach-davinci/pm.c | 57 +++++++++++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 29 deletions(-)
arch/arm/mach-davinci/pm.c +28 -29
index 3f1fb191c03f..0afd201ab980 100644
@@ -37,7 +37,6 @@ static struct davinci_pm_config pm_config = {
 	.sleepcount = DEEPSLEEP_SLEEPCOUNT,
 	.ddrpsc_num = DA8XX_LPSC1_EMIF3C,
 };
-static struct davinci_pm_config *pdata = &pm_config;
 
 static void davinci_sram_push(void *dest, void *src, unsigned int size)
 {
@@ -49,58 +48,58 @@ static void davinci_pm_suspend(void)
 {
 	unsigned val;
 
-	if (pdata->cpupll_reg_base != pdata->ddrpll_reg_base) {
+	if (pm_config.cpupll_reg_base != pm_config.ddrpll_reg_base) {
 
 		/* Switch CPU PLL to bypass mode */
-		val = __raw_readl(pdata->cpupll_reg_base + PLLCTL);
+		val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
 		val &= ~(PLLCTL_PLLENSRC | PLLCTL_PLLEN);
-		__raw_writel(val, pdata->cpupll_reg_base + PLLCTL);
+		__raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
 
 		udelay(PLL_BYPASS_TIME);
 
 		/* Powerdown CPU PLL */
-		val = __raw_readl(pdata->cpupll_reg_base + PLLCTL);
+		val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
 		val |= PLLCTL_PLLPWRDN;
-		__raw_writel(val, pdata->cpupll_reg_base + PLLCTL);
+		__raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
 	}
 
 	/* Configure sleep count in deep sleep register */
-	val = __raw_readl(pdata->deepsleep_reg);
+	val = __raw_readl(pm_config.deepsleep_reg);
 	val &= ~DEEPSLEEP_SLEEPCOUNT_MASK,
-	val |= pdata->sleepcount;
-	__raw_writel(val, pdata->deepsleep_reg);
+	val |= pm_config.sleepcount;
+	__raw_writel(val, pm_config.deepsleep_reg);
 
 	/* System goes to sleep in this call */
-	davinci_sram_suspend(pdata);
+	davinci_sram_suspend(&pm_config);
 
-	if (pdata->cpupll_reg_base != pdata->ddrpll_reg_base) {
+	if (pm_config.cpupll_reg_base != pm_config.ddrpll_reg_base) {
 
 		/* put CPU PLL in reset */
-		val = __raw_readl(pdata->cpupll_reg_base + PLLCTL);
+		val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
 		val &= ~PLLCTL_PLLRST;
-		__raw_writel(val, pdata->cpupll_reg_base + PLLCTL);
+		__raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
 
 		/* put CPU PLL in power down */
-		val = __raw_readl(pdata->cpupll_reg_base + PLLCTL);
+		val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
 		val &= ~PLLCTL_PLLPWRDN;
-		__raw_writel(val, pdata->cpupll_reg_base + PLLCTL);
+		__raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
 
 		/* wait for CPU PLL reset */
 		udelay(PLL_RESET_TIME);
 
 		/* bring CPU PLL out of reset */
-		val = __raw_readl(pdata->cpupll_reg_base + PLLCTL);
+		val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
 		val |= PLLCTL_PLLRST;
-		__raw_writel(val, pdata->cpupll_reg_base + PLLCTL);
+		__raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
 
 		/* Wait for CPU PLL to lock */
 		udelay(PLL_LOCK_TIME);
 
 		/* Remove CPU PLL from bypass mode */
-		val = __raw_readl(pdata->cpupll_reg_base + PLLCTL);
+		val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
 		val &= ~PLLCTL_PLLENSRC;
 		val |= PLLCTL_PLLEN;
-		__raw_writel(val, pdata->cpupll_reg_base + PLLCTL);
+		__raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
 	}
 }
 
@@ -133,21 +132,21 @@ int __init davinci_pm_init(void)
 	if (ret)
 		return ret;
 
-	pdata->ddr2_ctlr_base = da8xx_get_mem_ctlr();
-	pdata->deepsleep_reg = DA8XX_SYSCFG1_VIRT(DA8XX_DEEPSLEEP_REG);
+	pm_config.ddr2_ctlr_base = da8xx_get_mem_ctlr();
+	pm_config.deepsleep_reg = DA8XX_SYSCFG1_VIRT(DA8XX_DEEPSLEEP_REG);
 
-	pdata->cpupll_reg_base = ioremap(DA8XX_PLL0_BASE, SZ_4K);
-	if (!pdata->cpupll_reg_base)
+	pm_config.cpupll_reg_base = ioremap(DA8XX_PLL0_BASE, SZ_4K);
+	if (!pm_config.cpupll_reg_base)
 		return -ENOMEM;
 
-	pdata->ddrpll_reg_base = ioremap(DA850_PLL1_BASE, SZ_4K);
-	if (!pdata->ddrpll_reg_base) {
+	pm_config.ddrpll_reg_base = ioremap(DA850_PLL1_BASE, SZ_4K);
+	if (!pm_config.ddrpll_reg_base) {
 		ret = -ENOMEM;
 		goto no_ddrpll_mem;
 	}
 
-	pdata->ddrpsc_reg_base = ioremap(DA8XX_PSC1_BASE, SZ_4K);
-	if (!pdata->ddrpsc_reg_base) {
+	pm_config.ddrpsc_reg_base = ioremap(DA8XX_PSC1_BASE, SZ_4K);
+	if (!pm_config.ddrpsc_reg_base) {
 		ret = -ENOMEM;
 		goto no_ddrpsc_mem;
 	}
@@ -164,8 +163,8 @@ int __init davinci_pm_init(void)
 	suspend_set_ops(&davinci_pm_ops);
 
 no_ddrpsc_mem:
-	iounmap(pdata->ddrpll_reg_base);
+	iounmap(pm_config.ddrpll_reg_base);
 no_ddrpll_mem:
-	iounmap(pdata->cpupll_reg_base);
+	iounmap(pm_config.cpupll_reg_base);
 	return ret;
 }
Signature · 1 line
2.9.3
Applied
#4 lore raw

PATCH v2 2/3 ARM: davinci: PM: cleanup: remove references to pdata

Quoted 6 lines · Kevin Hilman

Since the PM core code is no longer using a fake platform_device or platform_data, remove references to 'pdata'.

No functional changes.

Applied to v4.10/cleanup

Thanks,
Sekhar

#5 lore raw

PATCH v2 3/3 ARM: davinci: PM: support da8xx DT platforms

In reply to Kevin Hilman
---
 arch/arm/mach-davinci/da8xx-dt.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-davinci/da8xx-dt.c +1 -0
index c9f7e9274aa8..aed44dcdfd30 100644
@@ -46,6 +46,7 @@ static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = {
 static void __init da850_init_machine(void)
 {
 	of_platform_default_populate(NULL, da850_auxdata_lookup, NULL);
+	davinci_pm_init();
 }
 
 static const char *const da850_boards_compat[] __initconst = {
Signature · 1 line
2.9.3
Applied
#6 lore raw

PATCH v2 3/3 ARM: davinci: PM: support da8xx DT platforms

Quoted 1 line · Kevin Hilman

Added a one line description which is essentially a copy of subject line.

Applied to v4.10/soc

Thanks,
Sekhar

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

v2 cover ARM: davinci: PM: cleanup init, add DT support

Quoted 11 lines · Sekhar Nori

Hi Kevin,

Quoted 5 lines · Kevin Hilman

This series removes the fake platform_device used to initialize PM on legacy davinci platforms, and also adds PM support for DT platforms.

Tested with legacy boot on da850-evm, and DT boot on da850-lcdk. Used RTC to wake from suspend-to-RAM: e.g. rtcwake -m mem -s 4 -d /dev/rtc0

With these patches applied, I saw the following randconfig build error.

Quoted 8 lines

arch/arm/mach-davinci/built-in.o: In function `davinci_pm_init':
pm_domain.c:(.init.text+0x13d8): undefined reference to da8xx_get_mem_ctlr' pm_domain.c:(.init.text+0x14bc): undefined reference to da8xx_syscfg1_base'
make: *** [vmlinux] Error 1

Attached is the defconfig. I did not check to see if your patches introduced it or if this is something that always existed and never caught.

It looks like a new problem caused by moving those calls into pm.c.

The problem is that currently pm.o can be built even when da850 support is not enabled, which is the case in your defconfig.

I'll hae a look at how to cleanup that dependency.

Kevin