Skip to contentSkip to conversation

power: pmic: Add support for Palmas family of PMICs

PATCH Superseded Keerthy 4 participants 13 messages Sep 14, 2016 – Sep 19, 2016

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Keerthy

author
#0 lore raw

cover power: pmic: Add support for Palmas family of PMICs

The series adds support for Palmas family of PMICs. Implements functions to configure regulators. Enable/Disable Get/Set voltages of regulators.

Supports TPS659038, TPS65917, Palmas.

Tested on TPS659038, TPS65917 using DRA7XX-EVM and AM57XX-EVM.

Keerthy (5):
power: regulator: Add ctrl_reg and volt_reg fields for pmic
power: pmic: Palmas: Add the base pmic support
power: regulator: palmas: Add regulator support
configs: am57xx_evm_defconfig: Enable PALMAS options
configs: dra7xx_evm_defconfig: Enable PALMAS options

 configs/am57xx_evm_defconfig               |   3 +
 configs/dra7xx_evm_defconfig               |   3 +
 drivers/power/pmic/Kconfig                 |   7 +
 drivers/power/pmic/Makefile                |   1 +
 drivers/power/pmic/palmas.c                |  77 +++++
 drivers/power/regulator/Kconfig            |   8 +
 drivers/power/regulator/Makefile           |   1 +
 drivers/power/regulator/palmas_regulator.c | 460 +++++++++++++++++++++++++++++
 include/power/palmas.h                     |  25 ++
 include/power/regulator.h                  |   2 +
 10 files changed, 587 insertions(+)
 create mode 100644 drivers/power/pmic/palmas.c
 create mode 100644 drivers/power/regulator/palmas_regulator.c
 create mode 100644 include/power/palmas.h
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/5 power: regulator: Add ctrl_reg and volt_reg fields for pmic

The ctrl reg contains bit fields to enable and disable regulators, and volt_reg has the bit fields to configure the voltage values. The registers are frequently accessed hence make them part of dm_regulator_uclass_platdata structure.

---
 include/power/regulator.h | 2 ++
 1 file changed, 2 insertions(+)
include/power/regulator.h +2 -0
index 9bcd728..57b14a3 100644
@@ -171,6 +171,8 @@ struct dm_regulator_uclass_platdata {
 	bool boot_on;
 	const char *name;
 	int flags;
+	u8 ctrl_reg;
+	u8 volt_reg;
 };
 
 /* Regulator device operations */
Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/5 power: regulator: Add ctrl_reg and volt_reg fields for pmic

Hello Keerthy,

Quoted 15 lines · Keerthy

The ctrl reg contains bit fields to enable and disable regulators, and volt_reg has the bit fields to configure the voltage values. The registers are frequently accessed hence make them part of dm_regulator_uclass_platdata structure.

---
  include/power/regulator.h | 2 ++
  1 file changed, 2 insertions(+)
include/power/regulator.h +0 -0
index 9bcd728..57b14a3 100644

include/power/regulator.h struct dm_regulator_uclass_platdata { · line 178

Quoted 8 lines
include/power/regulator.h +2 -0
@@ -171,6 +171,8 @@ struct dm_regulator_uclass_platdata {
  	bool boot_on;
  	const char *name;
  	int flags;
+	u8 ctrl_reg;
+	u8 volt_reg;
  };
 
  /* Regulator device operations */

This structure above is used for some common "high-level" data, which can be used by regulator uclass driver.

Even if most of PMICs has some ctrl/volt/etc regs, the regulator uclass driver doesn't know, how to use it, so from this point of view it is useless.

But, you can keep device/driver data in a proper fields. Please look at those files:

drivers/power/regulator/fixed.c:119
drivers/power/regulator/pfuze100.c:567

To store some device internal data, you can use:
.platdata_auto_alloc_size -> with access by dev_get_platdata() .priv_auto_alloc_size -> with access by dev_get_priv()

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#3 lore raw

PATCH 1/5 power: regulator: Add ctrl_reg and volt_reg fields for pmic

Hi Marczak,

Quoted 36 lines · Przemyslaw Marczak

Hello Keerthy,

Quoted 15 lines · Keerthy

The ctrl reg contains bit fields to enable and disable regulators, and volt_reg has the bit fields to configure the voltage values. The registers are frequently accessed hence make them part of dm_regulator_uclass_platdata structure.

---
  include/power/regulator.h | 2 ++
  1 file changed, 2 insertions(+)
include/power/regulator.h +0 -0
index 9bcd728..57b14a3 100644

include/power/regulator.h struct dm_regulator_uclass_platdata { · line 177

Quoted 7 lines
include/power/regulator.h +2 -0
@@ -171,6 +171,8 @@ struct dm_regulator_uclass_platdata {
      bool boot_on;
      const char *name;
      int flags;
+    u8 ctrl_reg;
+    u8 volt_reg;
  };
    /* Regulator device operations */

This structure above is used for some common "high-level" data, which can be used by regulator uclass driver.

Even if most of PMICs has some ctrl/volt/etc regs, the regulator uclass driver doesn't know, how to use it, so from this point of view it is useless.

But, you can keep device/driver data in a proper fields. Please look at those files:

Quoted 6 lines

drivers/power/regulator/fixed.c:119
drivers/power/regulator/pfuze100.c:567

To store some device internal data, you can use:
.platdata_auto_alloc_size -> with access by dev_get_platdata() .priv_auto_alloc_size -> with access by dev_get_priv()

Thanks for a quick review. I did look at some of those options before introducing volt and ctrl here.

Many PMICs will have ctrl/volt registers we might end up having lot of private strutures with the same ctrl/volt fields. I agree uclass driver will not know how to use it.

If i have to draw parallels from the kernel world regulator_desc is a common structure which hosts vsel_reg/enable_reg fields.

Isn't it better to have a common structure instead of having a some platform specific structure that might have the same fields?

Let me know your thoughts on this.

Quoted 2 lines

Best regards,

#4 lore raw

PATCH 1/5 power: regulator: Add ctrl_reg and volt_reg fields for pmic

Hello Keerthy,

Quoted 53 lines · Keerthy

Hi Marczak,

Quoted 36 lines · Przemyslaw Marczak

Hello Keerthy,

Quoted 15 lines · Keerthy

The ctrl reg contains bit fields to enable and disable regulators, and volt_reg has the bit fields to configure the voltage values. The registers are frequently accessed hence make them part of dm_regulator_uclass_platdata structure.

---
  include/power/regulator.h | 2 ++
  1 file changed, 2 insertions(+)
include/power/regulator.h +0 -0
index 9bcd728..57b14a3 100644

include/power/regulator.h struct dm_regulator_uclass_platdata { · line 177

Quoted 7 lines
include/power/regulator.h +2 -0
@@ -171,6 +171,8 @@ struct dm_regulator_uclass_platdata {
      bool boot_on;
      const char *name;
      int flags;
+    u8 ctrl_reg;
+    u8 volt_reg;
  };
    /* Regulator device operations */

This structure above is used for some common "high-level" data, which can be used by regulator uclass driver.

Even if most of PMICs has some ctrl/volt/etc regs, the regulator uclass driver doesn't know, how to use it, so from this point of view it is useless.

But, you can keep device/driver data in a proper fields. Please look at those files:

Quoted 6 lines

drivers/power/regulator/fixed.c:119
drivers/power/regulator/pfuze100.c:567

To store some device internal data, you can use:
.platdata_auto_alloc_size -> with access by dev_get_platdata() .priv_auto_alloc_size -> with access by dev_get_priv()

Thanks for a quick review. I did look at some of those options before introducing volt and ctrl here.

Many PMICs will have ctrl/volt registers we might end up having lot of private strutures with the same ctrl/volt fields. I agree uclass driver will not know how to use it.

Quoted 13 lines

If i have to draw parallels from the kernel world regulator_desc is a common structure which hosts vsel_reg/enable_reg fields.

Isn't it better to have a common structure instead of having a some platform specific structure that might have the same fields?

Let me know your thoughts on this.

Quoted 2 lines

Best regards,

You are right and I agree with you that make things common is a good approach.

At the begin of introducing this framework, I just wanted to provide a simple user interface for regulators, so I didn't tried to put all common things into a single structure, because not always it could be useful.

The present structure layout seems to be a good representation of regulator's node in the device-tree.

In the other hand, each driver can provide a static arrays with proper data like reg/mask/etc,
the driver:
drivers/power/regulator/s5m8767.c- is a good example.

I'm not going to break your solution, but let's wait for Simon's opinion.

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#5 lore raw

PATCH 1/5 power: regulator: Add ctrl_reg and volt_reg fields for pmic

Quoted 81 lines · Przemyslaw Marczak

Hello Keerthy,

Quoted 53 lines · Keerthy

Hi Marczak,

Quoted 36 lines · Przemyslaw Marczak

Hello Keerthy,

Quoted 15 lines · Keerthy

The ctrl reg contains bit fields to enable and disable regulators, and volt_reg has the bit fields to configure the voltage values. The registers are frequently accessed hence make them part of dm_regulator_uclass_platdata structure.

---
  include/power/regulator.h | 2 ++
  1 file changed, 2 insertions(+)
include/power/regulator.h +0 -0
index 9bcd728..57b14a3 100644

include/power/regulator.h struct dm_regulator_uclass_platdata { · line 177

Quoted 7 lines
include/power/regulator.h +2 -0
@@ -171,6 +171,8 @@ struct dm_regulator_uclass_platdata {
      bool boot_on;
      const char *name;
      int flags;
+    u8 ctrl_reg;
+    u8 volt_reg;
  };
    /* Regulator device operations */

This structure above is used for some common "high-level" data, which can be used by regulator uclass driver.

Even if most of PMICs has some ctrl/volt/etc regs, the regulator uclass driver doesn't know, how to use it, so from this point of view it is useless.

But, you can keep device/driver data in a proper fields. Please look at those files:

Quoted 6 lines

drivers/power/regulator/fixed.c:119
drivers/power/regulator/pfuze100.c:567

To store some device internal data, you can use:
.platdata_auto_alloc_size -> with access by dev_get_platdata() .priv_auto_alloc_size -> with access by dev_get_priv()

Thanks for a quick review. I did look at some of those options before introducing volt and ctrl here.

Many PMICs will have ctrl/volt registers we might end up having lot of private strutures with the same ctrl/volt fields. I agree uclass driver will not know how to use it.

Quoted 13 lines

If i have to draw parallels from the kernel world regulator_desc is a common structure which hosts vsel_reg/enable_reg fields.

Isn't it better to have a common structure instead of having a some platform specific structure that might have the same fields?

Let me know your thoughts on this.

Quoted 2 lines

Best regards,

You are right and I agree with you that make things common is a good approach.

At the begin of introducing this framework, I just wanted to provide a simple user interface for regulators, so I didn't tried to put all common things into a single structure, because not always it could be useful.

The present structure layout seems to be a good representation of regulator's node in the device-tree.

Quoted 6 lines

In the other hand, each driver can provide a static arrays with proper data like reg/mask/etc,
the driver:
drivers/power/regulator/s5m8767.c- is a good example.

I'm not going to break your solution, but let's wait for Simon's opinion.

okay.

Quoted 2 lines

Best regards,

author
#6 lore raw

PATCH 2/5 power: pmic: Palmas: Add the base pmic support

In reply to Keerthy

Add support to bind the regulators/child nodes with the pmic.

---
 drivers/power/pmic/Kconfig  |  7 +++++
 drivers/power/pmic/Makefile |  1 +
 drivers/power/pmic/palmas.c | 77 +++++++++++++++++++++++++++++++++++++++++++++
 include/power/palmas.h      | 25 +++++++++++++++
 4 files changed, 110 insertions(+)
 create mode 100644 drivers/power/pmic/palmas.c
 create mode 100644 include/power/palmas.h
drivers/power/pmic/Kconfig +7 -0
index 69f8d51..92931c5 100644
@@ -135,3 +135,10 @@ config PMIC_TPS65090
 	FETs and a battery charger. This driver provides register access
 	only, and you can enable the regulator/charger drivers separately if
 	required.
+
+config PMIC_PALMAS
+	bool "Enable driver for Texas Instruments PALMAS PMIC"
+	depends on DM_PMIC
+	---help---
+	The PALMAS is a PMIC containing several LDOs, SMPS.
+	This driver binds the pmic children.
drivers/power/pmic/Makefile +1 -0
index 52b4f71..828c0cf 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_PMIC_PM8916) += pm8916.o
 obj-$(CONFIG_PMIC_RK808) += rk808.o
 obj-$(CONFIG_PMIC_TPS65090) += tps65090.o
 obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o
+obj-$(CONFIG_$(SPL_)PMIC_PALMAS) += palmas.o
 
 obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o
 obj-$(CONFIG_POWER_MAX77696) += pmic_max77696.o
drivers/power/pmic/palmas.c new file +77 -0

77 lines not on this page · raw message

include/power/palmas.h new file +25 -0
new file mode 100644
index 0000000..bad5a35
@@ -0,0 +1,25 @@
+#define	PALMAS		0x0
+#define TPS659038	0x1
+#define TPS65917	0x2
+
+/* I2C device address for pmic palmas */
+#define PALMAS_I2C_ADDR	(0x12 >> 1)
+#define PALMAS_LDO_NUM		11
+#define PALMAS_SMPS_NUM	8
+
+/* Drivers name */
+#define PALMAS_LDO_DRIVER     "palmas_ldo"
+#define PALMAS_SMPS_DRIVER    "palmas_smps"
+
+#define PALMAS_SMPS_VOLT_MASK		0x7F
+#define PALMAS_SMPS_RANGE_MASK		0x80
+#define PALMAS_SMPS_VOLT_MAX_HEX	0x7F
+#define PALMAS_SMPS_VOLT_MAX		3300000
+#define PALMAS_SMPS_MODE_MASK		0x3
+#define	PALMAS_SMPS_STATUS_MASK		0x30
+
+#define PALMAS_LDO_VOLT_MASK    0x3F
+#define PALMAS_LDO_VOLT_MAX_HEX 0x3F
+#define PALMAS_LDO_VOLT_MAX     3300000
+#define PALMAS_LDO_MODE_MASK	0x1
+#define PALMAS_LDO_STATUS_MASK	0x10
Signature · 1 line
1.9.1
#7 lore raw

PATCH 2/5 power: pmic: Palmas: Add the base pmic support

Quoted 11 lines · Keerthy

Add support to bind the regulators/child nodes with the pmic.

---
 drivers/power/pmic/Kconfig  |  7 +++++
 drivers/power/pmic/Makefile |  1 +
 drivers/power/pmic/palmas.c | 77 +++++++++++++++++++++++++++++++++++++++++++++
 include/power/palmas.h      | 25 +++++++++++++++
 4 files changed, 110 insertions(+)
 create mode 100644 drivers/power/pmic/palmas.c
 create mode 100644 include/power/palmas.h
author
#8 lore raw

PATCH 3/5 power: regulator: palmas: Add regulator support

In reply to Keerthy

The driver provides regulator set/get voltage enable/disable functions for palmas family of PMICs.

---
 drivers/power/regulator/Kconfig            |   8 +
 drivers/power/regulator/Makefile           |   1 +
 drivers/power/regulator/palmas_regulator.c | 460 +++++++++++++++++++++++++++++
 3 files changed, 469 insertions(+)
 create mode 100644 drivers/power/regulator/palmas_regulator.c
drivers/power/regulator/Kconfig +8 -0
index 17f22dd..adb710a 100644
@@ -115,3 +115,11 @@ config REGULATOR_TPS65090
 	regulators, one for each FET. The standard regulator interface is
 	supported, but it is only possible to turn the regulators on or off.
 	There is no voltage/current control.
+
+config DM_REGULATOR_PALMAS
+	bool "Enable driver for PALMAS PMIC regulators"
+       depends on PMIC_PALMAS
+	---help---
+	This enables implementation of driver-model regulator uclass
+	features for REGULATOR PALMAS and the family of PALMAS PMICs.
+	The driver implements get/set api for: value and enable.
drivers/power/regulator/Makefile +1 -0
index 1590d85..75080d4 100644
@@ -14,3 +14,4 @@ obj-$(CONFIG_REGULATOR_RK808) += rk808.o
 obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
 obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
 obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o
+obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o
drivers/power/regulator/palmas_regulator.c new file +460 -0

460 lines not on this page · raw message

Signature · 1 line
1.9.1
#9 lore raw

PATCH 3/5 power: regulator: palmas: Add regulator support

Quoted 10 lines · Keerthy

The driver provides regulator set/get voltage enable/disable functions for palmas family of PMICs.

---
 drivers/power/regulator/Kconfig            |   8 +
 drivers/power/regulator/Makefile           |   1 +
 drivers/power/regulator/palmas_regulator.c | 460 +++++++++++++++++++++++++++++
 3 files changed, 469 insertions(+)
 create mode 100644 drivers/power/regulator/palmas_regulator.c

But please consider using dm_i2c_reg_read()

Also you have two blank lines at one point.

#10 lore raw

PATCH 3/5 power: regulator: palmas: Add regulator support

Quoted 12 lines · Simon Glass
Quoted 10 lines · Keerthy

The driver provides regulator set/get voltage enable/disable functions for palmas family of PMICs.

---
 drivers/power/regulator/Kconfig            |   8 +
 drivers/power/regulator/Makefile           |   1 +
 drivers/power/regulator/palmas_regulator.c | 460 +++++++++++++++++++++++++++++
 3 files changed, 469 insertions(+)
 create mode 100644 drivers/power/regulator/palmas_regulator.c
Quoted 5 lines

But please consider using dm_i2c_reg_read()

Also you have two blank lines at one point.

Sure i will fix them and repost.
Thanks for the review.

Quoted 1 line
author
#11 lore raw

PATCH 4/5 configs: am57xx_evm_defconfig: Enable PALMAS options

In reply to Keerthy

Enable palmas PMIC config options.

---
 configs/am57xx_evm_defconfig | 3 +++
 1 file changed, 3 insertions(+)
configs/am57xx_evm_defconfig +3 -0
index d49129d..b277783 100644
@@ -39,6 +39,9 @@ CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_BAR=y
 CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_DM_PMIC=y
+CONFIG_PMIC_PALMAS=y
+CONFIG_DM_REGULATOR_PALMAS=y
 CONFIG_DM_SERIAL=y
 CONFIG_SYS_NS16550=y
 CONFIG_DM_SPI=y
Signature · 1 line
1.9.1
author
#12 lore raw

PATCH 5/5 configs: dra7xx_evm_defconfig: Enable PALMAS options

In reply to Keerthy

Enable palmas PMIC config options.

---
 configs/dra7xx_evm_defconfig | 3 +++
 1 file changed, 3 insertions(+)
configs/dra7xx_evm_defconfig +3 -0
index 64184de..882e615 100644
@@ -43,8 +43,11 @@ CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_BAR=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_DM_ETH=y
+CONFIG_DM_PMIC=y
+CONFIG_PMIC_PALMAS=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_PALMAS=y
 CONFIG_DM_SERIAL=y
 CONFIG_SYS_NS16550=y
 CONFIG_DM_SPI=y
Signature · 1 line
1.9.1