Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[pandora-kernel.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
74 /* Mapping between source event lines and physical device address */
75 static const dma_addr_t dma40_rx_map[DB8500_DMA_NR_DEV];
76
77 /* Reserved event lines for memcpy only */
78 static int dma40_memcpy_event[] = {
79         DB8500_DMA_MEMCPY_TX_0,
80         DB8500_DMA_MEMCPY_TX_1,
81         DB8500_DMA_MEMCPY_TX_2,
82         DB8500_DMA_MEMCPY_TX_3,
83         DB8500_DMA_MEMCPY_TX_4,
84         DB8500_DMA_MEMCPY_TX_5,
85 };
86
87 static struct stedma40_platform_data dma40_plat_data = {
88         .dev_len = DB8500_DMA_NR_DEV,
89         .dev_rx = dma40_rx_map,
90         .dev_tx = dma40_tx_map,
91         .memcpy = dma40_memcpy_event,
92         .memcpy_len = ARRAY_SIZE(dma40_memcpy_event),
93         .memcpy_conf_phy = &dma40_memcpy_conf_phy,
94         .memcpy_conf_log = &dma40_memcpy_conf_log,
95         .disabled_channels = {-1},
96 };
97
98 struct platform_device u8500_dma40_device = {
99         .dev = {
100                 .platform_data = &dma40_plat_data,
101         },
102         .name = "dma40",
103         .id = 0,
104         .num_resources = ARRAY_SIZE(dma40_resources),
105         .resource = dma40_resources
106 };
107
108 void dma40_u8500ed_fixup(void)
109 {
110         dma40_plat_data.memcpy = NULL;
111         dma40_plat_data.memcpy_len = 0;
112         dma40_resources[0].start = U8500_DMA_BASE_ED;
113         dma40_resources[0].end = U8500_DMA_BASE_ED + SZ_4K - 1;
114         dma40_resources[1].start = U8500_DMA_LCPA_BASE_ED;
115         dma40_resources[1].end = U8500_DMA_LCPA_BASE_ED + 2 * SZ_1K - 1;
116 }
117
118 struct resource keypad_resources[] = {
119         [0] = {
120                 .start = U8500_SKE_BASE,
121                 .end = U8500_SKE_BASE + SZ_4K - 1,
122                 .flags = IORESOURCE_MEM,
123         },
124         [1] = {
125                 .start = IRQ_DB8500_KB,
126                 .end = IRQ_DB8500_KB,
127                 .flags = IORESOURCE_IRQ,
128         },
129 };
130
131 struct platform_device u8500_ske_keypad_device = {
132         .name = "nmk-ske-keypad",
133         .id = -1,
134         .num_resources = ARRAY_SIZE(keypad_resources),
135         .resource = keypad_resources,
136 };