Stepan Moskovchenko | 0c547bb | 2011-11-30 13:29:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 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> |
| 18 | #include <asm/mach-types.h> |
| 19 | #include <asm/mach/mmc.h> |
| 20 | #include <mach/msm_bus_board.h> |
| 21 | #include <mach/board.h> |
| 22 | #include <mach/gpio.h> |
| 23 | #include <mach/gpiomux.h> |
| 24 | #include "devices.h" |
Stepan Moskovchenko | 5a83dba | 2011-12-05 17:30:17 -0800 | [diff] [blame] | 25 | #include "board-8960.h" |
Stepan Moskovchenko | 0c547bb | 2011-11-30 13:29:12 -0800 | [diff] [blame] | 26 | |
| 27 | /* MSM8960 has 5 SDCC controllers */ |
| 28 | enum sdcc_controllers { |
| 29 | SDCC1, |
| 30 | SDCC2, |
| 31 | SDCC3, |
| 32 | SDCC4, |
| 33 | SDCC5, |
| 34 | MAX_SDCC_CONTROLLER |
| 35 | }; |
| 36 | |
| 37 | /* All SDCC controllers require VDD/VCC voltage */ |
| 38 | static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = { |
| 39 | /* SDCC1 : eMMC card connected */ |
| 40 | [SDCC1] = { |
| 41 | .name = "sdc_vdd", |
| 42 | .high_vol_level = 2950000, |
| 43 | .low_vol_level = 2950000, |
| 44 | .always_on = 1, |
| 45 | .lpm_sup = 1, |
| 46 | .lpm_uA = 9000, |
| 47 | .hpm_uA = 200000, /* 200mA */ |
| 48 | }, |
| 49 | /* SDCC3 : External card slot connected */ |
| 50 | [SDCC3] = { |
| 51 | .name = "sdc_vdd", |
| 52 | .high_vol_level = 2950000, |
| 53 | .low_vol_level = 2950000, |
| 54 | .hpm_uA = 600000, /* 600mA */ |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | /* Only slots having eMMC card will require VCCQ voltage */ |
| 59 | static struct msm_mmc_reg_data mmc_vccq_reg_data[1] = { |
| 60 | /* SDCC1 : eMMC card connected */ |
| 61 | [SDCC1] = { |
| 62 | .name = "sdc_vccq", |
| 63 | .always_on = 1, |
| 64 | .high_vol_level = 1800000, |
| 65 | .low_vol_level = 1800000, |
| 66 | .hpm_uA = 200000, /* 200mA */ |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | /* All SDCC controllers may require voting for VDD PAD voltage */ |
| 71 | static struct msm_mmc_reg_data mmc_vddp_reg_data[MAX_SDCC_CONTROLLER] = { |
| 72 | /* SDCC3 : External card slot connected */ |
| 73 | [SDCC3] = { |
| 74 | .name = "sdc_vddp", |
| 75 | .high_vol_level = 2950000, |
| 76 | .low_vol_level = 1850000, |
| 77 | .always_on = 1, |
| 78 | .lpm_sup = 1, |
| 79 | /* Max. Active current required is 16 mA */ |
| 80 | .hpm_uA = 16000, |
| 81 | /* |
| 82 | * Sleep current required is ~300 uA. But min. vote can be |
| 83 | * in terms of mA (min. 1 mA). So let's vote for 2 mA |
| 84 | * during sleep. |
| 85 | */ |
| 86 | .lpm_uA = 2000, |
| 87 | } |
| 88 | }; |
| 89 | |
| 90 | static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = { |
| 91 | /* SDCC1 : eMMC card connected */ |
| 92 | [SDCC1] = { |
| 93 | .vdd_data = &mmc_vdd_reg_data[SDCC1], |
| 94 | .vccq_data = &mmc_vccq_reg_data[SDCC1], |
| 95 | }, |
| 96 | /* SDCC3 : External card slot connected */ |
| 97 | [SDCC3] = { |
| 98 | .vdd_data = &mmc_vdd_reg_data[SDCC3], |
| 99 | .vddp_data = &mmc_vddp_reg_data[SDCC3], |
| 100 | } |
| 101 | }; |
| 102 | |
| 103 | /* SDC1 pad data */ |
| 104 | static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = { |
| 105 | {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA}, |
| 106 | {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA}, |
| 107 | {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA} |
| 108 | }; |
| 109 | |
| 110 | static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = { |
| 111 | {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA}, |
| 112 | {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA}, |
| 113 | {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA} |
| 114 | }; |
| 115 | |
| 116 | static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = { |
| 117 | {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL}, |
| 118 | {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP}, |
| 119 | {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP} |
| 120 | }; |
| 121 | |
| 122 | static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = { |
| 123 | {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL}, |
| 124 | {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN}, |
| 125 | {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN} |
| 126 | }; |
| 127 | |
| 128 | /* SDC3 pad data */ |
| 129 | static struct msm_mmc_pad_drv sdc3_pad_drv_on_cfg[] = { |
| 130 | {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA}, |
| 131 | {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA}, |
| 132 | {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA} |
| 133 | }; |
| 134 | |
| 135 | static struct msm_mmc_pad_drv sdc3_pad_drv_off_cfg[] = { |
| 136 | {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA}, |
| 137 | {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA}, |
| 138 | {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA} |
| 139 | }; |
| 140 | |
| 141 | static struct msm_mmc_pad_pull sdc3_pad_pull_on_cfg[] = { |
| 142 | {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL}, |
| 143 | {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP}, |
| 144 | {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP} |
| 145 | }; |
| 146 | |
| 147 | static struct msm_mmc_pad_pull sdc3_pad_pull_off_cfg[] = { |
| 148 | {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL}, |
| 149 | /* |
| 150 | * SDC3 CMD line should be PULLed UP otherwise fluid platform will |
| 151 | * see transitions (1 -> 0 and 0 -> 1) on card detection line, |
| 152 | * which would result in false card detection interrupts. |
| 153 | */ |
| 154 | {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP}, |
| 155 | /* |
| 156 | * Keeping DATA lines status to PULL UP will make sure that |
| 157 | * there is no current leak during sleep if external pull up |
| 158 | * is connected to DATA lines. |
| 159 | */ |
| 160 | {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP} |
| 161 | }; |
| 162 | |
| 163 | static struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = { |
| 164 | [SDCC1] = { |
| 165 | .on = sdc1_pad_pull_on_cfg, |
| 166 | .off = sdc1_pad_pull_off_cfg, |
| 167 | .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg) |
| 168 | }, |
| 169 | [SDCC3] = { |
| 170 | .on = sdc3_pad_pull_on_cfg, |
| 171 | .off = sdc3_pad_pull_off_cfg, |
| 172 | .size = ARRAY_SIZE(sdc3_pad_pull_on_cfg) |
| 173 | }, |
| 174 | }; |
| 175 | |
| 176 | static struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = { |
| 177 | [SDCC1] = { |
| 178 | .on = sdc1_pad_drv_on_cfg, |
| 179 | .off = sdc1_pad_drv_off_cfg, |
| 180 | .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg) |
| 181 | }, |
| 182 | [SDCC3] = { |
| 183 | .on = sdc3_pad_drv_on_cfg, |
| 184 | .off = sdc3_pad_drv_off_cfg, |
| 185 | .size = ARRAY_SIZE(sdc3_pad_drv_on_cfg) |
| 186 | }, |
| 187 | }; |
| 188 | |
| 189 | static struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = { |
| 190 | [SDCC1] = { |
| 191 | .pull = &mmc_pad_pull_data[SDCC1], |
| 192 | .drv = &mmc_pad_drv_data[SDCC1] |
| 193 | }, |
| 194 | [SDCC3] = { |
| 195 | .pull = &mmc_pad_pull_data[SDCC3], |
| 196 | .drv = &mmc_pad_drv_data[SDCC3] |
| 197 | }, |
| 198 | }; |
| 199 | |
| 200 | static struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = { |
| 201 | [SDCC1] = { |
| 202 | .pad_data = &mmc_pad_data[SDCC1], |
| 203 | }, |
| 204 | [SDCC3] = { |
| 205 | .pad_data = &mmc_pad_data[SDCC3], |
| 206 | }, |
| 207 | }; |
| 208 | |
| 209 | static unsigned int sdc1_sup_clk_rates[] = { |
| 210 | 400000, 24000000, 48000000 |
| 211 | }; |
| 212 | |
| 213 | static unsigned int sdc3_sup_clk_rates[] = { |
Subhash Jadavani | 2f64f5a | 2011-12-06 17:17:23 +0530 | [diff] [blame] | 214 | 400000, 24000000, 48000000, 96000000, 192000000 |
Stepan Moskovchenko | 0c547bb | 2011-11-30 13:29:12 -0800 | [diff] [blame] | 215 | }; |
| 216 | |
| 217 | #ifdef CONFIG_MMC_MSM_SDC1_SUPPORT |
| 218 | static struct mmc_platform_data msm8960_sdc1_data = { |
| 219 | .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29, |
| 220 | #ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT |
| 221 | .mmc_bus_width = MMC_CAP_8_BIT_DATA, |
| 222 | #else |
| 223 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 224 | #endif |
| 225 | .sup_clk_table = sdc1_sup_clk_rates, |
| 226 | .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates), |
| 227 | .pclk_src_dfab = 1, |
| 228 | .nonremovable = 1, |
| 229 | .vreg_data = &mmc_slot_vreg_data[SDCC1], |
| 230 | .pin_data = &mmc_slot_pin_data[SDCC1] |
| 231 | }; |
| 232 | #endif |
| 233 | |
| 234 | #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT |
| 235 | static struct mmc_platform_data msm8960_sdc3_data = { |
| 236 | .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29, |
| 237 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 238 | .sup_clk_table = sdc3_sup_clk_rates, |
| 239 | .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates), |
| 240 | .pclk_src_dfab = 1, |
| 241 | #ifdef CONFIG_MMC_MSM_SDC3_WP_SUPPORT |
| 242 | .wpswitch_gpio = PM8921_GPIO_PM_TO_SYS(16), |
| 243 | #endif |
| 244 | .vreg_data = &mmc_slot_vreg_data[SDCC3], |
| 245 | .pin_data = &mmc_slot_pin_data[SDCC3], |
| 246 | #ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION |
| 247 | .status_gpio = PM8921_GPIO_PM_TO_SYS(26), |
| 248 | .status_irq = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, 26), |
| 249 | .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
Krishna Konda | 360aa42 | 2011-12-06 18:27:41 -0800 | [diff] [blame] | 250 | .is_status_gpio_active_low = true, |
Stepan Moskovchenko | 0c547bb | 2011-11-30 13:29:12 -0800 | [diff] [blame] | 251 | #endif |
| 252 | .xpc_cap = 1, |
| 253 | .uhs_caps = (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | |
| 254 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_DDR50 | |
Subhash Jadavani | 2f64f5a | 2011-12-06 17:17:23 +0530 | [diff] [blame] | 255 | MMC_CAP_UHS_SDR104 | MMC_CAP_MAX_CURRENT_600), |
Stepan Moskovchenko | 0c547bb | 2011-11-30 13:29:12 -0800 | [diff] [blame] | 256 | }; |
| 257 | #endif |
| 258 | |
| 259 | void __init msm8960_init_mmc(void) |
| 260 | { |
| 261 | #ifdef CONFIG_MMC_MSM_SDC1_SUPPORT |
| 262 | /* SDC1 : eMMC card connected */ |
| 263 | msm_add_sdcc(1, &msm8960_sdc1_data); |
| 264 | #endif |
| 265 | #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT |
| 266 | /* SDC3: External card slot */ |
| 267 | msm_add_sdcc(3, &msm8960_sdc3_data); |
| 268 | #endif |
| 269 | } |