ARM: davinci: cleanup and rework PM initializaion
Subsystems (3)
cover ARM: davinci: cleanup and rework PM initializaion
This series removes the fake platform_device used to initialize PM on legacy davinci platforms, and adds PM support for DT platforms.
Sekhar: the 2nd patch should probably be squashed into the first upon approval, but was kept separated in order to make the functional changes in the first patch more readable.
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
Kevin Hilman (2):
ARM: davinci: PM: rework init, support DT platforms
ARM: davinci: PM: rework init: cleanup
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 | 99 +++++++++++++++++------------- 7 files changed, 58 insertions(+), 115 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/2 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 add PM support for DT platforms (vi da8xx-dt.c)
--- 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 | 64 ++++++++++++++++++------------ 7 files changed, 41 insertions(+), 97 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +1 -16
@@ -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
@@ -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
@@ -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
@@ -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/da8xx-dt.c +1 -0
@@ -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 = {
arch/arm/mach-davinci/include/mach/da8xx.h +0 -1
@@ -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 +38 -26
91 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 1/2 ARM: davinci: PM: rework init, support DT platforms
Hi Kevin,
Looks good to me overall, I have some minor comments.
Quoted 4 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 add PM support for DT platforms (vi
da8xx-dt.c)
Can you please separate out PM enabling on DT platform to a separate patch? Its a small change, but it will be nice to separate it from rest of the cleanup.
Quoted 17 lines
arch/arm/mach-davinci/include/mach/da8xx.h +0
-1@@ -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_displayarch/arm/mach-davinci/pm.c +0
-0
arch/arm/mach-davinci/pm.c line 26
Quoted 4 lines
arch/arm/mach-davinci/pm.c +1
-0@@ -23,13 +23,18 @@#include <mach/da8xx.h> #include "sram.h" #include <mach/pm.h> +#include <mach/mux.h>
Can you please add the mux.h inclusion above pm.h? Looks like the sram.h inclusion is out of place already, but since you are touching this part, can you please move it below along with rest of the local includes.
I see that linux/ includes are not sorted as well, but lets keep that aside until someone needs to touch them.
Quoted 25 lines
arch/arm/mach-davinci/pm.c +6
-6#include "clock.h" +#include "psc.h" +#define DA850_PLL1_BASE 0x01e1a000#define DEEPSLEEP_SLEEPCOUNT_MASK 0xFFFF +#define DEEPSLEEP_SLEEPCOUNT 128static void (*davinci_sram_suspend) (struct davinci_pm_config *); -static struct davinci_pm_config *pdata; +static struct davinci_pm_config pm_config; +static struct davinci_pm_config *pdata = &pm_config;static void davinci_sram_push (void *dest,void *src,unsigned int size) {@@ -117,17 +122,38 @@ static const struct platform_suspend_ops davinci_pm_ops = { .valid = suspend_valid_only_mem, }; -static int __init davinci_pm_probe (struct platform_device *pdev) +int __init davinci_pm_init (void ) { - pdata = pdev->dev.platform_data; -if (!pdata) { -dev_err (&pdev->dev,"cannot get platform data\n" ); -return -ENOENT ;
arch/arm/mach-davinci/pm.c static const struct platform_suspend_ops davinci_pm_ops = { · line 136
Quoted 10 lines
arch/arm/mach-davinci/pm.c +10
-0+int ret; + + ret =davinci_cfg_reg (DA850_RTC_ALARM ); +if (ret) +return ret; + + pdata->sleepcount =DEEPSLEEP_SLEEPCOUNT ; + pdata->ddr2_ctlr_base =da8xx_get_mem_ctlr (); + pdata->deepsleep_reg =DA8XX_SYSCFG1_VIRT (DA8XX_DEEPSLEEP_REG ); + pdata->ddrpsc_num =DA8XX_LPSC1_EMIF3C ;
Some of these could be statically initialized in pm_config. Can you please move the constants to static initialization.
Thanks,
Sekhar
PATCH 1/2 ARM: davinci: PM: rework init, support DT platforms
Quoted 5 lines · Sekhar Nori
Hi Kevin,
Looks good to me overall, I have some minor comments.
On Tuesday 15 November 2016 04:34 AM, Kevin Hilman wrote:
Quoted 8 lines
Quoted 4 lines
Remove fake platform device used for PM init. Move pdata values which are common across all current platforms into
pm.c.Also add PM support for DT platforms (vi
da8xx-dt.c)Can you please separate out PM enabling on DT platform to a separate patch? Its a small change, but it will be nice to separate it from rest of the cleanup.
Yes, will do.
Quoted 59 lines
Quoted 17 lines
arch/arm/mach-davinci/include/mach/da8xx.h +0
-1@@ -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_displayarch/arm/mach-davinci/pm.c +0
-0arch/arm/mach-davinci/pm.c line 26
Quoted 4 lines
arch/arm/mach-davinci/pm.c +1
-0@@ -23,13 +23,18 @@#include <mach/da8xx.h> #include "sram.h" #include <mach/pm.h> +#include <mach/mux.h> Can you please add the
mux.hinclusion abovepm.h? Looks like thesram.hinclusion is out of place already, but since you are touching this part, can you please move it below along with rest of the local includes.I see that linux/ includes are not sorted as well, but lets keep that aside until someone needs to touch them.
Quoted 30 lines
arch/arm/mach-davinci/pm.c +11
-6#include "clock.h" +#include "psc.h" +#define DA850_PLL1_BASE 0x01e1a000#define DEEPSLEEP_SLEEPCOUNT_MASK 0xFFFF +#define DEEPSLEEP_SLEEPCOUNT 128static void (*davinci_sram_suspend) (struct davinci_pm_config *); -static struct davinci_pm_config *pdata; +static struct davinci_pm_config pm_config; +static struct davinci_pm_config *pdata = &pm_config;static void davinci_sram_push (void *dest,void *src,unsigned int size) {@@ -117,17 +122,38 @@ static const struct platform_suspend_ops davinci_pm_ops = { .valid = suspend_valid_only_mem, }; -static int __init davinci_pm_probe (struct platform_device *pdev) +int __init davinci_pm_init (void ) { - pdata = pdev->dev.platform_data; -if (!pdata) { -dev_err (&pdev->dev,"cannot get platform data\n" ); -return -ENOENT ; +int ret; + + ret =davinci_cfg_reg (DA850_RTC_ALARM ); +if (ret) +return ret;
Quoted 8 lines
arch/arm/mach-davinci/pm.c static const struct platform_suspend_ops davinci_pm_ops = { · line 136
Quoted 5 lines
arch/arm/mach-davinci/pm.c +5
-0+ + pdata->sleepcount =DEEPSLEEP_SLEEPCOUNT ; + pdata->ddr2_ctlr_base =da8xx_get_mem_ctlr (); + pdata->deepsleep_reg =DA8XX_SYSCFG1_VIRT (DA8XX_DEEPSLEEP_REG ); + pdata->ddrpsc_num =DA8XX_LPSC1_EMIF3C ;Some of these could be statically initialized in
pm_config. Can you please move the constants to static initialization.
Yes.
Kevin
PATCH 2/2 ARM: davinci: PM: rework init: cleanup
In reply to Kevin HilmanA follow-on cleanup renaming 'pdata' since it is no longer platform_data.
--- arch/arm/mach-davinci/pm.c | 61 +++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 31 deletions(-)
arch/arm/mach-davinci/pm.c +30 -31
@@ -34,7 +34,6 @@static void (*davinci_sram_suspend) (struct davinci_pm_config *);static struct davinci_pm_config pm_config; -static struct davinci_pm_config *pdata = &pm_config;static void davinci_sram_push (void *dest,void *src,unsigned int size) {
@@ -46,58 +45,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 ); } }
@@ -130,23 +129,23 @@ int __init davinci_pm_init(void)if (ret)return ret; - pdata->sleepcount =DEEPSLEEP_SLEEPCOUNT ; - pdata->ddr2_ctlr_base =da8xx_get_mem_ctlr (); - pdata->deepsleep_reg =DA8XX_SYSCFG1_VIRT (DA8XX_DEEPSLEEP_REG ); - pdata->ddrpsc_num =DA8XX_LPSC1_EMIF3C ; + pm_config.sleepcount =DEEPSLEEP_SLEEPCOUNT ; + pm_config.ddr2_ctlr_base =da8xx_get_mem_ctlr (); + pm_config.deepsleep_reg =DA8XX_SYSCFG1_VIRT (DA8XX_DEEPSLEEP_REG ); + pm_config.ddrpsc_num =DA8XX_LPSC1_EMIF3C ; - 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; }
@@ -163,8 +162,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
PATCH 2/2 ARM: davinci: PM: rework init: cleanup
Quoted 4 lines · Kevin Hilman
A follow-on cleanup renaming 'pdata' since it is no longer
platform_data.Signed-off-by Kevin Hilman <[email protected]>
Looks good to me. Thanks for separating this out. Makes it much easier to review.
In the subject line though, instead of just calling it cleanup, how about a bit more descriptive statement like "remove references to pdata".
Thanks,
Sekhar
PATCH 2/2 ARM: davinci: PM: rework init: cleanup
Quoted 11 lines · Sekhar Nori
Quoted 4 lines · Kevin Hilman
A follow-on cleanup renaming 'pdata' since it is no longer
platform_data.Signed-off-by Kevin Hilman <[email protected]>Looks good to me. Thanks for separating this out. Makes it much easier to review.
In the subject line though, instead of just calling it cleanup, how about a bit more descriptive statement like "remove references to pdata".
Sure. respin coming right up.
Kevin