Sravan Kumar Ambapuram | b22cf4d | 2012-01-02 21:45:04 +0530 | [diff] [blame^] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [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 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/gpio_event.h> |
Pankaj Kumar | 6f84174 | 2011-10-10 15:52:14 +0530 | [diff] [blame] | 16 | #include <linux/usb/android.h> |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/io.h> |
| 19 | #include <linux/gpio.h> |
| 20 | #include <linux/mtd/nand.h> |
| 21 | #include <linux/mtd/partitions.h> |
| 22 | #include <linux/i2c.h> |
| 23 | #include <linux/android_pmem.h> |
| 24 | #include <linux/bootmem.h> |
| 25 | #include <linux/mfd/marimba.h> |
| 26 | #include <linux/power_supply.h> |
Taniya Das | da40882 | 2011-09-06 12:54:06 +0530 | [diff] [blame] | 27 | #include <linux/input/rmi_platformdata.h> |
| 28 | #include <linux/input/rmi_i2c.h> |
Pankaj Kumar | 3cec058 | 2011-11-18 11:13:29 +0530 | [diff] [blame] | 29 | #include <linux/regulator/consumer.h> |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 30 | #include <asm/mach/mmc.h> |
| 31 | #include <asm/mach-types.h> |
| 32 | #include <asm/mach/arch.h> |
| 33 | #include <mach/board.h> |
| 34 | #include <mach/msm_iomap.h> |
| 35 | #include <mach/msm_hsusb.h> |
| 36 | #include <mach/rpc_hsusb.h> |
| 37 | #include <mach/rpc_pmapp.h> |
| 38 | #include <mach/usbdiag.h> |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 39 | #include <mach/msm_memtypes.h> |
| 40 | #include <mach/msm_serial_hs.h> |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 41 | #include <mach/pmic.h> |
| 42 | #include <mach/socinfo.h> |
| 43 | #include <mach/vreg.h> |
| 44 | #include <mach/rpc_pmapp.h> |
| 45 | #include <mach/msm_battery.h> |
| 46 | #include <mach/rpc_server_handset.h> |
| 47 | #include <mach/socinfo.h> |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 48 | #include "board-msm7x27a-regulator.h" |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 49 | #include "devices.h" |
| 50 | #include "devices-msm7x2xa.h" |
| 51 | #include "pm.h" |
| 52 | #include "timer.h" |
Murali Nalajala | a182784 | 2011-11-13 14:12:39 +0530 | [diff] [blame] | 53 | #include "pm-boot.h" |
Pankaj Kumar | 3cec058 | 2011-11-18 11:13:29 +0530 | [diff] [blame] | 54 | #include "board-msm7x27a-regulator.h" |
Chintan Pandya | cf467fc | 2011-12-01 17:11:11 +0530 | [diff] [blame] | 55 | #include "board-msm7627a.h" |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 56 | |
| 57 | #define PMEM_KERNEL_EBI1_SIZE 0x3A000 |
| 58 | #define MSM_PMEM_AUDIO_SIZE 0x5B000 |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 59 | #define BAHAMA_SLAVE_ID_FM_REG 0x02 |
| 60 | #define FM_GPIO 83 |
Rahul Kashyap | 8b4a786 | 2011-12-13 18:40:54 +0530 | [diff] [blame] | 61 | #define BT_PCM_BCLK_MODE 0x88 |
| 62 | #define BT_PCM_DIN_MODE 0x89 |
| 63 | #define BT_PCM_DOUT_MODE 0x8A |
| 64 | #define BT_PCM_SYNC_MODE 0x8B |
| 65 | #define FM_I2S_SD_MODE 0x8E |
| 66 | #define FM_I2S_WS_MODE 0x8F |
| 67 | #define FM_I2S_SCK_MODE 0x90 |
| 68 | #define I2C_PIN_CTL 0x15 |
| 69 | #define I2C_NORMAL 0x40 |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 70 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 71 | static struct platform_device msm_wlan_ar6000_pm_device = { |
| 72 | .name = "wlan_ar6000_pm_dev", |
| 73 | .id = -1, |
| 74 | }; |
| 75 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 76 | static struct msm_gpio qup_i2c_gpios_io[] = { |
| 77 | { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 78 | "qup_scl" }, |
| 79 | { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 80 | "qup_sda" }, |
| 81 | { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 82 | "qup_scl" }, |
| 83 | { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 84 | "qup_sda" }, |
| 85 | }; |
| 86 | |
| 87 | static struct msm_gpio qup_i2c_gpios_hw[] = { |
| 88 | { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 89 | "qup_scl" }, |
| 90 | { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 91 | "qup_sda" }, |
| 92 | { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 93 | "qup_scl" }, |
| 94 | { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 95 | "qup_sda" }, |
| 96 | }; |
| 97 | |
| 98 | static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type) |
| 99 | { |
| 100 | int rc; |
| 101 | |
| 102 | if (adap_id < 0 || adap_id > 1) |
| 103 | return; |
| 104 | |
| 105 | /* Each adapter gets 2 lines from the table */ |
| 106 | if (config_type) |
| 107 | rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2); |
| 108 | else |
| 109 | rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2); |
| 110 | if (rc < 0) |
| 111 | pr_err("QUP GPIO request/enable failed: %d\n", rc); |
| 112 | } |
| 113 | |
| 114 | static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = { |
| 115 | .clk_freq = 100000, |
| 116 | .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config, |
| 117 | }; |
| 118 | |
| 119 | static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = { |
| 120 | .clk_freq = 100000, |
| 121 | .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config, |
| 122 | }; |
| 123 | |
| 124 | #ifdef CONFIG_ARCH_MSM7X27A |
| 125 | #define MSM_PMEM_MDP_SIZE 0x1DD1000 |
| 126 | #define MSM_PMEM_ADSP_SIZE 0x1000000 |
| 127 | |
| 128 | #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER |
| 129 | #define MSM_FB_SIZE 0x260000 |
| 130 | #else |
| 131 | #define MSM_FB_SIZE 0x195000 |
| 132 | #endif |
| 133 | |
| 134 | #endif |
| 135 | |
Taniya Das | da40882 | 2011-09-06 12:54:06 +0530 | [diff] [blame] | 136 | #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \ |
| 137 | defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE) |
| 138 | |
| 139 | #ifndef CLEARPAD3000_ATTEN_GPIO |
| 140 | #define CLEARPAD3000_ATTEN_GPIO (48) |
| 141 | #endif |
| 142 | |
| 143 | #ifndef CLEARPAD3000_RESET_GPIO |
| 144 | #define CLEARPAD3000_RESET_GPIO (26) |
| 145 | #endif |
| 146 | |
| 147 | static int synaptics_touchpad_setup(void); |
| 148 | |
| 149 | static struct msm_gpio clearpad3000_cfg_data[] = { |
| 150 | {GPIO_CFG(CLEARPAD3000_ATTEN_GPIO, 0, GPIO_CFG_INPUT, |
| 151 | GPIO_CFG_NO_PULL, GPIO_CFG_6MA), "rmi4_attn"}, |
| 152 | {GPIO_CFG(CLEARPAD3000_RESET_GPIO, 0, GPIO_CFG_OUTPUT, |
| 153 | GPIO_CFG_PULL_DOWN, GPIO_CFG_8MA), "rmi4_reset"}, |
| 154 | }; |
| 155 | |
| 156 | static struct rmi_XY_pair rmi_offset = {.x = 0, .y = 0}; |
| 157 | static struct rmi_range rmi_clipx = {.min = 48, .max = 980}; |
| 158 | static struct rmi_range rmi_clipy = {.min = 7, .max = 1647}; |
| 159 | static struct rmi_f11_functiondata synaptics_f11_data = { |
| 160 | .swap_axes = false, |
| 161 | .flipX = false, |
| 162 | .flipY = false, |
| 163 | .offset = &rmi_offset, |
| 164 | .button_height = 113, |
| 165 | .clipX = &rmi_clipx, |
| 166 | .clipY = &rmi_clipy, |
| 167 | }; |
| 168 | |
| 169 | #define MAX_LEN 100 |
| 170 | |
| 171 | static ssize_t clearpad3000_virtual_keys_register(struct kobject *kobj, |
| 172 | struct kobj_attribute *attr, char *buf) |
| 173 | { |
| 174 | char *virtual_keys = __stringify(EV_KEY) ":" __stringify(KEY_MENU) \ |
| 175 | ":60:830:120:60" ":" __stringify(EV_KEY) \ |
| 176 | ":" __stringify(KEY_HOME) ":180:830:120:60" \ |
| 177 | ":" __stringify(EV_KEY) ":" \ |
| 178 | __stringify(KEY_SEARCH) ":300:830:120:60" \ |
| 179 | ":" __stringify(EV_KEY) ":" \ |
| 180 | __stringify(KEY_BACK) ":420:830:120:60" "\n"; |
| 181 | |
| 182 | return snprintf(buf, strnlen(virtual_keys, MAX_LEN) + 1 , "%s", |
| 183 | virtual_keys); |
| 184 | } |
| 185 | |
| 186 | static struct kobj_attribute clearpad3000_virtual_keys_attr = { |
| 187 | .attr = { |
| 188 | .name = "virtualkeys.sensor00fn11", |
| 189 | .mode = S_IRUGO, |
| 190 | }, |
| 191 | .show = &clearpad3000_virtual_keys_register, |
| 192 | }; |
| 193 | |
| 194 | static struct attribute *virtual_key_properties_attrs[] = { |
| 195 | &clearpad3000_virtual_keys_attr.attr, |
| 196 | NULL |
| 197 | }; |
| 198 | |
| 199 | static struct attribute_group virtual_key_properties_attr_group = { |
| 200 | .attrs = virtual_key_properties_attrs, |
| 201 | }; |
| 202 | |
| 203 | struct kobject *virtual_key_properties_kobj; |
| 204 | |
| 205 | static struct rmi_functiondata synaptics_functiondata[] = { |
| 206 | { |
| 207 | .function_index = RMI_F11_INDEX, |
| 208 | .data = &synaptics_f11_data, |
| 209 | }, |
| 210 | }; |
| 211 | |
| 212 | static struct rmi_functiondata_list synaptics_perfunctiondata = { |
| 213 | .count = ARRAY_SIZE(synaptics_functiondata), |
| 214 | .functiondata = synaptics_functiondata, |
| 215 | }; |
| 216 | |
| 217 | static struct rmi_sensordata synaptics_sensordata = { |
| 218 | .perfunctiondata = &synaptics_perfunctiondata, |
| 219 | .rmi_sensor_setup = synaptics_touchpad_setup, |
| 220 | }; |
| 221 | |
| 222 | static struct rmi_i2c_platformdata synaptics_platformdata = { |
| 223 | .i2c_address = 0x2c, |
| 224 | .irq_type = IORESOURCE_IRQ_LOWLEVEL, |
| 225 | .sensordata = &synaptics_sensordata, |
| 226 | }; |
| 227 | |
| 228 | static struct i2c_board_info synaptic_i2c_clearpad3k[] = { |
| 229 | { |
| 230 | I2C_BOARD_INFO("rmi4_ts", 0x2c), |
| 231 | .platform_data = &synaptics_platformdata, |
| 232 | }, |
| 233 | }; |
| 234 | |
| 235 | static int synaptics_touchpad_setup(void) |
| 236 | { |
| 237 | int retval = 0; |
| 238 | |
| 239 | virtual_key_properties_kobj = |
| 240 | kobject_create_and_add("board_properties", NULL); |
| 241 | if (virtual_key_properties_kobj) |
| 242 | retval = sysfs_create_group(virtual_key_properties_kobj, |
| 243 | &virtual_key_properties_attr_group); |
| 244 | if (!virtual_key_properties_kobj || retval) |
| 245 | pr_err("failed to create ft5202 board_properties\n"); |
| 246 | |
| 247 | retval = msm_gpios_request_enable(clearpad3000_cfg_data, |
| 248 | sizeof(clearpad3000_cfg_data)/sizeof(struct msm_gpio)); |
| 249 | if (retval) { |
| 250 | pr_err("%s:Failed to obtain touchpad GPIO %d. Code: %d.", |
| 251 | __func__, CLEARPAD3000_ATTEN_GPIO, retval); |
| 252 | retval = 0; /* ignore the err */ |
| 253 | } |
| 254 | synaptics_platformdata.irq = gpio_to_irq(CLEARPAD3000_ATTEN_GPIO); |
| 255 | |
| 256 | gpio_set_value(CLEARPAD3000_RESET_GPIO, 0); |
| 257 | usleep(10000); |
| 258 | gpio_set_value(CLEARPAD3000_RESET_GPIO, 1); |
| 259 | usleep(50000); |
| 260 | |
| 261 | return retval; |
| 262 | } |
| 263 | #endif |
| 264 | |
| 265 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 266 | static struct android_usb_platform_data android_usb_pdata = { |
Pankaj Kumar | 6f84174 | 2011-10-10 15:52:14 +0530 | [diff] [blame] | 267 | .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num, |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 268 | }; |
| 269 | |
| 270 | static struct platform_device android_usb_device = { |
| 271 | .name = "android_usb", |
| 272 | .id = -1, |
| 273 | .dev = { |
| 274 | .platform_data = &android_usb_pdata, |
| 275 | }, |
| 276 | }; |
| 277 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 278 | #ifdef CONFIG_USB_EHCI_MSM_72K |
| 279 | static void msm_hsusb_vbus_power(unsigned phy_info, int on) |
| 280 | { |
| 281 | int rc = 0; |
| 282 | unsigned gpio; |
| 283 | |
Chintan Pandya | 03b0120 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 284 | gpio = QRD_GPIO_HOST_VBUS_EN; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 285 | |
| 286 | rc = gpio_request(gpio, "i2c_host_vbus_en"); |
| 287 | if (rc < 0) { |
| 288 | pr_err("failed to request %d GPIO\n", gpio); |
| 289 | return; |
| 290 | } |
| 291 | gpio_direction_output(gpio, !!on); |
| 292 | gpio_set_value_cansleep(gpio, !!on); |
| 293 | gpio_free(gpio); |
| 294 | } |
| 295 | |
| 296 | static struct msm_usb_host_platform_data msm_usb_host_pdata = { |
| 297 | .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM), |
| 298 | }; |
| 299 | |
| 300 | static void __init msm7627a_init_host(void) |
| 301 | { |
| 302 | msm_add_host(0, &msm_usb_host_pdata); |
| 303 | } |
| 304 | #endif |
| 305 | |
| 306 | #ifdef CONFIG_USB_MSM_OTG_72K |
| 307 | static int hsusb_rpc_connect(int connect) |
| 308 | { |
| 309 | if (connect) |
| 310 | return msm_hsusb_rpc_connect(); |
| 311 | else |
| 312 | return msm_hsusb_rpc_close(); |
| 313 | } |
| 314 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 315 | static struct regulator *reg_hsusb; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 316 | static int msm_hsusb_ldo_init(int init) |
| 317 | { |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 318 | int rc = 0; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 319 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 320 | if (init) { |
| 321 | reg_hsusb = regulator_get(NULL, "usb"); |
| 322 | if (IS_ERR(reg_hsusb)) { |
| 323 | rc = PTR_ERR(reg_hsusb); |
| 324 | pr_err("%s: could not get regulator: %d\n", |
| 325 | __func__, rc); |
| 326 | goto out; |
| 327 | } |
| 328 | |
| 329 | rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000); |
| 330 | if (rc) { |
| 331 | pr_err("%s: could not set voltage: %d\n", |
| 332 | __func__, rc); |
| 333 | goto reg_free; |
| 334 | } |
| 335 | |
| 336 | return 0; |
| 337 | } |
| 338 | /* else fall through */ |
| 339 | reg_free: |
| 340 | regulator_put(reg_hsusb); |
| 341 | out: |
| 342 | reg_hsusb = NULL; |
| 343 | return rc; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | static int msm_hsusb_ldo_enable(int enable) |
| 347 | { |
| 348 | static int ldo_status; |
| 349 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 350 | if (IS_ERR_OR_NULL(reg_hsusb)) |
| 351 | return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 352 | |
| 353 | if (ldo_status == enable) |
| 354 | return 0; |
| 355 | |
| 356 | ldo_status = enable; |
| 357 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 358 | return enable ? |
| 359 | regulator_enable(reg_hsusb) : |
| 360 | regulator_disable(reg_hsusb); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | #ifndef CONFIG_USB_EHCI_MSM_72K |
| 364 | static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init) |
| 365 | { |
| 366 | int ret = 0; |
| 367 | |
| 368 | if (init) |
| 369 | ret = msm_pm_app_rpc_init(callback); |
| 370 | else |
| 371 | msm_pm_app_rpc_deinit(callback); |
| 372 | |
| 373 | return ret; |
| 374 | } |
| 375 | #endif |
| 376 | |
| 377 | static struct msm_otg_platform_data msm_otg_pdata = { |
| 378 | #ifndef CONFIG_USB_EHCI_MSM_72K |
| 379 | .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init, |
| 380 | #else |
| 381 | .vbus_power = msm_hsusb_vbus_power, |
| 382 | #endif |
| 383 | .rpc_connect = hsusb_rpc_connect, |
| 384 | .core_clk = 1, |
| 385 | .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT, |
| 386 | .cdr_autoreset = CDR_AUTO_RESET_DISABLE, |
| 387 | .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT, |
| 388 | .se1_gating = SE1_GATING_DISABLE, |
| 389 | .ldo_init = msm_hsusb_ldo_init, |
| 390 | .ldo_enable = msm_hsusb_ldo_enable, |
| 391 | .chg_init = hsusb_chg_init, |
| 392 | .chg_connected = hsusb_chg_connected, |
| 393 | .chg_vbus_draw = hsusb_chg_vbus_draw, |
| 394 | }; |
| 395 | #endif |
| 396 | |
| 397 | static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = { |
| 398 | .is_phy_status_timer_on = 1, |
| 399 | }; |
| 400 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 401 | #ifdef CONFIG_SERIAL_MSM_HS |
| 402 | static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = { |
| 403 | .inject_rx_on_wakeup = 1, |
| 404 | .rx_to_inject = 0xFD, |
| 405 | }; |
| 406 | #endif |
| 407 | static struct msm_pm_platform_data msm7627a_pm_data[MSM_PM_SLEEP_MODE_NR] = { |
| 408 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = { |
| 409 | .idle_supported = 1, |
| 410 | .suspend_supported = 1, |
| 411 | .idle_enabled = 1, |
| 412 | .suspend_enabled = 1, |
| 413 | .latency = 16000, |
| 414 | .residency = 20000, |
| 415 | }, |
| 416 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = { |
| 417 | .idle_supported = 1, |
| 418 | .suspend_supported = 1, |
| 419 | .idle_enabled = 1, |
| 420 | .suspend_enabled = 1, |
| 421 | .latency = 12000, |
| 422 | .residency = 20000, |
| 423 | }, |
| 424 | [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = { |
| 425 | .idle_supported = 1, |
| 426 | .suspend_supported = 1, |
| 427 | .idle_enabled = 0, |
| 428 | .suspend_enabled = 1, |
| 429 | .latency = 2000, |
| 430 | .residency = 0, |
| 431 | }, |
| 432 | [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = { |
| 433 | .idle_supported = 1, |
| 434 | .suspend_supported = 1, |
| 435 | .idle_enabled = 1, |
| 436 | .suspend_enabled = 1, |
| 437 | .latency = 2, |
| 438 | .residency = 0, |
| 439 | }, |
| 440 | }; |
| 441 | |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 442 | static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = { |
Sravan Kumar Ambapuram | b22cf4d | 2012-01-02 21:45:04 +0530 | [diff] [blame^] | 443 | .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS, |
| 444 | .p_addr = 0, |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 445 | }; |
| 446 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 447 | static struct android_pmem_platform_data android_pmem_adsp_pdata = { |
| 448 | .name = "pmem_adsp", |
| 449 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 450 | .cached = 1, |
| 451 | .memory_type = MEMTYPE_EBI1, |
| 452 | }; |
| 453 | |
| 454 | static struct platform_device android_pmem_adsp_device = { |
| 455 | .name = "android_pmem", |
| 456 | .id = 1, |
| 457 | .dev = { .platform_data = &android_pmem_adsp_pdata }, |
| 458 | }; |
| 459 | |
| 460 | static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE; |
| 461 | static int __init pmem_mdp_size_setup(char *p) |
| 462 | { |
| 463 | pmem_mdp_size = memparse(p, NULL); |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | early_param("pmem_mdp_size", pmem_mdp_size_setup); |
| 468 | |
| 469 | static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE; |
| 470 | static int __init pmem_adsp_size_setup(char *p) |
| 471 | { |
| 472 | pmem_adsp_size = memparse(p, NULL); |
| 473 | return 0; |
| 474 | } |
| 475 | |
| 476 | early_param("pmem_adsp_size", pmem_adsp_size_setup); |
| 477 | |
| 478 | static unsigned fb_size = MSM_FB_SIZE; |
| 479 | static int __init fb_size_setup(char *p) |
| 480 | { |
| 481 | fb_size = memparse(p, NULL); |
| 482 | return 0; |
| 483 | } |
| 484 | |
| 485 | early_param("fb_size", fb_size_setup); |
| 486 | |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 487 | static struct resource msm_fb_resources[] = { |
| 488 | { |
| 489 | .flags = IORESOURCE_DMA, |
| 490 | } |
| 491 | }; |
| 492 | |
| 493 | static int msm_fb_detect_panel(const char *name) |
| 494 | { |
| 495 | int ret; |
| 496 | |
| 497 | if (!strncmp(name, "mipi_video_truly_wvga", 21)) |
| 498 | ret = 0; |
| 499 | else |
| 500 | ret = -ENODEV; |
| 501 | |
| 502 | return ret; |
| 503 | } |
| 504 | |
| 505 | static int mipi_truly_set_bl(int on) |
| 506 | { |
Chintan Pandya | 03b0120 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 507 | gpio_set_value_cansleep(QRD_GPIO_BACKLIGHT_EN, !!on); |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 508 | |
| 509 | return 1; |
| 510 | } |
| 511 | |
| 512 | static struct msm_fb_platform_data msm_fb_pdata = { |
| 513 | .detect_client = msm_fb_detect_panel, |
| 514 | }; |
| 515 | |
| 516 | static struct platform_device msm_fb_device = { |
| 517 | .name = "msm_fb", |
| 518 | .id = 0, |
| 519 | .num_resources = ARRAY_SIZE(msm_fb_resources), |
| 520 | .resource = msm_fb_resources, |
| 521 | .dev = { |
| 522 | .platform_data = &msm_fb_pdata, |
| 523 | } |
| 524 | }; |
| 525 | |
| 526 | static struct msm_panel_common_pdata mipi_truly_pdata = { |
| 527 | .pmic_backlight = mipi_truly_set_bl, |
| 528 | }; |
| 529 | |
| 530 | static struct platform_device mipi_dsi_truly_panel_device = { |
| 531 | .name = "mipi_truly", |
| 532 | .id = 0, |
| 533 | .dev = { |
| 534 | .platform_data = &mipi_truly_pdata, |
| 535 | } |
| 536 | }; |
| 537 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 538 | #define SND(desc, num) { .name = #desc, .id = num } |
| 539 | static struct snd_endpoint snd_endpoints_list[] = { |
| 540 | SND(HANDSET, 0), |
| 541 | SND(MONO_HEADSET, 2), |
| 542 | SND(HEADSET, 3), |
| 543 | SND(SPEAKER, 6), |
| 544 | SND(TTY_HEADSET, 8), |
| 545 | SND(TTY_VCO, 9), |
| 546 | SND(TTY_HCO, 10), |
| 547 | SND(BT, 12), |
| 548 | SND(IN_S_SADC_OUT_HANDSET, 16), |
| 549 | SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25), |
| 550 | SND(FM_DIGITAL_STEREO_HEADSET, 26), |
| 551 | SND(FM_DIGITAL_SPEAKER_PHONE, 27), |
| 552 | SND(FM_DIGITAL_BT_A2DP_HEADSET, 28), |
Shashi Kumar | 64e0760 | 2011-10-11 13:18:57 +0530 | [diff] [blame] | 553 | SND(STEREO_HEADSET_AND_SPEAKER, 31), |
Phani Kumar Allada | d697125 | 2011-10-19 10:50:15 +0530 | [diff] [blame] | 554 | SND(CURRENT, 0x7FFFFFFE), |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 555 | SND(FM_ANALOG_STEREO_HEADSET, 35), |
| 556 | SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36), |
| 557 | }; |
| 558 | #undef SND |
| 559 | |
| 560 | static struct msm_snd_endpoints msm_device_snd_endpoints = { |
| 561 | .endpoints = snd_endpoints_list, |
| 562 | .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint) |
| 563 | }; |
| 564 | |
| 565 | static struct platform_device msm_device_snd = { |
| 566 | .name = "msm_snd", |
| 567 | .id = -1, |
| 568 | .dev = { |
| 569 | .platform_data = &msm_device_snd_endpoints |
| 570 | }, |
| 571 | }; |
| 572 | |
| 573 | #define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 574 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 575 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 576 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 577 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 578 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 579 | #define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 580 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 581 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 582 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 583 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 584 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 585 | #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 586 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 587 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 588 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 589 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 590 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 591 | #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 592 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 593 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 594 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 595 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 596 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 597 | #define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI) |
| 598 | |
| 599 | static unsigned int dec_concurrency_table[] = { |
| 600 | /* Audio LP */ |
| 601 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0, |
| 602 | 0, 0, 0, |
| 603 | |
| 604 | /* Concurrency 1 */ |
| 605 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 606 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 607 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 608 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 609 | (DEC4_FORMAT), |
| 610 | |
| 611 | /* Concurrency 2 */ |
| 612 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 613 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 614 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 615 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 616 | (DEC4_FORMAT), |
| 617 | |
| 618 | /* Concurrency 3 */ |
| 619 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 620 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 621 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 622 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 623 | (DEC4_FORMAT), |
| 624 | |
| 625 | /* Concurrency 4 */ |
| 626 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 627 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 628 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 629 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 630 | (DEC4_FORMAT), |
| 631 | |
| 632 | /* Concurrency 5 */ |
| 633 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 634 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 635 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 636 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 637 | (DEC4_FORMAT), |
| 638 | |
| 639 | /* Concurrency 6 */ |
| 640 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 641 | 0, 0, 0, 0, |
| 642 | |
| 643 | /* Concurrency 7 */ |
| 644 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 645 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 646 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 647 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 648 | (DEC4_FORMAT), |
| 649 | }; |
| 650 | |
| 651 | #define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \ |
| 652 | .module_queueid = queueid, .module_decid = decid, \ |
| 653 | .nr_codec_support = nr_codec} |
| 654 | |
| 655 | static struct msm_adspdec_info dec_info_list[] = { |
| 656 | DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */ |
| 657 | DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */ |
| 658 | DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */ |
| 659 | DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */ |
| 660 | DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */ |
| 661 | }; |
| 662 | |
| 663 | static struct msm_adspdec_database msm_device_adspdec_database = { |
| 664 | .num_dec = ARRAY_SIZE(dec_info_list), |
| 665 | .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \ |
| 666 | ARRAY_SIZE(dec_info_list)), |
| 667 | .dec_concurrency_table = dec_concurrency_table, |
| 668 | .dec_info_list = dec_info_list, |
| 669 | }; |
| 670 | |
| 671 | static struct platform_device msm_device_adspdec = { |
| 672 | .name = "msm_adspdec", |
| 673 | .id = -1, |
| 674 | .dev = { |
| 675 | .platform_data = &msm_device_adspdec_database |
| 676 | }, |
| 677 | }; |
| 678 | |
| 679 | static struct android_pmem_platform_data android_pmem_audio_pdata = { |
| 680 | .name = "pmem_audio", |
| 681 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 682 | .cached = 0, |
| 683 | .memory_type = MEMTYPE_EBI1, |
| 684 | }; |
| 685 | |
| 686 | static struct platform_device android_pmem_audio_device = { |
| 687 | .name = "android_pmem", |
| 688 | .id = 2, |
| 689 | .dev = { .platform_data = &android_pmem_audio_pdata }, |
| 690 | }; |
| 691 | |
| 692 | static struct android_pmem_platform_data android_pmem_pdata = { |
| 693 | .name = "pmem", |
| 694 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 695 | .cached = 1, |
| 696 | .memory_type = MEMTYPE_EBI1, |
| 697 | }; |
| 698 | static struct platform_device android_pmem_device = { |
| 699 | .name = "android_pmem", |
| 700 | .id = 0, |
| 701 | .dev = { .platform_data = &android_pmem_pdata }, |
| 702 | }; |
| 703 | |
| 704 | static u32 msm_calculate_batt_capacity(u32 current_voltage); |
| 705 | |
| 706 | static struct msm_psy_batt_pdata msm_psy_batt_data = { |
| 707 | .voltage_min_design = 2800, |
| 708 | .voltage_max_design = 4300, |
| 709 | .avail_chg_sources = AC_CHG | USB_CHG , |
| 710 | .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION, |
| 711 | .calculate_capacity = &msm_calculate_batt_capacity, |
| 712 | }; |
| 713 | |
| 714 | static u32 msm_calculate_batt_capacity(u32 current_voltage) |
| 715 | { |
| 716 | u32 low_voltage = msm_psy_batt_data.voltage_min_design; |
| 717 | u32 high_voltage = msm_psy_batt_data.voltage_max_design; |
| 718 | |
| 719 | return (current_voltage - low_voltage) * 100 |
| 720 | / (high_voltage - low_voltage); |
| 721 | } |
| 722 | |
| 723 | static struct platform_device msm_batt_device = { |
| 724 | .name = "msm-battery", |
| 725 | .id = -1, |
| 726 | .dev.platform_data = &msm_psy_batt_data, |
| 727 | }; |
| 728 | |
| 729 | static struct platform_device *qrd1_devices[] __initdata = { |
| 730 | &msm_device_dmov, |
| 731 | &msm_device_smd, |
| 732 | &msm_device_uart1, |
| 733 | &msm_device_uart_dm1, |
| 734 | &msm_gsbi0_qup_i2c_device, |
| 735 | &msm_gsbi1_qup_i2c_device, |
| 736 | &msm_device_otg, |
| 737 | &msm_device_gadget_peripheral, |
| 738 | &android_usb_device, |
| 739 | &android_pmem_device, |
| 740 | &android_pmem_adsp_device, |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 741 | &msm_fb_device, |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 742 | &android_pmem_audio_device, |
| 743 | &msm_device_snd, |
| 744 | &msm_device_adspdec, |
| 745 | &msm_batt_device, |
| 746 | &msm_kgsl_3d0, |
| 747 | #ifdef CONFIG_BT |
| 748 | &msm_bt_power_device, |
| 749 | #endif |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 750 | &mipi_dsi_truly_panel_device, |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 751 | &msm_wlan_ar6000_pm_device, |
| 752 | &asoc_msm_pcm, |
| 753 | &asoc_msm_dai0, |
| 754 | &asoc_msm_dai1, |
| 755 | }; |
| 756 | |
| 757 | static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE; |
| 758 | static int __init pmem_kernel_ebi1_size_setup(char *p) |
| 759 | { |
| 760 | pmem_kernel_ebi1_size = memparse(p, NULL); |
| 761 | return 0; |
| 762 | } |
| 763 | early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup); |
| 764 | |
| 765 | static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE; |
| 766 | static int __init pmem_audio_size_setup(char *p) |
| 767 | { |
| 768 | pmem_audio_size = memparse(p, NULL); |
| 769 | return 0; |
| 770 | } |
| 771 | early_param("pmem_audio_size", pmem_audio_size_setup); |
| 772 | |
| 773 | static void __init msm_msm7627a_allocate_memory_regions(void) |
| 774 | { |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 775 | void *addr; |
| 776 | unsigned long size; |
| 777 | |
| 778 | size = fb_size ? : MSM_FB_SIZE; |
| 779 | addr = alloc_bootmem_align(size, 0x1000); |
| 780 | msm_fb_resources[0].start = __pa(addr); |
| 781 | msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1; |
| 782 | pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", size, |
| 783 | addr, __pa(addr)); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 784 | } |
| 785 | |
| 786 | static struct memtype_reserve msm7627a_reserve_table[] __initdata = { |
| 787 | [MEMTYPE_SMI] = { |
| 788 | }, |
| 789 | [MEMTYPE_EBI0] = { |
| 790 | .flags = MEMTYPE_FLAGS_1M_ALIGN, |
| 791 | }, |
| 792 | [MEMTYPE_EBI1] = { |
| 793 | .flags = MEMTYPE_FLAGS_1M_ALIGN, |
| 794 | }, |
| 795 | }; |
| 796 | |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 797 | static struct msm_panel_common_pdata mdp_pdata = { |
| 798 | .gpio = 97, |
| 799 | .mdp_rev = MDP_REV_303, |
| 800 | }; |
| 801 | |
| 802 | #define GPIO_LCDC_BRDG_PD 128 |
| 803 | #define GPIO_LCDC_BRDG_RESET_N 129 |
| 804 | #define GPIO_LCD_DSI_SEL 125 |
| 805 | |
| 806 | static unsigned mipi_dsi_gpio[] = { |
| 807 | GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT, |
| 808 | GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */ |
| 809 | GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT, |
| 810 | GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_PD */ |
| 811 | }; |
| 812 | |
| 813 | static unsigned lcd_dsi_sel_gpio[] = { |
| 814 | GPIO_CFG(GPIO_LCD_DSI_SEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, |
| 815 | GPIO_CFG_2MA), |
| 816 | }; |
| 817 | |
| 818 | enum { |
| 819 | DSI_SINGLE_LANE = 1, |
| 820 | DSI_TWO_LANES, |
| 821 | }; |
| 822 | |
| 823 | static int msm_fb_get_lane_config(void) |
| 824 | { |
| 825 | pr_info("DSI_TWO_LANES\n"); |
| 826 | return DSI_TWO_LANES; |
| 827 | } |
| 828 | |
| 829 | static int mipi_truly_sel_mode(int video_mode) |
| 830 | { |
| 831 | int rc = 0; |
| 832 | |
| 833 | rc = gpio_request(GPIO_LCD_DSI_SEL, "lcd_dsi_sel"); |
| 834 | if (rc < 0) |
| 835 | goto gpio_error; |
| 836 | |
| 837 | rc = gpio_tlmm_config(lcd_dsi_sel_gpio[0], GPIO_CFG_ENABLE); |
| 838 | if (rc) |
| 839 | goto gpio_error; |
| 840 | |
| 841 | rc = gpio_direction_output(GPIO_LCD_DSI_SEL, 1); |
| 842 | if (!rc) { |
| 843 | gpio_set_value_cansleep(GPIO_LCD_DSI_SEL, video_mode); |
| 844 | return rc; |
| 845 | } else { |
| 846 | goto gpio_error; |
| 847 | } |
| 848 | |
| 849 | gpio_error: |
| 850 | pr_err("mipi_truly_sel_mode failed\n"); |
| 851 | gpio_free(GPIO_LCD_DSI_SEL); |
| 852 | return rc; |
| 853 | } |
| 854 | |
| 855 | static int msm_fb_dsi_client_qrd1_reset(void) |
| 856 | { |
| 857 | int rc = 0; |
| 858 | |
| 859 | rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n"); |
| 860 | if (rc < 0) { |
| 861 | pr_err("failed to request lcd brdg reset_n\n"); |
| 862 | return rc; |
| 863 | } |
| 864 | |
| 865 | rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE); |
| 866 | if (rc < 0) { |
| 867 | pr_err("Failed to enable LCDC Bridge reset enable\n"); |
| 868 | return rc; |
| 869 | } |
| 870 | |
| 871 | rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1); |
| 872 | if (rc < 0) { |
| 873 | pr_err("Failed GPIO bridge pd\n"); |
| 874 | gpio_free(GPIO_LCDC_BRDG_RESET_N); |
| 875 | return rc; |
| 876 | } |
| 877 | |
| 878 | mipi_truly_sel_mode(1); |
| 879 | |
| 880 | return rc; |
| 881 | } |
| 882 | |
| 883 | static int msm_fb_dsi_client_reset(void) |
| 884 | { |
| 885 | int rc = 0; |
| 886 | |
| 887 | rc = msm_fb_dsi_client_qrd1_reset(); |
| 888 | return rc; |
| 889 | } |
| 890 | |
| 891 | static int dsi_gpio_initialized; |
| 892 | |
| 893 | static int mipi_dsi_panel_qrd1_power(int on) |
| 894 | { |
| 895 | int rc = 0; |
| 896 | |
| 897 | if (!dsi_gpio_initialized) { |
Chintan Pandya | 03b0120 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 898 | rc = gpio_request(QRD_GPIO_BACKLIGHT_EN, "gpio_bkl_en"); |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 899 | if (rc < 0) |
| 900 | return rc; |
| 901 | |
Chintan Pandya | 03b0120 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 902 | rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_BACKLIGHT_EN, 0, |
Jeevan Shriram | 72e4cc6 | 2011-11-10 14:57:22 +0530 | [diff] [blame] | 903 | GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 904 | GPIO_CFG_ENABLE); |
| 905 | if (rc < 0) { |
| 906 | pr_err("failed GPIO_BACKLIGHT_EN tlmm config\n"); |
| 907 | return rc; |
| 908 | } |
| 909 | |
Chintan Pandya | 03b0120 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 910 | rc = gpio_direction_output(QRD_GPIO_BACKLIGHT_EN, 1); |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 911 | if (rc < 0) { |
| 912 | pr_err("failed to enable backlight\n"); |
Chintan Pandya | 03b0120 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 913 | gpio_free(QRD_GPIO_BACKLIGHT_EN); |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 914 | return rc; |
| 915 | } |
| 916 | dsi_gpio_initialized = 1; |
| 917 | } |
| 918 | |
Chintan Pandya | 03b0120 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 919 | gpio_set_value_cansleep(QRD_GPIO_BACKLIGHT_EN, !!on); |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 920 | |
| 921 | if (!on) { |
| 922 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1); |
| 923 | msleep(20); |
| 924 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0); |
| 925 | msleep(20); |
| 926 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1); |
| 927 | |
| 928 | } |
| 929 | |
| 930 | return rc; |
| 931 | } |
| 932 | |
| 933 | static int mipi_dsi_panel_power(int on) |
| 934 | { |
| 935 | int rc = 0; |
| 936 | |
| 937 | rc = mipi_dsi_panel_qrd1_power(on); |
| 938 | return rc; |
| 939 | } |
| 940 | |
| 941 | #define MDP_303_VSYNC_GPIO 97 |
| 942 | |
| 943 | #ifdef CONFIG_FB_MSM_MDP303 |
| 944 | static struct mipi_dsi_platform_data mipi_dsi_pdata = { |
| 945 | .vsync_gpio = MDP_303_VSYNC_GPIO, |
| 946 | .dsi_power_save = mipi_dsi_panel_power, |
| 947 | .dsi_client_reset = msm_fb_dsi_client_reset, |
| 948 | .get_lane_config = msm_fb_get_lane_config, |
| 949 | }; |
| 950 | #endif |
| 951 | |
| 952 | static void __init msm_fb_add_devices(void) |
| 953 | { |
| 954 | msm_fb_register_device("mdp", &mdp_pdata); |
| 955 | msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata); |
| 956 | } |
| 957 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 958 | static void __init size_pmem_devices(void) |
| 959 | { |
| 960 | #ifdef CONFIG_ANDROID_PMEM |
| 961 | android_pmem_adsp_pdata.size = pmem_adsp_size; |
| 962 | android_pmem_pdata.size = pmem_mdp_size; |
| 963 | android_pmem_audio_pdata.size = pmem_audio_size; |
| 964 | #endif |
| 965 | } |
| 966 | |
| 967 | static void __init reserve_memory_for(struct android_pmem_platform_data *p) |
| 968 | { |
| 969 | msm7627a_reserve_table[p->memory_type].size += p->size; |
| 970 | } |
| 971 | |
| 972 | static void __init reserve_pmem_memory(void) |
| 973 | { |
| 974 | #ifdef CONFIG_ANDROID_PMEM |
| 975 | reserve_memory_for(&android_pmem_adsp_pdata); |
| 976 | reserve_memory_for(&android_pmem_pdata); |
| 977 | reserve_memory_for(&android_pmem_audio_pdata); |
| 978 | msm7627a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size; |
| 979 | #endif |
| 980 | } |
| 981 | |
| 982 | static void __init msm7627a_calculate_reserve_sizes(void) |
| 983 | { |
| 984 | size_pmem_devices(); |
| 985 | reserve_pmem_memory(); |
| 986 | } |
| 987 | |
| 988 | static int msm7627a_paddr_to_memtype(unsigned int paddr) |
| 989 | { |
| 990 | return MEMTYPE_EBI1; |
| 991 | } |
| 992 | |
| 993 | static struct reserve_info msm7627a_reserve_info __initdata = { |
| 994 | .memtype_reserve_table = msm7627a_reserve_table, |
| 995 | .calculate_reserve_sizes = msm7627a_calculate_reserve_sizes, |
| 996 | .paddr_to_memtype = msm7627a_paddr_to_memtype, |
| 997 | }; |
| 998 | |
| 999 | static void __init msm7627a_reserve(void) |
| 1000 | { |
| 1001 | reserve_info = &msm7627a_reserve_info; |
| 1002 | msm_reserve(); |
| 1003 | } |
| 1004 | |
| 1005 | static void __init msm_device_i2c_init(void) |
| 1006 | { |
| 1007 | msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata; |
| 1008 | msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata; |
| 1009 | } |
| 1010 | |
| 1011 | static struct msm_handset_platform_data hs_platform_data = { |
| 1012 | .hs_name = "7k_handset", |
| 1013 | .pwr_key_delay_ms = 500, /* 0 will disable end key */ |
| 1014 | }; |
| 1015 | |
| 1016 | static struct platform_device hs_pdev = { |
| 1017 | .name = "msm-handset", |
| 1018 | .id = -1, |
| 1019 | .dev = { |
| 1020 | .platform_data = &hs_platform_data, |
| 1021 | }, |
| 1022 | }; |
| 1023 | |
Pankaj Kumar | 3cec058 | 2011-11-18 11:13:29 +0530 | [diff] [blame] | 1024 | static struct platform_device msm_proccomm_regulator_dev = { |
| 1025 | .name = PROCCOMM_REGULATOR_DEV_NAME, |
| 1026 | .id = -1, |
| 1027 | .dev = { |
| 1028 | .platform_data = &msm7x27a_proccomm_regulator_data |
| 1029 | } |
| 1030 | }; |
| 1031 | |
| 1032 | static void __init msm7627a_init_regulators(void) |
| 1033 | { |
| 1034 | int rc = platform_device_register(&msm_proccomm_regulator_dev); |
| 1035 | if (rc) |
| 1036 | pr_err("%s: could not register regulator device: %d\n", |
| 1037 | __func__, rc); |
| 1038 | } |
| 1039 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1040 | #define UART1DM_RX_GPIO 45 |
| 1041 | static void __init msm_qrd1_init(void) |
| 1042 | { |
| 1043 | msm7x2x_misc_init(); |
Pankaj Kumar | 3cec058 | 2011-11-18 11:13:29 +0530 | [diff] [blame] | 1044 | msm7627a_init_regulators(); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1045 | msm_device_i2c_init(); |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 1046 | qrd1_camera_gpio_cfg(); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1047 | #ifdef CONFIG_SERIAL_MSM_HS |
| 1048 | msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO); |
| 1049 | msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata; |
| 1050 | #endif |
| 1051 | |
| 1052 | #ifdef CONFIG_USB_MSM_OTG_72K |
| 1053 | msm_otg_pdata.swfi_latency = msm7627a_pm_data |
| 1054 | [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency; |
| 1055 | msm_device_otg.dev.platform_data = &msm_otg_pdata; |
| 1056 | #endif |
| 1057 | msm_device_gadget_peripheral.dev.platform_data = |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 1058 | &msm_gadget_pdata; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1059 | platform_add_devices(qrd1_devices, |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 1060 | ARRAY_SIZE(qrd1_devices)); |
Chintan Pandya | cf467fc | 2011-12-01 17:11:11 +0530 | [diff] [blame] | 1061 | msm7627a_init_mmc(); |
| 1062 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1063 | #ifdef CONFIG_USB_EHCI_MSM_72K |
| 1064 | msm7627a_init_host(); |
| 1065 | #endif |
| 1066 | msm_pm_set_platform_data(msm7627a_pm_data, |
| 1067 | ARRAY_SIZE(msm7627a_pm_data)); |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 1068 | BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata)); |
Murali Nalajala | a182784 | 2011-11-13 14:12:39 +0530 | [diff] [blame] | 1069 | |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 1070 | msm_fb_add_devices(); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1071 | |
| 1072 | #if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE) |
Chintan Pandya | 13490c0 | 2011-12-20 13:03:36 +0530 | [diff] [blame] | 1073 | msm7627a_bt_power_init(); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1074 | #endif |
Taniya Das | da40882 | 2011-09-06 12:54:06 +0530 | [diff] [blame] | 1075 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1076 | msm_camera_vreg_init(); |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 1077 | |
Taniya Das | da40882 | 2011-09-06 12:54:06 +0530 | [diff] [blame] | 1078 | #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \ |
| 1079 | defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE) |
| 1080 | i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID, |
| 1081 | synaptic_i2c_clearpad3k, |
| 1082 | ARRAY_SIZE(synaptic_i2c_clearpad3k)); |
| 1083 | #endif |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1084 | platform_device_register(&hs_pdev); |
| 1085 | |
| 1086 | #ifdef CONFIG_MSM_RPC_VIBRATOR |
| 1087 | msm_init_pmic_vibrator(); |
| 1088 | #endif |
| 1089 | } |
| 1090 | |
| 1091 | static void __init qrd7627a_init_early(void) |
| 1092 | { |
| 1093 | msm_msm7627a_allocate_memory_regions(); |
| 1094 | } |
| 1095 | |
| 1096 | MACHINE_START(MSM7627A_QRD1, "QRD MSM7627a QRD1") |
| 1097 | .boot_params = PHYS_OFFSET + 0x100, |
| 1098 | .map_io = msm_common_io_init, |
| 1099 | .reserve = msm7627a_reserve, |
| 1100 | .init_irq = msm_init_irq, |
| 1101 | .init_machine = msm_qrd1_init, |
| 1102 | .timer = &msm_timer, |
| 1103 | .init_early = qrd7627a_init_early, |
Pankaj Kumar | bf8a2a3 | 2011-10-21 11:47:21 +0530 | [diff] [blame] | 1104 | .handle_irq = vic_handle_irq, |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1105 | MACHINE_END |