Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1395084
| From | Krzysztof Kozlowski <k.kozlowski@samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC v2 07/13] power: pwrseq: simple: Add support for toggling regulator |
| Date | 2016-05-05 14:40 +0200 |
| Message-ID | <rvqJs-8s0-35@gated-at.bofh.it> (permalink) |
| References | <rvqJr-8s0-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Some devices need real hard-reset by cutting the power. During power
sequence turn off and on the regulator, if it is provided.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
.../devicetree/bindings/mmc/mmc-pwrseq-simple.txt | 2 +
drivers/power/pwrseq/pwrseq_simple.c | 50 ++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/Documentation/devicetree/bindings/mmc/mmc-pwrseq-simple.txt b/Documentation/devicetree/bindings/mmc/mmc-pwrseq-simple.txt
index ce0e76749671..176ff831e7f1 100644
--- a/Documentation/devicetree/bindings/mmc/mmc-pwrseq-simple.txt
+++ b/Documentation/devicetree/bindings/mmc/mmc-pwrseq-simple.txt
@@ -16,6 +16,7 @@ Optional properties:
See ../clocks/clock-bindings.txt for details.
- clock-names : Must include the following entry:
"ext_clock" (External clock provided to the card).
+- ext-supply : External regulator supply
Example:
@@ -24,4 +25,5 @@ Example:
reset-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
clocks = <&clk_32768_ck>;
clock-names = "ext_clock";
+ ext-supply = <&buck8>;
}
diff --git a/drivers/power/pwrseq/pwrseq_simple.c b/drivers/power/pwrseq/pwrseq_simple.c
index ab0098412690..4d5ea53d3ead 100644
--- a/drivers/power/pwrseq/pwrseq_simple.c
+++ b/drivers/power/pwrseq/pwrseq_simple.c
@@ -16,7 +16,9 @@
#include <linux/device.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
+#include <linux/regulator/consumer.h>
#include <linux/pwrseq.h>
+#include <linux/delay.h>
#include <linux/mmc/host.h>
@@ -25,6 +27,7 @@ struct mmc_pwrseq_simple {
bool clk_enabled;
struct clk *ext_clk;
struct gpio_descs *reset_gpios;
+ struct regulator *ext_reg;
};
#define to_pwrseq_simple(p) container_of(p, struct mmc_pwrseq_simple, pwrseq)
@@ -62,6 +65,13 @@ static void mmc_pwrseq_simple_post_power_on(struct pwrseq *_pwrseq)
{
struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(_pwrseq);
+ if (pwrseq->ext_reg) {
+ int err;
+
+ err = regulator_enable(pwrseq->ext_reg);
+ WARN_ON_ONCE(err);
+ }
+
mmc_pwrseq_simple_set_gpios_value(pwrseq, 0);
}
@@ -75,6 +85,13 @@ static void mmc_pwrseq_simple_power_off(struct pwrseq *_pwrseq)
clk_disable_unprepare(pwrseq->ext_clk);
pwrseq->clk_enabled = false;
}
+
+ if (pwrseq->ext_reg) {
+ int err;
+
+ err = regulator_disable(pwrseq->ext_reg);
+ WARN_ON_ONCE(err);
+ }
}
static const struct pwrseq_ops mmc_pwrseq_simple_ops = {
@@ -102,6 +119,32 @@ static int mmc_pwrseq_simple_probe(struct platform_device *pdev)
if (IS_ERR(pwrseq->ext_clk) && PTR_ERR(pwrseq->ext_clk) != -ENOENT)
return PTR_ERR(pwrseq->ext_clk);
+ /* FIXME: regulator_get_exclusive? */
+ pwrseq->ext_reg = devm_regulator_get_optional(dev, "ext");
+ if (IS_ERR(pwrseq->ext_reg)) {
+ if (PTR_ERR(pwrseq->ext_reg) == -ENODEV)
+ pwrseq->ext_reg = NULL;
+ else
+ return PTR_ERR(pwrseq->ext_reg);
+ } else {
+ int err;
+ /*
+ * Be sure that regulator is off, before the driver will start
+ * power sequence. It is likely that regulator is on by default
+ * and it without toggling it here, it would be disabled much
+ * later by the core.
+ */
+
+ err = regulator_enable(pwrseq->ext_reg);
+ WARN_ON_ONCE(err);
+
+ /* FIXME: handle this in a more sensible way */
+ mdelay(10);
+
+ err = regulator_disable(pwrseq->ext_reg);
+ WARN_ON_ONCE(err);
+ }
+
pwrseq->reset_gpios = devm_gpiod_get_array(dev, "reset",
GPIOD_OUT_HIGH);
if (IS_ERR(pwrseq->reset_gpios) &&
@@ -124,6 +167,13 @@ static int mmc_pwrseq_simple_remove(struct platform_device *pdev)
pwrseq_unregister(&pwrseq->pwrseq);
+ if (pwrseq->ext_reg) {
+ int err;
+
+ err = regulator_disable(pwrseq->ext_reg);
+ WARN_ON_ONCE(err);
+ }
+
return 0;
}
--
1.9.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC v2 00/13] usb/mmc/power: Fix USB/LAN when TFTP booting Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
[RFC v2 03/13] MAINTAINERS: Retain Ulf Hansson as the same maintainer of pwrseq Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
Re: [RFC v2 03/13] MAINTAINERS: Retain Ulf Hansson as the same maintainer of pwrseq Javier Martinez Canillas <javier@osg.samsung.com> - 2016-05-05 20:50 +0200
[RFC v2 08/13] usb: hub: Handle deferred probe Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
[RFC v2 09/13] power: pwrseq: Add support for USB hubs with external power Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
Re: [RFC v2 09/13] power: pwrseq: Add support for USB hubs with external power Javier Martinez Canillas <javier@osg.samsung.com> - 2016-05-05 22:00 +0200
Re: [RFC v2 09/13] power: pwrseq: Add support for USB hubs with external power Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 08:30 +0200
[RFC v2 10/13] usb: hub: Power sequence the ports on activation Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
Re: [RFC v2 10/13] usb: hub: Power sequence the ports on activation Alan Stern <stern@rowland.harvard.edu> - 2016-05-05 16:20 +0200
Re: [RFC v2 10/13] usb: hub: Power sequence the ports on activation Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 19:40 +0200
Re: [RFC v2 10/13] usb: hub: Power sequence the ports on activation Javier Martinez Canillas <javier@osg.samsung.com> - 2016-05-05 22:00 +0200
[RFC v2 04/13] power: pwrseq: Enable COMPILE_TEST for drivers Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
Re: [RFC v2 04/13] power: pwrseq: Enable COMPILE_TEST for drivers Javier Martinez Canillas <javier@osg.samsung.com> - 2016-05-05 21:00 +0200
[RFC v2 06/13] power: pwrseq: Generalize mmc_pwrseq operations by removing mmc prefix Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
Re: [RFC v2 06/13] power: pwrseq: Generalize mmc_pwrseq operations by removing mmc prefix Javier Martinez Canillas <javier@osg.samsung.com> - 2016-05-05 21:20 +0200
[RFC v2 12/13] ARM: dts: exynos: Switch the buck8 to GPIO mode on Odroid U3 Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
[RFC v2 11/13] usb: port: Parse pwrseq phandle from Device Tree Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
Re: [RFC v2 11/13] usb: port: Parse pwrseq phandle from Device Tree Javier Martinez Canillas <javier@osg.samsung.com> - 2016-05-05 22:20 +0200
Re: [RFC v2 11/13] usb: port: Parse pwrseq phandle from Device Tree Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 08:30 +0200
[RFC v2 13/13] ARM: dts: exynos: Fix LAN and HUB after bootloader initialization on Odroid U3 Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
Re: [RFC v2 13/13] ARM: dts: exynos: Fix LAN and HUB after bootloader initialization on Odroid U3 Javier Martinez Canillas <javier@osg.samsung.com> - 2016-05-05 22:20 +0200
Re: [RFC v2 13/13] ARM: dts: exynos: Fix LAN and HUB after bootloader initialization on Odroid U3 Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 08:30 +0200
[RFC v2 05/13] power: pwrseq: Remove mmc prefix from mmc_pwrseq Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
Re: [RFC v2 05/13] power: pwrseq: Remove mmc prefix from mmc_pwrseq Javier Martinez Canillas <javier@osg.samsung.com> - 2016-05-05 21:20 +0200
Re: [RFC v2 05/13] power: pwrseq: Remove mmc prefix from mmc_pwrseq Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 08:30 +0200
[RFC v2 07/13] power: pwrseq: simple: Add support for toggling regulator Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:40 +0200
Re: [RFC v2 07/13] power: pwrseq: simple: Add support for toggling regulator Javier Martinez Canillas <javier@osg.samsung.com> - 2016-05-05 21:40 +0200
Re: [RFC v2 07/13] power: pwrseq: simple: Add support for toggling regulator Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 08:30 +0200
[RFC v2 02/13] power/mmc: Move pwrseq drivers to power/pwrseq Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-05 14:50 +0200
Re: [RFC v2 02/13] power/mmc: Move pwrseq drivers to power/pwrseq Javier Martinez Canillas <javier@osg.samsung.com> - 2016-05-05 20:50 +0200
Re: [RFC v2 02/13] power/mmc: Move pwrseq drivers to power/pwrseq Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 08:20 +0200
Re: [RFC v2 00/13] usb/mmc/power: Fix USB/LAN when TFTP booting Rob Herring <robh@kernel.org> - 2016-05-06 00:50 +0200
Re: [RFC v2 00/13] usb/mmc/power: Fix USB/LAN when TFTP booting Peter Chen <hzpeterchen@gmail.com> - 2016-05-06 08:00 +0200
Re: [RFC v2 00/13] usb/mmc/power: Fix USB/LAN when TFTP booting Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 08:20 +0200
Re: [RFC v2 00/13] usb/mmc/power: Fix USB/LAN when TFTP booting Peter Chen <hzpeterchen@gmail.com> - 2016-05-06 09:30 +0200
Re: [RFC v2 00/13] usb/mmc/power: Fix USB/LAN when TFTP booting Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-05-06 08:20 +0200
Re: [RFC v2 00/13] usb/mmc/power: Fix USB/LAN when TFTP booting Rob Herring <robh@kernel.org> - 2016-05-06 15:10 +0200
Re: [RFC v2 00/13] usb/mmc/power: Fix USB/LAN when TFTP booting Ulf Hansson <ulf.hansson@linaro.org> - 2016-05-09 09:50 +0200
Re: [RFC v2 00/13] usb/mmc/power: Fix USB/LAN when TFTP booting Rob Herring <robh@kernel.org> - 2016-05-09 20:20 +0200
Re: [RFC v2 00/13] usb/mmc/power: Fix USB/LAN when TFTP booting Ulf Hansson <ulf.hansson@linaro.org> - 2016-05-10 13:10 +0200
csiph-web