| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * USB | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #include <linux/init.h>
 | 
					
						
							|  |  |  | #include <linux/platform_device.h>
 | 
					
						
							|  |  |  | #include <linux/dma-mapping.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/usb/musb.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <mach/common.h>
 | 
					
						
							| 
									
										
										
										
											2009-01-18 17:29:10 +01:00
										 |  |  | #include <mach/irqs.h>
 | 
					
						
							| 
									
										
										
										
											2009-07-16 19:58:53 +04:00
										 |  |  | #include <mach/cputype.h>
 | 
					
						
							| 
									
										
										
										
											2013-04-10 14:57:15 +05:30
										 |  |  | #include <mach/da8xx.h>
 | 
					
						
							| 
									
										
										
										
											2012-08-24 15:11:34 +02:00
										 |  |  | #include <linux/platform_data/usb-davinci.h>
 | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-25 23:14:02 +04:00
										 |  |  | #define DAVINCI_USB_OTG_BASE	0x01c64000
 | 
					
						
							| 
									
										
										
										
											2009-10-30 23:49:44 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define DA8XX_USB0_BASE 	0x01e00000
 | 
					
						
							| 
									
										
										
										
											2009-09-25 23:14:02 +04:00
										 |  |  | #define DA8XX_USB1_BASE 	0x01e25000
 | 
					
						
							| 
									
										
										
										
											2009-04-14 07:04:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-01 12:43:44 +05:30
										 |  |  | #if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
 | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | static struct musb_hdrc_eps_bits musb_eps[] = { | 
					
						
							|  |  |  | 	{ "ep1_tx", 8, }, | 
					
						
							|  |  |  | 	{ "ep1_rx", 8, }, | 
					
						
							|  |  |  | 	{ "ep2_tx", 8, }, | 
					
						
							|  |  |  | 	{ "ep2_rx", 8, }, | 
					
						
							|  |  |  | 	{ "ep3_tx", 5, }, | 
					
						
							|  |  |  | 	{ "ep3_rx", 5, }, | 
					
						
							|  |  |  | 	{ "ep4_tx", 5, }, | 
					
						
							|  |  |  | 	{ "ep4_rx", 5, }, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct musb_hdrc_config musb_config = { | 
					
						
							|  |  |  | 	.multipoint	= true, | 
					
						
							|  |  |  | 	.dyn_fifo	= true, | 
					
						
							|  |  |  | 	.soft_con	= true, | 
					
						
							|  |  |  | 	.dma		= true, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	.num_eps	= 5, | 
					
						
							|  |  |  | 	.dma_channels	= 8, | 
					
						
							|  |  |  | 	.ram_bits	= 10, | 
					
						
							|  |  |  | 	.eps_bits	= musb_eps, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct musb_hdrc_platform_data usb_data = { | 
					
						
							|  |  |  | 	/* OTG requires a Mini-AB connector */ | 
					
						
							|  |  |  | 	.mode           = MUSB_OTG, | 
					
						
							| 
									
										
										
										
											2009-02-20 13:45:17 -08:00
										 |  |  | 	.clock		= "usb", | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | 	.config		= &musb_config, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct resource usb_resources[] = { | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		/* physical address */ | 
					
						
							|  |  |  | 		.start          = DAVINCI_USB_OTG_BASE, | 
					
						
							|  |  |  | 		.end            = DAVINCI_USB_OTG_BASE + 0x5ff, | 
					
						
							|  |  |  | 		.flags          = IORESOURCE_MEM, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.start          = IRQ_USBINT, | 
					
						
							|  |  |  | 		.flags          = IORESOURCE_IRQ, | 
					
						
							| 
									
										
										
										
											2010-09-29 11:26:39 -05:00
										 |  |  | 		.name		= "mc" | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2009-07-16 19:58:53 +04:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		/* placeholder for the dedicated CPPI IRQ */ | 
					
						
							|  |  |  | 		.flags          = IORESOURCE_IRQ, | 
					
						
							| 
									
										
										
										
											2010-09-29 11:26:39 -05:00
										 |  |  | 		.name		= "dma" | 
					
						
							| 
									
										
										
										
											2009-07-16 19:58:53 +04:00
										 |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-06 19:01:15 -07:00
										 |  |  | static u64 usb_dmamask = DMA_BIT_MASK(32); | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | static struct platform_device usb_dev = { | 
					
						
							| 
									
										
										
										
											2010-12-02 09:16:55 +02:00
										 |  |  | 	.name           = "musb-davinci", | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | 	.id             = -1, | 
					
						
							|  |  |  | 	.dev = { | 
					
						
							|  |  |  | 		.platform_data		= &usb_data, | 
					
						
							|  |  |  | 		.dma_mask		= &usb_dmamask, | 
					
						
							| 
									
										
										
										
											2009-04-06 19:01:15 -07:00
										 |  |  | 		.coherent_dma_mask      = DMA_BIT_MASK(32), | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 	.resource       = usb_resources, | 
					
						
							|  |  |  | 	.num_resources  = ARRAY_SIZE(usb_resources), | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-30 23:46:14 +04:00
										 |  |  | void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-30 23:46:14 +04:00
										 |  |  | 	usb_data.power = mA > 510 ? 255 : mA / 2; | 
					
						
							|  |  |  | 	usb_data.potpgt = (potpgt_ms + 1) / 2; | 
					
						
							| 
									
										
										
										
											2009-07-16 19:58:53 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (cpu_is_davinci_dm646x()) { | 
					
						
							|  |  |  | 		/* Override the defaults as DM6467 uses different IRQs. */ | 
					
						
							|  |  |  | 		usb_dev.resource[1].start = IRQ_DM646X_USBINT; | 
					
						
							|  |  |  | 		usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT; | 
					
						
							|  |  |  | 	} else	/* other devices don't have dedicated CPPI IRQ */ | 
					
						
							|  |  |  | 		usb_dev.num_resources = 2; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | 	platform_device_register(&usb_dev); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-30 23:49:44 +04:00
										 |  |  | #ifdef CONFIG_ARCH_DAVINCI_DA8XX
 | 
					
						
							|  |  |  | static struct resource da8xx_usb20_resources[] = { | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.start		= DA8XX_USB0_BASE, | 
					
						
							|  |  |  | 		.end		= DA8XX_USB0_BASE + SZ_64K - 1, | 
					
						
							|  |  |  | 		.flags		= IORESOURCE_MEM, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.start		= IRQ_DA8XX_USB_INT, | 
					
						
							|  |  |  | 		.flags		= IORESOURCE_IRQ, | 
					
						
							| 
									
										
										
										
											2010-12-10 20:23:06 +03:00
										 |  |  | 		.name		= "mc", | 
					
						
							| 
									
										
										
										
											2009-10-30 23:49:44 +04:00
										 |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int __init da8xx_register_usb20(unsigned mA, unsigned potpgt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	usb_data.clock  = "usb20"; | 
					
						
							|  |  |  | 	usb_data.power	= mA > 510 ? 255 : mA / 2; | 
					
						
							|  |  |  | 	usb_data.potpgt = (potpgt + 1) / 2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	usb_dev.resource = da8xx_usb20_resources; | 
					
						
							|  |  |  | 	usb_dev.num_resources = ARRAY_SIZE(da8xx_usb20_resources); | 
					
						
							| 
									
										
										
										
											2010-12-02 09:19:35 +02:00
										 |  |  | 	usb_dev.name = "musb-da8xx"; | 
					
						
							| 
									
										
										
										
											2009-10-30 23:49:44 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return platform_device_register(&usb_dev); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif	/* CONFIG_DAVINCI_DA8XX */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-30 23:46:14 +04:00
										 |  |  | void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-30 23:49:44 +04:00
										 |  |  | #ifdef CONFIG_ARCH_DAVINCI_DA8XX
 | 
					
						
							|  |  |  | int __init da8xx_register_usb20(unsigned mA, unsigned potpgt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-07 23:41:57 -07:00
										 |  |  | #endif  /* CONFIG_USB_MUSB_HDRC */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-25 23:14:02 +04:00
										 |  |  | #ifdef	CONFIG_ARCH_DAVINCI_DA8XX
 | 
					
						
							|  |  |  | static struct resource da8xx_usb11_resources[] = { | 
					
						
							|  |  |  | 	[0] = { | 
					
						
							|  |  |  | 		.start	= DA8XX_USB1_BASE, | 
					
						
							|  |  |  | 		.end	= DA8XX_USB1_BASE + SZ_4K - 1, | 
					
						
							|  |  |  | 		.flags	= IORESOURCE_MEM, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[1] = { | 
					
						
							|  |  |  | 		.start	= IRQ_DA8XX_IRQN, | 
					
						
							|  |  |  | 		.end	= IRQ_DA8XX_IRQN, | 
					
						
							|  |  |  | 		.flags	= IORESOURCE_IRQ, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct platform_device da8xx_usb11_device = { | 
					
						
							|  |  |  | 	.name		= "ohci", | 
					
						
							|  |  |  | 	.id		= 0, | 
					
						
							|  |  |  | 	.dev = { | 
					
						
							|  |  |  | 		.dma_mask		= &da8xx_usb11_dma_mask, | 
					
						
							|  |  |  | 		.coherent_dma_mask	= DMA_BIT_MASK(32), | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	.num_resources	= ARRAY_SIZE(da8xx_usb11_resources), | 
					
						
							|  |  |  | 	.resource	= da8xx_usb11_resources, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	da8xx_usb11_device.dev.platform_data = pdata; | 
					
						
							|  |  |  | 	return platform_device_register(&da8xx_usb11_device); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif	/* CONFIG_DAVINCI_DA8XX */
 |