David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * USB |
| 3 | */ |
| 4 | #include <linux/kernel.h> |
| 5 | #include <linux/module.h> |
| 6 | #include <linux/init.h> |
| 7 | #include <linux/platform_device.h> |
| 8 | #include <linux/dma-mapping.h> |
| 9 | |
| 10 | #include <linux/usb/musb.h> |
| 11 | #include <linux/usb/otg.h> |
| 12 | |
| 13 | #include <mach/common.h> |
| 14 | #include <mach/hardware.h> |
David Brownell | d0e58ae | 2009-01-18 17:29:10 +0100 | [diff] [blame] | 15 | #include <mach/irqs.h> |
Sergei Shtylyov | efd9118 | 2009-07-16 19:58:53 +0400 | [diff] [blame] | 16 | #include <mach/cputype.h> |
Sergei Shtylyov | e5d3d25 | 2009-09-25 23:14:02 +0400 | [diff] [blame^] | 17 | #include <mach/usb.h> |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 18 | |
Sergei Shtylyov | e5d3d25 | 2009-09-25 23:14:02 +0400 | [diff] [blame^] | 19 | #define DAVINCI_USB_OTG_BASE 0x01c64000 |
| 20 | #define DA8XX_USB1_BASE 0x01e25000 |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 21 | |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 22 | #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) |
| 23 | static struct musb_hdrc_eps_bits musb_eps[] = { |
| 24 | { "ep1_tx", 8, }, |
| 25 | { "ep1_rx", 8, }, |
| 26 | { "ep2_tx", 8, }, |
| 27 | { "ep2_rx", 8, }, |
| 28 | { "ep3_tx", 5, }, |
| 29 | { "ep3_rx", 5, }, |
| 30 | { "ep4_tx", 5, }, |
| 31 | { "ep4_rx", 5, }, |
| 32 | }; |
| 33 | |
| 34 | static struct musb_hdrc_config musb_config = { |
| 35 | .multipoint = true, |
| 36 | .dyn_fifo = true, |
| 37 | .soft_con = true, |
| 38 | .dma = true, |
| 39 | |
| 40 | .num_eps = 5, |
| 41 | .dma_channels = 8, |
| 42 | .ram_bits = 10, |
| 43 | .eps_bits = musb_eps, |
| 44 | }; |
| 45 | |
| 46 | static struct musb_hdrc_platform_data usb_data = { |
| 47 | #if defined(CONFIG_USB_MUSB_OTG) |
| 48 | /* OTG requires a Mini-AB connector */ |
| 49 | .mode = MUSB_OTG, |
| 50 | #elif defined(CONFIG_USB_MUSB_PERIPHERAL) |
| 51 | .mode = MUSB_PERIPHERAL, |
| 52 | #elif defined(CONFIG_USB_MUSB_HOST) |
| 53 | .mode = MUSB_HOST, |
| 54 | #endif |
David Brownell | 34f32c9 | 2009-02-20 13:45:17 -0800 | [diff] [blame] | 55 | .clock = "usb", |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 56 | .config = &musb_config, |
| 57 | }; |
| 58 | |
| 59 | static struct resource usb_resources[] = { |
| 60 | { |
| 61 | /* physical address */ |
| 62 | .start = DAVINCI_USB_OTG_BASE, |
| 63 | .end = DAVINCI_USB_OTG_BASE + 0x5ff, |
| 64 | .flags = IORESOURCE_MEM, |
| 65 | }, |
| 66 | { |
| 67 | .start = IRQ_USBINT, |
| 68 | .flags = IORESOURCE_IRQ, |
| 69 | }, |
Sergei Shtylyov | efd9118 | 2009-07-16 19:58:53 +0400 | [diff] [blame] | 70 | { |
| 71 | /* placeholder for the dedicated CPPI IRQ */ |
| 72 | .flags = IORESOURCE_IRQ, |
| 73 | }, |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 74 | }; |
| 75 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 76 | static u64 usb_dmamask = DMA_BIT_MASK(32); |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 77 | |
| 78 | static struct platform_device usb_dev = { |
| 79 | .name = "musb_hdrc", |
| 80 | .id = -1, |
| 81 | .dev = { |
| 82 | .platform_data = &usb_data, |
| 83 | .dma_mask = &usb_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 84 | .coherent_dma_mask = DMA_BIT_MASK(32), |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 85 | }, |
| 86 | .resource = usb_resources, |
| 87 | .num_resources = ARRAY_SIZE(usb_resources), |
| 88 | }; |
| 89 | |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 90 | void __init setup_usb(unsigned mA, unsigned potpgt_msec) |
| 91 | { |
| 92 | usb_data.power = mA / 2; |
| 93 | usb_data.potpgt = potpgt_msec / 2; |
Sergei Shtylyov | efd9118 | 2009-07-16 19:58:53 +0400 | [diff] [blame] | 94 | |
| 95 | if (cpu_is_davinci_dm646x()) { |
| 96 | /* Override the defaults as DM6467 uses different IRQs. */ |
| 97 | usb_dev.resource[1].start = IRQ_DM646X_USBINT; |
| 98 | usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT; |
| 99 | } else /* other devices don't have dedicated CPPI IRQ */ |
| 100 | usb_dev.num_resources = 2; |
| 101 | |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 102 | platform_device_register(&usb_dev); |
| 103 | } |
| 104 | |
| 105 | #else |
| 106 | |
| 107 | void __init setup_usb(unsigned mA, unsigned potpgt_msec) |
| 108 | { |
| 109 | } |
| 110 | |
| 111 | #endif /* CONFIG_USB_MUSB_HDRC */ |
| 112 | |
Sergei Shtylyov | e5d3d25 | 2009-09-25 23:14:02 +0400 | [diff] [blame^] | 113 | #ifdef CONFIG_ARCH_DAVINCI_DA8XX |
| 114 | static struct resource da8xx_usb11_resources[] = { |
| 115 | [0] = { |
| 116 | .start = DA8XX_USB1_BASE, |
| 117 | .end = DA8XX_USB1_BASE + SZ_4K - 1, |
| 118 | .flags = IORESOURCE_MEM, |
| 119 | }, |
| 120 | [1] = { |
| 121 | .start = IRQ_DA8XX_IRQN, |
| 122 | .end = IRQ_DA8XX_IRQN, |
| 123 | .flags = IORESOURCE_IRQ, |
| 124 | }, |
| 125 | }; |
| 126 | |
| 127 | static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32); |
| 128 | |
| 129 | static struct platform_device da8xx_usb11_device = { |
| 130 | .name = "ohci", |
| 131 | .id = 0, |
| 132 | .dev = { |
| 133 | .dma_mask = &da8xx_usb11_dma_mask, |
| 134 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 135 | }, |
| 136 | .num_resources = ARRAY_SIZE(da8xx_usb11_resources), |
| 137 | .resource = da8xx_usb11_resources, |
| 138 | }; |
| 139 | |
| 140 | int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata) |
| 141 | { |
| 142 | da8xx_usb11_device.dev.platform_data = pdata; |
| 143 | return platform_device_register(&da8xx_usb11_device); |
| 144 | } |
| 145 | #endif /* CONFIG_DAVINCI_DA8XX */ |