diff options
author | Hiroshi DOYU <Hiroshi.DOYU@nokia.com> | 2009-03-23 21:07:23 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2009-03-23 21:07:23 -0400 |
commit | 6c20a68372f158def0a29657ce11b3609ed24f9a (patch) | |
tree | 22be97db69357d2b5770a5e878220c8d529e9b16 /arch | |
parent | 733ecc5c06bb2892f04ab1881721d665644cd261 (diff) |
omap mailbox: add initial omap3 support
Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-omap2/devices.c | 37 | ||||
-rw-r--r-- | arch/arm/mach-omap2/mailbox.c | 70 | ||||
-rw-r--r-- | arch/arm/plat-omap/Kconfig | 8 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/mach/omap34xx.h | 1 |
4 files changed, 80 insertions, 36 deletions
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index ce03fa750775..d5f2a8118df3 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c | |||
@@ -28,13 +28,14 @@ | |||
28 | #include <mach/eac.h> | 28 | #include <mach/eac.h> |
29 | #include <mach/mmc.h> | 29 | #include <mach/mmc.h> |
30 | 30 | ||
31 | #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE) | 31 | #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE) |
32 | #define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE) | ||
33 | 32 | ||
34 | static struct resource mbox_resources[] = { | 33 | #define MBOX_REG_SIZE 0x120 |
34 | |||
35 | static struct resource omap2_mbox_resources[] = { | ||
35 | { | 36 | { |
36 | .start = OMAP2_MBOX_BASE, | 37 | .start = OMAP24XX_MAILBOX_BASE, |
37 | .end = OMAP2_MBOX_BASE + 0x11f, | 38 | .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1, |
38 | .flags = IORESOURCE_MEM, | 39 | .flags = IORESOURCE_MEM, |
39 | }, | 40 | }, |
40 | { | 41 | { |
@@ -47,20 +48,40 @@ static struct resource mbox_resources[] = { | |||
47 | }, | 48 | }, |
48 | }; | 49 | }; |
49 | 50 | ||
51 | static struct resource omap3_mbox_resources[] = { | ||
52 | { | ||
53 | .start = OMAP34XX_MAILBOX_BASE, | ||
54 | .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1, | ||
55 | .flags = IORESOURCE_MEM, | ||
56 | }, | ||
57 | { | ||
58 | .start = INT_24XX_MAIL_U0_MPU, | ||
59 | .flags = IORESOURCE_IRQ, | ||
60 | }, | ||
61 | }; | ||
62 | |||
50 | static struct platform_device mbox_device = { | 63 | static struct platform_device mbox_device = { |
51 | .name = "mailbox", | 64 | .name = "mailbox", |
52 | .id = -1, | 65 | .id = -1, |
53 | .num_resources = ARRAY_SIZE(mbox_resources), | ||
54 | .resource = mbox_resources, | ||
55 | }; | 66 | }; |
56 | 67 | ||
57 | static inline void omap_init_mbox(void) | 68 | static inline void omap_init_mbox(void) |
58 | { | 69 | { |
70 | if (cpu_is_omap2420()) { | ||
71 | mbox_device.num_resources = ARRAY_SIZE(omap2_mbox_resources); | ||
72 | mbox_device.resource = omap2_mbox_resources; | ||
73 | } else if (cpu_is_omap3430()) { | ||
74 | mbox_device.num_resources = ARRAY_SIZE(omap3_mbox_resources); | ||
75 | mbox_device.resource = omap3_mbox_resources; | ||
76 | } else { | ||
77 | pr_err("%s: platform not supported\n", __func__); | ||
78 | return; | ||
79 | } | ||
59 | platform_device_register(&mbox_device); | 80 | platform_device_register(&mbox_device); |
60 | } | 81 | } |
61 | #else | 82 | #else |
62 | static inline void omap_init_mbox(void) { } | 83 | static inline void omap_init_mbox(void) { } |
63 | #endif | 84 | #endif /* CONFIG_OMAP_MBOX_FWK */ |
64 | 85 | ||
65 | #if defined(CONFIG_OMAP_STI) | 86 | #if defined(CONFIG_OMAP_STI) |
66 | 87 | ||
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c index 4487a4de52f3..d925ef3d7d48 100644 --- a/arch/arm/mach-omap2/mailbox.c +++ b/arch/arm/mach-omap2/mailbox.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u))) | 30 | #define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u))) |
31 | #define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1)) | 31 | #define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1)) |
32 | 32 | ||
33 | static unsigned long mbox_base; | 33 | static void __iomem *mbox_base; |
34 | 34 | ||
35 | struct omap_mbox2_fifo { | 35 | struct omap_mbox2_fifo { |
36 | unsigned long msg; | 36 | unsigned long msg; |
@@ -52,14 +52,14 @@ static struct clk *mbox_ick_handle; | |||
52 | static void omap2_mbox_enable_irq(struct omap_mbox *mbox, | 52 | static void omap2_mbox_enable_irq(struct omap_mbox *mbox, |
53 | omap_mbox_type_t irq); | 53 | omap_mbox_type_t irq); |
54 | 54 | ||
55 | static inline unsigned int mbox_read_reg(unsigned int reg) | 55 | static inline unsigned int mbox_read_reg(size_t ofs) |
56 | { | 56 | { |
57 | return __raw_readl(mbox_base + reg); | 57 | return __raw_readl(mbox_base + ofs); |
58 | } | 58 | } |
59 | 59 | ||
60 | static inline void mbox_write_reg(unsigned int val, unsigned int reg) | 60 | static inline void mbox_write_reg(u32 val, size_t ofs) |
61 | { | 61 | { |
62 | __raw_writel(val, mbox_base + reg); | 62 | __raw_writel(val, mbox_base + ofs); |
63 | } | 63 | } |
64 | 64 | ||
65 | /* Mailbox H/W preparations */ | 65 | /* Mailbox H/W preparations */ |
@@ -208,7 +208,7 @@ struct omap_mbox mbox_dsp_info = { | |||
208 | }; | 208 | }; |
209 | EXPORT_SYMBOL(mbox_dsp_info); | 209 | EXPORT_SYMBOL(mbox_dsp_info); |
210 | 210 | ||
211 | /* IVA */ | 211 | #if defined(CONFIG_ARCH_OMAP2420) /* IVA */ |
212 | static struct omap_mbox2_priv omap2_mbox_iva_priv = { | 212 | static struct omap_mbox2_priv omap2_mbox_iva_priv = { |
213 | .tx_fifo = { | 213 | .tx_fifo = { |
214 | .msg = MAILBOX_MESSAGE(2), | 214 | .msg = MAILBOX_MESSAGE(2), |
@@ -229,17 +229,12 @@ static struct omap_mbox mbox_iva_info = { | |||
229 | .ops = &omap2_mbox_ops, | 229 | .ops = &omap2_mbox_ops, |
230 | .priv = &omap2_mbox_iva_priv, | 230 | .priv = &omap2_mbox_iva_priv, |
231 | }; | 231 | }; |
232 | #endif | ||
232 | 233 | ||
233 | static int __init omap2_mbox_probe(struct platform_device *pdev) | 234 | static int __init omap2_mbox_probe(struct platform_device *pdev) |
234 | { | 235 | { |
235 | struct resource *res; | 236 | struct resource *res; |
236 | int ret = 0; | 237 | int ret; |
237 | |||
238 | if (pdev->num_resources != 3) { | ||
239 | dev_err(&pdev->dev, "invalid number of resources: %d\n", | ||
240 | pdev->num_resources); | ||
241 | return -ENODEV; | ||
242 | } | ||
243 | 238 | ||
244 | /* MBOX base */ | 239 | /* MBOX base */ |
245 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 240 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -247,34 +242,53 @@ static int __init omap2_mbox_probe(struct platform_device *pdev) | |||
247 | dev_err(&pdev->dev, "invalid mem resource\n"); | 242 | dev_err(&pdev->dev, "invalid mem resource\n"); |
248 | return -ENODEV; | 243 | return -ENODEV; |
249 | } | 244 | } |
250 | mbox_base = res->start; | 245 | mbox_base = ioremap(res->start, res->end - res->start); |
246 | if (!mbox_base) | ||
247 | return -ENOMEM; | ||
251 | 248 | ||
252 | /* DSP IRQ */ | 249 | /* DSP or IVA2 IRQ */ |
253 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 250 | mbox_dsp_info.irq = platform_get_irq(pdev, 0); |
254 | if (unlikely(!res)) { | 251 | if (mbox_dsp_info.irq < 0) { |
255 | dev_err(&pdev->dev, "invalid irq resource\n"); | 252 | dev_err(&pdev->dev, "invalid irq resource\n"); |
256 | return -ENODEV; | 253 | ret = -ENODEV; |
254 | goto err_dsp; | ||
257 | } | 255 | } |
258 | mbox_dsp_info.irq = res->start; | ||
259 | 256 | ||
260 | ret = omap_mbox_register(&mbox_dsp_info); | 257 | ret = omap_mbox_register(&mbox_dsp_info); |
261 | 258 | if (ret) | |
262 | /* IVA IRQ */ | 259 | goto err_dsp; |
263 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 1); | 260 | |
264 | if (unlikely(!res)) { | 261 | #if defined(CONFIG_ARCH_OMAP2420) /* IVA */ |
265 | dev_err(&pdev->dev, "invalid irq resource\n"); | 262 | if (cpu_is_omap2420()) { |
266 | return -ENODEV; | 263 | /* IVA IRQ */ |
264 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 1); | ||
265 | if (unlikely(!res)) { | ||
266 | dev_err(&pdev->dev, "invalid irq resource\n"); | ||
267 | ret = -ENODEV; | ||
268 | goto err_iva1; | ||
269 | } | ||
270 | mbox_iva_info.irq = res->start; | ||
271 | ret = omap_mbox_register(&mbox_iva_info); | ||
272 | if (ret) | ||
273 | goto err_iva1; | ||
267 | } | 274 | } |
268 | mbox_iva_info.irq = res->start; | 275 | #endif |
269 | 276 | return 0; | |
270 | ret = omap_mbox_register(&mbox_iva_info); | ||
271 | 277 | ||
278 | err_iva1: | ||
279 | omap_mbox_unregister(&mbox_dsp_info); | ||
280 | err_dsp: | ||
281 | iounmap(mbox_base); | ||
272 | return ret; | 282 | return ret; |
273 | } | 283 | } |
274 | 284 | ||
275 | static int omap2_mbox_remove(struct platform_device *pdev) | 285 | static int omap2_mbox_remove(struct platform_device *pdev) |
276 | { | 286 | { |
287 | #if defined(CONFIG_ARCH_OMAP2420) | ||
288 | omap_mbox_unregister(&mbox_iva_info); | ||
289 | #endif | ||
277 | omap_mbox_unregister(&mbox_dsp_info); | 290 | omap_mbox_unregister(&mbox_dsp_info); |
291 | iounmap(mbox_base); | ||
278 | return 0; | 292 | return 0; |
279 | } | 293 | } |
280 | 294 | ||
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig index 46d3b0b9ce69..6b1d50610328 100644 --- a/arch/arm/plat-omap/Kconfig +++ b/arch/arm/plat-omap/Kconfig | |||
@@ -104,6 +104,14 @@ config OMAP_MCBSP | |||
104 | Say Y here if you want support for the OMAP Multichannel | 104 | Say Y here if you want support for the OMAP Multichannel |
105 | Buffered Serial Port. | 105 | Buffered Serial Port. |
106 | 106 | ||
107 | config OMAP_MBOX_FWK | ||
108 | tristate "Mailbox framework support" | ||
109 | depends on ARCH_OMAP | ||
110 | default n | ||
111 | help | ||
112 | Say Y here if you want to use OMAP Mailbox framework support for | ||
113 | DSP, IVA1.0 and IVA2 in OMAP1/2/3. | ||
114 | |||
107 | choice | 115 | choice |
108 | prompt "System timer" | 116 | prompt "System timer" |
109 | default OMAP_MPU_TIMER | 117 | default OMAP_MPU_TIMER |
diff --git a/arch/arm/plat-omap/include/mach/omap34xx.h b/arch/arm/plat-omap/include/mach/omap34xx.h index 8e0479fff05a..89173f16b9b7 100644 --- a/arch/arm/plat-omap/include/mach/omap34xx.h +++ b/arch/arm/plat-omap/include/mach/omap34xx.h | |||
@@ -61,6 +61,7 @@ | |||
61 | #define OMAP2_CM_BASE OMAP3430_CM_BASE | 61 | #define OMAP2_CM_BASE OMAP3430_CM_BASE |
62 | #define OMAP2_PRM_BASE OMAP3430_PRM_BASE | 62 | #define OMAP2_PRM_BASE OMAP3430_PRM_BASE |
63 | #define OMAP2_VA_IC_BASE IO_ADDRESS(OMAP34XX_IC_BASE) | 63 | #define OMAP2_VA_IC_BASE IO_ADDRESS(OMAP34XX_IC_BASE) |
64 | #define OMAP34XX_MAILBOX_BASE (L4_34XX_BASE + 0x94000) | ||
64 | 65 | ||
65 | #endif | 66 | #endif |
66 | 67 | ||