blob: 2e341fb4065c4fb33a5a88d28ec07b8843f84c7f [file] [log] [blame]
Hanumath Prasad008f8a22010-08-19 12:06:32 +01001/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * Author: Hanumath Prasad <hanumath.prasad@stericsson.com>
5 * License terms: GNU General Public License (GPL) version 2
6 */
7
8#include <linux/kernel.h>
9#include <linux/gpio.h>
10#include <linux/amba/bus.h>
11#include <linux/amba/mmci.h>
12#include <linux/mmc/host.h>
13#include <linux/platform_device.h>
Linus Walleij865fab62012-10-18 14:20:16 +020014#include <linux/platform_data/dma-ste-dma40.h>
Hanumath Prasad008f8a22010-08-19 12:06:32 +010015
Linus Walleij4b4f7572011-02-15 15:01:35 +010016#include <asm/mach-types.h>
Arnd Bergmanne657bcf2013-03-21 22:51:12 +010017#include "devices.h"
Hanumath Prasad008f8a22010-08-19 12:06:32 +010018
Linus Walleij174e7792013-03-19 15:41:55 +010019#include "db8500-regs.h"
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053020#include "devices-db8500.h"
Hanumath Prasad008f8a22010-08-19 12:06:32 +010021#include "board-mop500.h"
Linus Walleij5d7b8462010-10-14 13:57:59 +020022#include "ste-dma40-db8500.h"
Hanumath Prasad008f8a22010-08-19 12:06:32 +010023
Hanumath Prasad008f8a22010-08-19 12:06:32 +010024/*
Linus Walleijc15def12011-12-15 13:38:40 +010025 * v2 has a new version of this block that need to be forced, the number found
26 * in hardware is incorrect
27 */
28#define U8500_SDI_V2_PERIPHID 0x10480180
29
30/*
Rabin Vincentb8410a12010-08-09 19:18:17 +053031 * SDI 0 (MicroSD slot)
32 */
33
Linus Walleij5d7b8462010-10-14 13:57:59 +020034#ifdef CONFIG_STE_DMA40
35struct stedma40_chan_cfg mop500_sdi0_dma_cfg_rx = {
36 .mode = STEDMA40_MODE_LOGICAL,
37 .dir = STEDMA40_PERIPH_TO_MEM,
38 .src_dev_type = DB8500_DMA_DEV29_SD_MM0_RX,
39 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
40 .src_info.data_width = STEDMA40_WORD_WIDTH,
41 .dst_info.data_width = STEDMA40_WORD_WIDTH,
42};
43
44static struct stedma40_chan_cfg mop500_sdi0_dma_cfg_tx = {
45 .mode = STEDMA40_MODE_LOGICAL,
46 .dir = STEDMA40_MEM_TO_PERIPH,
47 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
48 .dst_dev_type = DB8500_DMA_DEV29_SD_MM0_TX,
49 .src_info.data_width = STEDMA40_WORD_WIDTH,
50 .dst_info.data_width = STEDMA40_WORD_WIDTH,
51};
52#endif
53
Lee Jones5e1ac7d2012-05-29 14:40:04 +080054struct mmci_platform_data mop500_sdi0_data = {
Ulf Hanssonb6ff56a2013-05-23 15:13:45 +020055 .f_max = 100000000,
Linus Walleij02a73432011-03-30 16:00:39 +020056 .capabilities = MMC_CAP_4_BIT_DATA |
57 MMC_CAP_SD_HIGHSPEED |
Ulf Hanssonfd1cc1b2013-05-23 15:13:48 +020058 MMC_CAP_MMC_HIGHSPEED |
59 MMC_CAP_ERASE,
Rabin Vincentb8410a12010-08-09 19:18:17 +053060 .gpio_wp = -1,
Ulf Hanssonbc521812011-12-13 16:57:55 +010061 .sigdir = MCI_ST_FBCLKEN |
62 MCI_ST_CMDDIREN |
63 MCI_ST_DATA0DIREN |
64 MCI_ST_DATA2DIREN,
Linus Walleij5d7b8462010-10-14 13:57:59 +020065#ifdef CONFIG_STE_DMA40
66 .dma_filter = stedma40_filter,
67 .dma_rx_param = &mop500_sdi0_dma_cfg_rx,
68 .dma_tx_param = &mop500_sdi0_dma_cfg_tx,
69#endif
Rabin Vincentb8410a12010-08-09 19:18:17 +053070};
71
Lee Jones18403422012-02-06 11:22:21 -080072static void sdi0_configure(struct device *parent)
Rabin Vincentb8410a12010-08-09 19:18:17 +053073{
Linus Walleij72930312011-03-24 16:13:13 +010074 /* Add the device, force v2 to subrevision 1 */
Lee Jones18403422012-02-06 11:22:21 -080075 db8500_add_sdi0(parent, &mop500_sdi0_data, U8500_SDI_V2_PERIPHID);
Rabin Vincentb8410a12010-08-09 19:18:17 +053076}
77
Lee Jones18403422012-02-06 11:22:21 -080078void mop500_sdi_tc35892_init(struct device *parent)
Linus Walleij4b4f7572011-02-15 15:01:35 +010079{
80 mop500_sdi0_data.gpio_cd = GPIO_SDMMC_CD;
Lee Jones18403422012-02-06 11:22:21 -080081 sdi0_configure(parent);
Linus Walleij4b4f7572011-02-15 15:01:35 +010082}
83
Rabin Vincentb8410a12010-08-09 19:18:17 +053084/*
Stefan Nilsson XK76d67172011-10-26 10:50:42 +020085 * SDI1 (SDIO WLAN)
86 */
87#ifdef CONFIG_STE_DMA40
88static struct stedma40_chan_cfg sdi1_dma_cfg_rx = {
89 .mode = STEDMA40_MODE_LOGICAL,
90 .dir = STEDMA40_PERIPH_TO_MEM,
91 .src_dev_type = DB8500_DMA_DEV32_SD_MM1_RX,
92 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
93 .src_info.data_width = STEDMA40_WORD_WIDTH,
94 .dst_info.data_width = STEDMA40_WORD_WIDTH,
95};
96
97static struct stedma40_chan_cfg sdi1_dma_cfg_tx = {
98 .mode = STEDMA40_MODE_LOGICAL,
99 .dir = STEDMA40_MEM_TO_PERIPH,
100 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
101 .dst_dev_type = DB8500_DMA_DEV32_SD_MM1_TX,
102 .src_info.data_width = STEDMA40_WORD_WIDTH,
103 .dst_info.data_width = STEDMA40_WORD_WIDTH,
104};
105#endif
106
Lee Jones9cf24b12012-08-30 16:11:08 +0100107struct mmci_platform_data mop500_sdi1_data = {
Stefan Nilsson XK76d67172011-10-26 10:50:42 +0200108 .ocr_mask = MMC_VDD_29_30,
Ulf Hanssonb6ff56a2013-05-23 15:13:45 +0200109 .f_max = 100000000,
Ulf Hanssona7de8b302013-05-23 15:13:49 +0200110 .capabilities = MMC_CAP_4_BIT_DATA |
111 MMC_CAP_NONREMOVABLE,
Stefan Nilsson XK76d67172011-10-26 10:50:42 +0200112 .gpio_cd = -1,
113 .gpio_wp = -1,
114#ifdef CONFIG_STE_DMA40
115 .dma_filter = stedma40_filter,
116 .dma_rx_param = &sdi1_dma_cfg_rx,
117 .dma_tx_param = &sdi1_dma_cfg_tx,
118#endif
119};
120
121/*
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100122 * SDI 2 (POP eMMC, not on DB8500ed)
123 */
124
Linus Walleij5d7b8462010-10-14 13:57:59 +0200125#ifdef CONFIG_STE_DMA40
126struct stedma40_chan_cfg mop500_sdi2_dma_cfg_rx = {
127 .mode = STEDMA40_MODE_LOGICAL,
128 .dir = STEDMA40_PERIPH_TO_MEM,
129 .src_dev_type = DB8500_DMA_DEV28_SD_MM2_RX,
130 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
131 .src_info.data_width = STEDMA40_WORD_WIDTH,
132 .dst_info.data_width = STEDMA40_WORD_WIDTH,
133};
134
135static struct stedma40_chan_cfg mop500_sdi2_dma_cfg_tx = {
136 .mode = STEDMA40_MODE_LOGICAL,
137 .dir = STEDMA40_MEM_TO_PERIPH,
138 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
139 .dst_dev_type = DB8500_DMA_DEV28_SD_MM2_TX,
140 .src_info.data_width = STEDMA40_WORD_WIDTH,
141 .dst_info.data_width = STEDMA40_WORD_WIDTH,
142};
143#endif
144
Lee Jones9cf24b12012-08-30 16:11:08 +0100145struct mmci_platform_data mop500_sdi2_data = {
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100146 .ocr_mask = MMC_VDD_165_195,
Ulf Hanssonb6ff56a2013-05-23 15:13:45 +0200147 .f_max = 100000000,
Ulf Hanssona2be7762013-05-23 15:13:47 +0200148 .capabilities = MMC_CAP_4_BIT_DATA |
149 MMC_CAP_8_BIT_DATA |
Ulf Hanssona7de8b302013-05-23 15:13:49 +0200150 MMC_CAP_NONREMOVABLE |
Ulf Hanssona2be7762013-05-23 15:13:47 +0200151 MMC_CAP_MMC_HIGHSPEED |
Ulf Hanssonfd1cc1b2013-05-23 15:13:48 +0200152 MMC_CAP_ERASE |
Ulf Hanssona2be7762013-05-23 15:13:47 +0200153 MMC_CAP_CMD23,
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100154 .gpio_cd = -1,
155 .gpio_wp = -1,
Linus Walleij5d7b8462010-10-14 13:57:59 +0200156#ifdef CONFIG_STE_DMA40
157 .dma_filter = stedma40_filter,
158 .dma_rx_param = &mop500_sdi2_dma_cfg_rx,
159 .dma_tx_param = &mop500_sdi2_dma_cfg_tx,
160#endif
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100161};
162
163/*
164 * SDI 4 (on-board eMMC)
165 */
166
Linus Walleij5d7b8462010-10-14 13:57:59 +0200167#ifdef CONFIG_STE_DMA40
168struct stedma40_chan_cfg mop500_sdi4_dma_cfg_rx = {
169 .mode = STEDMA40_MODE_LOGICAL,
170 .dir = STEDMA40_PERIPH_TO_MEM,
171 .src_dev_type = DB8500_DMA_DEV42_SD_MM4_RX,
172 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
173 .src_info.data_width = STEDMA40_WORD_WIDTH,
174 .dst_info.data_width = STEDMA40_WORD_WIDTH,
175};
176
177static struct stedma40_chan_cfg mop500_sdi4_dma_cfg_tx = {
178 .mode = STEDMA40_MODE_LOGICAL,
179 .dir = STEDMA40_MEM_TO_PERIPH,
180 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
181 .dst_dev_type = DB8500_DMA_DEV42_SD_MM4_TX,
182 .src_info.data_width = STEDMA40_WORD_WIDTH,
183 .dst_info.data_width = STEDMA40_WORD_WIDTH,
184};
185#endif
186
Lee Jones5e1ac7d2012-05-29 14:40:04 +0800187struct mmci_platform_data mop500_sdi4_data = {
Ulf Hanssonb6ff56a2013-05-23 15:13:45 +0200188 .f_max = 100000000,
Ulf Hanssona2be7762013-05-23 15:13:47 +0200189 .capabilities = MMC_CAP_4_BIT_DATA |
190 MMC_CAP_8_BIT_DATA |
Ulf Hanssona7de8b302013-05-23 15:13:49 +0200191 MMC_CAP_NONREMOVABLE |
Ulf Hanssona2be7762013-05-23 15:13:47 +0200192 MMC_CAP_MMC_HIGHSPEED |
Ulf Hanssonfd1cc1b2013-05-23 15:13:48 +0200193 MMC_CAP_ERASE |
Ulf Hanssona2be7762013-05-23 15:13:47 +0200194 MMC_CAP_CMD23,
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100195 .gpio_cd = -1,
196 .gpio_wp = -1,
Linus Walleij5d7b8462010-10-14 13:57:59 +0200197#ifdef CONFIG_STE_DMA40
198 .dma_filter = stedma40_filter,
199 .dma_rx_param = &mop500_sdi4_dma_cfg_rx,
200 .dma_tx_param = &mop500_sdi4_dma_cfg_tx,
201#endif
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100202};
203
Lee Jones18403422012-02-06 11:22:21 -0800204void __init mop500_sdi_init(struct device *parent)
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100205{
Linus Walleijc15def12011-12-15 13:38:40 +0100206 /* PoP:ed eMMC */
Lee Jones18403422012-02-06 11:22:21 -0800207 db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
Bibek Basu4bc3a692011-02-15 10:46:59 +0100208 /* On-board eMMC */
Lee Jones18403422012-02-06 11:22:21 -0800209 db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
210
Linus Walleijedaa86a2010-12-02 12:05:18 +0100211 /*
Linus Walleij4b4f7572011-02-15 15:01:35 +0100212 * On boards with the TC35892 GPIO expander, sdi0 will finally
213 * be added when the TC35892 initializes and calls
Linus Walleijedaa86a2010-12-02 12:05:18 +0100214 * mop500_sdi_tc35892_init() above.
215 */
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100216}
Lee Jones110c2c22011-08-26 16:54:07 +0100217
Lee Jones18403422012-02-06 11:22:21 -0800218void __init snowball_sdi_init(struct device *parent)
Lee Jones110c2c22011-08-26 16:54:07 +0100219{
Philippe Langlais2ab11592012-01-20 09:20:40 +0100220 /* On Snowball MMC_CAP_SD_HIGHSPEED isn't supported (Hardware issue?) */
221 mop500_sdi0_data.capabilities &= ~MMC_CAP_SD_HIGHSPEED;
Lee Jones110c2c22011-08-26 16:54:07 +0100222 /* On-board eMMC */
Lee Jones18403422012-02-06 11:22:21 -0800223 db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
Linus Walleijc15def12011-12-15 13:38:40 +0100224 /* External Micro SD slot */
Lee Jones110c2c22011-08-26 16:54:07 +0100225 mop500_sdi0_data.gpio_cd = SNOWBALL_SDMMC_CD_GPIO;
226 mop500_sdi0_data.cd_invert = true;
Lee Jones18403422012-02-06 11:22:21 -0800227 sdi0_configure(parent);
Lee Jones110c2c22011-08-26 16:54:07 +0100228}
229
Lee Jones18403422012-02-06 11:22:21 -0800230void __init hrefv60_sdi_init(struct device *parent)
Lee Jones110c2c22011-08-26 16:54:07 +0100231{
Linus Walleijc15def12011-12-15 13:38:40 +0100232 /* PoP:ed eMMC */
Lee Jones18403422012-02-06 11:22:21 -0800233 db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
Lee Jones110c2c22011-08-26 16:54:07 +0100234 /* On-board eMMC */
Lee Jones18403422012-02-06 11:22:21 -0800235 db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
Linus Walleijc15def12011-12-15 13:38:40 +0100236 /* External Micro SD slot */
Lee Jones110c2c22011-08-26 16:54:07 +0100237 mop500_sdi0_data.gpio_cd = HREFV60_SDMMC_CD_GPIO;
Lee Jones18403422012-02-06 11:22:21 -0800238 sdi0_configure(parent);
Linus Walleijc15def12011-12-15 13:38:40 +0100239 /* WLAN SDIO channel */
Lee Jones18403422012-02-06 11:22:21 -0800240 db8500_add_sdi1(parent, &mop500_sdi1_data, U8500_SDI_V2_PERIPHID);
Lee Jones110c2c22011-08-26 16:54:07 +0100241}