Re: [linux-sunxi] Re: [PATCH 6/7] regulator: AXP20x: Add support for regulators subsystem

2014-03-11 Thread Mark Brown
On Tue, Mar 11, 2014 at 10:06:59PM +0100, Carlo Caione wrote:
> On Tue, Mar 11, 2014 at 07:29:40PM +, Mark Brown wrote:

> > With the above code the driver will return an error and never get as far
> > as registering the regulator.

> I agree, but if I register the regulators without having the constrains
> defined in the DT, when regulator_init_complete() is
> called, the regulators are disabled powering off the SoC (at least for
> DCDC2 and DCDC3).

Right, but the kernel will say what it's doing before it does so and
then the user can provide the appropriate setup in DT to force things
on.


signature.asc
Description: Digital signature


Re: [linux-sunxi] Re: [PATCH 6/7] regulator: AXP20x: Add support for regulators subsystem

2014-03-11 Thread Carlo Caione
On Tue, Mar 11, 2014 at 07:29:40PM +, Mark Brown wrote:
> On Tue, Mar 11, 2014 at 08:24:11PM +0100, Carlo Caione wrote:
> > On Mon, Mar 03, 2014 at 10:56:16AM +0900, Mark Brown wrote:
> 
> > > > +   regulators = of_find_node_by_name(np, "regulators");
> > > > +   if (!regulators) {
> > > > +   dev_err(&pdev->dev, "regulators node not found\n");
> > > > +   return -EINVAL;
> > > > +   }
> 
> > > The driver should be able to start up with no configuration provided at
> > > all except for the device being registered - the user won't be able to
> > > change anything but they will be able to read the current state of the
> > > hardware which can be useful for diagnostics.
> 
> > If the device is DT enabled and no configuration is provided for
> > regulators, these are disabled according to:
> 
> > http://lxr.linux.no/linux+v3.13.5/drivers/regulator/core.c#L3797
> 
> > Am I missing something or do you have any pointer?
> 
> With the above code the driver will return an error and never get as far
> as registering the regulator.

I agree, but if I register the regulators without having the constrains
defined in the DT, when regulator_init_complete() is
called, the regulators are disabled powering off the SoC (at least for
DCDC2 and DCDC3).

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH 6/7] regulator: AXP20x: Add support for regulators subsystem

2014-03-11 Thread Mark Brown
On Tue, Mar 11, 2014 at 08:24:11PM +0100, Carlo Caione wrote:
> On Mon, Mar 03, 2014 at 10:56:16AM +0900, Mark Brown wrote:

> > > + regulators = of_find_node_by_name(np, "regulators");
> > > + if (!regulators) {
> > > + dev_err(&pdev->dev, "regulators node not found\n");
> > > + return -EINVAL;
> > > + }

> > The driver should be able to start up with no configuration provided at
> > all except for the device being registered - the user won't be able to
> > change anything but they will be able to read the current state of the
> > hardware which can be useful for diagnostics.

> If the device is DT enabled and no configuration is provided for
> regulators, these are disabled according to:

> http://lxr.linux.no/linux+v3.13.5/drivers/regulator/core.c#L3797

> Am I missing something or do you have any pointer?

With the above code the driver will return an error and never get as far
as registering the regulator.


signature.asc
Description: Digital signature


Re: [linux-sunxi] Re: [PATCH 6/7] regulator: AXP20x: Add support for regulators subsystem

2014-03-11 Thread Carlo Caione
On Mon, Mar 03, 2014 at 10:56:16AM +0900, Mark Brown wrote:


 
> > +   np = of_node_get(pdev->dev.parent->of_node);
> > +   if (!np)
> > +   return 0;
> > +
> > +   regulators = of_find_node_by_name(np, "regulators");
> > +   if (!regulators) {
> > +   dev_err(&pdev->dev, "regulators node not found\n");
> > +   return -EINVAL;
> > +   }
> 
> The driver should be able to start up with no configuration provided at
> all except for the device being registered - the user won't be able to
> change anything but they will be able to read the current state of the
> hardware which can be useful for diagnostics.

If the device is DT enabled and no configuration is provided for
regulators, these are disabled according to:

http://lxr.linux.no/linux+v3.13.5/drivers/regulator/core.c#L3797

Am I missing something or do you have any pointer?

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH 6/7] regulator: AXP20x: Add support for regulators subsystem

2014-03-09 Thread Carlo Caione
On Sun, Mar 09, 2014 at 07:51:48AM +, Mark Brown wrote:
> On Sat, Mar 08, 2014 at 12:43:04PM +0100, Carlo Caione wrote:
> > On Fri, Mar 7, 2014 at 7:22 PM, Maxime Ripard
> > > On Sat, Mar 01, 2014 at 05:45:51PM +0100, Carlo Caione wrote:
> 
> > >> + return platform_driver_register(&axp20x_regulator_driver);
> 
> > > I thought the AXP was only connected through I2C? How is that a
> > > platform device then?
> 
> > Not really. It is plain wrong.
> > I'll fix it in v2.
> 
> Are you sure this is wrong?  For MFDs the core MFD is a driver of
> whatever bus type is in use but the function drivers are platform
> devices which talk to the hardware via the core device.

ok, I spoke too soon. Sorry for the noise.

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH 6/7] regulator: AXP20x: Add support for regulators subsystem

2014-03-08 Thread Mark Brown
On Sat, Mar 08, 2014 at 12:43:04PM +0100, Carlo Caione wrote:
> On Fri, Mar 7, 2014 at 7:22 PM, Maxime Ripard
> > On Sat, Mar 01, 2014 at 05:45:51PM +0100, Carlo Caione wrote:

> >> + return platform_driver_register(&axp20x_regulator_driver);

> > I thought the AXP was only connected through I2C? How is that a
> > platform device then?

> Not really. It is plain wrong.
> I'll fix it in v2.

Are you sure this is wrong?  For MFDs the core MFD is a driver of
whatever bus type is in use but the function drivers are platform
devices which talk to the hardware via the core device.


signature.asc
Description: Digital signature


Re: [linux-sunxi] Re: [PATCH 6/7] regulator: AXP20x: Add support for regulators subsystem

2014-03-08 Thread Carlo Caione
On Fri, Mar 7, 2014 at 7:22 PM, Maxime Ripard
 wrote:
> On Sat, Mar 01, 2014 at 05:45:51PM +0100, Carlo Caione wrote:
>> +static struct platform_driver axp20x_regulator_driver = {
>> + .probe  = axp20x_regulator_probe,
>> + .remove = axp20x_regulator_remove,
>> + .driver = {
>> + .name   = "axp20x-regulator",
>> + .owner  = THIS_MODULE,
>> + },
>> +};
>> +
>> +static int __init axp20x_regulator_init(void)
>> +{
>> + return platform_driver_register(&axp20x_regulator_driver);
>> +}
>> +
>> +subsys_initcall(axp20x_regulator_init);
>
> Hmmm, really?
>
> I thought the AXP was only connected through I2C? How is that a
> platform device then?

Not really. It is plain wrong.
I'll fix it in v2.

Thanks,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH 6/7] regulator: AXP20x: Add support for regulators subsystem

2014-03-04 Thread Carlo Caione
On Mon, Mar 3, 2014 at 2:56 AM, Mark Brown  wrote:
> On Sat, Mar 01, 2014 at 05:45:51PM +0100, Carlo Caione wrote:
>
>> index d59c826..0cef101 100644
>> --- a/arch/arm/configs/sunxi_defconfig
>> +++ b/arch/arm/configs/sunxi_defconfig
>> @@ -69,3 +69,4 @@ CONFIG_NFS_FS=y
>>  CONFIG_ROOT_NFS=y
>>  CONFIG_NLS=y
>>  CONFIG_PRINTK_TIME=y
>> +CONFIG_REGULATOR_AXP20X=y
>
> If you want to update the defconfig do it in a separate patch.

Ok, I'll split the patch.

>> +static int axp20x_set_suspend_voltage(struct regulator_dev *rdev, int uV)
>> +{
>> + return regulator_set_voltage_sel_regmap(rdev, 0);
>> +}

Right. I'll fix it in v2.

> I'm not entirely clear what this is supposed to do but it's broken - it
> both ignores the voltage that is passed in and immediately writes to the
> normal voltage select register which will presumably distrupt the system.
>
>> +static int axp20x_io_enable_regmap(struct regulator_dev *rdev)
>> +{
>> + return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
>> +   rdev->desc->enable_mask, AXP20X_IO_ENABLED);
>> +}
>
> Please make some helpers for this (or extend the existing ones to cope
> with more than a single bit control) - there's several other devices
> which have similar multi-bit controls so we should factor this out
> rather than open coding.

No prob, I'll submit a patch for the helpers before submitting the v2
of this patchset

>> + np = of_node_get(pdev->dev.parent->of_node);
>> + if (!np)
>> + return 0;
>> +
>> + regulators = of_find_node_by_name(np, "regulators");
>> + if (!regulators) {
>> + dev_err(&pdev->dev, "regulators node not found\n");
>> + return -EINVAL;
>> + }
>
> The driver should be able to start up with no configuration provided at
> all except for the device being registered - the user won't be able to
> change anything but they will be able to read the current state of the
> hardware which can be useful for diagnostics.

seems reasonable

>> +static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 
>> workmode)
>> +{
>> + unsigned int mask = AXP20X_WORKMODE_DCDC2_MASK;
>> +
>> + if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
>> + return -EINVAL;
>> +
>> + if (id == AXP20X_DCDC3)
>> + mask = AXP20X_WORKMODE_DCDC3_MASK;
>> +
>> + return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, 
>> workmode);
>> +}
>
> What is a workmode?

It defines if the output from DCDC2 or DCDC3 (that can be used as PWM chargers).
I'll document it better in the bindings documentation.

>> + pmic->rdev[i] = regulator_register(&pmic->rdesc[i], &config);
>> + if (IS_ERR(pmic->rdev[i])) {
>
> Use devm_regulator_register() and then you don't need to clean up the
> regulators either.
>
>> +static int __init axp20x_regulator_init(void)
>> +{
>> + return platform_driver_register(&axp20x_regulator_driver);
>> +}
>> +
>> +subsys_initcall(axp20x_regulator_init);
>
> module_platform_driver().

I'll fix both in v2.

Thank you,

-- 
Carlo Caione

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.