mach-ux500: add MUSB to db8500 devices
[linux-2.6.git] / arch / arm / mach-ux500 / devices-db8500.c
1 /*
2  * Copyright (C) ST-Ericsson SA 2010
3  *
4  * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
5  * License terms: GNU General Public License (GPL) version 2
6  */
7
8 #include <linux/kernel.h>
9 #include <linux/platform_device.h>
10 #include <linux/interrupt.h>
11 #include <linux/io.h>
12 #include <linux/gpio.h>
13 #include <linux/amba/bus.h>
14
15 #include <plat/ste_dma40.h>
16
17 #include <mach/hardware.h>
18 #include <mach/setup.h>
19
20 #include "ste-dma40-db8500.h"
21
22 static struct resource dma40_resources[] = {
23         [0] = {
24                 .start = U8500_DMA_BASE,
25                 .end   = U8500_DMA_BASE + SZ_4K - 1,
26                 .flags = IORESOURCE_MEM,
27                 .name  = "base",
28         },
29         [1] = {
30                 .start = U8500_DMA_LCPA_BASE,
31                 .end   = U8500_DMA_LCPA_BASE + 2 * SZ_1K - 1,
32                 .flags = IORESOURCE_MEM,
33                 .name  = "lcpa",
34         },
35         [2] = {
36                 .start = IRQ_DB8500_DMA,
37                 .end   = IRQ_DB8500_DMA,
38                 .flags = IORESOURCE_IRQ,
39         }
40 };
41
42 /* Default configuration for physcial memcpy */
43 struct stedma40_chan_cfg dma40_memcpy_conf_phy = {
44         .mode = STEDMA40_MODE_PHYSICAL,
45         .dir = STEDMA40_MEM_TO_MEM,
46
47         .src_info.data_width = STEDMA40_BYTE_WIDTH,
48         .src_info.psize = STEDMA40_PSIZE_PHY_1,
49         .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
50
51         .dst_info.data_width = STEDMA40_BYTE_WIDTH,
52         .dst_info.psize = STEDMA40_PSIZE_PHY_1,
53         .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
54 };
55 /* Default configuration for logical memcpy */
56 struct stedma40_chan_cfg dma40_memcpy_conf_log = {
57         .dir = STEDMA40_MEM_TO_MEM,
58
59         .src_info.data_width = STEDMA40_BYTE_WIDTH,
60         .src_info.psize = STEDMA40_PSIZE_LOG_1,
61         .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
62
63         .dst_info.data_width = STEDMA40_BYTE_WIDTH,
64         .dst_info.psize = STEDMA40_PSIZE_LOG_1,
65         .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
66 };
67
68 /*
69  * Mapping between destination event lines and physical device address.
70  * The event line is tied to a device and therefor the address is constant.
71  */
72 static const dma_addr_t dma40_tx_map[DB8500_DMA_NR_DEV] = {
73         /* MUSB - these will be runtime-reconfigured */
74         [DB8500_DMA_DEV39_USB_OTG_OEP_8] = -1,
75         [DB8500_DMA_DEV16_USB_OTG_OEP_7_15] = -1,
76         [DB8500_DMA_DEV17_USB_OTG_OEP_6_14] = -1,
77         [DB8500_DMA_DEV18_USB_OTG_OEP_5_13] = -1,
78         [DB8500_DMA_DEV19_USB_OTG_OEP_4_12] = -1,
79         [DB8500_DMA_DEV36_USB_OTG_OEP_3_11] = -1,
80         [DB8500_DMA_DEV37_USB_OTG_OEP_2_10] = -1,
81         [DB8500_DMA_DEV38_USB_OTG_OEP_1_9] = -1,
82 };
83
84 /* Mapping between source event lines and physical device address */
85 static const dma_addr_t dma40_rx_map[DB8500_DMA_NR_DEV] = {
86         /* MUSB - these will be runtime-reconfigured */
87         [DB8500_DMA_DEV39_USB_OTG_IEP_8] = -1,
88         [DB8500_DMA_DEV16_USB_OTG_IEP_7_15] = -1,
89         [DB8500_DMA_DEV17_USB_OTG_IEP_6_14] = -1,
90         [DB8500_DMA_DEV18_USB_OTG_IEP_5_13] = -1,
91         [DB8500_DMA_DEV19_USB_OTG_IEP_4_12] = -1,
92         [DB8500_DMA_DEV36_USB_OTG_IEP_3_11] = -1,
93         [DB8500_DMA_DEV37_USB_OTG_IEP_2_10] = -1,
94         [DB8500_DMA_DEV38_USB_OTG_IEP_1_9] = -1,
95 };
96
97 /* Reserved event lines for memcpy only */
98 static int dma40_memcpy_event[] = {
99         DB8500_DMA_MEMCPY_TX_0,
100         DB8500_DMA_MEMCPY_TX_1,
101         DB8500_DMA_MEMCPY_TX_2,
102         DB8500_DMA_MEMCPY_TX_3,
103         DB8500_DMA_MEMCPY_TX_4,
104         DB8500_DMA_MEMCPY_TX_5,
105 };
106
107 static struct stedma40_platform_data dma40_plat_data = {
108         .dev_len = DB8500_DMA_NR_DEV,
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
118 struct platform_device u8500_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
128 void dma40_u8500ed_fixup(void)
129 {
130         dma40_plat_data.memcpy = NULL;
131         dma40_plat_data.memcpy_len = 0;
132         dma40_resources[0].start = U8500_DMA_BASE_ED;
133         dma40_resources[0].end = U8500_DMA_BASE_ED + SZ_4K - 1;
134         dma40_resources[1].start = U8500_DMA_LCPA_BASE_ED;
135         dma40_resources[1].end = U8500_DMA_LCPA_BASE_ED + 2 * SZ_1K - 1;
136 }
137
138 struct resource keypad_resources[] = {
139         [0] = {
140                 .start = U8500_SKE_BASE,
141                 .end = U8500_SKE_BASE + SZ_4K - 1,
142                 .flags = IORESOURCE_MEM,
143         },
144         [1] = {
145                 .start = IRQ_DB8500_KB,
146                 .end = IRQ_DB8500_KB,
147                 .flags = IORESOURCE_IRQ,
148         },
149 };
150
151 struct platform_device u8500_ske_keypad_device = {
152         .name = "nmk-ske-keypad",
153         .id = -1,
154         .num_resources = ARRAY_SIZE(keypad_resources),
155         .resource = keypad_resources,
156 };