Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved. |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 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 | * |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/irq.h> |
| 16 | #include <linux/gpio.h> |
| 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/delay.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 19 | #include <linux/bootmem.h> |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 20 | #include <linux/io.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 21 | #ifdef CONFIG_SPI_QSD |
| 22 | #include <linux/spi/spi.h> |
| 23 | #endif |
Anirudh Ghayal | 9d9cdc2 | 2011-10-10 17:17:07 +0530 | [diff] [blame] | 24 | #include <linux/msm_ssbi.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 25 | #include <linux/mfd/pmic8058.h> |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 26 | #include <linux/leds.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 27 | #include <linux/mfd/marimba.h> |
| 28 | #include <linux/i2c.h> |
| 29 | #include <linux/input.h> |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 30 | #include <linux/smsc911x.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 31 | #include <linux/ofn_atlab.h> |
| 32 | #include <linux/power_supply.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 33 | #include <linux/i2c/isa1200.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 34 | #include <linux/i2c/tsc2007.h> |
| 35 | #include <linux/input/kp_flip_switch.h> |
| 36 | #include <linux/leds-pmic8058.h> |
| 37 | #include <linux/input/cy8c_ts.h> |
| 38 | #include <linux/msm_adc.h> |
| 39 | #include <linux/dma-mapping.h> |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 40 | #include <linux/regulator/consumer.h> |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 41 | |
| 42 | #include <asm/mach-types.h> |
| 43 | #include <asm/mach/arch.h> |
| 44 | #include <asm/setup.h> |
| 45 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 46 | #include <mach/mpp.h> |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 47 | #include <mach/board.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 48 | #include <mach/camera.h> |
| 49 | #include <mach/memory.h> |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 50 | #include <mach/msm_iomap.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 51 | #include <mach/msm_hsusb.h> |
| 52 | #include <mach/rpc_hsusb.h> |
| 53 | #include <mach/msm_spi.h> |
| 54 | #include <mach/qdsp5v2/msm_lpa.h> |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 55 | #include <mach/dma.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 56 | #include <linux/android_pmem.h> |
| 57 | #include <linux/input/msm_ts.h> |
| 58 | #include <mach/pmic.h> |
| 59 | #include <mach/rpc_pmapp.h> |
| 60 | #include <mach/qdsp5v2/aux_pcm.h> |
| 61 | #include <mach/qdsp5v2/mi2s.h> |
| 62 | #include <mach/qdsp5v2/audio_dev_ctl.h> |
| 63 | #include <mach/msm_battery.h> |
| 64 | #include <mach/rpc_server_handset.h> |
| 65 | #include <mach/msm_tsif.h> |
| 66 | #include <mach/socinfo.h> |
| 67 | #include <mach/msm_memtypes.h> |
| 68 | #include <linux/cyttsp.h> |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 69 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 70 | #include <asm/mach/mmc.h> |
| 71 | #include <asm/mach/flash.h> |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 72 | #include <mach/vreg.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 73 | #include <linux/platform_data/qcom_crypto_device.h> |
| 74 | |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 75 | #include "devices.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 76 | #include "timer.h" |
| 77 | #ifdef CONFIG_USB_G_ANDROID |
| 78 | #include <linux/usb/android.h> |
| 79 | #include <mach/usbdiag.h> |
| 80 | #endif |
| 81 | #include "pm.h" |
Maheshkumar Sivasubramanian | 8ccc16e | 2011-10-25 15:59:57 -0600 | [diff] [blame] | 82 | #include "pm-boot.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 83 | #include "spm.h" |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 84 | #include "acpuclock.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 85 | #include <mach/dal_axi.h> |
| 86 | #include <mach/msm_serial_hs.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 87 | #include <mach/qdsp5v2/mi2s.h> |
| 88 | #include <mach/qdsp5v2/audio_dev_ctl.h> |
| 89 | #include <mach/sdio_al.h> |
| 90 | #include "smd_private.h" |
| 91 | #include <linux/bma150.h> |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 92 | |
Justin Paupore | 637a25d | 2011-07-14 17:11:04 -0700 | [diff] [blame] | 93 | #include "board-msm7x30-regulator.h" |
| 94 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 95 | #define MSM_PMEM_SF_SIZE 0x1700000 |
| 96 | #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER |
| 97 | #define MSM_FB_SIZE 0x780000 |
| 98 | #else |
| 99 | #define MSM_FB_SIZE 0x500000 |
| 100 | #endif |
| 101 | #define MSM_PMEM_ADSP_SIZE 0x1E00000 |
| 102 | #define MSM_FLUID_PMEM_ADSP_SIZE 0x2800000 |
| 103 | #define PMEM_KERNEL_EBI0_SIZE 0x600000 |
| 104 | #define MSM_PMEM_AUDIO_SIZE 0x200000 |
Daniel Walker | 90e37c5 | 2010-05-12 14:24:15 -0700 | [diff] [blame] | 105 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 106 | #define PMIC_GPIO_INT 27 |
| 107 | #define PMIC_VREG_WLAN_LEVEL 2900 |
| 108 | #define PMIC_GPIO_SD_DET 36 |
| 109 | #define PMIC_GPIO_SDC4_EN_N 17 /* PMIC GPIO Number 18 */ |
| 110 | #define PMIC_GPIO_HDMI_5V_EN_V3 32 /* PMIC GPIO for V3 H/W */ |
| 111 | #define PMIC_GPIO_HDMI_5V_EN_V2 39 /* PMIC GPIO for V2 H/W */ |
| 112 | |
| 113 | #define ADV7520_I2C_ADDR 0x39 |
| 114 | |
| 115 | #define FPGA_SDCC_STATUS 0x8E0001A8 |
| 116 | |
| 117 | #define FPGA_OPTNAV_GPIO_ADDR 0x8E000026 |
| 118 | #define OPTNAV_I2C_SLAVE_ADDR (0xB0 >> 1) |
| 119 | #define OPTNAV_IRQ 20 |
| 120 | #define OPTNAV_CHIP_SELECT 19 |
| 121 | |
| 122 | /* Macros assume PMIC GPIOs start at 0 */ |
| 123 | #define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_GPIO_IRQS) |
| 124 | #define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_GPIO_IRQS) |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 125 | #define PM8058_MPP_BASE PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) |
| 126 | #define PM8058_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_MPP_BASE) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 127 | |
| 128 | #define PMIC_GPIO_FLASH_BOOST_ENABLE 15 /* PMIC GPIO Number 16 */ |
| 129 | #define PMIC_GPIO_HAP_ENABLE 16 /* PMIC GPIO Number 17 */ |
| 130 | |
| 131 | #define PMIC_GPIO_WLAN_EXT_POR 22 /* PMIC GPIO NUMBER 23 */ |
| 132 | |
| 133 | #define BMA150_GPIO_INT 1 |
| 134 | |
| 135 | #define HAP_LVL_SHFT_MSM_GPIO 24 |
| 136 | |
| 137 | #define PMIC_GPIO_QUICKVX_CLK 37 /* PMIC GPIO 38 */ |
| 138 | |
| 139 | #define PM_FLIP_MPP 5 /* PMIC MPP 06 */ |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 140 | |
| 141 | struct pm8xxx_gpio_init_info { |
| 142 | unsigned gpio; |
| 143 | struct pm_gpio config; |
| 144 | }; |
| 145 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 146 | static int pm8058_gpios_init(void) |
| 147 | { |
| 148 | int rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 149 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 150 | struct pm8xxx_gpio_init_info sdc4_en = { |
| 151 | PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N), |
| 152 | { |
| 153 | .direction = PM_GPIO_DIR_OUT, |
| 154 | .pull = PM_GPIO_PULL_NO, |
| 155 | .vin_sel = PM8058_GPIO_VIN_L5, |
| 156 | .function = PM_GPIO_FUNC_NORMAL, |
| 157 | .inv_int_pol = 0, |
| 158 | .out_strength = PM_GPIO_STRENGTH_LOW, |
| 159 | .output_value = 0, |
| 160 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 161 | }; |
| 162 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 163 | struct pm8xxx_gpio_init_info haptics_enable = { |
| 164 | PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE), |
| 165 | { |
| 166 | .direction = PM_GPIO_DIR_OUT, |
| 167 | .pull = PM_GPIO_PULL_NO, |
| 168 | .out_strength = PM_GPIO_STRENGTH_HIGH, |
| 169 | .function = PM_GPIO_FUNC_NORMAL, |
| 170 | .inv_int_pol = 0, |
| 171 | .vin_sel = 2, |
| 172 | .output_buffer = PM_GPIO_OUT_BUF_CMOS, |
| 173 | .output_value = 0, |
| 174 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 175 | }; |
| 176 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 177 | struct pm8xxx_gpio_init_info hdmi_5V_en = { |
| 178 | PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HDMI_5V_EN_V3), |
| 179 | { |
| 180 | .direction = PM_GPIO_DIR_OUT, |
| 181 | .pull = PM_GPIO_PULL_NO, |
| 182 | .vin_sel = PM8058_GPIO_VIN_VPH, |
| 183 | .function = PM_GPIO_FUNC_NORMAL, |
| 184 | .out_strength = PM_GPIO_STRENGTH_LOW, |
| 185 | .output_value = 0, |
| 186 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 187 | }; |
| 188 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 189 | struct pm8xxx_gpio_init_info flash_boost_enable = { |
| 190 | PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), |
| 191 | { |
| 192 | .direction = PM_GPIO_DIR_OUT, |
| 193 | .output_buffer = PM_GPIO_OUT_BUF_CMOS, |
| 194 | .output_value = 0, |
| 195 | .pull = PM_GPIO_PULL_NO, |
| 196 | .vin_sel = PM8058_GPIO_VIN_S3, |
| 197 | .out_strength = PM_GPIO_STRENGTH_HIGH, |
| 198 | .function = PM_GPIO_FUNC_2, |
| 199 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 200 | }; |
| 201 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 202 | struct pm8xxx_gpio_init_info gpio23 = { |
| 203 | PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_WLAN_EXT_POR), |
| 204 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 205 | .direction = PM_GPIO_DIR_OUT, |
| 206 | .output_buffer = PM_GPIO_OUT_BUF_CMOS, |
| 207 | .output_value = 0, |
| 208 | .pull = PM_GPIO_PULL_NO, |
| 209 | .vin_sel = 2, |
| 210 | .out_strength = PM_GPIO_STRENGTH_LOW, |
| 211 | .function = PM_GPIO_FUNC_NORMAL, |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 212 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 213 | }; |
| 214 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 215 | #ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 216 | struct pm8xxx_gpio_init_info sdcc_det = { |
| 217 | PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1), |
| 218 | { |
| 219 | .direction = PM_GPIO_DIR_IN, |
| 220 | .pull = PM_GPIO_PULL_UP_1P5, |
| 221 | .vin_sel = 2, |
| 222 | .function = PM_GPIO_FUNC_NORMAL, |
| 223 | .inv_int_pol = 0, |
| 224 | }, |
| 225 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 226 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 227 | if (machine_is_msm7x30_fluid()) |
| 228 | sdcc_det.config.inv_int_pol = 1; |
| 229 | |
| 230 | rc = pm8xxx_gpio_config(sdcc_det.gpio, &sdcc_det.config); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 231 | if (rc) { |
| 232 | pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__); |
| 233 | return rc; |
| 234 | } |
| 235 | #endif |
| 236 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 237 | if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() || |
| 238 | machine_is_msm7x30_fluid()) |
| 239 | hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V2; |
| 240 | else |
| 241 | hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V3; |
| 242 | |
| 243 | hdmi_5V_en.gpio = PM8058_GPIO_PM_TO_SYS(hdmi_5V_en.gpio); |
| 244 | |
| 245 | rc = pm8xxx_gpio_config(hdmi_5V_en.gpio, &hdmi_5V_en.config); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 246 | if (rc) { |
| 247 | pr_err("%s PMIC_GPIO_HDMI_5V_EN config failed\n", __func__); |
| 248 | return rc; |
| 249 | } |
| 250 | |
| 251 | /* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */ |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 252 | rc = pm8xxx_gpio_config(gpio23.gpio, &gpio23.config); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 253 | if (rc) { |
| 254 | pr_err("%s PMIC_GPIO_WLAN_EXT_POR config failed\n", __func__); |
| 255 | return rc; |
| 256 | } |
| 257 | |
| 258 | if (machine_is_msm7x30_fluid()) { |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 259 | /* Haptics gpio */ |
| 260 | rc = pm8xxx_gpio_config(haptics_enable.gpio, |
| 261 | &haptics_enable.config); |
| 262 | if (rc) { |
| 263 | pr_err("%s: PMIC GPIO %d write failed\n", __func__, |
| 264 | haptics_enable.gpio); |
| 265 | return rc; |
| 266 | } |
| 267 | /* Flash boost gpio */ |
| 268 | rc = pm8xxx_gpio_config(flash_boost_enable.gpio, |
| 269 | &flash_boost_enable.config); |
| 270 | if (rc) { |
| 271 | pr_err("%s: PMIC GPIO %d write failed\n", __func__, |
| 272 | flash_boost_enable.gpio); |
| 273 | return rc; |
| 274 | } |
| 275 | /* SCD4 gpio */ |
| 276 | rc = pm8xxx_gpio_config(sdc4_en.gpio, &sdc4_en.config); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 277 | if (rc) { |
| 278 | pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n", |
| 279 | __func__); |
| 280 | return rc; |
| 281 | } |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 282 | rc = gpio_request(sdc4_en.gpio, "sdc4_en"); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 283 | if (rc) { |
| 284 | pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n", |
| 285 | __func__); |
| 286 | return rc; |
| 287 | } |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 288 | gpio_set_value_cansleep(sdc4_en.gpio, 0); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | return 0; |
| 292 | } |
| 293 | |
Justin Paupore | 637a25d | 2011-07-14 17:11:04 -0700 | [diff] [blame] | 294 | /* Regulator API support */ |
| 295 | |
| 296 | #ifdef CONFIG_MSM_PROC_COMM_REGULATOR |
| 297 | static struct platform_device msm_proccomm_regulator_dev = { |
| 298 | .name = PROCCOMM_REGULATOR_DEV_NAME, |
| 299 | .id = -1, |
| 300 | .dev = { |
| 301 | .platform_data = &msm7x30_proccomm_regulator_data |
| 302 | } |
| 303 | }; |
| 304 | #endif |
| 305 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 306 | /*virtual key support */ |
| 307 | static ssize_t tma300_vkeys_show(struct kobject *kobj, |
| 308 | struct kobj_attribute *attr, char *buf) |
| 309 | { |
| 310 | return sprintf(buf, |
| 311 | __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100" |
| 312 | ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100" |
| 313 | ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100" |
| 314 | ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100" |
| 315 | "\n"); |
| 316 | } |
| 317 | |
| 318 | static struct kobj_attribute tma300_vkeys_attr = { |
| 319 | .attr = { |
| 320 | .mode = S_IRUGO, |
| 321 | }, |
| 322 | .show = &tma300_vkeys_show, |
Pavankumar Kondeti | 5155e2c | 2010-12-08 13:37:08 +0530 | [diff] [blame] | 323 | }; |
| 324 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 325 | static struct attribute *tma300_properties_attrs[] = { |
| 326 | &tma300_vkeys_attr.attr, |
| 327 | NULL |
Pavankumar Kondeti | 5155e2c | 2010-12-08 13:37:08 +0530 | [diff] [blame] | 328 | }; |
| 329 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 330 | static struct attribute_group tma300_properties_attr_group = { |
| 331 | .attrs = tma300_properties_attrs, |
| 332 | }; |
| 333 | |
| 334 | static struct kobject *properties_kobj; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 335 | static struct regulator_bulk_data cyttsp_regs[] = { |
| 336 | { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 }, |
| 337 | { .supply = "ldo15", .min_uV = 3050000, .max_uV = 3100000 }, |
| 338 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 339 | |
| 340 | #define CYTTSP_TS_GPIO_IRQ 150 |
| 341 | static int cyttsp_platform_init(struct i2c_client *client) |
| 342 | { |
| 343 | int rc = -EINVAL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 344 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 345 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(cyttsp_regs), cyttsp_regs); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 346 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 347 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 348 | pr_err("%s: could not get regulators: %d\n", __func__, rc); |
| 349 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 352 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(cyttsp_regs), cyttsp_regs); |
| 353 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 354 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 355 | pr_err("%s: could not set regulator voltages: %d\n", __func__, |
| 356 | rc); |
| 357 | goto regs_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 358 | } |
| 359 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 360 | rc = regulator_bulk_enable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 361 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 362 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 363 | pr_err("%s: could not enable regulators: %d\n", __func__, rc); |
| 364 | goto regs_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | /* check this device active by reading first byte/register */ |
| 368 | rc = i2c_smbus_read_byte_data(client, 0x01); |
| 369 | if (rc < 0) { |
| 370 | pr_err("%s: i2c sanity check failed\n", __func__); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 371 | goto regs_disable; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT, |
| 375 | GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE); |
| 376 | if (rc) { |
| 377 | pr_err("%s: Could not configure gpio %d\n", |
| 378 | __func__, CYTTSP_TS_GPIO_IRQ); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 379 | goto regs_disable; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | /* virtual keys */ |
| 383 | tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c"; |
| 384 | properties_kobj = kobject_create_and_add("board_properties", |
| 385 | NULL); |
| 386 | if (properties_kobj) |
| 387 | rc = sysfs_create_group(properties_kobj, |
| 388 | &tma300_properties_attr_group); |
| 389 | if (!properties_kobj || rc) |
| 390 | pr_err("%s: failed to create board_properties\n", |
| 391 | __func__); |
| 392 | |
| 393 | return CY_OK; |
| 394 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 395 | regs_disable: |
| 396 | regulator_bulk_disable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs); |
| 397 | regs_free: |
| 398 | regulator_bulk_free(ARRAY_SIZE(cyttsp_regs), cyttsp_regs); |
| 399 | out: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 400 | return rc; |
| 401 | } |
| 402 | |
Anirudh Ghayal | f9929b1 | 2011-09-07 15:57:36 +0530 | [diff] [blame] | 403 | /* TODO: Put the regulator to LPM / HPM in suspend/resume*/ |
| 404 | static int cyttsp_platform_suspend(struct i2c_client *client) |
| 405 | { |
| 406 | msleep(20); |
| 407 | |
| 408 | return CY_OK; |
| 409 | } |
| 410 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 411 | static int cyttsp_platform_resume(struct i2c_client *client) |
| 412 | { |
| 413 | /* add any special code to strobe a wakeup pin or chip reset */ |
| 414 | mdelay(10); |
| 415 | |
| 416 | return CY_OK; |
| 417 | } |
| 418 | |
| 419 | static struct cyttsp_platform_data cyttsp_data = { |
| 420 | .fw_fname = "cyttsp_7630_fluid.hex", |
| 421 | .panel_maxx = 479, |
| 422 | .panel_maxy = 799, |
| 423 | .disp_maxx = 469, |
| 424 | .disp_maxy = 799, |
| 425 | .disp_minx = 10, |
| 426 | .disp_miny = 0, |
| 427 | .flags = 0, |
| 428 | .gen = CY_GEN3, /* or */ |
| 429 | .use_st = CY_USE_ST, |
| 430 | .use_mt = CY_USE_MT, |
| 431 | .use_hndshk = CY_SEND_HNDSHK, |
| 432 | .use_trk_id = CY_USE_TRACKING_ID, |
Anirudh Ghayal | 1518777 | 2011-06-22 17:39:41 +0530 | [diff] [blame] | 433 | .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 434 | .use_gestures = CY_USE_GESTURES, |
| 435 | /* activate up to 4 groups |
| 436 | * and set active distance |
| 437 | */ |
| 438 | .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 | |
| 439 | CY_GEST_GRP3 | CY_GEST_GRP4 | |
| 440 | CY_ACT_DIST, |
| 441 | /* change act_intrvl to customize the Active power state |
| 442 | * scanning/processing refresh interval for Operating mode |
| 443 | */ |
| 444 | .act_intrvl = CY_ACT_INTRVL_DFLT, |
| 445 | /* change tch_tmout to customize the touch timeout for the |
| 446 | * Active power state for Operating mode |
| 447 | */ |
| 448 | .tch_tmout = CY_TCH_TMOUT_DFLT, |
| 449 | /* change lp_intrvl to customize the Low Power power state |
| 450 | * scanning/processing refresh interval for Operating mode |
| 451 | */ |
| 452 | .lp_intrvl = CY_LP_INTRVL_DFLT, |
| 453 | .resume = cyttsp_platform_resume, |
Anirudh Ghayal | f9929b1 | 2011-09-07 15:57:36 +0530 | [diff] [blame] | 454 | .suspend = cyttsp_platform_suspend, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 455 | .init = cyttsp_platform_init, |
| 456 | .sleep_gpio = -1, |
| 457 | .resout_gpio = -1, |
| 458 | .irq_gpio = CYTTSP_TS_GPIO_IRQ, |
Mohan Pallaka | 49c37d6 | 2011-08-01 11:52:00 +0530 | [diff] [blame] | 459 | .correct_fw_ver = 2, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 460 | }; |
| 461 | |
| 462 | static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on) |
| 463 | { |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 464 | struct pm_gpio pwm_gpio_config = { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 465 | .direction = PM_GPIO_DIR_OUT, |
| 466 | .output_buffer = PM_GPIO_OUT_BUF_CMOS, |
| 467 | .output_value = 0, |
| 468 | .pull = PM_GPIO_PULL_NO, |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 469 | .vin_sel = PM8058_GPIO_VIN_S3, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 470 | .out_strength = PM_GPIO_STRENGTH_HIGH, |
| 471 | .function = PM_GPIO_FUNC_2, |
| 472 | }; |
| 473 | int rc = -EINVAL; |
| 474 | int id, mode, max_mA; |
| 475 | |
| 476 | id = mode = max_mA = 0; |
| 477 | switch (ch) { |
| 478 | case 0: |
| 479 | case 1: |
| 480 | case 2: |
| 481 | if (on) { |
| 482 | id = 24 + ch; |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 483 | rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1), |
| 484 | &pwm_gpio_config); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 485 | if (rc) |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 486 | pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 487 | __func__, id, rc); |
| 488 | } |
| 489 | break; |
| 490 | |
| 491 | case 3: |
| 492 | id = PM_PWM_LED_KPD; |
| 493 | mode = PM_PWM_CONF_DTEST3; |
| 494 | max_mA = 200; |
| 495 | break; |
| 496 | |
| 497 | case 4: |
| 498 | id = PM_PWM_LED_0; |
| 499 | mode = PM_PWM_CONF_PWM1; |
| 500 | max_mA = 40; |
| 501 | break; |
| 502 | |
| 503 | case 5: |
| 504 | id = PM_PWM_LED_2; |
| 505 | mode = PM_PWM_CONF_PWM2; |
| 506 | max_mA = 40; |
| 507 | break; |
| 508 | |
| 509 | case 6: |
| 510 | id = PM_PWM_LED_FLASH; |
| 511 | mode = PM_PWM_CONF_DTEST3; |
| 512 | max_mA = 200; |
| 513 | break; |
| 514 | |
| 515 | default: |
| 516 | break; |
| 517 | } |
| 518 | |
| 519 | if (ch >= 3 && ch <= 6) { |
| 520 | if (!on) { |
| 521 | mode = PM_PWM_CONF_NONE; |
| 522 | max_mA = 0; |
| 523 | } |
| 524 | rc = pm8058_pwm_config_led(pwm, id, mode, max_mA); |
| 525 | if (rc) |
| 526 | pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n", |
| 527 | __func__, ch, rc); |
| 528 | } |
| 529 | |
| 530 | return rc; |
| 531 | } |
| 532 | |
| 533 | static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on) |
| 534 | { |
| 535 | int rc; |
| 536 | |
| 537 | switch (ch) { |
| 538 | case 7: |
| 539 | rc = pm8058_pwm_set_dtest(pwm, on); |
| 540 | if (rc) |
| 541 | pr_err("%s: pwm_set_dtest(%d): rc=%d\n", |
| 542 | __func__, on, rc); |
| 543 | break; |
| 544 | default: |
| 545 | rc = -EINVAL; |
| 546 | break; |
| 547 | } |
| 548 | return rc; |
| 549 | } |
| 550 | |
| 551 | static const unsigned int fluid_keymap[] = { |
| 552 | KEY(0, 0, KEY_7), |
| 553 | KEY(0, 1, KEY_ENTER), |
| 554 | KEY(0, 2, KEY_UP), |
| 555 | /* drop (0,3) as it always shows up in pair with(0,2) */ |
| 556 | KEY(0, 4, KEY_DOWN), |
| 557 | |
| 558 | KEY(1, 0, KEY_CAMERA_SNAPSHOT), |
| 559 | KEY(1, 1, KEY_SELECT), |
| 560 | KEY(1, 2, KEY_1), |
| 561 | KEY(1, 3, KEY_VOLUMEUP), |
| 562 | KEY(1, 4, KEY_VOLUMEDOWN), |
| 563 | }; |
| 564 | |
| 565 | static const unsigned int surf_keymap[] = { |
| 566 | KEY(0, 0, KEY_7), |
| 567 | KEY(0, 1, KEY_DOWN), |
| 568 | KEY(0, 2, KEY_UP), |
| 569 | KEY(0, 3, KEY_RIGHT), |
| 570 | KEY(0, 4, KEY_ENTER), |
| 571 | KEY(0, 5, KEY_L), |
| 572 | KEY(0, 6, KEY_BACK), |
| 573 | KEY(0, 7, KEY_M), |
| 574 | |
| 575 | KEY(1, 0, KEY_LEFT), |
| 576 | KEY(1, 1, KEY_SEND), |
| 577 | KEY(1, 2, KEY_1), |
| 578 | KEY(1, 3, KEY_4), |
| 579 | KEY(1, 4, KEY_CLEAR), |
| 580 | KEY(1, 5, KEY_MSDOS), |
| 581 | KEY(1, 6, KEY_SPACE), |
| 582 | KEY(1, 7, KEY_COMMA), |
| 583 | |
| 584 | KEY(2, 0, KEY_6), |
| 585 | KEY(2, 1, KEY_5), |
| 586 | KEY(2, 2, KEY_8), |
| 587 | KEY(2, 3, KEY_3), |
| 588 | KEY(2, 4, KEY_NUMERIC_STAR), |
| 589 | KEY(2, 5, KEY_UP), |
| 590 | KEY(2, 6, KEY_DOWN), /* SYN */ |
| 591 | KEY(2, 7, KEY_LEFTSHIFT), |
| 592 | |
| 593 | KEY(3, 0, KEY_9), |
| 594 | KEY(3, 1, KEY_NUMERIC_POUND), |
| 595 | KEY(3, 2, KEY_0), |
| 596 | KEY(3, 3, KEY_2), |
| 597 | KEY(3, 4, KEY_SLEEP), |
| 598 | KEY(3, 5, KEY_F1), |
| 599 | KEY(3, 6, KEY_F2), |
| 600 | KEY(3, 7, KEY_F3), |
| 601 | |
| 602 | KEY(4, 0, KEY_BACK), |
| 603 | KEY(4, 1, KEY_HOME), |
| 604 | KEY(4, 2, KEY_MENU), |
| 605 | KEY(4, 3, KEY_VOLUMEUP), |
| 606 | KEY(4, 4, KEY_VOLUMEDOWN), |
| 607 | KEY(4, 5, KEY_F4), |
| 608 | KEY(4, 6, KEY_F5), |
| 609 | KEY(4, 7, KEY_F6), |
| 610 | |
| 611 | KEY(5, 0, KEY_R), |
| 612 | KEY(5, 1, KEY_T), |
| 613 | KEY(5, 2, KEY_Y), |
| 614 | KEY(5, 3, KEY_LEFTALT), |
| 615 | KEY(5, 4, KEY_KPENTER), |
| 616 | KEY(5, 5, KEY_Q), |
| 617 | KEY(5, 6, KEY_W), |
| 618 | KEY(5, 7, KEY_E), |
| 619 | |
| 620 | KEY(6, 0, KEY_F), |
| 621 | KEY(6, 1, KEY_G), |
| 622 | KEY(6, 2, KEY_H), |
| 623 | KEY(6, 3, KEY_CAPSLOCK), |
| 624 | KEY(6, 4, KEY_PAGEUP), |
| 625 | KEY(6, 5, KEY_A), |
| 626 | KEY(6, 6, KEY_S), |
| 627 | KEY(6, 7, KEY_D), |
| 628 | |
| 629 | KEY(7, 0, KEY_V), |
| 630 | KEY(7, 1, KEY_B), |
| 631 | KEY(7, 2, KEY_N), |
| 632 | KEY(7, 3, KEY_MENU), /* REVISIT - SYM */ |
| 633 | KEY(7, 4, KEY_PAGEDOWN), |
| 634 | KEY(7, 5, KEY_Z), |
| 635 | KEY(7, 6, KEY_X), |
| 636 | KEY(7, 7, KEY_C), |
| 637 | |
| 638 | KEY(8, 0, KEY_P), |
| 639 | KEY(8, 1, KEY_J), |
| 640 | KEY(8, 2, KEY_K), |
| 641 | KEY(8, 3, KEY_INSERT), |
| 642 | KEY(8, 4, KEY_LINEFEED), |
| 643 | KEY(8, 5, KEY_U), |
| 644 | KEY(8, 6, KEY_I), |
| 645 | KEY(8, 7, KEY_O), |
| 646 | |
| 647 | KEY(9, 0, KEY_4), |
| 648 | KEY(9, 1, KEY_5), |
| 649 | KEY(9, 2, KEY_6), |
| 650 | KEY(9, 3, KEY_7), |
| 651 | KEY(9, 4, KEY_8), |
| 652 | KEY(9, 5, KEY_1), |
| 653 | KEY(9, 6, KEY_2), |
| 654 | KEY(9, 7, KEY_3), |
| 655 | |
| 656 | KEY(10, 0, KEY_F7), |
| 657 | KEY(10, 1, KEY_F8), |
| 658 | KEY(10, 2, KEY_F9), |
| 659 | KEY(10, 3, KEY_F10), |
| 660 | KEY(10, 4, KEY_FN), |
| 661 | KEY(10, 5, KEY_9), |
| 662 | KEY(10, 6, KEY_0), |
| 663 | KEY(10, 7, KEY_DOT), |
| 664 | |
| 665 | KEY(11, 0, KEY_LEFTCTRL), |
| 666 | KEY(11, 1, KEY_F11), /* START */ |
| 667 | KEY(11, 2, KEY_ENTER), |
| 668 | KEY(11, 3, KEY_SEARCH), |
| 669 | KEY(11, 4, KEY_DELETE), |
| 670 | KEY(11, 5, KEY_RIGHT), |
| 671 | KEY(11, 6, KEY_LEFT), |
| 672 | KEY(11, 7, KEY_RIGHTSHIFT), |
| 673 | }; |
| 674 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 675 | static struct matrix_keymap_data surf_keymap_data = { |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 676 | .keymap_size = ARRAY_SIZE(surf_keymap), |
| 677 | .keymap = surf_keymap, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 678 | }; |
| 679 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 680 | static struct pm8xxx_keypad_platform_data surf_keypad_data = { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 681 | .input_name = "surf_keypad", |
| 682 | .input_phys_device = "surf_keypad/input0", |
| 683 | .num_rows = 12, |
| 684 | .num_cols = 8, |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 685 | .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8), |
| 686 | .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0), |
| 687 | .debounce_ms = 15, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 688 | .scan_delay_ms = 32, |
| 689 | .row_hold_ns = 91500, |
| 690 | .wakeup = 1, |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 691 | .keymap_data = &surf_keymap_data, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 692 | }; |
| 693 | |
| 694 | static struct matrix_keymap_data fluid_keymap_data = { |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 695 | .keymap_size = ARRAY_SIZE(fluid_keymap), |
| 696 | .keymap = fluid_keymap, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 697 | }; |
| 698 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 699 | static struct pm8xxx_keypad_platform_data fluid_keypad_data = { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 700 | .input_name = "fluid-keypad", |
| 701 | .input_phys_device = "fluid-keypad/input0", |
| 702 | .num_rows = 5, |
| 703 | .num_cols = 5, |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 704 | .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8), |
| 705 | .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0), |
| 706 | .debounce_ms = 15, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 707 | .scan_delay_ms = 32, |
| 708 | .row_hold_ns = 91500, |
| 709 | .wakeup = 1, |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 710 | .keymap_data = &fluid_keymap_data, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 711 | }; |
| 712 | |
| 713 | static struct pm8058_pwm_pdata pm8058_pwm_data = { |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 714 | .config = pm8058_pwm_config, |
| 715 | .enable = pm8058_pwm_enable, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 716 | }; |
| 717 | |
| 718 | static struct pmic8058_led pmic8058_ffa_leds[] = { |
| 719 | [0] = { |
| 720 | .name = "keyboard-backlight", |
| 721 | .max_brightness = 15, |
| 722 | .id = PMIC8058_ID_LED_KB_LIGHT, |
Dima Zavin | ba5499e | 2011-01-10 11:00:30 -0800 | [diff] [blame] | 723 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 724 | }; |
| 725 | |
| 726 | static struct pmic8058_leds_platform_data pm8058_ffa_leds_data = { |
| 727 | .num_leds = ARRAY_SIZE(pmic8058_ffa_leds), |
| 728 | .leds = pmic8058_ffa_leds, |
| 729 | }; |
| 730 | |
| 731 | static struct pmic8058_led pmic8058_surf_leds[] = { |
| 732 | [0] = { |
| 733 | .name = "keyboard-backlight", |
| 734 | .max_brightness = 15, |
| 735 | .id = PMIC8058_ID_LED_KB_LIGHT, |
| 736 | }, |
| 737 | [1] = { |
| 738 | .name = "voice:red", |
| 739 | .max_brightness = 20, |
| 740 | .id = PMIC8058_ID_LED_0, |
| 741 | }, |
| 742 | [2] = { |
| 743 | .name = "wlan:green", |
| 744 | .max_brightness = 20, |
| 745 | .id = PMIC8058_ID_LED_2, |
| 746 | }, |
| 747 | }; |
| 748 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 749 | static struct pmic8058_leds_platform_data pm8058_surf_leds_data = { |
| 750 | .num_leds = ARRAY_SIZE(pmic8058_surf_leds), |
| 751 | .leds = pmic8058_surf_leds, |
| 752 | }; |
| 753 | |
| 754 | static struct pmic8058_led pmic8058_fluid_leds[] = { |
| 755 | [0] = { |
| 756 | .name = "keyboard-backlight", |
| 757 | .max_brightness = 15, |
| 758 | .id = PMIC8058_ID_LED_KB_LIGHT, |
| 759 | }, |
| 760 | [1] = { |
| 761 | .name = "flash:led_0", |
| 762 | .max_brightness = 15, |
| 763 | .id = PMIC8058_ID_FLASH_LED_0, |
| 764 | }, |
| 765 | [2] = { |
| 766 | .name = "flash:led_1", |
| 767 | .max_brightness = 15, |
| 768 | .id = PMIC8058_ID_FLASH_LED_1, |
| 769 | }, |
| 770 | }; |
| 771 | |
| 772 | static struct pmic8058_leds_platform_data pm8058_fluid_leds_data = { |
| 773 | .num_leds = ARRAY_SIZE(pmic8058_fluid_leds), |
| 774 | .leds = pmic8058_fluid_leds, |
| 775 | }; |
| 776 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 777 | static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata = { |
| 778 | .irq_base = PMIC8058_IRQ_BASE, |
| 779 | .devirq = MSM_GPIO_TO_INT(PMIC_GPIO_INT), |
| 780 | .irq_trigger_flag = IRQF_TRIGGER_LOW, |
| 781 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 782 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 783 | static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata = { |
| 784 | .gpio_base = PM8058_GPIO_PM_TO_SYS(0), |
| 785 | }; |
| 786 | |
| 787 | static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata = { |
| 788 | .mpp_base = PM8058_MPP_PM_TO_SYS(0), |
| 789 | }; |
| 790 | |
| 791 | static struct pm8058_platform_data pm8058_7x30_data = { |
| 792 | .irq_pdata = &pm8xxx_irq_pdata, |
| 793 | .gpio_pdata = &pm8xxx_gpio_pdata, |
| 794 | .mpp_pdata = &pm8xxx_mpp_pdata, |
| 795 | .pwm_pdata = &pm8058_pwm_data, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 796 | }; |
| 797 | |
Anirudh Ghayal | 9d9cdc2 | 2011-10-10 17:17:07 +0530 | [diff] [blame] | 798 | #ifdef CONFIG_MSM_SSBI |
| 799 | static struct msm_ssbi_platform_data msm7x30_ssbi_pm8058_pdata = { |
| 800 | .controller_type = MSM_SBI_CTRL_SSBI2, |
| 801 | .slave = { |
| 802 | .name = "pm8058-core", |
| 803 | .platform_data = &pm8058_7x30_data, |
| 804 | }, |
| 805 | }; |
| 806 | #endif |
| 807 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 808 | static struct i2c_board_info cy8info[] __initdata = { |
| 809 | { |
| 810 | I2C_BOARD_INFO(CY_I2C_NAME, 0x24), |
| 811 | .platform_data = &cyttsp_data, |
| 812 | #ifndef CY_USE_TIMER |
| 813 | .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ), |
| 814 | #endif /* CY_USE_TIMER */ |
| 815 | }, |
| 816 | }; |
| 817 | |
| 818 | static struct i2c_board_info msm_camera_boardinfo[] __initdata = { |
| 819 | #ifdef CONFIG_MT9D112 |
| 820 | { |
| 821 | I2C_BOARD_INFO("mt9d112", 0x78 >> 1), |
Dima Zavin | ba5499e | 2011-01-10 11:00:30 -0800 | [diff] [blame] | 822 | }, |
| 823 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 824 | #ifdef CONFIG_WEBCAM_OV9726 |
| 825 | { |
| 826 | I2C_BOARD_INFO("ov9726", 0x10), |
| 827 | }, |
| 828 | #endif |
| 829 | #ifdef CONFIG_S5K3E2FX |
| 830 | { |
| 831 | I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1), |
| 832 | }, |
| 833 | #endif |
| 834 | #ifdef CONFIG_MT9P012 |
| 835 | { |
| 836 | I2C_BOARD_INFO("mt9p012", 0x6C >> 1), |
| 837 | }, |
| 838 | #endif |
| 839 | #ifdef CONFIG_VX6953 |
| 840 | { |
| 841 | I2C_BOARD_INFO("vx6953", 0x20), |
| 842 | }, |
| 843 | #endif |
| 844 | #ifdef CONFIG_MT9E013 |
| 845 | { |
| 846 | I2C_BOARD_INFO("mt9e013", 0x6C >> 2), |
| 847 | }, |
| 848 | #endif |
| 849 | #ifdef CONFIG_SN12M0PZ |
| 850 | { |
| 851 | I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1), |
| 852 | }, |
| 853 | #endif |
| 854 | #if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013) |
| 855 | { |
| 856 | I2C_BOARD_INFO("mt9t013", 0x6C), |
| 857 | }, |
| 858 | #endif |
| 859 | |
Dima Zavin | ba5499e | 2011-01-10 11:00:30 -0800 | [diff] [blame] | 860 | }; |
| 861 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 862 | #ifdef CONFIG_MSM_CAMERA |
| 863 | #define CAM_STNDBY 143 |
| 864 | static uint32_t camera_off_vcm_gpio_table[] = { |
| 865 | GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */ |
| 866 | }; |
| 867 | |
| 868 | static uint32_t camera_off_gpio_table[] = { |
| 869 | /* parallel CAMERA interfaces */ |
| 870 | GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */ |
| 871 | GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */ |
| 872 | GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */ |
| 873 | GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */ |
| 874 | GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */ |
| 875 | GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */ |
| 876 | GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */ |
| 877 | GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */ |
| 878 | GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */ |
| 879 | GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */ |
| 880 | GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */ |
| 881 | GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */ |
| 882 | GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */ |
| 883 | GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */ |
| 884 | GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */ |
| 885 | }; |
| 886 | |
| 887 | static uint32_t camera_on_vcm_gpio_table[] = { |
| 888 | GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */ |
| 889 | }; |
| 890 | |
| 891 | static uint32_t camera_on_gpio_table[] = { |
| 892 | /* parallel CAMERA interfaces */ |
| 893 | GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */ |
| 894 | GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */ |
| 895 | GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */ |
| 896 | GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */ |
| 897 | GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */ |
| 898 | GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */ |
| 899 | GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */ |
| 900 | GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */ |
| 901 | GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */ |
| 902 | GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */ |
| 903 | GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */ |
| 904 | GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */ |
| 905 | GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */ |
| 906 | GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */ |
| 907 | GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */ |
| 908 | }; |
| 909 | |
| 910 | static uint32_t camera_off_gpio_fluid_table[] = { |
| 911 | /* FLUID: CAM_VGA_RST_N */ |
| 912 | GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 913 | /* FLUID: CAMIF_STANDBY */ |
| 914 | GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA) |
| 915 | }; |
| 916 | |
| 917 | static uint32_t camera_on_gpio_fluid_table[] = { |
| 918 | /* FLUID: CAM_VGA_RST_N */ |
| 919 | GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 920 | /* FLUID: CAMIF_STANDBY */ |
| 921 | GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA) |
| 922 | }; |
| 923 | |
| 924 | static void config_gpio_table(uint32_t *table, int len) |
| 925 | { |
| 926 | int n, rc; |
| 927 | for (n = 0; n < len; n++) { |
| 928 | rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE); |
| 929 | if (rc) { |
| 930 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 931 | __func__, table[n], rc); |
| 932 | break; |
| 933 | } |
| 934 | } |
| 935 | } |
| 936 | static int config_camera_on_gpios(void) |
| 937 | { |
| 938 | config_gpio_table(camera_on_gpio_table, |
| 939 | ARRAY_SIZE(camera_on_gpio_table)); |
| 940 | |
| 941 | if (adie_get_detected_codec_type() != TIMPANI_ID) |
| 942 | /* GPIO1 is shared also used in Timpani RF card so |
| 943 | only configure it for non-Timpani RF card */ |
| 944 | config_gpio_table(camera_on_vcm_gpio_table, |
| 945 | ARRAY_SIZE(camera_on_vcm_gpio_table)); |
| 946 | |
| 947 | if (machine_is_msm7x30_fluid()) { |
| 948 | config_gpio_table(camera_on_gpio_fluid_table, |
| 949 | ARRAY_SIZE(camera_on_gpio_fluid_table)); |
| 950 | /* FLUID: turn on 5V booster */ |
| 951 | gpio_set_value( |
| 952 | PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1); |
| 953 | /* FLUID: drive high to put secondary sensor to STANDBY */ |
| 954 | gpio_set_value(CAM_STNDBY, 1); |
| 955 | } |
| 956 | return 0; |
| 957 | } |
| 958 | |
| 959 | static void config_camera_off_gpios(void) |
| 960 | { |
| 961 | config_gpio_table(camera_off_gpio_table, |
| 962 | ARRAY_SIZE(camera_off_gpio_table)); |
| 963 | |
| 964 | if (adie_get_detected_codec_type() != TIMPANI_ID) |
| 965 | /* GPIO1 is shared also used in Timpani RF card so |
| 966 | only configure it for non-Timpani RF card */ |
| 967 | config_gpio_table(camera_off_vcm_gpio_table, |
| 968 | ARRAY_SIZE(camera_off_vcm_gpio_table)); |
| 969 | |
| 970 | if (machine_is_msm7x30_fluid()) { |
| 971 | config_gpio_table(camera_off_gpio_fluid_table, |
| 972 | ARRAY_SIZE(camera_off_gpio_fluid_table)); |
| 973 | /* FLUID: turn off 5V booster */ |
| 974 | gpio_set_value( |
| 975 | PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0); |
| 976 | } |
| 977 | } |
| 978 | |
| 979 | struct resource msm_camera_resources[] = { |
| 980 | { |
| 981 | .start = 0xA6000000, |
| 982 | .end = 0xA6000000 + SZ_1M - 1, |
| 983 | .flags = IORESOURCE_MEM, |
| 984 | }, |
| 985 | { |
| 986 | .start = INT_VFE, |
| 987 | .end = INT_VFE, |
| 988 | .flags = IORESOURCE_IRQ, |
| 989 | }, |
| 990 | { |
| 991 | .flags = IORESOURCE_DMA, |
| 992 | } |
| 993 | }; |
| 994 | |
| 995 | struct msm_camera_device_platform_data msm_camera_device_data = { |
| 996 | .camera_gpio_on = config_camera_on_gpios, |
| 997 | .camera_gpio_off = config_camera_off_gpios, |
| 998 | .ioext.camifpadphy = 0xAB000000, |
| 999 | .ioext.camifpadsz = 0x00000400, |
| 1000 | .ioext.csiphy = 0xA6100000, |
| 1001 | .ioext.csisz = 0x00000400, |
| 1002 | .ioext.csiirq = INT_CSI, |
| 1003 | .ioclk.mclk_clk_rate = 24000000, |
| 1004 | .ioclk.vfe_clk_rate = 147456000, |
| 1005 | }; |
| 1006 | |
| 1007 | static struct msm_camera_sensor_flash_src msm_flash_src_pwm = { |
| 1008 | .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM, |
| 1009 | ._fsrc.pwm_src.freq = 1000, |
| 1010 | ._fsrc.pwm_src.max_load = 300, |
| 1011 | ._fsrc.pwm_src.low_load = 30, |
| 1012 | ._fsrc.pwm_src.high_load = 100, |
| 1013 | ._fsrc.pwm_src.channel = 7, |
| 1014 | }; |
| 1015 | |
| 1016 | #ifdef CONFIG_MT9D112 |
| 1017 | static struct msm_camera_sensor_flash_data flash_mt9d112 = { |
| 1018 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1019 | .flash_src = &msm_flash_src_pwm |
| 1020 | }; |
| 1021 | |
| 1022 | static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = { |
| 1023 | .sensor_name = "mt9d112", |
| 1024 | .sensor_reset = 0, |
| 1025 | .sensor_pwd = 85, |
| 1026 | .vcm_pwd = 1, |
| 1027 | .vcm_enable = 0, |
| 1028 | .pdata = &msm_camera_device_data, |
| 1029 | .resource = msm_camera_resources, |
| 1030 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1031 | .flash_data = &flash_mt9d112, |
| 1032 | .csi_if = 0 |
| 1033 | }; |
| 1034 | |
| 1035 | static struct platform_device msm_camera_sensor_mt9d112 = { |
| 1036 | .name = "msm_camera_mt9d112", |
| 1037 | .dev = { |
| 1038 | .platform_data = &msm_camera_sensor_mt9d112_data, |
| 1039 | }, |
| 1040 | }; |
| 1041 | #endif |
| 1042 | |
| 1043 | #ifdef CONFIG_WEBCAM_OV9726 |
| 1044 | |
| 1045 | static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = { |
| 1046 | .mount_angle = 90 |
| 1047 | }; |
| 1048 | |
| 1049 | static struct msm_camera_sensor_flash_data flash_ov9726 = { |
| 1050 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1051 | .flash_src = &msm_flash_src_pwm |
| 1052 | }; |
| 1053 | static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = { |
| 1054 | .sensor_name = "ov9726", |
| 1055 | .sensor_reset = 0, |
| 1056 | .sensor_pwd = 85, |
| 1057 | .vcm_pwd = 1, |
| 1058 | .vcm_enable = 0, |
| 1059 | .pdata = &msm_camera_device_data, |
| 1060 | .resource = msm_camera_resources, |
| 1061 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1062 | .flash_data = &flash_ov9726, |
| 1063 | .sensor_platform_info = &ov9726_sensor_7630_info, |
| 1064 | .csi_if = 1 |
| 1065 | }; |
| 1066 | struct platform_device msm_camera_sensor_ov9726 = { |
| 1067 | .name = "msm_camera_ov9726", |
| 1068 | .dev = { |
| 1069 | .platform_data = &msm_camera_sensor_ov9726_data, |
| 1070 | }, |
| 1071 | }; |
| 1072 | #endif |
| 1073 | |
| 1074 | #ifdef CONFIG_S5K3E2FX |
| 1075 | static struct msm_camera_sensor_flash_data flash_s5k3e2fx = { |
| 1076 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1077 | .flash_src = &msm_flash_src_pwm, |
| 1078 | }; |
| 1079 | |
| 1080 | static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = { |
| 1081 | .sensor_name = "s5k3e2fx", |
| 1082 | .sensor_reset = 0, |
| 1083 | .sensor_pwd = 85, |
| 1084 | .vcm_pwd = 1, |
| 1085 | .vcm_enable = 0, |
| 1086 | .pdata = &msm_camera_device_data, |
| 1087 | .resource = msm_camera_resources, |
| 1088 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1089 | .flash_data = &flash_s5k3e2fx, |
| 1090 | .csi_if = 0 |
| 1091 | }; |
| 1092 | |
| 1093 | static struct platform_device msm_camera_sensor_s5k3e2fx = { |
| 1094 | .name = "msm_camera_s5k3e2fx", |
| 1095 | .dev = { |
| 1096 | .platform_data = &msm_camera_sensor_s5k3e2fx_data, |
| 1097 | }, |
| 1098 | }; |
| 1099 | #endif |
| 1100 | |
| 1101 | #ifdef CONFIG_MT9P012 |
| 1102 | static struct msm_camera_sensor_flash_data flash_mt9p012 = { |
| 1103 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1104 | .flash_src = &msm_flash_src_pwm |
| 1105 | }; |
| 1106 | |
| 1107 | static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = { |
| 1108 | .sensor_name = "mt9p012", |
| 1109 | .sensor_reset = 0, |
| 1110 | .sensor_pwd = 85, |
| 1111 | .vcm_pwd = 1, |
| 1112 | .vcm_enable = 1, |
| 1113 | .pdata = &msm_camera_device_data, |
| 1114 | .resource = msm_camera_resources, |
| 1115 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1116 | .flash_data = &flash_mt9p012, |
| 1117 | .csi_if = 0 |
| 1118 | }; |
| 1119 | |
| 1120 | static struct platform_device msm_camera_sensor_mt9p012 = { |
| 1121 | .name = "msm_camera_mt9p012", |
| 1122 | .dev = { |
| 1123 | .platform_data = &msm_camera_sensor_mt9p012_data, |
| 1124 | }, |
| 1125 | }; |
| 1126 | #endif |
| 1127 | |
| 1128 | #ifdef CONFIG_MT9E013 |
| 1129 | static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = { |
| 1130 | .mount_angle = 0 |
| 1131 | }; |
| 1132 | |
| 1133 | static struct msm_camera_sensor_flash_data flash_mt9e013 = { |
| 1134 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1135 | .flash_src = &msm_flash_src_pwm |
| 1136 | }; |
| 1137 | |
| 1138 | static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = { |
| 1139 | .sensor_name = "mt9e013", |
| 1140 | .sensor_reset = 0, |
| 1141 | .sensor_pwd = 85, |
| 1142 | .vcm_pwd = 1, |
| 1143 | .vcm_enable = 1, |
| 1144 | .pdata = &msm_camera_device_data, |
| 1145 | .resource = msm_camera_resources, |
| 1146 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1147 | .flash_data = &flash_mt9e013, |
| 1148 | .sensor_platform_info = &mt9e013_sensor_7630_info, |
| 1149 | .csi_if = 1 |
| 1150 | }; |
| 1151 | |
| 1152 | static struct platform_device msm_camera_sensor_mt9e013 = { |
| 1153 | .name = "msm_camera_mt9e013", |
| 1154 | .dev = { |
| 1155 | .platform_data = &msm_camera_sensor_mt9e013_data, |
| 1156 | }, |
| 1157 | }; |
| 1158 | #endif |
| 1159 | |
| 1160 | #ifdef CONFIG_VX6953 |
Jilai Wang | 971f97f | 2011-07-13 14:25:25 -0400 | [diff] [blame] | 1161 | static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = { |
| 1162 | .mount_angle = 0 |
| 1163 | }; |
| 1164 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1165 | static struct msm_camera_sensor_flash_data flash_vx6953 = { |
| 1166 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1167 | .flash_src = &msm_flash_src_pwm |
| 1168 | }; |
| 1169 | static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = { |
| 1170 | .sensor_name = "vx6953", |
| 1171 | .sensor_reset = 0, |
| 1172 | .sensor_pwd = 85, |
| 1173 | .vcm_pwd = 1, |
| 1174 | .vcm_enable = 0, |
| 1175 | .pdata = &msm_camera_device_data, |
| 1176 | .resource = msm_camera_resources, |
| 1177 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
Jilai Wang | 971f97f | 2011-07-13 14:25:25 -0400 | [diff] [blame] | 1178 | .sensor_platform_info = &vx6953_sensor_7630_info, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1179 | .flash_data = &flash_vx6953, |
| 1180 | .csi_if = 1 |
| 1181 | }; |
| 1182 | static struct platform_device msm_camera_sensor_vx6953 = { |
| 1183 | .name = "msm_camera_vx6953", |
| 1184 | .dev = { |
| 1185 | .platform_data = &msm_camera_sensor_vx6953_data, |
| 1186 | }, |
| 1187 | }; |
| 1188 | #endif |
| 1189 | |
| 1190 | #ifdef CONFIG_SN12M0PZ |
| 1191 | static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = { |
| 1192 | .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER, |
| 1193 | ._fsrc.current_driver_src.low_current = 210, |
| 1194 | ._fsrc.current_driver_src.high_current = 700, |
| 1195 | ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data, |
| 1196 | }; |
| 1197 | |
| 1198 | static struct msm_camera_sensor_flash_data flash_sn12m0pz = { |
| 1199 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1200 | .flash_src = &msm_flash_src_current_driver |
| 1201 | }; |
| 1202 | static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = { |
| 1203 | .sensor_name = "sn12m0pz", |
| 1204 | .sensor_reset = 0, |
| 1205 | .sensor_pwd = 85, |
| 1206 | .vcm_pwd = 1, |
| 1207 | .vcm_enable = 1, |
| 1208 | .pdata = &msm_camera_device_data, |
| 1209 | .flash_data = &flash_sn12m0pz, |
| 1210 | .resource = msm_camera_resources, |
| 1211 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1212 | .csi_if = 0 |
| 1213 | }; |
| 1214 | |
| 1215 | static struct platform_device msm_camera_sensor_sn12m0pz = { |
| 1216 | .name = "msm_camera_sn12m0pz", |
| 1217 | .dev = { |
| 1218 | .platform_data = &msm_camera_sensor_sn12m0pz_data, |
| 1219 | }, |
| 1220 | }; |
| 1221 | #endif |
| 1222 | |
| 1223 | #ifdef CONFIG_MT9T013 |
| 1224 | static struct msm_camera_sensor_flash_data flash_mt9t013 = { |
| 1225 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1226 | .flash_src = &msm_flash_src_pwm |
| 1227 | }; |
| 1228 | |
| 1229 | static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = { |
| 1230 | .sensor_name = "mt9t013", |
| 1231 | .sensor_reset = 0, |
| 1232 | .sensor_pwd = 85, |
| 1233 | .vcm_pwd = 1, |
| 1234 | .vcm_enable = 0, |
| 1235 | .pdata = &msm_camera_device_data, |
| 1236 | .resource = msm_camera_resources, |
| 1237 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1238 | .flash_data = &flash_mt9t013, |
| 1239 | .csi_if = 1 |
| 1240 | }; |
| 1241 | |
| 1242 | static struct platform_device msm_camera_sensor_mt9t013 = { |
| 1243 | .name = "msm_camera_mt9t013", |
| 1244 | .dev = { |
| 1245 | .platform_data = &msm_camera_sensor_mt9t013_data, |
| 1246 | }, |
| 1247 | }; |
| 1248 | #endif |
| 1249 | |
| 1250 | #ifdef CONFIG_MSM_GEMINI |
| 1251 | static struct resource msm_gemini_resources[] = { |
| 1252 | { |
| 1253 | .start = 0xA3A00000, |
| 1254 | .end = 0xA3A00000 + 0x0150 - 1, |
| 1255 | .flags = IORESOURCE_MEM, |
| 1256 | }, |
| 1257 | { |
| 1258 | .start = INT_JPEG, |
| 1259 | .end = INT_JPEG, |
| 1260 | .flags = IORESOURCE_IRQ, |
| 1261 | }, |
| 1262 | }; |
| 1263 | |
| 1264 | static struct platform_device msm_gemini_device = { |
| 1265 | .name = "msm_gemini", |
| 1266 | .resource = msm_gemini_resources, |
| 1267 | .num_resources = ARRAY_SIZE(msm_gemini_resources), |
| 1268 | }; |
| 1269 | #endif |
| 1270 | |
| 1271 | #ifdef CONFIG_MSM_VPE |
| 1272 | static struct resource msm_vpe_resources[] = { |
| 1273 | { |
| 1274 | .start = 0xAD200000, |
| 1275 | .end = 0xAD200000 + SZ_1M - 1, |
| 1276 | .flags = IORESOURCE_MEM, |
| 1277 | }, |
| 1278 | { |
| 1279 | .start = INT_VPE, |
| 1280 | .end = INT_VPE, |
| 1281 | .flags = IORESOURCE_IRQ, |
| 1282 | }, |
| 1283 | }; |
| 1284 | |
| 1285 | static struct platform_device msm_vpe_device = { |
| 1286 | .name = "msm_vpe", |
| 1287 | .id = 0, |
| 1288 | .num_resources = ARRAY_SIZE(msm_vpe_resources), |
| 1289 | .resource = msm_vpe_resources, |
| 1290 | }; |
| 1291 | #endif |
| 1292 | |
| 1293 | #endif /*CONFIG_MSM_CAMERA*/ |
| 1294 | |
| 1295 | #ifdef CONFIG_MSM7KV2_AUDIO |
| 1296 | static uint32_t audio_pamp_gpio_config = |
| 1297 | GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA); |
| 1298 | |
| 1299 | static uint32_t audio_fluid_icodec_tx_config = |
| 1300 | GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA); |
| 1301 | |
| 1302 | static int __init snddev_poweramp_gpio_init(void) |
| 1303 | { |
| 1304 | int rc; |
| 1305 | |
| 1306 | pr_info("snddev_poweramp_gpio_init \n"); |
| 1307 | rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE); |
| 1308 | if (rc) { |
| 1309 | printk(KERN_ERR |
| 1310 | "%s: gpio_tlmm_config(%#x)=%d\n", |
| 1311 | __func__, audio_pamp_gpio_config, rc); |
| 1312 | } |
| 1313 | return rc; |
| 1314 | } |
| 1315 | |
| 1316 | void msm_snddev_tx_route_config(void) |
| 1317 | { |
| 1318 | int rc; |
| 1319 | |
| 1320 | pr_debug("%s()\n", __func__); |
| 1321 | |
| 1322 | if (machine_is_msm7x30_fluid()) { |
| 1323 | rc = gpio_tlmm_config(audio_fluid_icodec_tx_config, |
| 1324 | GPIO_CFG_ENABLE); |
| 1325 | if (rc) { |
| 1326 | printk(KERN_ERR |
| 1327 | "%s: gpio_tlmm_config(%#x)=%d\n", |
| 1328 | __func__, audio_fluid_icodec_tx_config, rc); |
| 1329 | } else |
| 1330 | gpio_set_value(85, 0); |
| 1331 | } |
| 1332 | } |
| 1333 | |
| 1334 | void msm_snddev_tx_route_deconfig(void) |
| 1335 | { |
| 1336 | int rc; |
| 1337 | |
| 1338 | pr_debug("%s()\n", __func__); |
| 1339 | |
| 1340 | if (machine_is_msm7x30_fluid()) { |
| 1341 | rc = gpio_tlmm_config(audio_fluid_icodec_tx_config, |
| 1342 | GPIO_CFG_DISABLE); |
| 1343 | if (rc) { |
| 1344 | printk(KERN_ERR |
| 1345 | "%s: gpio_tlmm_config(%#x)=%d\n", |
| 1346 | __func__, audio_fluid_icodec_tx_config, rc); |
| 1347 | } |
| 1348 | } |
| 1349 | } |
| 1350 | |
| 1351 | void msm_snddev_poweramp_on(void) |
| 1352 | { |
| 1353 | gpio_set_value(82, 1); /* enable spkr poweramp */ |
| 1354 | pr_info("%s: power on amplifier\n", __func__); |
| 1355 | } |
| 1356 | |
| 1357 | void msm_snddev_poweramp_off(void) |
| 1358 | { |
| 1359 | gpio_set_value(82, 0); /* disable spkr poweramp */ |
| 1360 | pr_info("%s: power off amplifier\n", __func__); |
| 1361 | } |
| 1362 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1363 | static struct regulator_bulk_data snddev_regs[] = { |
| 1364 | { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 }, |
| 1365 | { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 }, |
| 1366 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1367 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1368 | static int __init snddev_hsed_voltage_init(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1369 | { |
| 1370 | int rc; |
| 1371 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1372 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1373 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1374 | if (rc) { |
| 1375 | pr_err("%s: could not get regulators: %d\n", __func__, rc); |
| 1376 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1377 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1378 | |
| 1379 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs); |
| 1380 | |
| 1381 | if (rc) { |
| 1382 | pr_err("%s: could not set regulator voltages: %d\n", |
| 1383 | __func__, rc); |
| 1384 | goto regs_free; |
| 1385 | } |
| 1386 | |
| 1387 | return 0; |
| 1388 | |
| 1389 | regs_free: |
| 1390 | regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs); |
| 1391 | out: |
| 1392 | return rc; |
| 1393 | } |
| 1394 | |
| 1395 | |
| 1396 | void msm_snddev_hsed_voltage_on(void) |
| 1397 | { |
| 1398 | int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs); |
| 1399 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1400 | if (rc) |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1401 | pr_err("%s: could not enable regulators: %d\n", __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1402 | } |
| 1403 | |
| 1404 | void msm_snddev_hsed_voltage_off(void) |
| 1405 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1406 | int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1407 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1408 | if (rc) { |
| 1409 | pr_err("%s: could not disable regulators: %d\n", __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1410 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1411 | } |
| 1412 | |
| 1413 | static unsigned aux_pcm_gpio_on[] = { |
| 1414 | GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */ |
| 1415 | GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */ |
| 1416 | GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */ |
| 1417 | GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */ |
| 1418 | }; |
| 1419 | |
| 1420 | static int __init aux_pcm_gpio_init(void) |
| 1421 | { |
| 1422 | int pin, rc; |
| 1423 | |
| 1424 | pr_info("aux_pcm_gpio_init \n"); |
| 1425 | for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) { |
| 1426 | rc = gpio_tlmm_config(aux_pcm_gpio_on[pin], |
| 1427 | GPIO_CFG_ENABLE); |
| 1428 | if (rc) { |
| 1429 | printk(KERN_ERR |
| 1430 | "%s: gpio_tlmm_config(%#x)=%d\n", |
| 1431 | __func__, aux_pcm_gpio_on[pin], rc); |
| 1432 | } |
| 1433 | } |
| 1434 | return rc; |
| 1435 | } |
| 1436 | |
| 1437 | static struct msm_gpio mi2s_clk_gpios[] = { |
| 1438 | { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1439 | "MI2S_SCLK"}, |
| 1440 | { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1441 | "MI2S_WS"}, |
| 1442 | { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1443 | "MI2S_MCLK_A"}, |
| 1444 | }; |
| 1445 | |
| 1446 | static struct msm_gpio mi2s_rx_data_lines_gpios[] = { |
| 1447 | { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1448 | "MI2S_DATA_SD0_A"}, |
| 1449 | { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1450 | "MI2S_DATA_SD1_A"}, |
| 1451 | { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1452 | "MI2S_DATA_SD2_A"}, |
| 1453 | { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1454 | "MI2S_DATA_SD3"}, |
| 1455 | }; |
| 1456 | |
| 1457 | static struct msm_gpio mi2s_tx_data_lines_gpios[] = { |
| 1458 | { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1459 | "MI2S_DATA_SD3"}, |
| 1460 | }; |
| 1461 | |
| 1462 | int mi2s_config_clk_gpio(void) |
| 1463 | { |
| 1464 | int rc = 0; |
| 1465 | |
| 1466 | rc = msm_gpios_request_enable(mi2s_clk_gpios, |
| 1467 | ARRAY_SIZE(mi2s_clk_gpios)); |
| 1468 | if (rc) { |
| 1469 | pr_err("%s: enable mi2s clk gpios failed\n", |
| 1470 | __func__); |
| 1471 | return rc; |
| 1472 | } |
| 1473 | return 0; |
| 1474 | } |
| 1475 | |
| 1476 | int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask) |
| 1477 | { |
| 1478 | int i, rc = 0; |
| 1479 | sd_line_mask &= MI2S_SD_LINE_MASK; |
| 1480 | |
| 1481 | switch (direction) { |
| 1482 | case DIR_TX: |
| 1483 | msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1); |
| 1484 | break; |
| 1485 | case DIR_RX: |
| 1486 | i = 0; |
| 1487 | while (sd_line_mask) { |
| 1488 | if (sd_line_mask & 0x1) |
| 1489 | msm_gpios_disable_free( |
| 1490 | mi2s_rx_data_lines_gpios + i , 1); |
| 1491 | sd_line_mask = sd_line_mask >> 1; |
| 1492 | i++; |
| 1493 | } |
| 1494 | break; |
| 1495 | default: |
| 1496 | pr_err("%s: Invaild direction direction = %u\n", |
| 1497 | __func__, direction); |
| 1498 | rc = -EINVAL; |
| 1499 | break; |
| 1500 | } |
| 1501 | return rc; |
| 1502 | } |
| 1503 | |
| 1504 | int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask) |
| 1505 | { |
| 1506 | int i , rc = 0; |
| 1507 | u8 sd_config_done_mask = 0; |
| 1508 | |
| 1509 | sd_line_mask &= MI2S_SD_LINE_MASK; |
| 1510 | |
| 1511 | switch (direction) { |
| 1512 | case DIR_TX: |
| 1513 | if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) || |
| 1514 | (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) { |
| 1515 | pr_err("%s: can not use SD0 or SD1 or SD2 for TX" |
| 1516 | ".only can use SD3. sd_line_mask = 0x%x\n", |
| 1517 | __func__ , sd_line_mask); |
| 1518 | rc = -EINVAL; |
| 1519 | } else { |
| 1520 | rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios, |
| 1521 | 1); |
| 1522 | if (rc) |
| 1523 | pr_err("%s: enable mi2s gpios for TX failed\n", |
| 1524 | __func__); |
| 1525 | } |
| 1526 | break; |
| 1527 | case DIR_RX: |
| 1528 | i = 0; |
| 1529 | while (sd_line_mask && (rc == 0)) { |
| 1530 | if (sd_line_mask & 0x1) { |
| 1531 | rc = msm_gpios_request_enable( |
| 1532 | mi2s_rx_data_lines_gpios + i , 1); |
| 1533 | if (rc) { |
| 1534 | pr_err("%s: enable mi2s gpios for" |
| 1535 | "RX failed. SD line = %s\n", |
| 1536 | __func__, |
| 1537 | (mi2s_rx_data_lines_gpios + i)->label); |
| 1538 | mi2s_unconfig_data_gpio(DIR_RX, |
| 1539 | sd_config_done_mask); |
| 1540 | } else |
| 1541 | sd_config_done_mask |= (1 << i); |
| 1542 | } |
| 1543 | sd_line_mask = sd_line_mask >> 1; |
| 1544 | i++; |
| 1545 | } |
| 1546 | break; |
| 1547 | default: |
| 1548 | pr_err("%s: Invaild direction direction = %u\n", |
| 1549 | __func__, direction); |
| 1550 | rc = -EINVAL; |
| 1551 | break; |
| 1552 | } |
| 1553 | return rc; |
| 1554 | } |
| 1555 | |
| 1556 | int mi2s_unconfig_clk_gpio(void) |
| 1557 | { |
| 1558 | msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios)); |
| 1559 | return 0; |
| 1560 | } |
| 1561 | |
| 1562 | #endif /* CONFIG_MSM7KV2_AUDIO */ |
| 1563 | |
| 1564 | static int __init buses_init(void) |
| 1565 | { |
| 1566 | if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT, |
| 1567 | GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE)) |
| 1568 | pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n", |
| 1569 | __func__, PMIC_GPIO_INT); |
| 1570 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 1571 | if (machine_is_msm8x60_fluid()) |
| 1572 | pm8058_7x30_data.keypad_pdata = &fluid_keypad_data; |
| 1573 | else |
| 1574 | pm8058_7x30_data.keypad_pdata = &surf_keypad_data; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1575 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1576 | return 0; |
| 1577 | } |
| 1578 | |
| 1579 | #define TIMPANI_RESET_GPIO 1 |
| 1580 | |
| 1581 | struct bahama_config_register{ |
| 1582 | u8 reg; |
| 1583 | u8 value; |
| 1584 | u8 mask; |
| 1585 | }; |
| 1586 | |
| 1587 | enum version{ |
| 1588 | VER_1_0, |
| 1589 | VER_2_0, |
| 1590 | VER_UNSUPPORTED = 0xFF |
| 1591 | }; |
| 1592 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1593 | static struct regulator *vreg_marimba_1; |
| 1594 | static struct regulator *vreg_marimba_2; |
| 1595 | static struct regulator *vreg_bahama; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1596 | |
| 1597 | static struct msm_gpio timpani_reset_gpio_cfg[] = { |
| 1598 | { GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT, |
| 1599 | GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} }; |
| 1600 | |
| 1601 | static u8 read_bahama_ver(void) |
| 1602 | { |
| 1603 | int rc; |
| 1604 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA }; |
| 1605 | u8 bahama_version; |
| 1606 | |
| 1607 | rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F); |
| 1608 | if (rc < 0) { |
| 1609 | printk(KERN_ERR |
| 1610 | "%s: version read failed: %d\n", |
| 1611 | __func__, rc); |
| 1612 | return rc; |
| 1613 | } else { |
| 1614 | printk(KERN_INFO |
| 1615 | "%s: version read got: 0x%x\n", |
| 1616 | __func__, bahama_version); |
| 1617 | } |
| 1618 | |
| 1619 | switch (bahama_version) { |
| 1620 | case 0x08: /* varient of bahama v1 */ |
| 1621 | case 0x10: |
| 1622 | case 0x00: |
| 1623 | return VER_1_0; |
| 1624 | case 0x09: /* variant of bahama v2 */ |
| 1625 | return VER_2_0; |
| 1626 | default: |
| 1627 | return VER_UNSUPPORTED; |
| 1628 | } |
| 1629 | } |
| 1630 | |
| 1631 | static int config_timpani_reset(void) |
| 1632 | { |
| 1633 | int rc; |
| 1634 | |
| 1635 | rc = msm_gpios_request_enable(timpani_reset_gpio_cfg, |
| 1636 | ARRAY_SIZE(timpani_reset_gpio_cfg)); |
| 1637 | if (rc < 0) { |
| 1638 | printk(KERN_ERR |
| 1639 | "%s: msm_gpios_request_enable failed (%d)\n", |
| 1640 | __func__, rc); |
| 1641 | } |
| 1642 | return rc; |
| 1643 | } |
| 1644 | |
| 1645 | static unsigned int msm_timpani_setup_power(void) |
| 1646 | { |
| 1647 | int rc; |
| 1648 | |
| 1649 | rc = config_timpani_reset(); |
| 1650 | if (rc < 0) |
| 1651 | goto out; |
| 1652 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1653 | rc = regulator_enable(vreg_marimba_1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1654 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1655 | pr_err("%s: regulator_enable failed (%d)\n", __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1656 | goto out; |
| 1657 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1658 | |
| 1659 | rc = regulator_enable(vreg_marimba_2); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1660 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1661 | pr_err("%s: regulator_enable failed (%d)\n", __func__, rc); |
| 1662 | goto disable_marimba_1; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1663 | } |
| 1664 | |
| 1665 | rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1); |
| 1666 | if (rc < 0) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1667 | pr_err("%s: gpio_direction_output failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1668 | __func__, rc); |
| 1669 | msm_gpios_free(timpani_reset_gpio_cfg, |
| 1670 | ARRAY_SIZE(timpani_reset_gpio_cfg)); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1671 | goto disable_marimba_2; |
| 1672 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1673 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1674 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1675 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1676 | disable_marimba_2: |
| 1677 | regulator_disable(vreg_marimba_2); |
| 1678 | disable_marimba_1: |
| 1679 | regulator_disable(vreg_marimba_1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1680 | out: |
| 1681 | return rc; |
| 1682 | }; |
| 1683 | |
| 1684 | static void msm_timpani_shutdown_power(void) |
| 1685 | { |
| 1686 | int rc; |
| 1687 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1688 | rc = regulator_disable(vreg_marimba_2); |
| 1689 | if (rc) |
| 1690 | pr_err("%s: regulator_disable failed (%d)\n", __func__, rc); |
| 1691 | |
| 1692 | rc = regulator_disable(vreg_marimba_1); |
| 1693 | if (rc) |
| 1694 | pr_err("%s: regulator_disable failed (%d)\n", __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1695 | |
| 1696 | rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1697 | if (rc < 0) |
| 1698 | pr_err("%s: gpio_direction_output failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1699 | __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1700 | |
| 1701 | msm_gpios_free(timpani_reset_gpio_cfg, |
| 1702 | ARRAY_SIZE(timpani_reset_gpio_cfg)); |
| 1703 | }; |
| 1704 | |
| 1705 | static unsigned int msm_bahama_core_config(int type) |
| 1706 | { |
| 1707 | int rc = 0; |
| 1708 | |
| 1709 | if (type == BAHAMA_ID) { |
| 1710 | |
| 1711 | int i; |
| 1712 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA }; |
| 1713 | |
| 1714 | const struct bahama_config_register v20_init[] = { |
| 1715 | /* reg, value, mask */ |
| 1716 | { 0xF4, 0x84, 0xFF }, /* AREG */ |
| 1717 | { 0xF0, 0x04, 0xFF } /* DREG */ |
| 1718 | }; |
| 1719 | |
| 1720 | if (read_bahama_ver() == VER_2_0) { |
| 1721 | for (i = 0; i < ARRAY_SIZE(v20_init); i++) { |
| 1722 | u8 value = v20_init[i].value; |
| 1723 | rc = marimba_write_bit_mask(&config, |
| 1724 | v20_init[i].reg, |
| 1725 | &value, |
| 1726 | sizeof(v20_init[i].value), |
| 1727 | v20_init[i].mask); |
| 1728 | if (rc < 0) { |
| 1729 | printk(KERN_ERR |
| 1730 | "%s: reg %d write failed: %d\n", |
| 1731 | __func__, v20_init[i].reg, rc); |
| 1732 | return rc; |
| 1733 | } |
| 1734 | printk(KERN_INFO "%s: reg 0x%02x value 0x%02x" |
| 1735 | " mask 0x%02x\n", |
| 1736 | __func__, v20_init[i].reg, |
| 1737 | v20_init[i].value, v20_init[i].mask); |
| 1738 | } |
| 1739 | } |
| 1740 | } |
| 1741 | printk(KERN_INFO "core type: %d\n", type); |
| 1742 | |
| 1743 | return rc; |
| 1744 | } |
| 1745 | |
| 1746 | static unsigned int msm_bahama_setup_power(void) |
| 1747 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1748 | int rc = regulator_enable(vreg_bahama); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1749 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1750 | if (rc) |
| 1751 | pr_err("%s: regulator_enable failed (%d)\n", __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1752 | |
| 1753 | return rc; |
| 1754 | }; |
| 1755 | |
| 1756 | static unsigned int msm_bahama_shutdown_power(int value) |
| 1757 | { |
| 1758 | int rc = 0; |
| 1759 | |
| 1760 | if (value != BAHAMA_ID) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1761 | rc = regulator_disable(vreg_bahama); |
| 1762 | |
| 1763 | if (rc) |
| 1764 | pr_err("%s: regulator_disable failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1765 | __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1766 | } |
| 1767 | |
| 1768 | return rc; |
| 1769 | }; |
| 1770 | |
| 1771 | static struct msm_gpio marimba_svlte_config_clock[] = { |
| 1772 | { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1773 | "MARIMBA_SVLTE_CLOCK_ENABLE" }, |
| 1774 | }; |
| 1775 | |
| 1776 | static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba) |
| 1777 | { |
| 1778 | if (machine_is_msm8x55_svlte_surf() || |
| 1779 | machine_is_msm8x55_svlte_ffa()) { |
| 1780 | if (gpio_cfg_marimba) |
| 1781 | gpio_set_value(GPIO_PIN |
| 1782 | (marimba_svlte_config_clock->gpio_cfg), 1); |
| 1783 | else |
| 1784 | gpio_set_value(GPIO_PIN |
| 1785 | (marimba_svlte_config_clock->gpio_cfg), 0); |
| 1786 | } |
| 1787 | |
| 1788 | return 0; |
| 1789 | }; |
| 1790 | |
| 1791 | static unsigned int msm_marimba_setup_power(void) |
| 1792 | { |
| 1793 | int rc; |
| 1794 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1795 | rc = regulator_enable(vreg_marimba_1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1796 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1797 | pr_err("%s: regulator_enable failed (%d)\n", __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1798 | goto out; |
| 1799 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1800 | |
| 1801 | rc = regulator_enable(vreg_marimba_2); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1802 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1803 | pr_err("%s: regulator_enable failed (%d)\n", __func__, rc); |
| 1804 | goto disable_marimba_1; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1805 | } |
| 1806 | |
| 1807 | if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) { |
| 1808 | rc = msm_gpios_request_enable(marimba_svlte_config_clock, |
| 1809 | ARRAY_SIZE(marimba_svlte_config_clock)); |
| 1810 | if (rc < 0) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1811 | pr_err("%s: msm_gpios_request_enable failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1812 | __func__, rc); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1813 | goto disable_marimba_2; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1814 | } |
| 1815 | |
| 1816 | rc = gpio_direction_output(GPIO_PIN |
| 1817 | (marimba_svlte_config_clock->gpio_cfg), 0); |
| 1818 | if (rc < 0) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1819 | pr_err("%s: gpio_direction_output failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1820 | __func__, rc); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1821 | goto disable_marimba_2; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1822 | } |
| 1823 | } |
| 1824 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1825 | return 0; |
| 1826 | |
| 1827 | disable_marimba_2: |
| 1828 | regulator_disable(vreg_marimba_2); |
| 1829 | disable_marimba_1: |
| 1830 | regulator_disable(vreg_marimba_1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1831 | out: |
| 1832 | return rc; |
| 1833 | }; |
| 1834 | |
| 1835 | static void msm_marimba_shutdown_power(void) |
| 1836 | { |
| 1837 | int rc; |
| 1838 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1839 | rc = regulator_disable(vreg_marimba_2); |
| 1840 | if (rc) |
| 1841 | pr_err("%s: regulator_disable failed (%d)\n", __func__, rc); |
| 1842 | |
| 1843 | rc = regulator_disable(vreg_marimba_1); |
| 1844 | if (rc) |
| 1845 | pr_err("%s: regulator_disable failed (%d)\n", __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1846 | }; |
| 1847 | |
| 1848 | static int bahama_present(void) |
| 1849 | { |
| 1850 | int id; |
| 1851 | switch (id = adie_get_detected_connectivity_type()) { |
| 1852 | case BAHAMA_ID: |
| 1853 | return 1; |
| 1854 | |
| 1855 | case MARIMBA_ID: |
| 1856 | return 0; |
| 1857 | |
| 1858 | case TIMPANI_ID: |
| 1859 | default: |
| 1860 | printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n", |
| 1861 | __func__, id); |
| 1862 | return -ENODEV; |
| 1863 | } |
| 1864 | } |
| 1865 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1866 | struct regulator *fm_regulator; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1867 | static int fm_radio_setup(struct marimba_fm_platform_data *pdata) |
| 1868 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1869 | int rc, voltage; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1870 | uint32_t irqcfg; |
| 1871 | const char *id = "FMPW"; |
| 1872 | |
| 1873 | int bahama_not_marimba = bahama_present(); |
| 1874 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1875 | if (bahama_not_marimba < 0) { |
| 1876 | pr_warn("%s: bahama_present: %d\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1877 | __func__, bahama_not_marimba); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1878 | rc = -ENODEV; |
| 1879 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1880 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1881 | if (bahama_not_marimba) { |
| 1882 | fm_regulator = regulator_get(NULL, "s3"); |
| 1883 | voltage = 1800000; |
| 1884 | } else { |
| 1885 | fm_regulator = regulator_get(NULL, "s2"); |
| 1886 | voltage = 1300000; |
| 1887 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1888 | |
| 1889 | if (IS_ERR(fm_regulator)) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1890 | rc = PTR_ERR(fm_regulator); |
| 1891 | pr_err("%s: regulator_get failed (%d)\n", __func__, rc); |
| 1892 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1893 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1894 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1895 | rc = regulator_set_voltage(fm_regulator, voltage, voltage); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1896 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1897 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1898 | pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc); |
| 1899 | goto regulator_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1900 | } |
| 1901 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1902 | rc = regulator_enable(fm_regulator); |
| 1903 | |
| 1904 | if (rc) { |
| 1905 | pr_err("%s: regulator_enable failed (%d)\n", __func__, rc); |
| 1906 | goto regulator_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1907 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1908 | |
| 1909 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON); |
| 1910 | |
| 1911 | if (rc < 0) { |
| 1912 | pr_err("%s: clock vote failed (%d)\n", __func__, rc); |
| 1913 | goto regulator_disable; |
| 1914 | } |
| 1915 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1916 | /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case |
| 1917 | of svlte*/ |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1918 | if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1919 | rc = marimba_gpio_config(1); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1920 | if (rc < 0) { |
| 1921 | pr_err("%s: clock enable for svlte : %d\n", |
| 1922 | __func__, rc); |
| 1923 | goto clock_devote; |
| 1924 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1925 | } |
| 1926 | irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, |
| 1927 | GPIO_CFG_2MA); |
| 1928 | rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE); |
| 1929 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1930 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1931 | rc = -EIO; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1932 | goto gpio_deconfig; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1933 | |
| 1934 | } |
| 1935 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1936 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1937 | gpio_deconfig: |
| 1938 | if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) |
| 1939 | marimba_gpio_config(0); |
| 1940 | clock_devote: |
| 1941 | pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF); |
| 1942 | regulator_disable: |
| 1943 | regulator_disable(fm_regulator); |
| 1944 | regulator_free: |
| 1945 | regulator_put(fm_regulator); |
| 1946 | fm_regulator = NULL; |
| 1947 | out: |
| 1948 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1949 | }; |
| 1950 | |
| 1951 | static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata) |
| 1952 | { |
| 1953 | int rc; |
| 1954 | const char *id = "FMPW"; |
| 1955 | uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, |
| 1956 | GPIO_CFG_2MA); |
| 1957 | |
| 1958 | int bahama_not_marimba = bahama_present(); |
| 1959 | if (bahama_not_marimba == -1) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1960 | pr_warn("%s: bahama_present: %d\n", |
| 1961 | __func__, bahama_not_marimba); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1962 | return; |
| 1963 | } |
| 1964 | |
| 1965 | rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE); |
| 1966 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1967 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1968 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1969 | if (!IS_ERR_OR_NULL(fm_regulator)) { |
| 1970 | rc = regulator_disable(fm_regulator); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1971 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1972 | if (rc) |
| 1973 | pr_err("%s: return val: %d\n", __func__, rc); |
| 1974 | |
| 1975 | regulator_put(fm_regulator); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1976 | fm_regulator = NULL; |
| 1977 | } |
| 1978 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, |
| 1979 | PMAPP_CLOCK_VOTE_OFF); |
| 1980 | if (rc < 0) |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1981 | pr_err("%s: clock_vote return val: %d\n", __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1982 | |
| 1983 | /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case |
| 1984 | of svlte*/ |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1985 | if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1986 | rc = marimba_gpio_config(0); |
| 1987 | if (rc < 0) |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 1988 | pr_err("%s: clock disable for svlte : %d\n", |
| 1989 | __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1990 | } |
| 1991 | } |
| 1992 | |
| 1993 | static struct marimba_fm_platform_data marimba_fm_pdata = { |
| 1994 | .fm_setup = fm_radio_setup, |
| 1995 | .fm_shutdown = fm_radio_shutdown, |
| 1996 | .irq = MSM_GPIO_TO_INT(147), |
| 1997 | .vreg_s2 = NULL, |
| 1998 | .vreg_xo_out = NULL, |
| 1999 | .is_fm_soc_i2s_master = false, |
| 2000 | .config_i2s_gpio = NULL, |
| 2001 | }; |
| 2002 | |
| 2003 | |
| 2004 | /* Slave id address for FM/CDC/QMEMBIST |
| 2005 | * Values can be programmed using Marimba slave id 0 |
| 2006 | * should there be a conflict with other I2C devices |
| 2007 | * */ |
| 2008 | #define MARIMBA_SLAVE_ID_FM_ADDR 0x2A |
| 2009 | #define MARIMBA_SLAVE_ID_CDC_ADDR 0x77 |
| 2010 | #define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66 |
| 2011 | |
| 2012 | #define BAHAMA_SLAVE_ID_FM_ADDR 0x2A |
| 2013 | #define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B |
| 2014 | |
| 2015 | static const char *tsadc_id = "MADC"; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2016 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2017 | static struct regulator_bulk_data regs_tsadc_marimba[] = { |
| 2018 | { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 }, |
| 2019 | { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2020 | }; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2021 | |
| 2022 | static struct regulator_bulk_data regs_tsadc_timpani[] = { |
| 2023 | { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 }, |
| 2024 | { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 }, |
| 2025 | { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 }, |
| 2026 | }; |
| 2027 | |
| 2028 | static struct regulator_bulk_data *regs_tsadc; |
| 2029 | static int regs_tsadc_count; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2030 | |
| 2031 | static int marimba_tsadc_power(int vreg_on) |
| 2032 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2033 | int rc = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2034 | int tsadc_adie_type = adie_get_detected_codec_type(); |
| 2035 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2036 | switch (tsadc_adie_type) { |
| 2037 | case TIMPANI_ID: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2038 | rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1, |
| 2039 | vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF); |
| 2040 | if (rc) { |
| 2041 | pr_err("%s: unable to %svote for d1 clk\n", |
| 2042 | __func__, vreg_on ? "" : "de-"); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2043 | goto D1_vote_fail; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2044 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2045 | |
| 2046 | /* fall through */ |
| 2047 | case MARIMBA_ID: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2048 | rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO, |
| 2049 | vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF); |
| 2050 | if (rc) { |
| 2051 | pr_err("%s: unable to %svote for d1 clk\n", |
| 2052 | __func__, vreg_on ? "" : "de-"); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2053 | goto D0_vote_fail; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2054 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2055 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2056 | WARN_ON(regs_tsadc_count == 0); |
| 2057 | |
| 2058 | rc = vreg_on ? |
| 2059 | regulator_bulk_enable(regs_tsadc_count, regs_tsadc) : |
| 2060 | regulator_bulk_disable(regs_tsadc_count, regs_tsadc); |
| 2061 | |
| 2062 | if (rc) { |
| 2063 | pr_err("%s: regulator %sable failed: %d\n", |
| 2064 | __func__, vreg_on ? "en" : "dis", rc); |
| 2065 | goto regulator_switch_fail; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2066 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2067 | |
| 2068 | break; |
| 2069 | default: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2070 | pr_err("%s:Adie %d not supported\n", |
| 2071 | __func__, tsadc_adie_type); |
| 2072 | return -ENODEV; |
| 2073 | } |
| 2074 | |
| 2075 | msleep(5); /* ensure power is stable */ |
| 2076 | |
| 2077 | return 0; |
| 2078 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2079 | regulator_switch_fail: |
| 2080 | pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO, |
| 2081 | vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON); |
| 2082 | D0_vote_fail: |
| 2083 | if (tsadc_adie_type == TIMPANI_ID) |
| 2084 | pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1, |
| 2085 | vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON); |
| 2086 | D1_vote_fail: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2087 | return rc; |
| 2088 | } |
| 2089 | |
| 2090 | static int marimba_tsadc_init(void) |
| 2091 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2092 | int rc = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2093 | int tsadc_adie_type = adie_get_detected_codec_type(); |
| 2094 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2095 | switch (tsadc_adie_type) { |
| 2096 | case MARIMBA_ID: |
| 2097 | regs_tsadc = regs_tsadc_marimba; |
| 2098 | regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba); |
| 2099 | break; |
| 2100 | case TIMPANI_ID: |
| 2101 | regs_tsadc = regs_tsadc_timpani; |
| 2102 | regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani); |
| 2103 | break; |
| 2104 | default: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2105 | pr_err("%s:Adie %d not supported\n", |
| 2106 | __func__, tsadc_adie_type); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2107 | rc = -ENODEV; |
| 2108 | goto out; |
| 2109 | } |
| 2110 | |
| 2111 | rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc); |
| 2112 | if (rc) { |
| 2113 | pr_err("%s: could not get regulators: %d\n", |
| 2114 | __func__, rc); |
| 2115 | goto out; |
| 2116 | } |
| 2117 | |
| 2118 | rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc); |
| 2119 | if (rc) { |
| 2120 | pr_err("%s: could not set regulator voltages: %d\n", |
| 2121 | __func__, rc); |
| 2122 | goto vreg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2123 | } |
| 2124 | |
| 2125 | return 0; |
| 2126 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2127 | vreg_free: |
| 2128 | regulator_bulk_free(regs_tsadc_count, regs_tsadc); |
| 2129 | out: |
| 2130 | regs_tsadc = NULL; |
| 2131 | regs_tsadc_count = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2132 | return rc; |
| 2133 | } |
| 2134 | |
| 2135 | static int marimba_tsadc_exit(void) |
| 2136 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2137 | regulator_bulk_free(regs_tsadc_count, regs_tsadc); |
| 2138 | regs_tsadc_count = 0; |
| 2139 | regs_tsadc = NULL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2140 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2141 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2142 | } |
| 2143 | |
| 2144 | |
| 2145 | static struct msm_ts_platform_data msm_ts_data = { |
| 2146 | .min_x = 0, |
| 2147 | .max_x = 4096, |
| 2148 | .min_y = 0, |
| 2149 | .max_y = 4096, |
| 2150 | .min_press = 0, |
| 2151 | .max_press = 255, |
| 2152 | .inv_x = 4096, |
| 2153 | .inv_y = 4096, |
| 2154 | .can_wakeup = false, |
| 2155 | }; |
| 2156 | |
| 2157 | static struct marimba_tsadc_platform_data marimba_tsadc_pdata = { |
| 2158 | .marimba_tsadc_power = marimba_tsadc_power, |
| 2159 | .init = marimba_tsadc_init, |
| 2160 | .exit = marimba_tsadc_exit, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2161 | .tsadc_prechg_en = true, |
| 2162 | .can_wakeup = false, |
| 2163 | .setup = { |
| 2164 | .pen_irq_en = true, |
| 2165 | .tsadc_en = true, |
| 2166 | }, |
| 2167 | .params2 = { |
| 2168 | .input_clk_khz = 2400, |
| 2169 | .sample_prd = TSADC_CLK_3, |
| 2170 | }, |
| 2171 | .params3 = { |
| 2172 | .prechg_time_nsecs = 6400, |
| 2173 | .stable_time_nsecs = 6400, |
| 2174 | .tsadc_test_mode = 0, |
| 2175 | }, |
| 2176 | .tssc_data = &msm_ts_data, |
| 2177 | }; |
| 2178 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2179 | static struct regulator_bulk_data codec_regs[] = { |
| 2180 | { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 }, |
| 2181 | }; |
| 2182 | |
| 2183 | static int __init msm_marimba_codec_init(void) |
| 2184 | { |
| 2185 | int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs); |
| 2186 | |
| 2187 | if (rc) { |
| 2188 | pr_err("%s: could not get regulators: %d\n", __func__, rc); |
| 2189 | goto out; |
| 2190 | } |
| 2191 | |
| 2192 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs); |
| 2193 | if (rc) { |
| 2194 | pr_err("%s: could not set regulator voltages: %d\n", |
| 2195 | __func__, rc); |
| 2196 | goto reg_free; |
| 2197 | } |
| 2198 | |
| 2199 | return rc; |
| 2200 | |
| 2201 | reg_free: |
| 2202 | regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs); |
| 2203 | out: |
| 2204 | return rc; |
| 2205 | } |
| 2206 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2207 | static int msm_marimba_codec_power(int vreg_on) |
| 2208 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2209 | int rc = vreg_on ? |
| 2210 | regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) : |
| 2211 | regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2212 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2213 | if (rc) { |
| 2214 | pr_err("%s: could not %sable regulators: %d", |
| 2215 | __func__, vreg_on ? "en" : "dis", rc); |
| 2216 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2217 | } |
| 2218 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2219 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2220 | } |
| 2221 | |
| 2222 | static struct marimba_codec_platform_data mariba_codec_pdata = { |
| 2223 | .marimba_codec_power = msm_marimba_codec_power, |
| 2224 | #ifdef CONFIG_MARIMBA_CODEC |
| 2225 | .snddev_profile_init = msm_snddev_init, |
| 2226 | #endif |
| 2227 | }; |
| 2228 | |
| 2229 | static struct marimba_platform_data marimba_pdata = { |
| 2230 | .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR, |
| 2231 | .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR, |
| 2232 | .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR, |
| 2233 | .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR, |
| 2234 | .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR, |
| 2235 | .marimba_setup = msm_marimba_setup_power, |
| 2236 | .marimba_shutdown = msm_marimba_shutdown_power, |
| 2237 | .bahama_setup = msm_bahama_setup_power, |
| 2238 | .bahama_shutdown = msm_bahama_shutdown_power, |
| 2239 | .marimba_gpio_config = msm_marimba_gpio_config_svlte, |
| 2240 | .bahama_core_config = msm_bahama_core_config, |
| 2241 | .fm = &marimba_fm_pdata, |
| 2242 | .codec = &mariba_codec_pdata, |
| 2243 | .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP, |
| 2244 | }; |
| 2245 | |
| 2246 | static void __init msm7x30_init_marimba(void) |
| 2247 | { |
| 2248 | int rc; |
| 2249 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2250 | struct regulator_bulk_data regs[] = { |
| 2251 | { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 }, |
| 2252 | { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 }, |
| 2253 | { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 }, |
| 2254 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2255 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2256 | rc = msm_marimba_codec_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2257 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2258 | if (rc) { |
| 2259 | pr_err("%s: msm_marimba_codec_init failed (%d)\n", |
| 2260 | __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2261 | return; |
| 2262 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2263 | |
| 2264 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs); |
| 2265 | |
| 2266 | if (rc) { |
| 2267 | pr_err("%s: could not get regulators: %d\n", __func__, rc); |
| 2268 | return; |
| 2269 | } |
| 2270 | |
| 2271 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs); |
| 2272 | |
| 2273 | if (rc) { |
| 2274 | pr_err("%s: could not set voltages: %d\n", __func__, rc); |
| 2275 | regulator_bulk_free(ARRAY_SIZE(regs), regs); |
| 2276 | return; |
| 2277 | } |
| 2278 | |
| 2279 | vreg_marimba_1 = regs[0].consumer; |
| 2280 | vreg_marimba_2 = regs[1].consumer; |
| 2281 | vreg_bahama = regs[2].consumer; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2282 | } |
| 2283 | |
| 2284 | static struct marimba_codec_platform_data timpani_codec_pdata = { |
| 2285 | .marimba_codec_power = msm_marimba_codec_power, |
| 2286 | #ifdef CONFIG_TIMPANI_CODEC |
| 2287 | .snddev_profile_init = msm_snddev_init_timpani, |
| 2288 | #endif |
| 2289 | }; |
| 2290 | |
| 2291 | static struct marimba_platform_data timpani_pdata = { |
| 2292 | .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR, |
| 2293 | .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR, |
| 2294 | .marimba_setup = msm_timpani_setup_power, |
| 2295 | .marimba_shutdown = msm_timpani_shutdown_power, |
| 2296 | .codec = &timpani_codec_pdata, |
| 2297 | .tsadc = &marimba_tsadc_pdata, |
| 2298 | .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP, |
| 2299 | }; |
| 2300 | |
| 2301 | #define TIMPANI_I2C_SLAVE_ADDR 0xD |
| 2302 | |
| 2303 | static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = { |
| 2304 | { |
| 2305 | I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR), |
| 2306 | .platform_data = &timpani_pdata, |
| 2307 | }, |
| 2308 | }; |
| 2309 | |
| 2310 | #ifdef CONFIG_MSM7KV2_AUDIO |
| 2311 | static struct resource msm_aictl_resources[] = { |
| 2312 | { |
| 2313 | .name = "aictl", |
| 2314 | .start = 0xa5000100, |
| 2315 | .end = 0xa5000100, |
| 2316 | .flags = IORESOURCE_MEM, |
| 2317 | } |
| 2318 | }; |
| 2319 | |
| 2320 | static struct resource msm_mi2s_resources[] = { |
| 2321 | { |
| 2322 | .name = "hdmi", |
| 2323 | .start = 0xac900000, |
| 2324 | .end = 0xac900038, |
| 2325 | .flags = IORESOURCE_MEM, |
| 2326 | }, |
| 2327 | { |
| 2328 | .name = "codec_rx", |
| 2329 | .start = 0xac940040, |
| 2330 | .end = 0xac940078, |
| 2331 | .flags = IORESOURCE_MEM, |
| 2332 | }, |
| 2333 | { |
| 2334 | .name = "codec_tx", |
| 2335 | .start = 0xac980080, |
| 2336 | .end = 0xac9800B8, |
| 2337 | .flags = IORESOURCE_MEM, |
| 2338 | } |
| 2339 | |
| 2340 | }; |
| 2341 | |
| 2342 | static struct msm_lpa_platform_data lpa_pdata = { |
| 2343 | .obuf_hlb_size = 0x2BFF8, |
| 2344 | .dsp_proc_id = 0, |
| 2345 | .app_proc_id = 2, |
| 2346 | .nosb_config = { |
| 2347 | .llb_min_addr = 0, |
| 2348 | .llb_max_addr = 0x3ff8, |
| 2349 | .sb_min_addr = 0, |
| 2350 | .sb_max_addr = 0, |
| 2351 | }, |
| 2352 | .sb_config = { |
| 2353 | .llb_min_addr = 0, |
| 2354 | .llb_max_addr = 0x37f8, |
| 2355 | .sb_min_addr = 0x3800, |
| 2356 | .sb_max_addr = 0x3ff8, |
| 2357 | } |
| 2358 | }; |
| 2359 | |
| 2360 | static struct resource msm_lpa_resources[] = { |
| 2361 | { |
| 2362 | .name = "lpa", |
| 2363 | .start = 0xa5000000, |
| 2364 | .end = 0xa50000a0, |
| 2365 | .flags = IORESOURCE_MEM, |
| 2366 | } |
| 2367 | }; |
| 2368 | |
| 2369 | static struct resource msm_aux_pcm_resources[] = { |
| 2370 | |
| 2371 | { |
| 2372 | .name = "aux_codec_reg_addr", |
| 2373 | .start = 0xac9c00c0, |
| 2374 | .end = 0xac9c00c8, |
| 2375 | .flags = IORESOURCE_MEM, |
| 2376 | }, |
| 2377 | { |
| 2378 | .name = "aux_pcm_dout", |
| 2379 | .start = 138, |
| 2380 | .end = 138, |
| 2381 | .flags = IORESOURCE_IO, |
| 2382 | }, |
| 2383 | { |
| 2384 | .name = "aux_pcm_din", |
| 2385 | .start = 139, |
| 2386 | .end = 139, |
| 2387 | .flags = IORESOURCE_IO, |
| 2388 | }, |
| 2389 | { |
| 2390 | .name = "aux_pcm_syncout", |
| 2391 | .start = 140, |
| 2392 | .end = 140, |
| 2393 | .flags = IORESOURCE_IO, |
| 2394 | }, |
| 2395 | { |
| 2396 | .name = "aux_pcm_clkin_a", |
| 2397 | .start = 141, |
| 2398 | .end = 141, |
| 2399 | .flags = IORESOURCE_IO, |
| 2400 | }, |
| 2401 | }; |
| 2402 | |
| 2403 | static struct platform_device msm_aux_pcm_device = { |
| 2404 | .name = "msm_aux_pcm", |
| 2405 | .id = 0, |
| 2406 | .num_resources = ARRAY_SIZE(msm_aux_pcm_resources), |
| 2407 | .resource = msm_aux_pcm_resources, |
| 2408 | }; |
| 2409 | |
| 2410 | struct platform_device msm_aictl_device = { |
| 2411 | .name = "audio_interct", |
| 2412 | .id = 0, |
| 2413 | .num_resources = ARRAY_SIZE(msm_aictl_resources), |
| 2414 | .resource = msm_aictl_resources, |
| 2415 | }; |
| 2416 | |
| 2417 | struct platform_device msm_mi2s_device = { |
| 2418 | .name = "mi2s", |
| 2419 | .id = 0, |
| 2420 | .num_resources = ARRAY_SIZE(msm_mi2s_resources), |
| 2421 | .resource = msm_mi2s_resources, |
| 2422 | }; |
| 2423 | |
| 2424 | struct platform_device msm_lpa_device = { |
| 2425 | .name = "lpa", |
| 2426 | .id = 0, |
| 2427 | .num_resources = ARRAY_SIZE(msm_lpa_resources), |
| 2428 | .resource = msm_lpa_resources, |
| 2429 | .dev = { |
| 2430 | .platform_data = &lpa_pdata, |
| 2431 | }, |
| 2432 | }; |
| 2433 | #endif /* CONFIG_MSM7KV2_AUDIO */ |
| 2434 | |
| 2435 | #define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 2436 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 2437 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 2438 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 2439 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 2440 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 2441 | #define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 2442 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 2443 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 2444 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 2445 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 2446 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 2447 | #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 2448 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 2449 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 2450 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 2451 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 2452 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 2453 | #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 2454 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 2455 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 2456 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 2457 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 2458 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 2459 | #define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI) |
| 2460 | |
| 2461 | static unsigned int dec_concurrency_table[] = { |
| 2462 | /* Audio LP */ |
| 2463 | 0, |
| 2464 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2465 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2466 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2467 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)| |
| 2468 | (1<<MSM_ADSP_OP_DM)), |
| 2469 | |
| 2470 | /* Concurrency 1 */ |
| 2471 | (DEC4_FORMAT), |
| 2472 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2473 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2474 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2475 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2476 | |
| 2477 | /* Concurrency 2 */ |
| 2478 | (DEC4_FORMAT), |
| 2479 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2480 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2481 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2482 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2483 | |
| 2484 | /* Concurrency 3 */ |
| 2485 | (DEC4_FORMAT), |
| 2486 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2487 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2488 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2489 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2490 | |
| 2491 | /* Concurrency 4 */ |
| 2492 | (DEC4_FORMAT), |
| 2493 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2494 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2495 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2496 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2497 | |
| 2498 | /* Concurrency 5 */ |
| 2499 | (DEC4_FORMAT), |
| 2500 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2501 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2502 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2503 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2504 | |
| 2505 | /* Concurrency 6 */ |
| 2506 | (DEC4_FORMAT), |
| 2507 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2508 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2509 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2510 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2511 | }; |
| 2512 | |
| 2513 | #define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \ |
| 2514 | .module_queueid = queueid, .module_decid = decid, \ |
| 2515 | .nr_codec_support = nr_codec} |
| 2516 | |
| 2517 | #define DEC_INSTANCE(max_instance_same, max_instance_diff) { \ |
| 2518 | .max_instances_same_dec = max_instance_same, \ |
| 2519 | .max_instances_diff_dec = max_instance_diff} |
| 2520 | |
| 2521 | static struct msm_adspdec_info dec_info_list[] = { |
| 2522 | DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */ |
| 2523 | DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */ |
| 2524 | DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */ |
| 2525 | DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */ |
| 2526 | DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */ |
| 2527 | }; |
| 2528 | |
| 2529 | static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = { |
| 2530 | /* Non Turbo Mode */ |
| 2531 | { |
| 2532 | DEC_INSTANCE(4, 3), /* WAV */ |
| 2533 | DEC_INSTANCE(4, 3), /* ADPCM */ |
| 2534 | DEC_INSTANCE(4, 2), /* MP3 */ |
| 2535 | DEC_INSTANCE(0, 0), /* Real Audio */ |
| 2536 | DEC_INSTANCE(4, 2), /* WMA */ |
| 2537 | DEC_INSTANCE(3, 2), /* AAC */ |
| 2538 | DEC_INSTANCE(0, 0), /* Reserved */ |
| 2539 | DEC_INSTANCE(0, 0), /* MIDI */ |
| 2540 | DEC_INSTANCE(4, 3), /* YADPCM */ |
| 2541 | DEC_INSTANCE(4, 3), /* QCELP */ |
| 2542 | DEC_INSTANCE(4, 3), /* AMRNB */ |
| 2543 | DEC_INSTANCE(1, 1), /* AMRWB/WB+ */ |
| 2544 | DEC_INSTANCE(4, 3), /* EVRC */ |
| 2545 | DEC_INSTANCE(1, 1), /* WMAPRO */ |
| 2546 | }, |
| 2547 | /* Turbo Mode */ |
| 2548 | { |
| 2549 | DEC_INSTANCE(4, 3), /* WAV */ |
| 2550 | DEC_INSTANCE(4, 3), /* ADPCM */ |
| 2551 | DEC_INSTANCE(4, 3), /* MP3 */ |
| 2552 | DEC_INSTANCE(0, 0), /* Real Audio */ |
| 2553 | DEC_INSTANCE(4, 3), /* WMA */ |
| 2554 | DEC_INSTANCE(4, 3), /* AAC */ |
| 2555 | DEC_INSTANCE(0, 0), /* Reserved */ |
| 2556 | DEC_INSTANCE(0, 0), /* MIDI */ |
| 2557 | DEC_INSTANCE(4, 3), /* YADPCM */ |
| 2558 | DEC_INSTANCE(4, 3), /* QCELP */ |
| 2559 | DEC_INSTANCE(4, 3), /* AMRNB */ |
| 2560 | DEC_INSTANCE(2, 3), /* AMRWB/WB+ */ |
| 2561 | DEC_INSTANCE(4, 3), /* EVRC */ |
| 2562 | DEC_INSTANCE(1, 2), /* WMAPRO */ |
| 2563 | }, |
| 2564 | }; |
| 2565 | |
| 2566 | static struct msm_adspdec_database msm_device_adspdec_database = { |
| 2567 | .num_dec = ARRAY_SIZE(dec_info_list), |
| 2568 | .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \ |
| 2569 | ARRAY_SIZE(dec_info_list)), |
| 2570 | .dec_concurrency_table = dec_concurrency_table, |
| 2571 | .dec_info_list = dec_info_list, |
| 2572 | .dec_instance_list = &dec_instance_list[0][0], |
| 2573 | }; |
| 2574 | |
| 2575 | static struct platform_device msm_device_adspdec = { |
| 2576 | .name = "msm_adspdec", |
| 2577 | .id = -1, |
| 2578 | .dev = { |
| 2579 | .platform_data = &msm_device_adspdec_database |
| 2580 | }, |
| 2581 | }; |
| 2582 | |
| 2583 | static struct resource smc91x_resources[] = { |
| 2584 | [0] = { |
| 2585 | .start = 0x8A000300, |
| 2586 | .end = 0x8A0003ff, |
| 2587 | .flags = IORESOURCE_MEM, |
| 2588 | }, |
| 2589 | [1] = { |
| 2590 | .start = MSM_GPIO_TO_INT(156), |
| 2591 | .end = MSM_GPIO_TO_INT(156), |
| 2592 | .flags = IORESOURCE_IRQ, |
| 2593 | }, |
| 2594 | }; |
| 2595 | |
| 2596 | static struct platform_device smc91x_device = { |
| 2597 | .name = "smc91x", |
| 2598 | .id = 0, |
| 2599 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 2600 | .resource = smc91x_resources, |
| 2601 | }; |
| 2602 | |
| 2603 | static struct smsc911x_platform_config smsc911x_config = { |
| 2604 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 2605 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 2606 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 2607 | .flags = SMSC911X_USE_32BIT, |
| 2608 | }; |
| 2609 | |
| 2610 | static struct resource smsc911x_resources[] = { |
| 2611 | [0] = { |
| 2612 | .start = 0x8D000000, |
| 2613 | .end = 0x8D000100, |
| 2614 | .flags = IORESOURCE_MEM, |
| 2615 | }, |
| 2616 | [1] = { |
| 2617 | .start = MSM_GPIO_TO_INT(88), |
| 2618 | .end = MSM_GPIO_TO_INT(88), |
| 2619 | .flags = IORESOURCE_IRQ, |
| 2620 | }, |
| 2621 | }; |
| 2622 | |
| 2623 | static struct platform_device smsc911x_device = { |
| 2624 | .name = "smsc911x", |
| 2625 | .id = -1, |
| 2626 | .num_resources = ARRAY_SIZE(smsc911x_resources), |
| 2627 | .resource = smsc911x_resources, |
| 2628 | .dev = { |
| 2629 | .platform_data = &smsc911x_config, |
| 2630 | }, |
| 2631 | }; |
| 2632 | |
| 2633 | static struct msm_gpio smsc911x_gpios[] = { |
| 2634 | { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" }, |
| 2635 | { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" }, |
| 2636 | { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" }, |
| 2637 | { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" }, |
| 2638 | { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" }, |
| 2639 | { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" }, |
| 2640 | { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" }, |
| 2641 | { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" }, |
| 2642 | }; |
| 2643 | |
| 2644 | static void msm7x30_cfg_smsc911x(void) |
| 2645 | { |
| 2646 | int rc; |
| 2647 | |
| 2648 | rc = msm_gpios_request_enable(smsc911x_gpios, |
| 2649 | ARRAY_SIZE(smsc911x_gpios)); |
| 2650 | if (rc) |
| 2651 | pr_err("%s: unable to enable gpios\n", __func__); |
| 2652 | } |
| 2653 | |
| 2654 | #ifdef CONFIG_USB_G_ANDROID |
| 2655 | static struct android_usb_platform_data android_usb_pdata = { |
| 2656 | .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num, |
| 2657 | }; |
| 2658 | |
| 2659 | static struct platform_device android_usb_device = { |
| 2660 | .name = "android_usb", |
| 2661 | .id = -1, |
| 2662 | .dev = { |
| 2663 | .platform_data = &android_usb_pdata, |
| 2664 | }, |
| 2665 | }; |
| 2666 | #endif |
| 2667 | |
| 2668 | static struct msm_gpio optnav_config_data[] = { |
| 2669 | { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), |
| 2670 | "optnav_chip_select" }, |
| 2671 | }; |
| 2672 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2673 | static struct regulator_bulk_data optnav_regulators[] = { |
| 2674 | { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 }, |
| 2675 | { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 }, |
| 2676 | { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 }, |
| 2677 | { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 }, |
| 2678 | }; |
| 2679 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2680 | static void __iomem *virtual_optnav; |
| 2681 | |
| 2682 | static int optnav_gpio_setup(void) |
| 2683 | { |
| 2684 | int rc = -ENODEV; |
| 2685 | rc = msm_gpios_request_enable(optnav_config_data, |
| 2686 | ARRAY_SIZE(optnav_config_data)); |
| 2687 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2688 | if (rc) |
| 2689 | return rc; |
| 2690 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2691 | /* Configure the FPGA for GPIOs */ |
| 2692 | virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4); |
| 2693 | if (!virtual_optnav) { |
| 2694 | pr_err("%s:Could not ioremap region\n", __func__); |
| 2695 | return -ENOMEM; |
| 2696 | } |
| 2697 | /* |
| 2698 | * Configure the FPGA to set GPIO 19 as |
| 2699 | * normal, active(enabled), output(MSM to SURF) |
| 2700 | */ |
| 2701 | writew(0x311E, virtual_optnav); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2702 | |
| 2703 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators), |
| 2704 | optnav_regulators); |
| 2705 | if (rc) |
| 2706 | return rc; |
| 2707 | |
| 2708 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators), |
| 2709 | optnav_regulators); |
| 2710 | |
| 2711 | if (rc) |
| 2712 | goto regulator_put; |
| 2713 | |
| 2714 | return rc; |
| 2715 | |
| 2716 | regulator_put: |
| 2717 | regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2718 | return rc; |
| 2719 | } |
| 2720 | |
| 2721 | static void optnav_gpio_release(void) |
| 2722 | { |
| 2723 | msm_gpios_disable_free(optnav_config_data, |
| 2724 | ARRAY_SIZE(optnav_config_data)); |
| 2725 | iounmap(virtual_optnav); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2726 | regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2727 | } |
| 2728 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2729 | static int optnav_enable(void) |
| 2730 | { |
| 2731 | int rc; |
| 2732 | /* |
| 2733 | * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb) |
| 2734 | * for I2C communication with keyboard. |
| 2735 | */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2736 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2737 | rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators), |
| 2738 | optnav_regulators); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2739 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2740 | if (rc) |
| 2741 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2742 | |
| 2743 | /* Enable the chip select GPIO */ |
| 2744 | gpio_set_value(OPTNAV_CHIP_SELECT, 1); |
| 2745 | gpio_set_value(OPTNAV_CHIP_SELECT, 0); |
| 2746 | |
| 2747 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2748 | } |
| 2749 | |
| 2750 | static void optnav_disable(void) |
| 2751 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2752 | regulator_bulk_disable(ARRAY_SIZE(optnav_regulators), |
| 2753 | optnav_regulators); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2754 | |
| 2755 | gpio_set_value(OPTNAV_CHIP_SELECT, 1); |
| 2756 | } |
| 2757 | |
| 2758 | static struct ofn_atlab_platform_data optnav_data = { |
| 2759 | .gpio_setup = optnav_gpio_setup, |
| 2760 | .gpio_release = optnav_gpio_release, |
| 2761 | .optnav_on = optnav_enable, |
| 2762 | .optnav_off = optnav_disable, |
| 2763 | .rotate_xy = 0, |
| 2764 | .function1 = { |
| 2765 | .no_motion1_en = true, |
| 2766 | .touch_sensor_en = true, |
| 2767 | .ofn_en = true, |
| 2768 | .clock_select_khz = 1500, |
| 2769 | .cpi_selection = 1200, |
| 2770 | }, |
| 2771 | .function2 = { |
| 2772 | .invert_y = false, |
| 2773 | .invert_x = true, |
| 2774 | .swap_x_y = false, |
| 2775 | .hold_a_b_en = true, |
| 2776 | .motion_filter_en = true, |
| 2777 | }, |
| 2778 | }; |
| 2779 | |
| 2780 | static int hdmi_comm_power(int on, int show); |
| 2781 | static int hdmi_init_irq(void); |
| 2782 | static int hdmi_enable_5v(int on); |
| 2783 | static int hdmi_core_power(int on, int show); |
| 2784 | static int hdmi_cec_power(int on); |
| 2785 | static bool hdmi_check_hdcp_hw_support(void); |
| 2786 | |
| 2787 | static struct msm_hdmi_platform_data adv7520_hdmi_data = { |
| 2788 | .irq = MSM_GPIO_TO_INT(18), |
| 2789 | .comm_power = hdmi_comm_power, |
| 2790 | .init_irq = hdmi_init_irq, |
| 2791 | .enable_5v = hdmi_enable_5v, |
| 2792 | .core_power = hdmi_core_power, |
| 2793 | .cec_power = hdmi_cec_power, |
| 2794 | .check_hdcp_hw_support = hdmi_check_hdcp_hw_support, |
| 2795 | }; |
| 2796 | |
| 2797 | #ifdef CONFIG_BOSCH_BMA150 |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2798 | |
| 2799 | static struct regulator_bulk_data sensors_ldo[] = { |
| 2800 | { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 }, |
| 2801 | { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 }, |
| 2802 | }; |
| 2803 | |
| 2804 | static int __init sensors_ldo_init(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2805 | { |
| 2806 | int rc; |
| 2807 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2808 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2809 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2810 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2811 | pr_err("%s: could not get regulators: %d\n", __func__, rc); |
| 2812 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2813 | } |
| 2814 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2815 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo); |
| 2816 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2817 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2818 | pr_err("%s: could not set voltages: %d\n", __func__, rc); |
| 2819 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2820 | } |
| 2821 | |
| 2822 | return 0; |
| 2823 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2824 | reg_free: |
| 2825 | regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo); |
| 2826 | out: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2827 | return rc; |
| 2828 | } |
| 2829 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2830 | static int sensors_ldo_set(int on) |
| 2831 | { |
| 2832 | int rc = on ? |
| 2833 | regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) : |
| 2834 | regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo); |
| 2835 | |
| 2836 | if (rc) |
| 2837 | pr_err("%s: could not %sable regulators: %d\n", |
| 2838 | __func__, on ? "en" : "dis", rc); |
| 2839 | |
| 2840 | return rc; |
| 2841 | } |
| 2842 | |
| 2843 | static int sensors_ldo_enable(void) |
| 2844 | { |
| 2845 | return sensors_ldo_set(1); |
| 2846 | } |
| 2847 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2848 | static void sensors_ldo_disable(void) |
| 2849 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2850 | sensors_ldo_set(0); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2851 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 2852 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2853 | static struct bma150_platform_data bma150_data = { |
| 2854 | .power_on = sensors_ldo_enable, |
| 2855 | .power_off = sensors_ldo_disable, |
| 2856 | }; |
| 2857 | |
| 2858 | static struct i2c_board_info bma150_board_info[] __initdata = { |
| 2859 | { |
| 2860 | I2C_BOARD_INFO("bma150", 0x38), |
| 2861 | .flags = I2C_CLIENT_WAKE, |
| 2862 | .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT), |
| 2863 | .platform_data = &bma150_data, |
| 2864 | }, |
| 2865 | }; |
| 2866 | #endif |
| 2867 | |
| 2868 | static struct i2c_board_info msm_i2c_board_info[] = { |
| 2869 | { |
| 2870 | I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR), |
| 2871 | .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ), |
| 2872 | .platform_data = &optnav_data, |
| 2873 | }, |
| 2874 | { |
| 2875 | I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR), |
| 2876 | .platform_data = &adv7520_hdmi_data, |
| 2877 | }, |
| 2878 | }; |
| 2879 | |
| 2880 | static struct i2c_board_info msm_marimba_board_info[] = { |
| 2881 | { |
| 2882 | I2C_BOARD_INFO("marimba", 0xc), |
| 2883 | .platform_data = &marimba_pdata, |
| 2884 | } |
| 2885 | }; |
| 2886 | |
| 2887 | |
| 2888 | static struct msm_handset_platform_data hs_platform_data = { |
| 2889 | .hs_name = "7k_handset", |
| 2890 | .pwr_key_delay_ms = 500, /* 0 will disable end key */ |
| 2891 | }; |
| 2892 | |
| 2893 | static struct platform_device hs_device = { |
| 2894 | .name = "msm-handset", |
| 2895 | .id = -1, |
| 2896 | .dev = { |
| 2897 | .platform_data = &hs_platform_data, |
| 2898 | }, |
| 2899 | }; |
| 2900 | |
| 2901 | static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = { |
| 2902 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = { |
| 2903 | .idle_supported = 1, |
| 2904 | .suspend_supported = 1, |
| 2905 | .idle_enabled = 1, |
| 2906 | .suspend_enabled = 1, |
| 2907 | .latency = 8594, |
| 2908 | .residency = 23740, |
| 2909 | }, |
| 2910 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = { |
| 2911 | .idle_supported = 1, |
| 2912 | .suspend_supported = 1, |
| 2913 | .idle_enabled = 1, |
| 2914 | .suspend_enabled = 1, |
| 2915 | .latency = 4594, |
| 2916 | .residency = 23740, |
| 2917 | }, |
| 2918 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE] = { |
| 2919 | #ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE |
| 2920 | .idle_supported = 1, |
| 2921 | .suspend_supported = 1, |
| 2922 | .idle_enabled = 1, |
| 2923 | .suspend_enabled = 0, |
| 2924 | #else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/ |
| 2925 | .idle_supported = 0, |
| 2926 | .suspend_supported = 0, |
| 2927 | .idle_enabled = 0, |
| 2928 | .suspend_enabled = 0, |
| 2929 | #endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/ |
| 2930 | .latency = 500, |
| 2931 | .residency = 6000, |
| 2932 | }, |
| 2933 | [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = { |
| 2934 | .idle_supported = 1, |
| 2935 | .suspend_supported = 1, |
| 2936 | .idle_enabled = 0, |
| 2937 | .suspend_enabled = 1, |
| 2938 | .latency = 443, |
| 2939 | .residency = 1098, |
| 2940 | }, |
| 2941 | [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = { |
| 2942 | .idle_supported = 1, |
| 2943 | .suspend_supported = 1, |
| 2944 | .idle_enabled = 1, |
| 2945 | .suspend_enabled = 1, |
| 2946 | .latency = 2, |
| 2947 | .residency = 0, |
| 2948 | }, |
| 2949 | }; |
| 2950 | |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 2951 | static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = { |
| 2952 | .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT, |
| 2953 | .v_addr = (uint32_t *)PAGE_OFFSET, |
| 2954 | }; |
| 2955 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2956 | static struct resource qsd_spi_resources[] = { |
| 2957 | { |
| 2958 | .name = "spi_irq_in", |
| 2959 | .start = INT_SPI_INPUT, |
| 2960 | .end = INT_SPI_INPUT, |
| 2961 | .flags = IORESOURCE_IRQ, |
| 2962 | }, |
| 2963 | { |
| 2964 | .name = "spi_irq_out", |
| 2965 | .start = INT_SPI_OUTPUT, |
| 2966 | .end = INT_SPI_OUTPUT, |
| 2967 | .flags = IORESOURCE_IRQ, |
| 2968 | }, |
| 2969 | { |
| 2970 | .name = "spi_irq_err", |
| 2971 | .start = INT_SPI_ERROR, |
| 2972 | .end = INT_SPI_ERROR, |
| 2973 | .flags = IORESOURCE_IRQ, |
| 2974 | }, |
| 2975 | { |
| 2976 | .name = "spi_base", |
| 2977 | .start = 0xA8000000, |
| 2978 | .end = 0xA8000000 + SZ_4K - 1, |
| 2979 | .flags = IORESOURCE_MEM, |
| 2980 | }, |
| 2981 | { |
| 2982 | .name = "spidm_channels", |
| 2983 | .flags = IORESOURCE_DMA, |
| 2984 | }, |
| 2985 | { |
| 2986 | .name = "spidm_crci", |
| 2987 | .flags = IORESOURCE_DMA, |
| 2988 | }, |
| 2989 | }; |
| 2990 | |
| 2991 | #define AMDH0_BASE_PHYS 0xAC200000 |
| 2992 | #define ADMH0_GP_CTL (ct_adm_base + 0x3D8) |
| 2993 | static int msm_qsd_spi_dma_config(void) |
| 2994 | { |
| 2995 | void __iomem *ct_adm_base = 0; |
| 2996 | u32 spi_mux = 0; |
| 2997 | int ret = 0; |
| 2998 | |
| 2999 | ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE); |
| 3000 | if (!ct_adm_base) { |
| 3001 | pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS); |
| 3002 | return -ENOMEM; |
| 3003 | } |
| 3004 | |
| 3005 | spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12; |
| 3006 | |
| 3007 | qsd_spi_resources[4].start = DMOV_USB_CHAN; |
| 3008 | qsd_spi_resources[4].end = DMOV_TSIF_CHAN; |
| 3009 | |
| 3010 | switch (spi_mux) { |
| 3011 | case (1): |
| 3012 | qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI; |
| 3013 | qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI; |
| 3014 | break; |
| 3015 | case (2): |
| 3016 | qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI; |
| 3017 | qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI; |
| 3018 | break; |
| 3019 | case (3): |
| 3020 | qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI; |
| 3021 | qsd_spi_resources[5].end = DMOV_CE_IN_CRCI; |
| 3022 | break; |
| 3023 | default: |
| 3024 | ret = -ENOENT; |
| 3025 | } |
| 3026 | |
| 3027 | iounmap(ct_adm_base); |
| 3028 | |
| 3029 | return ret; |
| 3030 | } |
| 3031 | |
| 3032 | static struct platform_device qsd_device_spi = { |
| 3033 | .name = "spi_qsd", |
| 3034 | .id = 0, |
| 3035 | .num_resources = ARRAY_SIZE(qsd_spi_resources), |
| 3036 | .resource = qsd_spi_resources, |
| 3037 | }; |
| 3038 | |
| 3039 | #ifdef CONFIG_SPI_QSD |
| 3040 | static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = { |
| 3041 | { |
| 3042 | .modalias = "lcdc_sharp_ls038y7dx01", |
| 3043 | .mode = SPI_MODE_1, |
| 3044 | .bus_num = 0, |
| 3045 | .chip_select = 0, |
| 3046 | .max_speed_hz = 26331429, |
| 3047 | } |
| 3048 | }; |
| 3049 | static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = { |
| 3050 | { |
| 3051 | .modalias = "lcdc_toshiba_ltm030dd40", |
| 3052 | .mode = SPI_MODE_3|SPI_CS_HIGH, |
| 3053 | .bus_num = 0, |
| 3054 | .chip_select = 0, |
| 3055 | .max_speed_hz = 9963243, |
| 3056 | } |
| 3057 | }; |
| 3058 | #endif |
| 3059 | |
| 3060 | static struct msm_gpio qsd_spi_gpio_config_data[] = { |
| 3061 | { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" }, |
| 3062 | { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" }, |
| 3063 | { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" }, |
| 3064 | { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" }, |
| 3065 | }; |
| 3066 | |
| 3067 | static int msm_qsd_spi_gpio_config(void) |
| 3068 | { |
| 3069 | return msm_gpios_request_enable(qsd_spi_gpio_config_data, |
| 3070 | ARRAY_SIZE(qsd_spi_gpio_config_data)); |
| 3071 | } |
| 3072 | |
| 3073 | static void msm_qsd_spi_gpio_release(void) |
| 3074 | { |
| 3075 | msm_gpios_disable_free(qsd_spi_gpio_config_data, |
| 3076 | ARRAY_SIZE(qsd_spi_gpio_config_data)); |
| 3077 | } |
| 3078 | |
| 3079 | static struct msm_spi_platform_data qsd_spi_pdata = { |
| 3080 | .max_clock_speed = 26331429, |
| 3081 | .gpio_config = msm_qsd_spi_gpio_config, |
| 3082 | .gpio_release = msm_qsd_spi_gpio_release, |
| 3083 | .dma_config = msm_qsd_spi_dma_config, |
| 3084 | }; |
| 3085 | |
| 3086 | static void __init msm_qsd_spi_init(void) |
| 3087 | { |
| 3088 | qsd_device_spi.dev.platform_data = &qsd_spi_pdata; |
| 3089 | } |
| 3090 | |
| 3091 | #ifdef CONFIG_USB_EHCI_MSM_72K |
| 3092 | static void msm_hsusb_vbus_power(unsigned phy_info, int on) |
| 3093 | { |
| 3094 | int rc; |
| 3095 | static int vbus_is_on; |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 3096 | struct pm8xxx_gpio_init_info usb_vbus = { |
| 3097 | PM8058_GPIO_PM_TO_SYS(36), |
| 3098 | { |
| 3099 | .direction = PM_GPIO_DIR_OUT, |
| 3100 | .pull = PM_GPIO_PULL_NO, |
| 3101 | .output_buffer = PM_GPIO_OUT_BUF_CMOS, |
| 3102 | .output_value = 1, |
| 3103 | .vin_sel = 2, |
| 3104 | .out_strength = PM_GPIO_STRENGTH_MED, |
| 3105 | .function = PM_GPIO_FUNC_NORMAL, |
| 3106 | .inv_int_pol = 0, |
| 3107 | }, |
| 3108 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3109 | |
| 3110 | /* If VBUS is already on (or off), do nothing. */ |
| 3111 | if (unlikely(on == vbus_is_on)) |
| 3112 | return; |
| 3113 | |
| 3114 | if (on) { |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 3115 | rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config); |
| 3116 | if (rc) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3117 | pr_err("%s PMIC GPIO 36 write failed\n", __func__); |
| 3118 | return; |
| 3119 | } |
| 3120 | } else { |
| 3121 | gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0); |
| 3122 | } |
| 3123 | |
| 3124 | vbus_is_on = on; |
| 3125 | } |
| 3126 | |
| 3127 | static struct msm_usb_host_platform_data msm_usb_host_pdata = { |
| 3128 | .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM), |
| 3129 | .vbus_power = msm_hsusb_vbus_power, |
| 3130 | .power_budget = 180, |
| 3131 | }; |
| 3132 | #endif |
| 3133 | |
| 3134 | #ifdef CONFIG_USB_MSM_OTG_72K |
| 3135 | static int hsusb_rpc_connect(int connect) |
| 3136 | { |
| 3137 | if (connect) |
| 3138 | return msm_hsusb_rpc_connect(); |
| 3139 | else |
| 3140 | return msm_hsusb_rpc_close(); |
| 3141 | } |
| 3142 | #endif |
| 3143 | |
| 3144 | #ifdef CONFIG_USB_MSM_OTG_72K |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3145 | static struct regulator *vreg_3p3; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3146 | static int msm_hsusb_ldo_init(int init) |
| 3147 | { |
| 3148 | uint32_t version = 0; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3149 | int def_vol = 3400000; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3150 | |
| 3151 | version = socinfo_get_version(); |
| 3152 | |
| 3153 | if (SOCINFO_VERSION_MAJOR(version) >= 2 && |
| 3154 | SOCINFO_VERSION_MINOR(version) >= 1) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3155 | def_vol = 3075000; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3156 | pr_debug("%s: default voltage:%d\n", __func__, def_vol); |
| 3157 | } |
| 3158 | |
| 3159 | if (init) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3160 | vreg_3p3 = regulator_get(NULL, "usb"); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3161 | if (IS_ERR(vreg_3p3)) |
| 3162 | return PTR_ERR(vreg_3p3); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3163 | regulator_set_voltage(vreg_3p3, def_vol, def_vol); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3164 | } else |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3165 | regulator_put(vreg_3p3); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3166 | |
| 3167 | return 0; |
| 3168 | } |
| 3169 | |
| 3170 | static int msm_hsusb_ldo_enable(int enable) |
| 3171 | { |
| 3172 | static int ldo_status; |
| 3173 | |
| 3174 | if (!vreg_3p3 || IS_ERR(vreg_3p3)) |
| 3175 | return -ENODEV; |
| 3176 | |
| 3177 | if (ldo_status == enable) |
| 3178 | return 0; |
| 3179 | |
| 3180 | ldo_status = enable; |
| 3181 | |
| 3182 | if (enable) |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3183 | return regulator_enable(vreg_3p3); |
| 3184 | else |
| 3185 | return regulator_disable(vreg_3p3); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3186 | } |
| 3187 | |
| 3188 | static int msm_hsusb_ldo_set_voltage(int mV) |
| 3189 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3190 | static int cur_voltage; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3191 | |
| 3192 | if (!vreg_3p3 || IS_ERR(vreg_3p3)) |
| 3193 | return -ENODEV; |
| 3194 | |
| 3195 | if (cur_voltage == mV) |
| 3196 | return 0; |
| 3197 | |
| 3198 | cur_voltage = mV; |
| 3199 | |
| 3200 | pr_debug("%s: (%d)\n", __func__, mV); |
| 3201 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3202 | return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3203 | } |
| 3204 | #endif |
| 3205 | |
| 3206 | #ifndef CONFIG_USB_EHCI_MSM_72K |
| 3207 | static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init); |
| 3208 | #endif |
| 3209 | static struct msm_otg_platform_data msm_otg_pdata = { |
| 3210 | .rpc_connect = hsusb_rpc_connect, |
| 3211 | |
| 3212 | #ifndef CONFIG_USB_EHCI_MSM_72K |
| 3213 | .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init, |
| 3214 | #else |
| 3215 | .vbus_power = msm_hsusb_vbus_power, |
| 3216 | #endif |
| 3217 | .core_clk = 1, |
| 3218 | .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT, |
| 3219 | .cdr_autoreset = CDR_AUTO_RESET_DISABLE, |
| 3220 | .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT, |
| 3221 | .se1_gating = SE1_GATING_DISABLE, |
| 3222 | .chg_vbus_draw = hsusb_chg_vbus_draw, |
| 3223 | .chg_connected = hsusb_chg_connected, |
| 3224 | .chg_init = hsusb_chg_init, |
| 3225 | .ldo_enable = msm_hsusb_ldo_enable, |
| 3226 | .ldo_init = msm_hsusb_ldo_init, |
| 3227 | .ldo_set_voltage = msm_hsusb_ldo_set_voltage, |
| 3228 | }; |
| 3229 | |
| 3230 | #ifdef CONFIG_USB_GADGET |
| 3231 | static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = { |
| 3232 | .is_phy_status_timer_on = 1, |
| 3233 | }; |
| 3234 | #endif |
| 3235 | #ifndef CONFIG_USB_EHCI_MSM_72K |
| 3236 | typedef void (*notify_vbus_state) (int); |
| 3237 | notify_vbus_state notify_vbus_state_func_ptr; |
| 3238 | int vbus_on_irq; |
| 3239 | static irqreturn_t pmic_vbus_on_irq(int irq, void *data) |
| 3240 | { |
| 3241 | pr_info("%s: vbus notification from pmic\n", __func__); |
| 3242 | |
| 3243 | (*notify_vbus_state_func_ptr) (1); |
| 3244 | |
| 3245 | return IRQ_HANDLED; |
| 3246 | } |
| 3247 | static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init) |
| 3248 | { |
| 3249 | int ret; |
| 3250 | |
| 3251 | if (init) { |
| 3252 | if (!callback) |
| 3253 | return -ENODEV; |
| 3254 | |
| 3255 | notify_vbus_state_func_ptr = callback; |
| 3256 | vbus_on_irq = platform_get_irq_byname(&msm_device_otg, |
| 3257 | "vbus_on"); |
| 3258 | if (vbus_on_irq <= 0) { |
| 3259 | pr_err("%s: unable to get vbus on irq\n", __func__); |
| 3260 | return -ENODEV; |
| 3261 | } |
| 3262 | |
| 3263 | ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq, |
| 3264 | IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL); |
| 3265 | if (ret < 0) { |
| 3266 | pr_info("%s: request_irq for vbus_on" |
| 3267 | "interrupt failed\n", __func__); |
| 3268 | return ret; |
| 3269 | } |
| 3270 | msm_otg_pdata.pmic_vbus_irq = vbus_on_irq; |
| 3271 | return 0; |
| 3272 | } else { |
| 3273 | free_irq(vbus_on_irq, 0); |
| 3274 | notify_vbus_state_func_ptr = NULL; |
| 3275 | return 0; |
| 3276 | } |
| 3277 | } |
| 3278 | #endif |
| 3279 | |
| 3280 | static struct android_pmem_platform_data android_pmem_pdata = { |
| 3281 | .name = "pmem", |
| 3282 | .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING, |
| 3283 | .cached = 1, |
| 3284 | .memory_type = MEMTYPE_EBI0, |
| 3285 | }; |
| 3286 | |
| 3287 | static struct platform_device android_pmem_device = { |
| 3288 | .name = "android_pmem", |
| 3289 | .id = 0, |
| 3290 | .dev = { .platform_data = &android_pmem_pdata }, |
| 3291 | }; |
| 3292 | |
| 3293 | #ifndef CONFIG_SPI_QSD |
| 3294 | static int lcdc_gpio_array_num[] = { |
| 3295 | 45, /* spi_clk */ |
| 3296 | 46, /* spi_cs */ |
| 3297 | 47, /* spi_mosi */ |
| 3298 | 48, /* spi_miso */ |
| 3299 | }; |
| 3300 | |
| 3301 | static struct msm_gpio lcdc_gpio_config_data[] = { |
| 3302 | { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" }, |
| 3303 | { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" }, |
| 3304 | { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" }, |
| 3305 | { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" }, |
| 3306 | }; |
| 3307 | |
| 3308 | static void lcdc_config_gpios(int enable) |
| 3309 | { |
| 3310 | if (enable) { |
| 3311 | msm_gpios_request_enable(lcdc_gpio_config_data, |
| 3312 | ARRAY_SIZE( |
| 3313 | lcdc_gpio_config_data)); |
| 3314 | } else |
| 3315 | msm_gpios_disable_free(lcdc_gpio_config_data, |
| 3316 | ARRAY_SIZE( |
| 3317 | lcdc_gpio_config_data)); |
| 3318 | } |
| 3319 | #endif |
| 3320 | |
| 3321 | static struct msm_panel_common_pdata lcdc_sharp_panel_data = { |
| 3322 | #ifndef CONFIG_SPI_QSD |
| 3323 | .panel_config_gpio = lcdc_config_gpios, |
| 3324 | .gpio_num = lcdc_gpio_array_num, |
| 3325 | #endif |
| 3326 | .gpio = 2, /* LPG PMIC_GPIO26 channel number */ |
| 3327 | }; |
| 3328 | |
| 3329 | static struct platform_device lcdc_sharp_panel_device = { |
| 3330 | .name = "lcdc_sharp_wvga", |
| 3331 | .id = 0, |
| 3332 | .dev = { |
| 3333 | .platform_data = &lcdc_sharp_panel_data, |
| 3334 | } |
| 3335 | }; |
| 3336 | |
| 3337 | static struct msm_gpio dtv_panel_irq_gpios[] = { |
| 3338 | { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), |
| 3339 | "hdmi_int" }, |
| 3340 | }; |
| 3341 | |
| 3342 | static struct msm_gpio dtv_panel_gpios[] = { |
| 3343 | { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" }, |
| 3344 | { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" }, |
| 3345 | { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" }, |
| 3346 | { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" }, |
| 3347 | { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" }, |
| 3348 | { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" }, |
| 3349 | { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" }, |
| 3350 | { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" }, |
| 3351 | { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" }, |
| 3352 | { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" }, |
| 3353 | { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" }, |
| 3354 | { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" }, |
| 3355 | { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" }, |
| 3356 | { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" }, |
| 3357 | { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" }, |
| 3358 | { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" }, |
| 3359 | { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" }, |
| 3360 | { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" }, |
| 3361 | { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" }, |
| 3362 | { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" }, |
| 3363 | { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" }, |
| 3364 | { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" }, |
| 3365 | { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" }, |
| 3366 | { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" }, |
| 3367 | { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" }, |
| 3368 | { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" }, |
| 3369 | { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" }, |
| 3370 | { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" }, |
| 3371 | { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" }, |
| 3372 | { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" }, |
| 3373 | { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" }, |
| 3374 | { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" }, |
| 3375 | }; |
| 3376 | |
| 3377 | |
| 3378 | #ifdef HDMI_RESET |
| 3379 | static unsigned dtv_reset_gpio = |
| 3380 | GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA); |
| 3381 | #endif |
| 3382 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3383 | static struct regulator_bulk_data hdmi_core_regs[] = { |
| 3384 | { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 }, |
| 3385 | }; |
| 3386 | |
| 3387 | static struct regulator_bulk_data hdmi_comm_regs[] = { |
| 3388 | { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 }, |
| 3389 | { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 }, |
| 3390 | }; |
| 3391 | |
| 3392 | static struct regulator_bulk_data hdmi_cec_regs[] = { |
| 3393 | { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 }, |
| 3394 | }; |
| 3395 | |
| 3396 | static int __init hdmi_init_regs(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3397 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3398 | int rc; |
| 3399 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3400 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs), |
| 3401 | hdmi_core_regs); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3402 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3403 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3404 | pr_err("%s: could not get %s regulators: %d\n", |
| 3405 | __func__, "core", rc); |
| 3406 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3407 | } |
| 3408 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3409 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs), |
| 3410 | hdmi_core_regs); |
| 3411 | |
| 3412 | if (rc) { |
| 3413 | pr_err("%s: could not set %s voltages: %d\n", |
| 3414 | __func__, "core", rc); |
| 3415 | goto free_core; |
| 3416 | } |
| 3417 | |
| 3418 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs), |
| 3419 | hdmi_comm_regs); |
| 3420 | |
| 3421 | if (rc) { |
| 3422 | pr_err("%s: could not get %s regulators: %d\n", |
| 3423 | __func__, "comm", rc); |
| 3424 | goto free_core; |
| 3425 | } |
| 3426 | |
| 3427 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs), |
| 3428 | hdmi_comm_regs); |
| 3429 | |
| 3430 | if (rc) { |
| 3431 | pr_err("%s: could not set %s voltages: %d\n", |
| 3432 | __func__, "comm", rc); |
| 3433 | goto free_comm; |
| 3434 | } |
| 3435 | |
| 3436 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs), |
| 3437 | hdmi_cec_regs); |
| 3438 | |
| 3439 | if (rc) { |
| 3440 | pr_err("%s: could not get %s regulators: %d\n", |
| 3441 | __func__, "cec", rc); |
| 3442 | goto free_comm; |
| 3443 | } |
| 3444 | |
| 3445 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs), |
| 3446 | hdmi_cec_regs); |
| 3447 | |
| 3448 | if (rc) { |
| 3449 | pr_err("%s: could not set %s voltages: %d\n", |
| 3450 | __func__, "cec", rc); |
| 3451 | goto free_cec; |
| 3452 | } |
| 3453 | |
| 3454 | return 0; |
| 3455 | |
| 3456 | free_cec: |
| 3457 | regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs); |
| 3458 | free_comm: |
| 3459 | regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs); |
| 3460 | free_core: |
| 3461 | regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs); |
| 3462 | out: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3463 | return rc; |
| 3464 | } |
| 3465 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3466 | static int hdmi_init_irq(void) |
| 3467 | { |
| 3468 | int rc = msm_gpios_enable(dtv_panel_irq_gpios, |
| 3469 | ARRAY_SIZE(dtv_panel_irq_gpios)); |
| 3470 | if (rc < 0) { |
| 3471 | pr_err("%s: gpio enable failed: %d\n", __func__, rc); |
| 3472 | return rc; |
| 3473 | } |
| 3474 | pr_info("%s\n", __func__); |
| 3475 | |
| 3476 | return 0; |
| 3477 | } |
| 3478 | |
| 3479 | static int hdmi_enable_5v(int on) |
| 3480 | { |
| 3481 | int pmic_gpio_hdmi_5v_en ; |
| 3482 | |
| 3483 | if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() || |
| 3484 | machine_is_msm7x30_fluid()) |
| 3485 | pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ; |
| 3486 | else |
| 3487 | pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ; |
| 3488 | |
| 3489 | pr_info("%s: %d\n", __func__, on); |
| 3490 | if (on) { |
| 3491 | int rc; |
| 3492 | rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), |
| 3493 | "hdmi_5V_en"); |
| 3494 | if (rc) { |
| 3495 | pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n", |
| 3496 | __func__); |
| 3497 | return rc; |
| 3498 | } |
| 3499 | gpio_set_value_cansleep( |
| 3500 | PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1); |
| 3501 | } else { |
| 3502 | gpio_set_value_cansleep( |
| 3503 | PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0); |
| 3504 | gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en)); |
| 3505 | } |
| 3506 | return 0; |
| 3507 | } |
| 3508 | |
| 3509 | static int hdmi_comm_power(int on, int show) |
| 3510 | { |
| 3511 | if (show) |
| 3512 | pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on); |
| 3513 | return on ? |
| 3514 | regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs), |
| 3515 | hdmi_comm_regs) : |
| 3516 | regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs), |
| 3517 | hdmi_comm_regs); |
| 3518 | } |
| 3519 | |
| 3520 | static int hdmi_core_power(int on, int show) |
| 3521 | { |
| 3522 | if (show) |
| 3523 | pr_info("%s: %d <LDO8>\n", __func__, on); |
| 3524 | return on ? |
| 3525 | regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs), |
| 3526 | hdmi_core_regs) : |
| 3527 | regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs), |
| 3528 | hdmi_core_regs); |
| 3529 | } |
| 3530 | |
| 3531 | static int hdmi_cec_power(int on) |
| 3532 | { |
| 3533 | pr_info("%s: %d <LDO17>\n", __func__, on); |
| 3534 | return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs), |
| 3535 | hdmi_cec_regs) : |
| 3536 | regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs), |
| 3537 | hdmi_cec_regs); |
| 3538 | } |
| 3539 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3540 | #if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150) |
| 3541 | /* there is an i2c address conflict between adv7520 and bma150 sensor after |
| 3542 | * power up on fluid. As a solution, the default address of adv7520's packet |
| 3543 | * memory is changed as soon as possible |
| 3544 | */ |
| 3545 | static int __init fluid_i2c_address_fixup(void) |
| 3546 | { |
| 3547 | unsigned char wBuff[16]; |
| 3548 | unsigned char rBuff[16]; |
| 3549 | struct i2c_msg msgs[3]; |
| 3550 | int res; |
| 3551 | int rc = -EINVAL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3552 | struct i2c_adapter *adapter; |
| 3553 | |
| 3554 | if (machine_is_msm7x30_fluid()) { |
| 3555 | adapter = i2c_get_adapter(0); |
| 3556 | if (!adapter) { |
| 3557 | pr_err("%s: invalid i2c adapter\n", __func__); |
| 3558 | return PTR_ERR(adapter); |
| 3559 | } |
| 3560 | |
| 3561 | /* turn on LDO8 */ |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3562 | rc = hdmi_core_power(1, 0); |
| 3563 | if (rc) { |
| 3564 | pr_err("%s: could not enable hdmi core regs: %d", |
| 3565 | __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3566 | goto adapter_put; |
| 3567 | } |
| 3568 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3569 | /* change packet memory address to 0x74 */ |
| 3570 | wBuff[0] = 0x45; |
| 3571 | wBuff[1] = 0x74; |
| 3572 | |
| 3573 | msgs[0].addr = ADV7520_I2C_ADDR; |
| 3574 | msgs[0].flags = 0; |
| 3575 | msgs[0].buf = (unsigned char *) wBuff; |
| 3576 | msgs[0].len = 2; |
| 3577 | |
| 3578 | res = i2c_transfer(adapter, msgs, 1); |
| 3579 | if (res != 1) { |
| 3580 | pr_err("%s: error writing adv7520\n", __func__); |
| 3581 | goto ldo8_disable; |
| 3582 | } |
| 3583 | |
| 3584 | /* powerdown adv7520 using bit 6 */ |
| 3585 | /* i2c read first */ |
| 3586 | wBuff[0] = 0x41; |
| 3587 | |
| 3588 | msgs[0].addr = ADV7520_I2C_ADDR; |
| 3589 | msgs[0].flags = 0; |
| 3590 | msgs[0].buf = (unsigned char *) wBuff; |
| 3591 | msgs[0].len = 1; |
| 3592 | |
| 3593 | msgs[1].addr = ADV7520_I2C_ADDR; |
| 3594 | msgs[1].flags = I2C_M_RD; |
| 3595 | msgs[1].buf = rBuff; |
| 3596 | msgs[1].len = 1; |
| 3597 | res = i2c_transfer(adapter, msgs, 2); |
| 3598 | if (res != 2) { |
| 3599 | pr_err("%s: error reading adv7520\n", __func__); |
| 3600 | goto ldo8_disable; |
| 3601 | } |
| 3602 | |
| 3603 | /* i2c write back */ |
| 3604 | wBuff[0] = 0x41; |
| 3605 | wBuff[1] = rBuff[0] | 0x40; |
| 3606 | |
| 3607 | msgs[0].addr = ADV7520_I2C_ADDR; |
| 3608 | msgs[0].flags = 0; |
| 3609 | msgs[0].buf = (unsigned char *) wBuff; |
| 3610 | msgs[0].len = 2; |
| 3611 | |
| 3612 | res = i2c_transfer(adapter, msgs, 1); |
| 3613 | if (res != 1) { |
| 3614 | pr_err("%s: error writing adv7520\n", __func__); |
| 3615 | goto ldo8_disable; |
| 3616 | } |
| 3617 | |
| 3618 | /* for successful fixup, we release the i2c adapter */ |
| 3619 | /* but leave ldo8 on so that the adv7520 is not repowered */ |
| 3620 | i2c_put_adapter(adapter); |
| 3621 | pr_info("%s: fluid i2c address conflict resolved\n", __func__); |
| 3622 | } |
| 3623 | return 0; |
| 3624 | |
| 3625 | ldo8_disable: |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3626 | hdmi_core_power(0, 0); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3627 | adapter_put: |
| 3628 | i2c_put_adapter(adapter); |
| 3629 | return rc; |
| 3630 | } |
| 3631 | fs_initcall_sync(fluid_i2c_address_fixup); |
| 3632 | #endif |
| 3633 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3634 | static bool hdmi_check_hdcp_hw_support(void) |
| 3635 | { |
| 3636 | if (machine_is_msm7x30_fluid()) |
| 3637 | return false; |
| 3638 | else |
| 3639 | return true; |
| 3640 | } |
| 3641 | |
| 3642 | static int dtv_panel_power(int on) |
| 3643 | { |
| 3644 | int flag_on = !!on; |
| 3645 | static int dtv_power_save_on; |
| 3646 | int rc; |
| 3647 | |
| 3648 | if (dtv_power_save_on == flag_on) |
| 3649 | return 0; |
| 3650 | |
| 3651 | dtv_power_save_on = flag_on; |
| 3652 | pr_info("%s: %d\n", __func__, on); |
| 3653 | |
| 3654 | #ifdef HDMI_RESET |
| 3655 | if (on) { |
| 3656 | /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */ |
| 3657 | rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE); |
| 3658 | if (rc) { |
| 3659 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 3660 | __func__, dtv_reset_gpio, rc); |
| 3661 | return rc; |
| 3662 | } |
| 3663 | |
| 3664 | /* bring reset line low to hold reset*/ |
| 3665 | gpio_set_value(37, 0); |
| 3666 | } |
| 3667 | #endif |
| 3668 | |
| 3669 | if (on) { |
| 3670 | rc = msm_gpios_enable(dtv_panel_gpios, |
| 3671 | ARRAY_SIZE(dtv_panel_gpios)); |
| 3672 | if (rc < 0) { |
| 3673 | printk(KERN_ERR "%s: gpio enable failed: %d\n", |
| 3674 | __func__, rc); |
| 3675 | return rc; |
| 3676 | } |
| 3677 | } else { |
| 3678 | rc = msm_gpios_disable(dtv_panel_gpios, |
| 3679 | ARRAY_SIZE(dtv_panel_gpios)); |
| 3680 | if (rc < 0) { |
| 3681 | printk(KERN_ERR "%s: gpio disable failed: %d\n", |
| 3682 | __func__, rc); |
| 3683 | return rc; |
| 3684 | } |
| 3685 | } |
| 3686 | |
| 3687 | mdelay(5); /* ensure power is stable */ |
| 3688 | |
| 3689 | #ifdef HDMI_RESET |
| 3690 | if (on) { |
| 3691 | gpio_set_value(37, 1); /* bring reset line high */ |
| 3692 | mdelay(10); /* 10 msec before IO can be accessed */ |
| 3693 | } |
| 3694 | #endif |
| 3695 | |
| 3696 | return rc; |
| 3697 | } |
| 3698 | |
| 3699 | static struct lcdc_platform_data dtv_pdata = { |
| 3700 | .lcdc_power_save = dtv_panel_power, |
| 3701 | }; |
| 3702 | |
| 3703 | static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = { |
| 3704 | .inject_rx_on_wakeup = 1, |
| 3705 | .rx_to_inject = 0xFD, |
| 3706 | }; |
| 3707 | |
| 3708 | static struct resource msm_fb_resources[] = { |
| 3709 | { |
| 3710 | .flags = IORESOURCE_DMA, |
| 3711 | } |
| 3712 | }; |
| 3713 | |
| 3714 | static int msm_fb_detect_panel(const char *name) |
| 3715 | { |
| 3716 | if (machine_is_msm7x30_fluid()) { |
| 3717 | if (!strcmp(name, "lcdc_sharp_wvga_pt")) |
| 3718 | return 0; |
| 3719 | } else { |
| 3720 | if (!strncmp(name, "mddi_toshiba_wvga_pt", 20)) |
| 3721 | return -EPERM; |
| 3722 | else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20)) |
| 3723 | return 0; |
| 3724 | else if (!strcmp(name, "mddi_orise")) |
| 3725 | return -EPERM; |
| 3726 | else if (!strcmp(name, "mddi_quickvx")) |
| 3727 | return -EPERM; |
| 3728 | } |
| 3729 | return -ENODEV; |
| 3730 | } |
| 3731 | |
| 3732 | static struct msm_fb_platform_data msm_fb_pdata = { |
| 3733 | .detect_client = msm_fb_detect_panel, |
| 3734 | .mddi_prescan = 1, |
| 3735 | }; |
| 3736 | |
| 3737 | static struct platform_device msm_fb_device = { |
| 3738 | .name = "msm_fb", |
| 3739 | .id = 0, |
| 3740 | .num_resources = ARRAY_SIZE(msm_fb_resources), |
| 3741 | .resource = msm_fb_resources, |
| 3742 | .dev = { |
| 3743 | .platform_data = &msm_fb_pdata, |
| 3744 | } |
| 3745 | }; |
| 3746 | |
| 3747 | static struct platform_device msm_migrate_pages_device = { |
| 3748 | .name = "msm_migrate_pages", |
| 3749 | .id = -1, |
| 3750 | }; |
| 3751 | |
| 3752 | static struct android_pmem_platform_data android_pmem_adsp_pdata = { |
| 3753 | .name = "pmem_adsp", |
| 3754 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 3755 | .cached = 0, |
| 3756 | .memory_type = MEMTYPE_EBI0, |
| 3757 | }; |
| 3758 | |
| 3759 | static struct android_pmem_platform_data android_pmem_audio_pdata = { |
| 3760 | .name = "pmem_audio", |
| 3761 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 3762 | .cached = 0, |
| 3763 | .memory_type = MEMTYPE_EBI0, |
| 3764 | }; |
| 3765 | |
| 3766 | static struct platform_device android_pmem_adsp_device = { |
| 3767 | .name = "android_pmem", |
| 3768 | .id = 2, |
| 3769 | .dev = { .platform_data = &android_pmem_adsp_pdata }, |
| 3770 | }; |
| 3771 | |
| 3772 | static struct platform_device android_pmem_audio_device = { |
| 3773 | .name = "android_pmem", |
| 3774 | .id = 4, |
| 3775 | .dev = { .platform_data = &android_pmem_audio_pdata }, |
| 3776 | }; |
| 3777 | |
| 3778 | #if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \ |
| 3779 | defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \ |
| 3780 | defined(CONFIG_CRYPTO_DEV_QCEDEV) || \ |
| 3781 | defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE) |
| 3782 | |
| 3783 | #define QCE_SIZE 0x10000 |
| 3784 | #define QCE_0_BASE 0xA8400000 |
| 3785 | |
| 3786 | #define QCE_HW_KEY_SUPPORT 1 |
| 3787 | #define QCE_SHA_HMAC_SUPPORT 0 |
| 3788 | #define QCE_SHARE_CE_RESOURCE 0 |
| 3789 | #define QCE_CE_SHARED 0 |
| 3790 | |
| 3791 | static struct resource qcrypto_resources[] = { |
| 3792 | [0] = { |
| 3793 | .start = QCE_0_BASE, |
| 3794 | .end = QCE_0_BASE + QCE_SIZE - 1, |
| 3795 | .flags = IORESOURCE_MEM, |
| 3796 | }, |
| 3797 | [1] = { |
| 3798 | .name = "crypto_channels", |
| 3799 | .start = DMOV_CE_IN_CHAN, |
| 3800 | .end = DMOV_CE_OUT_CHAN, |
| 3801 | .flags = IORESOURCE_DMA, |
| 3802 | }, |
| 3803 | [2] = { |
| 3804 | .name = "crypto_crci_in", |
| 3805 | .start = DMOV_CE_IN_CRCI, |
| 3806 | .end = DMOV_CE_IN_CRCI, |
| 3807 | .flags = IORESOURCE_DMA, |
| 3808 | }, |
| 3809 | [3] = { |
| 3810 | .name = "crypto_crci_out", |
| 3811 | .start = DMOV_CE_OUT_CRCI, |
| 3812 | .end = DMOV_CE_OUT_CRCI, |
| 3813 | .flags = IORESOURCE_DMA, |
| 3814 | }, |
| 3815 | [4] = { |
| 3816 | .name = "crypto_crci_hash", |
| 3817 | .start = DMOV_CE_HASH_CRCI, |
| 3818 | .end = DMOV_CE_HASH_CRCI, |
| 3819 | .flags = IORESOURCE_DMA, |
| 3820 | }, |
| 3821 | }; |
| 3822 | |
| 3823 | static struct resource qcedev_resources[] = { |
| 3824 | [0] = { |
| 3825 | .start = QCE_0_BASE, |
| 3826 | .end = QCE_0_BASE + QCE_SIZE - 1, |
| 3827 | .flags = IORESOURCE_MEM, |
| 3828 | }, |
| 3829 | [1] = { |
| 3830 | .name = "crypto_channels", |
| 3831 | .start = DMOV_CE_IN_CHAN, |
| 3832 | .end = DMOV_CE_OUT_CHAN, |
| 3833 | .flags = IORESOURCE_DMA, |
| 3834 | }, |
| 3835 | [2] = { |
| 3836 | .name = "crypto_crci_in", |
| 3837 | .start = DMOV_CE_IN_CRCI, |
| 3838 | .end = DMOV_CE_IN_CRCI, |
| 3839 | .flags = IORESOURCE_DMA, |
| 3840 | }, |
| 3841 | [3] = { |
| 3842 | .name = "crypto_crci_out", |
| 3843 | .start = DMOV_CE_OUT_CRCI, |
| 3844 | .end = DMOV_CE_OUT_CRCI, |
| 3845 | .flags = IORESOURCE_DMA, |
| 3846 | }, |
| 3847 | [4] = { |
| 3848 | .name = "crypto_crci_hash", |
| 3849 | .start = DMOV_CE_HASH_CRCI, |
| 3850 | .end = DMOV_CE_HASH_CRCI, |
| 3851 | .flags = IORESOURCE_DMA, |
| 3852 | }, |
| 3853 | }; |
| 3854 | |
| 3855 | #endif |
| 3856 | |
| 3857 | #if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \ |
| 3858 | defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) |
| 3859 | |
| 3860 | static struct msm_ce_hw_support qcrypto_ce_hw_suppport = { |
| 3861 | .ce_shared = QCE_CE_SHARED, |
| 3862 | .shared_ce_resource = QCE_SHARE_CE_RESOURCE, |
| 3863 | .hw_key_support = QCE_HW_KEY_SUPPORT, |
| 3864 | .sha_hmac = QCE_SHA_HMAC_SUPPORT, |
Ramesh Masavarapu | 4925968 | 2011-12-02 14:00:18 -0800 | [diff] [blame^] | 3865 | /* Bus Scaling declaration*/ |
| 3866 | .bus_scale_table = NULL, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3867 | }; |
| 3868 | |
| 3869 | static struct platform_device qcrypto_device = { |
| 3870 | .name = "qcrypto", |
| 3871 | .id = 0, |
| 3872 | .num_resources = ARRAY_SIZE(qcrypto_resources), |
| 3873 | .resource = qcrypto_resources, |
| 3874 | .dev = { |
| 3875 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 3876 | .platform_data = &qcrypto_ce_hw_suppport, |
| 3877 | }, |
| 3878 | }; |
| 3879 | #endif |
| 3880 | |
| 3881 | #if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \ |
| 3882 | defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE) |
| 3883 | |
| 3884 | static struct msm_ce_hw_support qcedev_ce_hw_suppport = { |
| 3885 | .ce_shared = QCE_CE_SHARED, |
| 3886 | .shared_ce_resource = QCE_SHARE_CE_RESOURCE, |
| 3887 | .hw_key_support = QCE_HW_KEY_SUPPORT, |
| 3888 | .sha_hmac = QCE_SHA_HMAC_SUPPORT, |
Ramesh Masavarapu | 4925968 | 2011-12-02 14:00:18 -0800 | [diff] [blame^] | 3889 | /* Bus Scaling declaration*/ |
| 3890 | .bus_scale_table = NULL, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3891 | }; |
| 3892 | static struct platform_device qcedev_device = { |
| 3893 | .name = "qce", |
| 3894 | .id = 0, |
| 3895 | .num_resources = ARRAY_SIZE(qcedev_resources), |
| 3896 | .resource = qcedev_resources, |
| 3897 | .dev = { |
| 3898 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 3899 | .platform_data = &qcedev_ce_hw_suppport, |
| 3900 | }, |
| 3901 | }; |
| 3902 | #endif |
| 3903 | |
| 3904 | static int mddi_toshiba_pmic_bl(int level) |
| 3905 | { |
| 3906 | int ret = -EPERM; |
| 3907 | |
| 3908 | ret = pmic_set_led_intensity(LED_LCD, level); |
| 3909 | |
| 3910 | if (ret) |
| 3911 | printk(KERN_WARNING "%s: can't set lcd backlight!\n", |
| 3912 | __func__); |
| 3913 | return ret; |
| 3914 | } |
| 3915 | |
| 3916 | static struct msm_panel_common_pdata mddi_toshiba_pdata = { |
| 3917 | .pmic_backlight = mddi_toshiba_pmic_bl, |
| 3918 | }; |
| 3919 | |
| 3920 | static struct platform_device mddi_toshiba_device = { |
| 3921 | .name = "mddi_toshiba", |
| 3922 | .id = 0, |
| 3923 | .dev = { |
| 3924 | .platform_data = &mddi_toshiba_pdata, |
| 3925 | } |
| 3926 | }; |
| 3927 | |
| 3928 | static unsigned wega_reset_gpio = |
| 3929 | GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA); |
| 3930 | |
| 3931 | static struct msm_gpio fluid_vee_reset_gpio[] = { |
| 3932 | { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" }, |
| 3933 | }; |
| 3934 | |
| 3935 | static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1; |
| 3936 | static unsigned char quickvx_ldo_enabled; |
| 3937 | |
| 3938 | static unsigned quickvx_vlp_gpio = |
| 3939 | GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA); |
| 3940 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 3941 | static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = { |
| 3942 | PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK), |
| 3943 | { |
| 3944 | .direction = PM_GPIO_DIR_OUT, |
| 3945 | .output_buffer = PM_GPIO_OUT_BUF_CMOS, |
| 3946 | .output_value = 1, |
| 3947 | .pull = PM_GPIO_PULL_NO, |
| 3948 | .vin_sel = PM8058_GPIO_VIN_S3, |
| 3949 | .out_strength = PM_GPIO_STRENGTH_HIGH, |
| 3950 | .function = PM_GPIO_FUNC_2, |
| 3951 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3952 | }; |
| 3953 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 3954 | static struct regulator *mddi_ldo20; |
| 3955 | static struct regulator *mddi_ldo12; |
| 3956 | static struct regulator *mddi_ldo16; |
| 3957 | static struct regulator *mddi_ldo6; |
| 3958 | static struct regulator *mddi_lcd; |
| 3959 | |
| 3960 | static int display_common_init(void) |
| 3961 | { |
| 3962 | struct regulator_bulk_data regs[5] = { |
| 3963 | { .supply = "ldo20", /* voltage set in display_common_power */}, |
| 3964 | { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 }, |
| 3965 | { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 }, |
| 3966 | { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 }, |
| 3967 | { .supply = NULL, /* mddi_lcd, initialized below */ }, |
| 3968 | }; |
| 3969 | |
| 3970 | int rc = 0; |
| 3971 | |
| 3972 | if (machine_is_msm7x30_fluid()) { |
| 3973 | /* lcd: LDO8 @1.8V */ |
| 3974 | regs[4].supply = "ldo8"; |
| 3975 | regs[4].min_uV = 1800000; |
| 3976 | regs[4].max_uV = 1800000; |
| 3977 | } else { |
| 3978 | /* lcd: LDO15 @3.1V */ |
| 3979 | regs[4].supply = "ldo15"; |
| 3980 | regs[4].min_uV = 3100000; |
| 3981 | regs[4].max_uV = 3100000; |
| 3982 | } |
| 3983 | |
| 3984 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs); |
| 3985 | if (rc) { |
| 3986 | pr_err("%s: regulator_bulk_get failed: %d\n", |
| 3987 | __func__, rc); |
| 3988 | goto bail; |
| 3989 | } |
| 3990 | |
| 3991 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs); |
| 3992 | if (rc) { |
| 3993 | pr_err("%s: regulator_bulk_set_voltage failed: %d\n", |
| 3994 | __func__, rc); |
| 3995 | goto put_regs; |
| 3996 | } |
| 3997 | |
| 3998 | mddi_ldo20 = regs[0].consumer; |
| 3999 | mddi_ldo12 = regs[1].consumer; |
| 4000 | mddi_ldo6 = regs[2].consumer; |
| 4001 | mddi_ldo16 = regs[3].consumer; |
| 4002 | mddi_lcd = regs[4].consumer; |
| 4003 | |
| 4004 | return rc; |
| 4005 | |
| 4006 | put_regs: |
| 4007 | regulator_bulk_free(ARRAY_SIZE(regs), regs); |
| 4008 | bail: |
| 4009 | return rc; |
| 4010 | } |
| 4011 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4012 | static int display_common_power(int on) |
| 4013 | { |
| 4014 | int rc = 0, flag_on = !!on; |
| 4015 | static int display_common_power_save_on; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4016 | static bool display_regs_initialized; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4017 | |
| 4018 | if (display_common_power_save_on == flag_on) |
| 4019 | return 0; |
| 4020 | |
| 4021 | display_common_power_save_on = flag_on; |
| 4022 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4023 | if (unlikely(!display_regs_initialized)) { |
| 4024 | rc = display_common_init(); |
| 4025 | if (rc) { |
| 4026 | pr_err("%s: regulator init failed: %d\n", |
| 4027 | __func__, rc); |
| 4028 | return rc; |
| 4029 | } |
| 4030 | display_regs_initialized = true; |
| 4031 | } |
| 4032 | |
| 4033 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4034 | if (on) { |
| 4035 | /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */ |
| 4036 | rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE); |
| 4037 | if (rc) { |
| 4038 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 4039 | __func__, wega_reset_gpio, rc); |
| 4040 | return rc; |
| 4041 | } |
| 4042 | |
| 4043 | /* bring reset line low to hold reset*/ |
| 4044 | gpio_set_value(180, 0); |
| 4045 | |
| 4046 | if (quickvx_mddi_client) { |
| 4047 | /* QuickVX chip -- VLP pin -- gpio 97 */ |
| 4048 | rc = gpio_tlmm_config(quickvx_vlp_gpio, |
| 4049 | GPIO_CFG_ENABLE); |
| 4050 | if (rc) { |
| 4051 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 4052 | __func__, quickvx_vlp_gpio, rc); |
| 4053 | return rc; |
| 4054 | } |
| 4055 | |
| 4056 | /* bring QuickVX VLP line low */ |
| 4057 | gpio_set_value(97, 0); |
| 4058 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 4059 | rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio, |
| 4060 | &pmic_quickvx_clk_gpio.config); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4061 | if (rc) { |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 4062 | pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n", |
| 4063 | __func__, pmic_quickvx_clk_gpio.gpio, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4064 | rc); |
| 4065 | return rc; |
| 4066 | } |
| 4067 | |
| 4068 | gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS( |
| 4069 | PMIC_GPIO_QUICKVX_CLK), 0); |
| 4070 | } |
| 4071 | } |
| 4072 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4073 | if (quickvx_mddi_client) |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4074 | rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4075 | else |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4076 | rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000); |
| 4077 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4078 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4079 | pr_err("%s: could not set voltage for ldo20: %d\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4080 | __func__, rc); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4081 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4082 | } |
| 4083 | |
| 4084 | if (on) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4085 | rc = regulator_enable(mddi_ldo20); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4086 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4087 | pr_err("%s: LDO20 regulator enable failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4088 | __func__, rc); |
| 4089 | return rc; |
| 4090 | } |
| 4091 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4092 | rc = regulator_enable(mddi_ldo12); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4093 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4094 | pr_err("%s: LDO12 regulator enable failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4095 | __func__, rc); |
| 4096 | return rc; |
| 4097 | } |
| 4098 | |
| 4099 | if (other_mddi_client) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4100 | rc = regulator_enable(mddi_ldo16); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4101 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4102 | pr_err("%s: LDO16 regulator enable failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4103 | __func__, rc); |
| 4104 | return rc; |
| 4105 | } |
| 4106 | } |
| 4107 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4108 | if (quickvx_ldo_enabled) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4109 | /* Disable LDO6 during display ON */ |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4110 | rc = regulator_disable(mddi_ldo6); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4111 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4112 | pr_err("%s: LDO6 regulator disable failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4113 | __func__, rc); |
| 4114 | return rc; |
| 4115 | } |
| 4116 | quickvx_ldo_enabled = 0; |
| 4117 | } |
| 4118 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4119 | rc = regulator_enable(mddi_lcd); |
| 4120 | if (rc) { |
| 4121 | pr_err("%s: LCD regulator enable failed (%d)\n", |
| 4122 | __func__, rc); |
| 4123 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4124 | } |
| 4125 | |
| 4126 | mdelay(5); /* ensure power is stable */ |
| 4127 | |
| 4128 | if (machine_is_msm7x30_fluid()) { |
| 4129 | rc = msm_gpios_request_enable(fluid_vee_reset_gpio, |
| 4130 | ARRAY_SIZE(fluid_vee_reset_gpio)); |
| 4131 | if (rc) |
| 4132 | pr_err("%s gpio_request_enable failed rc=%d\n", |
| 4133 | __func__, rc); |
| 4134 | else { |
| 4135 | /* assert vee reset_n */ |
| 4136 | gpio_set_value(20, 1); |
| 4137 | gpio_set_value(20, 0); |
| 4138 | mdelay(1); |
| 4139 | gpio_set_value(20, 1); |
| 4140 | } |
| 4141 | } |
| 4142 | |
| 4143 | gpio_set_value(180, 1); /* bring reset line high */ |
| 4144 | mdelay(10); /* 10 msec before IO can be accessed */ |
| 4145 | |
| 4146 | if (quickvx_mddi_client) { |
| 4147 | gpio_set_value(97, 1); |
| 4148 | msleep(2); |
| 4149 | gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS( |
| 4150 | PMIC_GPIO_QUICKVX_CLK), 1); |
| 4151 | msleep(2); |
| 4152 | } |
| 4153 | |
| 4154 | rc = pmapp_display_clock_config(1); |
| 4155 | if (rc) { |
| 4156 | pr_err("%s pmapp_display_clock_config rc=%d\n", |
| 4157 | __func__, rc); |
| 4158 | return rc; |
| 4159 | } |
| 4160 | |
| 4161 | } else { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4162 | rc = regulator_disable(mddi_ldo20); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4163 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4164 | pr_err("%s: LDO20 regulator disable failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4165 | __func__, rc); |
| 4166 | return rc; |
| 4167 | } |
| 4168 | |
| 4169 | |
| 4170 | if (other_mddi_client) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4171 | rc = regulator_disable(mddi_ldo16); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4172 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4173 | pr_err("%s: LDO16 regulator disable failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4174 | __func__, rc); |
| 4175 | return rc; |
| 4176 | } |
| 4177 | } |
| 4178 | |
| 4179 | if (quickvx_mddi_client && !quickvx_ldo_enabled) { |
| 4180 | /* Enable LDO6 during display OFF for |
| 4181 | Quicklogic chip to sleep with data retention */ |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4182 | rc = regulator_enable(mddi_ldo6); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4183 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4184 | pr_err("%s: LDO6 regulator enable failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4185 | __func__, rc); |
| 4186 | return rc; |
| 4187 | } |
| 4188 | quickvx_ldo_enabled = 1; |
| 4189 | } |
| 4190 | |
| 4191 | gpio_set_value(180, 0); /* bring reset line low */ |
| 4192 | |
| 4193 | if (quickvx_mddi_client) { |
| 4194 | gpio_set_value(97, 0); |
| 4195 | gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS( |
| 4196 | PMIC_GPIO_QUICKVX_CLK), 0); |
| 4197 | } |
| 4198 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4199 | rc = regulator_disable(mddi_lcd); |
| 4200 | if (rc) { |
| 4201 | pr_err("%s: LCD regulator disable failed (%d)\n", |
| 4202 | __func__, rc); |
| 4203 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4204 | } |
| 4205 | |
| 4206 | mdelay(5); /* ensure power is stable */ |
| 4207 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4208 | rc = regulator_disable(mddi_ldo12); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4209 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4210 | pr_err("%s: LDO12 regulator disable failed (%d)\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4211 | __func__, rc); |
| 4212 | return rc; |
| 4213 | } |
| 4214 | |
| 4215 | if (machine_is_msm7x30_fluid()) { |
| 4216 | msm_gpios_disable_free(fluid_vee_reset_gpio, |
| 4217 | ARRAY_SIZE(fluid_vee_reset_gpio)); |
| 4218 | } |
| 4219 | |
| 4220 | rc = pmapp_display_clock_config(0); |
| 4221 | if (rc) { |
| 4222 | pr_err("%s pmapp_display_clock_config rc=%d\n", |
| 4223 | __func__, rc); |
| 4224 | return rc; |
| 4225 | } |
| 4226 | } |
| 4227 | |
| 4228 | return rc; |
| 4229 | } |
| 4230 | |
| 4231 | static int msm_fb_mddi_sel_clk(u32 *clk_rate) |
| 4232 | { |
| 4233 | *clk_rate *= 2; |
| 4234 | return 0; |
| 4235 | } |
| 4236 | |
| 4237 | static int msm_fb_mddi_client_power(u32 client_id) |
| 4238 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4239 | printk(KERN_NOTICE "\n client_id = 0x%x", client_id); |
| 4240 | /* Check if it is Quicklogic client */ |
| 4241 | if (client_id == 0xc5835800) { |
| 4242 | printk(KERN_NOTICE "\n Quicklogic MDDI client"); |
| 4243 | other_mddi_client = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4244 | } else { |
| 4245 | printk(KERN_NOTICE "\n Non-Quicklogic MDDI client"); |
| 4246 | quickvx_mddi_client = 0; |
| 4247 | gpio_set_value(97, 0); |
| 4248 | gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS( |
| 4249 | PMIC_GPIO_QUICKVX_CLK), 0); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4250 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4251 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4252 | return 0; |
| 4253 | } |
| 4254 | |
| 4255 | static struct mddi_platform_data mddi_pdata = { |
| 4256 | .mddi_power_save = display_common_power, |
| 4257 | .mddi_sel_clk = msm_fb_mddi_sel_clk, |
| 4258 | .mddi_client_power = msm_fb_mddi_client_power, |
| 4259 | }; |
| 4260 | |
| 4261 | int mdp_core_clk_rate_table[] = { |
| 4262 | 122880000, |
| 4263 | 122880000, |
Pradeep Jilagam | 3cc12f9 | 2011-07-26 22:25:18 +0530 | [diff] [blame] | 4264 | 192000000, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4265 | 192000000, |
| 4266 | }; |
| 4267 | |
| 4268 | static struct msm_panel_common_pdata mdp_pdata = { |
| 4269 | .hw_revision_addr = 0xac001270, |
| 4270 | .gpio = 30, |
| 4271 | .mdp_core_clk_rate = 122880000, |
| 4272 | .mdp_core_clk_table = mdp_core_clk_rate_table, |
| 4273 | .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table), |
Ravishangar Kalyanam | 07ef788 | 2011-08-09 15:50:48 -0700 | [diff] [blame] | 4274 | .mdp_rev = MDP_REV_40, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4275 | }; |
| 4276 | |
| 4277 | static int lcd_panel_spi_gpio_num[] = { |
| 4278 | 45, /* spi_clk */ |
| 4279 | 46, /* spi_cs */ |
| 4280 | 47, /* spi_mosi */ |
| 4281 | 48, /* spi_miso */ |
| 4282 | }; |
| 4283 | |
| 4284 | static struct msm_gpio lcd_panel_gpios[] = { |
| 4285 | /* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as |
| 4286 | * input. if there is a hardware revision; we should reassign this GPIO to a |
| 4287 | * new open line; and removing it will just ensure that this will be missed in |
| 4288 | * the future. |
| 4289 | { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" }, |
| 4290 | */ |
| 4291 | { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" }, |
| 4292 | { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" }, |
| 4293 | { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" }, |
| 4294 | { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" }, |
| 4295 | { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" }, |
| 4296 | { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" }, |
| 4297 | { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" }, |
| 4298 | #ifndef CONFIG_SPI_QSD |
| 4299 | { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" }, |
| 4300 | { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" }, |
| 4301 | { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" }, |
| 4302 | { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" }, |
| 4303 | #endif |
| 4304 | { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" }, |
| 4305 | { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" }, |
| 4306 | { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" }, |
| 4307 | { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" }, |
| 4308 | { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" }, |
| 4309 | { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" }, |
| 4310 | { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" }, |
| 4311 | { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" }, |
| 4312 | { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" }, |
| 4313 | { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" }, |
| 4314 | { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" }, |
| 4315 | { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" }, |
| 4316 | { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" }, |
| 4317 | { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" }, |
| 4318 | { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" }, |
| 4319 | { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" }, |
| 4320 | { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" }, |
| 4321 | { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" }, |
| 4322 | { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" }, |
| 4323 | { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" }, |
| 4324 | }; |
| 4325 | |
| 4326 | static struct msm_gpio lcd_sharp_panel_gpios[] = { |
| 4327 | { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" }, |
| 4328 | { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" }, |
| 4329 | { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" }, |
| 4330 | { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" }, |
| 4331 | { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" }, |
| 4332 | { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" }, |
| 4333 | { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" }, |
| 4334 | { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" }, |
| 4335 | { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" }, |
| 4336 | { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" }, |
| 4337 | { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" }, |
| 4338 | { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" }, |
| 4339 | { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" }, |
| 4340 | { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" }, |
| 4341 | { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" }, |
| 4342 | { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" }, |
| 4343 | { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" }, |
| 4344 | { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" }, |
| 4345 | { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" }, |
| 4346 | { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" }, |
| 4347 | { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" }, |
| 4348 | { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" }, |
| 4349 | }; |
| 4350 | |
| 4351 | static int lcdc_toshiba_panel_power(int on) |
| 4352 | { |
| 4353 | int rc, i; |
| 4354 | struct msm_gpio *gp; |
| 4355 | |
| 4356 | rc = display_common_power(on); |
| 4357 | if (rc < 0) { |
| 4358 | printk(KERN_ERR "%s display_common_power failed: %d\n", |
| 4359 | __func__, rc); |
| 4360 | return rc; |
| 4361 | } |
| 4362 | |
| 4363 | if (on) { |
| 4364 | rc = msm_gpios_enable(lcd_panel_gpios, |
| 4365 | ARRAY_SIZE(lcd_panel_gpios)); |
| 4366 | if (rc < 0) { |
| 4367 | printk(KERN_ERR "%s: gpio enable failed: %d\n", |
| 4368 | __func__, rc); |
| 4369 | } |
| 4370 | } else { /* off */ |
| 4371 | gp = lcd_panel_gpios; |
| 4372 | for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) { |
| 4373 | /* ouput low */ |
| 4374 | gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0); |
| 4375 | gp++; |
| 4376 | } |
| 4377 | } |
| 4378 | |
| 4379 | return rc; |
| 4380 | } |
| 4381 | |
| 4382 | static int lcdc_sharp_panel_power(int on) |
| 4383 | { |
| 4384 | int rc, i; |
| 4385 | struct msm_gpio *gp; |
| 4386 | |
| 4387 | rc = display_common_power(on); |
| 4388 | if (rc < 0) { |
| 4389 | printk(KERN_ERR "%s display_common_power failed: %d\n", |
| 4390 | __func__, rc); |
| 4391 | return rc; |
| 4392 | } |
| 4393 | |
| 4394 | if (on) { |
| 4395 | rc = msm_gpios_enable(lcd_sharp_panel_gpios, |
| 4396 | ARRAY_SIZE(lcd_sharp_panel_gpios)); |
| 4397 | if (rc < 0) { |
| 4398 | printk(KERN_ERR "%s: gpio enable failed: %d\n", |
| 4399 | __func__, rc); |
| 4400 | } |
| 4401 | } else { /* off */ |
| 4402 | gp = lcd_sharp_panel_gpios; |
| 4403 | for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) { |
| 4404 | /* ouput low */ |
| 4405 | gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0); |
| 4406 | gp++; |
| 4407 | } |
| 4408 | } |
| 4409 | |
| 4410 | return rc; |
| 4411 | } |
| 4412 | |
| 4413 | static int lcdc_panel_power(int on) |
| 4414 | { |
| 4415 | int flag_on = !!on; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4416 | static int lcdc_power_save_on, lcdc_power_initialized; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4417 | |
| 4418 | if (lcdc_power_save_on == flag_on) |
| 4419 | return 0; |
| 4420 | |
| 4421 | lcdc_power_save_on = flag_on; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4422 | |
| 4423 | if (unlikely(!lcdc_power_initialized)) { |
| 4424 | quickvx_mddi_client = 0; |
| 4425 | display_common_init(); |
| 4426 | lcdc_power_initialized = 1; |
| 4427 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4428 | |
| 4429 | if (machine_is_msm7x30_fluid()) |
| 4430 | return lcdc_sharp_panel_power(on); |
| 4431 | else |
| 4432 | return lcdc_toshiba_panel_power(on); |
| 4433 | } |
| 4434 | |
| 4435 | static struct lcdc_platform_data lcdc_pdata = { |
| 4436 | .lcdc_power_save = lcdc_panel_power, |
| 4437 | }; |
| 4438 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4439 | static struct regulator *atv_s4, *atv_ldo9; |
| 4440 | |
| 4441 | static int __init atv_dac_power_init(void) |
| 4442 | { |
| 4443 | int rc; |
| 4444 | struct regulator_bulk_data regs[] = { |
| 4445 | { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 }, |
| 4446 | { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 }, |
| 4447 | }; |
| 4448 | |
| 4449 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs); |
| 4450 | |
| 4451 | if (rc) { |
| 4452 | pr_err("%s: could not get regulators: %d\n", __func__, rc); |
| 4453 | goto bail; |
| 4454 | } |
| 4455 | |
| 4456 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs); |
| 4457 | |
| 4458 | if (rc) { |
| 4459 | pr_err("%s: could not set voltages: %d\n", __func__, rc); |
| 4460 | goto reg_free; |
| 4461 | } |
| 4462 | |
| 4463 | atv_s4 = regs[0].consumer; |
| 4464 | atv_ldo9 = regs[1].consumer; |
| 4465 | |
| 4466 | reg_free: |
| 4467 | regulator_bulk_free(ARRAY_SIZE(regs), regs); |
| 4468 | bail: |
| 4469 | return rc; |
| 4470 | } |
| 4471 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4472 | static int atv_dac_power(int on) |
| 4473 | { |
| 4474 | int rc = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4475 | |
| 4476 | if (on) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4477 | rc = regulator_enable(atv_s4); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4478 | if (rc) { |
| 4479 | pr_err("%s: s4 vreg enable failed (%d)\n", |
| 4480 | __func__, rc); |
| 4481 | return rc; |
| 4482 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4483 | rc = regulator_enable(atv_ldo9); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4484 | if (rc) { |
| 4485 | pr_err("%s: ldo9 vreg enable failed (%d)\n", |
| 4486 | __func__, rc); |
| 4487 | return rc; |
| 4488 | } |
| 4489 | } else { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4490 | rc = regulator_disable(atv_ldo9); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4491 | if (rc) { |
| 4492 | pr_err("%s: ldo9 vreg disable failed (%d)\n", |
| 4493 | __func__, rc); |
| 4494 | return rc; |
| 4495 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4496 | rc = regulator_disable(atv_s4); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4497 | if (rc) { |
| 4498 | pr_err("%s: s4 vreg disable failed (%d)\n", |
| 4499 | __func__, rc); |
| 4500 | return rc; |
| 4501 | } |
| 4502 | } |
| 4503 | return rc; |
| 4504 | } |
| 4505 | |
| 4506 | static struct tvenc_platform_data atv_pdata = { |
| 4507 | .poll = 1, |
| 4508 | .pm_vid_en = atv_dac_power, |
| 4509 | }; |
| 4510 | |
| 4511 | static void __init msm_fb_add_devices(void) |
| 4512 | { |
| 4513 | msm_fb_register_device("mdp", &mdp_pdata); |
| 4514 | msm_fb_register_device("pmdh", &mddi_pdata); |
| 4515 | msm_fb_register_device("lcdc", &lcdc_pdata); |
| 4516 | msm_fb_register_device("dtv", &dtv_pdata); |
| 4517 | msm_fb_register_device("tvenc", &atv_pdata); |
| 4518 | #ifdef CONFIG_FB_MSM_TVOUT |
| 4519 | msm_fb_register_device("tvout_device", NULL); |
| 4520 | #endif |
| 4521 | } |
| 4522 | |
| 4523 | static struct msm_panel_common_pdata lcdc_toshiba_panel_data = { |
| 4524 | .gpio_num = lcd_panel_spi_gpio_num, |
| 4525 | }; |
| 4526 | |
| 4527 | static struct platform_device lcdc_toshiba_panel_device = { |
| 4528 | .name = "lcdc_toshiba_wvga", |
| 4529 | .id = 0, |
| 4530 | .dev = { |
| 4531 | .platform_data = &lcdc_toshiba_panel_data, |
| 4532 | } |
| 4533 | }; |
| 4534 | |
| 4535 | #if defined(CONFIG_MARIMBA_CORE) && \ |
| 4536 | (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE)) |
| 4537 | static struct platform_device msm_bt_power_device = { |
| 4538 | .name = "bt_power", |
| 4539 | .id = -1 |
| 4540 | }; |
| 4541 | |
| 4542 | enum { |
| 4543 | BT_RFR, |
| 4544 | BT_CTS, |
| 4545 | BT_RX, |
| 4546 | BT_TX, |
| 4547 | }; |
| 4548 | |
| 4549 | static struct msm_gpio bt_config_power_on[] = { |
| 4550 | { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 4551 | "UART1DM_RFR" }, |
| 4552 | { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 4553 | "UART1DM_CTS" }, |
| 4554 | { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 4555 | "UART1DM_Rx" }, |
| 4556 | { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 4557 | "UART1DM_Tx" } |
| 4558 | }; |
| 4559 | |
| 4560 | static struct msm_gpio bt_config_power_off[] = { |
| 4561 | { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 4562 | "UART1DM_RFR" }, |
| 4563 | { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 4564 | "UART1DM_CTS" }, |
| 4565 | { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 4566 | "UART1DM_Rx" }, |
| 4567 | { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 4568 | "UART1DM_Tx" } |
| 4569 | }; |
| 4570 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4571 | static u8 bahama_version; |
| 4572 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4573 | static struct regulator_bulk_data regs_bt_marimba[] = { |
| 4574 | { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 }, |
| 4575 | { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 }, |
| 4576 | { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 }, |
Pankaj Kumar | a2320de | 2011-11-30 12:55:12 +0530 | [diff] [blame] | 4577 | { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 }, |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4578 | }; |
| 4579 | |
| 4580 | static struct regulator_bulk_data regs_bt_bahama_v1[] = { |
| 4581 | { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 }, |
| 4582 | { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 }, |
| 4583 | { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 }, |
Pankaj Kumar | a2320de | 2011-11-30 12:55:12 +0530 | [diff] [blame] | 4584 | { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 }, |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4585 | }; |
| 4586 | |
| 4587 | static struct regulator_bulk_data regs_bt_bahama_v2[] = { |
| 4588 | { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 }, |
| 4589 | { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 }, |
Pankaj Kumar | a2320de | 2011-11-30 12:55:12 +0530 | [diff] [blame] | 4590 | { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 }, |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4591 | }; |
| 4592 | |
| 4593 | static struct regulator_bulk_data *regs_bt; |
| 4594 | static int regs_bt_count; |
| 4595 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4596 | static int marimba_bt(int on) |
| 4597 | { |
| 4598 | int rc; |
| 4599 | int i; |
| 4600 | struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA }; |
| 4601 | |
| 4602 | struct marimba_config_register { |
| 4603 | u8 reg; |
| 4604 | u8 value; |
| 4605 | u8 mask; |
| 4606 | }; |
| 4607 | |
| 4608 | struct marimba_variant_register { |
| 4609 | const size_t size; |
| 4610 | const struct marimba_config_register *set; |
| 4611 | }; |
| 4612 | |
| 4613 | const struct marimba_config_register *p; |
| 4614 | |
| 4615 | u8 version; |
| 4616 | |
| 4617 | const struct marimba_config_register v10_bt_on[] = { |
| 4618 | { 0xE5, 0x0B, 0x0F }, |
| 4619 | { 0x05, 0x02, 0x07 }, |
| 4620 | { 0x06, 0x88, 0xFF }, |
| 4621 | { 0xE7, 0x21, 0x21 }, |
| 4622 | { 0xE3, 0x38, 0xFF }, |
| 4623 | { 0xE4, 0x06, 0xFF }, |
| 4624 | }; |
| 4625 | |
| 4626 | const struct marimba_config_register v10_bt_off[] = { |
| 4627 | { 0xE5, 0x0B, 0x0F }, |
| 4628 | { 0x05, 0x08, 0x0F }, |
| 4629 | { 0x06, 0x88, 0xFF }, |
| 4630 | { 0xE7, 0x00, 0x21 }, |
| 4631 | { 0xE3, 0x00, 0xFF }, |
| 4632 | { 0xE4, 0x00, 0xFF }, |
| 4633 | }; |
| 4634 | |
| 4635 | const struct marimba_config_register v201_bt_on[] = { |
| 4636 | { 0x05, 0x08, 0x07 }, |
| 4637 | { 0x06, 0x88, 0xFF }, |
| 4638 | { 0xE7, 0x21, 0x21 }, |
| 4639 | { 0xE3, 0x38, 0xFF }, |
| 4640 | { 0xE4, 0x06, 0xFF }, |
| 4641 | }; |
| 4642 | |
| 4643 | const struct marimba_config_register v201_bt_off[] = { |
| 4644 | { 0x05, 0x08, 0x07 }, |
| 4645 | { 0x06, 0x88, 0xFF }, |
| 4646 | { 0xE7, 0x00, 0x21 }, |
| 4647 | { 0xE3, 0x00, 0xFF }, |
| 4648 | { 0xE4, 0x00, 0xFF }, |
| 4649 | }; |
| 4650 | |
| 4651 | const struct marimba_config_register v210_bt_on[] = { |
| 4652 | { 0xE9, 0x01, 0x01 }, |
| 4653 | { 0x06, 0x88, 0xFF }, |
| 4654 | { 0xE7, 0x21, 0x21 }, |
| 4655 | { 0xE3, 0x38, 0xFF }, |
| 4656 | { 0xE4, 0x06, 0xFF }, |
| 4657 | }; |
| 4658 | |
| 4659 | const struct marimba_config_register v210_bt_off[] = { |
| 4660 | { 0x06, 0x88, 0xFF }, |
| 4661 | { 0xE7, 0x00, 0x21 }, |
| 4662 | { 0xE9, 0x00, 0x01 }, |
| 4663 | { 0xE3, 0x00, 0xFF }, |
| 4664 | { 0xE4, 0x00, 0xFF }, |
| 4665 | }; |
| 4666 | |
| 4667 | const struct marimba_variant_register bt_marimba[2][4] = { |
| 4668 | { |
| 4669 | { ARRAY_SIZE(v10_bt_off), v10_bt_off }, |
| 4670 | { 0, NULL }, |
| 4671 | { ARRAY_SIZE(v201_bt_off), v201_bt_off }, |
| 4672 | { ARRAY_SIZE(v210_bt_off), v210_bt_off } |
| 4673 | }, |
| 4674 | { |
| 4675 | { ARRAY_SIZE(v10_bt_on), v10_bt_on }, |
| 4676 | { 0, NULL }, |
| 4677 | { ARRAY_SIZE(v201_bt_on), v201_bt_on }, |
| 4678 | { ARRAY_SIZE(v210_bt_on), v210_bt_on } |
| 4679 | } |
| 4680 | }; |
| 4681 | |
| 4682 | on = on ? 1 : 0; |
| 4683 | |
| 4684 | rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F); |
| 4685 | if (rc < 0) { |
| 4686 | printk(KERN_ERR |
| 4687 | "%s: version read failed: %d\n", |
| 4688 | __func__, rc); |
| 4689 | return rc; |
| 4690 | } |
| 4691 | |
| 4692 | if ((version >= ARRAY_SIZE(bt_marimba[on])) || |
| 4693 | (bt_marimba[on][version].size == 0)) { |
| 4694 | printk(KERN_ERR |
| 4695 | "%s: unsupported version\n", |
| 4696 | __func__); |
| 4697 | return -EIO; |
| 4698 | } |
| 4699 | |
| 4700 | p = bt_marimba[on][version].set; |
| 4701 | |
| 4702 | printk(KERN_INFO "%s: found version %d\n", __func__, version); |
| 4703 | |
| 4704 | for (i = 0; i < bt_marimba[on][version].size; i++) { |
| 4705 | u8 value = (p+i)->value; |
| 4706 | rc = marimba_write_bit_mask(&config, |
| 4707 | (p+i)->reg, |
| 4708 | &value, |
| 4709 | sizeof((p+i)->value), |
| 4710 | (p+i)->mask); |
| 4711 | if (rc < 0) { |
| 4712 | printk(KERN_ERR |
| 4713 | "%s: reg %d write failed: %d\n", |
| 4714 | __func__, (p+i)->reg, rc); |
| 4715 | return rc; |
| 4716 | } |
| 4717 | printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n", |
| 4718 | __func__, (p+i)->reg, |
| 4719 | value, (p+i)->mask); |
| 4720 | } |
| 4721 | return 0; |
| 4722 | } |
| 4723 | |
| 4724 | static int bahama_bt(int on) |
| 4725 | { |
| 4726 | int rc; |
| 4727 | int i; |
| 4728 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA }; |
| 4729 | |
| 4730 | struct bahama_variant_register { |
| 4731 | const size_t size; |
| 4732 | const struct bahama_config_register *set; |
| 4733 | }; |
| 4734 | |
| 4735 | const struct bahama_config_register *p; |
| 4736 | |
| 4737 | |
| 4738 | const struct bahama_config_register v10_bt_on[] = { |
| 4739 | { 0xE9, 0x00, 0xFF }, |
| 4740 | { 0xF4, 0x80, 0xFF }, |
| 4741 | { 0xF0, 0x06, 0xFF }, |
| 4742 | { 0xE4, 0x00, 0xFF }, |
| 4743 | { 0xE5, 0x00, 0x0F }, |
| 4744 | #ifdef CONFIG_WLAN |
| 4745 | { 0xE6, 0x38, 0x7F }, |
| 4746 | { 0xE7, 0x06, 0xFF }, |
| 4747 | #endif |
| 4748 | { 0x11, 0x13, 0xFF }, |
| 4749 | { 0xE9, 0x21, 0xFF }, |
| 4750 | { 0x01, 0x0C, 0x1F }, |
| 4751 | { 0x01, 0x08, 0x1F }, |
| 4752 | }; |
| 4753 | |
| 4754 | const struct bahama_config_register v20_bt_on_fm_off[] = { |
| 4755 | { 0x11, 0x0C, 0xFF }, |
| 4756 | { 0x13, 0x01, 0xFF }, |
| 4757 | { 0xF4, 0x80, 0xFF }, |
| 4758 | { 0xF0, 0x00, 0xFF }, |
| 4759 | { 0xE9, 0x00, 0xFF }, |
| 4760 | #ifdef CONFIG_WLAN |
| 4761 | { 0x81, 0x00, 0xFF }, |
| 4762 | { 0x82, 0x00, 0xFF }, |
| 4763 | { 0xE6, 0x38, 0x7F }, |
| 4764 | { 0xE7, 0x06, 0xFF }, |
| 4765 | #endif |
| 4766 | { 0xE9, 0x21, 0xFF } |
| 4767 | }; |
| 4768 | |
| 4769 | const struct bahama_config_register v20_bt_on_fm_on[] = { |
| 4770 | { 0x11, 0x0C, 0xFF }, |
| 4771 | { 0x13, 0x01, 0xFF }, |
| 4772 | { 0xF4, 0x86, 0xFF }, |
| 4773 | { 0xF0, 0x06, 0xFF }, |
| 4774 | { 0xE9, 0x00, 0xFF }, |
| 4775 | #ifdef CONFIG_WLAN |
| 4776 | { 0x81, 0x00, 0xFF }, |
| 4777 | { 0x82, 0x00, 0xFF }, |
| 4778 | { 0xE6, 0x38, 0x7F }, |
| 4779 | { 0xE7, 0x06, 0xFF }, |
| 4780 | #endif |
| 4781 | { 0xE9, 0x21, 0xFF } |
| 4782 | }; |
| 4783 | |
| 4784 | const struct bahama_config_register v10_bt_off[] = { |
| 4785 | { 0xE9, 0x00, 0xFF }, |
| 4786 | }; |
| 4787 | |
| 4788 | const struct bahama_config_register v20_bt_off_fm_off[] = { |
| 4789 | { 0xF4, 0x84, 0xFF }, |
| 4790 | { 0xF0, 0x04, 0xFF }, |
| 4791 | { 0xE9, 0x00, 0xFF } |
| 4792 | }; |
| 4793 | |
| 4794 | const struct bahama_config_register v20_bt_off_fm_on[] = { |
| 4795 | { 0xF4, 0x86, 0xFF }, |
| 4796 | { 0xF0, 0x06, 0xFF }, |
| 4797 | { 0xE9, 0x00, 0xFF } |
| 4798 | }; |
| 4799 | |
| 4800 | const struct bahama_variant_register bt_bahama[2][3] = { |
| 4801 | { |
| 4802 | { ARRAY_SIZE(v10_bt_off), v10_bt_off }, |
| 4803 | { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off }, |
| 4804 | { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on } |
| 4805 | }, |
| 4806 | { |
| 4807 | { ARRAY_SIZE(v10_bt_on), v10_bt_on }, |
| 4808 | { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off }, |
| 4809 | { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on } |
| 4810 | } |
| 4811 | }; |
| 4812 | |
| 4813 | u8 offset = 0; /* index into bahama configs */ |
| 4814 | |
| 4815 | on = on ? 1 : 0; |
| 4816 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4817 | |
| 4818 | if (bahama_version == VER_2_0) { |
| 4819 | if (marimba_get_fm_status(&config)) |
| 4820 | offset = 0x01; |
| 4821 | } |
| 4822 | |
| 4823 | p = bt_bahama[on][bahama_version + offset].set; |
| 4824 | |
| 4825 | dev_info(&msm_bt_power_device.dev, |
| 4826 | "%s: found version %d\n", __func__, bahama_version); |
| 4827 | |
| 4828 | for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) { |
| 4829 | u8 value = (p+i)->value; |
| 4830 | rc = marimba_write_bit_mask(&config, |
| 4831 | (p+i)->reg, |
| 4832 | &value, |
| 4833 | sizeof((p+i)->value), |
| 4834 | (p+i)->mask); |
| 4835 | if (rc < 0) { |
| 4836 | dev_err(&msm_bt_power_device.dev, |
| 4837 | "%s: reg %d write failed: %d\n", |
| 4838 | __func__, (p+i)->reg, rc); |
| 4839 | return rc; |
| 4840 | } |
| 4841 | dev_info(&msm_bt_power_device.dev, |
| 4842 | "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n", |
| 4843 | __func__, (p+i)->reg, |
| 4844 | value, (p+i)->mask); |
| 4845 | } |
| 4846 | /* Update BT status */ |
| 4847 | if (on) |
| 4848 | marimba_set_bt_status(&config, true); |
| 4849 | else |
| 4850 | marimba_set_bt_status(&config, false); |
| 4851 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4852 | return 0; |
| 4853 | } |
| 4854 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4855 | static int bluetooth_regs_init(int bahama_not_marimba) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4856 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4857 | int rc = 0; |
| 4858 | struct device *const dev = &msm_bt_power_device.dev; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4859 | |
| 4860 | if (bahama_not_marimba) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4861 | bahama_version = read_bahama_ver(); |
| 4862 | |
| 4863 | switch (bahama_version) { |
| 4864 | case VER_1_0: |
| 4865 | regs_bt = regs_bt_bahama_v1; |
| 4866 | regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1); |
| 4867 | break; |
| 4868 | case VER_2_0: |
| 4869 | regs_bt = regs_bt_bahama_v2; |
| 4870 | regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2); |
| 4871 | break; |
| 4872 | case VER_UNSUPPORTED: |
| 4873 | default: |
| 4874 | dev_err(dev, |
| 4875 | "%s: i2c failure or unsupported version: %d\n", |
| 4876 | __func__, bahama_version); |
| 4877 | rc = -EIO; |
| 4878 | goto out; |
| 4879 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4880 | } else { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4881 | regs_bt = regs_bt_marimba; |
| 4882 | regs_bt_count = ARRAY_SIZE(regs_bt_marimba); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4883 | } |
| 4884 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4885 | rc = regulator_bulk_get(&msm_bt_power_device.dev, |
| 4886 | regs_bt_count, regs_bt); |
| 4887 | if (rc) { |
| 4888 | dev_err(dev, "%s: could not get regulators: %d\n", |
| 4889 | __func__, rc); |
| 4890 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4891 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4892 | |
| 4893 | rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt); |
| 4894 | if (rc) { |
| 4895 | dev_err(dev, "%s: could not set voltages: %d\n", |
| 4896 | __func__, rc); |
| 4897 | goto reg_free; |
| 4898 | } |
| 4899 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4900 | return 0; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4901 | |
| 4902 | reg_free: |
| 4903 | regulator_bulk_free(regs_bt_count, regs_bt); |
| 4904 | out: |
| 4905 | regs_bt_count = 0; |
| 4906 | regs_bt = NULL; |
| 4907 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4908 | } |
| 4909 | |
| 4910 | static int bluetooth_power(int on) |
| 4911 | { |
| 4912 | int rc; |
| 4913 | const char *id = "BTPW"; |
| 4914 | |
| 4915 | int bahama_not_marimba = bahama_present(); |
| 4916 | |
| 4917 | if (bahama_not_marimba == -1) { |
| 4918 | printk(KERN_WARNING "%s: bahama_present: %d\n", |
| 4919 | __func__, bahama_not_marimba); |
| 4920 | return -ENODEV; |
| 4921 | } |
| 4922 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4923 | if (unlikely(regs_bt_count == 0)) { |
| 4924 | rc = bluetooth_regs_init(bahama_not_marimba); |
| 4925 | if (rc) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4926 | return rc; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4927 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4928 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4929 | if (on) { |
| 4930 | rc = regulator_bulk_enable(regs_bt_count, regs_bt); |
| 4931 | if (rc) |
| 4932 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4933 | |
| 4934 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, |
| 4935 | PMAPP_CLOCK_VOTE_ON); |
| 4936 | if (rc < 0) |
| 4937 | return -EIO; |
| 4938 | |
| 4939 | if (machine_is_msm8x55_svlte_surf() || |
| 4940 | machine_is_msm8x55_svlte_ffa()) { |
| 4941 | rc = marimba_gpio_config(1); |
| 4942 | if (rc < 0) |
| 4943 | return -EIO; |
| 4944 | } |
| 4945 | |
| 4946 | rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on)); |
| 4947 | if (rc < 0) |
| 4948 | return -EIO; |
| 4949 | |
| 4950 | msleep(10); |
| 4951 | |
| 4952 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, |
| 4953 | PMAPP_CLOCK_VOTE_PIN_CTRL); |
| 4954 | if (rc < 0) |
| 4955 | return -EIO; |
| 4956 | |
| 4957 | if (machine_is_msm8x55_svlte_surf() || |
| 4958 | machine_is_msm8x55_svlte_ffa()) { |
| 4959 | rc = marimba_gpio_config(0); |
| 4960 | if (rc < 0) |
| 4961 | return -EIO; |
| 4962 | } |
| 4963 | |
| 4964 | rc = msm_gpios_enable(bt_config_power_on, |
| 4965 | ARRAY_SIZE(bt_config_power_on)); |
| 4966 | |
| 4967 | if (rc < 0) |
| 4968 | return rc; |
| 4969 | |
| 4970 | } else { |
| 4971 | rc = msm_gpios_enable(bt_config_power_off, |
| 4972 | ARRAY_SIZE(bt_config_power_off)); |
| 4973 | if (rc < 0) |
| 4974 | return rc; |
| 4975 | |
| 4976 | /* check for initial RFKILL block (power off) */ |
| 4977 | if (platform_get_drvdata(&msm_bt_power_device) == NULL) |
| 4978 | goto out; |
| 4979 | |
| 4980 | rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on)); |
| 4981 | if (rc < 0) |
| 4982 | return -EIO; |
| 4983 | |
| 4984 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, |
| 4985 | PMAPP_CLOCK_VOTE_OFF); |
| 4986 | if (rc < 0) |
| 4987 | return -EIO; |
| 4988 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 4989 | rc = regulator_bulk_disable(regs_bt_count, regs_bt); |
| 4990 | if (rc) |
| 4991 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4992 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4993 | } |
| 4994 | |
| 4995 | out: |
| 4996 | printk(KERN_DEBUG "Bluetooth power switch: %d\n", on); |
| 4997 | |
| 4998 | return 0; |
| 4999 | } |
| 5000 | |
| 5001 | static void __init bt_power_init(void) |
| 5002 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5003 | msm_bt_power_device.dev.platform_data = &bluetooth_power; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5004 | } |
| 5005 | #else |
| 5006 | #define bt_power_init(x) do {} while (0) |
| 5007 | #endif |
| 5008 | |
| 5009 | static struct msm_psy_batt_pdata msm_psy_batt_data = { |
| 5010 | .voltage_min_design = 2800, |
| 5011 | .voltage_max_design = 4300, |
| 5012 | .avail_chg_sources = AC_CHG | USB_CHG , |
| 5013 | .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION, |
| 5014 | }; |
| 5015 | |
| 5016 | static struct platform_device msm_batt_device = { |
| 5017 | .name = "msm-battery", |
| 5018 | .id = -1, |
| 5019 | .dev.platform_data = &msm_psy_batt_data, |
| 5020 | }; |
| 5021 | |
| 5022 | static char *msm_adc_fluid_device_names[] = { |
| 5023 | "LTC_ADC1", |
| 5024 | "LTC_ADC2", |
| 5025 | "LTC_ADC3", |
| 5026 | }; |
| 5027 | |
| 5028 | static char *msm_adc_surf_device_names[] = { |
| 5029 | "XO_ADC", |
| 5030 | }; |
| 5031 | |
| 5032 | static struct msm_adc_platform_data msm_adc_pdata; |
| 5033 | |
| 5034 | static struct platform_device msm_adc_device = { |
| 5035 | .name = "msm_adc", |
| 5036 | .id = -1, |
| 5037 | .dev = { |
| 5038 | .platform_data = &msm_adc_pdata, |
| 5039 | }, |
| 5040 | }; |
| 5041 | |
| 5042 | #ifdef CONFIG_MSM_SDIO_AL |
| 5043 | static struct msm_gpio mdm2ap_status = { |
| 5044 | GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 5045 | "mdm2ap_status" |
| 5046 | }; |
| 5047 | |
| 5048 | |
| 5049 | static int configure_mdm2ap_status(int on) |
| 5050 | { |
| 5051 | if (on) |
| 5052 | return msm_gpios_request_enable(&mdm2ap_status, 1); |
| 5053 | else { |
| 5054 | msm_gpios_disable_free(&mdm2ap_status, 1); |
| 5055 | return 0; |
| 5056 | } |
| 5057 | } |
| 5058 | |
| 5059 | static int get_mdm2ap_status(void) |
| 5060 | { |
| 5061 | return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg)); |
| 5062 | } |
| 5063 | |
| 5064 | static struct sdio_al_platform_data sdio_al_pdata = { |
| 5065 | .config_mdm2ap_status = configure_mdm2ap_status, |
| 5066 | .get_mdm2ap_status = get_mdm2ap_status, |
| 5067 | .allow_sdioc_version_major_2 = 1, |
| 5068 | .peer_sdioc_version_minor = 0x0001, |
| 5069 | .peer_sdioc_version_major = 0x0003, |
| 5070 | .peer_sdioc_boot_version_minor = 0x0001, |
| 5071 | .peer_sdioc_boot_version_major = 0x0003, |
| 5072 | }; |
| 5073 | |
| 5074 | struct platform_device msm_device_sdio_al = { |
| 5075 | .name = "msm_sdio_al", |
| 5076 | .id = -1, |
| 5077 | .dev = { |
| 5078 | .platform_data = &sdio_al_pdata, |
| 5079 | }, |
| 5080 | }; |
| 5081 | |
| 5082 | #endif /* CONFIG_MSM_SDIO_AL */ |
| 5083 | |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 5084 | static struct platform_device *devices[] __initdata = { |
Daniel Walker | 90e37c5 | 2010-05-12 14:24:15 -0700 | [diff] [blame] | 5085 | #if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5086 | &msm_device_uart2, |
| 5087 | #endif |
Justin Paupore | 637a25d | 2011-07-14 17:11:04 -0700 | [diff] [blame] | 5088 | #ifdef CONFIG_MSM_PROC_COMM_REGULATOR |
| 5089 | &msm_proccomm_regulator_dev, |
| 5090 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5091 | &asoc_msm_pcm, |
| 5092 | &asoc_msm_dai0, |
| 5093 | &asoc_msm_dai1, |
| 5094 | #if defined (CONFIG_SND_MSM_MVS_DAI_SOC) |
| 5095 | &asoc_msm_mvs, |
| 5096 | &asoc_mvs_dai0, |
| 5097 | &asoc_mvs_dai1, |
Daniel Walker | 90e37c5 | 2010-05-12 14:24:15 -0700 | [diff] [blame] | 5098 | #endif |
Niranjana Vishwanathapura | a8855e9 | 2010-10-06 13:52:10 -0700 | [diff] [blame] | 5099 | &msm_device_smd, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5100 | &msm_device_dmov, |
| 5101 | &smc91x_device, |
| 5102 | &smsc911x_device, |
| 5103 | &msm_device_nand, |
| 5104 | #ifdef CONFIG_USB_MSM_OTG_72K |
Pavankumar Kondeti | 5155e2c | 2010-12-08 13:37:08 +0530 | [diff] [blame] | 5105 | &msm_device_otg, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5106 | #ifdef CONFIG_USB_GADGET |
| 5107 | &msm_device_gadget_peripheral, |
| 5108 | #endif |
| 5109 | #endif |
| 5110 | #ifdef CONFIG_USB_G_ANDROID |
| 5111 | &android_usb_device, |
| 5112 | #endif |
| 5113 | &qsd_device_spi, |
Anirudh Ghayal | 9d9cdc2 | 2011-10-10 17:17:07 +0530 | [diff] [blame] | 5114 | |
| 5115 | #ifdef CONFIG_MSM_SSBI |
| 5116 | &msm_device_ssbi_pmic1, |
| 5117 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5118 | #ifdef CONFIG_I2C_SSBI |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5119 | &msm_device_ssbi7, |
| 5120 | #endif |
| 5121 | &android_pmem_device, |
| 5122 | &msm_fb_device, |
| 5123 | &msm_migrate_pages_device, |
| 5124 | &mddi_toshiba_device, |
| 5125 | &lcdc_toshiba_panel_device, |
| 5126 | #ifdef CONFIG_MSM_ROTATOR |
| 5127 | &msm_rotator_device, |
| 5128 | #endif |
| 5129 | &lcdc_sharp_panel_device, |
| 5130 | &android_pmem_adsp_device, |
| 5131 | &android_pmem_audio_device, |
| 5132 | &msm_device_i2c, |
| 5133 | &msm_device_i2c_2, |
| 5134 | &msm_device_uart_dm1, |
| 5135 | &hs_device, |
| 5136 | #ifdef CONFIG_MSM7KV2_AUDIO |
| 5137 | &msm_aictl_device, |
| 5138 | &msm_mi2s_device, |
| 5139 | &msm_lpa_device, |
| 5140 | &msm_aux_pcm_device, |
| 5141 | #endif |
| 5142 | &msm_device_adspdec, |
| 5143 | &qup_device_i2c, |
| 5144 | #if defined(CONFIG_MARIMBA_CORE) && \ |
| 5145 | (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE)) |
| 5146 | &msm_bt_power_device, |
| 5147 | #endif |
| 5148 | &msm_kgsl_3d0, |
| 5149 | &msm_kgsl_2d0, |
| 5150 | #ifdef CONFIG_MT9T013 |
| 5151 | &msm_camera_sensor_mt9t013, |
| 5152 | #endif |
| 5153 | #ifdef CONFIG_MT9D112 |
| 5154 | &msm_camera_sensor_mt9d112, |
| 5155 | #endif |
| 5156 | #ifdef CONFIG_WEBCAM_OV9726 |
| 5157 | &msm_camera_sensor_ov9726, |
| 5158 | #endif |
| 5159 | #ifdef CONFIG_S5K3E2FX |
| 5160 | &msm_camera_sensor_s5k3e2fx, |
| 5161 | #endif |
| 5162 | #ifdef CONFIG_MT9P012 |
| 5163 | &msm_camera_sensor_mt9p012, |
| 5164 | #endif |
| 5165 | #ifdef CONFIG_MT9E013 |
| 5166 | &msm_camera_sensor_mt9e013, |
| 5167 | #endif |
| 5168 | #ifdef CONFIG_VX6953 |
| 5169 | &msm_camera_sensor_vx6953, |
| 5170 | #endif |
| 5171 | #ifdef CONFIG_SN12M0PZ |
| 5172 | &msm_camera_sensor_sn12m0pz, |
| 5173 | #endif |
| 5174 | &msm_device_vidc_720p, |
| 5175 | #ifdef CONFIG_MSM_GEMINI |
| 5176 | &msm_gemini_device, |
| 5177 | #endif |
| 5178 | #ifdef CONFIG_MSM_VPE |
| 5179 | &msm_vpe_device, |
| 5180 | #endif |
| 5181 | #if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) |
| 5182 | &msm_device_tsif, |
| 5183 | #endif |
| 5184 | #ifdef CONFIG_MSM_SDIO_AL |
| 5185 | &msm_device_sdio_al, |
| 5186 | #endif |
| 5187 | |
| 5188 | #if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \ |
| 5189 | defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) |
| 5190 | &qcrypto_device, |
| 5191 | #endif |
| 5192 | |
| 5193 | #if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \ |
| 5194 | defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE) |
| 5195 | &qcedev_device, |
| 5196 | #endif |
| 5197 | |
| 5198 | &msm_batt_device, |
| 5199 | &msm_adc_device, |
| 5200 | &msm_ebi0_thermal, |
| 5201 | &msm_ebi1_thermal |
| 5202 | }; |
| 5203 | |
| 5204 | static struct msm_gpio msm_i2c_gpios_hw[] = { |
| 5205 | { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" }, |
| 5206 | { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" }, |
| 5207 | }; |
| 5208 | |
| 5209 | static struct msm_gpio msm_i2c_gpios_io[] = { |
| 5210 | { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" }, |
| 5211 | { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" }, |
| 5212 | }; |
| 5213 | |
| 5214 | static struct msm_gpio qup_i2c_gpios_io[] = { |
| 5215 | { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" }, |
| 5216 | { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" }, |
| 5217 | }; |
| 5218 | static struct msm_gpio qup_i2c_gpios_hw[] = { |
| 5219 | { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" }, |
| 5220 | { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" }, |
| 5221 | }; |
| 5222 | |
| 5223 | static void |
| 5224 | msm_i2c_gpio_config(int adap_id, int config_type) |
| 5225 | { |
| 5226 | struct msm_gpio *msm_i2c_table; |
| 5227 | |
| 5228 | /* Each adapter gets 2 lines from the table */ |
| 5229 | if (adap_id > 0) |
| 5230 | return; |
| 5231 | if (config_type) |
| 5232 | msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2]; |
| 5233 | else |
| 5234 | msm_i2c_table = &msm_i2c_gpios_io[adap_id*2]; |
| 5235 | msm_gpios_enable(msm_i2c_table, 2); |
| 5236 | } |
| 5237 | /*This needs to be enabled only for OEMS*/ |
| 5238 | #ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5239 | static struct regulator *qup_vreg; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5240 | #endif |
| 5241 | static void |
| 5242 | qup_i2c_gpio_config(int adap_id, int config_type) |
| 5243 | { |
| 5244 | int rc = 0; |
| 5245 | struct msm_gpio *qup_i2c_table; |
| 5246 | /* Each adapter gets 2 lines from the table */ |
| 5247 | if (adap_id != 4) |
| 5248 | return; |
| 5249 | if (config_type) |
| 5250 | qup_i2c_table = qup_i2c_gpios_hw; |
| 5251 | else |
| 5252 | qup_i2c_table = qup_i2c_gpios_io; |
| 5253 | rc = msm_gpios_enable(qup_i2c_table, 2); |
| 5254 | if (rc < 0) |
| 5255 | printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc); |
| 5256 | /*This needs to be enabled only for OEMS*/ |
| 5257 | #ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5258 | if (!IS_ERR_OR_NULL(qup_vreg)) { |
| 5259 | rc = regulator_enable(qup_vreg); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5260 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5261 | pr_err("%s: regulator_enable failed: %d\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5262 | __func__, rc); |
| 5263 | } |
| 5264 | } |
| 5265 | #endif |
| 5266 | } |
| 5267 | |
| 5268 | static struct msm_i2c_platform_data msm_i2c_pdata = { |
| 5269 | .clk_freq = 100000, |
| 5270 | .pri_clk = 70, |
| 5271 | .pri_dat = 71, |
| 5272 | .rmutex = 1, |
| 5273 | .rsl_id = "D:I2C02000021", |
| 5274 | .msm_i2c_config_gpio = msm_i2c_gpio_config, |
| 5275 | }; |
| 5276 | |
| 5277 | static void __init msm_device_i2c_init(void) |
| 5278 | { |
| 5279 | if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw))) |
| 5280 | pr_err("failed to request I2C gpios\n"); |
| 5281 | |
| 5282 | msm_device_i2c.dev.platform_data = &msm_i2c_pdata; |
| 5283 | } |
| 5284 | |
| 5285 | static struct msm_i2c_platform_data msm_i2c_2_pdata = { |
| 5286 | .clk_freq = 100000, |
| 5287 | .rmutex = 1, |
| 5288 | .rsl_id = "D:I2C02000022", |
| 5289 | .msm_i2c_config_gpio = msm_i2c_gpio_config, |
| 5290 | }; |
| 5291 | |
| 5292 | static void __init msm_device_i2c_2_init(void) |
| 5293 | { |
| 5294 | msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata; |
| 5295 | } |
| 5296 | |
| 5297 | static struct msm_i2c_platform_data qup_i2c_pdata = { |
| 5298 | .clk_freq = 384000, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5299 | .msm_i2c_config_gpio = qup_i2c_gpio_config, |
| 5300 | }; |
| 5301 | |
| 5302 | static void __init qup_device_i2c_init(void) |
| 5303 | { |
| 5304 | if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw))) |
| 5305 | pr_err("failed to request I2C gpios\n"); |
| 5306 | |
| 5307 | qup_device_i2c.dev.platform_data = &qup_i2c_pdata; |
| 5308 | /*This needs to be enabled only for OEMS*/ |
| 5309 | #ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5310 | qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1"); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5311 | if (IS_ERR(qup_vreg)) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5312 | dev_err(&qup_device_i2c.dev, |
| 5313 | "%s: regulator_get failed: %ld\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5314 | __func__, PTR_ERR(qup_vreg)); |
| 5315 | } |
| 5316 | #endif |
| 5317 | } |
| 5318 | |
| 5319 | #ifdef CONFIG_I2C_SSBI |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5320 | static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = { |
| 5321 | .rsl_id = "D:CODEC_SSBI", |
| 5322 | .controller_type = MSM_SBI_CTRL_SSBI, |
| 5323 | }; |
| 5324 | #endif |
| 5325 | |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 5326 | static void __init msm7x30_init_irq(void) |
| 5327 | { |
| 5328 | msm_init_irq(); |
| 5329 | } |
| 5330 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5331 | static struct msm_gpio msm_nand_ebi2_cfg_data[] = { |
| 5332 | {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"}, |
| 5333 | {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"}, |
| 5334 | }; |
| 5335 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5336 | #if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\ |
| 5337 | || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\ |
| 5338 | || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\ |
| 5339 | || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)) |
| 5340 | |
| 5341 | struct sdcc_gpio { |
| 5342 | struct msm_gpio *cfg_data; |
| 5343 | uint32_t size; |
| 5344 | struct msm_gpio *sleep_cfg_data; |
| 5345 | }; |
| 5346 | #if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) |
| 5347 | static struct msm_gpio sdc1_lvlshft_cfg_data[] = { |
| 5348 | {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"}, |
| 5349 | }; |
| 5350 | #endif |
| 5351 | static struct msm_gpio sdc1_cfg_data[] = { |
| 5352 | {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"}, |
| 5353 | {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"}, |
| 5354 | {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"}, |
| 5355 | {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"}, |
| 5356 | {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"}, |
| 5357 | {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"}, |
| 5358 | }; |
| 5359 | |
| 5360 | static struct msm_gpio sdc2_cfg_data[] = { |
| 5361 | {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"}, |
| 5362 | {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"}, |
| 5363 | {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"}, |
| 5364 | {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"}, |
| 5365 | {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"}, |
| 5366 | {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"}, |
| 5367 | |
| 5368 | #ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT |
| 5369 | {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"}, |
| 5370 | {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"}, |
| 5371 | {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"}, |
| 5372 | {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"}, |
| 5373 | #endif |
| 5374 | }; |
| 5375 | |
| 5376 | static struct msm_gpio sdc3_cfg_data[] = { |
| 5377 | {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"}, |
| 5378 | {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"}, |
| 5379 | {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"}, |
| 5380 | {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"}, |
| 5381 | {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"}, |
| 5382 | {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"}, |
| 5383 | }; |
| 5384 | |
| 5385 | static struct msm_gpio sdc3_sleep_cfg_data[] = { |
| 5386 | {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 5387 | "sdc3_clk"}, |
| 5388 | {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 5389 | "sdc3_cmd"}, |
| 5390 | {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 5391 | "sdc3_dat_3"}, |
| 5392 | {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 5393 | "sdc3_dat_2"}, |
| 5394 | {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 5395 | "sdc3_dat_1"}, |
| 5396 | {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 5397 | "sdc3_dat_0"}, |
| 5398 | }; |
| 5399 | |
| 5400 | static struct msm_gpio sdc4_cfg_data[] = { |
| 5401 | {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"}, |
| 5402 | {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"}, |
| 5403 | {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"}, |
| 5404 | {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"}, |
| 5405 | {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"}, |
| 5406 | {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"}, |
| 5407 | }; |
| 5408 | |
| 5409 | static struct sdcc_gpio sdcc_cfg_data[] = { |
| 5410 | { |
| 5411 | .cfg_data = sdc1_cfg_data, |
| 5412 | .size = ARRAY_SIZE(sdc1_cfg_data), |
| 5413 | .sleep_cfg_data = NULL, |
| 5414 | }, |
| 5415 | { |
| 5416 | .cfg_data = sdc2_cfg_data, |
| 5417 | .size = ARRAY_SIZE(sdc2_cfg_data), |
| 5418 | .sleep_cfg_data = NULL, |
| 5419 | }, |
| 5420 | { |
| 5421 | .cfg_data = sdc3_cfg_data, |
| 5422 | .size = ARRAY_SIZE(sdc3_cfg_data), |
| 5423 | .sleep_cfg_data = sdc3_sleep_cfg_data, |
| 5424 | }, |
| 5425 | { |
| 5426 | .cfg_data = sdc4_cfg_data, |
| 5427 | .size = ARRAY_SIZE(sdc4_cfg_data), |
| 5428 | .sleep_cfg_data = NULL, |
| 5429 | }, |
| 5430 | }; |
| 5431 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5432 | static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5433 | |
| 5434 | static unsigned long vreg_sts, gpio_sts; |
| 5435 | |
| 5436 | static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable) |
| 5437 | { |
| 5438 | int rc = 0; |
| 5439 | struct sdcc_gpio *curr; |
| 5440 | |
| 5441 | curr = &sdcc_cfg_data[dev_id - 1]; |
| 5442 | |
| 5443 | if (!(test_bit(dev_id, &gpio_sts)^enable)) |
| 5444 | return rc; |
| 5445 | |
| 5446 | if (enable) { |
| 5447 | set_bit(dev_id, &gpio_sts); |
| 5448 | rc = msm_gpios_request_enable(curr->cfg_data, curr->size); |
| 5449 | if (rc) |
| 5450 | printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n", |
| 5451 | __func__, dev_id); |
| 5452 | } else { |
| 5453 | clear_bit(dev_id, &gpio_sts); |
| 5454 | if (curr->sleep_cfg_data) { |
| 5455 | msm_gpios_enable(curr->sleep_cfg_data, curr->size); |
| 5456 | msm_gpios_free(curr->sleep_cfg_data, curr->size); |
| 5457 | } else { |
| 5458 | msm_gpios_disable_free(curr->cfg_data, curr->size); |
| 5459 | } |
| 5460 | } |
| 5461 | |
| 5462 | return rc; |
| 5463 | } |
| 5464 | |
| 5465 | static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable) |
| 5466 | { |
| 5467 | int rc = 0; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5468 | struct regulator *curr = sdcc_vreg_data[dev_id - 1]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5469 | static int enabled_once[] = {0, 0, 0, 0}; |
| 5470 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5471 | if (test_bit(dev_id, &vreg_sts) == enable) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5472 | return rc; |
| 5473 | |
| 5474 | if (!enable || enabled_once[dev_id - 1]) |
| 5475 | return 0; |
| 5476 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5477 | if (!curr) |
| 5478 | return -ENODEV; |
| 5479 | |
| 5480 | if (IS_ERR(curr)) |
| 5481 | return PTR_ERR(curr); |
| 5482 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5483 | if (enable) { |
| 5484 | set_bit(dev_id, &vreg_sts); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5485 | |
| 5486 | rc = regulator_enable(curr); |
| 5487 | if (rc) |
| 5488 | pr_err("%s: could not enable regulator: %d\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5489 | __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5490 | enabled_once[dev_id - 1] = 1; |
| 5491 | } else { |
| 5492 | clear_bit(dev_id, &vreg_sts); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5493 | |
| 5494 | rc = regulator_disable(curr); |
| 5495 | if (rc) |
| 5496 | pr_err("%s: could not disable regulator: %d\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5497 | __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5498 | } |
| 5499 | return rc; |
| 5500 | } |
| 5501 | |
| 5502 | static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd) |
| 5503 | { |
| 5504 | int rc = 0; |
| 5505 | struct platform_device *pdev; |
| 5506 | |
| 5507 | pdev = container_of(dv, struct platform_device, dev); |
| 5508 | rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0)); |
| 5509 | if (rc) |
| 5510 | goto out; |
| 5511 | |
| 5512 | if (pdev->id == 4) /* S3 is always ON and cannot be disabled */ |
| 5513 | rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0)); |
| 5514 | out: |
| 5515 | return rc; |
| 5516 | } |
| 5517 | |
| 5518 | #if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \ |
| 5519 | defined(CONFIG_CSDIO_VENDOR_ID) && \ |
| 5520 | defined(CONFIG_CSDIO_DEVICE_ID) && \ |
| 5521 | (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117) |
| 5522 | |
| 5523 | #define MBP_ON 1 |
| 5524 | #define MBP_OFF 0 |
| 5525 | |
| 5526 | #define MBP_RESET_N \ |
| 5527 | GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA) |
| 5528 | #define MBP_INT0 \ |
| 5529 | GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA) |
| 5530 | |
| 5531 | #define MBP_MODE_CTRL_0 \ |
| 5532 | GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA) |
| 5533 | #define MBP_MODE_CTRL_1 \ |
| 5534 | GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA) |
| 5535 | #define MBP_MODE_CTRL_2 \ |
| 5536 | GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA) |
| 5537 | #define TSIF_EN \ |
| 5538 | GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) |
| 5539 | #define TSIF_DATA \ |
| 5540 | GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) |
| 5541 | #define TSIF_CLK \ |
| 5542 | GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) |
| 5543 | |
| 5544 | static struct msm_gpio mbp_cfg_data[] = { |
| 5545 | {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), |
| 5546 | "mbp_reset"}, |
| 5547 | {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), |
| 5548 | "mbp_io_voltage"}, |
| 5549 | }; |
| 5550 | |
| 5551 | static int mbp_config_gpios_pre_init(int enable) |
| 5552 | { |
| 5553 | int rc = 0; |
| 5554 | |
| 5555 | if (enable) { |
| 5556 | rc = msm_gpios_request_enable(mbp_cfg_data, |
| 5557 | ARRAY_SIZE(mbp_cfg_data)); |
| 5558 | if (rc) { |
| 5559 | printk(KERN_ERR |
| 5560 | "%s: Failed to turnon GPIOs for mbp chip(%d)\n", |
| 5561 | __func__, rc); |
| 5562 | } |
| 5563 | } else |
| 5564 | msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data)); |
| 5565 | return rc; |
| 5566 | } |
| 5567 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5568 | static struct regulator_bulk_data mbp_regs_io[2]; |
| 5569 | static struct regulator_bulk_data mbp_regs_rf[2]; |
| 5570 | static struct regulator_bulk_data mbp_regs_adc[1]; |
| 5571 | static struct regulator_bulk_data mbp_regs_core[1]; |
| 5572 | |
| 5573 | static int mbp_init_regs(struct device *dev) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5574 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5575 | struct regulator_bulk_data regs[] = { |
| 5576 | /* Analog and I/O regs */ |
| 5577 | { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 }, |
| 5578 | { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 }, |
| 5579 | /* RF regs */ |
| 5580 | { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 }, |
| 5581 | { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 }, |
| 5582 | /* ADC regs */ |
| 5583 | { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 }, |
| 5584 | /* Core regs */ |
| 5585 | { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 }, |
| 5586 | }; |
| 5587 | |
| 5588 | struct regulator_bulk_data *regptr = regs; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5589 | int rc; |
| 5590 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5591 | rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs); |
| 5592 | |
| 5593 | if (rc) { |
| 5594 | dev_err(dev, "%s: could not get regulators: %d\n", |
| 5595 | __func__, rc); |
| 5596 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5597 | } |
| 5598 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5599 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5600 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5601 | if (rc) { |
| 5602 | dev_err(dev, "%s: could not set voltages: %d\n", |
| 5603 | __func__, rc); |
| 5604 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5605 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5606 | |
| 5607 | memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io)); |
| 5608 | regptr += ARRAY_SIZE(mbp_regs_io); |
| 5609 | |
| 5610 | memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf)); |
| 5611 | regptr += ARRAY_SIZE(mbp_regs_rf); |
| 5612 | |
| 5613 | memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc)); |
| 5614 | regptr += ARRAY_SIZE(mbp_regs_adc); |
| 5615 | |
| 5616 | memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core)); |
| 5617 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5618 | return 0; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5619 | |
| 5620 | reg_free: |
| 5621 | regulator_bulk_free(ARRAY_SIZE(regs), regs); |
| 5622 | out: |
| 5623 | return rc; |
| 5624 | } |
| 5625 | |
| 5626 | static int mbp_setup_rf_vregs(int state) |
| 5627 | { |
| 5628 | return state ? |
| 5629 | regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) : |
| 5630 | regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5631 | } |
| 5632 | |
| 5633 | static int mbp_setup_vregs(int state) |
| 5634 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5635 | return state ? |
| 5636 | regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) : |
| 5637 | regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5638 | } |
| 5639 | |
| 5640 | static int mbp_set_tcxo_en(int enable) |
| 5641 | { |
| 5642 | int rc; |
| 5643 | const char *id = "UBMC"; |
| 5644 | struct vreg *vreg_analog = NULL; |
| 5645 | |
| 5646 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1, |
| 5647 | enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF); |
| 5648 | if (rc < 0) { |
| 5649 | printk(KERN_ERR "%s: unable to %svote for a1 clk\n", |
| 5650 | __func__, enable ? "" : "de-"); |
| 5651 | return -EIO; |
| 5652 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5653 | return rc; |
| 5654 | } |
| 5655 | |
| 5656 | static void mbp_set_freeze_io(int state) |
| 5657 | { |
| 5658 | if (state) |
| 5659 | gpio_set_value(85, 0); |
| 5660 | else |
| 5661 | gpio_set_value(85, 1); |
| 5662 | } |
| 5663 | |
| 5664 | static int mbp_set_core_voltage_en(int enable) |
| 5665 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5666 | static bool is_enabled; |
| 5667 | int rc = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5668 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5669 | if (enable && !is_enabled) { |
| 5670 | rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core), |
| 5671 | mbp_regs_core); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5672 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5673 | pr_err("%s: could not enable regulators: %d\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5674 | __func__, rc); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5675 | } else { |
| 5676 | is_enabled = true; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5677 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5678 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5679 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5680 | return rc; |
| 5681 | } |
| 5682 | |
| 5683 | static void mbp_set_reset(int state) |
| 5684 | { |
| 5685 | if (state) |
| 5686 | gpio_set_value(GPIO_PIN(MBP_RESET_N), 0); |
| 5687 | else |
| 5688 | gpio_set_value(GPIO_PIN(MBP_RESET_N), 1); |
| 5689 | } |
| 5690 | |
| 5691 | static int mbp_config_interface_mode(int state) |
| 5692 | { |
| 5693 | if (state) { |
| 5694 | gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE); |
| 5695 | gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE); |
| 5696 | gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE); |
| 5697 | gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0); |
| 5698 | gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1); |
| 5699 | gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0); |
| 5700 | } else { |
| 5701 | gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE); |
| 5702 | gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE); |
| 5703 | gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE); |
| 5704 | } |
| 5705 | return 0; |
| 5706 | } |
| 5707 | |
| 5708 | static int mbp_setup_adc_vregs(int state) |
| 5709 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5710 | return state ? |
| 5711 | regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) : |
| 5712 | regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5713 | } |
| 5714 | |
| 5715 | static int mbp_power_up(void) |
| 5716 | { |
| 5717 | int rc; |
| 5718 | |
| 5719 | rc = mbp_config_gpios_pre_init(MBP_ON); |
| 5720 | if (rc) |
| 5721 | goto exit; |
| 5722 | pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__); |
| 5723 | |
| 5724 | rc = mbp_setup_vregs(MBP_ON); |
| 5725 | if (rc) |
| 5726 | goto exit; |
| 5727 | pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__); |
| 5728 | |
| 5729 | rc = mbp_set_tcxo_en(MBP_ON); |
| 5730 | if (rc) |
| 5731 | goto exit; |
| 5732 | pr_debug("%s: tcxo clock done\n", __func__); |
| 5733 | |
| 5734 | mbp_set_freeze_io(MBP_OFF); |
| 5735 | pr_debug("%s: set gpio 85 to 1 done\n", __func__); |
| 5736 | |
| 5737 | udelay(100); |
| 5738 | mbp_set_reset(MBP_ON); |
| 5739 | |
| 5740 | udelay(300); |
| 5741 | rc = mbp_config_interface_mode(MBP_ON); |
| 5742 | if (rc) |
| 5743 | goto exit; |
| 5744 | pr_debug("%s: mbp_config_interface_mode() done\n", __func__); |
| 5745 | |
| 5746 | udelay(100 + mbp_set_core_voltage_en(MBP_ON)); |
| 5747 | pr_debug("%s: power gp16 1.2V done\n", __func__); |
| 5748 | |
| 5749 | mbp_set_freeze_io(MBP_ON); |
| 5750 | pr_debug("%s: set gpio 85 to 0 done\n", __func__); |
| 5751 | |
| 5752 | udelay(100); |
| 5753 | |
| 5754 | rc = mbp_setup_rf_vregs(MBP_ON); |
| 5755 | if (rc) |
| 5756 | goto exit; |
| 5757 | pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__); |
| 5758 | |
| 5759 | rc = mbp_setup_adc_vregs(MBP_ON); |
| 5760 | if (rc) |
| 5761 | goto exit; |
| 5762 | pr_debug("%s: s4 2.2V done\n", __func__); |
| 5763 | |
| 5764 | udelay(200); |
| 5765 | |
| 5766 | mbp_set_reset(MBP_OFF); |
| 5767 | pr_debug("%s: close gpio 44 done\n", __func__); |
| 5768 | |
| 5769 | msleep(20); |
| 5770 | exit: |
| 5771 | return rc; |
| 5772 | } |
| 5773 | |
| 5774 | static int mbp_power_down(void) |
| 5775 | { |
| 5776 | int rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5777 | |
| 5778 | mbp_set_reset(MBP_ON); |
| 5779 | pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__); |
| 5780 | |
| 5781 | udelay(100); |
| 5782 | |
| 5783 | rc = mbp_setup_adc_vregs(MBP_OFF); |
| 5784 | if (rc) |
| 5785 | goto exit; |
| 5786 | pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__); |
| 5787 | |
| 5788 | udelay(5); |
| 5789 | |
| 5790 | rc = mbp_setup_rf_vregs(MBP_OFF); |
| 5791 | if (rc) |
| 5792 | goto exit; |
| 5793 | pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__); |
| 5794 | |
| 5795 | udelay(5); |
| 5796 | |
| 5797 | mbp_set_freeze_io(MBP_OFF); |
| 5798 | pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__); |
| 5799 | |
| 5800 | udelay(100); |
| 5801 | rc = mbp_set_core_voltage_en(MBP_OFF); |
| 5802 | if (rc) |
| 5803 | goto exit; |
| 5804 | pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__); |
| 5805 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5806 | rc = mbp_set_tcxo_en(MBP_OFF); |
| 5807 | if (rc) |
| 5808 | goto exit; |
| 5809 | pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__); |
| 5810 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5811 | rc = mbp_setup_vregs(MBP_OFF); |
| 5812 | if (rc) |
| 5813 | goto exit; |
| 5814 | pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__); |
| 5815 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5816 | rc = mbp_config_gpios_pre_init(MBP_OFF); |
| 5817 | if (rc) |
| 5818 | goto exit; |
| 5819 | exit: |
| 5820 | return rc; |
| 5821 | } |
| 5822 | |
| 5823 | static void (*mbp_status_notify_cb)(int card_present, void *dev_id); |
| 5824 | static void *mbp_status_notify_cb_devid; |
| 5825 | static int mbp_power_status; |
| 5826 | static int mbp_power_init_done; |
| 5827 | |
| 5828 | static uint32_t mbp_setup_power(struct device *dv, |
| 5829 | unsigned int power_status) |
| 5830 | { |
| 5831 | int rc = 0; |
| 5832 | struct platform_device *pdev; |
| 5833 | |
| 5834 | pdev = container_of(dv, struct platform_device, dev); |
| 5835 | |
| 5836 | if (power_status == mbp_power_status) |
| 5837 | goto exit; |
| 5838 | if (power_status) { |
| 5839 | pr_debug("turn on power of mbp slot"); |
| 5840 | rc = mbp_power_up(); |
| 5841 | mbp_power_status = 1; |
| 5842 | } else { |
| 5843 | pr_debug("turn off power of mbp slot"); |
| 5844 | rc = mbp_power_down(); |
| 5845 | mbp_power_status = 0; |
| 5846 | } |
| 5847 | exit: |
| 5848 | return rc; |
| 5849 | }; |
| 5850 | |
| 5851 | int mbp_register_status_notify(void (*callback)(int, void *), |
| 5852 | void *dev_id) |
| 5853 | { |
| 5854 | mbp_status_notify_cb = callback; |
| 5855 | mbp_status_notify_cb_devid = dev_id; |
| 5856 | return 0; |
| 5857 | } |
| 5858 | |
| 5859 | static unsigned int mbp_status(struct device *dev) |
| 5860 | { |
| 5861 | return mbp_power_status; |
| 5862 | } |
| 5863 | |
| 5864 | static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd) |
| 5865 | { |
| 5866 | struct platform_device *pdev; |
| 5867 | uint32_t rc = 0; |
| 5868 | |
| 5869 | pdev = container_of(dv, struct platform_device, dev); |
| 5870 | rc = msm_sdcc_setup_power(dv, vdd); |
| 5871 | if (rc) { |
| 5872 | pr_err("%s: Failed to setup power (%d)\n", |
| 5873 | __func__, rc); |
| 5874 | goto out; |
| 5875 | } |
| 5876 | if (!mbp_power_init_done) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 5877 | rc = mbp_init_regs(dv); |
| 5878 | if (rc) { |
| 5879 | dev_err(dv, "%s: regulator init failed: %d\n", |
| 5880 | __func__, rc); |
| 5881 | goto out; |
| 5882 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5883 | mbp_setup_power(dv, 1); |
| 5884 | mbp_setup_power(dv, 0); |
| 5885 | mbp_power_init_done = 1; |
| 5886 | } |
| 5887 | if (vdd >= 0x8000) { |
| 5888 | rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1); |
| 5889 | if (rc) { |
| 5890 | pr_err("%s: Failed to config mbp chip power (%d)\n", |
| 5891 | __func__, rc); |
| 5892 | goto out; |
| 5893 | } |
| 5894 | if (mbp_status_notify_cb) { |
| 5895 | mbp_status_notify_cb(mbp_power_status, |
| 5896 | mbp_status_notify_cb_devid); |
| 5897 | } |
| 5898 | } |
| 5899 | out: |
| 5900 | /* should return 0 only */ |
| 5901 | return 0; |
| 5902 | } |
| 5903 | |
| 5904 | #endif |
| 5905 | |
| 5906 | #endif |
| 5907 | |
| 5908 | #ifdef CONFIG_MMC_MSM_SDC4_SUPPORT |
| 5909 | #ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION |
| 5910 | static unsigned int msm7x30_sdcc_slot_status(struct device *dev) |
| 5911 | { |
| 5912 | return (unsigned int) |
| 5913 | gpio_get_value_cansleep( |
| 5914 | PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1)); |
| 5915 | } |
| 5916 | #endif |
| 5917 | |
| 5918 | static int msm_sdcc_get_wpswitch(struct device *dv) |
| 5919 | { |
| 5920 | void __iomem *wp_addr = 0; |
| 5921 | uint32_t ret = 0; |
| 5922 | struct platform_device *pdev; |
| 5923 | |
| 5924 | if (!(machine_is_msm7x30_surf())) |
| 5925 | return -1; |
| 5926 | pdev = container_of(dv, struct platform_device, dev); |
| 5927 | |
| 5928 | wp_addr = ioremap(FPGA_SDCC_STATUS, 4); |
| 5929 | if (!wp_addr) { |
| 5930 | pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS); |
| 5931 | return -ENOMEM; |
| 5932 | } |
| 5933 | |
| 5934 | ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01); |
| 5935 | pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__, |
| 5936 | pdev->id, ret); |
| 5937 | iounmap(wp_addr); |
| 5938 | |
| 5939 | return ret; |
| 5940 | } |
| 5941 | #endif |
| 5942 | |
| 5943 | #if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) |
| 5944 | #if defined(CONFIG_CSDIO_VENDOR_ID) && \ |
| 5945 | defined(CONFIG_CSDIO_DEVICE_ID) && \ |
| 5946 | (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117) |
| 5947 | static struct mmc_platform_data msm7x30_sdc1_data = { |
| 5948 | .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29, |
| 5949 | .translate_vdd = msm_sdcc_setup_power_mbp, |
| 5950 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 5951 | .status = mbp_status, |
| 5952 | .register_status_notify = mbp_register_status_notify, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5953 | .msmsdcc_fmin = 144000, |
| 5954 | .msmsdcc_fmid = 24576000, |
| 5955 | .msmsdcc_fmax = 24576000, |
| 5956 | .nonremovable = 0, |
| 5957 | }; |
| 5958 | #else |
| 5959 | static struct mmc_platform_data msm7x30_sdc1_data = { |
| 5960 | .ocr_mask = MMC_VDD_165_195, |
| 5961 | .translate_vdd = msm_sdcc_setup_power, |
| 5962 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5963 | .msmsdcc_fmin = 144000, |
| 5964 | .msmsdcc_fmid = 24576000, |
| 5965 | .msmsdcc_fmax = 49152000, |
| 5966 | .nonremovable = 0, |
| 5967 | }; |
| 5968 | #endif |
| 5969 | #endif |
| 5970 | |
| 5971 | #ifdef CONFIG_MMC_MSM_SDC2_SUPPORT |
| 5972 | static struct mmc_platform_data msm7x30_sdc2_data = { |
| 5973 | .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28, |
| 5974 | .translate_vdd = msm_sdcc_setup_power, |
| 5975 | #ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT |
| 5976 | .mmc_bus_width = MMC_CAP_8_BIT_DATA, |
| 5977 | #else |
| 5978 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 5979 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5980 | .msmsdcc_fmin = 144000, |
| 5981 | .msmsdcc_fmid = 24576000, |
| 5982 | .msmsdcc_fmax = 49152000, |
| 5983 | .nonremovable = 1, |
| 5984 | }; |
| 5985 | #endif |
| 5986 | |
| 5987 | #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT |
| 5988 | static struct mmc_platform_data msm7x30_sdc3_data = { |
| 5989 | .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29, |
| 5990 | .translate_vdd = msm_sdcc_setup_power, |
| 5991 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 5992 | #ifdef CONFIG_MMC_MSM_SDIO_SUPPORT |
| 5993 | .sdiowakeup_irq = MSM_GPIO_TO_INT(118), |
| 5994 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5995 | .msmsdcc_fmin = 144000, |
| 5996 | .msmsdcc_fmid = 24576000, |
| 5997 | .msmsdcc_fmax = 49152000, |
| 5998 | .nonremovable = 0, |
| 5999 | }; |
| 6000 | #endif |
| 6001 | |
| 6002 | #ifdef CONFIG_MMC_MSM_SDC4_SUPPORT |
| 6003 | static struct mmc_platform_data msm7x30_sdc4_data = { |
| 6004 | .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29, |
| 6005 | .translate_vdd = msm_sdcc_setup_power, |
| 6006 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 6007 | #ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION |
| 6008 | .status = msm7x30_sdcc_slot_status, |
| 6009 | .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1), |
| 6010 | .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
| 6011 | #endif |
| 6012 | .wpswitch = msm_sdcc_get_wpswitch, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6013 | .msmsdcc_fmin = 144000, |
| 6014 | .msmsdcc_fmid = 24576000, |
| 6015 | .msmsdcc_fmax = 49152000, |
| 6016 | .nonremovable = 0, |
| 6017 | }; |
| 6018 | #endif |
| 6019 | |
| 6020 | #ifdef CONFIG_MMC_MSM_SDC1_SUPPORT |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6021 | static int msm_sdc1_lvlshft_enable(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6022 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6023 | static struct regulator *ldo5; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6024 | int rc; |
| 6025 | |
| 6026 | /* Enable LDO5, an input to the FET that powers slot 1 */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6027 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6028 | ldo5 = regulator_get(NULL, "ldo5"); |
| 6029 | |
| 6030 | if (IS_ERR(ldo5)) { |
| 6031 | rc = PTR_ERR(ldo5); |
| 6032 | pr_err("%s: could not get ldo5: %d\n", __func__, rc); |
| 6033 | goto out; |
| 6034 | } |
| 6035 | |
| 6036 | rc = regulator_set_voltage(ldo5, 2850000, 2850000); |
| 6037 | if (rc) { |
| 6038 | pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc); |
| 6039 | goto ldo5_free; |
| 6040 | } |
| 6041 | |
| 6042 | rc = regulator_enable(ldo5); |
| 6043 | if (rc) { |
| 6044 | pr_err("%s: could not enable ldo5: %d\n", __func__, rc); |
| 6045 | goto ldo5_free; |
| 6046 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6047 | |
| 6048 | /* Enable GPIO 35, to turn on the FET that powers slot 1 */ |
| 6049 | rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data, |
| 6050 | ARRAY_SIZE(sdc1_lvlshft_cfg_data)); |
| 6051 | if (rc) |
| 6052 | printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__); |
| 6053 | |
| 6054 | rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg), |
| 6055 | 1); |
| 6056 | if (rc) |
| 6057 | printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6058 | |
| 6059 | return 0; |
| 6060 | |
| 6061 | ldo5_free: |
| 6062 | regulator_put(ldo5); |
| 6063 | out: |
| 6064 | ldo5 = NULL; |
| 6065 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6066 | } |
| 6067 | #endif |
| 6068 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6069 | static int mmc_regulator_init(int sdcc_no, const char *supply, int uV) |
| 6070 | { |
| 6071 | int rc; |
| 6072 | |
| 6073 | BUG_ON(sdcc_no < 1 || sdcc_no > 4); |
| 6074 | |
| 6075 | sdcc_no--; |
| 6076 | |
| 6077 | sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply); |
| 6078 | |
| 6079 | if (IS_ERR(sdcc_vreg_data[sdcc_no])) { |
| 6080 | rc = PTR_ERR(sdcc_vreg_data[sdcc_no]); |
| 6081 | pr_err("%s: could not get regulator \"%s\": %d\n", |
| 6082 | __func__, supply, rc); |
| 6083 | goto out; |
| 6084 | } |
| 6085 | |
| 6086 | rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV); |
| 6087 | |
| 6088 | if (rc) { |
| 6089 | pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n", |
| 6090 | __func__, supply, uV, rc); |
| 6091 | goto reg_free; |
| 6092 | } |
| 6093 | |
| 6094 | return rc; |
| 6095 | |
| 6096 | reg_free: |
| 6097 | regulator_put(sdcc_vreg_data[sdcc_no]); |
| 6098 | out: |
| 6099 | sdcc_vreg_data[sdcc_no] = NULL; |
| 6100 | return rc; |
| 6101 | } |
| 6102 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6103 | static void __init msm7x30_init_mmc(void) |
| 6104 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6105 | #ifdef CONFIG_MMC_MSM_SDC1_SUPPORT |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6106 | if (mmc_regulator_init(1, "s3", 1800000)) |
| 6107 | goto out1; |
| 6108 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6109 | if (machine_is_msm7x30_fluid()) { |
| 6110 | msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6111 | if (msm_sdc1_lvlshft_enable()) { |
| 6112 | pr_err("%s: could not enable level shift\n"); |
| 6113 | goto out1; |
| 6114 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6115 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6116 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6117 | msm_add_sdcc(1, &msm7x30_sdc1_data); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6118 | out1: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6119 | #endif |
| 6120 | #ifdef CONFIG_MMC_MSM_SDC2_SUPPORT |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6121 | if (mmc_regulator_init(2, "s3", 1800000)) |
| 6122 | goto out2; |
| 6123 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6124 | if (machine_is_msm8x55_svlte_surf()) |
| 6125 | msm7x30_sdc2_data.msmsdcc_fmax = 24576000; |
Sujith Reddy Thumma | 84a0f51 | 2011-08-29 09:57:03 +0530 | [diff] [blame] | 6126 | if (machine_is_msm8x55_svlte_surf() || |
| 6127 | machine_is_msm8x55_svlte_ffa()) { |
| 6128 | msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68); |
| 6129 | msm7x30_sdc2_data.is_sdio_al_client = 1; |
| 6130 | } |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6131 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6132 | msm_add_sdcc(2, &msm7x30_sdc2_data); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6133 | out2: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6134 | #endif |
| 6135 | #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6136 | if (mmc_regulator_init(3, "s3", 1800000)) |
| 6137 | goto out3; |
| 6138 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6139 | msm_sdcc_setup_gpio(3, 1); |
| 6140 | msm_add_sdcc(3, &msm7x30_sdc3_data); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6141 | out3: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6142 | #endif |
| 6143 | #ifdef CONFIG_MMC_MSM_SDC4_SUPPORT |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6144 | if (mmc_regulator_init(4, "mmc", 2850000)) |
| 6145 | return; |
| 6146 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6147 | msm_add_sdcc(4, &msm7x30_sdc4_data); |
| 6148 | #endif |
| 6149 | |
| 6150 | } |
| 6151 | |
| 6152 | static void __init msm7x30_init_nand(void) |
| 6153 | { |
| 6154 | char *build_id; |
| 6155 | struct flash_platform_data *plat_data; |
| 6156 | |
| 6157 | build_id = socinfo_get_build_id(); |
| 6158 | if (build_id == NULL) { |
| 6159 | pr_err("%s: Build ID not available from socinfo\n", __func__); |
| 6160 | return; |
| 6161 | } |
| 6162 | |
| 6163 | if (build_id[8] == 'C' && |
| 6164 | !msm_gpios_request_enable(msm_nand_ebi2_cfg_data, |
| 6165 | ARRAY_SIZE(msm_nand_ebi2_cfg_data))) { |
| 6166 | plat_data = msm_device_nand.dev.platform_data; |
| 6167 | plat_data->interleave = 1; |
| 6168 | printk(KERN_INFO "%s: Interleave mode Build ID found\n", |
| 6169 | __func__); |
| 6170 | } |
| 6171 | } |
| 6172 | |
| 6173 | #ifdef CONFIG_SERIAL_MSM_CONSOLE |
| 6174 | static struct msm_gpio uart2_config_data[] = { |
| 6175 | { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"}, |
| 6176 | { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"}, |
| 6177 | { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"}, |
| 6178 | { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"}, |
| 6179 | }; |
| 6180 | |
| 6181 | static void msm7x30_init_uart2(void) |
| 6182 | { |
| 6183 | msm_gpios_request_enable(uart2_config_data, |
| 6184 | ARRAY_SIZE(uart2_config_data)); |
| 6185 | |
| 6186 | } |
| 6187 | #endif |
| 6188 | |
| 6189 | /* TSIF begin */ |
| 6190 | #if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) |
| 6191 | |
| 6192 | #define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) |
| 6193 | #define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) |
| 6194 | #define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) |
| 6195 | #define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) |
| 6196 | |
| 6197 | static const struct msm_gpio tsif_gpios[] = { |
| 6198 | { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", }, |
| 6199 | { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", }, |
| 6200 | { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", }, |
| 6201 | { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", }, |
| 6202 | }; |
| 6203 | |
| 6204 | static struct msm_tsif_platform_data tsif_platform_data = { |
| 6205 | .num_gpios = ARRAY_SIZE(tsif_gpios), |
| 6206 | .gpios = tsif_gpios, |
Matt Wagantall | 640e5fd | 2011-08-17 16:08:53 -0700 | [diff] [blame] | 6207 | .tsif_pclk = "iface_clk", |
| 6208 | .tsif_ref_clk = "ref_clk", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6209 | }; |
| 6210 | #endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */ |
| 6211 | /* TSIF end */ |
| 6212 | |
| 6213 | static void __init pmic8058_leds_init(void) |
| 6214 | { |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 6215 | if (machine_is_msm7x30_surf()) |
| 6216 | pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data; |
| 6217 | else if (!machine_is_msm7x30_fluid()) |
| 6218 | pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data; |
| 6219 | else if (machine_is_msm7x30_fluid()) |
| 6220 | pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6221 | } |
| 6222 | |
| 6223 | static struct msm_spm_platform_data msm_spm_data __initdata = { |
| 6224 | .reg_base_addr = MSM_SAW_BASE, |
| 6225 | |
| 6226 | .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05, |
| 6227 | .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18, |
| 6228 | .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666, |
| 6229 | .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666, |
| 6230 | |
| 6231 | .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01, |
| 6232 | .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03, |
| 6233 | .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00, |
| 6234 | |
| 6235 | .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01, |
| 6236 | .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00, |
| 6237 | .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00, |
| 6238 | |
| 6239 | .awake_vlevel = 0xF2, |
| 6240 | .retention_vlevel = 0xE0, |
| 6241 | .collapse_vlevel = 0x72, |
| 6242 | .retention_mid_vlevel = 0xE0, |
| 6243 | .collapse_mid_vlevel = 0xE0, |
| 6244 | |
| 6245 | .vctl_timeout_us = 50, |
| 6246 | }; |
| 6247 | |
| 6248 | #if defined(CONFIG_TOUCHSCREEN_TSC2007) || \ |
| 6249 | defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE) |
| 6250 | |
| 6251 | #define TSC2007_TS_PEN_INT 20 |
| 6252 | |
| 6253 | static struct msm_gpio tsc2007_config_data[] = { |
| 6254 | { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 6255 | "tsc2007_irq" }, |
| 6256 | }; |
| 6257 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6258 | static struct regulator_bulk_data tsc2007_regs[] = { |
| 6259 | { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 }, |
| 6260 | { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 }, |
| 6261 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6262 | |
| 6263 | static int tsc2007_init(void) |
| 6264 | { |
| 6265 | int rc; |
| 6266 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6267 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6268 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6269 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6270 | pr_err("%s: could not get regulators: %d\n", __func__, rc); |
| 6271 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6272 | } |
| 6273 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6274 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs); |
| 6275 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6276 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6277 | pr_err("%s: could not set voltages: %d\n", __func__, rc); |
| 6278 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6279 | } |
| 6280 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6281 | rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6282 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6283 | if (rc) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6284 | pr_err("%s: could not enable regulators: %d\n", __func__, rc); |
| 6285 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6286 | } |
| 6287 | |
| 6288 | rc = msm_gpios_request_enable(tsc2007_config_data, |
| 6289 | ARRAY_SIZE(tsc2007_config_data)); |
| 6290 | if (rc) { |
| 6291 | pr_err("%s: Unable to request gpios\n", __func__); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6292 | goto reg_disable; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6293 | } |
| 6294 | |
| 6295 | return 0; |
| 6296 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6297 | reg_disable: |
| 6298 | regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs); |
| 6299 | reg_free: |
| 6300 | regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs); |
| 6301 | out: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6302 | return rc; |
| 6303 | } |
| 6304 | |
| 6305 | static int tsc2007_get_pendown_state(void) |
| 6306 | { |
| 6307 | int rc; |
| 6308 | |
| 6309 | rc = gpio_get_value(TSC2007_TS_PEN_INT); |
| 6310 | if (rc < 0) { |
| 6311 | pr_err("%s: MSM GPIO %d read failed\n", __func__, |
| 6312 | TSC2007_TS_PEN_INT); |
| 6313 | return rc; |
| 6314 | } |
| 6315 | |
| 6316 | return (rc == 0 ? 1 : 0); |
| 6317 | } |
| 6318 | |
| 6319 | static void tsc2007_exit(void) |
| 6320 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6321 | |
| 6322 | regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs); |
| 6323 | regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6324 | |
| 6325 | msm_gpios_disable_free(tsc2007_config_data, |
| 6326 | ARRAY_SIZE(tsc2007_config_data)); |
| 6327 | } |
| 6328 | |
| 6329 | static int tsc2007_power_shutdown(bool enable) |
| 6330 | { |
| 6331 | int rc; |
| 6332 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6333 | rc = (enable == false) ? |
| 6334 | regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) : |
| 6335 | regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs); |
| 6336 | |
| 6337 | if (rc) { |
| 6338 | pr_err("%s: could not %sable regulators: %d\n", |
| 6339 | __func__, enable ? "dis" : "en", rc); |
| 6340 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6341 | } |
| 6342 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6343 | if (enable == false) |
| 6344 | msleep(20); |
| 6345 | |
| 6346 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6347 | } |
| 6348 | |
| 6349 | static struct tsc2007_platform_data tsc2007_ts_data = { |
| 6350 | .model = 2007, |
| 6351 | .x_plate_ohms = 300, |
| 6352 | .irq_flags = IRQF_TRIGGER_LOW, |
| 6353 | .init_platform_hw = tsc2007_init, |
| 6354 | .exit_platform_hw = tsc2007_exit, |
| 6355 | .power_shutdown = tsc2007_power_shutdown, |
| 6356 | .invert_x = true, |
| 6357 | .invert_y = true, |
| 6358 | /* REVISIT: Temporary fix for reversed pressure */ |
| 6359 | .invert_z1 = true, |
| 6360 | .invert_z2 = true, |
| 6361 | .get_pendown_state = tsc2007_get_pendown_state, |
| 6362 | }; |
| 6363 | |
| 6364 | static struct i2c_board_info tsc_i2c_board_info[] = { |
| 6365 | { |
| 6366 | I2C_BOARD_INFO("tsc2007", 0x48), |
| 6367 | .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT), |
| 6368 | .platform_data = &tsc2007_ts_data, |
| 6369 | }, |
| 6370 | }; |
| 6371 | #endif |
| 6372 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6373 | static struct regulator_bulk_data regs_isa1200[] = { |
| 6374 | { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 }, |
| 6375 | { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6376 | }; |
| 6377 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6378 | static int isa1200_power(int vreg_on) |
| 6379 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6380 | int rc = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6381 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6382 | rc = vreg_on ? |
| 6383 | regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) : |
| 6384 | regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6385 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6386 | if (rc) { |
| 6387 | pr_err("%s: could not %sable regulators: %d\n", |
| 6388 | __func__, vreg_on ? "en" : "dis", rc); |
| 6389 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6390 | } |
| 6391 | |
| 6392 | /* vote for DO buffer */ |
| 6393 | rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO, |
| 6394 | vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF); |
| 6395 | if (rc) { |
| 6396 | pr_err("%s: unable to %svote for d0 clk\n", |
| 6397 | __func__, vreg_on ? "" : "de-"); |
| 6398 | goto vreg_fail; |
| 6399 | } |
| 6400 | |
| 6401 | return 0; |
| 6402 | |
| 6403 | vreg_fail: |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6404 | if (vreg_on) |
| 6405 | regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200); |
| 6406 | else |
| 6407 | regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200); |
| 6408 | out: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6409 | return rc; |
| 6410 | } |
| 6411 | |
| 6412 | static int isa1200_dev_setup(bool enable) |
| 6413 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6414 | int rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6415 | |
| 6416 | if (enable == true) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6417 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200), |
| 6418 | regs_isa1200); |
| 6419 | |
| 6420 | if (rc) { |
| 6421 | pr_err("%s: could not get regulators: %d\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6422 | __func__, rc); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6423 | goto out; |
| 6424 | } |
| 6425 | |
| 6426 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200), |
| 6427 | regs_isa1200); |
| 6428 | if (rc) { |
| 6429 | pr_err("%s: could not set voltages: %d\n", |
| 6430 | __func__, rc); |
| 6431 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6432 | } |
| 6433 | |
| 6434 | rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0, |
| 6435 | GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, |
| 6436 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 6437 | if (rc) { |
| 6438 | pr_err("%s: Could not configure gpio %d\n", |
| 6439 | __func__, HAP_LVL_SHFT_MSM_GPIO); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6440 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6441 | } |
| 6442 | |
| 6443 | rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe"); |
| 6444 | if (rc) { |
| 6445 | pr_err("%s: unable to request gpio %d (%d)\n", |
| 6446 | __func__, HAP_LVL_SHFT_MSM_GPIO, rc); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6447 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6448 | } |
| 6449 | |
| 6450 | gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1); |
| 6451 | } else { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6452 | regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6453 | gpio_free(HAP_LVL_SHFT_MSM_GPIO); |
| 6454 | } |
| 6455 | |
| 6456 | return 0; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6457 | |
| 6458 | reg_free: |
| 6459 | regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200); |
| 6460 | out: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6461 | return rc; |
| 6462 | } |
| 6463 | static struct isa1200_platform_data isa1200_1_pdata = { |
| 6464 | .name = "vibrator", |
| 6465 | .power_on = isa1200_power, |
| 6466 | .dev_setup = isa1200_dev_setup, |
| 6467 | .pwm_ch_id = 1, /*channel id*/ |
| 6468 | /*gpio to enable haptic*/ |
| 6469 | .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE), |
Mohan Pallaka | 0312232 | 2011-09-09 15:15:43 +0530 | [diff] [blame] | 6470 | .hap_len_gpio = -1, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6471 | .max_timeout = 15000, |
| 6472 | .mode_ctrl = PWM_GEN_MODE, |
| 6473 | .pwm_fd = { |
| 6474 | .pwm_div = 256, |
| 6475 | }, |
| 6476 | .is_erm = false, |
| 6477 | .smart_en = true, |
| 6478 | .ext_clk_en = true, |
| 6479 | .chip_en = 1, |
| 6480 | }; |
| 6481 | |
| 6482 | static struct i2c_board_info msm_isa1200_board_info[] = { |
| 6483 | { |
| 6484 | I2C_BOARD_INFO("isa1200_1", 0x90>>1), |
| 6485 | .platform_data = &isa1200_1_pdata, |
| 6486 | }, |
| 6487 | }; |
| 6488 | |
| 6489 | |
| 6490 | static int kp_flip_mpp_config(void) |
| 6491 | { |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 6492 | struct pm8xxx_mpp_config_data kp_flip_mpp = { |
| 6493 | .type = PM8XXX_MPP_TYPE_D_INPUT, |
| 6494 | .level = PM8018_MPP_DIG_LEVEL_S3, |
| 6495 | .control = PM8XXX_MPP_DIN_TO_INT, |
| 6496 | }; |
| 6497 | |
| 6498 | return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP), |
| 6499 | &kp_flip_mpp); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6500 | } |
| 6501 | |
| 6502 | static struct flip_switch_pdata flip_switch_data = { |
| 6503 | .name = "kp_flip_switch", |
| 6504 | .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP, |
| 6505 | .left_key = KEY_OPEN, |
| 6506 | .right_key = KEY_CLOSE, |
| 6507 | .active_low = 0, |
| 6508 | .wakeup = 1, |
| 6509 | .flip_mpp_config = kp_flip_mpp_config, |
| 6510 | }; |
| 6511 | |
| 6512 | static struct platform_device flip_switch_device = { |
| 6513 | .name = "kp_flip_switch", |
| 6514 | .id = -1, |
| 6515 | .dev = { |
| 6516 | .platform_data = &flip_switch_data, |
| 6517 | } |
| 6518 | }; |
| 6519 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6520 | static struct regulator_bulk_data regs_tma300[] = { |
| 6521 | { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 }, |
| 6522 | { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6523 | }; |
| 6524 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6525 | static int tma300_power(int vreg_on) |
| 6526 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6527 | int rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6528 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6529 | rc = vreg_on ? |
| 6530 | regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) : |
| 6531 | regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6532 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6533 | if (rc) |
| 6534 | pr_err("%s: could not %sable regulators: %d\n", |
| 6535 | __func__, vreg_on ? "en" : "dis", rc); |
| 6536 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6537 | } |
| 6538 | |
| 6539 | #define TS_GPIO_IRQ 150 |
| 6540 | |
| 6541 | static int tma300_dev_setup(bool enable) |
| 6542 | { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6543 | int rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6544 | |
| 6545 | if (enable) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6546 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300), |
| 6547 | regs_tma300); |
| 6548 | |
| 6549 | if (rc) { |
| 6550 | pr_err("%s: could not get regulators: %d\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6551 | __func__, rc); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6552 | goto out; |
| 6553 | } |
| 6554 | |
| 6555 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300), |
| 6556 | regs_tma300); |
| 6557 | |
| 6558 | if (rc) { |
| 6559 | pr_err("%s: could not set voltages: %d\n", |
| 6560 | __func__, rc); |
| 6561 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6562 | } |
| 6563 | |
| 6564 | /* enable interrupt gpio */ |
| 6565 | rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT, |
| 6566 | GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE); |
| 6567 | if (rc) { |
| 6568 | pr_err("%s: Could not configure gpio %d\n", |
| 6569 | __func__, TS_GPIO_IRQ); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6570 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6571 | } |
| 6572 | |
| 6573 | /* virtual keys */ |
| 6574 | tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts"; |
| 6575 | properties_kobj = kobject_create_and_add("board_properties", |
| 6576 | NULL); |
| 6577 | if (!properties_kobj) { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6578 | pr_err("%s: failed to create a kobject " |
| 6579 | "for board_properties\n", __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6580 | rc = -ENOMEM; |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6581 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6582 | } |
| 6583 | rc = sysfs_create_group(properties_kobj, |
| 6584 | &tma300_properties_attr_group); |
| 6585 | if (rc) { |
| 6586 | pr_err("%s: failed to create a sysfs entry %s\n", |
| 6587 | __func__, tma300_vkeys_attr.attr.name); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6588 | goto kobj_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6589 | } |
| 6590 | } else { |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6591 | regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6592 | /* destroy virtual keys */ |
| 6593 | if (properties_kobj) { |
| 6594 | sysfs_remove_group(properties_kobj, |
| 6595 | &tma300_properties_attr_group); |
| 6596 | kobject_put(properties_kobj); |
| 6597 | } |
| 6598 | } |
| 6599 | return 0; |
| 6600 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6601 | kobj_free: |
| 6602 | kobject_put(properties_kobj); |
| 6603 | properties_kobj = NULL; |
| 6604 | reg_free: |
| 6605 | regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300); |
| 6606 | out: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6607 | return rc; |
| 6608 | } |
| 6609 | |
| 6610 | static struct cy8c_ts_platform_data cy8ctma300_pdata = { |
| 6611 | .power_on = tma300_power, |
| 6612 | .dev_setup = tma300_dev_setup, |
| 6613 | .ts_name = "msm_tma300_ts", |
| 6614 | .dis_min_x = 0, |
| 6615 | .dis_max_x = 479, |
| 6616 | .dis_min_y = 0, |
| 6617 | .dis_max_y = 799, |
| 6618 | .res_x = 479, |
| 6619 | .res_y = 1009, |
| 6620 | .min_tid = 1, |
| 6621 | .max_tid = 255, |
| 6622 | .min_touch = 0, |
| 6623 | .max_touch = 255, |
| 6624 | .min_width = 0, |
| 6625 | .max_width = 255, |
| 6626 | .invert_y = 1, |
| 6627 | .nfingers = 4, |
| 6628 | .irq_gpio = TS_GPIO_IRQ, |
| 6629 | .resout_gpio = -1, |
| 6630 | }; |
| 6631 | |
| 6632 | static struct i2c_board_info cy8ctma300_board_info[] = { |
| 6633 | { |
| 6634 | I2C_BOARD_INFO("cy8ctma300", 0x2), |
| 6635 | .platform_data = &cy8ctma300_pdata, |
| 6636 | } |
| 6637 | }; |
| 6638 | |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6639 | static void __init msm7x30_init(void) |
| 6640 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6641 | int rc; |
| 6642 | unsigned smem_size; |
| 6643 | uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56, |
| 6644 | 0, |
| 6645 | GPIO_CFG_OUTPUT, |
| 6646 | GPIO_CFG_NO_PULL, |
| 6647 | GPIO_CFG_2MA); |
| 6648 | uint32_t soc_version = 0; |
Pavankumar Kondeti | 5155e2c | 2010-12-08 13:37:08 +0530 | [diff] [blame] | 6649 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6650 | soc_version = socinfo_get_version(); |
| 6651 | |
Stephen Boyd | bb600ae | 2011-08-02 20:11:40 -0700 | [diff] [blame] | 6652 | msm_clock_init(&msm7x30_clock_init_data); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6653 | #ifdef CONFIG_SERIAL_MSM_CONSOLE |
| 6654 | msm7x30_init_uart2(); |
| 6655 | #endif |
| 6656 | msm_spm_init(&msm_spm_data, 1); |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 6657 | acpuclk_init(&acpuclk_7x30_soc_data); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6658 | if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid()) |
| 6659 | msm7x30_cfg_smsc911x(); |
| 6660 | |
| 6661 | #ifdef CONFIG_USB_MSM_OTG_72K |
| 6662 | if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 && |
| 6663 | SOCINFO_VERSION_MINOR(soc_version) >= 1) { |
| 6664 | pr_debug("%s: SOC Version:2.(1 or more)\n", __func__); |
| 6665 | msm_otg_pdata.ldo_set_voltage = 0; |
| 6666 | } |
| 6667 | |
| 6668 | msm_device_otg.dev.platform_data = &msm_otg_pdata; |
| 6669 | #ifdef CONFIG_USB_GADGET |
| 6670 | msm_otg_pdata.swfi_latency = |
| 6671 | msm_pm_data |
| 6672 | [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency; |
| 6673 | msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata; |
| 6674 | #endif |
| 6675 | #endif |
| 6676 | msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136); |
| 6677 | msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata; |
| 6678 | #if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) |
| 6679 | msm_device_tsif.dev.platform_data = &tsif_platform_data; |
| 6680 | #endif |
| 6681 | if (machine_is_msm7x30_fluid()) { |
| 6682 | msm_adc_pdata.dev_names = msm_adc_fluid_device_names; |
| 6683 | msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names); |
| 6684 | } else { |
| 6685 | msm_adc_pdata.dev_names = msm_adc_surf_device_names; |
| 6686 | msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names); |
| 6687 | } |
| 6688 | |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 6689 | pmic8058_leds_init(); |
| 6690 | |
| 6691 | buses_init(); |
| 6692 | |
Anirudh Ghayal | 9d9cdc2 | 2011-10-10 17:17:07 +0530 | [diff] [blame] | 6693 | #ifdef CONFIG_MSM_SSBI |
| 6694 | msm_device_ssbi_pmic1.dev.platform_data = |
| 6695 | &msm7x30_ssbi_pm8058_pdata; |
| 6696 | #endif |
| 6697 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6698 | platform_add_devices(msm_footswitch_devices, |
| 6699 | msm_num_footswitch_devices); |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6700 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6701 | #ifdef CONFIG_USB_EHCI_MSM_72K |
| 6702 | msm_add_host(0, &msm_usb_host_pdata); |
| 6703 | #endif |
| 6704 | msm7x30_init_mmc(); |
| 6705 | msm7x30_init_nand(); |
| 6706 | msm_qsd_spi_init(); |
| 6707 | |
| 6708 | #ifdef CONFIG_SPI_QSD |
| 6709 | if (machine_is_msm7x30_fluid()) |
| 6710 | spi_register_board_info(lcdc_sharp_spi_board_info, |
| 6711 | ARRAY_SIZE(lcdc_sharp_spi_board_info)); |
| 6712 | else |
| 6713 | spi_register_board_info(lcdc_toshiba_spi_board_info, |
| 6714 | ARRAY_SIZE(lcdc_toshiba_spi_board_info)); |
| 6715 | #endif |
| 6716 | |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6717 | atv_dac_power_init(); |
| 6718 | sensors_ldo_init(); |
| 6719 | hdmi_init_regs(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6720 | msm_fb_add_devices(); |
| 6721 | msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data)); |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 6722 | BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6723 | msm_device_i2c_init(); |
| 6724 | msm_device_i2c_2_init(); |
| 6725 | qup_device_i2c_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6726 | msm7x30_init_marimba(); |
| 6727 | #ifdef CONFIG_MSM7KV2_AUDIO |
| 6728 | snddev_poweramp_gpio_init(); |
Justin Paupore | 3f40f34 | 2011-08-10 18:52:16 -0700 | [diff] [blame] | 6729 | snddev_hsed_voltage_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6730 | aux_pcm_gpio_init(); |
| 6731 | #endif |
| 6732 | |
| 6733 | i2c_register_board_info(0, msm_i2c_board_info, |
| 6734 | ARRAY_SIZE(msm_i2c_board_info)); |
| 6735 | |
| 6736 | if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid()) |
| 6737 | marimba_pdata.tsadc = &marimba_tsadc_pdata; |
| 6738 | |
| 6739 | if (machine_is_msm7x30_fluid()) |
| 6740 | i2c_register_board_info(0, cy8info, |
| 6741 | ARRAY_SIZE(cy8info)); |
| 6742 | #ifdef CONFIG_BOSCH_BMA150 |
| 6743 | if (machine_is_msm7x30_fluid()) |
| 6744 | i2c_register_board_info(0, bma150_board_info, |
| 6745 | ARRAY_SIZE(bma150_board_info)); |
| 6746 | #endif |
| 6747 | |
| 6748 | i2c_register_board_info(2, msm_marimba_board_info, |
| 6749 | ARRAY_SIZE(msm_marimba_board_info)); |
| 6750 | |
| 6751 | i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info, |
| 6752 | ARRAY_SIZE(msm_i2c_gsbi7_timpani_info)); |
| 6753 | |
| 6754 | i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo, |
| 6755 | ARRAY_SIZE(msm_camera_boardinfo)); |
| 6756 | |
| 6757 | bt_power_init(); |
| 6758 | #ifdef CONFIG_I2C_SSBI |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6759 | msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata; |
| 6760 | #endif |
| 6761 | if (machine_is_msm7x30_fluid()) |
| 6762 | i2c_register_board_info(0, msm_isa1200_board_info, |
| 6763 | ARRAY_SIZE(msm_isa1200_board_info)); |
| 6764 | |
| 6765 | #if defined(CONFIG_TOUCHSCREEN_TSC2007) || \ |
| 6766 | defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE) |
| 6767 | if (machine_is_msm8x55_svlte_ffa()) |
| 6768 | i2c_register_board_info(2, tsc_i2c_board_info, |
| 6769 | ARRAY_SIZE(tsc_i2c_board_info)); |
| 6770 | #endif |
| 6771 | |
| 6772 | if (machine_is_msm7x30_surf()) |
| 6773 | platform_device_register(&flip_switch_device); |
Anirudh Ghayal | c201933 | 2011-11-12 06:29:10 +0530 | [diff] [blame] | 6774 | |
| 6775 | pm8058_gpios_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6776 | |
| 6777 | if (machine_is_msm7x30_fluid()) { |
| 6778 | /* Initialize platform data for fluid v2 hardware */ |
| 6779 | if (SOCINFO_VERSION_MAJOR( |
| 6780 | socinfo_get_platform_version()) == 2) { |
| 6781 | cy8ctma300_pdata.res_y = 920; |
| 6782 | cy8ctma300_pdata.invert_y = 0; |
| 6783 | } |
| 6784 | i2c_register_board_info(0, cy8ctma300_board_info, |
| 6785 | ARRAY_SIZE(cy8ctma300_board_info)); |
| 6786 | } |
| 6787 | |
| 6788 | if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) { |
| 6789 | rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE); |
| 6790 | if (rc) |
| 6791 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 6792 | __func__, usb_hub_gpio_cfg_value, rc); |
| 6793 | } |
| 6794 | |
| 6795 | boot_reason = *(unsigned int *) |
| 6796 | (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size)); |
| 6797 | printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason); |
| 6798 | } |
| 6799 | |
| 6800 | static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE; |
| 6801 | static int __init pmem_sf_size_setup(char *p) |
| 6802 | { |
| 6803 | pmem_sf_size = memparse(p, NULL); |
| 6804 | return 0; |
| 6805 | } |
| 6806 | early_param("pmem_sf_size", pmem_sf_size_setup); |
| 6807 | |
| 6808 | static unsigned fb_size = MSM_FB_SIZE; |
| 6809 | static int __init fb_size_setup(char *p) |
| 6810 | { |
| 6811 | fb_size = memparse(p, NULL); |
| 6812 | return 0; |
| 6813 | } |
| 6814 | early_param("fb_size", fb_size_setup); |
| 6815 | |
| 6816 | static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE; |
| 6817 | static int __init pmem_adsp_size_setup(char *p) |
| 6818 | { |
| 6819 | pmem_adsp_size = memparse(p, NULL); |
| 6820 | return 0; |
| 6821 | } |
| 6822 | early_param("pmem_adsp_size", pmem_adsp_size_setup); |
| 6823 | |
| 6824 | static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE; |
| 6825 | static int __init fluid_pmem_adsp_size_setup(char *p) |
| 6826 | { |
| 6827 | fluid_pmem_adsp_size = memparse(p, NULL); |
| 6828 | return 0; |
| 6829 | } |
| 6830 | early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup); |
| 6831 | |
| 6832 | static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE; |
| 6833 | static int __init pmem_audio_size_setup(char *p) |
| 6834 | { |
| 6835 | pmem_audio_size = memparse(p, NULL); |
| 6836 | return 0; |
| 6837 | } |
| 6838 | early_param("pmem_audio_size", pmem_audio_size_setup); |
| 6839 | |
| 6840 | static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE; |
| 6841 | static int __init pmem_kernel_ebi0_size_setup(char *p) |
| 6842 | { |
| 6843 | pmem_kernel_ebi0_size = memparse(p, NULL); |
| 6844 | return 0; |
| 6845 | } |
| 6846 | early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup); |
| 6847 | |
| 6848 | static struct memtype_reserve msm7x30_reserve_table[] __initdata = { |
| 6849 | [MEMTYPE_SMI] = { |
| 6850 | }, |
| 6851 | [MEMTYPE_EBI0] = { |
| 6852 | .flags = MEMTYPE_FLAGS_1M_ALIGN, |
| 6853 | }, |
| 6854 | [MEMTYPE_EBI1] = { |
| 6855 | .flags = MEMTYPE_FLAGS_1M_ALIGN, |
| 6856 | }, |
| 6857 | }; |
| 6858 | |
| 6859 | static void __init size_pmem_devices(void) |
| 6860 | { |
| 6861 | #ifdef CONFIG_ANDROID_PMEM |
| 6862 | unsigned long size; |
| 6863 | |
| 6864 | if machine_is_msm7x30_fluid() |
| 6865 | size = fluid_pmem_adsp_size; |
| 6866 | else |
| 6867 | size = pmem_adsp_size; |
| 6868 | android_pmem_adsp_pdata.size = size; |
| 6869 | android_pmem_audio_pdata.size = pmem_audio_size; |
| 6870 | android_pmem_pdata.size = pmem_sf_size; |
| 6871 | #endif |
| 6872 | } |
| 6873 | |
| 6874 | static void __init reserve_memory_for(struct android_pmem_platform_data *p) |
| 6875 | { |
| 6876 | msm7x30_reserve_table[p->memory_type].size += p->size; |
| 6877 | } |
| 6878 | |
| 6879 | static void __init reserve_pmem_memory(void) |
| 6880 | { |
| 6881 | #ifdef CONFIG_ANDROID_PMEM |
| 6882 | reserve_memory_for(&android_pmem_adsp_pdata); |
| 6883 | reserve_memory_for(&android_pmem_audio_pdata); |
| 6884 | reserve_memory_for(&android_pmem_pdata); |
| 6885 | msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size; |
| 6886 | #endif |
| 6887 | } |
| 6888 | |
| 6889 | static void __init msm7x30_calculate_reserve_sizes(void) |
| 6890 | { |
| 6891 | size_pmem_devices(); |
| 6892 | reserve_pmem_memory(); |
| 6893 | } |
| 6894 | |
| 6895 | static int msm7x30_paddr_to_memtype(unsigned int paddr) |
| 6896 | { |
| 6897 | if (paddr < 0x40000000) |
| 6898 | return MEMTYPE_EBI0; |
| 6899 | if (paddr >= 0x40000000 && paddr < 0x80000000) |
| 6900 | return MEMTYPE_EBI1; |
| 6901 | return MEMTYPE_NONE; |
| 6902 | } |
| 6903 | |
| 6904 | static struct reserve_info msm7x30_reserve_info __initdata = { |
| 6905 | .memtype_reserve_table = msm7x30_reserve_table, |
| 6906 | .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes, |
| 6907 | .paddr_to_memtype = msm7x30_paddr_to_memtype, |
| 6908 | }; |
| 6909 | |
| 6910 | static void __init msm7x30_reserve(void) |
| 6911 | { |
| 6912 | reserve_info = &msm7x30_reserve_info; |
| 6913 | msm_reserve(); |
| 6914 | } |
| 6915 | |
| 6916 | static void __init msm7x30_allocate_memory_regions(void) |
| 6917 | { |
| 6918 | void *addr; |
| 6919 | unsigned long size; |
| 6920 | |
| 6921 | size = fb_size ? : MSM_FB_SIZE; |
| 6922 | addr = alloc_bootmem_align(size, 0x1000); |
| 6923 | msm_fb_resources[0].start = __pa(addr); |
| 6924 | msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1; |
| 6925 | pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", |
| 6926 | size, addr, __pa(addr)); |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6927 | } |
| 6928 | |
| 6929 | static void __init msm7x30_map_io(void) |
| 6930 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6931 | msm_shared_ram_phys = 0x00100000; |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6932 | msm_map_msm7x30_io(); |
Jeff Ohlstein | 3a77f9f | 2011-09-06 14:50:20 -0700 | [diff] [blame] | 6933 | if (socinfo_init() < 0) |
| 6934 | printk(KERN_ERR "%s: socinfo_init() failed!\n", |
| 6935 | __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6936 | } |
| 6937 | |
| 6938 | static void __init msm7x30_init_early(void) |
| 6939 | { |
| 6940 | msm7x30_allocate_memory_regions(); |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6941 | } |
| 6942 | |
| 6943 | MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF") |
Russell King | b75c178 | 2011-01-04 19:03:16 +0000 | [diff] [blame] | 6944 | .boot_params = PLAT_PHYS_OFFSET + 0x100, |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6945 | .map_io = msm7x30_map_io, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6946 | .reserve = msm7x30_reserve, |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6947 | .init_irq = msm7x30_init_irq, |
| 6948 | .init_machine = msm7x30_init, |
| 6949 | .timer = &msm_timer, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6950 | .init_early = msm7x30_init_early, |
Taniya Das | bae99fb | 2011-10-12 09:55:13 +0530 | [diff] [blame] | 6951 | .handle_irq = vic_handle_irq, |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6952 | MACHINE_END |
| 6953 | |
| 6954 | MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA") |
Russell King | b75c178 | 2011-01-04 19:03:16 +0000 | [diff] [blame] | 6955 | .boot_params = PLAT_PHYS_OFFSET + 0x100, |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6956 | .map_io = msm7x30_map_io, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6957 | .reserve = msm7x30_reserve, |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6958 | .init_irq = msm7x30_init_irq, |
| 6959 | .init_machine = msm7x30_init, |
| 6960 | .timer = &msm_timer, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6961 | .init_early = msm7x30_init_early, |
Taniya Das | bae99fb | 2011-10-12 09:55:13 +0530 | [diff] [blame] | 6962 | .handle_irq = vic_handle_irq, |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6963 | MACHINE_END |
| 6964 | |
| 6965 | MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID") |
Russell King | b75c178 | 2011-01-04 19:03:16 +0000 | [diff] [blame] | 6966 | .boot_params = PLAT_PHYS_OFFSET + 0x100, |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6967 | .map_io = msm7x30_map_io, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6968 | .reserve = msm7x30_reserve, |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 6969 | .init_irq = msm7x30_init_irq, |
| 6970 | .init_machine = msm7x30_init, |
| 6971 | .timer = &msm_timer, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6972 | .init_early = msm7x30_init_early, |
Taniya Das | bae99fb | 2011-10-12 09:55:13 +0530 | [diff] [blame] | 6973 | .handle_irq = vic_handle_irq, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6974 | MACHINE_END |
| 6975 | |
| 6976 | MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF") |
| 6977 | .boot_params = PHYS_OFFSET + 0x100, |
| 6978 | .map_io = msm7x30_map_io, |
| 6979 | .reserve = msm7x30_reserve, |
| 6980 | .init_irq = msm7x30_init_irq, |
| 6981 | .init_machine = msm7x30_init, |
| 6982 | .timer = &msm_timer, |
| 6983 | .init_early = msm7x30_init_early, |
Taniya Das | bae99fb | 2011-10-12 09:55:13 +0530 | [diff] [blame] | 6984 | .handle_irq = vic_handle_irq, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6985 | MACHINE_END |
| 6986 | |
| 6987 | MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA") |
| 6988 | .boot_params = PHYS_OFFSET + 0x100, |
| 6989 | .map_io = msm7x30_map_io, |
| 6990 | .reserve = msm7x30_reserve, |
| 6991 | .init_irq = msm7x30_init_irq, |
| 6992 | .init_machine = msm7x30_init, |
| 6993 | .timer = &msm_timer, |
| 6994 | .init_early = msm7x30_init_early, |
Taniya Das | bae99fb | 2011-10-12 09:55:13 +0530 | [diff] [blame] | 6995 | .handle_irq = vic_handle_irq, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 6996 | MACHINE_END |
| 6997 | MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF") |
| 6998 | .boot_params = PHYS_OFFSET + 0x100, |
| 6999 | .map_io = msm7x30_map_io, |
| 7000 | .reserve = msm7x30_reserve, |
| 7001 | .init_irq = msm7x30_init_irq, |
| 7002 | .init_machine = msm7x30_init, |
| 7003 | .timer = &msm_timer, |
| 7004 | .init_early = msm7x30_init_early, |
Taniya Das | bae99fb | 2011-10-12 09:55:13 +0530 | [diff] [blame] | 7005 | .handle_irq = vic_handle_irq, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 7006 | MACHINE_END |
| 7007 | MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA") |
| 7008 | .boot_params = PHYS_OFFSET + 0x100, |
| 7009 | .map_io = msm7x30_map_io, |
| 7010 | .reserve = msm7x30_reserve, |
| 7011 | .init_irq = msm7x30_init_irq, |
| 7012 | .init_machine = msm7x30_init, |
| 7013 | .timer = &msm_timer, |
| 7014 | .init_early = msm7x30_init_early, |
Taniya Das | bae99fb | 2011-10-12 09:55:13 +0530 | [diff] [blame] | 7015 | .handle_irq = vic_handle_irq, |
Daniel Walker | 8d747cd | 2010-02-25 11:37:43 -0800 | [diff] [blame] | 7016 | MACHINE_END |