Implement retention sleep mode
/arch/arm/mach-msm/board-m2_spr.c
blob:4694508bbb84406798888c3a87713b61aa025a32 -> blob:bf3b011649630ff8a57fe6ed96800a1c9585fda8
--- arch/arm/mach-msm/board-m2_spr.c
+++ arch/arm/mach-msm/board-m2_spr.c
@@ -296,28 +296,6 @@ struct sx150x_platform_data msm8960_sx15
#endif
-static struct gpiomux_setting sec_ts_ldo_act_cfg = {
- .func = GPIOMUX_FUNC_GPIO,
- .drv = GPIOMUX_DRV_8MA,
- .pull = GPIOMUX_PULL_UP,
-};
-
-static struct gpiomux_setting sec_ts_ldo_sus_cfg = {
- .func = GPIOMUX_FUNC_GPIO,
- .drv = GPIOMUX_DRV_8MA,
- .pull = GPIOMUX_PULL_DOWN,
-};
-
-static struct msm_gpiomux_config msm8960_sec_ts_configs[] = {
- { /* TS LDO EN */
- .gpio = 10,
- .settings = {
- [GPIOMUX_ACTIVE] = &sec_ts_ldo_act_cfg,
- [GPIOMUX_SUSPENDED] = &sec_ts_ldo_sus_cfg,
- },
- },
-};
-
#define MSM_PMEM_ADSP_SIZE 0x9600000 /* 150 Mbytes */
#define MSM_PMEM_ADSP_SIZE_FOR_2GB 0xA500000 /* 165 Mbytes */
#define MSM_PMEM_AUDIO_SIZE 0x160000 /* 1.375 Mbytes */
@@ -790,7 +768,7 @@ static void __init reserve_ion_memory(vo
if (!strcmp(heap->name, "mm")
&& (mb->start >= 0xc0000000)) {
printk(KERN_ERR "heap->name %s, mb->start %lx\n",
- heap->name, mb->start);
+ heap->name, (unsigned long)mb->start);
heap->size = MSM_PMEM_ADSP_SIZE_FOR_2GB;
}
@@ -1573,7 +1551,7 @@ int msm8960_get_cable_type(void)
}
if (i == 10) {
pr_err("%s: fail to get battery ps\n", __func__);
- return;
+ return ret;
}
#endif
@@ -1709,20 +1687,20 @@ static void sii9234_hw_onoff(bool onoff)
GPIO_CFG_PULL_UP, GPIO_CFG_2MA), 1);
mhl_l12 = regulator_get(NULL, "8921_l12");
rc = regulator_set_voltage(mhl_l12, 1200000, 1200000);
- if (rc)
- pr_err("error setting voltage\n");
- rc = regulator_enable(mhl_l12);
- if (rc)
- pr_err("error enabling regulator\n");
- usleep(1*1000);
+ if (rc)
+ pr_err("error setting voltage\n");
+ rc = regulator_enable(mhl_l12);
+ if (rc)
+ pr_err("error enabling regulator\n");
+ usleep(1*1000);
gpio_direction_output(GPIO_MHL_EN, 1);
} else {
gpio_direction_output(GPIO_MHL_EN, 0);
if (mhl_l12) {
rc = regulator_disable(mhl_l12);
- if (rc)
- pr_err("error disabling regulator\n");
- }
+ if (rc)
+ pr_err("error disabling regulator\n");
+ }
usleep_range(10000, 20000);
@@ -1946,12 +1924,14 @@ void max17040_hw_init(void)
static int max17040_low_batt_cb(void)
{
- pr_err("%s: Low battery alert\n", __func__);
-
#ifdef CONFIG_BATTERY_SEC
struct power_supply *psy = power_supply_get_by_name("battery");
union power_supply_propval value;
+#endif
+
+ pr_err("%s: Low battery alert\n", __func__);
+#ifdef CONFIG_BATTERY_SEC
if (!psy) {
pr_err("%s: fail to get battery ps\n", __func__);
return -ENODEV;
@@ -2069,7 +2049,9 @@ static struct i2c_board_info opt_i2c_bor
#endif
};
+#if defined(CONFIG_OPTICAL_GP2A) || defined(CONFIG_OPTICAL_GP2AP020A00F)
static void gp2a_led_onoff(int);
+#endif
#if defined(CONFIG_OPTICAL_GP2A)
static struct opt_gp2a_platform_data opt_gp2a_data = {
@@ -2426,7 +2408,7 @@ static int __init sensor_device_init(voi
if (system_rev < BOARD_REV06) {
gpio_tlmm_config(GPIO_CFG(mag_rst, 0,
- GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), 1);
+ GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), 1);
} else {
mag_rst = PM8921_GPIO_PM_TO_SYS(mag_rst);
pm8xxx_gpio_config(mag_rst, &mag_rst_cfg);
@@ -2597,7 +2579,6 @@ static void cm36651_led_onoff(int onoff)
if (rc)
pr_err("%s: error reg_8921_leda setting ret=%d\n",
__func__, rc);
- return;
}
if (onoff) {
@@ -2678,11 +2659,6 @@ static struct i2c_gpio_platform_data a2
.udelay = 1,
};
-static struct platform_device a2220_i2c_gpio_device = {
- .name = "i2c-gpio",
- .id = MSM_A2220_I2C_BUS_ID,
- .dev.platform_data = &a2220_i2c_gpio_data,
-};
static struct gpiomux_setting a2220_gsbi_config = {
.func = GPIOMUX_FUNC_GPIO,
.drv = GPIOMUX_DRV_8MA,
@@ -2800,7 +2776,6 @@ static struct slim_device msm_slim_tabla
.platform_data = &tabla_platform_data,
},
};
-static u8 tabla20_e_addr[6] = {0, 0, 0x60, 0, 0x17, 2};
static struct tabla_pdata tabla20_platform_data = {
.slimbus_slave_device = {
@@ -3201,9 +3176,6 @@ static struct msm_spi_platform_data msm8
.max_clock_speed = 48000000, /*15060000,*/
};
#endif
-static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
- .max_clock_speed = 15060000,
-};
#ifdef CONFIG_USB_MSM_OTG_72K
static struct msm_otg_platform_data msm_otg_pdata;
@@ -3486,24 +3458,52 @@ static struct platform_device android_us
};
static uint8_t spm_wfi_cmd_sequence[] __initdata = {
- 0x03, 0x0f,
+ 0x03, 0x0f,
+};
+
+static uint8_t spm_retention_cmd_sequence[] __initdata = {
+ 0x00, 0x05, 0x03, 0x0D,
+ 0x0B, 0x00, 0x0f,
};
static uint8_t spm_power_collapse_without_rpm[] __initdata = {
- 0x00, 0x24, 0x54, 0x10,
- 0x09, 0x03, 0x01,
- 0x10, 0x54, 0x30, 0x0C,
- 0x24, 0x30, 0x0f,
+ 0x00, 0x24, 0x54, 0x10,
+ 0x09, 0x03, 0x01,
+ 0x10, 0x54, 0x30, 0x0C,
+ 0x24, 0x30, 0x0f,
};
static uint8_t spm_power_collapse_with_rpm[] __initdata = {
- 0x00, 0x24, 0x54, 0x10,
- 0x09, 0x07, 0x01, 0x0B,
- 0x10, 0x54, 0x30, 0x0C,
- 0x24, 0x30, 0x0f,
+ 0x00, 0x24, 0x54, 0x10,
+ 0x09, 0x07, 0x01, 0x0B,
+ 0x10, 0x54, 0x30, 0x0C,
+ 0x24, 0x30, 0x0f,
+};
+
+static struct msm_spm_seq_entry msm_spm_boot_cpu_seq_list[] __initdata = {
+ [0] = {
+ .mode = MSM_SPM_MODE_CLOCK_GATING,
+ .notify_rpm = false,
+ .cmd = spm_wfi_cmd_sequence,
+ },
+ [1] = {
+ .mode = MSM_SPM_MODE_POWER_RETENTION,
+ .notify_rpm = false,
+ .cmd = spm_retention_cmd_sequence,
+ },
+ [2] = {
+ .mode = MSM_SPM_MODE_POWER_COLLAPSE,
+ .notify_rpm = false,
+ .cmd = spm_power_collapse_without_rpm,
+ },
+ [3] = {
+ .mode = MSM_SPM_MODE_POWER_COLLAPSE,
+ .notify_rpm = true,
+ .cmd = spm_power_collapse_with_rpm,
+ },
};
-static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
+static struct msm_spm_seq_entry msm_spm_nonboot_cpu_seq_list[] __initdata = {
[0] = {
.mode = MSM_SPM_MODE_CLOCK_GATING,
.notify_rpm = false,
@@ -3530,12 +3530,12 @@ static struct msm_spm_platform_data msm_
.reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
#endif
.reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
- .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020204,
- .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
- .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
+ .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x03020004,
+ .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0084009C,
+ .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A4001C,
.vctl_timeout_us = 50,
- .num_modes = ARRAY_SIZE(msm_spm_seq_list),
- .modes = msm_spm_seq_list,
+ .num_modes = ARRAY_SIZE(msm_spm_boot_cpu_seq_list),
+ .modes = msm_spm_boot_cpu_seq_list,
},
[1] = {
.reg_base_addr = MSM_SAW1_BASE,
@@ -3549,8 +3549,8 @@ static struct msm_spm_platform_data msm_
.reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
.reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
.vctl_timeout_us = 50,
- .num_modes = ARRAY_SIZE(msm_spm_seq_list),
- .modes = msm_spm_seq_list,
+ .num_modes = ARRAY_SIZE(msm_spm_nonboot_cpu_seq_list),
+ .modes = msm_spm_nonboot_cpu_seq_list,
},
};
@@ -3837,10 +3837,30 @@ static void mxt_init_hw_liquid(void)
__func__, GPIO_MXT_TS_LDO_EN);
goto err_ldo_gpio_req;
}
+#if !defined(CONFIG_WIRELESS_CHARGING)
+ rc = gpio_request(GPIO_MXT_TS_RESET, "mxt_reset_gpio");
+ if (rc) {
+ pr_err("%s: unable to request mxt_reset gpio [%d]\n",
+ __func__, GPIO_MXT_TS_RESET);
+ goto err_ldo_gpio_set_dir;
+ }
+
+ rc = gpio_direction_output(GPIO_MXT_TS_RESET, 1);
+ if (rc) {
+ pr_err("%s: unable to set_direction for mxt_reset gpio [%d]\n",
+ __func__, GPIO_MXT_TS_RESET);
+ goto err_reset_gpio_req;
+ }
+#endif
return;
+#if !defined(CONFIG_WIRELESS_CHARGING)
+err_reset_gpio_req:
+ gpio_free(GPIO_MXT_TS_RESET);
err_ldo_gpio_set_dir:
gpio_set_value(GPIO_MXT_TS_LDO_EN, 0);
+#endif
+
err_ldo_gpio_req:
gpio_free(GPIO_MXT_TS_LDO_EN);
err_irq_gpio_req:
@@ -3849,7 +3869,7 @@ err_irq_gpio_req:
static struct mxt_platform_data mxt_platform_data = {
.config = mxt_config_data,
- .config_length = ARRAY_SIZE(mxt_config_data),
+ .config_length = ARRAY_SIZE(mxt_config_data),
.x_line = 26,
.y_line = 42,
.x_size = 767,
@@ -3953,6 +3973,13 @@ static struct msm_rpm_platform_data msm_
.msm_apps_ipc_rpm_reg = MSM_APCS_GCC_BASE + 0x008,
.msm_apps_ipc_rpm_val = 4,
};
+
+static struct msm_pm_sleep_status_data msm_pm_slp_sts_data = {
+ .base_addr = MSM_ACC0_BASE + 0x08,
+ .cpu_offset = MSM_ACC1_BASE - MSM_ACC0_BASE,
+ .mask = 1UL << 13,
+};
+
#ifndef CONFIG_S5C73M3
static struct ks8851_pdata spi_eth_pdata = {
.irq_gpio = KS8851_IRQ_GPIO,
@@ -3979,12 +4006,6 @@ static struct spi_board_info spi_board_i
};
#endif
-static struct msm_pm_sleep_status_data msm_pm_slp_sts_data = {
- .base_addr = MSM_ACC0_BASE + 0x08,
- .cpu_offset = MSM_ACC1_BASE - MSM_ACC0_BASE,
- .mask = 1UL << 13,
-};
-
static struct platform_device msm_device_saw_core0 = {
.name = "saw-regulator",
.id = 0,
@@ -4030,14 +4051,6 @@ static struct platform_device msm8960_de
},
};
-static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
- .name = GPIO_REGULATOR_DEV_NAME,
- .id = 91,
- .dev = {
- .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
- },
-};
-
static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
.name = GPIO_REGULATOR_DEV_NAME,
.id = PM8921_GPIO_PM_TO_SYS(17),
@@ -4357,7 +4370,6 @@ static struct platform_device *common_de
&msm_cache_dump_device,
#endif
&msm8960_cpu_idle_device,
- &msm8960_msm_gov_device,
};
static struct platform_device *m2_spr_devices[] __initdata = {
@@ -4495,18 +4507,31 @@ static struct msm_cpuidle_state msm_csta
{0, 0, "C0", "WFI",
MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
- {0, 1, "C2", "POWER_COLLAPSE",
+ {0, 1, "C1", "RETENTION",
+ MSM_PM_SLEEP_MODE_RETENTION},
+
+ {0, 2, "C2", "POWER_COLLAPSE",
MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
{1, 0, "C0", "WFI",
MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
+
+ {1, 1, "C1", "RETENTION",
+ MSM_PM_SLEEP_MODE_RETENTION},
};
static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
[MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
.idle_supported = 1,
.suspend_supported = 1,
- .idle_enabled = 0,
+ .idle_enabled = 1,
+ .suspend_enabled = 1,
+ },
+
+ [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RETENTION)] = {
+ .idle_supported = 1,
+ .suspend_supported = 0,
+ .idle_enabled = 1,
.suspend_enabled = 0,
},
@@ -4521,7 +4546,14 @@ static struct msm_pm_platform_data msm_p
.idle_supported = 0,
.suspend_supported = 1,
.idle_enabled = 0,
- .suspend_enabled = 0,
+ .suspend_enabled = 1,
+ },
+
+ [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_RETENTION)] = {
+ .idle_supported = 1,
+ .suspend_supported = 1,
+ .idle_enabled = 1,
+ .suspend_enabled = 1,
},
[MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
@@ -4537,55 +4569,56 @@ static struct msm_rpmrs_level msm_rpmrs_
MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
true,
- 100, 650, 801, 200,
+ 1, 550, 180000, 100,
},
{
- MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
- MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
- false,
- 8500, 51, 1122000, 8500,
+ MSM_PM_SLEEP_MODE_RETENTION,
+ MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
+ true,
+ 415, 450, 340827, 475,
},
{
MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
- MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
+ MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
false,
- 9000, 51, 1130300, 9000,
+ 2000, 138, 1208400, 3200,
},
+
{
MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
false,
- 10000, 51, 1130300, 10000,
+ 6000, 119, 1850300, 9000,
},
{
MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
false,
- 12000, 14, 2205900, 12000,
+ 9200, 68, 2839200, 16400,
},
{
MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
false,
- 18000, 12, 2364250, 18000,
+ 10300, 63, 3128000, 18200,
},
{
MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
false,
- 23500, 10, 2667000, 23500,
+ 18000, 10, 4602600, 27000,
},
{
MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
false,
- 29700, 5, 2867000, 30000,
+ 20000, 2, 5752000, 32000,
},
};
@@ -5012,6 +5045,7 @@ static void __init gpio_rev_init(void)
gpio_keys_button[2].gpio = GPIO_HOME_KEY;
gpio_keys_platform_data.nbuttons = ARRAY_SIZE(gpio_keys_button);
}
+
#if defined(CONFIG_SENSORS_CM36651)
if (system_rev < BOARD_REV06)
cm36651_pdata.irq = gpio_rev(ALS_INT);
@@ -5076,7 +5110,7 @@ static struct pm_gpio ear_micbiase = {
.output_value = 0,
};
-static int secjack_gpio_init()
+static int secjack_gpio_init(void)
{
int rc;
@@ -5117,19 +5151,19 @@ static int secjack_gpio_init()
}
#endif
-void main_mic_bias_init()
+void main_mic_bias_init(void)
{
int ret;
ret = gpio_request(GPIO_MAIN_MIC_BIAS, "LDO_BIAS");
if (ret) {
pr_err("%s: ldo bias gpio %d request"
"failed\n", __func__, GPIO_MAIN_MIC_BIAS);
- return ret;
+ return;
}
gpio_direction_output(GPIO_MAIN_MIC_BIAS, 0);
}
-static int configure_codec_lineout_gpio()
+static int configure_codec_lineout_gpio(void)
{
int ret;
struct pm_gpio param = {
@@ -5155,7 +5189,7 @@ static int configure_codec_lineout_gpio(
return 0;
}
-static int tabla_codec_ldo_en_init()
+static int tabla_codec_ldo_en_init(void)
{
int ret;
@@ -5166,8 +5200,9 @@ static int tabla_codec_ldo_en_init()
"failed\n", __func__,
PM8921_GPIO_PM_TO_SYS(gpio_rev(LINEOUT_EN)));
return ret;
- }
- gpio_direction_output(PM8921_GPIO_PM_TO_SYS(gpio_rev(LINEOUT_EN)), 0);
+ } else
+ gpio_direction_output(PM8921_GPIO_PM_TO_SYS(
+ gpio_rev(LINEOUT_EN)), 0);
return 0;
}
@@ -5191,8 +5226,8 @@ static void __init samsung_m2_spr_init(v
regulator_suppress_info_printing();
if (msm_xo_init())
pr_err("Failed to initialize XO votes\n");
- platform_device_register(&msm8960_device_rpm_regulator);
- msm_clock_init(&msm8960_clock_init_data);
+ platform_device_register(&msm8960_device_rpm_regulator);
+ msm_clock_init(&msm8960_clock_init_data);
if (machine_is_msm8960_liquid())
msm_otg_pdata.mhl_enable = true;
msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
@@ -5313,9 +5348,10 @@ static void __init samsung_m2_spr_init(v
if (PLATFORM_IS_CHARM25())
platform_add_devices(mdm_devices, ARRAY_SIZE(mdm_devices));
+ msm_pm_set_tz_retention_flag(1);
}
-MACHINE_START(M2_SPR, "AnThRaXed SAMSUNG M2_SPR")
+MACHINE_START(M2_SPR, "SAMSUNG M2_SPR")
.map_io = msm8960_map_io,
.reserve = msm8960_reserve,
.init_irq = msm8960_init_irq,