David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * USB |
| 3 | */ |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 4 | #include <linux/init.h> |
| 5 | #include <linux/platform_device.h> |
| 6 | #include <linux/dma-mapping.h> |
| 7 | |
| 8 | #include <linux/usb/musb.h> |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 9 | |
| 10 | #include <mach/common.h> |
David Brownell | d0e58ae | 2009-01-18 17:29:10 +0100 | [diff] [blame] | 11 | #include <mach/irqs.h> |
Sergei Shtylyov | efd9118 | 2009-07-16 19:58:53 +0400 | [diff] [blame] | 12 | #include <mach/cputype.h> |
Arnd Bergmann | ec2a083 | 2012-08-24 15:11:34 +0200 | [diff] [blame] | 13 | #include <linux/platform_data/usb-davinci.h> |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 14 | |
Sergei Shtylyov | e5d3d25 | 2009-09-25 23:14:02 +0400 | [diff] [blame] | 15 | #define DAVINCI_USB_OTG_BASE 0x01c64000 |
Sergei Shtylyov | b0ea26e | 2009-10-30 23:49:44 +0400 | [diff] [blame] | 16 | |
Lad, Prabhakar | a0a56db | 2013-04-01 12:43:44 +0530 | [diff] [blame] | 17 | #if IS_ENABLED(CONFIG_USB_MUSB_HDRC) |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 18 | static struct musb_hdrc_config musb_config = { |
| 19 | .multipoint = true, |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 20 | |
| 21 | .num_eps = 5, |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 22 | .ram_bits = 10, |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | static struct musb_hdrc_platform_data usb_data = { |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 26 | /* OTG requires a Mini-AB connector */ |
| 27 | .mode = MUSB_OTG, |
David Brownell | 34f32c9 | 2009-02-20 13:45:17 -0800 | [diff] [blame] | 28 | .clock = "usb", |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 29 | .config = &musb_config, |
| 30 | }; |
| 31 | |
| 32 | static struct resource usb_resources[] = { |
| 33 | { |
| 34 | /* physical address */ |
| 35 | .start = DAVINCI_USB_OTG_BASE, |
| 36 | .end = DAVINCI_USB_OTG_BASE + 0x5ff, |
| 37 | .flags = IORESOURCE_MEM, |
| 38 | }, |
| 39 | { |
| 40 | .start = IRQ_USBINT, |
| 41 | .flags = IORESOURCE_IRQ, |
Hema Kalliguddi | fcf173e | 2010-09-29 11:26:39 -0500 | [diff] [blame] | 42 | .name = "mc" |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 43 | }, |
Sergei Shtylyov | efd9118 | 2009-07-16 19:58:53 +0400 | [diff] [blame] | 44 | { |
| 45 | /* placeholder for the dedicated CPPI IRQ */ |
| 46 | .flags = IORESOURCE_IRQ, |
Hema Kalliguddi | fcf173e | 2010-09-29 11:26:39 -0500 | [diff] [blame] | 47 | .name = "dma" |
Sergei Shtylyov | efd9118 | 2009-07-16 19:58:53 +0400 | [diff] [blame] | 48 | }, |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 51 | static u64 usb_dmamask = DMA_BIT_MASK(32); |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 52 | |
| 53 | static struct platform_device usb_dev = { |
Felipe Balbi | 73b089b | 2010-12-02 09:16:55 +0200 | [diff] [blame] | 54 | .name = "musb-davinci", |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 55 | .id = -1, |
| 56 | .dev = { |
| 57 | .platform_data = &usb_data, |
| 58 | .dma_mask = &usb_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 59 | .coherent_dma_mask = DMA_BIT_MASK(32), |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 60 | }, |
| 61 | .resource = usb_resources, |
| 62 | .num_resources = ARRAY_SIZE(usb_resources), |
| 63 | }; |
| 64 | |
Sergei Shtylyov | 355fb4e | 2009-10-30 23:46:14 +0400 | [diff] [blame] | 65 | void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 66 | { |
Sergei Shtylyov | 355fb4e | 2009-10-30 23:46:14 +0400 | [diff] [blame] | 67 | usb_data.power = mA > 510 ? 255 : mA / 2; |
| 68 | usb_data.potpgt = (potpgt_ms + 1) / 2; |
Sergei Shtylyov | efd9118 | 2009-07-16 19:58:53 +0400 | [diff] [blame] | 69 | |
| 70 | if (cpu_is_davinci_dm646x()) { |
| 71 | /* Override the defaults as DM6467 uses different IRQs. */ |
| 72 | usb_dev.resource[1].start = IRQ_DM646X_USBINT; |
| 73 | usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT; |
| 74 | } else /* other devices don't have dedicated CPPI IRQ */ |
| 75 | usb_dev.num_resources = 2; |
| 76 | |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 77 | platform_device_register(&usb_dev); |
| 78 | } |
| 79 | |
| 80 | #else |
| 81 | |
Sergei Shtylyov | 355fb4e | 2009-10-30 23:46:14 +0400 | [diff] [blame] | 82 | void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) |
David Brownell | cece6e5 | 2008-09-07 23:41:57 -0700 | [diff] [blame] | 83 | { |
| 84 | } |
| 85 | |
| 86 | #endif /* CONFIG_USB_MUSB_HDRC */ |