Message ID | 1397659455-13638-3-git-send-email-linus.walleij@linaro.org |
---|---|
State | Superseded |
Headers | show |
> The STMPE has VCC and VIO supply lines, and sometimes (as on > Ux500) this comes from a software-controlled regulator. Make > it possible to supply the STMPE with power from these > regulators. > > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > drivers/mfd/stmpe.c | 18 ++++++++++++++++++ > include/linux/mfd/stmpe.h | 5 +++++ > 2 files changed, 23 insertions(+) [...] > + stmpe->vcc = devm_regulator_get_optional(ci->dev, "vcc"); > + if (!IS_ERR(stmpe->vcc)) { > + ret = regulator_enable(stmpe->vcc); > + if (ret) > + dev_warn(ci->dev, "failed to enable VCC supply\n"); > + } > + stmpe->vio = devm_regulator_get_optional(ci->dev, "vio"); > + if (!IS_ERR(stmpe->vio)) { > + ret = regulator_enable(stmpe->vio); > + if (ret) > + dev_warn(ci->dev, "failed to enable VIO supply\n"); > + } [...] > int stmpe_remove(struct stmpe *stmpe) > { > + if (!IS_ERR(stmpe->vio)) > + regulator_disable(stmpe->vio); > + if (!IS_ERR(stmpe->vcc)) > + regulator_disable(stmpe->vcc); > + Genuine question: Doesn't the regulator core take care of this for you on removal?
On Thu, Apr 17, 2014 at 12:30 PM, Lee Jones <lee.jones@linaro.org> wrote: >> The STMPE has VCC and VIO supply lines, and sometimes (as on >> Ux500) this comes from a software-controlled regulator. Make >> it possible to supply the STMPE with power from these >> regulators. >> >> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (...) >> int stmpe_remove(struct stmpe *stmpe) >> { >> + if (!IS_ERR(stmpe->vio)) >> + regulator_disable(stmpe->vio); >> + if (!IS_ERR(stmpe->vcc)) >> + regulator_disable(stmpe->vcc); >> + > > Genuine question: > Doesn't the regulator core take care of this for you on removal? No devm_regulator_release() that gets called when refcount goes to 0 just calls regulator_put(). regulator_put(), in turn, will just kfree the struct regulator *. Thus we need to balance enable/disable. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
On Wed, Apr 16, 2014 at 04:44:11PM +0200, Linus Walleij wrote: > The STMPE has VCC and VIO supply lines, and sometimes (as on > Ux500) this comes from a software-controlled regulator. Make > it possible to supply the STMPE with power from these > regulators. > > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> What happens for this patch? I'm asking because I need to know if I should apply patch "ARM: dts: imx6: edmqmx6: add vcc and vio power supplies to stmpe". Shawn -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
On Wed, May 7, 2014 at 1:05 PM, Lee Jones <lee.jones@linaro.org> wrote: > On 6 May 2014 13:52, "Shawn Guo" <shawn.guo@linaro.org> wrote: >> >> What happens for this patch? I'm asking because I need to know if I >> should apply patch "ARM: dts: imx6: edmqmx6: add vcc and vio power >> supplies to stmpe". > > Actually I'm now a little confused as to the current status of this set, as > there have been two fixup patches sent independently of the group. > > Linus, would you mind resubmitting please? OK I'll resend with a RESEND prefix. I think the agreed way forward is that you apply patches 1 thru 4 to the MFD tree. The rest I will funnel in due time ... Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index 6155230ae29c..692452442ead 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -20,6 +20,7 @@ #include <linux/slab.h> #include <linux/mfd/core.h> #include <linux/delay.h> +#include <linux/regulator/consumer.h> #include "stmpe.h" static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks) @@ -1172,6 +1173,18 @@ int stmpe_probe(struct stmpe_client_info *ci, int partnum) stmpe->variant = stmpe_variant_info[partnum]; stmpe->regs = stmpe->variant->regs; stmpe->num_gpios = stmpe->variant->num_gpios; + stmpe->vcc = devm_regulator_get_optional(ci->dev, "vcc"); + if (!IS_ERR(stmpe->vcc)) { + ret = regulator_enable(stmpe->vcc); + if (ret) + dev_warn(ci->dev, "failed to enable VCC supply\n"); + } + stmpe->vio = devm_regulator_get_optional(ci->dev, "vio"); + if (!IS_ERR(stmpe->vio)) { + ret = regulator_enable(stmpe->vio); + if (ret) + dev_warn(ci->dev, "failed to enable VIO supply\n"); + } dev_set_drvdata(stmpe->dev, stmpe); if (ci->init) @@ -1238,6 +1251,11 @@ int stmpe_probe(struct stmpe_client_info *ci, int partnum) int stmpe_remove(struct stmpe *stmpe) { + if (!IS_ERR(stmpe->vio)) + regulator_disable(stmpe->vio); + if (!IS_ERR(stmpe->vcc)) + regulator_disable(stmpe->vcc); + mfd_remove_devices(stmpe->dev); return 0; diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h index 3f8798e4a87d..575a86c7fcbd 100644 --- a/include/linux/mfd/stmpe.h +++ b/include/linux/mfd/stmpe.h @@ -11,6 +11,7 @@ #include <linux/mutex.h> struct device; +struct regulator; enum stmpe_block { STMPE_BLOCK_GPIO = 1 << 0, @@ -62,6 +63,8 @@ struct stmpe_client_info; /** * struct stmpe - STMPE MFD structure + * @vcc: optional VCC regulator + * @vio: optional VIO regulator * @lock: lock protecting I/O operations * @irq_lock: IRQ bus lock * @dev: device, mostly for dev_dbg() @@ -79,6 +82,8 @@ struct stmpe_client_info; * @pdata: platform data */ struct stmpe { + struct regulator *vcc; + struct regulator *vio; struct mutex lock; struct mutex irq_lock; struct device *dev;
The STMPE has VCC and VIO supply lines, and sometimes (as on Ux500) this comes from a software-controlled regulator. Make it possible to supply the STMPE with power from these regulators. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- drivers/mfd/stmpe.c | 18 ++++++++++++++++++ include/linux/mfd/stmpe.h | 5 +++++ 2 files changed, 23 insertions(+)