2 * Copyright (C) ST-Ericsson SA 2010
4 * Author: Per Forlin <per.forlin@stericsson.com> for ST-Ericsson
5 * Author: Jonas Aaberg <jonas.aberg@stericsson.com> for ST-Ericsson
6 * Author: Rabin Vincent <rabinv.vincent@stericsson.com> for ST-Ericsson
8 * License terms: GNU General Public License (GPL), version 2
11 #include <linux/kernel.h>
12 #include <linux/platform_device.h>
14 #include <plat/ste_dma40.h>
15 #include <mach/setup.h>
16 #include <mach/hardware.h>
18 #include "ste-dma40-db5500.h"
20 static struct resource dma40_resources
[] = {
22 .start
= U5500_DMA_BASE
,
23 .end
= U5500_DMA_BASE
+ SZ_4K
- 1,
24 .flags
= IORESOURCE_MEM
,
28 .start
= U5500_DMA_LCPA_BASE
,
29 .end
= U5500_DMA_LCPA_BASE
+ 2 * SZ_1K
- 1,
30 .flags
= IORESOURCE_MEM
,
34 .start
= IRQ_DB5500_DMA
,
35 .end
= IRQ_DB5500_DMA
,
36 .flags
= IORESOURCE_IRQ
40 /* Default configuration for physical memcpy */
41 static struct stedma40_chan_cfg dma40_memcpy_conf_phy
= {
42 .mode
= STEDMA40_MODE_PHYSICAL
,
43 .dir
= STEDMA40_MEM_TO_MEM
,
45 .src_info
.data_width
= STEDMA40_BYTE_WIDTH
,
46 .src_info
.psize
= STEDMA40_PSIZE_PHY_1
,
47 .src_info
.flow_ctrl
= STEDMA40_NO_FLOW_CTRL
,
49 .dst_info
.data_width
= STEDMA40_BYTE_WIDTH
,
50 .dst_info
.psize
= STEDMA40_PSIZE_PHY_1
,
51 .dst_info
.flow_ctrl
= STEDMA40_NO_FLOW_CTRL
,
54 /* Default configuration for logical memcpy */
55 static struct stedma40_chan_cfg dma40_memcpy_conf_log
= {
56 .dir
= STEDMA40_MEM_TO_MEM
,
58 .src_info
.data_width
= STEDMA40_BYTE_WIDTH
,
59 .src_info
.psize
= STEDMA40_PSIZE_LOG_1
,
60 .src_info
.flow_ctrl
= STEDMA40_NO_FLOW_CTRL
,
62 .dst_info
.data_width
= STEDMA40_BYTE_WIDTH
,
63 .dst_info
.psize
= STEDMA40_PSIZE_LOG_1
,
64 .dst_info
.flow_ctrl
= STEDMA40_NO_FLOW_CTRL
,
68 * Mapping between soruce event lines and physical device address This was
69 * created assuming that the event line is tied to a device and therefore the
70 * address is constant, however this is not true for at least USB, and the
71 * values are just placeholders for USB. This table is preserved and used for
74 static const dma_addr_t dma40_rx_map
[DB5500_DMA_NR_DEV
] = {
75 [DB5500_DMA_DEV24_SDMMC0_RX
] = -1,
76 [DB5500_DMA_DEV38_USB_OTG_IEP_8
] = -1,
77 [DB5500_DMA_DEV23_USB_OTG_IEP_7_15
] = -1,
78 [DB5500_DMA_DEV22_USB_OTG_IEP_6_14
] = -1,
79 [DB5500_DMA_DEV21_USB_OTG_IEP_5_13
] = -1,
80 [DB5500_DMA_DEV20_USB_OTG_IEP_4_12
] = -1,
81 [DB5500_DMA_DEV6_USB_OTG_IEP_3_11
] = -1,
82 [DB5500_DMA_DEV5_USB_OTG_IEP_2_10
] = -1,
83 [DB5500_DMA_DEV4_USB_OTG_IEP_1_9
] = -1,
86 /* Mapping between destination event lines and physical device address */
87 static const dma_addr_t dma40_tx_map
[DB5500_DMA_NR_DEV
] = {
88 [DB5500_DMA_DEV24_SDMMC0_TX
] = -1,
89 [DB5500_DMA_DEV38_USB_OTG_OEP_8
] = -1,
90 [DB5500_DMA_DEV23_USB_OTG_OEP_7_15
] = -1,
91 [DB5500_DMA_DEV22_USB_OTG_OEP_6_14
] = -1,
92 [DB5500_DMA_DEV21_USB_OTG_OEP_5_13
] = -1,
93 [DB5500_DMA_DEV20_USB_OTG_OEP_4_12
] = -1,
94 [DB5500_DMA_DEV6_USB_OTG_OEP_3_11
] = -1,
95 [DB5500_DMA_DEV5_USB_OTG_OEP_2_10
] = -1,
96 [DB5500_DMA_DEV4_USB_OTG_OEP_1_9
] = -1,
99 static int dma40_memcpy_event
[] = {
100 DB5500_DMA_MEMCPY_TX_1
,
101 DB5500_DMA_MEMCPY_TX_2
,
102 DB5500_DMA_MEMCPY_TX_3
,
103 DB5500_DMA_MEMCPY_TX_4
,
104 DB5500_DMA_MEMCPY_TX_5
,
107 static struct stedma40_platform_data dma40_plat_data
= {
108 .dev_len
= ARRAY_SIZE(dma40_rx_map
),
109 .dev_rx
= dma40_rx_map
,
110 .dev_tx
= dma40_tx_map
,
111 .memcpy
= dma40_memcpy_event
,
112 .memcpy_len
= ARRAY_SIZE(dma40_memcpy_event
),
113 .memcpy_conf_phy
= &dma40_memcpy_conf_phy
,
114 .memcpy_conf_log
= &dma40_memcpy_conf_log
,
115 .disabled_channels
= {-1},
118 static struct platform_device dma40_device
= {
120 .platform_data
= &dma40_plat_data
,
124 .num_resources
= ARRAY_SIZE(dma40_resources
),
125 .resource
= dma40_resources
128 void __init
db5500_dma_init(void)
132 ret
= platform_device_register(&dma40_device
);
134 dev_err(&dma40_device
.dev
, "unable to register device: %d\n", ret
);