blob: 23c695d54977d7a551d06fdb529f28d4195c4efe [file] [log] [blame]
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +01001/*
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>
Rabin Vincent5b1f7dd2010-05-03 08:25:52 +010012#include <linux/gpio.h>
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +010013#include <linux/amba/bus.h>
14
Linus Walleij7b8ddb02010-05-27 15:21:26 -070015#include <plat/ste_dma40.h>
16
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +010017#include <mach/hardware.h>
18#include <mach/setup.h>
19
Linus Walleij7b8ddb02010-05-27 15:21:26 -070020#include "ste-dma40-db8500.h"
21
Linus Walleij7b8ddb02010-05-27 15:21:26 -070022static struct resource dma40_resources[] = {
23 [0] = {
24 .start = U8500_DMA_BASE,
Jonas Aaberg5aa12e82010-06-20 21:26:14 +000025 .end = U8500_DMA_BASE + SZ_4K - 1,
Linus Walleij7b8ddb02010-05-27 15:21:26 -070026 .flags = IORESOURCE_MEM,
Jonas Aaberg5aa12e82010-06-20 21:26:14 +000027 .name = "base",
Linus Walleij7b8ddb02010-05-27 15:21:26 -070028 },
29 [1] = {
30 .start = U8500_DMA_LCPA_BASE,
Jonas Aaberg5aa12e82010-06-20 21:26:14 +000031 .end = U8500_DMA_LCPA_BASE + 2 * SZ_1K - 1,
Linus Walleij7b8ddb02010-05-27 15:21:26 -070032 .flags = IORESOURCE_MEM,
Jonas Aaberg5aa12e82010-06-20 21:26:14 +000033 .name = "lcpa",
Linus Walleij7b8ddb02010-05-27 15:21:26 -070034 },
35 [2] = {
Rabin Vincent60559302010-07-26 11:09:27 +010036 .start = IRQ_DB8500_DMA,
37 .end = IRQ_DB8500_DMA,
Jonas Aaberg5aa12e82010-06-20 21:26:14 +000038 .flags = IORESOURCE_IRQ,
39 }
Linus Walleij7b8ddb02010-05-27 15:21:26 -070040};
41
42/* Default configuration for physcial memcpy */
43struct stedma40_chan_cfg dma40_memcpy_conf_phy = {
Rabin Vincent38bdbf02010-10-12 13:00:51 +000044 .mode = STEDMA40_MODE_PHYSICAL,
Linus Walleij7b8ddb02010-05-27 15:21:26 -070045 .dir = STEDMA40_MEM_TO_MEM,
46
Linus Walleij7b8ddb02010-05-27 15:21:26 -070047 .src_info.data_width = STEDMA40_BYTE_WIDTH,
48 .src_info.psize = STEDMA40_PSIZE_PHY_1,
Jonas Aabergef934ae2010-06-20 21:26:22 +000049 .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
Linus Walleij7b8ddb02010-05-27 15:21:26 -070050
Linus Walleij7b8ddb02010-05-27 15:21:26 -070051 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
52 .dst_info.psize = STEDMA40_PSIZE_PHY_1,
Jonas Aabergef934ae2010-06-20 21:26:22 +000053 .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
Linus Walleij7b8ddb02010-05-27 15:21:26 -070054};
55/* Default configuration for logical memcpy */
56struct stedma40_chan_cfg dma40_memcpy_conf_log = {
Linus Walleij7b8ddb02010-05-27 15:21:26 -070057 .dir = STEDMA40_MEM_TO_MEM,
58
Linus Walleij7b8ddb02010-05-27 15:21:26 -070059 .src_info.data_width = STEDMA40_BYTE_WIDTH,
60 .src_info.psize = STEDMA40_PSIZE_LOG_1,
Jonas Aabergef934ae2010-06-20 21:26:22 +000061 .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
Linus Walleij7b8ddb02010-05-27 15:21:26 -070062
Linus Walleij7b8ddb02010-05-27 15:21:26 -070063 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
64 .dst_info.psize = STEDMA40_PSIZE_LOG_1,
Jonas Aabergef934ae2010-06-20 21:26:22 +000065 .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
Linus Walleij7b8ddb02010-05-27 15:21:26 -070066};
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 */
Rabin Vincent1d7e35652010-09-29 16:01:08 +010072static const dma_addr_t dma40_tx_map[DB8500_DMA_NR_DEV];
Linus Walleij7b8ddb02010-05-27 15:21:26 -070073
74/* Mapping between source event lines and physical device address */
Rabin Vincent1d7e35652010-09-29 16:01:08 +010075static const dma_addr_t dma40_rx_map[DB8500_DMA_NR_DEV];
Linus Walleij7b8ddb02010-05-27 15:21:26 -070076
77/* Reserved event lines for memcpy only */
78static int dma40_memcpy_event[] = {
Rabin Vincent1d7e35652010-09-29 16:01:08 +010079 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,
Linus Walleij7b8ddb02010-05-27 15:21:26 -070085};
86
87static struct stedma40_platform_data dma40_plat_data = {
Rabin Vincent1d7e35652010-09-29 16:01:08 +010088 .dev_len = DB8500_DMA_NR_DEV,
Linus Walleij7b8ddb02010-05-27 15:21:26 -070089 .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,
Jonas Aaberg59516722010-06-20 21:26:45 +000095 .disabled_channels = {-1},
Linus Walleij7b8ddb02010-05-27 15:21:26 -070096};
97
98struct 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
108void 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;
Linus Walleijf4185592010-06-22 18:06:42 -0700114 dma40_resources[1].start = U8500_DMA_LCPA_BASE_ED;
115 dma40_resources[1].end = U8500_DMA_LCPA_BASE_ED + 2 * SZ_1K - 1;
Linus Walleij7b8ddb02010-05-27 15:21:26 -0700116}
Sundar Iyer4c61c842010-09-29 19:43:09 -0700117
118struct 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
Sundar Iyere43abe62010-12-03 20:35:36 +0530131struct platform_device u8500_ske_keypad_device = {
Sundar Iyer4c61c842010-09-29 19:43:09 -0700132 .name = "nmk-ske-keypad",
133 .id = -1,
134 .num_resources = ARRAY_SIZE(keypad_resources),
135 .resource = keypad_resources,
136};