Skip to contentSkip to conversation

TI TPS6594 PMIC support (RTC, pinctrl, regulators)

PATCH Superseded Esteban Blanc 3 participants 9 messages Apr 14, 2023 – May 5, 2023

Subsystems (4)

v3 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v3 cover TI TPS6594 PMIC support (RTC, pinctrl, regulators)

TPS6594 is a Power Management IC which provides regulators and others features like GPIOs, RTC, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine). The SoC and the PMIC can communicate through the I2C or SPI interfaces.
TPS6594 is the super-set device while TPS6593 and LP8764 are derivatives.

This series adds support to TI TPS6594 PMIC and its derivatives.

This should be applied on top of other patch series:
- https://lore.kernel.org/all/[email protected]/
For core MFD driver

The features implemented in this series are:
- RTC (child device)
- Pinmux/GPIO (child device)
- Regulator (child device)

RTC description:
The TPS6594 family has an RTC built-in, except for LP8764. It provides time and an alarm.

Pinmux/GPIO:
TPS6594 family has 11 GPIOs. Those GPIO can also serve different functions such as I2C or SPI interface, watchdog disable functions. The driver provides both pinmuxing for the functions and GPIO capability.

Regulator:
TPS6594/TPS6593: 5 BUCKs and 4LDOs
LP8764: 4 BUCKs and no LDO
Bucks can be used in multipahse mode.

Changes since v1:
https://lore.kernel.org/all/[email protected]/
Rtc:
- Removed struct tps6594_rtc.
- Removed some dev_err messages.
- Removed some comments.
- Remove some whitespaces in comments and error messages.
- Check if RTC is running before reading a timestamp in read_rtc.
- Stop RTC at the end of probe to wait for a timestamp to be set.
- Add default MFD_TPS6594 to Kconfig.

Pinctrl:
- Removed #define DEBUG.
- Add default MFD_TPS6594 to Kconfig.
- Fix typo and reword help message of Kconfig.

Regulators:
Further to Mark Brown review:
- File header whole block C++ style.
- Configuring modes not supported: omit all mode operations
- Log the error before notifying.
- Request the interrupts while registering the regulators (then remove the lookup function).
Further to Matti review:
- Postponed: devm_regulator_irq_helper() and regulator_irq_map_event_simple() can probably be used but code. refactoring is not so trivial. This can be done later as an enhancement after this patch list is merged.
Buck Multi phase management:
- Multiphase property can take an array when 2 multi phase buck, buck12 and buck34.
- Configuration multi phase buck34 without multiphase buck12 is not supported (when only one multiphase, must be buck12). Not clear from the spec but confirmed by TI.
- Supported multiphase conficurations: buck12, buck123, buck1234, buck12 + buck34.
- All interrupts are attached to the multiphase buck (ie: for regulator buck12, buck1 & buck2 interrupts are registered).

Changes since v2:
https://lore.kernel.org/all/[email protected]/
Rtc:
- Add logic to avoid reinitializing a working clock.
- Fix some multiline comments format.

Regulators:
Further to Mark Brown review:
- Log the error before notifying.
- Request the interrupts while registering the regulators. Further to Krzysztof Kozlowski:
https://lore.kernel.org/all/[email protected]/
- Remove ti, multi-phase-id property which is redundant with buck dts naming rules.

Esteban Blanc (2):
rtc: tps6594: add driver for TPS6594 PMIC RTC
pinctrl: tps6594: add for TPS6594 PMIC

Jerome Neanne (1):
regulator: tps6594-regulator: Add driver for TI TPS6594 regulators

 drivers/pinctrl/Kconfig               |  10 +
 drivers/pinctrl/Makefile              |   1 +
 drivers/pinctrl/pinctrl-tps6594.c     | 365 +++++++++++++++
 drivers/regulator/Kconfig             |  13 +
 drivers/regulator/Makefile            |   1 +
 drivers/regulator/tps6594-regulator.c | 620 ++++++++++++++++++++++++++
 drivers/rtc/Kconfig                   |   9 +
 drivers/rtc/Makefile                  |   1 +
 drivers/rtc/rtc-tps6594.c             | 473 ++++++++++++++++++++
 9 files changed, 1493 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-tps6594.c
 create mode 100644 drivers/regulator/tps6594-regulator.c
 create mode 100644 drivers/rtc/rtc-tps6594.c
Signature · 1 line
2.39.2
#1 lore raw

PATCH v3 1/3 rtc: tps6594: add driver for TPS6594 PMIC RTC

TPS6594 PMIC is a MFD driver. This adds support for the RTC found inside TPS6594 family of PMIC.

Alarm is also supported.

---
 drivers/rtc/Kconfig       |   9 +
 drivers/rtc/Makefile      |   1 +
 drivers/rtc/rtc-tps6594.c | 473 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 483 insertions(+)
 create mode 100644 drivers/rtc/rtc-tps6594.c
drivers/rtc/Kconfig +9 -0
index 5a71579af0a1..e5614a570d7e 100644
@@ -578,6 +578,15 @@ config RTC_DRV_TPS6586X
 	  along with alarm. This driver supports the RTC driver for
 	  the TPS6586X RTC module.
 
+config RTC_DRV_TPS6594
+	tristate "TI TPS6594 RTC driver"
+	depends on MFD_TPS6594
+	default MFD_TPS6594
+	help
+	  TI Power Management IC TPS6594 supports RTC functionality
+	  along with alarm. This driver supports the RTC driver for
+	  the TPS6594 RTC module.
+
 config RTC_DRV_TPS65910
 	tristate "TI TPS65910 RTC driver"
 	depends on MFD_TPS65910
drivers/rtc/Makefile +1 -0
index ea445d1ebb17..3d3f8c9d0697 100644
@@ -175,6 +175,7 @@ obj-$(CONFIG_RTC_DRV_TEGRA)	+= rtc-tegra.o
 obj-$(CONFIG_RTC_DRV_TEST)	+= rtc-test.o
 obj-$(CONFIG_RTC_DRV_TI_K3)	+= rtc-ti-k3.o
 obj-$(CONFIG_RTC_DRV_TPS6586X)	+= rtc-tps6586x.o
+obj-$(CONFIG_RTC_DRV_TPS6594)	+= rtc-tps6594.o
 obj-$(CONFIG_RTC_DRV_TPS65910)	+= rtc-tps65910.o
 obj-$(CONFIG_RTC_DRV_TWL4030)	+= rtc-twl.o
 obj-$(CONFIG_RTC_DRV_VT8500)	+= rtc-vt8500.o
drivers/rtc/rtc-tps6594.c new file +473 -0

473 lines not on this page · raw message

Signature · 1 line
2.39.2
#2 lore raw

PATCH v3 2/3 pinctrl: tps6594: add for TPS6594 PMIC

In reply to Esteban Blanc

TI TPS6594 PMIC has 11 GPIOs which can be used for different functions.

This add a pinctrl and pinmux drivers in order to use those functions.

---
 drivers/pinctrl/Kconfig           |  10 +
 drivers/pinctrl/Makefile          |   1 +
 drivers/pinctrl/pinctrl-tps6594.c | 365 ++++++++++++++++++++++++++++++
 3 files changed, 376 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-tps6594.c
drivers/pinctrl/Kconfig +10 -0
index dcb53c4a9584..2c1826e86a54 100644
@@ -499,6 +499,16 @@ config PINCTRL_THUNDERBAY
 	  rate control and direction control. This module will be
 	  called as pinctrl-thunderbay.
 
+config PINCTRL_TPS6594
+	tristate "Pinctrl and GPIO driver for TI TPS6594 PMIC"
+	depends on MFD_TPS6594
+	default MFD_TPS6594
+	select PINMUX
+	select GPIOLIB
+	help
+	  This driver supports GPIOs and pinmuxing for the TPS6594
+	  PMICs chip family.
+
 config PINCTRL_ZYNQ
 	bool "Pinctrl driver for Xilinx Zynq"
 	depends on ARCH_ZYNQ
drivers/pinctrl/Makefile +1 -0
index d5939840bb2a..ddaee9459da7 100644
@@ -49,6 +49,7 @@ obj-$(CONFIG_PINCTRL_STMFX) 	+= pinctrl-stmfx.o
 obj-$(CONFIG_PINCTRL_SX150X)	+= pinctrl-sx150x.o
 obj-$(CONFIG_PINCTRL_TB10X)	+= pinctrl-tb10x.o
 obj-$(CONFIG_PINCTRL_THUNDERBAY) += pinctrl-thunderbay.o
+obj-$(CONFIG_PINCTRL_TPS6594)	+= pinctrl-tps6594.o
 obj-$(CONFIG_PINCTRL_ZYNQMP)	+= pinctrl-zynqmp.o
 obj-$(CONFIG_PINCTRL_ZYNQ)	+= pinctrl-zynq.o
 
drivers/pinctrl/pinctrl-tps6594.c new file +365 -0

365 lines not on this page · raw message

Signature · 1 line
2.39.2
#3 lore raw

Re: [PATCH v3 2/3] pinctrl: tps6594: add for TPS6594 PMIC

Hi Esteban,

thanks for your patch!

Quoted 6 lines · Esteban Blanc

TI TPS6594 PMIC has 11 GPIOs which can be used for different functions.

This add a pinctrl and pinmux drivers in order to use those functions.

(...)

drivers/pinctrl/Kconfig config PINCTRL_THUNDERBAY · line 507

Quoted 6 lines
drivers/pinctrl/Kconfig +6 -0
+config PINCTRL_TPS6594
+       tristate "Pinctrl and GPIO driver for TI TPS6594 PMIC"
+       depends on MFD_TPS6594
+       default MFD_TPS6594
+       select PINMUX
+       select GPIOLIB

select GPIO_REGMAP
?

I think this driver can use the GPIO_REGMAP helper library.

Please look into other drivers using this, such as drivers/gpio/gpio-sl28cpld.c

Yours,
Linus Walleij

#4 lore raw

Re: [PATCH v3 2/3] pinctrl: tps6594: add for TPS6594 PMIC

Quoted 20 lines · Linus Walleij

Hi Esteban,

thanks for your patch!

Quoted 6 lines · Esteban Blanc

TI TPS6594 PMIC has 11 GPIOs which can be used for different functions.

This add a pinctrl and pinmux drivers in order to use those functions.

(...)

drivers/pinctrl/Kconfig config PINCTRL_THUNDERBAY · line 507

Quoted 6 lines
drivers/pinctrl/Kconfig +6 -0
+config PINCTRL_TPS6594
+       tristate "Pinctrl and GPIO driver for TI TPS6594 PMIC"
+       depends on MFD_TPS6594
+       default MFD_TPS6594
+       select PINMUX
+       select GPIOLIB
Quoted 7 lines

select GPIO_REGMAP
?

I think this driver can use the GPIO_REGMAP helper library.

Please look into other drivers using this, such as drivers/gpio/gpio-sl28cpld.c

I had a look at this driver and gpio-regmap.c. I think I understood what's going on, but I'm not sure how to handle the gpio_regmap_set_direction case. It is using the same reg_mask_xlate to determine the register and value to write as gpio_regmap_set or gpio_regmap_read. The problem is that this PMIC has 1 register per GPIO for the configuration (GPIOX_CONF registers with a bit for direction), while the in and out register are used for 8 pins (GPIO_OUT_1, GPIO_OUT_2 and GPIO_IN_1, GPIO_IN_2). This means that the register and mask returned by reg_mask_xlate will be erroneous in one or the other case.

I noticed that I could override reg_mask_xlate, so I should be able to "just" match on the base address given as argument to perform a different computation depending on whether we are using reg_mask_xlate in a "direction change" or not, but somehow this feels a bit wrong.

Is this the correct solution?
Am I missing something?

Thanks again for your time. Best regards,

Signature · 2 lines
Esteban Blanc
BayLibre
#5 lore raw

Re: [PATCH v3 2/3] pinctrl: tps6594: add for TPS6594 PMIC

Quoted 40 lines · Esteban Blanc
Quoted 20 lines · Linus Walleij

Hi Esteban,

thanks for your patch!

Quoted 6 lines · Esteban Blanc

TI TPS6594 PMIC has 11 GPIOs which can be used for different functions.

This add a pinctrl and pinmux drivers in order to use those functions.

(...)

drivers/pinctrl/Kconfig config PINCTRL_THUNDERBAY · line 507

Quoted 6 lines
drivers/pinctrl/Kconfig +6 -0
+config PINCTRL_TPS6594
+       tristate "Pinctrl and GPIO driver for TI TPS6594 PMIC"
+       depends on MFD_TPS6594
+       default MFD_TPS6594
+       select PINMUX
+       select GPIOLIB
Quoted 7 lines

select GPIO_REGMAP
?

I think this driver can use the GPIO_REGMAP helper library.

Please look into other drivers using this, such as drivers/gpio/gpio-sl28cpld.c

I had a look at this driver and gpio-regmap.c. I think I understood what's going on, but I'm not sure how to handle the gpio_regmap_set_direction case. It is using the same reg_mask_xlate to determine the register and value to write as gpio_regmap_set or gpio_regmap_read. The problem is that this PMIC has 1 register per GPIO for the configuration (GPIOX_CONF registers with a bit for direction), while the in and out register are used for 8 pins (GPIO_OUT_1, GPIO_OUT_2 and GPIO_IN_1, GPIO_IN_2). This means that the register and mask returned by reg_mask_xlate will be erroneous in one or the other case.

Quoted 7 lines

I noticed that I could override reg_mask_xlate, so I should be able to "just" match on the base address given as argument to perform a different computation depending on whether we are using reg_mask_xlate in a "direction change" or not, but somehow this feels a bit wrong.

Is this the correct solution?
Am I missing something?

This is a question for Michael Walle who wrote gpio-regmap, Michael, what do you say?

Yours,
Linus Walleij

#6 lore raw

Re: [PATCH v3 2/3] pinctrl: tps6594: add for TPS6594 PMIC

Hi,

Quoted 7 lines
Quoted 7 lines

I noticed that I could override reg_mask_xlate, so I should be able to "just" match on the base address given as argument to perform a different computation depending on whether we are using reg_mask_xlate in a "direction change" or not, but somehow this feels a bit wrong.

Is this the correct solution?
Am I missing something?

No you don't miss anything. This is the actual use case for the base parameter. If you need your own .xlate you can match on the base address to do the translation based on wether it is used for .direction, .set or .get.

I.e.

switch (base) {
case REG_IO_CTRL:
do_something_with_reg_and_mask;
case REG_DAT:
do_something_different_with_reg_and_mask;
default:
error;
}

-michael

#7 lore raw

Re: [PATCH v3 2/3] pinctrl: tps6594: add for TPS6594 PMIC

Quoted 18 lines · Michael Walle

Hi,

Quoted 8 lines
Quoted 8 lines

I noticed that I could override reg_mask_xlate, so I should be able to "just" match on the base address given as argument to perform a different computation depending on whether we are using reg_mask_xlate in
a "direction change" or not, but somehow this feels a bit wrong.

Is this the correct solution?
Am I missing something?

No you don't miss anything. This is the actual use case for the base parameter. If you need your own .xlate you can match on the base address to do the translation based on wether it is used for .direction, .set or .get.

I.e.

Quoted 8 lines

switch (base) {
case REG_IO_CTRL:

    do_something_with_reg_and_mask;
case REG_DAT:
    do_something_different_with_reg_and_mask;
default:
    error;
}

Ok perfect I will do that then!

Best regards,

Signature · 2 lines
Esteban Blanc
BayLibre
#8 lore raw

PATCH v3 3/3 regulator: tps6594-regulator: Add driver for TI TPS6594 regulators

In reply to Esteban Blanc

From: Jerome Neanne <[email protected]>

This patch adds support for TPS6594 regulators (bucks and LDOs). The output voltages are configurable and are meant to supply power to the main processor and other components.
Bucks can be used in single or multiphase mode, depending on PMIC part number.

---
 drivers/regulator/Kconfig             |  13 +
 drivers/regulator/Makefile            |   1 +
 drivers/regulator/tps6594-regulator.c | 620 ++++++++++++++++++++++++++
 3 files changed, 634 insertions(+)
 create mode 100644 drivers/regulator/tps6594-regulator.c
drivers/regulator/Kconfig +13 -0
index aae28d0a489c..5f01132b04e1 100644
@@ -1440,6 +1440,19 @@ config REGULATOR_TPS65219
 	  voltage regulators. It supports software based voltage control
 	  for different voltage domains.
 
+config REGULATOR_TPS6594
+	tristate "TI TPS6594 Power regulators"
+	depends on MFD_TPS6594 && OF
+	default MFD_TPS6594
+	help
+	  This driver supports TPS6594 voltage regulator chips.
+	  TPS6594 series of PMICs have 5 BUCKs and 4 LDOs
+	  voltage regulators.
+	  BUCKs 1,2,3,4 can be used in single phase or multiphase mode.
+	  Part number defines which single or multiphase mode is i used.
+	  It supports software based voltage control
+	  for different voltage domains.
+
 config REGULATOR_TPS6524X
 	tristate "TI TPS6524X Power regulators"
 	depends on SPI
drivers/regulator/Makefile +1 -0
index ee383d8fc835..cb420adf7670 100644
@@ -172,6 +172,7 @@ obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o
 obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o
 obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
 obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o
+obj-$(CONFIG_REGULATOR_TPS6594) += tps6594-regulator.o
 obj-$(CONFIG_REGULATOR_TPS65132) += tps65132-regulator.o
 obj-$(CONFIG_REGULATOR_TPS68470) += tps68470-regulator.o
 obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o twl6030-regulator.o
drivers/regulator/tps6594-regulator.c new file +620 -0

620 lines not on this page · raw message

Signature · 1 line
2.39.2