Skip to contentSkip to conversation

power: pmic/regulator: Add basic support for TPS65910

PATCH Superseded Felix Brack 1 participant 2 messages Nov 30, 2017

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 power: pmic/regulator: Add basic support for TPS65910

Texas Instrument's TPS65910 PMIC contains 3 buck DC-DC converts, one boost DC-DC converter and 8 LDOs. This patch implements driver model support for the TPS65910 PMIC and its regulators making the get/set API for regulator value/enable available.
This patch depends on the patch "am33xx: Add a function to query MPU voltage in uV" to build correctly. For boards relying on the DT include file tps65910.dtsi the v3 patch "power: extend prefix match to regulator-name property" and an appropriate regulator naming is also required.

---

Changes in v3:
- use dev_get_driver_data() instead of dev->driver_data
- use dev_get_platdata() instead of dev->platdata
- store unit address in platdata during ofdata_to_platdata() instead of queering it multiple times by dev_get_driver_data()
- use pmic_reg_read() instead of pmic_read() wherever possible
- eliminate the use small data types like u8 if not required

Changes in v2:
- move information about regulator supply power from the PMIC to the regulator driver which greatly simplifies and streamlines the code of both drivers (thanks Simon!)
- use dev_get_uclass_platdata() to get the regulator constraints instead of reinventing the wheel and reading them from the DT
- make pmic_tps65910_write() and pmic_tps65910_read() return the results of the i2c operation instead of obscuring it
- generally review and eventually fix return values
- modify regulator description in Kconfig
- get_ctrl_reg_from_unit_addr() uses a lookup array instead of a switch statement
- rename some local functions to prevent confusion with generic functions
- reformatting code for better readability

 drivers/power/pmic/Kconfig                   |   8 +
 drivers/power/pmic/Makefile                  |   1 +
 drivers/power/pmic/pmic_tps65910_dm.c        |  98 ++++++
 drivers/power/regulator/Kconfig              |   8 +
 drivers/power/regulator/Makefile             |   1 +
 drivers/power/regulator/tps65910_regulator.c | 460 +++++++++++++++++++++++++++
 include/power/tps65910_pmic.h                | 130 ++++++++
 7 files changed, 706 insertions(+)
 create mode 100644 drivers/power/pmic/pmic_tps65910_dm.c
 create mode 100644 drivers/power/regulator/tps65910_regulator.c
 create mode 100644 include/power/tps65910_pmic.h
drivers/power/pmic/Kconfig +8 -0
index e3f9e4d..5d49c93 100644
@@ -201,3 +201,11 @@ config POWER_MC34VR500
 	The MC34VR500 is used in conjunction with the FSL T1 and LS1 series
 	SoC. It provides 4 buck DC-DC convertors and 5 LDOs, and it is accessed
 	via an I2C interface.
+
+config DM_PMIC_TPS65910
+	bool "Enable driver for Texas Instruments TPS65910 PMIC"
+	depends on DM_PMIC
+	---help---
+	The TPS65910 is a PMIC containing 3 buck DC-DC converters, one boost
+	DC-DC converter, 8 LDOs and a RTC. This driver binds the SMPS and LDO
+	pmic children.
drivers/power/pmic/Makefile +1 -0
index f7bdfa5..7d6c583 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_PMIC_RK8XX) += rk8xx.o
 obj-$(CONFIG_PMIC_RN5T567) += rn5t567.o
 obj-$(CONFIG_PMIC_TPS65090) += tps65090.o
 obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o
+obj-$(CONFIG_DM_PMIC_TPS65910) += pmic_tps65910_dm.o
 obj-$(CONFIG_$(SPL_)PMIC_PALMAS) += palmas.o
 obj-$(CONFIG_$(SPL_)PMIC_LP873X) += lp873x.o
 obj-$(CONFIG_$(SPL_)PMIC_LP87565) += lp87565.o
drivers/power/pmic/pmic_tps65910_dm.c new file +98 -0

98 lines not on this page · raw message

drivers/power/regulator/Kconfig +8 -0
index c82a936..fb6a357 100644
@@ -168,3 +168,11 @@ config DM_REGULATOR_LP87565
 	LP87565 series of PMICs have 4 single phase BUCKs that can also
 	be configured in multi phase modes. The driver implements
 	get/set api for value and enable.
+
+config DM_REGULATOR_TPS65910
+	bool "Enable driver for TPS65910 PMIC regulators"
+	depends on DM_PMIC_TPS65910
+	---help---
+	The TPS65910 PMIC provides 4 SMPSs and 8 LDOs. This driver supports all
+	regulator types of the TPS65910 (BUCK, BOOST and LDO). It implements
+	the get/set api for value and enable.
drivers/power/regulator/Makefile +1 -0
index 18fb870..3eef297 100644
@@ -20,3 +20,4 @@ obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_PALMAS) += palmas_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o
+obj-$(CONFIG_DM_REGULATOR_TPS65910) += tps65910_regulator.o
drivers/power/regulator/tps65910_regulator.c new file +460 -0

460 lines not on this page · raw message

include/power/tps65910_pmic.h new file +130 -0

130 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/1 power: pmic/regulator: Add basic support for TPS65910

Please ignore this post. I will send an update v4 shortly, sorry.

regards Felix

Quoted 49 lines · Felix Brack

Texas Instrument's TPS65910 PMIC contains 3 buck DC-DC converts, one boost DC-DC converter and 8 LDOs. This patch implements driver model support for the TPS65910 PMIC and its regulators making the get/set API for regulator value/enable available.
This patch depends on the patch "am33xx: Add a function to query MPU voltage in uV" to build correctly. For boards relying on the DT include file tps65910.dtsi the v3 patch "power: extend prefix match to regulator-name property" and an appropriate regulator naming is also required.

---

Changes in v3:
- use dev_get_driver_data() instead of dev->driver_data
- use dev_get_platdata() instead of dev->platdata
- store unit address in platdata during ofdata_to_platdata() instead of queering it multiple times by dev_get_driver_data()
- use pmic_reg_read() instead of pmic_read() wherever possible
- eliminate the use small data types like u8 if not required

Changes in v2:
- move information about regulator supply power from the PMIC to the regulator driver which greatly simplifies and streamlines the code of both drivers (thanks Simon!)
- use dev_get_uclass_platdata() to get the regulator constraints instead of reinventing the wheel and reading them from the DT
- make pmic_tps65910_write() and pmic_tps65910_read() return the results of the i2c operation instead of obscuring it
- generally review and eventually fix return values
- modify regulator description in Kconfig
- get_ctrl_reg_from_unit_addr() uses a lookup array instead of a switch statement
- rename some local functions to prevent confusion with generic functions
- reformatting code for better readability

 drivers/power/pmic/Kconfig                   |   8 +
 drivers/power/pmic/Makefile                  |   1 +
 drivers/power/pmic/pmic_tps65910_dm.c        |  98 ++++++
 drivers/power/regulator/Kconfig              |   8 +
 drivers/power/regulator/Makefile             |   1 +
 drivers/power/regulator/tps65910_regulator.c | 460 +++++++++++++++++++++++++++
 include/power/tps65910_pmic.h                | 130 ++++++++
 7 files changed, 706 insertions(+)
 create mode 100644 drivers/power/pmic/pmic_tps65910_dm.c
 create mode 100644 drivers/power/regulator/tps65910_regulator.c
 create mode 100644 include/power/tps65910_pmic.h