Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[pandora-kernel.git] / arch / arm / mach-ux500 / dma-db5500.c
1 /*
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
20 static 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 */
41 static 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 */
55 static 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  */
74 static const dma_addr_t dma40_rx_map[DB5500_DMA_NR_DEV] = {
75         [DB5500_DMA_DEV24_SDMMC0_RX] = -1,
76 };
77
78 /* Mapping between destination event lines and physical device address */
79 static const dma_addr_t dma40_tx_map[DB5500_DMA_NR_DEV] = {
80         [DB5500_DMA_DEV24_SDMMC0_TX] = -1,
81 };
82
83 static int dma40_memcpy_event[] = {
84         DB5500_DMA_MEMCPY_TX_1,
85         DB5500_DMA_MEMCPY_TX_2,
86         DB5500_DMA_MEMCPY_TX_3,
87         DB5500_DMA_MEMCPY_TX_4,
88         DB5500_DMA_MEMCPY_TX_5,
89 };
90
91 static struct stedma40_platform_data dma40_plat_data = {
92         .dev_len                = ARRAY_SIZE(dma40_rx_map),
93         .dev_rx                 = dma40_rx_map,
94         .dev_tx                 = dma40_tx_map,
95         .memcpy                 = dma40_memcpy_event,
96         .memcpy_len             = ARRAY_SIZE(dma40_memcpy_event),
97         .memcpy_conf_phy        = &dma40_memcpy_conf_phy,
98         .memcpy_conf_log        = &dma40_memcpy_conf_log,
99         .disabled_channels      = {-1},
100 };
101
102 static struct platform_device dma40_device = {
103         .dev = {
104                 .platform_data = &dma40_plat_data,
105         },
106         .name           = "dma40",
107         .id             = 0,
108         .num_resources  = ARRAY_SIZE(dma40_resources),
109         .resource       = dma40_resources
110 };
111
112 void __init db5500_dma_init(void)
113 {
114         int ret;
115
116         ret = platform_device_register(&dma40_device);
117         if (ret)
118                 dev_err(&dma40_device.dev, "unable to register device: %d\n", ret);
119
120 }