Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Le jeudi 31 décembre 2015 à 22:14 +, Mark Brown a écrit : > On Thu, Dec 31, 2015 at 10:59:06PM +0100, Paul Kocialkowski wrote: > > > I understand, thanks for pointing this out. Well, for my use case, there > > is no use in disabling the chip at any point as it powers the external > > mmc. > > Presumably someone might decide not to use the MMC in some case (perhaps > only mounting it when explicitly needed in order to save power for > example, or the MMC subsystem might figure out a way to power down an > idle MMC block device). Makes sense, I'll keep that in mind. > > Would you agree to have the enable pin handled directly (and by that, I > > mean enabled once, when requested, as I first suggested in the patchset) > > in the driver then? > > That's probably fine, or do it via runtime PM (the framework is fairly > simple to use, I'll probably go add support in the core for it in the > next day or two as this seems like a sensible use case). I can't > remember if this device is a MFD or not and I'm just on my way out the > door. Runtime PM seems like a good fit (though I hadn't heard about it before: you can guess I'm fairly new to kernel development), please let me know whether you end up implementing it so I can try to handle the GPIO this way. Thanks! -- Paul Kocialkowski, Replicant developer Replicant is a fully free Android distribution running on several devices, a free software mobile operating system putting the emphasis on freedom and privacy/security. Website: https://www.replicant.us/ Blog: https://blog.replicant.us/ Wiki/tracker/forums: https://redmine.replicant.us/ signature.asc Description: This is a digitally signed message part
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
On Thu, Dec 31, 2015 at 10:59:06PM +0100, Paul Kocialkowski wrote: > I understand, thanks for pointing this out. Well, for my use case, there > is no use in disabling the chip at any point as it powers the external > mmc. Presumably someone might decide not to use the MMC in some case (perhaps only mounting it when explicitly needed in order to save power for example, or the MMC subsystem might figure out a way to power down an idle MMC block device). > Would you agree to have the enable pin handled directly (and by that, I > mean enabled once, when requested, as I first suggested in the patchset) > in the driver then? That's probably fine, or do it via runtime PM (the framework is fairly simple to use, I'll probably go add support in the core for it in the next day or two as this seems like a sensible use case). I can't remember if this device is a MFD or not and I'm just on my way out the door. signature.asc Description: PGP signature
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Le jeudi 31 décembre 2015 à 21:40 +, Mark Brown a écrit : > On Wed, Dec 30, 2015 at 07:37:19PM +0100, Paul Kocialkowski wrote: > > Le mercredi 30 décembre 2015 à 16:33 +, Mark Brown a écrit : > > > On Wed, Dec 30, 2015 at 09:35:21AM +0100, Paul Kocialkowski wrote: > > > > > In my opinion, it would be more elegant to adapt the core regulator > > > > framework to first enable the GPIO and then call the regulator enable > > > > ops callback instead of handling the GPIO in the driver. > > > > Why would we want to actively manage both things at runtime? It's more > > > work, what do we gain from it? > > > Well, I figured that it would be best to disable the EN pin when we're > > not using any of the regulators, since that allows the chip to enter > > standby mode (and thus consume less power). > > This doesn't sound like it's anything to do with the regulators, that's > a chip wide power management function which should be implemented via > runtime PM if there's any value in implementing it at all (if the device > is a primary PMIC normally this would be handled by the CPU core when it > enters low power state without any software). It's not something we > should be considering on a per regulator basis since it's at the chip > level and on a per regulator basis it's not doing anything useful for > the reasons above. I understand, thanks for pointing this out. Well, for my use case, there is no use in disabling the chip at any point as it powers the external mmc. Would you agree to have the enable pin handled directly (and by that, I mean enabled once, when requested, as I first suggested in the patchset) in the driver then? > > It also doesn't hurt regulators that only use a GPIO for enable. > > It causes problems for any device with an optional GPIO, it means that > we end up mantaining both GPIO and register which as I've said a couple > of times now defeats the point of having the GPIO. Fair enough. signature.asc Description: This is a digitally signed message part
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
On Wed, Dec 30, 2015 at 07:37:19PM +0100, Paul Kocialkowski wrote: > Le mercredi 30 décembre 2015 à 16:33 +, Mark Brown a écrit : > > On Wed, Dec 30, 2015 at 09:35:21AM +0100, Paul Kocialkowski wrote: > > > In my opinion, it would be more elegant to adapt the core regulator > > > framework to first enable the GPIO and then call the regulator enable > > > ops callback instead of handling the GPIO in the driver. > > Why would we want to actively manage both things at runtime? It's more > > work, what do we gain from it? > Well, I figured that it would be best to disable the EN pin when we're > not using any of the regulators, since that allows the chip to enter > standby mode (and thus consume less power). This doesn't sound like it's anything to do with the regulators, that's a chip wide power management function which should be implemented via runtime PM if there's any value in implementing it at all (if the device is a primary PMIC normally this would be handled by the CPU core when it enters low power state without any software). It's not something we should be considering on a per regulator basis since it's at the chip level and on a per regulator basis it's not doing anything useful for the reasons above. > It also doesn't hurt regulators that only use a GPIO for enable. It causes problems for any device with an optional GPIO, it means that we end up mantaining both GPIO and register which as I've said a couple of times now defeats the point of having the GPIO. signature.asc Description: PGP signature
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Le mercredi 30 décembre 2015 à 16:33 +, Mark Brown a écrit : > On Wed, Dec 30, 2015 at 09:35:21AM +0100, Paul Kocialkowski wrote: > > > In my opinion, it would be more elegant to adapt the core regulator > > framework to first enable the GPIO and then call the regulator enable > > ops callback instead of handling the GPIO in the driver. > > Why would we want to actively manage both things at runtime? It's more > work, what do we gain from it? Well, I figured that it would be best to disable the EN pin when we're not using any of the regulators, since that allows the chip to enter standby mode (and thus consume less power). Implementing that logic in the driver seems very redundant when we're one step away from doing it with the core regulator framework. It is also likely that in the future, other chips will use and need to handle a global enable pin for the same purpose, while allowing regulator configuration and enable via registers. It also doesn't hurt regulators that only use a GPIO for enable. The diff to do this is very minimal, I already have a patch ready, that I could send if there is a chance for it to get through. -- Paul Kocialkowski, Replicant developer Replicant is a fully free Android distribution running on several devices, a free software mobile operating system putting the emphasis on freedom and privacy/security. Website: https://www.replicant.us/ Blog: https://blog.replicant.us/ Wiki/tracker/forums: https://redmine.replicant.us/ signature.asc Description: This is a digitally signed message part
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
On Wed, Dec 30, 2015 at 09:35:21AM +0100, Paul Kocialkowski wrote: > In my opinion, it would be more elegant to adapt the core regulator > framework to first enable the GPIO and then call the regulator enable > ops callback instead of handling the GPIO in the driver. Why would we want to actively manage both things at runtime? It's more work, what do we gain from it? signature.asc Description: PGP signature
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Hi Milo, Le mercredi 30 décembre 2015 à 09:22 +0900, Milo Kim a écrit : > Hi Paul, > > On 29/12/15 20:13, Paul Kocialkowski wrote: > > Hi Milo, > > > > Le mardi 29 décembre 2015 à 09:45 +0900, Milo Kim a écrit : > >> Hi Paul, > >> > >> On 29/12/15 07:49, Paul Kocialkowski wrote: > >>> Hi Milo, thanks for the review, > >>> > >>> Le lundi 28 décembre 2015 à 09:56 +0900, Milo Kim a écrit : > Hi Paul, > > On 23/12/15 20:56, Mark Brown wrote: > > On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: > > > >> + gpio = lp->pdata->enable_gpio; > >> + if (!gpio_is_valid(gpio)) > >> + return 0; > >> + > >> + /* Always set enable GPIO high. */ > >> + ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, > >> "LP872X EN"); > >> + if (ret) { > >> + dev_err(lp->dev, "gpio request err: %d\n", ret); > >> + return ret; > >> + } > > > > This isn't really adding support for the enable GPIO as the changelog > > suggests, it's requesting but not managing the GPIO. Since there is > > core support for manging enable GPIOs this seems especially silly, > > please tell the core about the GPIO and then it will work at runtime > > too. > > > > With reference to my previous mail, external GPIOs for LDO3 and BUCK2 in > LP8725 can be specified through regulator_config.ena_gpio. BUCK2 only > can be controlled by external pin when CONFIG pin is grounded. > > Please see the description at page 5 of the datasheet. > > http://www.ti.com/lit/ds/symlink/lp8725.pdf > >>> > >>> After reading the datasheets thoroughly, it seems to me that for the > >>> lp8720, the EN pin is used to enable the regulators output, which is a > >>> good fit for the core regulator GPIO framework, as there is no reason to > >>> keep it on when no regulator is in use. The serial interface is already > >>> available when EN=0 and regulators can be configured in that state. The > >>> lp8725 seems seems to behave the same when CONFIG=0 (the datasheet > >>> clearly states: "CONFIG=0: EN=1 turns on outputs or standby mode if > >>> EN=0"). On the other hand, it is indeed used as a power-on pin when > >>> CONFIG=1. > >> > >> I think it's different use case. LP8720/5 are designed for system PMU, > >> so some regulators are enabled by default after the device is on. EN pin > >> is used for turning on/off the chip. This pin does not control regulator > >> outputs directly. It's separate functional block in the silicon. > > > > Well, I really don't understand why the EN pin would turn on/off the > > chip. All it does it enable the regulators outputs (by entering IDLE > > mode), the serial block is already available in STANDBY state. > > > > If we want some regulators enabled at boot, the best thing to do seems > > to be to request the GPIO with the GPIOF_INIT_HIGH flag, as done in e.g. > > the max8952 regulator driver: > > > > if (pdata->reg_data->constraints.boot_on) > > config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; > > According to MAX8952 datasheet, output regulator is enabled/disabled > using EN pin, so ena_gpio is used correctly. > However, LP8720/5 regulators are enabled/disabled through I2C command. > Only few regulators of LP8725 can be on/off by separate external pins. > (B2_EN and LDO3_EN) > Please note that EN pin in LP8720/5 is not the control pin for > enabling/disabling regulators. Oh, I should have mentionned that I also suggest making it possible to use *both* an enable GPIO and registers to enable a regulator. You are of course right in saying that the GPIO alone is not enough, and the core regulator framework will currently only do GPIO or registers to enable not both. In my opinion, it would be more elegant to adapt the core regulator framework to first enable the GPIO and then call the regulator enable ops callback instead of handling the GPIO in the driver. However, if that change is not welcome to the core regulator framework, we'll have to deal with the GPIO in the driver (and probably keep it enabled at all times there). Cheers, -- Paul Kocialkowski, Replicant developer Replicant is a fully free Android distribution running on several devices, a free software mobile operating system putting the emphasis on freedom and privacy/security. Website: https://www.replicant.us/ Blog: https://blog.replicant.us/ Wiki/tracker/forums: https://redmine.replicant.us/ signature.asc Description: This is a digitally signed message part
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Hi Paul, On 29/12/15 20:13, Paul Kocialkowski wrote: Hi Milo, Le mardi 29 décembre 2015 à 09:45 +0900, Milo Kim a écrit : Hi Paul, On 29/12/15 07:49, Paul Kocialkowski wrote: Hi Milo, thanks for the review, Le lundi 28 décembre 2015 à 09:56 +0900, Milo Kim a écrit : Hi Paul, On 23/12/15 20:56, Mark Brown wrote: On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: + gpio = lp->pdata->enable_gpio; + if (!gpio_is_valid(gpio)) + return 0; + + /* Always set enable GPIO high. */ + ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X EN"); + if (ret) { + dev_err(lp->dev, "gpio request err: %d\n", ret); + return ret; + } This isn't really adding support for the enable GPIO as the changelog suggests, it's requesting but not managing the GPIO. Since there is core support for manging enable GPIOs this seems especially silly, please tell the core about the GPIO and then it will work at runtime too. With reference to my previous mail, external GPIOs for LDO3 and BUCK2 in LP8725 can be specified through regulator_config.ena_gpio. BUCK2 only can be controlled by external pin when CONFIG pin is grounded. Please see the description at page 5 of the datasheet. http://www.ti.com/lit/ds/symlink/lp8725.pdf After reading the datasheets thoroughly, it seems to me that for the lp8720, the EN pin is used to enable the regulators output, which is a good fit for the core regulator GPIO framework, as there is no reason to keep it on when no regulator is in use. The serial interface is already available when EN=0 and regulators can be configured in that state. The lp8725 seems seems to behave the same when CONFIG=0 (the datasheet clearly states: "CONFIG=0: EN=1 turns on outputs or standby mode if EN=0"). On the other hand, it is indeed used as a power-on pin when CONFIG=1. I think it's different use case. LP8720/5 are designed for system PMU, so some regulators are enabled by default after the device is on. EN pin is used for turning on/off the chip. This pin does not control regulator outputs directly. It's separate functional block in the silicon. Well, I really don't understand why the EN pin would turn on/off the chip. All it does it enable the regulators outputs (by entering IDLE mode), the serial block is already available in STANDBY state. If we want some regulators enabled at boot, the best thing to do seems to be to request the GPIO with the GPIOF_INIT_HIGH flag, as done in e.g. the max8952 regulator driver: if (pdata->reg_data->constraints.boot_on) config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; According to MAX8952 datasheet, output regulator is enabled/disabled using EN pin, so ena_gpio is used correctly. However, LP8720/5 regulators are enabled/disabled through I2C command. Only few regulators of LP8725 can be on/off by separate external pins. (B2_EN and LDO3_EN) Please note that EN pin in LP8720/5 is not the control pin for enabling/disabling regulators. Best regards, Milo -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
On Tue, Dec 29, 2015 at 3:26 PM, Paul Kocialkowski wrote: > Le mardi 29 décembre 2015 à 14:02 -0600, Rob Herring a écrit : >> On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: >> > LP872x regulators are made active via the EN pin, which might be hooked to >> > a >> > GPIO. This adds support for driving the GPIO high when the driver is in >> > use. >> > >> > Signed-off-by: Paul Kocialkowski >> > --- >> > .../devicetree/bindings/regulator/lp872x.txt | 1 + >> > drivers/regulator/lp872x.c | 33 >> > -- >> > include/linux/regulator/lp872x.h | 2 ++ >> > 3 files changed, 33 insertions(+), 3 deletions(-) >> > >> > diff --git a/Documentation/devicetree/bindings/regulator/lp872x.txt >> > b/Documentation/devicetree/bindings/regulator/lp872x.txt >> > index 7818318..0559c25 100644 >> > --- a/Documentation/devicetree/bindings/regulator/lp872x.txt >> > +++ b/Documentation/devicetree/bindings/regulator/lp872x.txt >> > @@ -28,6 +28,7 @@ Optional properties: >> >- ti,dvs-gpio: GPIO specifier for external DVS pin control of LP872x >> > devices. >> >- ti,dvs-vsel: DVS selector. 0 = SEL_V1, 1 = SEL_V2. >> >- ti,dvs-state: initial DVS pin state. 0 = DVS_LOW, 1 = DVS_HIGH. >> > + - ti,enable-gpio: GPIO specifier for EN pin control of LP872x devices. >> >> Should be "-gpios" instead of "-gpio". > > Care to comment why? There is only one GPIO that can be used here, since > there is only one single EN pin. I thought this matched what is done > already with "ti,dvs-gpio". To be consistent. We use "clocks" and "interrupts" always whether one or more for example. -gpio is documented as deprecated now. Rob -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Le mardi 29 décembre 2015 à 14:02 -0600, Rob Herring a écrit : > On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: > > LP872x regulators are made active via the EN pin, which might be hooked to a > > GPIO. This adds support for driving the GPIO high when the driver is in use. > > > > Signed-off-by: Paul Kocialkowski > > --- > > .../devicetree/bindings/regulator/lp872x.txt | 1 + > > drivers/regulator/lp872x.c | 33 > > -- > > include/linux/regulator/lp872x.h | 2 ++ > > 3 files changed, 33 insertions(+), 3 deletions(-) > > > > diff --git a/Documentation/devicetree/bindings/regulator/lp872x.txt > > b/Documentation/devicetree/bindings/regulator/lp872x.txt > > index 7818318..0559c25 100644 > > --- a/Documentation/devicetree/bindings/regulator/lp872x.txt > > +++ b/Documentation/devicetree/bindings/regulator/lp872x.txt > > @@ -28,6 +28,7 @@ Optional properties: > >- ti,dvs-gpio: GPIO specifier for external DVS pin control of LP872x > > devices. > >- ti,dvs-vsel: DVS selector. 0 = SEL_V1, 1 = SEL_V2. > >- ti,dvs-state: initial DVS pin state. 0 = DVS_LOW, 1 = DVS_HIGH. > > + - ti,enable-gpio: GPIO specifier for EN pin control of LP872x devices. > > Should be "-gpios" instead of "-gpio". Care to comment why? There is only one GPIO that can be used here, since there is only one single EN pin. I thought this matched what is done already with "ti,dvs-gpio". Thanks! signature.asc Description: This is a digitally signed message part
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: > LP872x regulators are made active via the EN pin, which might be hooked to a > GPIO. This adds support for driving the GPIO high when the driver is in use. > > Signed-off-by: Paul Kocialkowski > --- > .../devicetree/bindings/regulator/lp872x.txt | 1 + > drivers/regulator/lp872x.c | 33 > -- > include/linux/regulator/lp872x.h | 2 ++ > 3 files changed, 33 insertions(+), 3 deletions(-) > > diff --git a/Documentation/devicetree/bindings/regulator/lp872x.txt > b/Documentation/devicetree/bindings/regulator/lp872x.txt > index 7818318..0559c25 100644 > --- a/Documentation/devicetree/bindings/regulator/lp872x.txt > +++ b/Documentation/devicetree/bindings/regulator/lp872x.txt > @@ -28,6 +28,7 @@ Optional properties: >- ti,dvs-gpio: GPIO specifier for external DVS pin control of LP872x > devices. >- ti,dvs-vsel: DVS selector. 0 = SEL_V1, 1 = SEL_V2. >- ti,dvs-state: initial DVS pin state. 0 = DVS_LOW, 1 = DVS_HIGH. > + - ti,enable-gpio: GPIO specifier for EN pin control of LP872x devices. Should be "-gpios" instead of "-gpio". Rob -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Hi Milo, Le mardi 29 décembre 2015 à 09:45 +0900, Milo Kim a écrit : > Hi Paul, > > On 29/12/15 07:49, Paul Kocialkowski wrote: > > Hi Milo, thanks for the review, > > > > Le lundi 28 décembre 2015 à 09:56 +0900, Milo Kim a écrit : > >> Hi Paul, > >> > >> On 23/12/15 20:56, Mark Brown wrote: > >>> On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: > >>> > +gpio = lp->pdata->enable_gpio; > +if (!gpio_is_valid(gpio)) > +return 0; > + > +/* Always set enable GPIO high. */ > +ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, > "LP872X EN"); > +if (ret) { > +dev_err(lp->dev, "gpio request err: %d\n", ret); > +return ret; > +} > >>> > >>> This isn't really adding support for the enable GPIO as the changelog > >>> suggests, it's requesting but not managing the GPIO. Since there is > >>> core support for manging enable GPIOs this seems especially silly, > >>> please tell the core about the GPIO and then it will work at runtime > >>> too. > >>> > >> > >> With reference to my previous mail, external GPIOs for LDO3 and BUCK2 in > >> LP8725 can be specified through regulator_config.ena_gpio. BUCK2 only > >> can be controlled by external pin when CONFIG pin is grounded. > >> > >> Please see the description at page 5 of the datasheet. > >> > >>http://www.ti.com/lit/ds/symlink/lp8725.pdf > > > > After reading the datasheets thoroughly, it seems to me that for the > > lp8720, the EN pin is used to enable the regulators output, which is a > > good fit for the core regulator GPIO framework, as there is no reason to > > keep it on when no regulator is in use. The serial interface is already > > available when EN=0 and regulators can be configured in that state. The > > lp8725 seems seems to behave the same when CONFIG=0 (the datasheet > > clearly states: "CONFIG=0: EN=1 turns on outputs or standby mode if > > EN=0"). On the other hand, it is indeed used as a power-on pin when > > CONFIG=1. > > I think it's different use case. LP8720/5 are designed for system PMU, > so some regulators are enabled by default after the device is on. EN pin > is used for turning on/off the chip. This pin does not control regulator > outputs directly. It's separate functional block in the silicon. Well, I really don't understand why the EN pin would turn on/off the chip. All it does it enable the regulators outputs (by entering IDLE mode), the serial block is already available in STANDBY state. If we want some regulators enabled at boot, the best thing to do seems to be to request the GPIO with the GPIOF_INIT_HIGH flag, as done in e.g. the max8952 regulator driver: if (pdata->reg_data->constraints.boot_on) config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; > On the other hand, 'ena_gpio' is used for each regulator control itself. > For example, WM8994 has two LDOs which are controlled by external pins. > LDOs are enabled/disabled through LDO1ENA and LDO2ENA pins. In this > case, 'ena_gpio' is used. Of course, but the ena_gpio feature is also a good fit for a global enable pin, as the GPIO can be shared by multiple regulators of the same chip, which is what we have here. In my opinion, using the ena_gpio feature is a good fit, as we don't need to keep the EN pin high when no regulator is used. > http://www.cirrus.com/en/pubs/proDatasheet/WM8994_v4.4.pdf > (please refer to page 224 and 225) Cheers, -- Paul Kocialkowski, Replicant developer Replicant is a fully free Android distribution running on several devices, a free software mobile operating system putting the emphasis on freedom and privacy/security. Website: https://www.replicant.us/ Blog: https://blog.replicant.us/ Wiki/tracker/forums: https://redmine.replicant.us/ signature.asc Description: This is a digitally signed message part
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Hi Paul, On 29/12/15 07:49, Paul Kocialkowski wrote: Hi Milo, thanks for the review, Le lundi 28 décembre 2015 à 09:56 +0900, Milo Kim a écrit : Hi Paul, On 23/12/15 20:56, Mark Brown wrote: On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: + gpio = lp->pdata->enable_gpio; + if (!gpio_is_valid(gpio)) + return 0; + + /* Always set enable GPIO high. */ + ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X EN"); + if (ret) { + dev_err(lp->dev, "gpio request err: %d\n", ret); + return ret; + } This isn't really adding support for the enable GPIO as the changelog suggests, it's requesting but not managing the GPIO. Since there is core support for manging enable GPIOs this seems especially silly, please tell the core about the GPIO and then it will work at runtime too. With reference to my previous mail, external GPIOs for LDO3 and BUCK2 in LP8725 can be specified through regulator_config.ena_gpio. BUCK2 only can be controlled by external pin when CONFIG pin is grounded. Please see the description at page 5 of the datasheet. http://www.ti.com/lit/ds/symlink/lp8725.pdf After reading the datasheets thoroughly, it seems to me that for the lp8720, the EN pin is used to enable the regulators output, which is a good fit for the core regulator GPIO framework, as there is no reason to keep it on when no regulator is in use. The serial interface is already available when EN=0 and regulators can be configured in that state. The lp8725 seems seems to behave the same when CONFIG=0 (the datasheet clearly states: "CONFIG=0: EN=1 turns on outputs or standby mode if EN=0"). On the other hand, it is indeed used as a power-on pin when CONFIG=1. I think it's different use case. LP8720/5 are designed for system PMU, so some regulators are enabled by default after the device is on. EN pin is used for turning on/off the chip. This pin does not control regulator outputs directly. It's separate functional block in the silicon. On the other hand, 'ena_gpio' is used for each regulator control itself. For example, WM8994 has two LDOs which are controlled by external pins. LDOs are enabled/disabled through LDO1ENA and LDO2ENA pins. In this case, 'ena_gpio' is used. http://www.cirrus.com/en/pubs/proDatasheet/WM8994_v4.4.pdf (please refer to page 224 and 225) Best regards, Milo -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Hi Milo, thanks for the review, Le lundi 28 décembre 2015 à 09:56 +0900, Milo Kim a écrit : > Hi Paul, > > On 23/12/15 20:56, Mark Brown wrote: > > On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: > > > >> + gpio = lp->pdata->enable_gpio; > >> + if (!gpio_is_valid(gpio)) > >> + return 0; > >> + > >> + /* Always set enable GPIO high. */ > >> + ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X > >> EN"); > >> + if (ret) { > >> + dev_err(lp->dev, "gpio request err: %d\n", ret); > >> + return ret; > >> + } > > > > This isn't really adding support for the enable GPIO as the changelog > > suggests, it's requesting but not managing the GPIO. Since there is > > core support for manging enable GPIOs this seems especially silly, > > please tell the core about the GPIO and then it will work at runtime > > too. > > > > With reference to my previous mail, external GPIOs for LDO3 and BUCK2 in > LP8725 can be specified through regulator_config.ena_gpio. BUCK2 only > can be controlled by external pin when CONFIG pin is grounded. > > Please see the description at page 5 of the datasheet. > > http://www.ti.com/lit/ds/symlink/lp8725.pdf After reading the datasheets thoroughly, it seems to me that for the lp8720, the EN pin is used to enable the regulators output, which is a good fit for the core regulator GPIO framework, as there is no reason to keep it on when no regulator is in use. The serial interface is already available when EN=0 and regulators can be configured in that state. The lp8725 seems seems to behave the same when CONFIG=0 (the datasheet clearly states: "CONFIG=0: EN=1 turns on outputs or standby mode if EN=0"). On the other hand, it is indeed used as a power-on pin when CONFIG=1. Since my intent here is to cover the lp8720 use case, I suggest that we implement this using the core regulator GPIO framework (I have patches ready for that) and leave out the case where CONFIG=1, which could be dealt with later by providing that piece of information via platform data (and devicetree) and then either use the regulator GPIO framework (when CONFIG=0 and default) or register the GPIO within the driver and keep it on at all times (when CONFIG=1). I could most certainly implement that behaviour, but I'd rather leave it to someone else (or at least the testing) since I don't have any lp8725 to play with. What do you think? -- Paul Kocialkowski, Replicant developer Replicant is a fully free Android distribution running on several devices, a free software mobile operating system putting the emphasis on freedom and privacy/security. Website: https://www.replicant.us/ Blog: https://blog.replicant.us/ Wiki/tracker/forums: https://redmine.replicant.us/ signature.asc Description: This is a digitally signed message part
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Hi Paul, On 23/12/15 20:56, Mark Brown wrote: On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: + gpio = lp->pdata->enable_gpio; + if (!gpio_is_valid(gpio)) + return 0; + + /* Always set enable GPIO high. */ + ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X EN"); + if (ret) { + dev_err(lp->dev, "gpio request err: %d\n", ret); + return ret; + } This isn't really adding support for the enable GPIO as the changelog suggests, it's requesting but not managing the GPIO. Since there is core support for manging enable GPIOs this seems especially silly, please tell the core about the GPIO and then it will work at runtime too. With reference to my previous mail, external GPIOs for LDO3 and BUCK2 in LP8725 can be specified through regulator_config.ena_gpio. BUCK2 only can be controlled by external pin when CONFIG pin is grounded. Please see the description at page 5 of the datasheet. http://www.ti.com/lit/ds/symlink/lp8725.pdf Best regards, Milo -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Hi Paul, Thanks for the patches. Please see my comments below. On 23/12/15 19:58, Paul Kocialkowski wrote: LP872x regulators are made active via the EN pin, which might be hooked to a GPIO. This adds support for driving the GPIO high when the driver is in use. EN pin is used for enabling HW logic like I2C block. It's not regulator enable pin. Please check the block diagram in the datasheet. All regulators of LP8720 and LP8725 are controlled through I2C registers. Additionally, LP8725 provides external pin control for LDO3 and BUCK2. In this case, you can use 'regulator_config.ena_gpio' when a regulator is registered. Signed-off-by: Paul Kocialkowski --- .../devicetree/bindings/regulator/lp872x.txt | 1 + drivers/regulator/lp872x.c | 33 -- include/linux/regulator/lp872x.h | 2 ++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/regulator/lp872x.txt b/Documentation/devicetree/bindings/regulator/lp872x.txt index 7818318..0559c25 100644 --- a/Documentation/devicetree/bindings/regulator/lp872x.txt +++ b/Documentation/devicetree/bindings/regulator/lp872x.txt @@ -28,6 +28,7 @@ Optional properties: - ti,dvs-gpio: GPIO specifier for external DVS pin control of LP872x devices. - ti,dvs-vsel: DVS selector. 0 = SEL_V1, 1 = SEL_V2. - ti,dvs-state: initial DVS pin state. 0 = DVS_LOW, 1 = DVS_HIGH. + - ti,enable-gpio: GPIO specifier for EN pin control of LP872x devices. Please use general property, "enable-gpios" instead of "ti,enable-gpio". Sub nodes for regulator_init_data LP8720 has maximum 6 nodes. (child name: ldo1 ~ 5 and buck) diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index 21c49d8..c8855f3 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c @@ -726,6 +726,27 @@ static struct regulator_desc lp8725_regulator_desc[] = { }, }; +static int lp872x_init_enable(struct lp872x *lp) lp872x_enable_hw() would be better. +{ + int ret, gpio; + + if (!lp->pdata) + return -EINVAL; + + gpio = lp->pdata->enable_gpio; + if (!gpio_is_valid(gpio)) + return 0; + + /* Always set enable GPIO high. */ + ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X EN"); + if (ret) { + dev_err(lp->dev, "gpio request err: %d\n", ret); + return ret; + } LP8720 device needs max 200usec for startup time. LP8725 also requires enable time about 30ms. Please use usleep_range() after EN pin control. + + return 0; +} + static int lp872x_init_dvs(struct lp872x *lp) { int ret, gpio; @@ -763,14 +784,18 @@ static int lp872x_config(struct lp872x *lp) int ret; if (!pdata || !pdata->update_config) - goto init_dvs; + goto init_dvs_enable; ret = lp872x_write_byte(lp, LP872X_GENERAL_CFG, pdata->general_config); if (ret) return ret; -init_dvs: - return lp872x_init_dvs(lp); +init_dvs_enable: + ret = lp872x_init_dvs(lp); + if (ret) + return ret; + + return lp872x_init_enable(lp); } Logic should be enabled prior to DVS configuration. And please call lp872x_enable_hw() in _probe(). static struct regulator_init_data @@ -875,6 +900,8 @@ static struct lp872x_platform_data of_property_read_u8(np, "ti,dvs-state", &dvs_state); pdata->dvs->init_state = dvs_state ? DVS_HIGH : DVS_LOW; + pdata->enable_gpio = of_get_named_gpio(np, "ti,enable-gpio", 0); + Please replace "ti,enable-gpio" with "enable-gpios". Best regards, Milo -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Le jeudi 24 décembre 2015 à 19:35 +, Mark Brown a écrit : > On Thu, Dec 24, 2015 at 07:12:53PM +0100, Paul Kocialkowski wrote: > > Le mercredi 23 décembre 2015 à 11:56 +, Mark Brown a écrit : > > > > This isn't really adding support for the enable GPIO as the changelog > > > suggests, it's requesting but not managing the GPIO. Since there is > > > core support for manging enable GPIOs this seems especially silly, > > > please tell the core about the GPIO and then it will work at runtime > > > too. > > > It looks like the core bindings for GPIO can only be used instead of the > > rdev->desc->ops->enable callback, not jointly, which doesn't fit my use > > case, where both the GPIO and register write have to be used to enable > > regulators. > > > I think it would be worth making it possible to use both in core, since > > that situation is probably shared with other regulators. I suggest the > > following diff (that would be split into a separate patch in v2 of this > > series): > > No, that's broken - the whole point with using a GPIO for enable control > on a lot of devices is that it is much faster than doing a register > write. What I would expect to happen in this case is that when > initialsing the GPIO we set the register to enabled and then only manage > the GPIO at runtime. That GPIO is shared with all regulators that the chip provides, so doing things this way certainly won't work if we don't want all the regulators powered at all times: in that case, the GPIO has precedence over the regulator-specific registers. Doing things the other way round would work and I suppose that chips that can use a GPIO over registers just wouldn't register any ops->enable callback in their description. -- Paul Kocialkowski, Replicant developer Replicant is a fully free Android distribution running on several devices, a free software mobile operating system putting the emphasis on freedom and privacy/security. Website: https://www.replicant.us/ Blog: https://blog.replicant.us/ Wiki/tracker/forums: https://redmine.replicant.us/ signature.asc Description: This is a digitally signed message part
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
On Thu, Dec 24, 2015 at 07:12:53PM +0100, Paul Kocialkowski wrote: > Le mercredi 23 décembre 2015 à 11:56 +, Mark Brown a écrit : > > This isn't really adding support for the enable GPIO as the changelog > > suggests, it's requesting but not managing the GPIO. Since there is > > core support for manging enable GPIOs this seems especially silly, > > please tell the core about the GPIO and then it will work at runtime > > too. > It looks like the core bindings for GPIO can only be used instead of the > rdev->desc->ops->enable callback, not jointly, which doesn't fit my use > case, where both the GPIO and register write have to be used to enable > regulators. > I think it would be worth making it possible to use both in core, since > that situation is probably shared with other regulators. I suggest the > following diff (that would be split into a separate patch in v2 of this > series): No, that's broken - the whole point with using a GPIO for enable control on a lot of devices is that it is much faster than doing a register write. What I would expect to happen in this case is that when initialsing the GPIO we set the register to enabled and then only manage the GPIO at runtime. signature.asc Description: PGP signature
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Le mercredi 23 décembre 2015 à 11:56 +, Mark Brown a écrit : > On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: > > > + gpio = lp->pdata->enable_gpio; > > + if (!gpio_is_valid(gpio)) > > + return 0; > > + > > + /* Always set enable GPIO high. */ > > + ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X > > EN"); > > + if (ret) { > > + dev_err(lp->dev, "gpio request err: %d\n", ret); > > + return ret; > > + } > > This isn't really adding support for the enable GPIO as the changelog > suggests, it's requesting but not managing the GPIO. Since there is > core support for manging enable GPIOs this seems especially silly, > please tell the core about the GPIO and then it will work at runtime > too. It looks like the core bindings for GPIO can only be used instead of the rdev->desc->ops->enable callback, not jointly, which doesn't fit my use case, where both the GPIO and register write have to be used to enable regulators. I think it would be worth making it possible to use both in core, since that situation is probably shared with other regulators. I suggest the following diff (that would be split into a separate patch in v2 of this series): diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index e92f344..dd0674f 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1963,7 +1963,6 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) if (pin->enable_count == 0) gpiod_set_value_cansleep(pin->gpiod, !pin->ena_gpio_invert); - pin->enable_count++; } else { if (pin->enable_count > 1) { @@ -2063,6 +2062,14 @@ static int _regulator_do_enable(struct regulator_dev *rdev) } } + if (rdev->desc->ops->enable) { + ret = rdev->desc->ops->enable(rdev); + if (ret < 0) + return ret; + } else if (!rdev->ena_pin) { + return -EINVAL; + } + if (rdev->ena_pin) { if (!rdev->ena_gpio_state) { ret = regulator_ena_gpio_ctrl(rdev, true); @@ -2070,10 +2077,6 @@ static int _regulator_do_enable(struct regulator_dev *rdev) return ret; rdev->ena_gpio_state = 1; } - } else if (rdev->desc->ops->enable) { - ret = rdev->desc->ops->enable(rdev); - if (ret < 0) - return ret; } else { return -EINVAL; } signature.asc Description: This is a digitally signed message part
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
Le mercredi 23 décembre 2015 à 11:56 +, Mark Brown a écrit : > On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: > > > + gpio = lp->pdata->enable_gpio; > > + if (!gpio_is_valid(gpio)) > > + return 0; > > + > > + /* Always set enable GPIO high. */ > > + ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X > > EN"); > > + if (ret) { > > + dev_err(lp->dev, "gpio request err: %d\n", ret); > > + return ret; > > + } > > This isn't really adding support for the enable GPIO as the changelog > suggests, it's requesting but not managing the GPIO. Since there is > core support for manging enable GPIOs this seems especially silly, > please tell the core about the GPIO and then it will work at runtime > too. You're right, I had clearly overlooked this, thanks for pointing it out. Will send v2 using GPIO handling from core. -- Paul Kocialkowski, Replicant developer Replicant is a fully free Android distribution running on several devices, a free software mobile operating system putting the emphasis on freedom and privacy/security. Website: https://www.replicant.us/ Blog: https://blog.replicant.us/ Wiki/tracker/forums: https://redmine.replicant.us/ signature.asc Description: This is a digitally signed message part
Re: [PATCH 4/6] regulator: lp872x: Add enable GPIO pin support
On Wed, Dec 23, 2015 at 11:58:37AM +0100, Paul Kocialkowski wrote: > + gpio = lp->pdata->enable_gpio; > + if (!gpio_is_valid(gpio)) > + return 0; > + > + /* Always set enable GPIO high. */ > + ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X > EN"); > + if (ret) { > + dev_err(lp->dev, "gpio request err: %d\n", ret); > + return ret; > + } This isn't really adding support for the enable GPIO as the changelog suggests, it's requesting but not managing the GPIO. Since there is core support for manging enable GPIOs this seems especially silly, please tell the core about the GPIO and then it will work at runtime too. signature.asc Description: PGP signature