| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (C) ST-Ericsson SA 2011 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Author: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com> | 
					
						
							|  |  |  |  * License terms: GNU General Public License (GPL) version 2 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #include <linux/platform_device.h>
 | 
					
						
							|  |  |  | #include <linux/usb/musb.h>
 | 
					
						
							| 
									
										
										
										
											2011-06-27 18:19:30 +02:00
										 |  |  | #include <linux/dma-mapping.h>
 | 
					
						
							| 
									
										
										
										
											2012-10-18 14:20:16 +02:00
										 |  |  | #include <linux/platform_data/usb-musb-ux500.h>
 | 
					
						
							|  |  |  | #include <linux/platform_data/dma-ste-dma40.h>
 | 
					
						
							| 
									
										
										
										
											2012-02-06 11:22:25 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-19 15:41:55 +01:00
										 |  |  | #include "db8500-regs.h"
 | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define MUSB_DMA40_RX_CH { \
 | 
					
						
							|  |  |  | 		.mode = STEDMA40_MODE_LOGICAL, \ | 
					
						
							| 
									
										
										
										
											2013-05-15 10:51:53 +01:00
										 |  |  | 		.dir = DMA_DEV_TO_MEM, \ | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define MUSB_DMA40_TX_CH { \
 | 
					
						
							|  |  |  | 		.mode = STEDMA40_MODE_LOGICAL, \ | 
					
						
							| 
									
										
										
										
											2013-05-15 10:51:53 +01:00
										 |  |  | 		.dir = DMA_MEM_TO_DEV, \ | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:51:43 +01:00
										 |  |  | static struct stedma40_chan_cfg musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | 	= { | 
					
						
							|  |  |  | 	MUSB_DMA40_RX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_RX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_RX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_RX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_RX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_RX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_RX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_RX_CH | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:51:43 +01:00
										 |  |  | static struct stedma40_chan_cfg musb_dma_tx_ch[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | 	= { | 
					
						
							|  |  |  | 	MUSB_DMA40_TX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_TX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_TX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_TX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_TX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_TX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_TX_CH, | 
					
						
							|  |  |  | 	MUSB_DMA40_TX_CH, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:51:43 +01:00
										 |  |  | static void *ux500_dma_rx_param_array[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] = { | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | 	&musb_dma_rx_ch[0], | 
					
						
							|  |  |  | 	&musb_dma_rx_ch[1], | 
					
						
							|  |  |  | 	&musb_dma_rx_ch[2], | 
					
						
							|  |  |  | 	&musb_dma_rx_ch[3], | 
					
						
							|  |  |  | 	&musb_dma_rx_ch[4], | 
					
						
							|  |  |  | 	&musb_dma_rx_ch[5], | 
					
						
							|  |  |  | 	&musb_dma_rx_ch[6], | 
					
						
							|  |  |  | 	&musb_dma_rx_ch[7] | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:51:43 +01:00
										 |  |  | static void *ux500_dma_tx_param_array[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] = { | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | 	&musb_dma_tx_ch[0], | 
					
						
							|  |  |  | 	&musb_dma_tx_ch[1], | 
					
						
							|  |  |  | 	&musb_dma_tx_ch[2], | 
					
						
							|  |  |  | 	&musb_dma_tx_ch[3], | 
					
						
							|  |  |  | 	&musb_dma_tx_ch[4], | 
					
						
							|  |  |  | 	&musb_dma_tx_ch[5], | 
					
						
							|  |  |  | 	&musb_dma_tx_ch[6], | 
					
						
							|  |  |  | 	&musb_dma_tx_ch[7] | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct ux500_musb_board_data musb_board_data = { | 
					
						
							|  |  |  | 	.dma_rx_param_array = ux500_dma_rx_param_array, | 
					
						
							|  |  |  | 	.dma_tx_param_array = ux500_dma_tx_param_array, | 
					
						
							|  |  |  | 	.dma_filter = stedma40_filter, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct musb_hdrc_platform_data musb_platform_data = { | 
					
						
							|  |  |  | 	.mode = MUSB_OTG, | 
					
						
							|  |  |  | 	.board_data = &musb_board_data, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct resource usb_resources[] = { | 
					
						
							|  |  |  | 	[0] = { | 
					
						
							|  |  |  | 		.name	= "usb-mem", | 
					
						
							|  |  |  | 		.flags	=  IORESOURCE_MEM, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	[1] = { | 
					
						
							|  |  |  | 		.name   = "mc", /* hard-coded in musb */ | 
					
						
							|  |  |  | 		.flags	= IORESOURCE_IRQ, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct platform_device ux500_musb_device = { | 
					
						
							|  |  |  | 	.name = "musb-ux500", | 
					
						
							|  |  |  | 	.id = 0, | 
					
						
							|  |  |  | 	.dev = { | 
					
						
							|  |  |  | 		.platform_data = &musb_platform_data, | 
					
						
							|  |  |  | 		.coherent_dma_mask = DMA_BIT_MASK(32), | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	.num_resources = ARRAY_SIZE(usb_resources), | 
					
						
							|  |  |  | 	.resource = usb_resources, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-03 15:31:56 +01:00
										 |  |  | static inline void ux500_usb_dma_update_rx_ch_config(int *dev_type) | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	u32 idx; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:51:43 +01:00
										 |  |  | 	for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; idx++) | 
					
						
							| 
									
										
										
										
											2013-05-03 15:31:56 +01:00
										 |  |  | 		musb_dma_rx_ch[idx].dev_type = dev_type[idx]; | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-03 15:31:56 +01:00
										 |  |  | static inline void ux500_usb_dma_update_tx_ch_config(int *dev_type) | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	u32 idx; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:51:43 +01:00
										 |  |  | 	for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; idx++) | 
					
						
							| 
									
										
										
										
											2013-05-03 15:31:56 +01:00
										 |  |  | 		musb_dma_tx_ch[idx].dev_type = dev_type[idx]; | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-06 11:22:21 -08:00
										 |  |  | void ux500_add_usb(struct device *parent, resource_size_t base, int irq, | 
					
						
							|  |  |  | 		   int *dma_rx_cfg, int *dma_tx_cfg) | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	ux500_musb_device.resource[0].start = base; | 
					
						
							|  |  |  | 	ux500_musb_device.resource[0].end = base + SZ_64K - 1; | 
					
						
							|  |  |  | 	ux500_musb_device.resource[1].start = irq; | 
					
						
							|  |  |  | 	ux500_musb_device.resource[1].end = irq; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ux500_usb_dma_update_rx_ch_config(dma_rx_cfg); | 
					
						
							|  |  |  | 	ux500_usb_dma_update_tx_ch_config(dma_tx_cfg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-06 11:22:25 -08:00
										 |  |  | 	ux500_musb_device.dev.parent = parent; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-21 17:59:56 +01:00
										 |  |  | 	platform_device_register(&ux500_musb_device); | 
					
						
							|  |  |  | } |