diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-01 23:58:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-01 23:58:25 -0400 |
commit | 81a3c10ce8a7fd5bf9a06bfc38bd417512911831 (patch) | |
tree | 12ceac10fae8c4b2dc17b362672a5db305a8d960 /arch/arm/plat-omap | |
parent | 6585dea1f99cc2265582ff2e4cc1727062136e92 (diff) | |
parent | df80442d1ee2902c2e39f90f18160f2e08d14c06 (diff) |
Merge branch 'next/cleanup2' of git://git.linaro.org/people/arnd/arm-soc
* 'next/cleanup2' of git://git.linaro.org/people/arnd/arm-soc: (31 commits)
ARM: OMAP: Warn if omap_ioremap is called before SoC detection
ARM: OMAP: Move set_globals initialization to happen in init_early
ARM: OMAP: Map SRAM later on with ioremap_exec()
ARM: OMAP: Remove calls to SRAM allocations for framebuffer
ARM: OMAP: Avoid cpu_is_omapxxxx usage until map_io is done
ARM: OMAP1: Use generic map_io, init_early and init_irq
arm/dts: OMAP3+: Add mpu, dsp and iva nodes
arm/dts: OMAP4: Add a main ocp entry bound to l3-noc driver
ARM: OMAP2+: l3-noc: Add support for device-tree
ARM: OMAP2+: board-generic: Add i2c static init
ARM: OMAP2+: board-generic: Add DT support to generic board
arm/dts: Add support for OMAP3 Beagle board
arm/dts: Add initial device tree support for OMAP3 SoC
arm/dts: Add support for OMAP4 SDP board
arm/dts: Add support for OMAP4 PandaBoard
arm/dts: Add initial device tree support for OMAP4 SoC
ARM: OMAP: omap_device: Add a method to build an omap_device from a DT node
ARM: OMAP: omap_device: Add omap_device_[alloc|delete] for DT integration
of: Add helpers to get one string in multiple strings property
ARM: OMAP2+: devices: Remove all omap_device_pm_latency structures
...
Fix up trivial header file conflicts in arch/arm/mach-omap2/board-generic.c
Diffstat (limited to 'arch/arm/plat-omap')
-rw-r--r-- | arch/arm/plat-omap/i2c.c | 10 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/common.h | 17 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/io.h | 33 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/omap_device.h | 1 | ||||
-rw-r--r-- | arch/arm/plat-omap/io.c | 10 | ||||
-rw-r--r-- | arch/arm/plat-omap/omap_device.c | 313 | ||||
-rw-r--r-- | arch/arm/plat-omap/sram.c | 85 |
7 files changed, 335 insertions, 134 deletions
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c index a162b2c2ae15..679cbd49c019 100644 --- a/arch/arm/plat-omap/i2c.c +++ b/arch/arm/plat-omap/i2c.c | |||
@@ -139,14 +139,6 @@ static void omap_pm_set_max_mpu_wakeup_lat_compat(struct device *dev, long t) | |||
139 | omap_pm_set_max_mpu_wakeup_lat(dev, t); | 139 | omap_pm_set_max_mpu_wakeup_lat(dev, t); |
140 | } | 140 | } |
141 | 141 | ||
142 | static struct omap_device_pm_latency omap_i2c_latency[] = { | ||
143 | [0] = { | ||
144 | .deactivate_func = omap_device_idle_hwmods, | ||
145 | .activate_func = omap_device_enable_hwmods, | ||
146 | .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST, | ||
147 | }, | ||
148 | }; | ||
149 | |||
150 | static inline int omap2_i2c_add_bus(int bus_id) | 142 | static inline int omap2_i2c_add_bus(int bus_id) |
151 | { | 143 | { |
152 | int l; | 144 | int l; |
@@ -189,7 +181,7 @@ static inline int omap2_i2c_add_bus(int bus_id) | |||
189 | pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat; | 181 | pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat; |
190 | pdev = omap_device_build(name, bus_id, oh, pdata, | 182 | pdev = omap_device_build(name, bus_id, oh, pdata, |
191 | sizeof(struct omap_i2c_bus_platform_data), | 183 | sizeof(struct omap_i2c_bus_platform_data), |
192 | omap_i2c_latency, ARRAY_SIZE(omap_i2c_latency), 0); | 184 | NULL, 0, 0); |
193 | WARN(IS_ERR(pdev), "Could not build omap_device for %s\n", name); | 185 | WARN(IS_ERR(pdev), "Could not build omap_device for %s\n", name); |
194 | 186 | ||
195 | return PTR_ERR(pdev); | 187 | return PTR_ERR(pdev); |
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h index abda2c7e499b..c50df4814f6f 100644 --- a/arch/arm/plat-omap/include/plat/common.h +++ b/arch/arm/plat-omap/include/plat/common.h | |||
@@ -50,10 +50,13 @@ void omap2430_init_early(void); | |||
50 | void omap3430_init_early(void); | 50 | void omap3430_init_early(void); |
51 | void omap35xx_init_early(void); | 51 | void omap35xx_init_early(void); |
52 | void omap3630_init_early(void); | 52 | void omap3630_init_early(void); |
53 | void omap3_init_early(void); /* Do not use this one */ | ||
53 | void am35xx_init_early(void); | 54 | void am35xx_init_early(void); |
54 | void ti816x_init_early(void); | 55 | void ti816x_init_early(void); |
55 | void omap4430_init_early(void); | 56 | void omap4430_init_early(void); |
56 | 57 | ||
58 | void omap_sram_init(void); | ||
59 | |||
57 | /* | 60 | /* |
58 | * IO bases for various OMAP processors | 61 | * IO bases for various OMAP processors |
59 | * Except the tap base, rest all the io bases | 62 | * Except the tap base, rest all the io bases |
@@ -62,13 +65,13 @@ void omap4430_init_early(void); | |||
62 | struct omap_globals { | 65 | struct omap_globals { |
63 | u32 class; /* OMAP class to detect */ | 66 | u32 class; /* OMAP class to detect */ |
64 | void __iomem *tap; /* Control module ID code */ | 67 | void __iomem *tap; /* Control module ID code */ |
65 | unsigned long sdrc; /* SDRAM Controller */ | 68 | void __iomem *sdrc; /* SDRAM Controller */ |
66 | unsigned long sms; /* SDRAM Memory Scheduler */ | 69 | void __iomem *sms; /* SDRAM Memory Scheduler */ |
67 | unsigned long ctrl; /* System Control Module */ | 70 | void __iomem *ctrl; /* System Control Module */ |
68 | unsigned long ctrl_pad; /* PAD Control Module */ | 71 | void __iomem *ctrl_pad; /* PAD Control Module */ |
69 | unsigned long prm; /* Power and Reset Management */ | 72 | void __iomem *prm; /* Power and Reset Management */ |
70 | unsigned long cm; /* Clock Management */ | 73 | void __iomem *cm; /* Clock Management */ |
71 | unsigned long cm2; | 74 | void __iomem *cm2; |
72 | }; | 75 | }; |
73 | 76 | ||
74 | void omap2_set_globals_242x(void); | 77 | void omap2_set_globals_242x(void); |
diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/plat-omap/include/plat/io.h index a93a00db93da..7f2969eadb85 100644 --- a/arch/arm/plat-omap/include/plat/io.h +++ b/arch/arm/plat-omap/include/plat/io.h | |||
@@ -228,13 +228,13 @@ | |||
228 | 228 | ||
229 | #define OMAP44XX_EMIF2_PHYS OMAP44XX_EMIF2_BASE | 229 | #define OMAP44XX_EMIF2_PHYS OMAP44XX_EMIF2_BASE |
230 | /* 0x4d000000 --> 0xfd200000 */ | 230 | /* 0x4d000000 --> 0xfd200000 */ |
231 | #define OMAP44XX_EMIF2_VIRT (OMAP44XX_EMIF2_PHYS + OMAP4_L3_PER_IO_OFFSET) | ||
232 | #define OMAP44XX_EMIF2_SIZE SZ_1M | 231 | #define OMAP44XX_EMIF2_SIZE SZ_1M |
232 | #define OMAP44XX_EMIF2_VIRT (OMAP44XX_EMIF1_VIRT + OMAP44XX_EMIF1_SIZE) | ||
233 | 233 | ||
234 | #define OMAP44XX_DMM_PHYS OMAP44XX_DMM_BASE | 234 | #define OMAP44XX_DMM_PHYS OMAP44XX_DMM_BASE |
235 | /* 0x4e000000 --> 0xfd300000 */ | 235 | /* 0x4e000000 --> 0xfd300000 */ |
236 | #define OMAP44XX_DMM_VIRT (OMAP44XX_DMM_PHYS + OMAP4_L3_PER_IO_OFFSET) | ||
237 | #define OMAP44XX_DMM_SIZE SZ_1M | 236 | #define OMAP44XX_DMM_SIZE SZ_1M |
237 | #define OMAP44XX_DMM_VIRT (OMAP44XX_EMIF2_VIRT + OMAP44XX_EMIF2_SIZE) | ||
238 | /* | 238 | /* |
239 | * ---------------------------------------------------------------------------- | 239 | * ---------------------------------------------------------------------------- |
240 | * Omap specific register access | 240 | * Omap specific register access |
@@ -247,6 +247,8 @@ | |||
247 | * NOTE: Please use ioremap + __raw_read/write where possible instead of these | 247 | * NOTE: Please use ioremap + __raw_read/write where possible instead of these |
248 | */ | 248 | */ |
249 | 249 | ||
250 | void omap_ioremap_init(void); | ||
251 | |||
250 | extern u8 omap_readb(u32 pa); | 252 | extern u8 omap_readb(u32 pa); |
251 | extern u16 omap_readw(u32 pa); | 253 | extern u16 omap_readw(u32 pa); |
252 | extern u32 omap_readl(u32 pa); | 254 | extern u32 omap_readl(u32 pa); |
@@ -256,8 +258,31 @@ extern void omap_writel(u32 v, u32 pa); | |||
256 | 258 | ||
257 | struct omap_sdrc_params; | 259 | struct omap_sdrc_params; |
258 | 260 | ||
259 | extern void omap1_map_common_io(void); | 261 | #if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850) |
260 | extern void omap1_init_common_hw(void); | 262 | void omap7xx_map_io(void); |
263 | #else | ||
264 | static inline void omap_map_io(void) | ||
265 | { | ||
266 | } | ||
267 | #endif | ||
268 | |||
269 | #ifdef CONFIG_ARCH_OMAP15XX | ||
270 | void omap15xx_map_io(void); | ||
271 | #else | ||
272 | static inline void omap15xx_map_io(void) | ||
273 | { | ||
274 | } | ||
275 | #endif | ||
276 | |||
277 | #ifdef CONFIG_ARCH_OMAP16XX | ||
278 | void omap16xx_map_io(void); | ||
279 | #else | ||
280 | static inline void omap16xx_map_io(void) | ||
281 | { | ||
282 | } | ||
283 | #endif | ||
284 | |||
285 | void omap1_init_early(void); | ||
261 | 286 | ||
262 | #ifdef CONFIG_SOC_OMAP2420 | 287 | #ifdef CONFIG_SOC_OMAP2420 |
263 | extern void omap242x_map_common_io(void); | 288 | extern void omap242x_map_common_io(void); |
diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h index d4d9b96f961e..12c5b0c345bf 100644 --- a/arch/arm/plat-omap/include/plat/omap_device.h +++ b/arch/arm/plat-omap/include/plat/omap_device.h | |||
@@ -101,6 +101,7 @@ struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id, | |||
101 | int pm_lats_cnt, int is_early_device); | 101 | int pm_lats_cnt, int is_early_device); |
102 | 102 | ||
103 | void __iomem *omap_device_get_rt_va(struct omap_device *od); | 103 | void __iomem *omap_device_get_rt_va(struct omap_device *od); |
104 | struct device *omap_device_get_by_hwmod_name(const char *oh_name); | ||
104 | 105 | ||
105 | /* OMAP PM interface */ | 106 | /* OMAP PM interface */ |
106 | int omap_device_align_pm_lat(struct platform_device *pdev, | 107 | int omap_device_align_pm_lat(struct platform_device *pdev, |
diff --git a/arch/arm/plat-omap/io.c b/arch/arm/plat-omap/io.c index e9b0e23edd0a..333871f59995 100644 --- a/arch/arm/plat-omap/io.c +++ b/arch/arm/plat-omap/io.c | |||
@@ -24,11 +24,16 @@ | |||
24 | #define BETWEEN(p,st,sz) ((p) >= (st) && (p) < ((st) + (sz))) | 24 | #define BETWEEN(p,st,sz) ((p) >= (st) && (p) < ((st) + (sz))) |
25 | #define XLATE(p,pst,vst) ((void __iomem *)((p) - (pst) + (vst))) | 25 | #define XLATE(p,pst,vst) ((void __iomem *)((p) - (pst) + (vst))) |
26 | 26 | ||
27 | static int initialized; | ||
28 | |||
27 | /* | 29 | /* |
28 | * Intercept ioremap() requests for addresses in our fixed mapping regions. | 30 | * Intercept ioremap() requests for addresses in our fixed mapping regions. |
29 | */ | 31 | */ |
30 | void __iomem *omap_ioremap(unsigned long p, size_t size, unsigned int type) | 32 | void __iomem *omap_ioremap(unsigned long p, size_t size, unsigned int type) |
31 | { | 33 | { |
34 | |||
35 | WARN(!initialized, "Do not use ioremap before init_early\n"); | ||
36 | |||
32 | #ifdef CONFIG_ARCH_OMAP1 | 37 | #ifdef CONFIG_ARCH_OMAP1 |
33 | if (cpu_class_is_omap1()) { | 38 | if (cpu_class_is_omap1()) { |
34 | if (BETWEEN(p, OMAP1_IO_PHYS, OMAP1_IO_SIZE)) | 39 | if (BETWEEN(p, OMAP1_IO_PHYS, OMAP1_IO_SIZE)) |
@@ -147,3 +152,8 @@ void __init omap_init_consistent_dma_size(void) | |||
147 | init_consistent_dma_size(CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE << 20); | 152 | init_consistent_dma_size(CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE << 20); |
148 | #endif | 153 | #endif |
149 | } | 154 | } |
155 | |||
156 | void __init omap_ioremap_init(void) | ||
157 | { | ||
158 | initialized++; | ||
159 | } | ||
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index 26aee5cc1fc1..cd90bedd9306 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c | |||
@@ -85,6 +85,8 @@ | |||
85 | #include <linux/clk.h> | 85 | #include <linux/clk.h> |
86 | #include <linux/clkdev.h> | 86 | #include <linux/clkdev.h> |
87 | #include <linux/pm_runtime.h> | 87 | #include <linux/pm_runtime.h> |
88 | #include <linux/of.h> | ||
89 | #include <linux/notifier.h> | ||
88 | 90 | ||
89 | #include <plat/omap_device.h> | 91 | #include <plat/omap_device.h> |
90 | #include <plat/omap_hwmod.h> | 92 | #include <plat/omap_hwmod.h> |
@@ -96,6 +98,20 @@ | |||
96 | 98 | ||
97 | static int omap_device_register(struct platform_device *pdev); | 99 | static int omap_device_register(struct platform_device *pdev); |
98 | static int omap_early_device_register(struct platform_device *pdev); | 100 | static int omap_early_device_register(struct platform_device *pdev); |
101 | static struct omap_device *omap_device_alloc(struct platform_device *pdev, | ||
102 | struct omap_hwmod **ohs, int oh_cnt, | ||
103 | struct omap_device_pm_latency *pm_lats, | ||
104 | int pm_lats_cnt); | ||
105 | static void omap_device_delete(struct omap_device *od); | ||
106 | |||
107 | |||
108 | static struct omap_device_pm_latency omap_default_latency[] = { | ||
109 | { | ||
110 | .deactivate_func = omap_device_idle_hwmods, | ||
111 | .activate_func = omap_device_enable_hwmods, | ||
112 | .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST, | ||
113 | } | ||
114 | }; | ||
99 | 115 | ||
100 | /* Private functions */ | 116 | /* Private functions */ |
101 | 117 | ||
@@ -303,6 +319,96 @@ static void _add_hwmod_clocks_clkdev(struct omap_device *od, | |||
303 | } | 319 | } |
304 | 320 | ||
305 | 321 | ||
322 | static struct dev_pm_domain omap_device_pm_domain; | ||
323 | |||
324 | /** | ||
325 | * omap_device_build_from_dt - build an omap_device with multiple hwmods | ||
326 | * @pdev_name: name of the platform_device driver to use | ||
327 | * @pdev_id: this platform_device's connection ID | ||
328 | * @oh: ptr to the single omap_hwmod that backs this omap_device | ||
329 | * @pdata: platform_data ptr to associate with the platform_device | ||
330 | * @pdata_len: amount of memory pointed to by @pdata | ||
331 | * @pm_lats: pointer to a omap_device_pm_latency array for this device | ||
332 | * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats | ||
333 | * @is_early_device: should the device be registered as an early device or not | ||
334 | * | ||
335 | * Function for building an omap_device already registered from device-tree | ||
336 | * | ||
337 | * Returns 0 or PTR_ERR() on error. | ||
338 | */ | ||
339 | static int omap_device_build_from_dt(struct platform_device *pdev) | ||
340 | { | ||
341 | struct omap_hwmod **hwmods; | ||
342 | struct omap_device *od; | ||
343 | struct omap_hwmod *oh; | ||
344 | struct device_node *node = pdev->dev.of_node; | ||
345 | const char *oh_name; | ||
346 | int oh_cnt, i, ret = 0; | ||
347 | |||
348 | oh_cnt = of_property_count_strings(node, "ti,hwmods"); | ||
349 | if (!oh_cnt || IS_ERR_VALUE(oh_cnt)) { | ||
350 | dev_warn(&pdev->dev, "No 'hwmods' to build omap_device\n"); | ||
351 | return -ENODEV; | ||
352 | } | ||
353 | |||
354 | hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL); | ||
355 | if (!hwmods) { | ||
356 | ret = -ENOMEM; | ||
357 | goto odbfd_exit; | ||
358 | } | ||
359 | |||
360 | for (i = 0; i < oh_cnt; i++) { | ||
361 | of_property_read_string_index(node, "ti,hwmods", i, &oh_name); | ||
362 | oh = omap_hwmod_lookup(oh_name); | ||
363 | if (!oh) { | ||
364 | dev_err(&pdev->dev, "Cannot lookup hwmod '%s'\n", | ||
365 | oh_name); | ||
366 | ret = -EINVAL; | ||
367 | goto odbfd_exit1; | ||
368 | } | ||
369 | hwmods[i] = oh; | ||
370 | } | ||
371 | |||
372 | od = omap_device_alloc(pdev, hwmods, oh_cnt, NULL, 0); | ||
373 | if (!od) { | ||
374 | dev_err(&pdev->dev, "Cannot allocate omap_device for :%s\n", | ||
375 | oh_name); | ||
376 | ret = PTR_ERR(od); | ||
377 | goto odbfd_exit1; | ||
378 | } | ||
379 | |||
380 | if (of_get_property(node, "ti,no_idle_on_suspend", NULL)) | ||
381 | omap_device_disable_idle_on_suspend(pdev); | ||
382 | |||
383 | pdev->dev.pm_domain = &omap_device_pm_domain; | ||
384 | |||
385 | odbfd_exit1: | ||
386 | kfree(hwmods); | ||
387 | odbfd_exit: | ||
388 | return ret; | ||
389 | } | ||
390 | |||
391 | static int _omap_device_notifier_call(struct notifier_block *nb, | ||
392 | unsigned long event, void *dev) | ||
393 | { | ||
394 | struct platform_device *pdev = to_platform_device(dev); | ||
395 | |||
396 | switch (event) { | ||
397 | case BUS_NOTIFY_ADD_DEVICE: | ||
398 | if (pdev->dev.of_node) | ||
399 | omap_device_build_from_dt(pdev); | ||
400 | break; | ||
401 | |||
402 | case BUS_NOTIFY_DEL_DEVICE: | ||
403 | if (pdev->archdata.od) | ||
404 | omap_device_delete(pdev->archdata.od); | ||
405 | break; | ||
406 | } | ||
407 | |||
408 | return NOTIFY_DONE; | ||
409 | } | ||
410 | |||
411 | |||
306 | /* Public functions for use by core code */ | 412 | /* Public functions for use by core code */ |
307 | 413 | ||
308 | /** | 414 | /** |
@@ -389,6 +495,113 @@ static int omap_device_fill_resources(struct omap_device *od, | |||
389 | } | 495 | } |
390 | 496 | ||
391 | /** | 497 | /** |
498 | * omap_device_alloc - allocate an omap_device | ||
499 | * @pdev: platform_device that will be included in this omap_device | ||
500 | * @oh: ptr to the single omap_hwmod that backs this omap_device | ||
501 | * @pdata: platform_data ptr to associate with the platform_device | ||
502 | * @pdata_len: amount of memory pointed to by @pdata | ||
503 | * @pm_lats: pointer to a omap_device_pm_latency array for this device | ||
504 | * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats | ||
505 | * | ||
506 | * Convenience function for allocating an omap_device structure and filling | ||
507 | * hwmods, resources and pm_latency attributes. | ||
508 | * | ||
509 | * Returns an struct omap_device pointer or ERR_PTR() on error; | ||
510 | */ | ||
511 | static struct omap_device *omap_device_alloc(struct platform_device *pdev, | ||
512 | struct omap_hwmod **ohs, int oh_cnt, | ||
513 | struct omap_device_pm_latency *pm_lats, | ||
514 | int pm_lats_cnt) | ||
515 | { | ||
516 | int ret = -ENOMEM; | ||
517 | struct omap_device *od; | ||
518 | struct resource *res = NULL; | ||
519 | int i, res_count; | ||
520 | struct omap_hwmod **hwmods; | ||
521 | |||
522 | od = kzalloc(sizeof(struct omap_device), GFP_KERNEL); | ||
523 | if (!od) { | ||
524 | ret = -ENOMEM; | ||
525 | goto oda_exit1; | ||
526 | } | ||
527 | od->hwmods_cnt = oh_cnt; | ||
528 | |||
529 | hwmods = kmemdup(ohs, sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL); | ||
530 | if (!hwmods) | ||
531 | goto oda_exit2; | ||
532 | |||
533 | od->hwmods = hwmods; | ||
534 | od->pdev = pdev; | ||
535 | |||
536 | /* | ||
537 | * HACK: Ideally the resources from DT should match, and hwmod | ||
538 | * should just add the missing ones. Since the name is not | ||
539 | * properly populated by DT, stick to hwmod resources only. | ||
540 | */ | ||
541 | if (pdev->num_resources && pdev->resource) | ||
542 | dev_warn(&pdev->dev, "%s(): resources already allocated %d\n", | ||
543 | __func__, pdev->num_resources); | ||
544 | |||
545 | res_count = omap_device_count_resources(od); | ||
546 | if (res_count > 0) { | ||
547 | dev_dbg(&pdev->dev, "%s(): resources allocated from hwmod %d\n", | ||
548 | __func__, res_count); | ||
549 | res = kzalloc(sizeof(struct resource) * res_count, GFP_KERNEL); | ||
550 | if (!res) | ||
551 | goto oda_exit3; | ||
552 | |||
553 | omap_device_fill_resources(od, res); | ||
554 | |||
555 | ret = platform_device_add_resources(pdev, res, res_count); | ||
556 | kfree(res); | ||
557 | |||
558 | if (ret) | ||
559 | goto oda_exit3; | ||
560 | } | ||
561 | |||
562 | if (!pm_lats) { | ||
563 | pm_lats = omap_default_latency; | ||
564 | pm_lats_cnt = ARRAY_SIZE(omap_default_latency); | ||
565 | } | ||
566 | |||
567 | od->pm_lats_cnt = pm_lats_cnt; | ||
568 | od->pm_lats = kmemdup(pm_lats, | ||
569 | sizeof(struct omap_device_pm_latency) * pm_lats_cnt, | ||
570 | GFP_KERNEL); | ||
571 | if (!od->pm_lats) | ||
572 | goto oda_exit3; | ||
573 | |||
574 | pdev->archdata.od = od; | ||
575 | |||
576 | for (i = 0; i < oh_cnt; i++) { | ||
577 | hwmods[i]->od = od; | ||
578 | _add_hwmod_clocks_clkdev(od, hwmods[i]); | ||
579 | } | ||
580 | |||
581 | return od; | ||
582 | |||
583 | oda_exit3: | ||
584 | kfree(hwmods); | ||
585 | oda_exit2: | ||
586 | kfree(od); | ||
587 | oda_exit1: | ||
588 | dev_err(&pdev->dev, "omap_device: build failed (%d)\n", ret); | ||
589 | |||
590 | return ERR_PTR(ret); | ||
591 | } | ||
592 | |||
593 | static void omap_device_delete(struct omap_device *od) | ||
594 | { | ||
595 | if (!od) | ||
596 | return; | ||
597 | |||
598 | od->pdev->archdata.od = NULL; | ||
599 | kfree(od->pm_lats); | ||
600 | kfree(od->hwmods); | ||
601 | kfree(od); | ||
602 | } | ||
603 | |||
604 | /** | ||
392 | * omap_device_build - build and register an omap_device with one omap_hwmod | 605 | * omap_device_build - build and register an omap_device with one omap_hwmod |
393 | * @pdev_name: name of the platform_device driver to use | 606 | * @pdev_name: name of the platform_device driver to use |
394 | * @pdev_id: this platform_device's connection ID | 607 | * @pdev_id: this platform_device's connection ID |
@@ -447,9 +660,6 @@ struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id, | |||
447 | int ret = -ENOMEM; | 660 | int ret = -ENOMEM; |
448 | struct platform_device *pdev; | 661 | struct platform_device *pdev; |
449 | struct omap_device *od; | 662 | struct omap_device *od; |
450 | struct resource *res = NULL; | ||
451 | int i, res_count; | ||
452 | struct omap_hwmod **hwmods; | ||
453 | 663 | ||
454 | if (!ohs || oh_cnt == 0 || !pdev_name) | 664 | if (!ohs || oh_cnt == 0 || !pdev_name) |
455 | return ERR_PTR(-EINVAL); | 665 | return ERR_PTR(-EINVAL); |
@@ -463,67 +673,31 @@ struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id, | |||
463 | goto odbs_exit; | 673 | goto odbs_exit; |
464 | } | 674 | } |
465 | 675 | ||
466 | pr_debug("omap_device: %s: building with %d hwmods\n", pdev_name, | 676 | /* Set the dev_name early to allow dev_xxx in omap_device_alloc */ |
467 | oh_cnt); | 677 | if (pdev->id != -1) |
678 | dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); | ||
679 | else | ||
680 | dev_set_name(&pdev->dev, "%s", pdev->name); | ||
468 | 681 | ||
469 | od = kzalloc(sizeof(struct omap_device), GFP_KERNEL); | 682 | od = omap_device_alloc(pdev, ohs, oh_cnt, pm_lats, pm_lats_cnt); |
470 | if (!od) { | 683 | if (!od) |
471 | ret = -ENOMEM; | ||
472 | goto odbs_exit1; | 684 | goto odbs_exit1; |
473 | } | ||
474 | od->hwmods_cnt = oh_cnt; | ||
475 | |||
476 | hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, | ||
477 | GFP_KERNEL); | ||
478 | if (!hwmods) | ||
479 | goto odbs_exit2; | ||
480 | |||
481 | memcpy(hwmods, ohs, sizeof(struct omap_hwmod *) * oh_cnt); | ||
482 | od->hwmods = hwmods; | ||
483 | od->pdev = pdev; | ||
484 | |||
485 | res_count = omap_device_count_resources(od); | ||
486 | if (res_count > 0) { | ||
487 | res = kzalloc(sizeof(struct resource) * res_count, GFP_KERNEL); | ||
488 | if (!res) | ||
489 | goto odbs_exit3; | ||
490 | |||
491 | omap_device_fill_resources(od, res); | ||
492 | |||
493 | ret = platform_device_add_resources(pdev, res, res_count); | ||
494 | kfree(res); | ||
495 | |||
496 | if (ret) | ||
497 | goto odbs_exit3; | ||
498 | } | ||
499 | 685 | ||
500 | ret = platform_device_add_data(pdev, pdata, pdata_len); | 686 | ret = platform_device_add_data(pdev, pdata, pdata_len); |
501 | if (ret) | 687 | if (ret) |
502 | goto odbs_exit3; | 688 | goto odbs_exit2; |
503 | |||
504 | pdev->archdata.od = od; | ||
505 | 689 | ||
506 | if (is_early_device) | 690 | if (is_early_device) |
507 | ret = omap_early_device_register(pdev); | 691 | ret = omap_early_device_register(pdev); |
508 | else | 692 | else |
509 | ret = omap_device_register(pdev); | 693 | ret = omap_device_register(pdev); |
510 | if (ret) | 694 | if (ret) |
511 | goto odbs_exit3; | 695 | goto odbs_exit2; |
512 | |||
513 | od->pm_lats = pm_lats; | ||
514 | od->pm_lats_cnt = pm_lats_cnt; | ||
515 | |||
516 | for (i = 0; i < oh_cnt; i++) { | ||
517 | hwmods[i]->od = od; | ||
518 | _add_hwmod_clocks_clkdev(od, hwmods[i]); | ||
519 | } | ||
520 | 696 | ||
521 | return pdev; | 697 | return pdev; |
522 | 698 | ||
523 | odbs_exit3: | ||
524 | kfree(hwmods); | ||
525 | odbs_exit2: | 699 | odbs_exit2: |
526 | kfree(od); | 700 | omap_device_delete(od); |
527 | odbs_exit1: | 701 | odbs_exit1: |
528 | platform_device_put(pdev); | 702 | platform_device_put(pdev); |
529 | odbs_exit: | 703 | odbs_exit: |
@@ -844,6 +1018,42 @@ void __iomem *omap_device_get_rt_va(struct omap_device *od) | |||
844 | return omap_hwmod_get_mpu_rt_va(od->hwmods[0]); | 1018 | return omap_hwmod_get_mpu_rt_va(od->hwmods[0]); |
845 | } | 1019 | } |
846 | 1020 | ||
1021 | /** | ||
1022 | * omap_device_get_by_hwmod_name() - convert a hwmod name to | ||
1023 | * device pointer. | ||
1024 | * @oh_name: name of the hwmod device | ||
1025 | * | ||
1026 | * Returns back a struct device * pointer associated with a hwmod | ||
1027 | * device represented by a hwmod_name | ||
1028 | */ | ||
1029 | struct device *omap_device_get_by_hwmod_name(const char *oh_name) | ||
1030 | { | ||
1031 | struct omap_hwmod *oh; | ||
1032 | |||
1033 | if (!oh_name) { | ||
1034 | WARN(1, "%s: no hwmod name!\n", __func__); | ||
1035 | return ERR_PTR(-EINVAL); | ||
1036 | } | ||
1037 | |||
1038 | oh = omap_hwmod_lookup(oh_name); | ||
1039 | if (IS_ERR_OR_NULL(oh)) { | ||
1040 | WARN(1, "%s: no hwmod for %s\n", __func__, | ||
1041 | oh_name); | ||
1042 | return ERR_PTR(oh ? PTR_ERR(oh) : -ENODEV); | ||
1043 | } | ||
1044 | if (IS_ERR_OR_NULL(oh->od)) { | ||
1045 | WARN(1, "%s: no omap_device for %s\n", __func__, | ||
1046 | oh_name); | ||
1047 | return ERR_PTR(oh->od ? PTR_ERR(oh->od) : -ENODEV); | ||
1048 | } | ||
1049 | |||
1050 | if (IS_ERR_OR_NULL(oh->od->pdev)) | ||
1051 | return ERR_PTR(oh->od->pdev ? PTR_ERR(oh->od->pdev) : -ENODEV); | ||
1052 | |||
1053 | return &oh->od->pdev->dev; | ||
1054 | } | ||
1055 | EXPORT_SYMBOL(omap_device_get_by_hwmod_name); | ||
1056 | |||
847 | /* | 1057 | /* |
848 | * Public functions intended for use in omap_device_pm_latency | 1058 | * Public functions intended for use in omap_device_pm_latency |
849 | * .activate_func and .deactivate_func function pointers | 1059 | * .activate_func and .deactivate_func function pointers |
@@ -924,8 +1134,13 @@ struct device omap_device_parent = { | |||
924 | .parent = &platform_bus, | 1134 | .parent = &platform_bus, |
925 | }; | 1135 | }; |
926 | 1136 | ||
1137 | static struct notifier_block platform_nb = { | ||
1138 | .notifier_call = _omap_device_notifier_call, | ||
1139 | }; | ||
1140 | |||
927 | static int __init omap_device_init(void) | 1141 | static int __init omap_device_init(void) |
928 | { | 1142 | { |
1143 | bus_register_notifier(&platform_bus_type, &platform_nb); | ||
929 | return device_register(&omap_device_parent); | 1144 | return device_register(&omap_device_parent); |
930 | } | 1145 | } |
931 | core_initcall(omap_device_init); | 1146 | core_initcall(omap_device_init); |
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c index 363c91e44efb..8b28664d1c62 100644 --- a/arch/arm/plat-omap/sram.c +++ b/arch/arm/plat-omap/sram.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/io.h> | 21 | #include <linux/io.h> |
22 | #include <linux/omapfb.h> | ||
23 | 22 | ||
24 | #include <asm/tlb.h> | 23 | #include <asm/tlb.h> |
25 | #include <asm/cacheflush.h> | 24 | #include <asm/cacheflush.h> |
@@ -29,10 +28,8 @@ | |||
29 | #include <plat/sram.h> | 28 | #include <plat/sram.h> |
30 | #include <plat/board.h> | 29 | #include <plat/board.h> |
31 | #include <plat/cpu.h> | 30 | #include <plat/cpu.h> |
32 | #include <plat/vram.h> | ||
33 | 31 | ||
34 | #include "sram.h" | 32 | #include "sram.h" |
35 | #include "fb.h" | ||
36 | 33 | ||
37 | /* XXX These "sideways" includes are a sign that something is wrong */ | 34 | /* XXX These "sideways" includes are a sign that something is wrong */ |
38 | #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) | 35 | #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) |
@@ -41,16 +38,9 @@ | |||
41 | #endif | 38 | #endif |
42 | 39 | ||
43 | #define OMAP1_SRAM_PA 0x20000000 | 40 | #define OMAP1_SRAM_PA 0x20000000 |
44 | #define OMAP1_SRAM_VA VMALLOC_END | ||
45 | #define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800) | 41 | #define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800) |
46 | #define OMAP2_SRAM_VA 0xfe400000 | ||
47 | #define OMAP2_SRAM_PUB_VA (OMAP2_SRAM_VA + 0x800) | ||
48 | #define OMAP3_SRAM_VA 0xfe400000 | ||
49 | #define OMAP3_SRAM_PUB_PA (OMAP3_SRAM_PA + 0x8000) | 42 | #define OMAP3_SRAM_PUB_PA (OMAP3_SRAM_PA + 0x8000) |
50 | #define OMAP3_SRAM_PUB_VA (OMAP3_SRAM_VA + 0x8000) | ||
51 | #define OMAP4_SRAM_VA 0xfe400000 | ||
52 | #define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000) | 43 | #define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000) |
53 | #define OMAP4_SRAM_PUB_VA (OMAP4_SRAM_VA + 0x4000) | ||
54 | 44 | ||
55 | #if defined(CONFIG_ARCH_OMAP2PLUS) | 45 | #if defined(CONFIG_ARCH_OMAP2PLUS) |
56 | #define SRAM_BOOTLOADER_SZ 0x00 | 46 | #define SRAM_BOOTLOADER_SZ 0x00 |
@@ -73,9 +63,9 @@ | |||
73 | #define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) | 63 | #define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) |
74 | 64 | ||
75 | static unsigned long omap_sram_start; | 65 | static unsigned long omap_sram_start; |
76 | static unsigned long omap_sram_base; | 66 | static void __iomem *omap_sram_base; |
77 | static unsigned long omap_sram_size; | 67 | static unsigned long omap_sram_size; |
78 | static unsigned long omap_sram_ceil; | 68 | static void __iomem *omap_sram_ceil; |
79 | 69 | ||
80 | /* | 70 | /* |
81 | * Depending on the target RAMFS firewall setup, the public usable amount of | 71 | * Depending on the target RAMFS firewall setup, the public usable amount of |
@@ -112,12 +102,9 @@ static int is_sram_locked(void) | |||
112 | */ | 102 | */ |
113 | static void __init omap_detect_sram(void) | 103 | static void __init omap_detect_sram(void) |
114 | { | 104 | { |
115 | unsigned long reserved; | ||
116 | |||
117 | if (cpu_class_is_omap2()) { | 105 | if (cpu_class_is_omap2()) { |
118 | if (is_sram_locked()) { | 106 | if (is_sram_locked()) { |
119 | if (cpu_is_omap34xx()) { | 107 | if (cpu_is_omap34xx()) { |
120 | omap_sram_base = OMAP3_SRAM_PUB_VA; | ||
121 | omap_sram_start = OMAP3_SRAM_PUB_PA; | 108 | omap_sram_start = OMAP3_SRAM_PUB_PA; |
122 | if ((omap_type() == OMAP2_DEVICE_TYPE_EMU) || | 109 | if ((omap_type() == OMAP2_DEVICE_TYPE_EMU) || |
123 | (omap_type() == OMAP2_DEVICE_TYPE_SEC)) { | 110 | (omap_type() == OMAP2_DEVICE_TYPE_SEC)) { |
@@ -126,25 +113,20 @@ static void __init omap_detect_sram(void) | |||
126 | omap_sram_size = 0x8000; /* 32K */ | 113 | omap_sram_size = 0x8000; /* 32K */ |
127 | } | 114 | } |
128 | } else if (cpu_is_omap44xx()) { | 115 | } else if (cpu_is_omap44xx()) { |
129 | omap_sram_base = OMAP4_SRAM_PUB_VA; | ||
130 | omap_sram_start = OMAP4_SRAM_PUB_PA; | 116 | omap_sram_start = OMAP4_SRAM_PUB_PA; |
131 | omap_sram_size = 0xa000; /* 40K */ | 117 | omap_sram_size = 0xa000; /* 40K */ |
132 | } else { | 118 | } else { |
133 | omap_sram_base = OMAP2_SRAM_PUB_VA; | ||
134 | omap_sram_start = OMAP2_SRAM_PUB_PA; | 119 | omap_sram_start = OMAP2_SRAM_PUB_PA; |
135 | omap_sram_size = 0x800; /* 2K */ | 120 | omap_sram_size = 0x800; /* 2K */ |
136 | } | 121 | } |
137 | } else { | 122 | } else { |
138 | if (cpu_is_omap34xx()) { | 123 | if (cpu_is_omap34xx()) { |
139 | omap_sram_base = OMAP3_SRAM_VA; | ||
140 | omap_sram_start = OMAP3_SRAM_PA; | 124 | omap_sram_start = OMAP3_SRAM_PA; |
141 | omap_sram_size = 0x10000; /* 64K */ | 125 | omap_sram_size = 0x10000; /* 64K */ |
142 | } else if (cpu_is_omap44xx()) { | 126 | } else if (cpu_is_omap44xx()) { |
143 | omap_sram_base = OMAP4_SRAM_VA; | ||
144 | omap_sram_start = OMAP4_SRAM_PA; | 127 | omap_sram_start = OMAP4_SRAM_PA; |
145 | omap_sram_size = 0xe000; /* 56K */ | 128 | omap_sram_size = 0xe000; /* 56K */ |
146 | } else { | 129 | } else { |
147 | omap_sram_base = OMAP2_SRAM_VA; | ||
148 | omap_sram_start = OMAP2_SRAM_PA; | 130 | omap_sram_start = OMAP2_SRAM_PA; |
149 | if (cpu_is_omap242x()) | 131 | if (cpu_is_omap242x()) |
150 | omap_sram_size = 0xa0000; /* 640K */ | 132 | omap_sram_size = 0xa0000; /* 640K */ |
@@ -153,7 +135,6 @@ static void __init omap_detect_sram(void) | |||
153 | } | 135 | } |
154 | } | 136 | } |
155 | } else { | 137 | } else { |
156 | omap_sram_base = OMAP1_SRAM_VA; | ||
157 | omap_sram_start = OMAP1_SRAM_PA; | 138 | omap_sram_start = OMAP1_SRAM_PA; |
158 | 139 | ||
159 | if (cpu_is_omap7xx()) | 140 | if (cpu_is_omap7xx()) |
@@ -170,35 +151,14 @@ static void __init omap_detect_sram(void) | |||
170 | omap_sram_size = 0x4000; | 151 | omap_sram_size = 0x4000; |
171 | } | 152 | } |
172 | } | 153 | } |
173 | reserved = omapfb_reserve_sram(omap_sram_start, omap_sram_base, | ||
174 | omap_sram_size, | ||
175 | omap_sram_start + SRAM_BOOTLOADER_SZ, | ||
176 | omap_sram_size - SRAM_BOOTLOADER_SZ); | ||
177 | omap_sram_size -= reserved; | ||
178 | |||
179 | reserved = omap_vram_reserve_sram(omap_sram_start, omap_sram_base, | ||
180 | omap_sram_size, | ||
181 | omap_sram_start + SRAM_BOOTLOADER_SZ, | ||
182 | omap_sram_size - SRAM_BOOTLOADER_SZ); | ||
183 | omap_sram_size -= reserved; | ||
184 | |||
185 | omap_sram_ceil = omap_sram_base + omap_sram_size; | ||
186 | } | 154 | } |
187 | 155 | ||
188 | static struct map_desc omap_sram_io_desc[] __initdata = { | ||
189 | { /* .length gets filled in at runtime */ | ||
190 | .virtual = OMAP1_SRAM_VA, | ||
191 | .pfn = __phys_to_pfn(OMAP1_SRAM_PA), | ||
192 | .type = MT_MEMORY | ||
193 | } | ||
194 | }; | ||
195 | |||
196 | /* | 156 | /* |
197 | * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early. | 157 | * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early. |
198 | */ | 158 | */ |
199 | static void __init omap_map_sram(void) | 159 | static void __init omap_map_sram(void) |
200 | { | 160 | { |
201 | unsigned long base; | 161 | int cached = 1; |
202 | 162 | ||
203 | if (omap_sram_size == 0) | 163 | if (omap_sram_size == 0) |
204 | return; | 164 | return; |
@@ -211,28 +171,18 @@ static void __init omap_map_sram(void) | |||
211 | * the ARM may attempt to write cache lines back to SDRAM | 171 | * the ARM may attempt to write cache lines back to SDRAM |
212 | * which will cause the system to hang. | 172 | * which will cause the system to hang. |
213 | */ | 173 | */ |
214 | omap_sram_io_desc[0].type = MT_MEMORY_NONCACHED; | 174 | cached = 0; |
215 | } | 175 | } |
216 | 176 | ||
217 | omap_sram_io_desc[0].virtual = omap_sram_base; | 177 | omap_sram_start = ROUND_DOWN(omap_sram_start, PAGE_SIZE); |
218 | base = omap_sram_start; | 178 | omap_sram_base = __arm_ioremap_exec(omap_sram_start, omap_sram_size, |
219 | base = ROUND_DOWN(base, PAGE_SIZE); | 179 | cached); |
220 | omap_sram_io_desc[0].pfn = __phys_to_pfn(base); | 180 | if (!omap_sram_base) { |
221 | omap_sram_io_desc[0].length = ROUND_DOWN(omap_sram_size, PAGE_SIZE); | 181 | pr_err("SRAM: Could not map\n"); |
222 | iotable_init(omap_sram_io_desc, ARRAY_SIZE(omap_sram_io_desc)); | 182 | return; |
223 | 183 | } | |
224 | pr_info("SRAM: Mapped pa 0x%08llx to va 0x%08lx size: 0x%lx\n", | ||
225 | (long long) __pfn_to_phys(omap_sram_io_desc[0].pfn), | ||
226 | omap_sram_io_desc[0].virtual, | ||
227 | omap_sram_io_desc[0].length); | ||
228 | 184 | ||
229 | /* | 185 | omap_sram_ceil = omap_sram_base + omap_sram_size; |
230 | * Normally devicemaps_init() would flush caches and tlb after | ||
231 | * mdesc->map_io(), but since we're called from map_io(), we | ||
232 | * must do it here. | ||
233 | */ | ||
234 | local_flush_tlb_all(); | ||
235 | flush_cache_all(); | ||
236 | 186 | ||
237 | /* | 187 | /* |
238 | * Looks like we need to preserve some bootloader code at the | 188 | * Looks like we need to preserve some bootloader code at the |
@@ -251,13 +201,18 @@ static void __init omap_map_sram(void) | |||
251 | */ | 201 | */ |
252 | void *omap_sram_push_address(unsigned long size) | 202 | void *omap_sram_push_address(unsigned long size) |
253 | { | 203 | { |
254 | if (size > (omap_sram_ceil - (omap_sram_base + SRAM_BOOTLOADER_SZ))) { | 204 | unsigned long available, new_ceil = (unsigned long)omap_sram_ceil; |
205 | |||
206 | available = omap_sram_ceil - (omap_sram_base + SRAM_BOOTLOADER_SZ); | ||
207 | |||
208 | if (size > available) { | ||
255 | pr_err("Not enough space in SRAM\n"); | 209 | pr_err("Not enough space in SRAM\n"); |
256 | return NULL; | 210 | return NULL; |
257 | } | 211 | } |
258 | 212 | ||
259 | omap_sram_ceil -= size; | 213 | new_ceil -= size; |
260 | omap_sram_ceil = ROUND_DOWN(omap_sram_ceil, FNCPY_ALIGN); | 214 | new_ceil = ROUND_DOWN(new_ceil, FNCPY_ALIGN); |
215 | omap_sram_ceil = IOMEM(new_ceil); | ||
261 | 216 | ||
262 | return (void *)omap_sram_ceil; | 217 | return (void *)omap_sram_ceil; |
263 | } | 218 | } |