Re: [PATCH 1/3 v4 RESEND] mfd: arizona: Export function to control subsystem DVFS
> > + > +int arizona_dvfs_down(struct arizona *arizona, unsigned int flags) > +{ > + int ret = 0; > + > + mutex_lock(>subsys_max_lock); > + > + if ((arizona->subsys_max_rq & flags) != flags) > + dev_warn(arizona->dev, "Unbalanced DVFS down: %x\n", flags); This warning is bogus and should be removed. These are just simple on/off bit flags, not a reference count. If a requestor is already at the lower DVFS state we just do nothing. It was done this way to keep the code simple and lower risk. None of the blocks that need to move the DVFS frequency up and down have multiple users so they are simple either/or cases that don't currently reference count themselves. So having a boolean flag to match the state of each block keeps the change set smaller. > + > + arizona->subsys_max_rq &= ~flags; > + > + if (arizona->subsys_max_rq == 0) { > + switch (arizona->type) { > + case WM5102: > + case WM8997: > + ret = regmap_update_bits(arizona->regmap, > + ARIZONA_DYNAMIC_FREQUENCY_SCALING_1, > + ARIZONA_SUBSYS_MAX_FREQ, 0); > + if (ret != 0) > + dev_err(arizona->dev, > + "Failed to disable subsys max: %d\n", > + ret); > + > + ret = regulator_set_voltage(arizona->dcvdd, > + 120, 180); > + if (ret != 0) > + dev_err(arizona->dev, > + "Failed to set DCVDD (DVFS down): %d\n", > + ret); > + break; > + > + default: > + break; > + } > + } > + > + mutex_unlock(>subsys_max_lock); > + return ret; > +} > +EXPORT_SYMBOL_GPL(arizona_dvfs_down); > + -- 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/
Re: [PATCH 1/3 v4 RESEND] mfd: arizona: Export function to control subsystem DVFS
+ +int arizona_dvfs_down(struct arizona *arizona, unsigned int flags) +{ + int ret = 0; + + mutex_lock(arizona-subsys_max_lock); + + if ((arizona-subsys_max_rq flags) != flags) + dev_warn(arizona-dev, Unbalanced DVFS down: %x\n, flags); This warning is bogus and should be removed. These are just simple on/off bit flags, not a reference count. If a requestor is already at the lower DVFS state we just do nothing. It was done this way to keep the code simple and lower risk. None of the blocks that need to move the DVFS frequency up and down have multiple users so they are simple either/or cases that don't currently reference count themselves. So having a boolean flag to match the state of each block keeps the change set smaller. + + arizona-subsys_max_rq = ~flags; + + if (arizona-subsys_max_rq == 0) { + switch (arizona-type) { + case WM5102: + case WM8997: + ret = regmap_update_bits(arizona-regmap, + ARIZONA_DYNAMIC_FREQUENCY_SCALING_1, + ARIZONA_SUBSYS_MAX_FREQ, 0); + if (ret != 0) + dev_err(arizona-dev, + Failed to disable subsys max: %d\n, + ret); + + ret = regulator_set_voltage(arizona-dcvdd, + 120, 180); + if (ret != 0) + dev_err(arizona-dev, + Failed to set DCVDD (DVFS down): %d\n, + ret); + break; + + default: + break; + } + } + + mutex_unlock(arizona-subsys_max_lock); + return ret; +} +EXPORT_SYMBOL_GPL(arizona_dvfs_down); + -- 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/
Re: [PATCH 1/3 v4 RESEND] mfd: arizona: Export function to control subsystem DVFS
On Thu, Aug 21, 2014 at 11:40:51AM +0100, Lee Jones wrote: > On Fri, 08 Aug 2014, Richard Fitzgerald wrote: > > > From: Richard Fitzgerald > > > > Moving this control from being a side-effect of the LDO1 > > regulator driver to a specific exported function. > > > > Signed-off-by: Richard Fitzgerald > > Signed-off-by: Charles Keepax > > --- > > drivers/mfd/arizona-core.c | 89 > > ++ > > include/linux/mfd/arizona/core.h | 12 + > > 2 files changed, 101 insertions(+), 0 deletions(-) > > If this is the same patch I reviewed before: > > Acked-by: Lee Jones > > I guess we're just waiting for maintainer Acks before I can apply the > set. > Yes it is, and yes we are. -- 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/
Re: [PATCH 1/3 v4 RESEND] mfd: arizona: Export function to control subsystem DVFS
On Thu, Aug 21, 2014 at 11:40:51AM +0100, Lee Jones wrote: On Fri, 08 Aug 2014, Richard Fitzgerald wrote: From: Richard Fitzgerald r...@opensource.wolfsonmicro.com Moving this control from being a side-effect of the LDO1 regulator driver to a specific exported function. Signed-off-by: Richard Fitzgerald r...@opensource.wolfsonmicro.com Signed-off-by: Charles Keepax ckee...@opensource.wolfsonmicro.com --- drivers/mfd/arizona-core.c | 89 ++ include/linux/mfd/arizona/core.h | 12 + 2 files changed, 101 insertions(+), 0 deletions(-) If this is the same patch I reviewed before: Acked-by: Lee Jones lee.jo...@linaro.org I guess we're just waiting for maintainer Acks before I can apply the set. Yes it is, and yes we are. -- 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/
Re: [PATCH 1/3 v4 RESEND] mfd: arizona: Export function to control subsystem DVFS
On Fri, 08 Aug 2014, Richard Fitzgerald wrote: > From: Richard Fitzgerald > > Moving this control from being a side-effect of the LDO1 > regulator driver to a specific exported function. > > Signed-off-by: Richard Fitzgerald > Signed-off-by: Charles Keepax > --- > drivers/mfd/arizona-core.c | 89 > ++ > include/linux/mfd/arizona/core.h | 12 + > 2 files changed, 101 insertions(+), 0 deletions(-) If this is the same patch I reviewed before: Acked-by: Lee Jones I guess we're just waiting for maintainer Acks before I can apply the set. > diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c > index cfc191a..04cde4b 100644 > --- a/drivers/mfd/arizona-core.c > +++ b/drivers/mfd/arizona-core.c > @@ -94,6 +94,94 @@ int arizona_clk32k_disable(struct arizona *arizona) > } > EXPORT_SYMBOL_GPL(arizona_clk32k_disable); > > +int arizona_dvfs_up(struct arizona *arizona, unsigned int flags) > +{ > + unsigned int new_flags; > + int ret = 0; > + > + mutex_lock(>subsys_max_lock); > + > + new_flags = arizona->subsys_max_rq | flags; > + > + if (arizona->subsys_max_rq != new_flags) { > + switch (arizona->type) { > + case WM5102: > + case WM8997: > + ret = regulator_set_voltage(arizona->dcvdd, > + 180, 180); > + if (ret != 0) { > + dev_err(arizona->dev, > + "Failed to set DCVDD (DVFS up): %d\n", > + ret); > + goto err; > + } > + > + ret = regmap_update_bits(arizona->regmap, > + ARIZONA_DYNAMIC_FREQUENCY_SCALING_1, > + ARIZONA_SUBSYS_MAX_FREQ, 1); > + if (ret != 0) { > + dev_err(arizona->dev, > + "Failed to enable subsys max: %d\n", > + ret); > + regulator_set_voltage(arizona->dcvdd, > + 120, 180); > + goto err; > + } > + break; > + > + default: > + break; > + } > + > + arizona->subsys_max_rq = new_flags; > + } > +err: > + mutex_unlock(>subsys_max_lock); > + return ret; > +} > +EXPORT_SYMBOL_GPL(arizona_dvfs_up); > + > +int arizona_dvfs_down(struct arizona *arizona, unsigned int flags) > +{ > + int ret = 0; > + > + mutex_lock(>subsys_max_lock); > + > + if ((arizona->subsys_max_rq & flags) != flags) > + dev_warn(arizona->dev, "Unbalanced DVFS down: %x\n", flags); > + > + arizona->subsys_max_rq &= ~flags; > + > + if (arizona->subsys_max_rq == 0) { > + switch (arizona->type) { > + case WM5102: > + case WM8997: > + ret = regmap_update_bits(arizona->regmap, > + ARIZONA_DYNAMIC_FREQUENCY_SCALING_1, > + ARIZONA_SUBSYS_MAX_FREQ, 0); > + if (ret != 0) > + dev_err(arizona->dev, > + "Failed to disable subsys max: %d\n", > + ret); > + > + ret = regulator_set_voltage(arizona->dcvdd, > + 120, 180); > + if (ret != 0) > + dev_err(arizona->dev, > + "Failed to set DCVDD (DVFS down): %d\n", > + ret); > + break; > + > + default: > + break; > + } > + } > + > + mutex_unlock(>subsys_max_lock); > + return ret; > +} > +EXPORT_SYMBOL_GPL(arizona_dvfs_down); > + > static irqreturn_t arizona_clkgen_err(int irq, void *data) > { > struct arizona *arizona = data; > @@ -641,6 +729,7 @@ int arizona_dev_init(struct arizona *arizona) > > dev_set_drvdata(arizona->dev, arizona); > mutex_init(>clk_lock); > + mutex_init(>subsys_max_lock); > > if (dev_get_platdata(arizona->dev)) > memcpy(>pdata, dev_get_platdata(arizona->dev), > diff --git a/include/linux/mfd/arizona/core.h > b/include/linux/mfd/arizona/core.h > index a614b33..4aec6a3 100644 > --- a/include/linux/mfd/arizona/core.h > +++ b/include/linux/mfd/arizona/core.h > @@ -109,6 +109,9 @@ struct arizona { > struct mutex clk_lock; > int clk32k_ref; > > + struct mutex subsys_max_lock; > + unsigned int subsys_max_rq; > + > struct snd_soc_dapm_context *dapm; > > int
Re: [PATCH 1/3 v4 RESEND] mfd: arizona: Export function to control subsystem DVFS
On Fri, 08 Aug 2014, Richard Fitzgerald wrote: From: Richard Fitzgerald r...@opensource.wolfsonmicro.com Moving this control from being a side-effect of the LDO1 regulator driver to a specific exported function. Signed-off-by: Richard Fitzgerald r...@opensource.wolfsonmicro.com Signed-off-by: Charles Keepax ckee...@opensource.wolfsonmicro.com --- drivers/mfd/arizona-core.c | 89 ++ include/linux/mfd/arizona/core.h | 12 + 2 files changed, 101 insertions(+), 0 deletions(-) If this is the same patch I reviewed before: Acked-by: Lee Jones lee.jo...@linaro.org I guess we're just waiting for maintainer Acks before I can apply the set. diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index cfc191a..04cde4b 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -94,6 +94,94 @@ int arizona_clk32k_disable(struct arizona *arizona) } EXPORT_SYMBOL_GPL(arizona_clk32k_disable); +int arizona_dvfs_up(struct arizona *arizona, unsigned int flags) +{ + unsigned int new_flags; + int ret = 0; + + mutex_lock(arizona-subsys_max_lock); + + new_flags = arizona-subsys_max_rq | flags; + + if (arizona-subsys_max_rq != new_flags) { + switch (arizona-type) { + case WM5102: + case WM8997: + ret = regulator_set_voltage(arizona-dcvdd, + 180, 180); + if (ret != 0) { + dev_err(arizona-dev, + Failed to set DCVDD (DVFS up): %d\n, + ret); + goto err; + } + + ret = regmap_update_bits(arizona-regmap, + ARIZONA_DYNAMIC_FREQUENCY_SCALING_1, + ARIZONA_SUBSYS_MAX_FREQ, 1); + if (ret != 0) { + dev_err(arizona-dev, + Failed to enable subsys max: %d\n, + ret); + regulator_set_voltage(arizona-dcvdd, + 120, 180); + goto err; + } + break; + + default: + break; + } + + arizona-subsys_max_rq = new_flags; + } +err: + mutex_unlock(arizona-subsys_max_lock); + return ret; +} +EXPORT_SYMBOL_GPL(arizona_dvfs_up); + +int arizona_dvfs_down(struct arizona *arizona, unsigned int flags) +{ + int ret = 0; + + mutex_lock(arizona-subsys_max_lock); + + if ((arizona-subsys_max_rq flags) != flags) + dev_warn(arizona-dev, Unbalanced DVFS down: %x\n, flags); + + arizona-subsys_max_rq = ~flags; + + if (arizona-subsys_max_rq == 0) { + switch (arizona-type) { + case WM5102: + case WM8997: + ret = regmap_update_bits(arizona-regmap, + ARIZONA_DYNAMIC_FREQUENCY_SCALING_1, + ARIZONA_SUBSYS_MAX_FREQ, 0); + if (ret != 0) + dev_err(arizona-dev, + Failed to disable subsys max: %d\n, + ret); + + ret = regulator_set_voltage(arizona-dcvdd, + 120, 180); + if (ret != 0) + dev_err(arizona-dev, + Failed to set DCVDD (DVFS down): %d\n, + ret); + break; + + default: + break; + } + } + + mutex_unlock(arizona-subsys_max_lock); + return ret; +} +EXPORT_SYMBOL_GPL(arizona_dvfs_down); + static irqreturn_t arizona_clkgen_err(int irq, void *data) { struct arizona *arizona = data; @@ -641,6 +729,7 @@ int arizona_dev_init(struct arizona *arizona) dev_set_drvdata(arizona-dev, arizona); mutex_init(arizona-clk_lock); + mutex_init(arizona-subsys_max_lock); if (dev_get_platdata(arizona-dev)) memcpy(arizona-pdata, dev_get_platdata(arizona-dev), diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h index a614b33..4aec6a3 100644 --- a/include/linux/mfd/arizona/core.h +++ b/include/linux/mfd/arizona/core.h @@ -109,6 +109,9 @@ struct arizona { struct mutex clk_lock; int clk32k_ref; + struct mutex subsys_max_lock; + unsigned int subsys_max_rq; + struct snd_soc_dapm_context *dapm; int