blob: d0450401818e213b85bb58876b583bb19b55b6cb [file] [log] [blame]
Duy Truong790f06d2013-02-13 16:38:12 -08001/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#include <linux/init.h>
15#include <linux/ioport.h>
16#include <linux/platform_device.h>
17#include <linux/bootmem.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070018#include <linux/gpio.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080019#include <asm/mach-types.h>
20#include <asm/mach/mmc.h>
21#include <mach/msm_bus_board.h>
22#include <mach/board.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080023#include <mach/gpiomux.h>
Krishna Kondae9cb4b82012-07-02 14:42:59 -070024#include <mach/socinfo.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080025#include "devices.h"
Jay Chokshi06fa7542011-12-07 13:09:17 -080026
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080027#include "board-8930.h"
Subhash Jadavanibcd435f2012-04-24 18:26:49 +053028#include "board-storage-common-a.h"
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080029
30/* MSM8960 has 5 SDCC controllers */
31enum sdcc_controllers {
32 SDCC1,
33 SDCC2,
34 SDCC3,
35 SDCC4,
36 SDCC5,
37 MAX_SDCC_CONTROLLER
38};
39
40/* All SDCC controllers require VDD/VCC voltage */
41static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
42 /* SDCC1 : eMMC card connected */
43 [SDCC1] = {
44 .name = "sdc_vdd",
45 .high_vol_level = 2950000,
46 .low_vol_level = 2950000,
47 .always_on = 1,
48 .lpm_sup = 1,
49 .lpm_uA = 9000,
50 .hpm_uA = 200000, /* 200mA */
51 },
52 /* SDCC3 : External card slot connected */
53 [SDCC3] = {
54 .name = "sdc_vdd",
55 .high_vol_level = 2950000,
56 .low_vol_level = 2950000,
Krishna Konda41b6ab02012-05-16 15:08:03 -070057 /*
58 * Normally this is not an always ON regulator. On this
59 * platform, unfortunately the sd detect line is connected
60 * to this via esd circuit and so turn this off/on while card
61 * is not present causes the sd detect line to toggle
62 * continuously. This is expected to be fixed in the newer
63 * hardware revisions - maybe once that is done, this can be
64 * reverted.
65 */
Krishna Konda41b6ab02012-05-16 15:08:03 -070066 .lpm_sup = 1,
Krishna Kondad4f88122012-02-17 18:43:52 -080067 .hpm_uA = 800000, /* 800mA */
Krishna Konda41b6ab02012-05-16 15:08:03 -070068 .lpm_uA = 9000,
Krishna Konda3c4142d2012-06-27 11:01:56 -070069 },
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080070};
71
Subhash Jadavani937c7502012-06-01 15:34:46 +053072/* All SDCC controllers may require voting for VDD PAD voltage */
73static struct msm_mmc_reg_data mmc_vdd_io_reg_data[MAX_SDCC_CONTROLLER] = {
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080074 /* SDCC1 : eMMC card connected */
75 [SDCC1] = {
Subhash Jadavani937c7502012-06-01 15:34:46 +053076 .name = "sdc_vdd_io",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080077 .always_on = 1,
78 .high_vol_level = 1800000,
79 .low_vol_level = 1800000,
80 .hpm_uA = 200000, /* 200mA */
Subhash Jadavani937c7502012-06-01 15:34:46 +053081 },
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080082 /* SDCC3 : External card slot connected */
83 [SDCC3] = {
Subhash Jadavani937c7502012-06-01 15:34:46 +053084 .name = "sdc_vdd_io",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080085 .high_vol_level = 2950000,
86 .low_vol_level = 1850000,
87 .always_on = 1,
88 .lpm_sup = 1,
89 /* Max. Active current required is 16 mA */
90 .hpm_uA = 16000,
91 /*
92 * Sleep current required is ~300 uA. But min. vote can be
93 * in terms of mA (min. 1 mA). So let's vote for 2 mA
94 * during sleep.
95 */
96 .lpm_uA = 2000,
97 }
98};
99
100static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = {
101 /* SDCC1 : eMMC card connected */
102 [SDCC1] = {
103 .vdd_data = &mmc_vdd_reg_data[SDCC1],
Subhash Jadavani937c7502012-06-01 15:34:46 +0530104 .vdd_io_data = &mmc_vdd_io_reg_data[SDCC1],
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800105 },
106 /* SDCC3 : External card slot connected */
107 [SDCC3] = {
108 .vdd_data = &mmc_vdd_reg_data[SDCC3],
Subhash Jadavani937c7502012-06-01 15:34:46 +0530109 .vdd_io_data = &mmc_vdd_io_reg_data[SDCC3],
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800110 }
111};
112
113/* SDC1 pad data */
114static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
115 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
116 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
117 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
118};
119
120static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
121 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
122 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
123 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
124};
125
126static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
127 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
128 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
129 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
130};
131
132static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
133 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
Krishna Kondacf10b9f2012-02-17 19:22:39 -0800134 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
135 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800136};
137
138/* SDC3 pad data */
139static struct msm_mmc_pad_drv sdc3_pad_drv_on_cfg[] = {
140 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
141 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
142 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
143};
144
145static struct msm_mmc_pad_drv sdc3_pad_drv_off_cfg[] = {
146 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
147 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
148 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
149};
150
151static struct msm_mmc_pad_pull sdc3_pad_pull_on_cfg[] = {
152 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
153 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
154 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
155};
156
157static struct msm_mmc_pad_pull sdc3_pad_pull_off_cfg[] = {
158 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
159 /*
160 * SDC3 CMD line should be PULLed UP otherwise fluid platform will
161 * see transitions (1 -> 0 and 0 -> 1) on card detection line,
162 * which would result in false card detection interrupts.
163 */
164 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
165 /*
166 * Keeping DATA lines status to PULL UP will make sure that
167 * there is no current leak during sleep if external pull up
168 * is connected to DATA lines.
169 */
170 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
171};
172
173static struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
174 [SDCC1] = {
175 .on = sdc1_pad_pull_on_cfg,
176 .off = sdc1_pad_pull_off_cfg,
177 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
178 },
179 [SDCC3] = {
180 .on = sdc3_pad_pull_on_cfg,
181 .off = sdc3_pad_pull_off_cfg,
182 .size = ARRAY_SIZE(sdc3_pad_pull_on_cfg)
183 },
184};
185
186static struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
187 [SDCC1] = {
188 .on = sdc1_pad_drv_on_cfg,
189 .off = sdc1_pad_drv_off_cfg,
190 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
191 },
192 [SDCC3] = {
193 .on = sdc3_pad_drv_on_cfg,
194 .off = sdc3_pad_drv_off_cfg,
195 .size = ARRAY_SIZE(sdc3_pad_drv_on_cfg)
196 },
197};
198
199static struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
200 [SDCC1] = {
201 .pull = &mmc_pad_pull_data[SDCC1],
202 .drv = &mmc_pad_drv_data[SDCC1]
203 },
204 [SDCC3] = {
205 .pull = &mmc_pad_pull_data[SDCC3],
206 .drv = &mmc_pad_drv_data[SDCC3]
207 },
208};
209
210static struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
211 [SDCC1] = {
212 .pad_data = &mmc_pad_data[SDCC1],
213 },
214 [SDCC3] = {
215 .pad_data = &mmc_pad_data[SDCC3],
216 },
217};
218
Subhash Jadavani55e188e2012-04-13 11:31:08 +0530219#define MSM_MPM_PIN_SDC1_DAT1 17
220#define MSM_MPM_PIN_SDC3_DAT1 21
221
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800222static unsigned int sdc1_sup_clk_rates[] = {
Subhash Jadavani871b1a82012-06-14 16:08:38 +0530223 400000, 24000000, 48000000, 96000000
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800224};
225
Terence Hampson2e1705f2012-04-11 19:55:29 -0400226#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800227static unsigned int sdc3_sup_clk_rates[] = {
Krishna Kondad4f88122012-02-17 18:43:52 -0800228 400000, 24000000, 48000000, 96000000, 192000000,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800229};
Terence Hampson2e1705f2012-04-11 19:55:29 -0400230#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800231
232#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
233static struct mmc_platform_data msm8960_sdc1_data = {
234 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
235#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
236 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
237#else
238 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
239#endif
240 .sup_clk_table = sdc1_sup_clk_rates,
241 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800242 .nonremovable = 1,
243 .vreg_data = &mmc_slot_vreg_data[SDCC1],
Subhash Jadavani55e188e2012-04-13 11:31:08 +0530244 .pin_data = &mmc_slot_pin_data[SDCC1],
245 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC1_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +0530246 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Subhash Jadavanicb6f9ce2012-06-26 11:57:10 +0530247 .uhs_caps2 = MMC_CAP2_HS200_1_8V_SDR,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800248};
249#endif
250
251#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
252static struct mmc_platform_data msm8960_sdc3_data = {
253 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
254 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
255 .sup_clk_table = sdc3_sup_clk_rates,
256 .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates),
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800257#ifdef CONFIG_MMC_MSM_SDC3_WP_SUPPORT
Jay Chokshi06fa7542011-12-07 13:09:17 -0800258/*TODO: Insert right replacement for PM8038 */
259#ifndef MSM8930_PHASE_2
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800260 .wpswitch_gpio = PM8921_GPIO_PM_TO_SYS(16),
Krishna Konda40ec7e92011-12-20 19:28:25 -0800261#else
262 .wpswitch_gpio = 66,
Sujit Reddy Thumma8f912ea2012-06-22 16:18:43 +0530263 .is_wpswitch_active_low = true,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800264#endif
Jay Chokshi06fa7542011-12-07 13:09:17 -0800265#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800266 .vreg_data = &mmc_slot_vreg_data[SDCC3],
267 .pin_data = &mmc_slot_pin_data[SDCC3],
Jay Chokshi06fa7542011-12-07 13:09:17 -0800268/*TODO: Insert right replacement for PM8038 */
269#ifndef MSM8930_PHASE_2
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800270 .status_gpio = PM8921_GPIO_PM_TO_SYS(26),
271 .status_irq = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, 26),
Krishna Konda40ec7e92011-12-20 19:28:25 -0800272#else
273 .status_gpio = 94,
274 .status_irq = MSM_GPIO_TO_INT(94),
Jay Chokshi06fa7542011-12-07 13:09:17 -0800275#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800276 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Krishna Konda941604a2012-01-10 17:46:34 -0800277 .is_status_gpio_active_low = true,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800278 .xpc_cap = 1,
279 .uhs_caps = (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
280 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_DDR50 |
Krishna Kondad4f88122012-02-17 18:43:52 -0800281 MMC_CAP_UHS_SDR104 | MMC_CAP_MAX_CURRENT_800),
Subhash Jadavani55e188e2012-04-13 11:31:08 +0530282 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +0530283 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800284};
285#endif
286
287void __init msm8930_init_mmc(void)
288{
289#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Subhash Jadavani871b1a82012-06-14 16:08:38 +0530290 /*
291 * When eMMC runs in DDR mode on CDP platform, we have
292 * seen instability due to DATA CRC errors. These errors are
293 * attributed to long physical path between MSM and eMMC on CDP.
294 * So let's not enable the DDR mode on CDP platform but let other
295 * platforms take advantage of eMMC DDR mode.
296 */
297 if (!machine_is_msm8930_cdp())
298 msm8960_sdc1_data.uhs_caps |= (MMC_CAP_1_8V_DDR |
299 MMC_CAP_UHS_DDR50);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800300 /* SDC1 : eMMC card connected */
301 msm_add_sdcc(1, &msm8960_sdc1_data);
302#endif
303#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Krishna Kondae9cb4b82012-07-02 14:42:59 -0700304 /*
305 * All 8930 platform boards using the 1.2 SoC have been reworked so that
306 * the sd card detect line's esd circuit is no longer powered by the sd
307 * card's voltage regulator. So this means we can turn the regulator off
308 * to save power without affecting the sd card detect functionality.
309 * This change to the boards will be true for newer versions of the SoC
310 * as well.
311 */
Pratibhasagar Vca48b582013-02-21 18:55:36 +0530312 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1 &&
313 SOCINFO_VERSION_MINOR(socinfo_get_version()) < 2) {
314 msm8960_sdc3_data.vreg_data->vdd_data->always_on = true;
315 msm8960_sdc3_data.vreg_data->vdd_data->reset_at_init = true;
Krishna Kondae9cb4b82012-07-02 14:42:59 -0700316 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800317 /* SDC3: External card slot */
Krishna Kondafb2b1982012-05-15 20:32:26 -0700318 if (!machine_is_msm8930_cdp()) {
319 msm8960_sdc3_data.wpswitch_gpio = 0;
Sujit Reddy Thumma8f912ea2012-06-22 16:18:43 +0530320 msm8960_sdc3_data.is_wpswitch_active_low = false;
Krishna Kondafb2b1982012-05-15 20:32:26 -0700321 }
Krishna Kondae9cb4b82012-07-02 14:42:59 -0700322
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800323 msm_add_sdcc(3, &msm8960_sdc3_data);
324#endif
325}