regulator: palmas: enable all modes for SMPS10
RFC PATCH 1/1 regulator: palmas: enable all modes for SMPS10
SMPS10 supports different modes such as BOOST mode, BYPASS mode and SWITCH. Inorder to configure SMPS10 in these modes, added palmas_set_mode_smps10() and palmas_get_mode_smps10() for the consumers of SMPS10 to configure it accordingly.
---
Only compile tested. Just sent a patch to get some comments /ideas on how to handle such one off regulators. to handle
drivers/regulator/palmas-regulator.c | 46 ++++++++++++++++++++++++++++++++++ include/linux/mfd/palmas.h | 1 + 2 files changed, 47 insertions(+)
drivers/regulator/palmas-regulator.c +46 -0
@@ -355,6 +355,50 @@ static unsigned int palmas_get_mode_smps(struct regulator_dev *dev)return 0 ; } +static int palmas_set_mode_smps10 (struct regulator_dev *dev,unsigned int mode) +{ +struct palmas_pmic *pmic =rdev_get_drvdata (dev); +int id =rdev_get_id (dev); +unsigned int reg; + +palmas_smps_read (pmic->palmas, palmas_regs_info[id].ctrl_addr, ®); + reg &= ~PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK ; + +if (mode ==REGULATOR_MODE_NORMAL ) + reg |=SMPS10_BOOST_EN ; + +if (mode ==REGULATOR_MODE_FAST ) + reg |=SMPS10_SWITCH_EN ; + +if (mode ==REGULATOR_MODE_IDLE ) + reg |=SMPS10_BYPASS_EN ; + +palmas_smps_write (pmic->palmas, palmas_regs_info[id].ctrl_addr, reg); +return 0 ; +} + +static unsigned int palmas_get_mode_smps10 (struct regulator_dev *dev) +{ +struct palmas_pmic *pmic =rdev_get_drvdata (dev); +int id =rdev_get_id (dev); +unsigned int reg; +int ret =0 ; + + reg = pmic->current_reg_mode[id] & +PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK ; + +if (reg ==SMPS10_BOOST_EN ) + ret |=REGULATOR_MODE_NORMAL ; + +if (reg ==SMPS10_SWITCH_EN ) + ret |=REGULATOR_MODE_FAST ; + +if (reg ==SMPS10_BYPASS_EN ) + ret |=REGULATOR_MODE_IDLE ; + +return ret; +} +static int palmas_list_voltage_smps (struct regulator_dev *dev,unsigned selector) {
@@ -483,6 +527,8 @@ static struct regulator_ops palmas_ops_smps10 = { .is_enabled = regulator_is_enabled_regmap, .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, + .set_mode = palmas_set_mode_smps10, + .get_mode = palmas_get_mode_smps10, .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, .list_voltage = regulator_list_voltage_linear,
include/linux/mfd/palmas.h +1 -0
@@ -846,6 +846,7 @@ enum usb_irq_events {#define PALMAS_SMPS10_CTRL_MODE_SLEEP_MASK 0xf0#define PALMAS_SMPS10_CTRL_MODE_SLEEP_SHIFT 4#define PALMAS_SMPS10_CTRL_MODE_ACTIVE_MASK 0x0f +#define PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK 0x07#define PALMAS_SMPS10_CTRL_MODE_ACTIVE_SHIFT 0/* Bit definitions for SMPS10_STATUS */
Signature · 1 line
1.7.10.4
Mark Brown
maintainerQuoted 3 lines · Kishon Vijay Abraham I
Only compile tested. Just sent a patch to get some comments /ideas on how to handle such one off regulators. to handle
What's unclear or confusing? This all looks really basic...
Quoted 4 lines
drivers/regulator/palmas-regulator.c +4
-0+palmas_smps_read (pmic->palmas, palmas_regs_info[id].ctrl_addr, ®); + reg &= ~PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK ; + +if (mode ==REGULATOR_MODE_NORMAL )
drivers/regulator/palmas-regulator.c static unsigned int palmas_get_mode_smps(struct regulator_dev *dev) · line 377
Quoted 10 lines
drivers/regulator/palmas-regulator.c +10
-0+ reg |=SMPS10_BOOST_EN ; + +if (mode ==REGULATOR_MODE_FAST ) + reg |=SMPS10_SWITCH_EN ; + +if (mode ==REGULATOR_MODE_IDLE ) + reg |=SMPS10_BYPASS_EN ; + +palmas_smps_write (pmic->palmas, palmas_regs_info[id].ctrl_addr, reg); +return 0 ;
This looks like a switch statement and isn't there an update bits operation?
Hi,
Quoted 7 lines · Mark Brown
Quoted 3 lines · Kishon Vijay Abraham I
Only compile tested. Just sent a patch to get some comments /ideas on how to handle such one off regulators. to handle
What's unclear or confusing? This all looks really basic...
For instance mapping of regulator modes to smps10 modes is unclear.
Quoted 10 lines
Quoted 10 lines
drivers/regulator/palmas-regulator.c +9
-0+palmas_smps_read (pmic->palmas, palmas_regs_info[id].ctrl_addr, ®); + reg &= ~PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK ; + +if (mode ==REGULATOR_MODE_NORMAL ) + reg |=SMPS10_BOOST_EN ; + +if (mode ==REGULATOR_MODE_FAST ) + reg |=SMPS10_SWITCH_EN ; +
Quoted 8 lines
drivers/regulator/palmas-regulator.c static unsigned int palmas_get_mode_smps(struct regulator_dev *dev) · line 377
Quoted 5 lines
drivers/regulator/palmas-regulator.c +5
-0+if (mode ==REGULATOR_MODE_IDLE ) + reg |=SMPS10_BYPASS_EN ; + +palmas_smps_write (pmic->palmas, palmas_regs_info[id].ctrl_addr, reg); +return 0 ;This looks like a switch statement and isn't there an update bits operation?
There can be multiple modes set at the same time. Having switch statement means we would need to call the same API multiple times to set the mode. There isn't a palmas wrapper to regmap_update_bits. I can send a patch to add a palmas wrapper.
Thanks
Kishon
Mark Brown
maintainerQuoted 10 lines · Kishon Vijay Abraham I
Quoted 7 lines · Mark Brown
Quoted 3 lines · Kishon Vijay Abraham I
Only compile tested. Just sent a patch to get some comments /ideas on how to handle such one off regulators. to handle
What's unclear or confusing? This all looks really basic...
For instance mapping of regulator modes to smps10 modes is unclear.
If you need clarification on that you need to ask a question about it. There is no question in your code.
Quoted 10 lines
Quoted 8 lines
drivers/regulator/palmas-regulator.c static unsigned int palmas_get_mode_smps(struct regulator_dev *dev) · line 368
Quoted 5 lines
drivers/regulator/palmas-regulator.c +5
-0+palmas_smps_read (pmic->palmas, palmas_regs_info[id].ctrl_addr, ®); + reg &= ~PALMAS_SMPS10_CTRL_MODE_ACTIVE_MODE_MASK ; + +if (mode ==REGULATOR_MODE_NORMAL ) + reg |=SMPS10_BOOST_EN ;This looks like a switch statement and isn't there an update bits operation?
There can be multiple modes set at the same time. Having switch
No they can't and if you check your code you'll see that it's correctly doing that - you're checking if the supplied mode is equal to a given value...
HI Mark,
Quoted 8 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 3 lines · Kishon Vijay Abraham I
Only compile tested. Just sent a patch to get some comments /ideas on how to handle such one off regulators. to handle
What's unclear or confusing? This all looks really basic...
Palma have SMPS10 regulator which can generate two voltage level 3.75 and 5V. This SMPS10 has the two outputs OUT1 and OUT2 and having one input IN1.
SMPS10-OUT2 is always connected to SMPS10-IN1 via following logic:
- Through parasitic diode (no sw control)
- In bypass mode (bit configuration is there to enable/disable Bypass)
- In Boost mode (bit configuration is there to enable/disable Boost mode)
SMPS10-OUT1 is connected to the SMPS10-OUT2 pin through Switch (SW control for enabling/disabling this switch).
So I think:
regualtor enable/disable, we should toggle the bit for SWITCH. In STANDBY mode, it should be BYPASS disable and Boost disable. In Idle/Normal mode, BYPASS enable and Boost disable. In Fast mode, it should be bypass disable and Boost enable.
Kishon,
Do you agree here?
Mark Brown
maintainerQuoted 9 lines · Laxman Dewangan
Palma have SMPS10 regulator which can generate two voltage level 3.75 and 5V.
This SMPS10 has the two outputs OUT1 and OUT2 and having one input IN1.SMPS10-OUT2 is always connected to SMPS10-IN1 via following logic:
- Through parasitic diode (no sw control)
- In bypass mode (bit configuration is there to enable/disable Bypass)
- In Boost mode (bit configuration is there to enable/disable Boost mode)
Quoted 8 lines
SMPS10-OUT1 is connected to the SMPS10-OUT2 pin through Switch (SW control for enabling/disabling this switch).
So I think:
regualtor enable/disable, we should toggle the bit for SWITCH. In STANDBY mode, it should be BYPASS disable and Boost disable. In Idle/Normal mode, BYPASS enable and Boost disable. In Fast mode, it should be bypass disable and Boost enable.
No, that makes no sense at all to me. Why do you think this maps onto the set mode API? Modes are all about accuracy of regulation.
Quoted 18 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 6 lines · Laxman Dewangan
Palma have SMPS10 regulator which can generate two voltage level 3.75 and 5V.
This SMPS10 has the two outputs OUT1 and OUT2 and having one input IN1. SMPS10-OUT2 is always connected to SMPS10-IN1 via following logic:
- Through parasitic diode (no sw control)
- In bypass mode (bit configuration is there to enable/disable Bypass)Quoted 8 lines
- In Boost mode (bit configuration is there to enable/disable Boost mode) SMPS10-OUT1 is connected to the SMPS10-OUT2 pin through Switch (SW control for enabling/disabling this switch).
So I think:
regualtor enable/disable, we should toggle the bit for SWITCH. In STANDBY mode, it should be BYPASS disable and Boost disable. In Idle/Normal mode, BYPASS enable and Boost disable.
In Fast mode, it should be bypass disable and Boost enable.
Quoted 2 lines
No, that makes no sense at all to me. Why do you think this maps onto the set mode API? Modes are all about accuracy of regulation.
I mapped this to the regulation under different load, Fast mode is in heavy load and so boost enable, normal/idle mode for normal load and so bypass.
Mark Brown
maintainerQuoted 8 lines · Laxman Dewangan
Quoted 2 lines · Mark Brown
No, that makes no sense at all to me. Why do you think this maps onto the set mode API? Modes are all about accuracy of regulation.
I mapped this to the regulation under different load, Fast mode is in heavy load and so boost enable, normal/idle mode for normal load and so bypass.
This is still not making any sense. The quality of regulation and output voltage are essentially orthogonal, and obviously there's a specific API for bypass which is something different again to both mode and output voltage selection.
Hi,
Quoted 6 lines · Mark Brown
Quoted 4 lines · Laxman Dewangan
Quoted 2 lines · Mark Brown
No, that makes no sense at all to me. Why do you think this maps onto the set mode API? Modes are all about accuracy of regulation.
Quoted 8 lines
Quoted 3 lines
I mapped this to the regulation under different load, Fast mode is in heavy load and so boost enable, normal/idle mode for normal load and so bypass.
This is still not making any sense. The quality of regulation and output voltage are essentially orthogonal, and obviously there's a specific API for bypass which is something different again to both mode and output voltage selection.
Do you recommend adding API's (similar to bypass) for BOOST and SWITCH?
Thanks
Kishon
Mark Brown
maintainerQuoted 8 lines · Kishon Vijay Abraham I
Quoted 4 lines · Mark Brown
This is still not making any sense. The quality of regulation and output voltage are essentially orthogonal, and obviously there's a specific API for bypass which is something different again to both mode and output voltage selection.
Do you recommend adding API's (similar to bypass) for BOOST and SWITCH?
No. A boost regulator is still a voltage regulator, it just happens to raise rather than lower the voltage but it's otherwise a normal regulator. I'm not sure what you mean by "SWITCH" - from the name it'd just be a bypass?
Hi,
Quoted 8 lines · Mark Brown
Quoted 6 lines · Kishon Vijay Abraham I
Quoted 4 lines · Mark Brown
This is still not making any sense. The quality of regulation and output voltage are essentially orthogonal, and obviously there's a specific API for bypass which is something different again to both mode and output voltage selection.
Quoted 6 lines
Quoted 1 line
Do you recommend adding API's (similar to bypass) for BOOST and SWITCH?
No. A boost regulator is still a voltage regulator, it just happens to raise rather than lower the voltage but it's otherwise a normal regulator. I'm not sure what you mean by "SWITCH" - from the name it'd just be a bypass?
Copy-pasting Laxman's explanation
<...>
Palma have SMPS10 regulator which can generate two voltage level 3.75 and 5V. This SMPS10 has the two outputs OUT1 and OUT2 and having one input IN1.
SMPS10-OUT2 is always connected to SMPS10-IN1 via following logic:
- Through parasitic diode (no sw control)
- In bypass mode (bit configuration is there to enable/disable Bypass)
- In Boost mode (bit configuration is there to enable/disable Boost mode)
SMPS10-OUT1 is connected to the SMPS10-OUT2 pin through Switch (SW control for enabling/disabling this switch).
<...>
Thanks
Kishon
Mark Brown
maintainerQuoted 8 lines · Kishon Vijay Abraham I
Quoted 4 lines · Mark Brown
No. A boost regulator is still a voltage regulator, it just happens to raise rather than lower the voltage but it's otherwise a normal regulator. I'm not sure what you mean by "SWITCH" - from the name it'd just be a bypass?
Copy-pasting Laxman's explanation
That doesn't clarify anything at all.
Hi,
Quoted 7 lines · Mark Brown
Quoted 6 lines · Kishon Vijay Abraham I
Quoted 4 lines · Mark Brown
No. A boost regulator is still a voltage regulator, it just happens to raise rather than lower the voltage but it's otherwise a normal regulator. I'm not sure what you mean by "SWITCH" - from the name it'd just be a bypass?
SMPS10 has two outputs OUT2 and OUT1. In order to connect OUT2 to OUT1 we have to set "SWITCH_EN" bit in SMPS10_CTRL register.
Thanks
Kishon
Mark Brown
maintainerQuoted 11 lines · Kishon Vijay Abraham I
Quoted 7 lines · Mark Brown
Quoted 6 lines · Kishon Vijay Abraham I
Quoted 4 lines · Mark Brown
No. A boost regulator is still a voltage regulator, it just happens to raise rather than lower the voltage but it's otherwise a normal regulator. I'm not sure what you mean by "SWITCH" - from the name it'd just be a bypass?
SMPS10 has two outputs OUT2 and OUT1. In order to connect OUT2 to OUT1 we have to set "
SWITCH_EN" bit inSMPS10_CTRLregister.
Is that not just a normal enable?
Hi,
Quoted 10 lines · Mark Brown
Quoted 8 lines · Kishon Vijay Abraham I
Quoted 7 lines · Mark Brown
Quoted 6 lines · Kishon Vijay Abraham I
Quoted 4 lines · Mark Brown
No. A boost regulator is still a voltage regulator, it just happens to raise rather than lower the voltage but it's otherwise a normal regulator. I'm not sure what you mean by "SWITCH" - from the name it'd just be a bypass?
Quoted 4 lines
Quoted 2 lines
SMPS10 has two outputs OUT2 and OUT1. In order to connect OUT2 to OUT1 we have to set "
SWITCH_EN" bit inSMPS10_CTRLregister.Is that not just a normal enable?
IIUC, normal enable should be when output is driven through OUT2.
Thanks
Kishon
Mark Brown
maintainerQuoted 9 lines · Kishon Vijay Abraham I
Quoted 6 lines · Mark Brown
Quoted 2 lines · Kishon Vijay Abraham I
SMPS10 has two outputs OUT2 and OUT1. In order to connect OUT2 to OUT1 we have to set "
SWITCH_EN" bit inSMPS10_CTRLregister.Is that not just a normal enable?
IIUC, normal enable should be when output is driven through OUT2.
I'm sorry but you're really not making much sense at all here. You say there are two different outputs here...
Please think about what the hardware is doing and try to map it onto the APIs in a coherent fashion - pasting in large sections of dataseet isn't usually helpful, the goal is to map it onto abstractions.
Quoted 11 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 1 line · Kishon Vijay Abraham I
IIUC, normal enable should be when output is driven through OUT2.
I'm sorry but you're really not making much sense at all here. You say there are two different outputs here...
Please think about what the hardware is doing and try to map it onto the APIs in a coherent fashion - pasting in large sections of dataseet isn't usually helpful, the goal is to map it onto abstractions.
I think ff we really want to abstract this stuff then we should have the two different regulator SMPS10-OUT1 and SMPS-OUT2 as there is physically two pins in the device for output and controlled different way.
Mark Brown
maintainerQuoted 4 lines · Laxman Dewangan
I think ff we really want to abstract this stuff then we should have the two different regulator SMPS10-OUT1 and SMPS-OUT2 as there is physically two pins in the device for output and controlled different way.
Yes, that seems like the most obvious thing here as far as I can tell from the frankly fragmented and obscure information but given all the confusion that seems to exist among the people working on the driver it's really not clear if there's something else going on.
Quoted 11 lines · Mark Brown
Quoted 4 lines · Laxman Dewangan
I think ff we really want to abstract this stuff then we should have the two different regulator SMPS10-OUT1 and SMPS-OUT2 as there is physically two pins in the device for output and controlled different way.
Yes, that seems like the most obvious thing here as far as I can tell from the frankly fragmented and obscure information but given all the confusion that seems to exist among the people working on the driver it's really not clear if there's something else going on.
What about the case where they are inputs? For bus power?
Graeme
Mark Brown
maintainerQuoted 8 lines · On Wed, Jun 12, 2013 at 03:31:09PM +0100, [email protected] wrote:
Quoted 4 lines · Mark Brown
Yes, that seems like the most obvious thing here as far as I can tell from the frankly fragmented and obscure information but given all the confusion that seems to exist among the people working on the driver it's really not clear if there's something else going on.
What about the case where they are inputs? For bus power?
So the current flow can change direction here?
Quoted 11 lines · Mark Brown
Quoted 8 lines · On Wed, Jun 12, 2013 at 03:31:09PM +0100, [email protected] wrote:
Quoted 4 lines · Mark Brown
Yes, that seems like the most obvious thing here as far as I can tell from the frankly fragmented and obscure information but given all the confusion that seems to exist among the people working on the driver it's really not clear if there's something else going on.
What about the case where they are inputs? For bus power?
So the current flow can change direction here?
Just rechecked the data sheet and it looks like that use-case has actually been removed from more recent data sheets.
So ignore me, yes now it can be modelled by two regulators!
Graeme
Quoted 7 lines · On Wednesday 12 June 2013 08:53 PM, [email protected] wrote:
Quoted 6 lines · Mark Brown
Quoted 5 lines · On Wed, Jun 12, 2013 at 03:31:09PM +0100, [email protected] wrote:
Quoted 4 lines · Mark Brown
Yes, that seems like the most obvious thing here as far as I can tell from the frankly fragmented and obscure information but given all the confusion that seems to exist among the people working on the driver it's really not clear if there's something else going on.
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
What about the case where they are inputs? For bus power?
So the current flow can change direction here?
Just rechecked the data sheet and it looks like that use-case has actually been
removed from more recent data sheets.So ignore me, yes now it can be modelled by two regulators!
Thanks for concluding on this.
Kishon,
Are you going to send new patch for splitting this regulator or should I send for this?
This will help on populating dts file what Keerthi is sending and also to me for the tegra platform.
Hi,
Quoted 14 lines · Laxman Dewangan
Quoted 13 lines · On Wednesday 12 June 2013 08:53 PM, [email protected] wrote:
Quoted 8 lines · Mark Brown
Quoted 6 lines · On Wed, Jun 12, 2013 at 03:31:09PM +0100, [email protected] wrote:
Quoted 4 lines · Mark Brown
Yes, that seems like the most obvious thing here as far as I can tell from the frankly fragmented and obscure information but given all the confusion that seems to exist among the people working on the driver it's really not clear if there's something else going on.
What about the case where they are inputs? For bus power?
So the current flow can change direction here?
Just rechecked the data sheet and it looks like that use-case has actually been
removed from more recent data sheets.
Quoted 7 lines
Quoted 1 line
So ignore me, yes now it can be modelled by two regulators!
Thanks for concluding on this.
Kishon,
Are you going to send new patch for splitting this regulator or should I send for this?
I'll send by today or tomorrow.
Thanks
Kishon