regulator: tps6586x: add SMx slew rate setting
PATCH 1/1 regulator: tps6586x: add SMx slew rate setting
From: Danny Huang <[email protected]>
Add output vlotage slew rate setting for SM0/SM1
From: Xin Xie <[email protected]>
--- drivers/regulator/tps6586x-regulator.c | 27 ++++++++++++++++++++++++++- include/linux/mfd/tps6586x.h | 15 +++++++++++++++ 2 files changed, 41 insertions(+), 1 deletions(-)
drivers/regulator/tps6586x-regulator.c +26 -1
@@ -332,6 +332,31 @@ static inline int tps6586x_regulator_preinit(struct device *parent, 1 << ri->enable_bit[1]); } +static int tps6586x_regulator_set_slew_rate (struct platform_device *pdev) +{ +struct device *parent = pdev->dev.parent; +struct regulator_init_data *p = pdev->dev.platform_data; +struct tps6586x_settings *setting = p->driver_data; +uint8_t reg; + +if (setting ==NULL ) +return 0 ; + +/* only SM0 and SM1 can have the slew rate settings */ +switch (pdev->id) { +case TPS6586X_ID_SM_0 : + reg =TPS6586X_SM0SL ; +break ; +case TPS6586X_ID_SM_1 : + reg =TPS6586X_SM1SL ; +break ; +default : +dev_err (&pdev->dev,"invalid regulator ID\n" ); +return -EINVAL ; + } +return tps6586x_write (parent, reg, setting->slew_rate); +} +static inline struct tps6586x_regulator *find_regulator_info (int id) {struct tps6586x_regulator *ri;
@@ -374,7 +399,7 @@ static int __devinit tps6586x_regulator_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rdev); -return 0 ; +return tps6586x_regulator_set_slew_rate (pdev); } static int __devexit tps6586x_regulator_remove(struct platform_device *pdev)
include/linux/mfd/tps6586x.h +15 -0
@@ -48,6 +48,21 @@ enum { TPS6586X_INT_RTC_ALM2, }; +enum { + TPS6586x_SLEW_RATE_INSTANTLY, + TPS6586x_SLEW_RATE_110UV, + TPS6586x_SLEW_RATE_220UV, + TPS6586x_SLEW_RATE_440UV, + TPS6586x_SLEW_RATE_880UV, + TPS6586x_SLEW_RATE_1760UV, + TPS6586x_SLEW_RATE_3520UV, + TPS6586x_SLEW_RATE_7040UV, +}; + +struct tps6586x_settings { +int slew_rate; +}; +struct tps6586x_subdev_info {int id;const char *name;
Signature · 1 line
1.7.0.4
Quoted 5 lines · On Thu, Aug 04, 2011 at 07:34:22PM +0800, [email protected] wrote:
From: Danny Huang <[email protected]>
Add output vlotage slew rate setting for SM0/SM1
From: Xin Xie <[email protected]>
Looks like you messed up here, I rather suspect Xin Xie rather than you should be the author?
drivers/regulator/tps6586x-regulator.c static inline int tps6586x_regulator_preinit(struct device *parent, · line 339
Quoted 5 lines
drivers/regulator/tps6586x-regulator.c +5
-0+static int tps6586x_regulator_set_slew_rate (struct platform_device *pdev) +{ +struct device *parent = pdev->dev.parent; +struct regulator_init_data *p = pdev->dev.platform_data; +struct tps6586x_settings *setting = p->driver_data;
If this is system configured data (which is what one would expect for this) it should be coming in as platform data not driver data - what's happened here?
drivers/regulator/tps6586x-regulator.c static inline int tps6586x_regulator_preinit(struct device *parent, · line 356
Quoted 4 lines
drivers/regulator/tps6586x-regulator.c +4
-0+default : +dev_err (&pdev->dev,"invalid regulator ID\n" ); +return -EINVAL ; + }
Should say what data is invalid here, otherwise it's not going to be at all obvious what's invalid.
include/linux/mfd/tps6586x.h enum { · line 60
Quoted 10 lines
include/linux/mfd/tps6586x.h +10
-0+enum { + TPS6586x_SLEW_RATE_INSTANTLY, + TPS6586x_SLEW_RATE_110UV, + TPS6586x_SLEW_RATE_220UV, + TPS6586x_SLEW_RATE_440UV, + TPS6586x_SLEW_RATE_880UV, + TPS6586x_SLEW_RATE_1760UV, + TPS6586x_SLEW_RATE_3520UV, + TPS6586x_SLEW_RATE_7040UV, +};
If the values are being written directly to the chip you should probably explicitly specify the values that are being set.
Quoted 3 lines · On Thu, Aug 04, 2011 at 07:34:22PM +0800, [email protected] wrote:
From: Danny Huang <[email protected]>
Add output vlotage slew rate setting for SM0/SM1
Oh, and you should also be implementing set_voltage_time_sel() if you know what the slew rate for the device is.
Thanks for the feedback.
The reason for using driver_data is that I can't find a proper field in regulator_init_data for the slew rate setting. I'll do some correction based on the feedback and try to add a new field for the slew rate setting.
-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Thursday, August 04, 2011 20:13
To: Danny Huang
Cc: [email protected]; [email protected]; [email protected]; Xin Xie; [email protected]; [email protected]
Subject: Re: [PATCH] regulator: tps6586x: add SMx slew rate setting
Quoted 5 lines · On Thu, Aug 04, 2011 at 07:34:22PM +0800, [email protected] wrote:
From: Danny Huang <[email protected]>
Add output vlotage slew rate setting for SM0/SM1
From: Xin Xie <[email protected]>
Looks like you messed up here, I rather suspect Xin Xie rather than you should be the author?
drivers/regulator/tps6586x-regulator.c static inline int tps6586x_regulator_preinit(struct device *parent, · line 339
Quoted 5 lines
drivers/regulator/tps6586x-regulator.c +5
-0+static int tps6586x_regulator_set_slew_rate (struct platform_device +*pdev) { +struct device *parent = pdev->dev.parent; +struct regulator_init_data *p = pdev->dev.platform_data; +struct tps6586x_settings *setting = p->driver_data;
If this is system configured data (which is what one would expect for this) it should be coming in as platform data not driver data - what's happened here?
drivers/regulator/tps6586x-regulator.c static inline int tps6586x_regulator_preinit(struct device *parent, · line 356
Quoted 4 lines
drivers/regulator/tps6586x-regulator.c +4
-0+default : +dev_err (&pdev->dev,"invalid regulator ID\n" ); +return -EINVAL ; + }
Should say what data is invalid here, otherwise it's not going to be at all obvious what's invalid.
include/linux/mfd/tps6586x.h enum { · line 60
Quoted 10 lines
include/linux/mfd/tps6586x.h +10
-0+enum { + TPS6586x_SLEW_RATE_INSTANTLY, + TPS6586x_SLEW_RATE_110UV, + TPS6586x_SLEW_RATE_220UV, + TPS6586x_SLEW_RATE_440UV, + TPS6586x_SLEW_RATE_880UV, + TPS6586x_SLEW_RATE_1760UV, + TPS6586x_SLEW_RATE_3520UV, + TPS6586x_SLEW_RATE_7040UV, +};
If the values are being written directly to the chip you should probably explicitly specify the values that are being set.
Thanks. I'll implement this in a separate patch.
-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Thursday, August 04, 2011 20:42
To: Danny Huang
Cc: [email protected]; [email protected]; [email protected]; Xin Xie; [email protected]; [email protected]
Subject: Re: [PATCH] regulator: tps6586x: add SMx slew rate setting
Quoted 3 lines · On Thu, Aug 04, 2011 at 07:34:22PM +0800, [email protected] wrote:
From: Danny Huang <[email protected]>
Add output vlotage slew rate setting for SM0/SM1
Oh, and you should also be implementing set_voltage_time_sel() if you know what the slew rate for the device is.
Quoted 3 lines · Danny Huang
Thanks for the feedback.
The reason for usingdriver_datais that I can't find a proper field inregulator_init_datafor the slew rate setting. I'll do some correction based on the feedback and try to add a new field for the slew rate setting.
No, this is OK - we should really rename the driver_data field, it's very misleading. However:
Quoted 1 line
+ return
tps6586x_write(parent, reg, setting->slew_rate);
what happens if the user sets zero for the slew rate (eg, if another field is added to the platform data that they want to set)? Is this a sane setting (like the chip default) or might it break something?
From: Mark Brown, Sent: Monday, August 08, 2011 17:37
Quoted 7 lines · Danny Huang
Quoted 2 lines
Thanks for the feedback.
The reason for usingdriver_datais that I can't find a proper field in
regulator_init_datafor the slew rate setting.Quoted 1 line
I'll do some correction based on the feedback and try to add a new field for
the slew rate setting.
Quoted 8 lines
No, this is OK - we should really rename the
driver_datafield, it's very misleading. However:Quoted 1 line
+ return
tps6586x_write(parent, reg, setting->slew_rate);what happens if the user sets zero for the slew rate (eg, if another field is added to the platform data that they want to set)? Is this a sane setting (like the chip default) or might it break something?
Zero is a valid setting for the regulator but not the default setting. The default setting is 0x07.
This might affect the system stability under some particular condition. I thought that users should pick a proper setting before init.
Quoted 4 lines · Danny Huang
Zero is a valid setting for the regulator but not the default setting. The default setting is
0x07.
This might affect the system stability under some particular condition. I thought that users should pick a proper setting before init.
It'd be good to do something like make the variable wider than the register then require that users set an out of band bit to program the value to zero. This would improve robustness in hte case where someone relies on a zero initialized platform data by default.