Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/usb-musb.c |
| 3 | * |
| 4 | * This file will contain the board specific details for the |
| 5 | * MENTOR USB OTG controller on OMAP3430 |
| 6 | * |
| 7 | * Copyright (C) 2007-2008 Texas Instruments |
| 8 | * Copyright (C) 2008 Nokia Corporation |
| 9 | * Author: Vikram Pandita |
| 10 | * |
| 11 | * Generalization by: |
| 12 | * Felipe Balbi <felipe.balbi@nokia.com> |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License version 2 as |
| 16 | * published by the Free Software Foundation. |
| 17 | */ |
| 18 | |
| 19 | #include <linux/types.h> |
| 20 | #include <linux/errno.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/clk.h> |
| 24 | #include <linux/dma-mapping.h> |
| 25 | #include <linux/io.h> |
| 26 | |
| 27 | #include <linux/usb/musb.h> |
| 28 | |
| 29 | #include <mach/hardware.h> |
| 30 | #include <mach/irqs.h> |
Ajay Kumar Gupta | 3a0d30b | 2010-10-19 10:08:11 +0300 | [diff] [blame] | 31 | #include <mach/am35xx.h> |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 32 | #include <plat/usb.h> |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 33 | |
Felipe Balbi | 7c92554 | 2010-12-01 14:23:48 +0200 | [diff] [blame^] | 34 | #if defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined (CONFIG_USB_MUSB_AM35X) |
Peter 'p2' De Schrijver | 94a3ef6 | 2009-01-19 19:09:22 +0200 | [diff] [blame] | 35 | |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 36 | static struct resource musb_resources[] = { |
| 37 | [0] = { /* start and end set dynamically */ |
| 38 | .flags = IORESOURCE_MEM, |
| 39 | }, |
| 40 | [1] = { /* general IRQ */ |
| 41 | .start = INT_243X_HS_USB_MC, |
| 42 | .flags = IORESOURCE_IRQ, |
Hema Kalliguddi | fcf173e | 2010-09-29 11:26:39 -0500 | [diff] [blame] | 43 | .name = "mc", |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 44 | }, |
| 45 | [2] = { /* DMA IRQ */ |
| 46 | .start = INT_243X_HS_USB_DMA, |
| 47 | .flags = IORESOURCE_IRQ, |
Hema Kalliguddi | fcf173e | 2010-09-29 11:26:39 -0500 | [diff] [blame] | 48 | .name = "dma", |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 49 | }, |
| 50 | }; |
| 51 | |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 52 | static struct musb_hdrc_config musb_config = { |
| 53 | .multipoint = 1, |
| 54 | .dyn_fifo = 1, |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 55 | .num_eps = 16, |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 56 | .ram_bits = 12, |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | static struct musb_hdrc_platform_data musb_plat = { |
| 60 | #ifdef CONFIG_USB_MUSB_OTG |
| 61 | .mode = MUSB_OTG, |
| 62 | #elif defined(CONFIG_USB_MUSB_HDRC_HCD) |
| 63 | .mode = MUSB_HOST, |
| 64 | #elif defined(CONFIG_USB_GADGET_MUSB_HDRC) |
| 65 | .mode = MUSB_PERIPHERAL, |
| 66 | #endif |
| 67 | /* .clock is set dynamically */ |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 68 | .config = &musb_config, |
| 69 | |
| 70 | /* REVISIT charge pump on TWL4030 can supply up to |
| 71 | * 100 mA ... but this value is board-specific, like |
| 72 | * "mode", and should be passed to usb_musb_init(). |
| 73 | */ |
| 74 | .power = 50, /* up to 100 mA */ |
| 75 | }; |
| 76 | |
Yang Hongyang | e930438 | 2009-04-13 14:40:14 -0700 | [diff] [blame] | 77 | static u64 musb_dmamask = DMA_BIT_MASK(32); |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 78 | |
| 79 | static struct platform_device musb_device = { |
| 80 | .name = "musb_hdrc", |
| 81 | .id = -1, |
| 82 | .dev = { |
| 83 | .dma_mask = &musb_dmamask, |
Yang Hongyang | e930438 | 2009-04-13 14:40:14 -0700 | [diff] [blame] | 84 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 85 | .platform_data = &musb_plat, |
| 86 | }, |
| 87 | .num_resources = ARRAY_SIZE(musb_resources), |
| 88 | .resource = musb_resources, |
| 89 | }; |
| 90 | |
Maulik Mankad | 884b836 | 2010-02-17 14:09:30 -0800 | [diff] [blame] | 91 | void __init usb_musb_init(struct omap_musb_board_data *board_data) |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 92 | { |
Maulik Mankad | bce0668 | 2010-02-17 14:09:32 -0800 | [diff] [blame] | 93 | if (cpu_is_omap243x()) { |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 94 | musb_resources[0].start = OMAP243X_HS_BASE; |
Ajay Kumar Gupta | 3a0d30b | 2010-10-19 10:08:11 +0300 | [diff] [blame] | 95 | } else if (cpu_is_omap3517() || cpu_is_omap3505()) { |
| 96 | musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE; |
| 97 | musb_resources[1].start = INT_35XX_USBOTG_IRQ; |
Maulik Mankad | bce0668 | 2010-02-17 14:09:32 -0800 | [diff] [blame] | 98 | } else if (cpu_is_omap34xx()) { |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 99 | musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE; |
Maulik Mankad | bce0668 | 2010-02-17 14:09:32 -0800 | [diff] [blame] | 100 | } else if (cpu_is_omap44xx()) { |
| 101 | musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE; |
Santosh Shilimkar | 5772ca7 | 2010-02-18 03:14:12 +0530 | [diff] [blame] | 102 | musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N; |
| 103 | musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N; |
Maulik Mankad | bce0668 | 2010-02-17 14:09:32 -0800 | [diff] [blame] | 104 | } |
Felipe Balbi | f982855 | 2010-02-17 14:09:29 -0800 | [diff] [blame] | 105 | musb_resources[0].end = musb_resources[0].start + SZ_4K - 1; |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 106 | |
| 107 | /* |
| 108 | * REVISIT: This line can be removed once all the platforms using |
| 109 | * musb_core.c have been converted to use use clkdev. |
| 110 | */ |
| 111 | musb_plat.clock = "ick"; |
Maulik Mankad | 884b836 | 2010-02-17 14:09:30 -0800 | [diff] [blame] | 112 | musb_plat.board_data = board_data; |
| 113 | musb_plat.power = board_data->power >> 1; |
| 114 | musb_plat.mode = board_data->mode; |
Ajay Kumar Gupta | 58815fa | 2010-03-25 13:25:27 +0200 | [diff] [blame] | 115 | musb_plat.extvbus = board_data->extvbus; |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 116 | |
Felipe Balbi | bdfa351 | 2010-02-17 14:09:31 -0800 | [diff] [blame] | 117 | if (platform_device_register(&musb_device) < 0) |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 118 | printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n"); |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 119 | } |
Peter 'p2' De Schrijver | 94a3ef6 | 2009-01-19 19:09:22 +0200 | [diff] [blame] | 120 | |
| 121 | #else |
Maulik Mankad | 884b836 | 2010-02-17 14:09:30 -0800 | [diff] [blame] | 122 | void __init usb_musb_init(struct omap_musb_board_data *board_data) |
Peter 'p2' De Schrijver | 94a3ef6 | 2009-01-19 19:09:22 +0200 | [diff] [blame] | 123 | { |
Peter 'p2' De Schrijver | 94a3ef6 | 2009-01-19 19:09:22 +0200 | [diff] [blame] | 124 | } |
| 125 | #endif /* CONFIG_USB_MUSB_SOC */ |