blob: 41e9470fa0e6e327855204cdc54db49cfaf7da7f [file] [log] [blame]
Per Forline8b1cc32010-12-05 13:35:12 +01001/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
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
7 *
8 * License terms: GNU General Public License (GPL), version 2
9 */
10
11#include <linux/kernel.h>
12#include <linux/platform_device.h>
13
14#include <plat/ste_dma40.h>
15#include <mach/setup.h>
16#include <mach/hardware.h>
17
18#include "ste-dma40-db5500.h"
19
20static struct resource dma40_resources[] = {
21 [0] = {
22 .start = U5500_DMA_BASE,
23 .end = U5500_DMA_BASE + SZ_4K - 1,
24 .flags = IORESOURCE_MEM,
25 .name = "base",
26 },
27 [1] = {
28 .start = U5500_DMA_LCPA_BASE,
29 .end = U5500_DMA_LCPA_BASE + 2 * SZ_1K - 1,
30 .flags = IORESOURCE_MEM,
31 .name = "lcpa",
32 },
33 [2] = {
34 .start = IRQ_DB5500_DMA,
35 .end = IRQ_DB5500_DMA,
36 .flags = IORESOURCE_IRQ
37 }
38};
39
40/* Default configuration for physical memcpy */
41static struct stedma40_chan_cfg dma40_memcpy_conf_phy = {
42 .mode = STEDMA40_MODE_PHYSICAL,
43 .dir = STEDMA40_MEM_TO_MEM,
44
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,
48
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,
52};
53
54/* Default configuration for logical memcpy */
55static struct stedma40_chan_cfg dma40_memcpy_conf_log = {
56 .dir = STEDMA40_MEM_TO_MEM,
57
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,
61
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,
65};
66
67/*
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
72 * now.
73 */
74static const dma_addr_t dma40_rx_map[DB5500_DMA_NR_DEV] = {
75 [DB5500_DMA_DEV24_SDMMC0_RX] = -1,
Mian Yousaf Kaukab741caea2011-01-21 18:24:19 +010076 [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,
Per Forline8b1cc32010-12-05 13:35:12 +010084};
85
86/* Mapping between destination event lines and physical device address */
87static const dma_addr_t dma40_tx_map[DB5500_DMA_NR_DEV] = {
88 [DB5500_DMA_DEV24_SDMMC0_TX] = -1,
Mian Yousaf Kaukab741caea2011-01-21 18:24:19 +010089 [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,
Per Forline8b1cc32010-12-05 13:35:12 +010097};
98
99static 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,
105};
106
107static 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},
116};
117
118static struct platform_device dma40_device = {
119 .dev = {
120 .platform_data = &dma40_plat_data,
121 },
122 .name = "dma40",
123 .id = 0,
124 .num_resources = ARRAY_SIZE(dma40_resources),
125 .resource = dma40_resources
126};
127
Lee Jones18403422012-02-06 11:22:21 -0800128void __init db5500_dma_init(struct device *parent)
Per Forline8b1cc32010-12-05 13:35:12 +0100129{
130 int ret;
131
Lee Jones18403422012-02-06 11:22:21 -0800132 dma40_device.dev.parent = parent;
Per Forline8b1cc32010-12-05 13:35:12 +0100133 ret = platform_device_register(&dma40_device);
134 if (ret)
135 dev_err(&dma40_device.dev, "unable to register device: %d\n", ret);
136
137}