Merge branches 'samsung/exynos-dt2' and 'samsung/s3c24xx-dt2' into next/drivers
[cascardo/linux.git] / arch / arm / mach-ux500 / board-mop500-sdi.c
1 /*
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>
14 #include <linux/platform_data/dma-ste-dma40.h>
15
16 #include <asm/mach-types.h>
17 #include "devices.h"
18
19 #include "db8500-regs.h"
20 #include "devices-db8500.h"
21 #include "board-mop500.h"
22 #include "ste-dma40-db8500.h"
23
24 /*
25  * 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 /*
31  * SDI 0 (MicroSD slot)
32  */
33
34 #ifdef CONFIG_STE_DMA40
35 struct stedma40_chan_cfg mop500_sdi0_dma_cfg_rx = {
36         .mode = STEDMA40_MODE_LOGICAL,
37         .dir = DMA_DEV_TO_MEM,
38         .dev_type = DB8500_DMA_DEV29_SD_MM0,
39 };
40
41 static struct stedma40_chan_cfg mop500_sdi0_dma_cfg_tx = {
42         .mode = STEDMA40_MODE_LOGICAL,
43         .dir = DMA_MEM_TO_DEV,
44         .dev_type = DB8500_DMA_DEV29_SD_MM0,
45 };
46 #endif
47
48 struct mmci_platform_data mop500_sdi0_data = {
49         .ocr_mask       = MMC_VDD_29_30,
50         .f_max          = 50000000,
51         .capabilities   = MMC_CAP_4_BIT_DATA |
52                                 MMC_CAP_SD_HIGHSPEED |
53                                 MMC_CAP_MMC_HIGHSPEED,
54         .gpio_wp        = -1,
55         .sigdir         = MCI_ST_FBCLKEN |
56                                 MCI_ST_CMDDIREN |
57                                 MCI_ST_DATA0DIREN |
58                                 MCI_ST_DATA2DIREN,
59 #ifdef CONFIG_STE_DMA40
60         .dma_filter     = stedma40_filter,
61         .dma_rx_param   = &mop500_sdi0_dma_cfg_rx,
62         .dma_tx_param   = &mop500_sdi0_dma_cfg_tx,
63 #endif
64 };
65
66 static void sdi0_configure(struct device *parent)
67 {
68         /* Add the device, force v2 to subrevision 1 */
69         db8500_add_sdi0(parent, &mop500_sdi0_data, U8500_SDI_V2_PERIPHID);
70 }
71
72 void mop500_sdi_tc35892_init(struct device *parent)
73 {
74         mop500_sdi0_data.gpio_cd = GPIO_SDMMC_CD;
75         sdi0_configure(parent);
76 }
77
78 /*
79  * SDI1 (SDIO WLAN)
80  */
81 #ifdef CONFIG_STE_DMA40
82 static struct stedma40_chan_cfg sdi1_dma_cfg_rx = {
83         .mode = STEDMA40_MODE_LOGICAL,
84         .dir = DMA_DEV_TO_MEM,
85         .dev_type = DB8500_DMA_DEV32_SD_MM1,
86 };
87
88 static struct stedma40_chan_cfg sdi1_dma_cfg_tx = {
89         .mode = STEDMA40_MODE_LOGICAL,
90         .dir = DMA_MEM_TO_DEV,
91         .dev_type = DB8500_DMA_DEV32_SD_MM1,
92 };
93 #endif
94
95 struct mmci_platform_data mop500_sdi1_data = {
96         .ocr_mask       = MMC_VDD_29_30,
97         .f_max          = 50000000,
98         .capabilities   = MMC_CAP_4_BIT_DATA,
99         .gpio_cd        = -1,
100         .gpio_wp        = -1,
101 #ifdef CONFIG_STE_DMA40
102         .dma_filter     = stedma40_filter,
103         .dma_rx_param   = &sdi1_dma_cfg_rx,
104         .dma_tx_param   = &sdi1_dma_cfg_tx,
105 #endif
106 };
107
108 /*
109  * SDI 2 (POP eMMC, not on DB8500ed)
110  */
111
112 #ifdef CONFIG_STE_DMA40
113 struct stedma40_chan_cfg mop500_sdi2_dma_cfg_rx = {
114         .mode = STEDMA40_MODE_LOGICAL,
115         .dir = DMA_DEV_TO_MEM,
116         .dev_type =  DB8500_DMA_DEV28_SD_MM2,
117 };
118
119 static struct stedma40_chan_cfg mop500_sdi2_dma_cfg_tx = {
120         .mode = STEDMA40_MODE_LOGICAL,
121         .dir = DMA_MEM_TO_DEV,
122         .dev_type = DB8500_DMA_DEV28_SD_MM2,
123 };
124 #endif
125
126 struct mmci_platform_data mop500_sdi2_data = {
127         .ocr_mask       = MMC_VDD_165_195,
128         .f_max          = 50000000,
129         .capabilities   = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
130                           MMC_CAP_MMC_HIGHSPEED,
131         .gpio_cd        = -1,
132         .gpio_wp        = -1,
133 #ifdef CONFIG_STE_DMA40
134         .dma_filter     = stedma40_filter,
135         .dma_rx_param   = &mop500_sdi2_dma_cfg_rx,
136         .dma_tx_param   = &mop500_sdi2_dma_cfg_tx,
137 #endif
138 };
139
140 /*
141  * SDI 4 (on-board eMMC)
142  */
143
144 #ifdef CONFIG_STE_DMA40
145 struct stedma40_chan_cfg mop500_sdi4_dma_cfg_rx = {
146         .mode = STEDMA40_MODE_LOGICAL,
147         .dir = DMA_DEV_TO_MEM,
148         .dev_type =  DB8500_DMA_DEV42_SD_MM4,
149 };
150
151 static struct stedma40_chan_cfg mop500_sdi4_dma_cfg_tx = {
152         .mode = STEDMA40_MODE_LOGICAL,
153         .dir = DMA_MEM_TO_DEV,
154         .dev_type = DB8500_DMA_DEV42_SD_MM4,
155 };
156 #endif
157
158 struct mmci_platform_data mop500_sdi4_data = {
159         .ocr_mask       = MMC_VDD_29_30,
160         .f_max          = 50000000,
161         .capabilities   = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
162                           MMC_CAP_MMC_HIGHSPEED,
163         .gpio_cd        = -1,
164         .gpio_wp        = -1,
165 #ifdef CONFIG_STE_DMA40
166         .dma_filter     = stedma40_filter,
167         .dma_rx_param   = &mop500_sdi4_dma_cfg_rx,
168         .dma_tx_param   = &mop500_sdi4_dma_cfg_tx,
169 #endif
170 };
171
172 void __init mop500_sdi_init(struct device *parent)
173 {
174         /* PoP:ed eMMC */
175         db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
176         /* On-board eMMC */
177         db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
178
179         /*
180          * On boards with the TC35892 GPIO expander, sdi0 will finally
181          * be added when the TC35892 initializes and calls
182          * mop500_sdi_tc35892_init() above.
183          */
184 }
185
186 void __init snowball_sdi_init(struct device *parent)
187 {
188         /* On Snowball MMC_CAP_SD_HIGHSPEED isn't supported (Hardware issue?) */
189         mop500_sdi0_data.capabilities &= ~MMC_CAP_SD_HIGHSPEED;
190         /* On-board eMMC */
191         db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
192         /* External Micro SD slot */
193         mop500_sdi0_data.gpio_cd = SNOWBALL_SDMMC_CD_GPIO;
194         mop500_sdi0_data.cd_invert = true;
195         sdi0_configure(parent);
196 }
197
198 void __init hrefv60_sdi_init(struct device *parent)
199 {
200         /* PoP:ed eMMC */
201         db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
202         /* On-board eMMC */
203         db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
204         /* External Micro SD slot */
205         mop500_sdi0_data.gpio_cd = HREFV60_SDMMC_CD_GPIO;
206         sdi0_configure(parent);
207         /* WLAN SDIO channel */
208         db8500_add_sdi1(parent, &mop500_sdi1_data, U8500_SDI_V2_PERIPHID);
209 }