Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 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> |
Rabin Vincent | 5b1f7dd | 2010-05-03 08:25:52 +0100 | [diff] [blame] | 12 | #include <linux/gpio.h> |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 13 | #include <linux/amba/bus.h> |
| 14 | |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 15 | #include <plat/ste_dma40.h> |
| 16 | |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 17 | #include <mach/hardware.h> |
| 18 | #include <mach/setup.h> |
| 19 | |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 20 | #include "ste-dma40-db8500.h" |
| 21 | |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 22 | static struct resource dma40_resources[] = { |
| 23 | [0] = { |
| 24 | .start = U8500_DMA_BASE, |
Jonas Aaberg | 5aa12e8 | 2010-06-20 21:26:14 +0000 | [diff] [blame] | 25 | .end = U8500_DMA_BASE + SZ_4K - 1, |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 26 | .flags = IORESOURCE_MEM, |
Jonas Aaberg | 5aa12e8 | 2010-06-20 21:26:14 +0000 | [diff] [blame] | 27 | .name = "base", |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 28 | }, |
| 29 | [1] = { |
| 30 | .start = U8500_DMA_LCPA_BASE, |
Jonas Aaberg | 5aa12e8 | 2010-06-20 21:26:14 +0000 | [diff] [blame] | 31 | .end = U8500_DMA_LCPA_BASE + 2 * SZ_1K - 1, |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 32 | .flags = IORESOURCE_MEM, |
Jonas Aaberg | 5aa12e8 | 2010-06-20 21:26:14 +0000 | [diff] [blame] | 33 | .name = "lcpa", |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 34 | }, |
| 35 | [2] = { |
Rabin Vincent | 6055930 | 2010-07-26 11:09:27 +0100 | [diff] [blame] | 36 | .start = IRQ_DB8500_DMA, |
| 37 | .end = IRQ_DB8500_DMA, |
Jonas Aaberg | 5aa12e8 | 2010-06-20 21:26:14 +0000 | [diff] [blame] | 38 | .flags = IORESOURCE_IRQ, |
| 39 | } |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | /* Default configuration for physcial memcpy */ |
| 43 | struct stedma40_chan_cfg dma40_memcpy_conf_phy = { |
Rabin Vincent | 38bdbf0 | 2010-10-12 13:00:51 +0000 | [diff] [blame] | 44 | .mode = STEDMA40_MODE_PHYSICAL, |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 45 | .dir = STEDMA40_MEM_TO_MEM, |
| 46 | |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 47 | .src_info.data_width = STEDMA40_BYTE_WIDTH, |
| 48 | .src_info.psize = STEDMA40_PSIZE_PHY_1, |
Jonas Aaberg | ef934ae | 2010-06-20 21:26:22 +0000 | [diff] [blame] | 49 | .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL, |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 50 | |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 51 | .dst_info.data_width = STEDMA40_BYTE_WIDTH, |
| 52 | .dst_info.psize = STEDMA40_PSIZE_PHY_1, |
Jonas Aaberg | ef934ae | 2010-06-20 21:26:22 +0000 | [diff] [blame] | 53 | .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL, |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 54 | }; |
| 55 | /* Default configuration for logical memcpy */ |
| 56 | struct stedma40_chan_cfg dma40_memcpy_conf_log = { |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 57 | .dir = STEDMA40_MEM_TO_MEM, |
| 58 | |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 59 | .src_info.data_width = STEDMA40_BYTE_WIDTH, |
| 60 | .src_info.psize = STEDMA40_PSIZE_LOG_1, |
Jonas Aaberg | ef934ae | 2010-06-20 21:26:22 +0000 | [diff] [blame] | 61 | .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL, |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 62 | |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 63 | .dst_info.data_width = STEDMA40_BYTE_WIDTH, |
| 64 | .dst_info.psize = STEDMA40_PSIZE_LOG_1, |
Jonas Aaberg | ef934ae | 2010-06-20 21:26:22 +0000 | [diff] [blame] | 65 | .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL, |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 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 | */ |
Rabin Vincent | 1d7e3565 | 2010-09-29 16:01:08 +0100 | [diff] [blame] | 72 | static const dma_addr_t dma40_tx_map[DB8500_DMA_NR_DEV]; |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 73 | |
| 74 | /* Mapping between source event lines and physical device address */ |
Rabin Vincent | 1d7e3565 | 2010-09-29 16:01:08 +0100 | [diff] [blame] | 75 | static const dma_addr_t dma40_rx_map[DB8500_DMA_NR_DEV]; |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 76 | |
| 77 | /* Reserved event lines for memcpy only */ |
| 78 | static int dma40_memcpy_event[] = { |
Rabin Vincent | 1d7e3565 | 2010-09-29 16:01:08 +0100 | [diff] [blame] | 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, |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | static struct stedma40_platform_data dma40_plat_data = { |
Rabin Vincent | 1d7e3565 | 2010-09-29 16:01:08 +0100 | [diff] [blame] | 88 | .dev_len = DB8500_DMA_NR_DEV, |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 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, |
Jonas Aaberg | 5951672 | 2010-06-20 21:26:45 +0000 | [diff] [blame] | 95 | .disabled_channels = {-1}, |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 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; |
Linus Walleij | f418559 | 2010-06-22 18:06:42 -0700 | [diff] [blame] | 114 | dma40_resources[1].start = U8500_DMA_LCPA_BASE_ED; |
| 115 | dma40_resources[1].end = U8500_DMA_LCPA_BASE_ED + 2 * SZ_1K - 1; |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 116 | } |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 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 | |
Sundar Iyer | e43abe6 | 2010-12-03 20:35:36 +0530 | [diff] [blame^] | 131 | struct platform_device u8500_ske_keypad_device = { |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 132 | .name = "nmk-ske-keypad", |
| 133 | .id = -1, |
| 134 | .num_resources = ARRAY_SIZE(keypad_resources), |
| 135 | .resource = keypad_resources, |
| 136 | }; |