[PATCH v2] extcon: gpio: Add power resume support
From: Rongjun Ying When system on the suspend state, Some SoC can't get gpio interrupt. After system resume, need send extcon uevent to userspace. Signed-off-by: Rongjun Ying --- -v2: Add lost_sleep_irq flags. drivers/extcon/extcon-gpio.c | 20 include/linux/extcon/extcon-gpio.h |1 + 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 7e0dff5..fde52c1 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -40,6 +40,7 @@ struct gpio_extcon_data { int irq; struct delayed_work work; unsigned long debounce_jiffies; + bool lost_sleep_irq; }; static void gpio_extcon_work(struct work_struct *work) @@ -103,6 +104,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) extcon_data->gpio_active_low = pdata->gpio_active_low; extcon_data->state_on = pdata->state_on; extcon_data->state_off = pdata->state_off; + extcon_data->lost_sleep_irq = pdata->lost_sleep_irq; if (pdata->state_on && pdata->state_off) extcon_data->edev.print_state = extcon_gpio_print_state; if (pdata->debounce) { @@ -159,12 +161,30 @@ static int gpio_extcon_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int gpio_extcon_resume(struct device *dev) +{ + struct gpio_extcon_data *extcon_data; + + extcon_data = dev_get_drvdata(dev); + if (extcon_data->lost_sleep_irq) + queue_delayed_work(system_power_efficient_wq, + _data->work, extcon_data->debounce_jiffies); + return 0; +} +#endif + +static const struct dev_pm_ops gpio_extcon_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(NULL, gpio_extcon_resume) +}; + static struct platform_driver gpio_extcon_driver = { .probe = gpio_extcon_probe, .remove = gpio_extcon_remove, .driver = { .name = "extcon-gpio", .owner = THIS_MODULE, + .pm = _extcon_pm_ops, }, }; diff --git a/include/linux/extcon/extcon-gpio.h b/include/linux/extcon/extcon-gpio.h index 4195810..c7f0c3e 100644 --- a/include/linux/extcon/extcon-gpio.h +++ b/include/linux/extcon/extcon-gpio.h @@ -51,6 +51,7 @@ struct gpio_extcon_platform_data { /* if NULL, "0" or "1" will be printed */ const char *state_on; const char *state_off; + bool lost_sleep_irq; }; #endif /* __EXTCON_GPIO_H__ */ -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2] extcon: gpio: Add power resume support
From: Rongjun Ying rongjun.y...@csr.com When system on the suspend state, Some SoC can't get gpio interrupt. After system resume, need send extcon uevent to userspace. Signed-off-by: Rongjun Ying rongjun.y...@csr.com --- -v2: Add lost_sleep_irq flags. drivers/extcon/extcon-gpio.c | 20 include/linux/extcon/extcon-gpio.h |1 + 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 7e0dff5..fde52c1 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -40,6 +40,7 @@ struct gpio_extcon_data { int irq; struct delayed_work work; unsigned long debounce_jiffies; + bool lost_sleep_irq; }; static void gpio_extcon_work(struct work_struct *work) @@ -103,6 +104,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) extcon_data-gpio_active_low = pdata-gpio_active_low; extcon_data-state_on = pdata-state_on; extcon_data-state_off = pdata-state_off; + extcon_data-lost_sleep_irq = pdata-lost_sleep_irq; if (pdata-state_on pdata-state_off) extcon_data-edev.print_state = extcon_gpio_print_state; if (pdata-debounce) { @@ -159,12 +161,30 @@ static int gpio_extcon_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int gpio_extcon_resume(struct device *dev) +{ + struct gpio_extcon_data *extcon_data; + + extcon_data = dev_get_drvdata(dev); + if (extcon_data-lost_sleep_irq) + queue_delayed_work(system_power_efficient_wq, + extcon_data-work, extcon_data-debounce_jiffies); + return 0; +} +#endif + +static const struct dev_pm_ops gpio_extcon_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(NULL, gpio_extcon_resume) +}; + static struct platform_driver gpio_extcon_driver = { .probe = gpio_extcon_probe, .remove = gpio_extcon_remove, .driver = { .name = extcon-gpio, .owner = THIS_MODULE, + .pm = gpio_extcon_pm_ops, }, }; diff --git a/include/linux/extcon/extcon-gpio.h b/include/linux/extcon/extcon-gpio.h index 4195810..c7f0c3e 100644 --- a/include/linux/extcon/extcon-gpio.h +++ b/include/linux/extcon/extcon-gpio.h @@ -51,6 +51,7 @@ struct gpio_extcon_platform_data { /* if NULL, 0 or 1 will be printed */ const char *state_on; const char *state_off; + bool lost_sleep_irq; }; #endif /* __EXTCON_GPIO_H__ */ -- 1.7.5.4 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/1] extcon: gpio: Add power resume support
From: Rongjun Ying After system resume, need send extcon uevent to userspace Change-Id: I32a9e1c6646035f95765bba79a7acaccb8ce45a7 Signed-off-by: Rongjun Ying --- drivers/extcon/extcon-gpio.c | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 7e0dff5..d916522 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -159,12 +159,29 @@ static int gpio_extcon_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int gpio_extcon_resume(struct device *dev) +{ + struct gpio_extcon_data *extcon_data; + + extcon_data = dev_get_drvdata(dev); + queue_delayed_work(system_power_efficient_wq, _data->work, + extcon_data->debounce_jiffies); + return 0; +} +#endif + +static const struct dev_pm_ops gpio_extcon_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(NULL, gpio_extcon_resume) +}; + static struct platform_driver gpio_extcon_driver = { .probe = gpio_extcon_probe, .remove = gpio_extcon_remove, .driver = { .name = "extcon-gpio", .owner = THIS_MODULE, + .pm = _extcon_pm_ops, }, }; -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/1] extcon: gpio: Add power resume support
From: Rongjun Ying rongjun.y...@csr.com After system resume, need send extcon uevent to userspace Change-Id: I32a9e1c6646035f95765bba79a7acaccb8ce45a7 Signed-off-by: Rongjun Ying rongjun.y...@csr.com --- drivers/extcon/extcon-gpio.c | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 7e0dff5..d916522 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -159,12 +159,29 @@ static int gpio_extcon_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int gpio_extcon_resume(struct device *dev) +{ + struct gpio_extcon_data *extcon_data; + + extcon_data = dev_get_drvdata(dev); + queue_delayed_work(system_power_efficient_wq, extcon_data-work, + extcon_data-debounce_jiffies); + return 0; +} +#endif + +static const struct dev_pm_ops gpio_extcon_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(NULL, gpio_extcon_resume) +}; + static struct platform_driver gpio_extcon_driver = { .probe = gpio_extcon_probe, .remove = gpio_extcon_remove, .driver = { .name = extcon-gpio, .owner = THIS_MODULE, + .pm = gpio_extcon_pm_ops, }, }; -- 1.7.5.4 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance
From: Rongjun Ying Sometime the regulator can't supply appropriate voltages for requestion of cpu. All voltage tolerance value can't figure out a good voltage. Signed-off-by: Rongjun Ying --- drivers/cpufreq/cpufreq-cpu0.c | 17 ++--- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c index c522a95..0c9e6b9 100644 --- a/drivers/cpufreq/cpufreq-cpu0.c +++ b/drivers/cpufreq/cpufreq-cpu0.c @@ -23,7 +23,7 @@ #include static unsigned int transition_latency; -static unsigned int voltage_tolerance; /* in percentage */ +static unsigned int voltage_max; static struct device *cpu_dev; static struct clk *cpu_clk; @@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, { struct cpufreq_freqs freqs; struct opp *opp; - unsigned long volt = 0, volt_old = 0, tol = 0; + unsigned long volt = 0, volt_old = 0; long freq_Hz, freq_exact; unsigned int index; int ret; @@ -82,7 +82,6 @@ static int cpu0_set_target(struct cpufreq_policy *policy, } volt = opp_get_voltage(opp); rcu_read_unlock(); - tol = volt * voltage_tolerance / 100; volt_old = regulator_get_voltage(cpu_reg); } @@ -92,7 +91,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, /* scaling up? scale voltage before frequency */ if (!IS_ERR(cpu_reg) && freqs.new > freqs.old) { - ret = regulator_set_voltage_tol(cpu_reg, volt, tol); + ret = regulator_set_voltage(cpu_reg, volt, voltage_max); if (ret) { pr_err("failed to scale voltage up: %d\n", ret); freqs.new = freqs.old; @@ -104,14 +103,14 @@ static int cpu0_set_target(struct cpufreq_policy *policy, if (ret) { pr_err("failed to set clock rate: %d\n", ret); if (!IS_ERR(cpu_reg)) - regulator_set_voltage_tol(cpu_reg, volt_old, tol); + regulator_set_voltage(cpu_reg, volt_old, voltage_max); freqs.new = freqs.old; goto post_notify; } /* scaling down? scale voltage after frequency */ if (!IS_ERR(cpu_reg) && freqs.new < freqs.old) { - ret = regulator_set_voltage_tol(cpu_reg, volt, tol); + ret = regulator_set_voltage(cpu_reg, volt, voltage_max); if (ret) { pr_err("failed to scale voltage down: %d\n", ret); clk_set_rate(cpu_clk, freqs.old * 1000); @@ -224,7 +223,11 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) goto out_put_node; } - of_property_read_u32(np, "voltage-tolerance", _tolerance); + ret = of_property_read_u32(np, "voltage-max", _max); + if (ret) { + pr_err("failed to get max voltage: %d\n", ret); + goto out_put_node; + } if (of_property_read_u32(np, "clock-latency", _latency)) transition_latency = CPUFREQ_ETERNAL; -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/1] cpufreq: cpufreq-cpu0: use the max voltage instead of voltage-tolerance
From: Rongjun Ying rongjun.y...@csr.com Sometime the regulator can't supply appropriate voltages for requestion of cpu. All voltage tolerance value can't figure out a good voltage. Signed-off-by: Rongjun Ying rongjun.y...@csr.com --- drivers/cpufreq/cpufreq-cpu0.c | 17 ++--- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c index c522a95..0c9e6b9 100644 --- a/drivers/cpufreq/cpufreq-cpu0.c +++ b/drivers/cpufreq/cpufreq-cpu0.c @@ -23,7 +23,7 @@ #include linux/slab.h static unsigned int transition_latency; -static unsigned int voltage_tolerance; /* in percentage */ +static unsigned int voltage_max; static struct device *cpu_dev; static struct clk *cpu_clk; @@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, { struct cpufreq_freqs freqs; struct opp *opp; - unsigned long volt = 0, volt_old = 0, tol = 0; + unsigned long volt = 0, volt_old = 0; long freq_Hz, freq_exact; unsigned int index; int ret; @@ -82,7 +82,6 @@ static int cpu0_set_target(struct cpufreq_policy *policy, } volt = opp_get_voltage(opp); rcu_read_unlock(); - tol = volt * voltage_tolerance / 100; volt_old = regulator_get_voltage(cpu_reg); } @@ -92,7 +91,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, /* scaling up? scale voltage before frequency */ if (!IS_ERR(cpu_reg) freqs.new freqs.old) { - ret = regulator_set_voltage_tol(cpu_reg, volt, tol); + ret = regulator_set_voltage(cpu_reg, volt, voltage_max); if (ret) { pr_err(failed to scale voltage up: %d\n, ret); freqs.new = freqs.old; @@ -104,14 +103,14 @@ static int cpu0_set_target(struct cpufreq_policy *policy, if (ret) { pr_err(failed to set clock rate: %d\n, ret); if (!IS_ERR(cpu_reg)) - regulator_set_voltage_tol(cpu_reg, volt_old, tol); + regulator_set_voltage(cpu_reg, volt_old, voltage_max); freqs.new = freqs.old; goto post_notify; } /* scaling down? scale voltage after frequency */ if (!IS_ERR(cpu_reg) freqs.new freqs.old) { - ret = regulator_set_voltage_tol(cpu_reg, volt, tol); + ret = regulator_set_voltage(cpu_reg, volt, voltage_max); if (ret) { pr_err(failed to scale voltage down: %d\n, ret); clk_set_rate(cpu_clk, freqs.old * 1000); @@ -224,7 +223,11 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) goto out_put_node; } - of_property_read_u32(np, voltage-tolerance, voltage_tolerance); + ret = of_property_read_u32(np, voltage-max, voltage_max); + if (ret) { + pr_err(failed to get max voltage: %d\n, ret); + goto out_put_node; + } if (of_property_read_u32(np, clock-latency, transition_latency)) transition_latency = CPUFREQ_ETERNAL; -- 1.7.5.4 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/