diff options
Diffstat (limited to 'arch/sh/kernel/cpu')
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/clock-sh7722.c | 6 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/clock-sh7723.c | 6 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/clock-sh7724.c | 8 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/setup-sh7722.c | 31 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/setup-sh7723.c | 40 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/setup-sh7724.c | 43 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/shmobile/Makefile | 1 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/shmobile/pm_runtime.c | 303 |
8 files changed, 428 insertions, 10 deletions
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c index 5b1bbbe63b1b..ea38b554dc05 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c | |||
@@ -164,11 +164,11 @@ static struct clk mstp_clks[] = { | |||
164 | SH_HWBLK_CLK("2dg0", -1, B_CLK, HWBLK_2DG, 0), | 164 | SH_HWBLK_CLK("2dg0", -1, B_CLK, HWBLK_2DG, 0), |
165 | SH_HWBLK_CLK("siu0", -1, B_CLK, HWBLK_SIU, 0), | 165 | SH_HWBLK_CLK("siu0", -1, B_CLK, HWBLK_SIU, 0), |
166 | SH_HWBLK_CLK("vou0", -1, B_CLK, HWBLK_VOU, 0), | 166 | SH_HWBLK_CLK("vou0", -1, B_CLK, HWBLK_VOU, 0), |
167 | SH_HWBLK_CLK("jpu0", -1, B_CLK, HWBLK_JPU, CLK_ENABLE_ON_INIT), | 167 | SH_HWBLK_CLK("jpu0", -1, B_CLK, HWBLK_JPU, 0), |
168 | SH_HWBLK_CLK("beu0", -1, B_CLK, HWBLK_BEU, 0), | 168 | SH_HWBLK_CLK("beu0", -1, B_CLK, HWBLK_BEU, 0), |
169 | SH_HWBLK_CLK("ceu0", -1, B_CLK, HWBLK_CEU, 0), | 169 | SH_HWBLK_CLK("ceu0", -1, B_CLK, HWBLK_CEU, 0), |
170 | SH_HWBLK_CLK("veu0", -1, B_CLK, HWBLK_VEU, CLK_ENABLE_ON_INIT), | 170 | SH_HWBLK_CLK("veu0", -1, B_CLK, HWBLK_VEU, 0), |
171 | SH_HWBLK_CLK("vpu0", -1, B_CLK, HWBLK_VPU, CLK_ENABLE_ON_INIT), | 171 | SH_HWBLK_CLK("vpu0", -1, B_CLK, HWBLK_VPU, 0), |
172 | SH_HWBLK_CLK("lcdc0", -1, P_CLK, HWBLK_LCDC, 0), | 172 | SH_HWBLK_CLK("lcdc0", -1, P_CLK, HWBLK_LCDC, 0), |
173 | }; | 173 | }; |
174 | 174 | ||
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c index e5c63911403c..20a31c2255a8 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c | |||
@@ -190,12 +190,12 @@ static struct clk mstp_clks[] = { | |||
190 | SH_HWBLK_CLK("usb0", -1, B_CLK, HWBLK_USB, 0), | 190 | SH_HWBLK_CLK("usb0", -1, B_CLK, HWBLK_USB, 0), |
191 | SH_HWBLK_CLK("2dg0", -1, B_CLK, HWBLK_2DG, 0), | 191 | SH_HWBLK_CLK("2dg0", -1, B_CLK, HWBLK_2DG, 0), |
192 | SH_HWBLK_CLK("siu0", -1, B_CLK, HWBLK_SIU, 0), | 192 | SH_HWBLK_CLK("siu0", -1, B_CLK, HWBLK_SIU, 0), |
193 | SH_HWBLK_CLK("veu1", -1, B_CLK, HWBLK_VEU2H1, CLK_ENABLE_ON_INIT), | 193 | SH_HWBLK_CLK("veu1", -1, B_CLK, HWBLK_VEU2H1, 0), |
194 | SH_HWBLK_CLK("vou0", -1, B_CLK, HWBLK_VOU, 0), | 194 | SH_HWBLK_CLK("vou0", -1, B_CLK, HWBLK_VOU, 0), |
195 | SH_HWBLK_CLK("beu0", -1, B_CLK, HWBLK_BEU, 0), | 195 | SH_HWBLK_CLK("beu0", -1, B_CLK, HWBLK_BEU, 0), |
196 | SH_HWBLK_CLK("ceu0", -1, B_CLK, HWBLK_CEU, 0), | 196 | SH_HWBLK_CLK("ceu0", -1, B_CLK, HWBLK_CEU, 0), |
197 | SH_HWBLK_CLK("veu0", -1, B_CLK, HWBLK_VEU2H0, CLK_ENABLE_ON_INIT), | 197 | SH_HWBLK_CLK("veu0", -1, B_CLK, HWBLK_VEU2H0, 0), |
198 | SH_HWBLK_CLK("vpu0", -1, B_CLK, HWBLK_VPU, CLK_ENABLE_ON_INIT), | 198 | SH_HWBLK_CLK("vpu0", -1, B_CLK, HWBLK_VPU, 0), |
199 | SH_HWBLK_CLK("lcdc0", -1, B_CLK, HWBLK_LCDC, 0), | 199 | SH_HWBLK_CLK("lcdc0", -1, B_CLK, HWBLK_LCDC, 0), |
200 | }; | 200 | }; |
201 | 201 | ||
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c index 627588dfddf0..dfe9192be63e 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c | |||
@@ -204,17 +204,17 @@ static struct clk mstp_clks[] = { | |||
204 | SH_HWBLK_CLK("2dg0", -1, B_CLK, HWBLK_2DG, 0), | 204 | SH_HWBLK_CLK("2dg0", -1, B_CLK, HWBLK_2DG, 0), |
205 | SH_HWBLK_CLK("sdhi0", -1, B_CLK, HWBLK_SDHI0, 0), | 205 | SH_HWBLK_CLK("sdhi0", -1, B_CLK, HWBLK_SDHI0, 0), |
206 | SH_HWBLK_CLK("sdhi1", -1, B_CLK, HWBLK_SDHI1, 0), | 206 | SH_HWBLK_CLK("sdhi1", -1, B_CLK, HWBLK_SDHI1, 0), |
207 | SH_HWBLK_CLK("veu1", -1, B_CLK, HWBLK_VEU1, CLK_ENABLE_ON_INIT), | 207 | SH_HWBLK_CLK("veu1", -1, B_CLK, HWBLK_VEU1, 0), |
208 | SH_HWBLK_CLK("ceu1", -1, B_CLK, HWBLK_CEU1, 0), | 208 | SH_HWBLK_CLK("ceu1", -1, B_CLK, HWBLK_CEU1, 0), |
209 | SH_HWBLK_CLK("beu1", -1, B_CLK, HWBLK_BEU1, 0), | 209 | SH_HWBLK_CLK("beu1", -1, B_CLK, HWBLK_BEU1, 0), |
210 | SH_HWBLK_CLK("2ddmac0", -1, SH_CLK, HWBLK_2DDMAC, 0), | 210 | SH_HWBLK_CLK("2ddmac0", -1, SH_CLK, HWBLK_2DDMAC, 0), |
211 | SH_HWBLK_CLK("spu0", -1, B_CLK, HWBLK_SPU, 0), | 211 | SH_HWBLK_CLK("spu0", -1, B_CLK, HWBLK_SPU, 0), |
212 | SH_HWBLK_CLK("jpu0", -1, B_CLK, HWBLK_JPU, CLK_ENABLE_ON_INIT), | 212 | SH_HWBLK_CLK("jpu0", -1, B_CLK, HWBLK_JPU, 0), |
213 | SH_HWBLK_CLK("vou0", -1, B_CLK, HWBLK_VOU, 0), | 213 | SH_HWBLK_CLK("vou0", -1, B_CLK, HWBLK_VOU, 0), |
214 | SH_HWBLK_CLK("beu0", -1, B_CLK, HWBLK_BEU0, 0), | 214 | SH_HWBLK_CLK("beu0", -1, B_CLK, HWBLK_BEU0, 0), |
215 | SH_HWBLK_CLK("ceu0", -1, B_CLK, HWBLK_CEU0, 0), | 215 | SH_HWBLK_CLK("ceu0", -1, B_CLK, HWBLK_CEU0, 0), |
216 | SH_HWBLK_CLK("veu0", -1, B_CLK, HWBLK_VEU0, CLK_ENABLE_ON_INIT), | 216 | SH_HWBLK_CLK("veu0", -1, B_CLK, HWBLK_VEU0, 0), |
217 | SH_HWBLK_CLK("vpu0", -1, B_CLK, HWBLK_VPU, CLK_ENABLE_ON_INIT), | 217 | SH_HWBLK_CLK("vpu0", -1, B_CLK, HWBLK_VPU, 0), |
218 | SH_HWBLK_CLK("lcdc0", -1, B_CLK, HWBLK_LCDC, 0), | 218 | SH_HWBLK_CLK("lcdc0", -1, B_CLK, HWBLK_LCDC, 0), |
219 | }; | 219 | }; |
220 | 220 | ||
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c index 67b0d87fcb27..35097753456c 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/sh_timer.h> | 17 | #include <linux/sh_timer.h> |
18 | #include <asm/clock.h> | 18 | #include <asm/clock.h> |
19 | #include <asm/mmzone.h> | 19 | #include <asm/mmzone.h> |
20 | #include <cpu/sh7722.h> | ||
20 | 21 | ||
21 | static struct resource rtc_resources[] = { | 22 | static struct resource rtc_resources[] = { |
22 | [0] = { | 23 | [0] = { |
@@ -46,6 +47,9 @@ static struct platform_device rtc_device = { | |||
46 | .id = -1, | 47 | .id = -1, |
47 | .num_resources = ARRAY_SIZE(rtc_resources), | 48 | .num_resources = ARRAY_SIZE(rtc_resources), |
48 | .resource = rtc_resources, | 49 | .resource = rtc_resources, |
50 | .archdata = { | ||
51 | .hwblk_id = HWBLK_RTC, | ||
52 | }, | ||
49 | }; | 53 | }; |
50 | 54 | ||
51 | static struct m66592_platdata usbf_platdata = { | 55 | static struct m66592_platdata usbf_platdata = { |
@@ -76,6 +80,9 @@ static struct platform_device usbf_device = { | |||
76 | }, | 80 | }, |
77 | .num_resources = ARRAY_SIZE(usbf_resources), | 81 | .num_resources = ARRAY_SIZE(usbf_resources), |
78 | .resource = usbf_resources, | 82 | .resource = usbf_resources, |
83 | .archdata = { | ||
84 | .hwblk_id = HWBLK_USBF, | ||
85 | }, | ||
79 | }; | 86 | }; |
80 | 87 | ||
81 | static struct resource iic_resources[] = { | 88 | static struct resource iic_resources[] = { |
@@ -97,6 +104,9 @@ static struct platform_device iic_device = { | |||
97 | .id = 0, /* "i2c0" clock */ | 104 | .id = 0, /* "i2c0" clock */ |
98 | .num_resources = ARRAY_SIZE(iic_resources), | 105 | .num_resources = ARRAY_SIZE(iic_resources), |
99 | .resource = iic_resources, | 106 | .resource = iic_resources, |
107 | .archdata = { | ||
108 | .hwblk_id = HWBLK_IIC, | ||
109 | }, | ||
100 | }; | 110 | }; |
101 | 111 | ||
102 | static struct uio_info vpu_platform_data = { | 112 | static struct uio_info vpu_platform_data = { |
@@ -125,6 +135,9 @@ static struct platform_device vpu_device = { | |||
125 | }, | 135 | }, |
126 | .resource = vpu_resources, | 136 | .resource = vpu_resources, |
127 | .num_resources = ARRAY_SIZE(vpu_resources), | 137 | .num_resources = ARRAY_SIZE(vpu_resources), |
138 | .archdata = { | ||
139 | .hwblk_id = HWBLK_VPU, | ||
140 | }, | ||
128 | }; | 141 | }; |
129 | 142 | ||
130 | static struct uio_info veu_platform_data = { | 143 | static struct uio_info veu_platform_data = { |
@@ -153,6 +166,9 @@ static struct platform_device veu_device = { | |||
153 | }, | 166 | }, |
154 | .resource = veu_resources, | 167 | .resource = veu_resources, |
155 | .num_resources = ARRAY_SIZE(veu_resources), | 168 | .num_resources = ARRAY_SIZE(veu_resources), |
169 | .archdata = { | ||
170 | .hwblk_id = HWBLK_VEU, | ||
171 | }, | ||
156 | }; | 172 | }; |
157 | 173 | ||
158 | static struct uio_info jpu_platform_data = { | 174 | static struct uio_info jpu_platform_data = { |
@@ -181,6 +197,9 @@ static struct platform_device jpu_device = { | |||
181 | }, | 197 | }, |
182 | .resource = jpu_resources, | 198 | .resource = jpu_resources, |
183 | .num_resources = ARRAY_SIZE(jpu_resources), | 199 | .num_resources = ARRAY_SIZE(jpu_resources), |
200 | .archdata = { | ||
201 | .hwblk_id = HWBLK_JPU, | ||
202 | }, | ||
184 | }; | 203 | }; |
185 | 204 | ||
186 | static struct sh_timer_config cmt_platform_data = { | 205 | static struct sh_timer_config cmt_platform_data = { |
@@ -213,6 +232,9 @@ static struct platform_device cmt_device = { | |||
213 | }, | 232 | }, |
214 | .resource = cmt_resources, | 233 | .resource = cmt_resources, |
215 | .num_resources = ARRAY_SIZE(cmt_resources), | 234 | .num_resources = ARRAY_SIZE(cmt_resources), |
235 | .archdata = { | ||
236 | .hwblk_id = HWBLK_CMT, | ||
237 | }, | ||
216 | }; | 238 | }; |
217 | 239 | ||
218 | static struct sh_timer_config tmu0_platform_data = { | 240 | static struct sh_timer_config tmu0_platform_data = { |
@@ -244,6 +266,9 @@ static struct platform_device tmu0_device = { | |||
244 | }, | 266 | }, |
245 | .resource = tmu0_resources, | 267 | .resource = tmu0_resources, |
246 | .num_resources = ARRAY_SIZE(tmu0_resources), | 268 | .num_resources = ARRAY_SIZE(tmu0_resources), |
269 | .archdata = { | ||
270 | .hwblk_id = HWBLK_TMU, | ||
271 | }, | ||
247 | }; | 272 | }; |
248 | 273 | ||
249 | static struct sh_timer_config tmu1_platform_data = { | 274 | static struct sh_timer_config tmu1_platform_data = { |
@@ -275,6 +300,9 @@ static struct platform_device tmu1_device = { | |||
275 | }, | 300 | }, |
276 | .resource = tmu1_resources, | 301 | .resource = tmu1_resources, |
277 | .num_resources = ARRAY_SIZE(tmu1_resources), | 302 | .num_resources = ARRAY_SIZE(tmu1_resources), |
303 | .archdata = { | ||
304 | .hwblk_id = HWBLK_TMU, | ||
305 | }, | ||
278 | }; | 306 | }; |
279 | 307 | ||
280 | static struct sh_timer_config tmu2_platform_data = { | 308 | static struct sh_timer_config tmu2_platform_data = { |
@@ -305,6 +333,9 @@ static struct platform_device tmu2_device = { | |||
305 | }, | 333 | }, |
306 | .resource = tmu2_resources, | 334 | .resource = tmu2_resources, |
307 | .num_resources = ARRAY_SIZE(tmu2_resources), | 335 | .num_resources = ARRAY_SIZE(tmu2_resources), |
336 | .archdata = { | ||
337 | .hwblk_id = HWBLK_TMU, | ||
338 | }, | ||
308 | }; | 339 | }; |
309 | 340 | ||
310 | static struct plat_sci_port sci_platform_data[] = { | 341 | static struct plat_sci_port sci_platform_data[] = { |
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c index 26dc4d323252..4caa5a7ca86e 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <asm/clock.h> | 19 | #include <asm/clock.h> |
20 | #include <asm/mmzone.h> | 20 | #include <asm/mmzone.h> |
21 | #include <cpu/sh7723.h> | ||
21 | 22 | ||
22 | static struct uio_info vpu_platform_data = { | 23 | static struct uio_info vpu_platform_data = { |
23 | .name = "VPU5", | 24 | .name = "VPU5", |
@@ -45,6 +46,9 @@ static struct platform_device vpu_device = { | |||
45 | }, | 46 | }, |
46 | .resource = vpu_resources, | 47 | .resource = vpu_resources, |
47 | .num_resources = ARRAY_SIZE(vpu_resources), | 48 | .num_resources = ARRAY_SIZE(vpu_resources), |
49 | .archdata = { | ||
50 | .hwblk_id = HWBLK_VPU, | ||
51 | }, | ||
48 | }; | 52 | }; |
49 | 53 | ||
50 | static struct uio_info veu0_platform_data = { | 54 | static struct uio_info veu0_platform_data = { |
@@ -73,6 +77,9 @@ static struct platform_device veu0_device = { | |||
73 | }, | 77 | }, |
74 | .resource = veu0_resources, | 78 | .resource = veu0_resources, |
75 | .num_resources = ARRAY_SIZE(veu0_resources), | 79 | .num_resources = ARRAY_SIZE(veu0_resources), |
80 | .archdata = { | ||
81 | .hwblk_id = HWBLK_VEU2H0, | ||
82 | }, | ||
76 | }; | 83 | }; |
77 | 84 | ||
78 | static struct uio_info veu1_platform_data = { | 85 | static struct uio_info veu1_platform_data = { |
@@ -101,6 +108,9 @@ static struct platform_device veu1_device = { | |||
101 | }, | 108 | }, |
102 | .resource = veu1_resources, | 109 | .resource = veu1_resources, |
103 | .num_resources = ARRAY_SIZE(veu1_resources), | 110 | .num_resources = ARRAY_SIZE(veu1_resources), |
111 | .archdata = { | ||
112 | .hwblk_id = HWBLK_VEU2H1, | ||
113 | }, | ||
104 | }; | 114 | }; |
105 | 115 | ||
106 | static struct sh_timer_config cmt_platform_data = { | 116 | static struct sh_timer_config cmt_platform_data = { |
@@ -133,6 +143,9 @@ static struct platform_device cmt_device = { | |||
133 | }, | 143 | }, |
134 | .resource = cmt_resources, | 144 | .resource = cmt_resources, |
135 | .num_resources = ARRAY_SIZE(cmt_resources), | 145 | .num_resources = ARRAY_SIZE(cmt_resources), |
146 | .archdata = { | ||
147 | .hwblk_id = HWBLK_CMT, | ||
148 | }, | ||
136 | }; | 149 | }; |
137 | 150 | ||
138 | static struct sh_timer_config tmu0_platform_data = { | 151 | static struct sh_timer_config tmu0_platform_data = { |
@@ -164,6 +177,9 @@ static struct platform_device tmu0_device = { | |||
164 | }, | 177 | }, |
165 | .resource = tmu0_resources, | 178 | .resource = tmu0_resources, |
166 | .num_resources = ARRAY_SIZE(tmu0_resources), | 179 | .num_resources = ARRAY_SIZE(tmu0_resources), |
180 | .archdata = { | ||
181 | .hwblk_id = HWBLK_TMU0, | ||
182 | }, | ||
167 | }; | 183 | }; |
168 | 184 | ||
169 | static struct sh_timer_config tmu1_platform_data = { | 185 | static struct sh_timer_config tmu1_platform_data = { |
@@ -195,6 +211,9 @@ static struct platform_device tmu1_device = { | |||
195 | }, | 211 | }, |
196 | .resource = tmu1_resources, | 212 | .resource = tmu1_resources, |
197 | .num_resources = ARRAY_SIZE(tmu1_resources), | 213 | .num_resources = ARRAY_SIZE(tmu1_resources), |
214 | .archdata = { | ||
215 | .hwblk_id = HWBLK_TMU0, | ||
216 | }, | ||
198 | }; | 217 | }; |
199 | 218 | ||
200 | static struct sh_timer_config tmu2_platform_data = { | 219 | static struct sh_timer_config tmu2_platform_data = { |
@@ -225,6 +244,9 @@ static struct platform_device tmu2_device = { | |||
225 | }, | 244 | }, |
226 | .resource = tmu2_resources, | 245 | .resource = tmu2_resources, |
227 | .num_resources = ARRAY_SIZE(tmu2_resources), | 246 | .num_resources = ARRAY_SIZE(tmu2_resources), |
247 | .archdata = { | ||
248 | .hwblk_id = HWBLK_TMU0, | ||
249 | }, | ||
228 | }; | 250 | }; |
229 | 251 | ||
230 | static struct sh_timer_config tmu3_platform_data = { | 252 | static struct sh_timer_config tmu3_platform_data = { |
@@ -255,6 +277,9 @@ static struct platform_device tmu3_device = { | |||
255 | }, | 277 | }, |
256 | .resource = tmu3_resources, | 278 | .resource = tmu3_resources, |
257 | .num_resources = ARRAY_SIZE(tmu3_resources), | 279 | .num_resources = ARRAY_SIZE(tmu3_resources), |
280 | .archdata = { | ||
281 | .hwblk_id = HWBLK_TMU1, | ||
282 | }, | ||
258 | }; | 283 | }; |
259 | 284 | ||
260 | static struct sh_timer_config tmu4_platform_data = { | 285 | static struct sh_timer_config tmu4_platform_data = { |
@@ -285,6 +310,9 @@ static struct platform_device tmu4_device = { | |||
285 | }, | 310 | }, |
286 | .resource = tmu4_resources, | 311 | .resource = tmu4_resources, |
287 | .num_resources = ARRAY_SIZE(tmu4_resources), | 312 | .num_resources = ARRAY_SIZE(tmu4_resources), |
313 | .archdata = { | ||
314 | .hwblk_id = HWBLK_TMU1, | ||
315 | }, | ||
288 | }; | 316 | }; |
289 | 317 | ||
290 | static struct sh_timer_config tmu5_platform_data = { | 318 | static struct sh_timer_config tmu5_platform_data = { |
@@ -315,6 +343,9 @@ static struct platform_device tmu5_device = { | |||
315 | }, | 343 | }, |
316 | .resource = tmu5_resources, | 344 | .resource = tmu5_resources, |
317 | .num_resources = ARRAY_SIZE(tmu5_resources), | 345 | .num_resources = ARRAY_SIZE(tmu5_resources), |
346 | .archdata = { | ||
347 | .hwblk_id = HWBLK_TMU1, | ||
348 | }, | ||
318 | }; | 349 | }; |
319 | 350 | ||
320 | static struct plat_sci_port sci_platform_data[] = { | 351 | static struct plat_sci_port sci_platform_data[] = { |
@@ -395,6 +426,9 @@ static struct platform_device rtc_device = { | |||
395 | .id = -1, | 426 | .id = -1, |
396 | .num_resources = ARRAY_SIZE(rtc_resources), | 427 | .num_resources = ARRAY_SIZE(rtc_resources), |
397 | .resource = rtc_resources, | 428 | .resource = rtc_resources, |
429 | .archdata = { | ||
430 | .hwblk_id = HWBLK_RTC, | ||
431 | }, | ||
398 | }; | 432 | }; |
399 | 433 | ||
400 | static struct r8a66597_platdata r8a66597_data = { | 434 | static struct r8a66597_platdata r8a66597_data = { |
@@ -424,6 +458,9 @@ static struct platform_device sh7723_usb_host_device = { | |||
424 | }, | 458 | }, |
425 | .num_resources = ARRAY_SIZE(sh7723_usb_host_resources), | 459 | .num_resources = ARRAY_SIZE(sh7723_usb_host_resources), |
426 | .resource = sh7723_usb_host_resources, | 460 | .resource = sh7723_usb_host_resources, |
461 | .archdata = { | ||
462 | .hwblk_id = HWBLK_USB, | ||
463 | }, | ||
427 | }; | 464 | }; |
428 | 465 | ||
429 | static struct resource iic_resources[] = { | 466 | static struct resource iic_resources[] = { |
@@ -445,6 +482,9 @@ static struct platform_device iic_device = { | |||
445 | .id = 0, /* "i2c0" clock */ | 482 | .id = 0, /* "i2c0" clock */ |
446 | .num_resources = ARRAY_SIZE(iic_resources), | 483 | .num_resources = ARRAY_SIZE(iic_resources), |
447 | .resource = iic_resources, | 484 | .resource = iic_resources, |
485 | .archdata = { | ||
486 | .hwblk_id = HWBLK_IIC, | ||
487 | }, | ||
448 | }; | 488 | }; |
449 | 489 | ||
450 | static struct platform_device *sh7723_devices[] __initdata = { | 490 | static struct platform_device *sh7723_devices[] __initdata = { |
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c index a04edaab9a29..f3851fd757ec 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <asm/clock.h> | 23 | #include <asm/clock.h> |
24 | #include <asm/mmzone.h> | 24 | #include <asm/mmzone.h> |
25 | #include <cpu/sh7724.h> | ||
25 | 26 | ||
26 | /* Serial */ | 27 | /* Serial */ |
27 | static struct plat_sci_port sci_platform_data[] = { | 28 | static struct plat_sci_port sci_platform_data[] = { |
@@ -103,6 +104,9 @@ static struct platform_device rtc_device = { | |||
103 | .id = -1, | 104 | .id = -1, |
104 | .num_resources = ARRAY_SIZE(rtc_resources), | 105 | .num_resources = ARRAY_SIZE(rtc_resources), |
105 | .resource = rtc_resources, | 106 | .resource = rtc_resources, |
107 | .archdata = { | ||
108 | .hwblk_id = HWBLK_RTC, | ||
109 | }, | ||
106 | }; | 110 | }; |
107 | 111 | ||
108 | /* I2C0 */ | 112 | /* I2C0 */ |
@@ -125,6 +129,9 @@ static struct platform_device iic0_device = { | |||
125 | .id = 0, /* "i2c0" clock */ | 129 | .id = 0, /* "i2c0" clock */ |
126 | .num_resources = ARRAY_SIZE(iic0_resources), | 130 | .num_resources = ARRAY_SIZE(iic0_resources), |
127 | .resource = iic0_resources, | 131 | .resource = iic0_resources, |
132 | .archdata = { | ||
133 | .hwblk_id = HWBLK_IIC0, | ||
134 | }, | ||
128 | }; | 135 | }; |
129 | 136 | ||
130 | /* I2C1 */ | 137 | /* I2C1 */ |
@@ -147,6 +154,9 @@ static struct platform_device iic1_device = { | |||
147 | .id = 1, /* "i2c1" clock */ | 154 | .id = 1, /* "i2c1" clock */ |
148 | .num_resources = ARRAY_SIZE(iic1_resources), | 155 | .num_resources = ARRAY_SIZE(iic1_resources), |
149 | .resource = iic1_resources, | 156 | .resource = iic1_resources, |
157 | .archdata = { | ||
158 | .hwblk_id = HWBLK_IIC1, | ||
159 | }, | ||
150 | }; | 160 | }; |
151 | 161 | ||
152 | /* VPU */ | 162 | /* VPU */ |
@@ -176,6 +186,9 @@ static struct platform_device vpu_device = { | |||
176 | }, | 186 | }, |
177 | .resource = vpu_resources, | 187 | .resource = vpu_resources, |
178 | .num_resources = ARRAY_SIZE(vpu_resources), | 188 | .num_resources = ARRAY_SIZE(vpu_resources), |
189 | .archdata = { | ||
190 | .hwblk_id = HWBLK_VPU, | ||
191 | }, | ||
179 | }; | 192 | }; |
180 | 193 | ||
181 | /* VEU0 */ | 194 | /* VEU0 */ |
@@ -205,6 +218,9 @@ static struct platform_device veu0_device = { | |||
205 | }, | 218 | }, |
206 | .resource = veu0_resources, | 219 | .resource = veu0_resources, |
207 | .num_resources = ARRAY_SIZE(veu0_resources), | 220 | .num_resources = ARRAY_SIZE(veu0_resources), |
221 | .archdata = { | ||
222 | .hwblk_id = HWBLK_VEU0, | ||
223 | }, | ||
208 | }; | 224 | }; |
209 | 225 | ||
210 | /* VEU1 */ | 226 | /* VEU1 */ |
@@ -234,6 +250,9 @@ static struct platform_device veu1_device = { | |||
234 | }, | 250 | }, |
235 | .resource = veu1_resources, | 251 | .resource = veu1_resources, |
236 | .num_resources = ARRAY_SIZE(veu1_resources), | 252 | .num_resources = ARRAY_SIZE(veu1_resources), |
253 | .archdata = { | ||
254 | .hwblk_id = HWBLK_VEU1, | ||
255 | }, | ||
237 | }; | 256 | }; |
238 | 257 | ||
239 | static struct sh_timer_config cmt_platform_data = { | 258 | static struct sh_timer_config cmt_platform_data = { |
@@ -266,6 +285,9 @@ static struct platform_device cmt_device = { | |||
266 | }, | 285 | }, |
267 | .resource = cmt_resources, | 286 | .resource = cmt_resources, |
268 | .num_resources = ARRAY_SIZE(cmt_resources), | 287 | .num_resources = ARRAY_SIZE(cmt_resources), |
288 | .archdata = { | ||
289 | .hwblk_id = HWBLK_CMT, | ||
290 | }, | ||
269 | }; | 291 | }; |
270 | 292 | ||
271 | static struct sh_timer_config tmu0_platform_data = { | 293 | static struct sh_timer_config tmu0_platform_data = { |
@@ -297,6 +319,9 @@ static struct platform_device tmu0_device = { | |||
297 | }, | 319 | }, |
298 | .resource = tmu0_resources, | 320 | .resource = tmu0_resources, |
299 | .num_resources = ARRAY_SIZE(tmu0_resources), | 321 | .num_resources = ARRAY_SIZE(tmu0_resources), |
322 | .archdata = { | ||
323 | .hwblk_id = HWBLK_TMU0, | ||
324 | }, | ||
300 | }; | 325 | }; |
301 | 326 | ||
302 | static struct sh_timer_config tmu1_platform_data = { | 327 | static struct sh_timer_config tmu1_platform_data = { |
@@ -328,6 +353,9 @@ static struct platform_device tmu1_device = { | |||
328 | }, | 353 | }, |
329 | .resource = tmu1_resources, | 354 | .resource = tmu1_resources, |
330 | .num_resources = ARRAY_SIZE(tmu1_resources), | 355 | .num_resources = ARRAY_SIZE(tmu1_resources), |
356 | .archdata = { | ||
357 | .hwblk_id = HWBLK_TMU0, | ||
358 | }, | ||
331 | }; | 359 | }; |
332 | 360 | ||
333 | static struct sh_timer_config tmu2_platform_data = { | 361 | static struct sh_timer_config tmu2_platform_data = { |
@@ -358,6 +386,9 @@ static struct platform_device tmu2_device = { | |||
358 | }, | 386 | }, |
359 | .resource = tmu2_resources, | 387 | .resource = tmu2_resources, |
360 | .num_resources = ARRAY_SIZE(tmu2_resources), | 388 | .num_resources = ARRAY_SIZE(tmu2_resources), |
389 | .archdata = { | ||
390 | .hwblk_id = HWBLK_TMU0, | ||
391 | }, | ||
361 | }; | 392 | }; |
362 | 393 | ||
363 | 394 | ||
@@ -389,6 +420,9 @@ static struct platform_device tmu3_device = { | |||
389 | }, | 420 | }, |
390 | .resource = tmu3_resources, | 421 | .resource = tmu3_resources, |
391 | .num_resources = ARRAY_SIZE(tmu3_resources), | 422 | .num_resources = ARRAY_SIZE(tmu3_resources), |
423 | .archdata = { | ||
424 | .hwblk_id = HWBLK_TMU1, | ||
425 | }, | ||
392 | }; | 426 | }; |
393 | 427 | ||
394 | static struct sh_timer_config tmu4_platform_data = { | 428 | static struct sh_timer_config tmu4_platform_data = { |
@@ -419,6 +453,9 @@ static struct platform_device tmu4_device = { | |||
419 | }, | 453 | }, |
420 | .resource = tmu4_resources, | 454 | .resource = tmu4_resources, |
421 | .num_resources = ARRAY_SIZE(tmu4_resources), | 455 | .num_resources = ARRAY_SIZE(tmu4_resources), |
456 | .archdata = { | ||
457 | .hwblk_id = HWBLK_TMU1, | ||
458 | }, | ||
422 | }; | 459 | }; |
423 | 460 | ||
424 | static struct sh_timer_config tmu5_platform_data = { | 461 | static struct sh_timer_config tmu5_platform_data = { |
@@ -449,6 +486,9 @@ static struct platform_device tmu5_device = { | |||
449 | }, | 486 | }, |
450 | .resource = tmu5_resources, | 487 | .resource = tmu5_resources, |
451 | .num_resources = ARRAY_SIZE(tmu5_resources), | 488 | .num_resources = ARRAY_SIZE(tmu5_resources), |
489 | .archdata = { | ||
490 | .hwblk_id = HWBLK_TMU1, | ||
491 | }, | ||
452 | }; | 492 | }; |
453 | 493 | ||
454 | /* JPU */ | 494 | /* JPU */ |
@@ -478,6 +518,9 @@ static struct platform_device jpu_device = { | |||
478 | }, | 518 | }, |
479 | .resource = jpu_resources, | 519 | .resource = jpu_resources, |
480 | .num_resources = ARRAY_SIZE(jpu_resources), | 520 | .num_resources = ARRAY_SIZE(jpu_resources), |
521 | .archdata = { | ||
522 | .hwblk_id = HWBLK_JPU, | ||
523 | }, | ||
481 | }; | 524 | }; |
482 | 525 | ||
483 | static struct platform_device *sh7724_devices[] __initdata = { | 526 | static struct platform_device *sh7724_devices[] __initdata = { |
diff --git a/arch/sh/kernel/cpu/shmobile/Makefile b/arch/sh/kernel/cpu/shmobile/Makefile index e8a5111e848a..a39f88ea1a85 100644 --- a/arch/sh/kernel/cpu/shmobile/Makefile +++ b/arch/sh/kernel/cpu/shmobile/Makefile | |||
@@ -5,3 +5,4 @@ | |||
5 | # Power Management & Sleep mode | 5 | # Power Management & Sleep mode |
6 | obj-$(CONFIG_PM) += pm.o sleep.o | 6 | obj-$(CONFIG_PM) += pm.o sleep.o |
7 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o | 7 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o |
8 | obj-$(CONFIG_PM_RUNTIME) += pm_runtime.o | ||
diff --git a/arch/sh/kernel/cpu/shmobile/pm_runtime.c b/arch/sh/kernel/cpu/shmobile/pm_runtime.c new file mode 100644 index 000000000000..7c615b17e209 --- /dev/null +++ b/arch/sh/kernel/cpu/shmobile/pm_runtime.c | |||
@@ -0,0 +1,303 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/shmobile/pm_runtime.c | ||
3 | * | ||
4 | * Runtime PM support code for SuperH Mobile | ||
5 | * | ||
6 | * Copyright (C) 2009 Magnus Damm | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file "COPYING" in the main directory of this archive | ||
10 | * for more details. | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/pm_runtime.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/mutex.h> | ||
18 | #include <asm/hwblk.h> | ||
19 | |||
20 | static DEFINE_SPINLOCK(hwblk_lock); | ||
21 | static LIST_HEAD(hwblk_idle_list); | ||
22 | static struct work_struct hwblk_work; | ||
23 | |||
24 | extern struct hwblk_info *hwblk_info; | ||
25 | |||
26 | static void platform_pm_runtime_not_idle(struct platform_device *pdev) | ||
27 | { | ||
28 | unsigned long flags; | ||
29 | |||
30 | /* remove device from idle list */ | ||
31 | spin_lock_irqsave(&hwblk_lock, flags); | ||
32 | if (test_bit(PDEV_ARCHDATA_FLAG_IDLE, &pdev->archdata.flags)) { | ||
33 | list_del(&pdev->archdata.entry); | ||
34 | __clear_bit(PDEV_ARCHDATA_FLAG_IDLE, &pdev->archdata.flags); | ||
35 | } | ||
36 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
37 | } | ||
38 | |||
39 | static int __platform_pm_runtime_resume(struct platform_device *pdev) | ||
40 | { | ||
41 | struct device *d = &pdev->dev; | ||
42 | struct pdev_archdata *ad = &pdev->archdata; | ||
43 | int hwblk = ad->hwblk_id; | ||
44 | int ret = -ENOSYS; | ||
45 | |||
46 | dev_dbg(d, "__platform_pm_runtime_resume() [%d]\n", hwblk); | ||
47 | |||
48 | if (d->driver && d->driver->pm && d->driver->pm->runtime_resume) { | ||
49 | hwblk_enable(hwblk_info, hwblk); | ||
50 | ret = 0; | ||
51 | |||
52 | if (test_bit(PDEV_ARCHDATA_FLAG_SUSP, &ad->flags)) { | ||
53 | ret = d->driver->pm->runtime_resume(d); | ||
54 | if (!ret) | ||
55 | clear_bit(PDEV_ARCHDATA_FLAG_SUSP, &ad->flags); | ||
56 | else | ||
57 | hwblk_disable(hwblk_info, hwblk); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | dev_dbg(d, "__platform_pm_runtime_resume() [%d] - returns %d\n", | ||
62 | hwblk, ret); | ||
63 | |||
64 | return ret; | ||
65 | } | ||
66 | |||
67 | static int __platform_pm_runtime_suspend(struct platform_device *pdev) | ||
68 | { | ||
69 | struct device *d = &pdev->dev; | ||
70 | struct pdev_archdata *ad = &pdev->archdata; | ||
71 | int hwblk = ad->hwblk_id; | ||
72 | int ret = -ENOSYS; | ||
73 | |||
74 | dev_dbg(d, "__platform_pm_runtime_suspend() [%d]\n", hwblk); | ||
75 | |||
76 | if (d->driver && d->driver->pm && d->driver->pm->runtime_suspend) { | ||
77 | BUG_ON(!test_bit(PDEV_ARCHDATA_FLAG_IDLE, &ad->flags)); | ||
78 | |||
79 | hwblk_enable(hwblk_info, hwblk); | ||
80 | ret = d->driver->pm->runtime_suspend(d); | ||
81 | hwblk_disable(hwblk_info, hwblk); | ||
82 | |||
83 | if (!ret) { | ||
84 | set_bit(PDEV_ARCHDATA_FLAG_SUSP, &ad->flags); | ||
85 | platform_pm_runtime_not_idle(pdev); | ||
86 | hwblk_cnt_dec(hwblk_info, hwblk, HWBLK_CNT_IDLE); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | dev_dbg(d, "__platform_pm_runtime_suspend() [%d] - returns %d\n", | ||
91 | hwblk, ret); | ||
92 | |||
93 | return ret; | ||
94 | } | ||
95 | |||
96 | static void platform_pm_runtime_work(struct work_struct *work) | ||
97 | { | ||
98 | struct platform_device *pdev; | ||
99 | unsigned long flags; | ||
100 | int ret; | ||
101 | |||
102 | /* go through the idle list and suspend one device at a time */ | ||
103 | do { | ||
104 | spin_lock_irqsave(&hwblk_lock, flags); | ||
105 | if (list_empty(&hwblk_idle_list)) | ||
106 | pdev = NULL; | ||
107 | else | ||
108 | pdev = list_first_entry(&hwblk_idle_list, | ||
109 | struct platform_device, | ||
110 | archdata.entry); | ||
111 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
112 | |||
113 | if (pdev) { | ||
114 | mutex_lock(&pdev->archdata.mutex); | ||
115 | ret = __platform_pm_runtime_suspend(pdev); | ||
116 | |||
117 | /* at this point the platform device may be: | ||
118 | * suspended: ret = 0, FLAG_SUSP set, clock stopped | ||
119 | * failed: ret < 0, FLAG_IDLE set, clock stopped | ||
120 | */ | ||
121 | mutex_unlock(&pdev->archdata.mutex); | ||
122 | } else { | ||
123 | ret = -ENODEV; | ||
124 | } | ||
125 | } while (!ret); | ||
126 | } | ||
127 | |||
128 | /* this function gets called from cpuidle context when all devices in the | ||
129 | * main power domain are unused but some are counted as idle, ie the hwblk | ||
130 | * counter values are (HWBLK_CNT_USAGE == 0) && (HWBLK_CNT_IDLE != 0) | ||
131 | */ | ||
132 | void platform_pm_runtime_suspend_idle(void) | ||
133 | { | ||
134 | queue_work(pm_wq, &hwblk_work); | ||
135 | } | ||
136 | |||
137 | int platform_pm_runtime_suspend(struct device *dev) | ||
138 | { | ||
139 | struct platform_device *pdev = to_platform_device(dev); | ||
140 | struct pdev_archdata *ad = &pdev->archdata; | ||
141 | unsigned long flags; | ||
142 | int hwblk = ad->hwblk_id; | ||
143 | int ret = 0; | ||
144 | |||
145 | dev_dbg(dev, "platform_pm_runtime_suspend() [%d]\n", hwblk); | ||
146 | |||
147 | /* ignore off-chip platform devices */ | ||
148 | if (!hwblk) | ||
149 | goto out; | ||
150 | |||
151 | /* interrupt context not allowed */ | ||
152 | might_sleep(); | ||
153 | |||
154 | /* catch misconfigured drivers not starting with resume */ | ||
155 | if (test_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags)) { | ||
156 | ret = -EINVAL; | ||
157 | goto out; | ||
158 | } | ||
159 | |||
160 | /* serialize */ | ||
161 | mutex_lock(&ad->mutex); | ||
162 | |||
163 | /* disable clock */ | ||
164 | hwblk_disable(hwblk_info, hwblk); | ||
165 | |||
166 | /* put device on idle list */ | ||
167 | spin_lock_irqsave(&hwblk_lock, flags); | ||
168 | list_add_tail(&pdev->archdata.entry, &hwblk_idle_list); | ||
169 | __set_bit(PDEV_ARCHDATA_FLAG_IDLE, &pdev->archdata.flags); | ||
170 | spin_unlock_irqrestore(&hwblk_lock, flags); | ||
171 | |||
172 | /* increase idle count */ | ||
173 | hwblk_cnt_inc(hwblk_info, hwblk, HWBLK_CNT_IDLE); | ||
174 | |||
175 | /* at this point the platform device is: | ||
176 | * idle: ret = 0, FLAG_IDLE set, clock stopped | ||
177 | */ | ||
178 | mutex_unlock(&ad->mutex); | ||
179 | |||
180 | out: | ||
181 | dev_dbg(dev, "platform_pm_runtime_suspend() [%d] returns %d\n", | ||
182 | hwblk, ret); | ||
183 | |||
184 | return ret; | ||
185 | } | ||
186 | |||
187 | int platform_pm_runtime_resume(struct device *dev) | ||
188 | { | ||
189 | struct platform_device *pdev = to_platform_device(dev); | ||
190 | struct pdev_archdata *ad = &pdev->archdata; | ||
191 | int hwblk = ad->hwblk_id; | ||
192 | int ret = 0; | ||
193 | |||
194 | dev_dbg(dev, "platform_pm_runtime_resume() [%d]\n", hwblk); | ||
195 | |||
196 | /* ignore off-chip platform devices */ | ||
197 | if (!hwblk) | ||
198 | goto out; | ||
199 | |||
200 | /* interrupt context not allowed */ | ||
201 | might_sleep(); | ||
202 | |||
203 | /* serialize */ | ||
204 | mutex_lock(&ad->mutex); | ||
205 | |||
206 | /* make sure device is removed from idle list */ | ||
207 | platform_pm_runtime_not_idle(pdev); | ||
208 | |||
209 | /* decrease idle count */ | ||
210 | if (!test_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags) && | ||
211 | !test_bit(PDEV_ARCHDATA_FLAG_SUSP, &pdev->archdata.flags)) | ||
212 | hwblk_cnt_dec(hwblk_info, hwblk, HWBLK_CNT_IDLE); | ||
213 | |||
214 | /* resume the device if needed */ | ||
215 | ret = __platform_pm_runtime_resume(pdev); | ||
216 | |||
217 | /* the driver has been initialized now, so clear the init flag */ | ||
218 | clear_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags); | ||
219 | |||
220 | /* at this point the platform device may be: | ||
221 | * resumed: ret = 0, flags = 0, clock started | ||
222 | * failed: ret < 0, FLAG_SUSP set, clock stopped | ||
223 | */ | ||
224 | mutex_unlock(&ad->mutex); | ||
225 | out: | ||
226 | dev_dbg(dev, "platform_pm_runtime_resume() [%d] returns %d\n", | ||
227 | hwblk, ret); | ||
228 | |||
229 | return ret; | ||
230 | } | ||
231 | |||
232 | int platform_pm_runtime_idle(struct device *dev) | ||
233 | { | ||
234 | struct platform_device *pdev = to_platform_device(dev); | ||
235 | int hwblk = pdev->archdata.hwblk_id; | ||
236 | int ret = 0; | ||
237 | |||
238 | dev_dbg(dev, "platform_pm_runtime_idle() [%d]\n", hwblk); | ||
239 | |||
240 | /* ignore off-chip platform devices */ | ||
241 | if (!hwblk) | ||
242 | goto out; | ||
243 | |||
244 | /* interrupt context not allowed, use pm_runtime_put()! */ | ||
245 | might_sleep(); | ||
246 | |||
247 | /* suspend synchronously to disable clocks immediately */ | ||
248 | ret = pm_runtime_suspend(dev); | ||
249 | out: | ||
250 | dev_dbg(dev, "platform_pm_runtime_idle() [%d] done!\n", hwblk); | ||
251 | return ret; | ||
252 | } | ||
253 | |||
254 | static int platform_bus_notify(struct notifier_block *nb, | ||
255 | unsigned long action, void *data) | ||
256 | { | ||
257 | struct device *dev = data; | ||
258 | struct platform_device *pdev = to_platform_device(dev); | ||
259 | int hwblk = pdev->archdata.hwblk_id; | ||
260 | |||
261 | /* ignore off-chip platform devices */ | ||
262 | if (!hwblk) | ||
263 | return 0; | ||
264 | |||
265 | switch (action) { | ||
266 | case BUS_NOTIFY_ADD_DEVICE: | ||
267 | INIT_LIST_HEAD(&pdev->archdata.entry); | ||
268 | mutex_init(&pdev->archdata.mutex); | ||
269 | /* platform devices without drivers should be disabled */ | ||
270 | hwblk_enable(hwblk_info, hwblk); | ||
271 | hwblk_disable(hwblk_info, hwblk); | ||
272 | /* make sure driver re-inits itself once */ | ||
273 | __set_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags); | ||
274 | break; | ||
275 | /* TODO: add BUS_NOTIFY_BIND_DRIVER and increase idle count */ | ||
276 | case BUS_NOTIFY_BOUND_DRIVER: | ||
277 | /* keep track of number of devices in use per hwblk */ | ||
278 | hwblk_cnt_inc(hwblk_info, hwblk, HWBLK_CNT_DEVICES); | ||
279 | break; | ||
280 | case BUS_NOTIFY_UNBOUND_DRIVER: | ||
281 | /* keep track of number of devices in use per hwblk */ | ||
282 | hwblk_cnt_dec(hwblk_info, hwblk, HWBLK_CNT_DEVICES); | ||
283 | /* make sure driver re-inits itself once */ | ||
284 | __set_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags); | ||
285 | break; | ||
286 | case BUS_NOTIFY_DEL_DEVICE: | ||
287 | break; | ||
288 | } | ||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | static struct notifier_block platform_bus_notifier = { | ||
293 | .notifier_call = platform_bus_notify | ||
294 | }; | ||
295 | |||
296 | static int __init sh_pm_runtime_init(void) | ||
297 | { | ||
298 | INIT_WORK(&hwblk_work, platform_pm_runtime_work); | ||
299 | |||
300 | bus_register_notifier(&platform_bus_type, &platform_bus_notifier); | ||
301 | return 0; | ||
302 | } | ||
303 | core_initcall(sh_pm_runtime_init); | ||