aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-11-30 08:45:31 -0500
committerArnd Bergmann <arnd@arndb.de>2016-11-30 08:45:31 -0500
commite264ae280ce178c2da6ddf77c9a7928c6d3b6caa (patch)
treee11c0d154382a429b819346e20302116258c8331
parente70a13e7d771289589131890a64762da56990656 (diff)
parentf7715b299954b1f1644253682e50f38282eee611 (diff)
Merge tag 'davinci-for-v4.10/cleanup-2' of git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci into next/soc
Pull DaVinci cleanup for v4.10 from Sekhar Nori: mach-davinci cleanup to make it easy to add PM support for DT-boot. * tag 'davinci-for-v4.10/cleanup-2' of git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci: ARM: davinci: PM: fix build when da850 not compiled in ARM: davinci: PM: cleanup: remove references to pdata ARM: davinci: PM: rework init, remove platform device
-rw-r--r--arch/arm/mach-davinci/Makefile4
-rw-r--r--arch/arm/mach-davinci/board-da850-evm.c17
-rw-r--r--arch/arm/mach-davinci/board-mityomapl138.c16
-rw-r--r--arch/arm/mach-davinci/common.c1
-rw-r--r--arch/arm/mach-davinci/da850.c38
-rw-r--r--arch/arm/mach-davinci/include/mach/da8xx.h1
-rw-r--r--arch/arm/mach-davinci/pm.c102
7 files changed, 62 insertions, 117 deletions
diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
index da4c336b4637..0a2e6da45f28 100644
--- a/arch/arm/mach-davinci/Makefile
+++ b/arch/arm/mach-davinci/Makefile
@@ -36,5 +36,7 @@ obj-$(CONFIG_MACH_OMAPL138_HAWKBOARD) += board-omapl138-hawk.o
36 36
37# Power Management 37# Power Management
38obj-$(CONFIG_CPU_IDLE) += cpuidle.o 38obj-$(CONFIG_CPU_IDLE) += cpuidle.o
39obj-$(CONFIG_SUSPEND) += pm.o sleep.o
40obj-$(CONFIG_HAVE_CLK) += pm_domain.o 39obj-$(CONFIG_HAVE_CLK) += pm_domain.o
40ifeq ($(CONFIG_SUSPEND),y)
41obj-$(CONFIG_ARCH_DAVINCI_DA850) += pm.o sleep.o
42endif
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index ec5cb105e1d6..265abe7dd77c 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -196,18 +196,6 @@ static struct platform_device da850_evm_norflash_device = {
196 .resource = da850_evm_norflash_resource, 196 .resource = da850_evm_norflash_resource,
197}; 197};
198 198
199static struct davinci_pm_config da850_pm_pdata = {
200 .sleepcount = 128,
201};
202
203static struct platform_device da850_pm_device = {
204 .name = "pm-davinci",
205 .dev = {
206 .platform_data = &da850_pm_pdata,
207 },
208 .id = -1,
209};
210
211/* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash 199/* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
212 * (128K blocks). It may be used instead of the (default) SPI flash 200 * (128K blocks). It may be used instead of the (default) SPI flash
213 * to boot, using TI's tools to install the secondary boot loader 201 * to boot, using TI's tools to install the secondary boot loader
@@ -1457,10 +1445,7 @@ static __init void da850_evm_init(void)
1457 if (ret) 1445 if (ret)
1458 pr_warn("%s: cpuidle registration failed: %d\n", __func__, ret); 1446 pr_warn("%s: cpuidle registration failed: %d\n", __func__, ret);
1459 1447
1460 ret = da850_register_pm(&da850_pm_device); 1448 davinci_pm_init();
1461 if (ret)
1462 pr_warn("%s: suspend registration failed: %d\n", __func__, ret);
1463
1464 da850_vpif_init(); 1449 da850_vpif_init();
1465 1450
1466 ret = spi_register_board_info(da850evm_spi_info, 1451 ret = spi_register_board_info(da850evm_spi_info,
diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c
index 1a6d430742d4..b73ce7bae81f 100644
--- a/arch/arm/mach-davinci/board-mityomapl138.c
+++ b/arch/arm/mach-davinci/board-mityomapl138.c
@@ -498,18 +498,6 @@ static void __init mityomapl138_config_emac(void)
498 pr_warn("emac registration failed: %d\n", ret); 498 pr_warn("emac registration failed: %d\n", ret);
499} 499}
500 500
501static struct davinci_pm_config da850_pm_pdata = {
502 .sleepcount = 128,
503};
504
505static struct platform_device da850_pm_device = {
506 .name = "pm-davinci",
507 .dev = {
508 .platform_data = &da850_pm_pdata,
509 },
510 .id = -1,
511};
512
513static void __init mityomapl138_init(void) 501static void __init mityomapl138_init(void)
514{ 502{
515 int ret; 503 int ret;
@@ -559,9 +547,7 @@ static void __init mityomapl138_init(void)
559 if (ret) 547 if (ret)
560 pr_warn("cpuidle registration failed: %d\n", ret); 548 pr_warn("cpuidle registration failed: %d\n", ret);
561 549
562 ret = da850_register_pm(&da850_pm_device); 550 davinci_pm_init();
563 if (ret)
564 pr_warn("suspend registration failed: %d\n", ret);
565} 551}
566 552
567#ifdef CONFIG_SERIAL_8250_CONSOLE 553#ifdef CONFIG_SERIAL_8250_CONSOLE
diff --git a/arch/arm/mach-davinci/common.c b/arch/arm/mach-davinci/common.c
index 049025f6d531..9f9fbfa6da0d 100644
--- a/arch/arm/mach-davinci/common.c
+++ b/arch/arm/mach-davinci/common.c
@@ -118,6 +118,5 @@ err:
118void __init davinci_init_late(void) 118void __init davinci_init_late(void)
119{ 119{
120 davinci_cpufreq_init(); 120 davinci_cpufreq_init();
121 davinci_pm_init();
122 davinci_clk_disable_unused(); 121 davinci_clk_disable_unused();
123} 122}
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 196e262b7147..512ccc19e4e1 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -1172,44 +1172,6 @@ static int da850_round_armrate(struct clk *clk, unsigned long rate)
1172} 1172}
1173#endif 1173#endif
1174 1174
1175int __init da850_register_pm(struct platform_device *pdev)
1176{
1177 int ret;
1178 struct davinci_pm_config *pdata = pdev->dev.platform_data;
1179
1180 ret = davinci_cfg_reg(DA850_RTC_ALARM);
1181 if (ret)
1182 return ret;
1183
1184 pdata->ddr2_ctlr_base = da8xx_get_mem_ctlr();
1185 pdata->deepsleep_reg = DA8XX_SYSCFG1_VIRT(DA8XX_DEEPSLEEP_REG);
1186 pdata->ddrpsc_num = DA8XX_LPSC1_EMIF3C;
1187
1188 pdata->cpupll_reg_base = ioremap(DA8XX_PLL0_BASE, SZ_4K);
1189 if (!pdata->cpupll_reg_base)
1190 return -ENOMEM;
1191
1192 pdata->ddrpll_reg_base = ioremap(DA850_PLL1_BASE, SZ_4K);
1193 if (!pdata->ddrpll_reg_base) {
1194 ret = -ENOMEM;
1195 goto no_ddrpll_mem;
1196 }
1197
1198 pdata->ddrpsc_reg_base = ioremap(DA8XX_PSC1_BASE, SZ_4K);
1199 if (!pdata->ddrpsc_reg_base) {
1200 ret = -ENOMEM;
1201 goto no_ddrpsc_mem;
1202 }
1203
1204 return platform_device_register(pdev);
1205
1206no_ddrpsc_mem:
1207 iounmap(pdata->ddrpll_reg_base);
1208no_ddrpll_mem:
1209 iounmap(pdata->cpupll_reg_base);
1210 return ret;
1211}
1212
1213/* VPIF resource, platform data */ 1175/* VPIF resource, platform data */
1214static u64 da850_vpif_dma_mask = DMA_BIT_MASK(32); 1176static u64 da850_vpif_dma_mask = DMA_BIT_MASK(32);
1215 1177
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h
index 43322be26bd5..85ff2183b6db 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -106,7 +106,6 @@ int da8xx_register_gpio(void *pdata);
106int da850_register_cpufreq(char *async_clk); 106int da850_register_cpufreq(char *async_clk);
107int da8xx_register_cpuidle(void); 107int da8xx_register_cpuidle(void);
108void __iomem *da8xx_get_mem_ctlr(void); 108void __iomem *da8xx_get_mem_ctlr(void);
109int da850_register_pm(struct platform_device *pdev);
110int da850_register_sata(unsigned long refclkpn); 109int da850_register_sata(unsigned long refclkpn);
111int da850_register_vpif(void); 110int da850_register_vpif(void);
112int da850_register_vpif_display 111int da850_register_vpif_display
diff --git a/arch/arm/mach-davinci/pm.c b/arch/arm/mach-davinci/pm.c
index 8929569b1f8a..0afd201ab980 100644
--- a/arch/arm/mach-davinci/pm.c
+++ b/arch/arm/mach-davinci/pm.c
@@ -21,15 +21,22 @@
21 21
22#include <mach/common.h> 22#include <mach/common.h>
23#include <mach/da8xx.h> 23#include <mach/da8xx.h>
24#include "sram.h" 24#include <mach/mux.h>
25#include <mach/pm.h> 25#include <mach/pm.h>
26 26
27#include "clock.h" 27#include "clock.h"
28#include "psc.h"
29#include "sram.h"
28 30
31#define DA850_PLL1_BASE 0x01e1a000
29#define DEEPSLEEP_SLEEPCOUNT_MASK 0xFFFF 32#define DEEPSLEEP_SLEEPCOUNT_MASK 0xFFFF
33#define DEEPSLEEP_SLEEPCOUNT 128
30 34
31static void (*davinci_sram_suspend) (struct davinci_pm_config *); 35static void (*davinci_sram_suspend) (struct davinci_pm_config *);
32static struct davinci_pm_config *pdata; 36static struct davinci_pm_config pm_config = {
37 .sleepcount = DEEPSLEEP_SLEEPCOUNT,
38 .ddrpsc_num = DA8XX_LPSC1_EMIF3C,
39};
33 40
34static void davinci_sram_push(void *dest, void *src, unsigned int size) 41static void davinci_sram_push(void *dest, void *src, unsigned int size)
35{ 42{
@@ -41,58 +48,58 @@ static void davinci_pm_suspend(void)
41{ 48{
42 unsigned val; 49 unsigned val;
43 50
44 if (pdata->cpupll_reg_base != pdata->ddrpll_reg_base) { 51 if (pm_config.cpupll_reg_base != pm_config.ddrpll_reg_base) {
45 52
46 /* Switch CPU PLL to bypass mode */ 53 /* Switch CPU PLL to bypass mode */
47 val = __raw_readl(pdata->cpupll_reg_base + PLLCTL); 54 val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
48 val &= ~(PLLCTL_PLLENSRC | PLLCTL_PLLEN); 55 val &= ~(PLLCTL_PLLENSRC | PLLCTL_PLLEN);
49 __raw_writel(val, pdata->cpupll_reg_base + PLLCTL); 56 __raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
50 57
51 udelay(PLL_BYPASS_TIME); 58 udelay(PLL_BYPASS_TIME);
52 59
53 /* Powerdown CPU PLL */ 60 /* Powerdown CPU PLL */
54 val = __raw_readl(pdata->cpupll_reg_base + PLLCTL); 61 val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
55 val |= PLLCTL_PLLPWRDN; 62 val |= PLLCTL_PLLPWRDN;
56 __raw_writel(val, pdata->cpupll_reg_base + PLLCTL); 63 __raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
57 } 64 }
58 65
59 /* Configure sleep count in deep sleep register */ 66 /* Configure sleep count in deep sleep register */
60 val = __raw_readl(pdata->deepsleep_reg); 67 val = __raw_readl(pm_config.deepsleep_reg);
61 val &= ~DEEPSLEEP_SLEEPCOUNT_MASK, 68 val &= ~DEEPSLEEP_SLEEPCOUNT_MASK,
62 val |= pdata->sleepcount; 69 val |= pm_config.sleepcount;
63 __raw_writel(val, pdata->deepsleep_reg); 70 __raw_writel(val, pm_config.deepsleep_reg);
64 71
65 /* System goes to sleep in this call */ 72 /* System goes to sleep in this call */
66 davinci_sram_suspend(pdata); 73 davinci_sram_suspend(&pm_config);
67 74
68 if (pdata->cpupll_reg_base != pdata->ddrpll_reg_base) { 75 if (pm_config.cpupll_reg_base != pm_config.ddrpll_reg_base) {
69 76
70 /* put CPU PLL in reset */ 77 /* put CPU PLL in reset */
71 val = __raw_readl(pdata->cpupll_reg_base + PLLCTL); 78 val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
72 val &= ~PLLCTL_PLLRST; 79 val &= ~PLLCTL_PLLRST;
73 __raw_writel(val, pdata->cpupll_reg_base + PLLCTL); 80 __raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
74 81
75 /* put CPU PLL in power down */ 82 /* put CPU PLL in power down */
76 val = __raw_readl(pdata->cpupll_reg_base + PLLCTL); 83 val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
77 val &= ~PLLCTL_PLLPWRDN; 84 val &= ~PLLCTL_PLLPWRDN;
78 __raw_writel(val, pdata->cpupll_reg_base + PLLCTL); 85 __raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
79 86
80 /* wait for CPU PLL reset */ 87 /* wait for CPU PLL reset */
81 udelay(PLL_RESET_TIME); 88 udelay(PLL_RESET_TIME);
82 89
83 /* bring CPU PLL out of reset */ 90 /* bring CPU PLL out of reset */
84 val = __raw_readl(pdata->cpupll_reg_base + PLLCTL); 91 val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
85 val |= PLLCTL_PLLRST; 92 val |= PLLCTL_PLLRST;
86 __raw_writel(val, pdata->cpupll_reg_base + PLLCTL); 93 __raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
87 94
88 /* Wait for CPU PLL to lock */ 95 /* Wait for CPU PLL to lock */
89 udelay(PLL_LOCK_TIME); 96 udelay(PLL_LOCK_TIME);
90 97
91 /* Remove CPU PLL from bypass mode */ 98 /* Remove CPU PLL from bypass mode */
92 val = __raw_readl(pdata->cpupll_reg_base + PLLCTL); 99 val = __raw_readl(pm_config.cpupll_reg_base + PLLCTL);
93 val &= ~PLLCTL_PLLENSRC; 100 val &= ~PLLCTL_PLLENSRC;
94 val |= PLLCTL_PLLEN; 101 val |= PLLCTL_PLLEN;
95 __raw_writel(val, pdata->cpupll_reg_base + PLLCTL); 102 __raw_writel(val, pm_config.cpupll_reg_base + PLLCTL);
96 } 103 }
97} 104}
98 105
@@ -117,17 +124,36 @@ static const struct platform_suspend_ops davinci_pm_ops = {
117 .valid = suspend_valid_only_mem, 124 .valid = suspend_valid_only_mem,
118}; 125};
119 126
120static int __init davinci_pm_probe(struct platform_device *pdev) 127int __init davinci_pm_init(void)
121{ 128{
122 pdata = pdev->dev.platform_data; 129 int ret;
123 if (!pdata) { 130
124 dev_err(&pdev->dev, "cannot get platform data\n"); 131 ret = davinci_cfg_reg(DA850_RTC_ALARM);
125 return -ENOENT; 132 if (ret)
133 return ret;
134
135 pm_config.ddr2_ctlr_base = da8xx_get_mem_ctlr();
136 pm_config.deepsleep_reg = DA8XX_SYSCFG1_VIRT(DA8XX_DEEPSLEEP_REG);
137
138 pm_config.cpupll_reg_base = ioremap(DA8XX_PLL0_BASE, SZ_4K);
139 if (!pm_config.cpupll_reg_base)
140 return -ENOMEM;
141
142 pm_config.ddrpll_reg_base = ioremap(DA850_PLL1_BASE, SZ_4K);
143 if (!pm_config.ddrpll_reg_base) {
144 ret = -ENOMEM;
145 goto no_ddrpll_mem;
146 }
147
148 pm_config.ddrpsc_reg_base = ioremap(DA8XX_PSC1_BASE, SZ_4K);
149 if (!pm_config.ddrpsc_reg_base) {
150 ret = -ENOMEM;
151 goto no_ddrpsc_mem;
126 } 152 }
127 153
128 davinci_sram_suspend = sram_alloc(davinci_cpu_suspend_sz, NULL); 154 davinci_sram_suspend = sram_alloc(davinci_cpu_suspend_sz, NULL);
129 if (!davinci_sram_suspend) { 155 if (!davinci_sram_suspend) {
130 dev_err(&pdev->dev, "cannot allocate SRAM memory\n"); 156 pr_err("PM: cannot allocate SRAM memory\n");
131 return -ENOMEM; 157 return -ENOMEM;
132 } 158 }
133 159
@@ -136,23 +162,9 @@ static int __init davinci_pm_probe(struct platform_device *pdev)
136 162
137 suspend_set_ops(&davinci_pm_ops); 163 suspend_set_ops(&davinci_pm_ops);
138 164
139 return 0; 165no_ddrpsc_mem:
140} 166 iounmap(pm_config.ddrpll_reg_base);
141 167no_ddrpll_mem:
142static int __exit davinci_pm_remove(struct platform_device *pdev) 168 iounmap(pm_config.cpupll_reg_base);
143{ 169 return ret;
144 sram_free(davinci_sram_suspend, davinci_cpu_suspend_sz);
145 return 0;
146}
147
148static struct platform_driver davinci_pm_driver = {
149 .driver = {
150 .name = "pm-davinci",
151 },
152 .remove = __exit_p(davinci_pm_remove),
153};
154
155int __init davinci_pm_init(void)
156{
157 return platform_driver_probe(&davinci_pm_driver, davinci_pm_probe);
158} 170}