Add support for TI TPS65224 PMIC
Subsystems (7)
cover Add support for TI TPS65224 PMIC
This series modifies the existing TPS6594 drivers to add support for the TPS65224 PMIC device that is a derivative of TPS6594. TPS65224 has a similar register map to TPS6594 with a few differences. SPI, I2C, ESM, PFSM, Regulators and GPIO features overlap between the two devices.
TPS65224 is a Power Management IC (PMIC) which provides regulators and other features like GPIOs, Watchdog, Error Signal Monitor (ESM) and Pre-configurable Finite State Machine (PFSM). The SoC and the PMIC can communicate through the I2C or SPI interfaces. The PMIC TPS65224 additionally has a 12-bit ADC.
Data Sheet for TPS65224: https://www.ti.com/product/TPS65224-Q1
Driver re-use is applied following the advice of the following series:
https://lore.kernel.org/lkml/[email protected]/
The features implemented in this series are:
- TPS65224 Register definitions
- Core (MFD I2C and SPI entry points)
- PFSM
- ESM
- Regulators
- Pinctrl
TPS65224 Register definitions:
This patch adds macros for register field definitions of TPS65224 to the existing TPS6594 driver.
Core description:
I2C and SPI interface protocols are implemented, with and without the bit-integrity error detection feature (CRC mode).
PFSM description:
Strictly speaking, PFSM is not hardware. It is a piece of code. PMIC integrates a state machine which manages operational modes. Depending on the current operational mode, some voltage domains remain energized while others can be off.
PFSM driver can be used to trigger transitions between configured states.
ESM description:
This device monitors the SoC error output signal at its nERR_MCU input pin. On error detection, ESM driver toggles the PMIC nRSTOUT pin to reset the SoC.
Regulators description:
4 BUCKs and 3 LDOs.
BUCK12 can be used in dual-phase mode.
Pinctrl description:
TPS65224 family has 6 GPIOs. Those GPIOs can also serve different functions such as I2C or SPI interface or watchdog disable functions. The driver provides both pinmuxing for the functions and GPIO capability.
This series was tested on linux-next tag: next-20240118
Test logs can be found here:
https://gist.github.com/LeonardMH/58ec135921fb1062ffd4a8b384831eb0
Bhargav Raviprakash (10):
mfd: tps6594: use volatile_table instead of volatile_reg
dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
mfd: tps6594-i2c: Add TI TPS65224 PMIC I2C
mfd: tps6594-spi: Add TI TPS65224 PMIC SPI
mfd: tps6594-core: Add TI TPS65224 PMIC core
misc: tps6594-pfsm: Add TI TPS65224 PMIC PFSM
misc: tps6594-esm: reversion check limited to TPS6594 family
misc: tps6594-esm: use regmap_field
misc: tps6594-esm: Add TI TPS65224 PMIC ESM
arch: arm64: dts: ti: k3-am62p5-sk: Add TPS65224 PMIC support in AM62P
dts
Nirmala Devi Mal Nadar (3):
mfd: tps6594: Add register definitions for TI TPS65224 PMIC
regulator: tps6594-regulator: Add TI TPS65224 PMIC regulators
pinctrl: pinctrl-tps6594: Add TPS65224 PMIC pinctrl and GPIO
.../devicetree/bindings/mfd/ti,tps6594.yaml | 1 + arch/arm64/boot/dts/ti/k3-am62p5-sk.dts | 95 +++++ drivers/mfd/tps6594-core.c | 258 ++++++++++++- drivers/mfd/tps6594-i2c.c | 20 +- drivers/mfd/tps6594-spi.c | 18 +- drivers/misc/tps6594-esm.c | 89 +++-- drivers/misc/tps6594-pfsm.c | 55 ++- drivers/pinctrl/pinctrl-tps6594.c | 287 ++++++++++++-- drivers/regulator/Kconfig | 4 +- drivers/regulator/tps6594-regulator.c | 244 ++++++++++-- include/linux/mfd/tps6594.h | 358 +++++++++++++++++- 11 files changed, 1272 insertions(+), 157 deletions(-)
base-commit: 2863b714f3ad0a9686f2de1b779228ad8c7a8052
Signature · 1 line
2.25.1
PATCH RESEND 1/13 mfd: tps6594: Add register definitions for TI TPS65224 PMIC
From: Nirmala Devi Mal Nadar <[email protected]>
Extend TPS6594 PMIC register and field definitions to support TPS65224 power management IC.
TPS65224 is software compatible to TPS6594 and can re-use many of the same definitions, new definitions are added to support additional controls available on TPS65224.
--- include/linux/mfd/tps6594.h | 354 ++++++++++++++++++++++++++++++++++-- 1 file changed, 342 insertions(+), 12 deletions(-)
include/linux/mfd/tps6594.h +342 -12
@@ -18,12 +18,13 @@ enum pmic_id {TPS6594 ,TPS6593 ,LP8764 , + TPS65224, };/* Macro to get page index from register address */ #define TPS6594_REG_TO_PAGE (reg) ((reg) >> 8) -/* Registers for page 0 of TPS6594 */ +/* Registers for page 0 */ #define TPS6594_REG_DEV_REV 0x01#define TPS6594_REG_NVM_CODE_1 0x02
@@ -56,9 +57,6 @@ enum pmic_id {#define TPS6594_REG_GPIOX_OUT (gpio_inst) (TPS6594_REG_GPIO_OUT_1 + (gpio_inst) / 8)#define TPS6594_REG_GPIOX_IN (gpio_inst) (TPS6594_REG_GPIO_IN_1 + (gpio_inst) / 8) -#define TPS6594_REG_GPIO_IN_1 0x3f -#define TPS6594_REG_GPIO_IN_2 0x40 -#define TPS6594_REG_RAIL_SEL_1 0x41#define TPS6594_REG_RAIL_SEL_2 0x42#define TPS6594_REG_RAIL_SEL_3 0x43
@@ -70,13 +68,15 @@ enum pmic_id {#define TPS6594_REG_FSM_TRIG_MASK_3 0x48#define TPS6594_REG_MASK_BUCK1_2 0x49 +#define TPS65224_REG_MASK_BUCKS 0x49#define TPS6594_REG_MASK_BUCK3_4 0x4a#define TPS6594_REG_MASK_BUCK5 0x4b#define TPS6594_REG_MASK_LDO1_2 0x4c +#define TPS65224_REG_MASK_LDOS 0x4c#define TPS6594_REG_MASK_LDO3_4 0x4d#define TPS6594_REG_MASK_VMON 0x4e -#define TPS6594_REG_MASK_GPIO1_8_FALL 0x4f -#define TPS6594_REG_MASK_GPIO1_8_RISE 0x50 +#define TPS6594_REG_MASK_GPIO_FALL 0x4f +#define TPS6594_REG_MASK_GPIO_RISE 0x50#define TPS6594_REG_MASK_GPIO9_11 0x51#define TPS6594_REG_MASK_STARTUP 0x52#define TPS6594_REG_MASK_MISC 0x53
@@ -174,6 +174,10 @@ enum pmic_id {#define TPS6594_REG_REGISTER_LOCK 0xa1 +#define TPS65224_REG_SRAM_ACCESS_1 0xa2 +#define TPS65224_REG_SRAM_ACCESS_2 0xa3 +#define TPS65224_REG_SRAM_ADDR_CTRL 0xa4 +#define TPS65224_REG_RECOV_CNT_PFSM_INCR 0xa5#define TPS6594_REG_MANUFACTURING_VER 0xa6#define TPS6594_REG_CUSTOMER_NVM_ID_REG 0xa7
@@ -182,6 +186,9 @@ enum pmic_id {#define TPS6594_REG_SOFT_REBOOT_REG 0xab +#define TPS65224_REG_ADC_CTRL 0xac +#define TPS65224_REG_ADC_RESULT_REG_1 0xad +#define TPS65224_REG_ADC_RESULT_REG_2 0xae#define TPS6594_REG_RTC_SECONDS 0xb5#define TPS6594_REG_RTC_MINUTES 0xb6#define TPS6594_REG_RTC_HOURS 0xb7
@@ -199,6 +206,7 @@ enum pmic_id {#define TPS6594_REG_RTC_CTRL_1 0xc2#define TPS6594_REG_RTC_CTRL_2 0xc3 +#define TPS65224_REG_STARTUP_CTRL 0xc3#define TPS6594_REG_RTC_STATUS 0xc4#define TPS6594_REG_RTC_INTERRUPTS 0xc5#define TPS6594_REG_RTC_COMP_LSB 0xc6
@@ -214,13 +222,17 @@ enum pmic_id {#define TPS6594_REG_PFSM_DELAY_REG_2 0xce#define TPS6594_REG_PFSM_DELAY_REG_3 0xcf#define TPS6594_REG_PFSM_DELAY_REG_4 0xd0 +#define TPS65224_REG_ADC_GAIN_COMP_REG 0xd0 +#define TPS65224_REG_CRC_CALC_CONTROL 0xef +#define TPS65224_REG_REGMAP_USER_CRC_LOW 0xf0 +#define TPS65224_REG_REGMAP_USER_CRC_HIGH 0xf1 -/* Registers for page 1 of TPS6594 */ +/* Registers for page 1 */ #define TPS6594_REG_SERIAL_IF_CONFIG 0x11a#define TPS6594_REG_I2C1_ID 0x122#define TPS6594_REG_I2C2_ID 0x123 -/* Registers for page 4 of TPS6594 */ +/* Registers for page 4 */ #define TPS6594_REG_WD_ANSWER_REG 0x401#define TPS6594_REG_WD_QUESTION_ANSW_CNT 0x402#define TPS6594_REG_WD_WIN1_CFG 0x403
@@ -241,16 +253,26 @@ enum pmic_id {#define TPS6594_BIT_BUCK_PLDN BIT(5)#define TPS6594_BIT_BUCK_RV_SEL BIT(7) -/* BUCKX_CONF register field definition */ +/* TPS6594 BUCKX_CONF register field definition */ #define TPS6594_MASK_BUCK_SLEW_RATE GENMASK(2, 0)#define TPS6594_MASK_BUCK_ILIM GENMASK(5, 3) -/* BUCKX_PG_WINDOW register field definition */ +/* TPS65224 BUCKX_CONF register field definition */ +#define TPS65224_MASK_BUCK_SLEW_RATE GENMASK(1, 0) + +/* TPS6594 BUCKX_PG_WINDOW register field definition */ #define TPS6594_MASK_BUCK_OV_THR GENMASK(2, 0)#define TPS6594_MASK_BUCK_UV_THR GENMASK(5, 3) -/* BUCKX VSET */ -#define TPS6594_MASK_BUCKS_VSET GENMASK(7, 0) +/* TPS65224 BUCKX_PG_WINDOW register field definition */ +#define TPS65224_MASK_BUCK_VMON_THR GENMASK(1, 0) + +/* TPS6594 BUCKX_VOUT register field definition */ +#define TPS6594_MASK_BUCKS_VSET GENMASK(7, 0) + +/* TPS65224 BUCKX_VOUT register field definition */ +#define TPS65224_MASK_BUCK1_VSET GENMASK(7, 0) +#define TPS65224_MASK_BUCKS_VSET GENMASK(6, 0)/* LDOX_CTRL register field definition */ #define TPS6594_BIT_LDO_EN BIT(0)
@@ -258,6 +280,7 @@ enum pmic_id {#define TPS6594_BIT_LDO_VMON_EN BIT(4)#define TPS6594_MASK_LDO_PLDN GENMASK(6, 5)#define TPS6594_BIT_LDO_RV_SEL BIT(7) +#define TPS65224_BIT_LDO_DISCHARGE_EN BIT(5)/* LDORTC_CTRL register field definition */ #define TPS6594_BIT_LDORTC_DIS BIT(0)
@@ -271,6 +294,9 @@ enum pmic_id {#define TPS6594_MASK_LDO_OV_THR GENMASK(2, 0)#define TPS6594_MASK_LDO_UV_THR GENMASK(5, 3) +/* LDOX_PG_WINDOW register field definition */ +#define TPS65224_MASK_LDO_VMON_THR GENMASK(1, 0) +/* VCCA_VMON_CTRL register field definition */ #define TPS6594_BIT_VMON_EN BIT(0)#define TPS6594_BIT_VMON1_EN BIT(1)
@@ -278,10 +304,12 @@ enum pmic_id {#define TPS6594_BIT_VMON2_EN BIT(3)#define TPS6594_BIT_VMON2_RV_SEL BIT(4)#define TPS6594_BIT_VMON_DEGLITCH_SEL BIT(5) +#define TPS65224_BIT_VMON_DEGLITCH_SEL GENMASK(7, 5)/* VCCA_PG_WINDOW register field definition */ #define TPS6594_MASK_VCCA_OV_THR GENMASK(2, 0)#define TPS6594_MASK_VCCA_UV_THR GENMASK(5, 3) +#define TPS65224_MASK_VCCA_VMON_THR GENMASK(1, 0)#define TPS6594_BIT_VCCA_PG_SET BIT(6)/* VMONX_PG_WINDOW register field definition */
@@ -289,6 +317,9 @@ enum pmic_id {#define TPS6594_MASK_VMONX_UV_THR GENMASK(5, 3)#define TPS6594_BIT_VMONX_RANGE BIT(6) +/* VMONX_PG_WINDOW register field definition */ +#define TPS65224_MASK_VMONX_THR GENMASK(1, 0) +/* GPIOX_CONF register field definition */ #define TPS6594_BIT_GPIO_DIR BIT(0)#define TPS6594_BIT_GPIO_OD BIT(1)
@@ -296,6 +327,8 @@ enum pmic_id {#define TPS6594_BIT_GPIO_PU_PD_EN BIT(3)#define TPS6594_BIT_GPIO_DEGLITCH_EN BIT(4)#define TPS6594_MASK_GPIO_SEL GENMASK(7, 5) +#define TPS65224_MASK_GPIO_SEL GENMASK(6, 5) +#define TPS65224_MASK_GPIO_SEL_GPIO6 GENMASK(7, 5)/* NPWRON_CONF register field definition */ #define TPS6594_BIT_NRSTOUT_OD BIT(0)
@@ -305,6 +338,12 @@ enum pmic_id {#define TPS6594_BIT_ENABLE_POL BIT(5)#define TPS6594_MASK_NPWRON_SEL GENMASK(7, 6) +/* POWER_ON_CONFIG register field definition */ +#define TPS65224_BIT_NINT_ENDRV_PU_SEL BIT(0) +#define TPS65224_BIT_NINT_ENDRV_SEL BIT(1) +#define TPS65224_BIT_EN_PB_DEGL BIT(5) +#define TPS65224_MASK_EN_PB_VSENSE_CONFIG GENMASK(7, 6) +/* GPIO_OUT_X register field definition */ #define TPS6594_BIT_GPIOX_OUT (gpio_inst) BIT((gpio_inst) % 8)
@@ -312,6 +351,12 @@ enum pmic_id {#define TPS6594_BIT_GPIOX_IN (gpio_inst) BIT((gpio_inst) % 8)#define TPS6594_BIT_NPWRON_IN BIT(3) +/* GPIO_OUT_X register field definition */ +#define TPS65224_BIT_GPIOX_OUT (gpio_inst) BIT((gpio_inst)) + +/* GPIO_IN_X register field definition */ +#define TPS65224_BIT_GPIOX_IN (gpio_inst) BIT((gpio_inst)) +/* RAIL_SEL_1 register field definition */ #define TPS6594_MASK_BUCK1_GRP_SEL GENMASK(1, 0)#define TPS6594_MASK_BUCK2_GRP_SEL GENMASK(3, 2)
@@ -343,6 +388,9 @@ enum pmic_id {#define TPS6594_BIT_GPIOX_FSM_MASK (gpio_inst) BIT(((gpio_inst) << 1) % 8)#define TPS6594_BIT_GPIOX_FSM_MASK_POL (gpio_inst) BIT(((gpio_inst) << 1) % 8 + 1) +#define TPS65224_BIT_GPIOX_FSM_MASK (gpio_inst) BIT(((gpio_inst) << 1) % 6) +#define TPS65224_BIT_GPIOX_FSM_MASK_POL (gpio_inst) BIT(((gpio_inst) << 1) % 6 + 1) +/* MASK_BUCKX register field definition */ #define TPS6594_BIT_BUCKX_OV_MASK (buck_inst) BIT(((buck_inst) << 2) % 8)#define TPS6594_BIT_BUCKX_UV_MASK (buck_inst) BIT(((buck_inst) << 2) % 8 + 1)
@@ -361,22 +409,46 @@ enum pmic_id {#define TPS6594_BIT_VMON2_OV_MASK BIT(5)#define TPS6594_BIT_VMON2_UV_MASK BIT(6) +/* MASK_BUCK Register field definition */ +#define TPS65224_BIT_BUCK1_UVOV_MASK BIT(0) +#define TPS65224_BIT_BUCK2_UVOV_MASK BIT(1) +#define TPS65224_BIT_BUCK3_UVOV_MASK BIT(2) +#define TPS65224_BIT_BUCK4_UVOV_MASK BIT(4) + +/* MASK_LDO_VMON register field definition */ +#define TPS65224_BIT_LDO1_UVOV_MASK BIT(0) +#define TPS65224_BIT_LDO2_UVOV_MASK BIT(1) +#define TPS65224_BIT_LDO3_UVOV_MASK BIT(2) +#define TPS65224_BIT_VCCA_UVOV_MASK BIT(4) +#define TPS65224_BIT_VMON1_UVOV_MASK BIT(5) +#define TPS65224_BIT_VMON2_UVOV_MASK BIT(6) +/* MASK_GPIOX register field definition */ #define TPS6594_BIT_GPIOX_FALL_MASK (gpio_inst) BIT((gpio_inst) < 8 ? \ (gpio_inst) : (gpio_inst) % 8)#define TPS6594_BIT_GPIOX_RISE_MASK (gpio_inst) BIT((gpio_inst) < 8 ? \ (gpio_inst) : (gpio_inst) % 8 + 3) +/* MASK_GPIOX register field definition */ +#define TPS65224_BIT_GPIOX_FALL_MASK (gpio_inst) BIT((gpio_inst)) +#define TPS65224_BIT_GPIOX_RISE_MASK (gpio_inst) BIT((gpio_inst))/* MASK_STARTUP register field definition */ #define TPS6594_BIT_NPWRON_START_MASK BIT(0)#define TPS6594_BIT_ENABLE_MASK BIT(1)#define TPS6594_BIT_FSD_MASK BIT(4)#define TPS6594_BIT_SOFT_REBOOT_MASK BIT(5) +#define TPS65224_BIT_VSENSE_MASK BIT(0) +#define TPS65224_BIT_PB_SHORT_MASK BIT(2)/* MASK_MISC register field definition */ #define TPS6594_BIT_BIST_PASS_MASK BIT(0)#define TPS6594_BIT_EXT_CLK_MASK BIT(1) +#define TPS65224_BIT_REG_UNLOCK_MASK BIT(2)#define TPS6594_BIT_TWARN_MASK BIT(3) +#define TPS65224_BIT_PB_LONG_MASK BIT(4) +#define TPS65224_BIT_PB_FALL_MASK BIT(5) +#define TPS65224_BIT_PB_RISE_MASK BIT(6) +#define TPS65224_BIT_ADC_CONV_READY_MASK BIT(7)/* MASK_MODERATE_ERR register field definition */ #define TPS6594_BIT_BIST_FAIL_MASK BIT(1)
@@ -391,6 +463,8 @@ enum pmic_id {#define TPS6594_BIT_ORD_SHUTDOWN_MASK BIT(1)#define TPS6594_BIT_MCU_PWR_ERR_MASK BIT(2)#define TPS6594_BIT_SOC_PWR_ERR_MASK BIT(3) +#define TPS65224_BIT_COMM_ERR_MASK BIT(4) +#define TPS65224_BIT_I2C2_ERR_MASK BIT(5)/* MASK_COMM_ERR register field definition */ #define TPS6594_BIT_COMM_FRM_ERR_MASK BIT(0)
@@ -426,6 +500,12 @@ enum pmic_id {#define TPS6594_BIT_BUCK3_4_INT BIT(1)#define TPS6594_BIT_BUCK5_INT BIT(2) +/* INT_BUCK register field definition */ +#define TPS65224_BIT_BUCK1_UVOV_INT BIT(0) +#define TPS65224_BIT_BUCK2_UVOV_INT BIT(1) +#define TPS65224_BIT_BUCK3_UVOV_INT BIT(2) +#define TPS65224_BIT_BUCK4_UVOV_INT BIT(3) +/* INT_BUCKX register field definition */ #define TPS6594_BIT_BUCKX_OV_INT (buck_inst) BIT(((buck_inst) << 2) % 8)#define TPS6594_BIT_BUCKX_UV_INT (buck_inst) BIT(((buck_inst) << 2) % 8 + 1)
@@ -437,6 +517,14 @@ enum pmic_id {#define TPS6594_BIT_LDO3_4_INT BIT(1)#define TPS6594_BIT_VCCA_INT BIT(4) +/* INT_LDO_VMON register field definition */ +#define TPS65224_BIT_LDO1_UVOV_INT BIT(0) +#define TPS65224_BIT_LDO2_UVOV_INT BIT(1) +#define TPS65224_BIT_LDO3_UVOV_INT BIT(2) +#define TPS65224_BIT_VCCA_UVOV_INT BIT(4) +#define TPS65224_BIT_VMON1_UVOV_INT BIT(5) +#define TPS65224_BIT_VMON2_UVOV_INT BIT(6) +/* INT_LDOX register field definition */ #define TPS6594_BIT_LDOX_OV_INT (ldo_inst) BIT(((ldo_inst) << 2) % 8)#define TPS6594_BIT_LDOX_UV_INT (ldo_inst) BIT(((ldo_inst) << 2) % 8 + 1)
@@ -462,17 +550,32 @@ enum pmic_id {/* INT_GPIOX register field definition */ #define TPS6594_BIT_GPIOX_INT (gpio_inst) BIT(gpio_inst) +/* INT_GPIO register field definition */ +#define TPS65224_BIT_GPIO1_INT BIT(0) +#define TPS65224_BIT_GPIO2_INT BIT(1) +#define TPS65224_BIT_GPIO3_INT BIT(2) +#define TPS65224_BIT_GPIO4_INT BIT(3) +#define TPS65224_BIT_GPIO5_INT BIT(4) +#define TPS65224_BIT_GPIO6_INT BIT(5) +/* INT_STARTUP register field definition */ #define TPS6594_BIT_NPWRON_START_INT BIT(0) +#define TPS65224_BIT_VSENSE_INT BIT(0)#define TPS6594_BIT_ENABLE_INT BIT(1)#define TPS6594_BIT_RTC_INT BIT(2) +#define TPS65224_BIT_PB_SHORT_INT BIT(2)#define TPS6594_BIT_FSD_INT BIT(4)#define TPS6594_BIT_SOFT_REBOOT_INT BIT(5)/* INT_MISC register field definition */ #define TPS6594_BIT_BIST_PASS_INT BIT(0)#define TPS6594_BIT_EXT_CLK_INT BIT(1) +#define TPS65224_BIT_REG_UNLOCK_INT BIT(2)#define TPS6594_BIT_TWARN_INT BIT(3) +#define TPS65224_BIT_PB_LONG_INT BIT(4) +#define TPS65224_BIT_PB_FALL_INT BIT(5) +#define TPS65224_BIT_PB_RISE_INT BIT(6) +#define TPS65224_BIT_ADC_CONV_READY_INT BIT(7)/* INT_MODERATE_ERR register field definition */ #define TPS6594_BIT_TSD_ORD_INT BIT(0)
@@ -488,6 +591,7 @@ enum pmic_id {#define TPS6594_BIT_TSD_IMM_INT BIT(0)#define TPS6594_BIT_VCCA_OVP_INT BIT(1)#define TPS6594_BIT_PFSM_ERR_INT BIT(2) +#define TPS65224_BIT_BG_XMON_INT BIT(3)/* INT_FSM_ERR register field definition */ #define TPS6594_BIT_IMM_SHUTDOWN_INT BIT(0)
@@ -496,6 +600,7 @@ enum pmic_id {#define TPS6594_BIT_SOC_PWR_ERR_INT BIT(3)#define TPS6594_BIT_COMM_ERR_INT BIT(4)#define TPS6594_BIT_READBACK_ERR_INT BIT(5) +#define TPS65224_BIT_I2C2_ERR_INT BIT(5)#define TPS6594_BIT_ESM_INT BIT(6)#define TPS6594_BIT_WD_INT BIT(7)
@@ -536,8 +641,18 @@ enum pmic_id {#define TPS6594_BIT_VMON2_OV_STAT BIT(5)#define TPS6594_BIT_VMON2_UV_STAT BIT(6) +/* STAT_LDO_VMON register field definition */ +#define TPS65224_BIT_LDO1_UVOV_STAT BIT(0) +#define TPS65224_BIT_LDO2_UVOV_STAT BIT(1) +#define TPS65224_BIT_LDO3_UVOV_STAT BIT(2) +#define TPS65224_BIT_VCCA_UVOV_STAT BIT(4) +#define TPS65224_BIT_VMON1_UVOV_STAT BIT(5) +#define TPS65224_BIT_VMON2_UVOV_STAT BIT(6) +/* STAT_STARTUP register field definition */ +#define TPS65224_BIT_VSENSE_STAT BIT(0)#define TPS6594_BIT_ENABLE_STAT BIT(1) +#define TPS65224_BIT_PB_LEVEL_STAT BIT(2)/* STAT_MISC register field definition */ #define TPS6594_BIT_EXT_CLK_STAT BIT(1)
@@ -549,6 +664,7 @@ enum pmic_id {/* STAT_SEVERE_ERR register field definition */ #define TPS6594_BIT_TSD_IMM_STAT BIT(0)#define TPS6594_BIT_VCCA_OVP_STAT BIT(1) +#define TPS65224_BIT_BG_XMON_STAT BIT(3)/* STAT_READBACK_ERR register field definition */ #define TPS6594_BIT_EN_DRV_READBACK_STAT BIT(0)
@@ -597,6 +713,8 @@ enum pmic_id {#define TPS6594_BIT_BB_CHARGER_EN BIT(0)#define TPS6594_BIT_BB_ICHR BIT(1)#define TPS6594_MASK_BB_VEOC GENMASK(3, 2) +#define TPS65224_BIT_I2C1_SPI_CRC_EN BIT(4) +#define TPS65224_BIT_I2C2_CRC_EN BIT(5)#define TPS6594_BB_EOC_RDY BIT(7)/* ENABLE_DRV_REG register field definition */
@@ -617,6 +735,7 @@ enum pmic_id {#define TPS6594_BIT_NRSTOUT_SOC_IN BIT(2)#define TPS6594_BIT_FORCE_EN_DRV_LOW BIT(3)#define TPS6594_BIT_SPMI_LPM_EN BIT(4) +#define TPS65224_BIT_TSD_DISABLE BIT(5)/* RECOV_CNT_REG_1 register field definition */ #define TPS6594_MASK_RECOV_CNT GENMASK(3, 0)
@@ -671,15 +790,27 @@ enum pmic_id {/* ESM_SOC_START_REG register field definition */ #define TPS6594_BIT_ESM_SOC_START BIT(0) +/* ESM_MCU_START_REG register field definition */ +#define TPS65224_BIT_ESM_MCU_START BIT(0) +/* ESM_SOC_MODE_CFG register field definition */ #define TPS6594_MASK_ESM_SOC_ERR_CNT_TH GENMASK(3, 0)#define TPS6594_BIT_ESM_SOC_ENDRV BIT(5)#define TPS6594_BIT_ESM_SOC_EN BIT(6)#define TPS6594_BIT_ESM_SOC_MODE BIT(7) +/* ESM_MCU_MODE_CFG register field definition */ +#define TPS65224_MASK_ESM_MCU_ERR_CNT_TH GENMASK(3, 0) +#define TPS65224_BIT_ESM_MCU_ENDRV BIT(5) +#define TPS65224_BIT_ESM_MCU_EN BIT(6) +#define TPS65224_BIT_ESM_MCU_MODE BIT(7) +/* ESM_SOC_ERR_CNT_REG register field definition */ #define TPS6594_MASK_ESM_SOC_ERR_CNT GENMASK(4, 0) +/* ESM_MCU_ERR_CNT_REG register field definition */ +#define TPS6594_MASK_ESM_MCU_ERR_CNT GENMASK(4, 0) +/* REGISTER_LOCK register field definition */ #define TPS6594_BIT_REGISTER_LOCK_STATUS BIT(0)
@@ -687,6 +818,29 @@ enum pmic_id {#define TPS6594_MASK_VMON1_SLEW_RATE GENMASK(2, 0)#define TPS6594_MASK_VMON2_SLEW_RATE GENMASK(5, 3) +/* SRAM_ACCESS_1 Register field definition */ +#define TPS65224_MASk_SRAM_UNLOCK_SEQ GENMASK(7, 0) + +/* SRAM_ACCESS_2 Register field definition */ +#define TPS65224_BIT_SRAM_WRITE_MODE BIT(0) +#define TPS65224_BIT_OTP_PROG_USER BIT(1) +#define TPS65224_BIT_OTP_PROG_PFSM BIT(2) +#define TPS65224_BIT_OTP_PROG_STATUS BIT(3) +#define TPS65224_BIT_SRAM_UNLOCKED BIT(6) +#define TPS65224_USER_PROG_ALLOWED BIT(7) + +/* SRAM_ADDR_CTRL Register field definition */ +#define TPS65224_MASk_SRAM_SEL GENMASK(1, 0) + +/* RECOV_CNT_PFSM_INCR Register field definition */ +#define TPS65224_BIT_INCREMENT_RECOV_CNT BIT(0) + +/* MANUFACTURING_VER Register field definition */ +#define TPS65224_MASK_SILICON_REV GENMASK(7, 0) + +/* CUSTOMER_NVM_ID_REG Register field definition */ +#define TPS65224_MASK_CUSTOMER_NVM_ID GENMASK(7, 0) +/* SOFT_REBOOT_REG register field definition */ #define TPS6594_BIT_SOFT_REBOOT BIT(0)
@@ -755,14 +909,83 @@ enum pmic_id {#define TPS6594_BIT_I2C2_CRC_EN BIT(2)#define TPS6594_MASK_T_CRC GENMASK(7, 3) +/* ADC_CTRL Register field definition */ +#define TPS65224_BIT_ADC_START BIT(0) +#define TPS65224_BIT_ADC_CONT_CONV BIT(1) +#define TPS65224_BIT_ADC_THERMAL_SEL BIT(2) +#define TPS65224_BIT_ADC_RDIV_EN BIT(3) +#define TPS65224_BIT_ADC_STATUS BIT(7) + +/* ADC_RESULT_REG_1 Register field definition */ +#define TPS65224_MASK_ADC_RESULT_11_4 GENMASK(7, 0) + +/* ADC_RESULT_REG_2 Register field definition */ +#define TPS65224_MASK_ADC_RESULT_3_0 GENMASK(7, 4) + +/* STARTUP_CTRL Register field definition */ +#define TPS65224_MASK_STARTUP_DEST GENMASK(6, 5) +#define TPS65224_BIT_FIRST_STARTUP_DONE BIT(7) + +/* SCRATCH_PAD_REG_1 Register field definition */ +#define TPS6594_MASK_SCRATCH_PAD_1 GENMASK(7, 0) + +/* SCRATCH_PAD_REG_2 Register field definition */ +#define TPS6594_MASK_SCRATCH_PAD_2 GENMASK(7, 0) + +/* SCRATCH_PAD_REG_3 Register field definition */ +#define TPS6594_MASK_SCRATCH_PAD_3 GENMASK(7, 0) + +/* SCRATCH_PAD_REG_4 Register field definition */ +#define TPS6594_MASK_SCRATCH_PAD_4 GENMASK(7, 0) + +/* PFSM_DELAY_REG_1 Register field definition */ +#define TPS6594_MASK_PFSM_DELAY1 GENMASK(7, 0) + +/* PFSM_DELAY_REG_2 Register field definition */ +#define TPS6594_MASK_PFSM_DELAY2 GENMASK(7, 0) + +/* PFSM_DELAY_REG_3 Register field definition */ +#define TPS6594_MASK_PFSM_DELAY3 GENMASK(7, 0) + +/* PFSM_DELAY_REG_4 Register field definition */ +#define TPS6594_MASK_PFSM_DELAY4 GENMASK(7, 0) + +/* CRC_CALC_CONTROL Register field definition */ +#define TPS65224_BIT_RUN_CRC_BIST BIT(0) +#define TPS65224_BIT_RUN_CRC_UPDATE BIT(1) + +/* ADC_GAIN_COMP_REG Register field definition */ +#define TPS65224_MASK_ADC_GAIN_COMP GENMASK(7, 0) + +/* REGMAP_USER_CRC_LOW Register field definition */ +#define TPS65224_MASK_REGMAP_USER_CRC16_LOW GENMASK(7, 0) + +/* REGMAP_USER_CRC_HIGH Register field definition */ +#define TPS65224_MASK_REGMAP_USER_CRC16_HIGH GENMASK(7, 0) + +/* WD_ANSWER_REG Register field definition */ +#define TPS6594_MASK_WD_ANSWER GENMASK(7, 0) +/* WD_QUESTION_ANSW_CNT register field definition */ #define TPS6594_MASK_WD_QUESTION GENMASK(3, 0)#define TPS6594_MASK_WD_ANSW_CNT GENMASK(5, 4) +#define TPS65224_BIT_INT_TOP_STATUS BIT(7) + +/* WD WIN1_CFG register field definition */ +#define TPS6594_MASK_WD_WIN1_CFG GENMASK(6, 0) + +/* WD WIN2_CFG register field definition */ +#define TPS6594_MASK_WD_WIN2_CFG GENMASK(6, 0) + +/* WD LongWin register field definition */ +#define TPS6594_MASK_WD_LONGWIN_CFG GENMASK(7, 0)/* WD_MODE_REG register field definition */ #define TPS6594_BIT_WD_RETURN_LONGWIN BIT(0)#define TPS6594_BIT_WD_MODE_SELECT BIT(1)#define TPS6594_BIT_WD_PWRHOLD BIT(2) +#define TPS65224_BIT_WD_ENDRV_SEL BIT(6) +#define TPS65224_BIT_WD_CNT_SEL BIT(7)/* WD_QA_CFG register field definition */ #define TPS6594_MASK_WD_QUESTION_SEED GENMASK(3, 0)
@@ -993,6 +1216,113 @@ enum tps6594_irqs {#define TPS6594_IRQ_NAME_ALARM "alarm"#define TPS6594_IRQ_NAME_POWERUP "powerup" +/* IRQs */ +enum tps65224_irqs { +/* INT_BUCK register */ +TPS65224_IRQ_BUCK1_UVOV , +TPS65224_IRQ_BUCK2_UVOV , +TPS65224_IRQ_BUCK3_UVOV , +TPS65224_IRQ_BUCK4_UVOV , +/* INT_LDO_VMON register */ +TPS65224_IRQ_LDO1_UVOV , +TPS65224_IRQ_LDO2_UVOV , +TPS65224_IRQ_LDO3_UVOV , +TPS65224_IRQ_VCCA_UVOV , +TPS65224_IRQ_VMON1_UVOV , +TPS65224_IRQ_VMON2_UVOV , +/* INT_GPIO register */ +TPS65224_IRQ_GPIO1 , +TPS65224_IRQ_GPIO2 , +TPS65224_IRQ_GPIO3 , +TPS65224_IRQ_GPIO4 , +TPS65224_IRQ_GPIO5 , +TPS65224_IRQ_GPIO6 , +/* INT_STARTUP register */ +TPS65224_IRQ_VSENSE , +TPS65224_IRQ_ENABLE , +TPS65224_IRQ_PB_SHORT , +TPS65224_IRQ_FSD , +TPS65224_IRQ_SOFT_REBOOT , +/* INT_MISC register */ +TPS65224_IRQ_BIST_PASS , +TPS65224_IRQ_EXT_CLK , +TPS65224_IRQ_REG_UNLOCK , +TPS65224_IRQ_TWARN , +TPS65224_IRQ_PB_LONG , +TPS65224_IRQ_PB_FALL , +TPS65224_IRQ_PB_RISE , +TPS65224_IRQ_ADC_CONV_READY , +/* INT_MODERATE_ERR register */ +TPS65224_IRQ_TSD_ORD , +TPS65224_IRQ_BIST_FAIL , +TPS65224_IRQ_REG_CRC_ERR , +TPS65224_IRQ_RECOV_CNT , +/* INT_SEVERE_ERR register */ +TPS65224_IRQ_TSD_IMM , +TPS65224_IRQ_VCCA_OVP , +TPS65224_IRQ_PFSM_ERR , +TPS65224_IRQ_BG_XMON , +/* INT_FSM_ERR register */ +TPS65224_IRQ_IMM_SHUTDOWN , +TPS65224_IRQ_ORD_SHUTDOWN , +TPS65224_IRQ_MCU_PWR_ERR , +TPS65224_IRQ_SOC_PWR_ERR , +TPS65224_IRQ_COMM_ERR , +TPS65224_IRQ_I2C2_ERR , +/* INT_ESM register */ +TPS65224_IRQ_ESM_MCU_PIN , +TPS65224_IRQ_ESM_MCU_FAIL , +TPS65224_IRQ_ESM_MCU_RST , +}; + +#define TPS65224_IRQ_NAME_BUCK1_UVOV "buck1_uvov" +#define TPS65224_IRQ_NAME_BUCK2_UVOV "buck2_uvov" +#define TPS65224_IRQ_NAME_BUCK3_UVOV "buck3_uvov" +#define TPS65224_IRQ_NAME_BUCK4_UVOV "buck4_uvov" +#define TPS65224_IRQ_NAME_LDO1_UVOV "ldo1_uvov" +#define TPS65224_IRQ_NAME_LDO2_UVOV "ldo2_uvov" +#define TPS65224_IRQ_NAME_LDO3_UVOV "ldo3_uvov" +#define TPS65224_IRQ_NAME_VCCA_UVOV "vcca_uvov" +#define TPS65224_IRQ_NAME_VMON1_UVOV "vmon1_uvov" +#define TPS65224_IRQ_NAME_VMON2_UVOV "vmon2_uvov" +#define TPS65224_IRQ_NAME_GPIO1 "gpio1" +#define TPS65224_IRQ_NAME_GPIO2 "gpio2" +#define TPS65224_IRQ_NAME_GPIO3 "gpio3" +#define TPS65224_IRQ_NAME_GPIO4 "gpio4" +#define TPS65224_IRQ_NAME_GPIO5 "gpio5" +#define TPS65224_IRQ_NAME_GPIO6 "gpio6" +#define TPS65224_IRQ_NAME_VSENSE "vsense" +#define TPS65224_IRQ_NAME_ENABLE "enable" +#define TPS65224_IRQ_NAME_PB_SHORT "pb_short" +#define TPS65224_IRQ_NAME_FSD "fsd" +#define TPS65224_IRQ_NAME_SOFT_REBOOT "soft_reboot" +#define TPS65224_IRQ_NAME_BIST_PASS "bist_pass" +#define TPS65224_IRQ_NAME_EXT_CLK "ext_clk" +#define TPS65224_IRQ_NAME_REG_UNLOCK "reg_unlock" +#define TPS65224_IRQ_NAME_TWARN "twarn" +#define TPS65224_IRQ_NAME_PB_LONG "pb_long" +#define TPS65224_IRQ_NAME_PB_FALL "pb_fall" +#define TPS65224_IRQ_NAME_PB_RISE "pb_rise" +#define TPS65224_IRQ_NAME_ADC_CONV_READY "adc_conv_ready" +#define TPS65224_IRQ_NAME_TSD_ORD "tsd_ord" +#define TPS65224_IRQ_NAME_BIST_FAIL "bist_fail" +#define TPS65224_IRQ_NAME_REG_CRC_ERR "reg_crc_err" +#define TPS65224_IRQ_NAME_RECOV_CNT "recov_cnt" +#define TPS65224_IRQ_NAME_TSD_IMM "tsd_imm" +#define TPS65224_IRQ_NAME_VCCA_OVP "vcca_ovp" +#define TPS65224_IRQ_NAME_PFSM_ERR "pfsm_err" +#define TPS65224_IRQ_NAME_BG_XMON "bg_xmon" +#define TPS65224_IRQ_NAME_IMM_SHUTDOWN "imm_shutdown" +#define TPS65224_IRQ_NAME_ORD_SHUTDOWN "ord_shutdown" +#define TPS65224_IRQ_NAME_MCU_PWR_ERR "mcu_pwr_err" +#define TPS65224_IRQ_NAME_SOC_PWR_ERR "soc_pwr_err" +#define TPS65224_IRQ_NAME_COMM_ERR "comm_err" +#define TPS65224_IRQ_NAME_I2C2_ERR "i2c2_err" +#define TPS65224_IRQ_NAME_ESM_MCU_PIN "esm_mcu_pin" +#define TPS65224_IRQ_NAME_ESM_MCU_FAIL "esm_mcu_fail" +#define TPS65224_IRQ_NAME_ESM_MCU_RST "esm_mcu_rst" +#define TPS65224_IRQ_NAME_POWERUP "powerup" +/** * struct tps6594 - device private data structure *
Signature · 1 line
2.25.1
Nishanth Menon
maintainerRe: [RESEND PATCH v1 01/13] mfd: tps6594: Add register definitions for TI TPS65224 PMIC
Quoted 10 lines · Bhargav Raviprakash
From: Nirmala Devi Mal Nadar <[email protected]>
Extend TPS6594 PMIC register and field definitions to support TPS65224 power management IC.
TPS65224 is software compatible to TPS6594 and can re-use many of the same definitions, new definitions are added to support additional controls available on TPS65224.
Signed-off-by Nirmala Devi Mal Nadar <[email protected]>
You've got to Sign-off as part of recommendations read [1]
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
Re: [RESEND PATCH v1 01/13] mfd: tps6594: Add register definitions for TI TPS65224 PMIC
Hi,
Quoted 10 lines · Nishanth Menon
Quoted 9 lines · Bhargav Raviprakash
From: Nirmala Devi Mal Nadar <[email protected]>
Extend TPS6594 PMIC register and field definitions to support TPS65224 power management IC.
TPS65224 is software compatible to TPS6594 and can re-use many of the same definitions, new definitions are added to support additional controls available on TPS65224.
Quoted 9 lines
Quoted 1 line
Signed-off-by Nirmala Devi Mal Nadar <[email protected]>You've got to Sign-off as part of recommendations read [1]
Signature · 2 lines
Regards, Nishanth Menon
Thanks for your feedback. We will do the sign-off in next patch version.
Regards,
Bhargav
PATCH RESEND 2/13 mfd: tps6594: use volatile_table instead of volatile_reg
In reply to Bhargav RaviprakashIn regmap_config use volatile_table instead of volatile_reg. This change makes it easier to add support for TPS65224 PMIC.
--- drivers/mfd/tps6594-core.c | 16 ++++++++++------ drivers/mfd/tps6594-i2c.c | 2 +- drivers/mfd/tps6594-spi.c | 2 +- include/linux/mfd/tps6594.h | 4 +++- 4 files changed, 15 insertions(+), 9 deletions(-)
drivers/mfd/tps6594-core.c +10 -6
@@ -319,12 +319,16 @@ static struct regmap_irq_chip tps6594_irq_chip = { .handle_post_irq = tps6594_handle_post_irq, }; -bool tps6594_is_volatile_reg (struct device *dev,unsigned int reg) -{ -return (reg >=TPS6594_REG_INT_TOP && reg <=TPS6594_REG_STAT_READBACK_ERR ) || - reg ==TPS6594_REG_RTC_STATUS ; -} -EXPORT_SYMBOL_GPL (tps6594_is_volatile_reg); +static const struct regmap_range tps6594_volatile_ranges[] = { +regmap_reg_range (TPS6594_REG_INT_TOP ,TPS6594_REG_STAT_READBACK_ERR ), +regmap_reg_range (TPS6594_REG_RTC_STATUS ,TPS6594_REG_RTC_STATUS ), +}; + +const struct regmap_access_table tps6594_volatile_table = { + .yes_ranges = tps6594_volatile_ranges, + .n_yes_ranges =ARRAY_SIZE (tps6594_volatile_ranges), +}; +EXPORT_SYMBOL_GPL (tps6594_volatile_table);static int tps6594_check_crc_mode (struct tps6594 *tps,bool primary_pmic) {
drivers/mfd/tps6594-i2c.c +1 -1
@@ -187,7 +187,7 @@ static const struct regmap_config tps6594_i2c_regmap_config = { .reg_bits = 16, .val_bits = 8, .max_register = TPS6594_REG_DWD_FAIL_CNT_REG, - .volatile_reg = tps6594_is_volatile_reg, + .volatile_table = &tps6594_volatile_table, .read = tps6594_i2c_read, .write = tps6594_i2c_write, };
drivers/mfd/tps6594-spi.c +1 -1
@@ -70,7 +70,7 @@ static const struct regmap_config tps6594_spi_regmap_config = { .reg_bits = 16, .val_bits = 8, .max_register = TPS6594_REG_DWD_FAIL_CNT_REG, - .volatile_reg = tps6594_is_volatile_reg, + .volatile_table = &tps6594_volatile_table, .reg_read = tps6594_spi_reg_read, .reg_write = tps6594_spi_reg_write, .use_single_read = true,
include/linux/mfd/tps6594.h +3 -1
@@ -1344,7 +1344,9 @@ struct tps6594 { struct regmap_irq_chip_data *irq_data; }; -bool tps6594_is_volatile_reg (struct device *dev,unsigned int reg); +extern const struct regmap_access_table tps6594_volatile_table; +extern const struct regmap_access_table tps65224_volatile_table; +int tps6594_device_init (struct tps6594 *tps,bool enable_crc);#endif /* __LINUX_MFD_TPS6594_H */
Signature · 1 line
2.25.1
PATCH RESEND 3/13 dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
In reply to Bhargav RaviprakashTPS65224 is a Power Management IC with 4 Buck regulators and 3 LDO regulators, it includes additional features like GPIOs, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine) managing the state of the device.
TPS6594 and TPS65224 have significant functional overlap.
--- Documentation/devicetree/bindings/mfd/ti,tps6594.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/mfd/ti,tps6594.yaml +1 -0
@@ -21,6 +21,7 @@ properties: - ti,lp8764-q1 - ti,tps6593-q1 - ti,tps6594-q1 + - ti,tps65224-q1 reg: description: I2C slave address or SPI chip select number.
Signature · 1 line
2.25.1
Re: [RESEND PATCH v1 03/13] dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
Quoted 6 lines · Bhargav Raviprakash
TPS65224 is a Power Management IC with 4 Buck regulators and 3 LDO regulators, it includes additional features like GPIOs, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine) managing the state of the device.
TPS6594 and TPS65224 have significant functional overlap.
What does "significant functional overlap" mean? Does one implement a compatible subset of the other? I assume the answer is no, given there seems to be some core looking registers at different addresses.
Thanks,
Conor.
Re: [RESEND PATCH v1 03/13] dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
Hi Conor,
Quoted 6 lines · Conor Dooley
Quoted 4 lines · Bhargav Raviprakash
TPS65224 is a Power Management IC with 4 Buck regulators and 3 LDO regulators, it includes additional features like GPIOs, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine) managing the state of the device.
Quoted 8 lines
Quoted 1 line
TPS6594 and TPS65224 have significant functional overlap.
What does "significant functional overlap" mean? Does one implement a compatible subset of the other? I assume the answer is no, given there seems to be some core looking registers at different addresses.
Thanks,
Conor.
The intention behind “significant functional overlap” was meant to indicate a lot of the features between TPS6594 and TPS65224 overlap, while there are some features specific to TPS65224.
There is compatibility between the PMIC register maps, I2C, PFSM, and other drivers even though there are some core registers at different addresses.
Would it be more appropriate to say the 2 devices are compatible and have sufficient feature overlap rather than significant functional overlap?
Thank you for your review and feedback!
Regards,
Bhargav
Re: [RESEND PATCH v1 03/13] dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
Quoted 22 lines · Bhargav Raviprakash
Hi Conor,
Quoted 11 lines · Conor Dooley
Quoted 6 lines · Bhargav Raviprakash
TPS65224 is a Power Management IC with 4 Buck regulators and 3 LDO regulators, it includes additional features like GPIOs, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine) managing the state of the device.
TPS6594 and TPS65224 have significant functional overlap.
What does "significant functional overlap" mean? Does one implement a compatible subset of the other? I assume the answer is no, given there seems to be some core looking registers at different addresses.
The intention behind “significant functional overlap” was meant to indicate a lot of the features between TPS6594 and TPS65224 overlap, while there are some features specific to TPS65224.
There is compatibility between the PMIC register maps, I2C, PFSM, and other drivers even though there are some core registers at different addresses.
Quoted 2 lines
Would it be more appropriate to say the 2 devices are compatible and have sufficient feature overlap rather than significant functional overlap?
If core registers are at different addresses, then it is unlikely that these devices are compatible. In this context, compatible means that existing software intended for the 6594 would run without modification on the 65224, although maybe only supporting a subset of features. If that's not the case, then the devices are not compatible.
Re: [RESEND PATCH v1 03/13] dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
Quoted 23 lines · Conor Dooley
Quoted 22 lines · Bhargav Raviprakash
Hi Conor,
Quoted 11 lines · Conor Dooley
Quoted 6 lines · Bhargav Raviprakash
TPS65224 is a Power Management IC with 4 Buck regulators and 3 LDO regulators, it includes additional features like GPIOs, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine) managing the state of the device.
TPS6594 and TPS65224 have significant functional overlap.
What does "significant functional overlap" mean? Does one implement a compatible subset of the other? I assume the answer is no, given there seems to be some core looking registers at different addresses.
The intention behind “significant functional overlap” was meant to indicate a lot of the features between TPS6594 and TPS65224 overlap, while there are some features specific to TPS65224.
There is compatibility between the PMIC register maps, I2C, PFSM, and other drivers even though there are some core registers at different addresses.
Quoted 5 lines
Quoted 2 lines
Would it be more appropriate to say the 2 devices are compatible and have sufficient feature overlap rather than significant functional overlap?
If core registers are at different addresses, then it is unlikely that these devices are compatible.
That's not necessarily true. Hardware designers can sometimes be creative. :)
Quoted 4 lines
In this context, compatible means that existing software intended for the 6594 would run without modification on the 65224, although maybe only supporting a subset of features. If that's not the case, then the devices are not compatible.
Compatible is a fuzzy term... so we need to get into the gray area.
What's going on here is that this new part is derivative in many signifcant (but not all) ways from an existing similar part. When writing drivers for new, derivative parts, there's always a choice between 1) extending the existing driver (using a new compatible string & match table for the diffs) or 2) creating a new driver which will have a bunch of duplicated code.
The first verion of this series[1] took the 2nd approach, but due to the significant functional (and feature) overlap, the recommendation was instead to take the "reuse" path to avoid signficant amounts of duplicated code.
Of course, it's possible that while going down the "reuse" path, there may be a point where creating a separate driver for some aspects might make sense, but that needs to be justified. Based on a quick glance of what I see in this series so far (I have not done a detailed review), the differences with the new device look to me like they can be handled with chip-specific data in a match table.
Kevin
Re: [RESEND PATCH v1 03/13] dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
Quoted 22 lines · Kevin Hilman
Quoted 21 lines · Conor Dooley
Quoted 20 lines · Bhargav Raviprakash
Quoted 11 lines · Conor Dooley
Quoted 6 lines · Bhargav Raviprakash
TPS65224 is a Power Management IC with 4 Buck regulators and 3 LDO regulators, it includes additional features like GPIOs, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine) managing the state of the device.
TPS6594 and TPS65224 have significant functional overlap.
What does "significant functional overlap" mean? Does one implement a compatible subset of the other? I assume the answer is no, given there seems to be some core looking registers at different addresses.
The intention behind “significant functional overlap” was meant to indicate a lot of the features between TPS6594 and TPS65224 overlap, while there are some features specific to TPS65224.
There is compatibility between the PMIC register maps, I2C, PFSM, and other drivers even though there are some core registers at different addresses.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Would it be more appropriate to say the 2 devices are compatible and have sufficient feature overlap rather than significant functional overlap?
If core registers are at different addresses, then it is unlikely that these devices are compatible.
That's not necessarily true. Hardware designers can sometimes be creative. :)
Hence "unlikely" in my mail :)
Quoted 19 lines
Quoted 4 lines
In this context, compatible means that existing software intended for the 6594 would run without modification on the 65224, although maybe only supporting a subset of features. If that's not the case, then the devices are not compatible.
Compatible is a fuzzy term... so we need to get into the gray area.
What's going on here is that this new part is derivative in many signifcant (but not all) ways from an existing similar part. When writing drivers for new, derivative parts, there's always a choice between 1) extending the existing driver (using a new compatible string & match table for the diffs) or 2) creating a new driver which will have a bunch of duplicated code.
The first verion of this series[1] took the 2nd approach, but due to the significant functional (and feature) overlap, the recommendation was instead to take the "reuse" path to avoid signficant amounts of duplicated code.
Quoted 6 lines
Of course, it's possible that while going down the "reuse" path, there may be a point where creating a separate driver for some aspects might make sense, but that needs to be justified. Based on a quick glance of what I see in this series so far (I have not done a detailed review), the differences with the new device look to me like they can be handled with chip-specific data in a match table.
This is all nice information, but not really relevant here - this is a binding patch, not a driver one & the conversation stemmed from me making sure that a fallback compatible was not suitable. Whether or not there are multiple drivers or not is someone else's problem!
Thanks,
Conor.
Re: [RESEND PATCH v1 03/13] dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
Quoted 60 lines · Conor Dooley
Quoted 22 lines · Kevin Hilman
Quoted 21 lines · Conor Dooley
Quoted 20 lines · Bhargav Raviprakash
Quoted 11 lines · Conor Dooley
Quoted 6 lines · Bhargav Raviprakash
TPS65224 is a Power Management IC with 4 Buck regulators and 3 LDO regulators, it includes additional features like GPIOs, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine) managing the state of the device.
TPS6594 and TPS65224 have significant functional overlap.
What does "significant functional overlap" mean? Does one implement a compatible subset of the other? I assume the answer is no, given there seems to be some core looking registers at different addresses.
The intention behind “significant functional overlap” was meant to indicate a lot of the features between TPS6594 and TPS65224 overlap, while there are some features specific to TPS65224.
There is compatibility between the PMIC register maps, I2C, PFSM, and other drivers even though there are some core registers at different addresses.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Would it be more appropriate to say the 2 devices are compatible and have sufficient feature overlap rather than significant functional overlap?
If core registers are at different addresses, then it is unlikely that these devices are compatible.
That's not necessarily true. Hardware designers can sometimes be creative. :)
Hence "unlikely" in my mail :)
Quoted 19 lines
Quoted 4 lines
In this context, compatible means that existing software intended for the 6594 would run without modification on the 65224, although maybe only supporting a subset of features. If that's not the case, then the devices are not compatible.
Compatible is a fuzzy term... so we need to get into the gray area.
What's going on here is that this new part is derivative in many signifcant (but not all) ways from an existing similar part. When writing drivers for new, derivative parts, there's always a choice between 1) extending the existing driver (using a new compatible string & match table for the diffs) or 2) creating a new driver which will have a bunch of duplicated code.
The first verion of this series[1] took the 2nd approach, but due to the significant functional (and feature) overlap, the recommendation was instead to take the "reuse" path to avoid signficant amounts of duplicated code.
Quoted 6 lines
Of course, it's possible that while going down the "reuse" path, there may be a point where creating a separate driver for some aspects might make sense, but that needs to be justified. Based on a quick glance of what I see in this series so far (I have not done a detailed review), the differences with the new device look to me like they can be handled with chip-specific data in a match table.
Quoted 3 lines
This is all nice information, but not really relevant here - this is a binding patch, not a driver one & the conversation stemmed from me making sure that a fallback compatible was not suitable.
hehe, oops. <blush>. my fault for mixing the two together
Sorry for the noise.
Kevin
Re: [RESEND PATCH v1 03/13] dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
Quoted 1 line · Kevin Hilman
Sorry for the noise.
nw chief
Re: [RESEND PATCH v1 03/13] dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
In reply to Conor DooleyQuoted 20 lines · Conor Dooley
Quoted 19 lines · Kevin Hilman
Quoted 18 lines · Conor Dooley
Quoted 17 lines · Bhargav Raviprakash
Quoted 9 lines · Conor Dooley
Quoted 5 lines · Bhargav Raviprakash
TPS65224 is a Power Management IC with 4 Buck regulators and 3 LDO regulators, it includes additional features like GPIOs, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine) managing the state of the device.
TPS6594 and TPS65224 have significant functional overlap.What does "significant functional overlap" mean? Does one implement a compatible subset of the other? I assume the answer is no, given there seems to be some core looking registers at different addresses.
The intention behind “significant functional overlap” was meant to indicate a lot of the features between TPS6594 and TPS65224 overlap, while there are some features specific to TPS65224.
There is compatibility between the PMIC register maps, I2C, PFSM, and other drivers even though there are some core registers at different addresses.
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Would it be more appropriate to say the 2 devices are compatible and have sufficient feature overlap rather than significant functional overlap?
If core registers are at different addresses, then it is unlikely that these devices are compatible.
That's not necessarily true. Hardware designers can sometimes be creative. :)
Hence "unlikely" in my mail :)
For tps6594 and tps65224, some core registers are at different adresses indeed, but the code is the same for both MFD I2C/SPI entry points. As an example, the way CRC is enabled is exactly the same, even if the bit that must be set belongs to different registers. tps65224 has more resources and it's as if HW designers had had to re-organize the way bits are distributed among the registers (due to a lack of space, so to speak).
That said, if we consider that these devices are not compatible, what does it imply concretely for the next version ? Does that mean that:
1) Only a new binding must be created, even if MFD drivers and most of child drivers will be re-used ? (then the binding would simply be duplicated, but the drivers would not)
2) A new binding and new MFD drivers must be created, even if most of child drivers will be re-used ? (then the binding and MFD drivers would simply be duplicated, but the child drivers would not)
3) A new binding and new drivers (MFD and child devices) must be created ?
4) Anything else ?
@Conor: I understand that it's not your problem. Anybody can answer, I just try to make things clear for the next version. :)
Julien
Quoted 32 lines
Quoted 19 lines
Quoted 5 lines
In this context, compatible means that existing software intended for the 6594 would run without modification on the 65224, although maybe only supporting a subset of features. If that's not the case, then the devices are not compatible.
Compatible is a fuzzy term... so we need to get into the gray area.
What's going on here is that this new part is derivative in many signifcant (but not all) ways from an existing similar part. When writing drivers for new, derivative parts, there's always a choice between 1) extending the existing driver (using a new compatible string & match table for the diffs) or 2) creating a new driver which will have a bunch of duplicated code.
The first verion of this series[1] took the 2nd approach, but due to the significant functional (and feature) overlap, the recommendation was instead to take the "reuse" path to avoid signficant amounts of duplicated code.
Quoted 6 lines
Of course, it's possible that while going down the "reuse" path, there may be a point where creating a separate driver for some aspects might make sense, but that needs to be justified. Based on a quick glance of what I see in this series so far (I have not done a detailed review), the differences with the new device look to me like they can be handled with chip-specific data in a match table.
This is all nice information, but not really relevant here - this is a binding patch, not a driver one & the conversation stemmed from me making sure that a fallback compatible was not suitable. Whether or not there are multiple drivers or not is someone else's problem!
Thanks,
Conor.
Re: [RESEND PATCH v1 03/13] dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
Quoted 36 lines · Julien Panis
Quoted 20 lines · Conor Dooley
Quoted 19 lines · Kevin Hilman
Quoted 18 lines · Conor Dooley
Quoted 17 lines · Bhargav Raviprakash
Quoted 9 lines · Conor Dooley
Quoted 5 lines · Bhargav Raviprakash
TPS65224 is a Power Management IC with 4 Buck regulators and 3 LDO regulators, it includes additional features like GPIOs, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine) managing the state of the device.
TPS6594 and TPS65224 have significant functional overlap.What does "significant functional overlap" mean? Does one implement a compatible subset of the other? I assume the answer is no, given there seems to be some core looking registers at different addresses.
The intention behind “significant functional overlap” was meant to indicate a lot of the features between TPS6594 and TPS65224 overlap, while there are some features specific to TPS65224.
There is compatibility between the PMIC register maps, I2C, PFSM, and other drivers even though there are some core registers at different addresses.Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Would it be more appropriate to say the 2 devices are compatible and have sufficient feature overlap rather than significant functional overlap?
If core registers are at different addresses, then it is unlikely that these devices are compatible.
That's not necessarily true. Hardware designers can sometimes be creative. :)
Hence "unlikely" in my mail :)
For tps6594 and tps65224, some core registers are at different adresses indeed, but the code is the same for both MFD I2C/SPI entry points. As an example, the way CRC is enabled is exactly the same, even if the bit that must be set belongs to different registers. tps65224 has more resources and it's as if HW designers had had to re-organize the way bits are distributed among the registers (due to a lack of space, so to speak).
Quoted 10 lines
That said, if we consider that these devices are not compatible, what does it imply concretely for the next version ? Does that mean that:
1) Only a new binding must be created, even if MFD drivers and most of child drivers will be re-used ? (then the binding would simply be duplicated, but the drivers would not)
2) A new binding and new MFD drivers must be created, even if most of child drivers will be re-used ? (then the binding and MFD drivers would simply be duplicated, but the child drivers would not)
3) A new binding and new drivers (MFD and child devices) must be created ?
4) Anything else ?
If they're not compatible the next version of this patch does not need to change, so option 4 I guess.
Re: [RESEND PATCH v1 03/13] dt-bindings: mfd: ti,tps6594: Add TI TPS65224 PMIC
In reply to Bhargav RaviprakashQuoted 6 lines · Bhargav Raviprakash
TPS65224 is a Power Management IC with 4 Buck regulators and 3 LDO regulators, it includes additional features like GPIOs, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine) managing the state of the device.
TPS6594 and TPS65224 have significant functional overlap.
With this updated to mention what makes the devices incompatible,
Cheers,
Conor.
Quoted 21 lines
Signed-off-by Bhargav Raviprakash <[email protected]>--- Documentation/devicetree/bindings/mfd/ti,tps6594.yaml | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/mfd/ti,tps6594.yaml +1
-0@@ -21,6 +21,7 @@ properties: - ti,lp8764-q1 - ti,tps6593-q1 - ti,tps6594-q1 + - ti,tps65224-q1 reg: description: I2C slave address or SPI chip select number.Signature · 1 line
2.25.1
PATCH RESEND 4/13 mfd: tps6594-i2c: Add TI TPS65224 PMIC I2C
In reply to Bhargav RaviprakashAdd support for TPS65224 PMIC in TPS6594's I2C driver which has significant functional overlap.
--- drivers/mfd/tps6594-i2c.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/mfd/tps6594-i2c.c +11 -7
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 /* -* I2C access driver for TI TPS6594/TPS6593/LP8764 PMICs +* I2C access driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs * * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ */
@@ -183,7 +183,7 @@ static int tps6594_i2c_write(void *context, const void *data, size_t count)return ret; } -static const struct regmap_config tps6594_i2c_regmap_config = { +static struct regmap_config tps6594_i2c_regmap_config = { .reg_bits =16 , .val_bits =8 , .max_register =TPS6594_REG_DWD_FAIL_CNT_REG ,
@@ -196,6 +196,7 @@ static const struct of_device_id tps6594_i2c_of_match_table[] = { { .compatible = "ti,tps6594-q1", .data = (void *)TPS6594, }, { .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, }, { .compatible = "ti,lp8764-q1", .data = (void *)LP8764, }, + { .compatible = "ti,tps65224-q1", .data = (void *)TPS65224, }, {} }; MODULE_DEVICE_TABLE(of, tps6594_i2c_of_match_table);
@@ -216,15 +217,18 @@ static int tps6594_i2c_probe(struct i2c_client *client) tps->reg = client->addr; tps->irq = client->irq; - tps->regmap =devm_regmap_init (dev,NULL , client, &tps6594_i2c_regmap_config); -if (IS_ERR (tps->regmap)) -return dev_err_probe (dev,PTR_ERR (tps->regmap),"Failed to init regmap\n" ); - match =of_match_device (tps6594_i2c_of_match_table, dev);if (!match)return dev_err_probe (dev, -EINVAL ,"Failed to find matching chip ID\n" ); tps->chip_id = (unsigned long )match->data; +if (tps->chip_id ==TPS65224 ) + tps6594_i2c_regmap_config.volatile_table = &tps65224_volatile_table; + + tps->regmap =devm_regmap_init (dev,NULL , client, &tps6594_i2c_regmap_config); +if (IS_ERR (tps->regmap)) +return dev_err_probe (dev,PTR_ERR (tps->regmap),"Failed to init regmap\n" ); +crc8_populate_msb (tps6594_i2c_crc_table,TPS6594_CRC8_POLYNOMIAL );return tps6594_device_init (tps, enable_crc);
@@ -240,5 +244,5 @@ static struct i2c_driver tps6594_i2c_driver = {module_i2c_driver (tps6594_i2c_driver);MODULE_AUTHOR ("Julien Panis <[email protected]>" ); -MODULE_DESCRIPTION ("TPS6594 I2C Interface Driver" ); +MODULE_DESCRIPTION ("I2C Interface Driver for TPS65224, TPS6594/3, and LP8764" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.25.1
Re: [RESEND PATCH v1 04/13] mfd: tps6594-i2c: Add TI TPS65224 PMIC I2C
Hello,
Quoted 4 lines · Bhargav Raviprakash
Add support for TPS65224 PMIC in TPS6594's I2C driver which has significant functional overlap.
Signed-off-by Bhargav Raviprakash <[email protected]>
Thanks for the patch adding TPS65224 support
[...]
Quoted 5 lines
drivers/mfd/tps6594-i2c.c +0
-1@@ -216,15 +217,18 @@ static int tps6594_i2c_probe(struct i2c_client *client) tps->reg = client->addr; tps->irq = client->irq; - tps->regmap =devm_regmap_init (dev,NULL , client, &tps6594_i2c_regmap_config);
drivers/mfd/tps6594-i2c.c static int tps6594_i2c_probe(struct i2c_client *client) · line 226
Quoted 10 lines
drivers/mfd/tps6594-i2c.c +2
-3-if (IS_ERR (tps->regmap)) -return dev_err_probe (dev,PTR_ERR (tps->regmap),"Failed to init regmap\n" ); - match =of_match_device (tps6594_i2c_of_match_table, dev);if (!match)return dev_err_probe (dev, -EINVAL ,"Failed to find matching chip ID\n" ); tps->chip_id = (unsigned long )match->data; +if (tps->chip_id ==TPS65224 ) + tps6594_i2c_regmap_config.volatile_table = &tps65224_volatile_table;
minor nit: for chip-specific differnces like this, rather than do this kind of "if" check here to update the regmap_config, instead use the compatible match data have a separate i2c_regmap_config match table for tps65224.
Kevin
PATCH RESEND 5/13 mfd: tps6594-spi: Add TI TPS65224 PMIC SPI
In reply to Bhargav RaviprakashAdd support for TPS65224 PMIC in the TPS6594 driver as they share significant functional overlap.
--- drivers/mfd/tps6594-spi.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/mfd/tps6594-spi.c +10 -6
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 /* -* SPI access driver for TI TPS6594/TPS6593/LP8764 PMICs +* SPI access driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs * * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ */
@@ -66,7 +66,7 @@ static int tps6594_spi_reg_write(void *context, unsigned int reg, unsigned int vreturn spi_write (spi, buf, count); } -static const struct regmap_config tps6594_spi_regmap_config = { +static struct regmap_config tps6594_spi_regmap_config = { .reg_bits =16 , .val_bits =8 , .max_register =TPS6594_REG_DWD_FAIL_CNT_REG ,
@@ -81,6 +81,7 @@ static const struct of_device_id tps6594_spi_of_match_table[] = { { .compatible = "ti,tps6594-q1", .data = (void *)TPS6594, }, { .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, }, { .compatible = "ti,lp8764-q1", .data = (void *)LP8764, }, + { .compatible = "ti,tps65224-q1", .data = (void *)TPS65224, }, {} }; MODULE_DEVICE_TABLE(of, tps6594_spi_of_match_table);
@@ -101,15 +102,18 @@ static int tps6594_spi_probe(struct spi_device *spi) tps->reg =spi_get_chipselect (spi,0 ); tps->irq = spi->irq; - tps->regmap =devm_regmap_init (dev,NULL , spi, &tps6594_spi_regmap_config); -if (IS_ERR (tps->regmap)) -return dev_err_probe (dev,PTR_ERR (tps->regmap),"Failed to init regmap\n" ); - match =of_match_device (tps6594_spi_of_match_table, dev);if (!match)return dev_err_probe (dev, -EINVAL ,"Failed to find matching chip ID\n" ); tps->chip_id = (unsigned long )match->data; +if (tps->chip_id ==TPS65224 ) + tps6594_spi_regmap_config.volatile_table = &tps65224_volatile_table; + + tps->regmap =devm_regmap_init (dev,NULL , spi, &tps6594_spi_regmap_config); +if (IS_ERR (tps->regmap)) +return dev_err_probe (dev,PTR_ERR (tps->regmap),"Failed to init regmap\n" ); +crc8_populate_msb (tps6594_spi_crc_table,TPS6594_CRC8_POLYNOMIAL );return tps6594_device_init (tps, enable_crc);
Signature · 1 line
2.25.1
Re: [RESEND PATCH v1 05/13] mfd: tps6594-spi: Add TI TPS65224 PMIC SPI
Quoted 42 lines · Bhargav Raviprakash
Add support for TPS65224 PMIC in the TPS6594 driver as they share significant functional overlap.
Signed-off-by Bhargav Raviprakash <[email protected]>--- drivers/mfd/tps6594-spi.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/mfd/tps6594-spi.c +3
-3@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 /* -* SPI access driver for TI TPS6594/TPS6593/LP8764 PMICs +* SPI access driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs * * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ */ @@ -66,7 +66,7 @@ static int tps6594_spi_reg_write(void *context, unsigned int reg, unsigned int vreturn spi_write (spi, buf, count); } -static const struct regmap_config tps6594_spi_regmap_config = { +static struct regmap_config tps6594_spi_regmap_config = { .reg_bits =16 , .val_bits =8 , .max_register =TPS6594_REG_DWD_FAIL_CNT_REG ,@@ -81,6 +81,7 @@ static const struct of_device_id tps6594_spi_of_match_table[] = { { .compatible = "ti,tps6594-q1", .data = (void *)TPS6594, }, { .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, }, { .compatible = "ti,lp8764-q1", .data = (void *)LP8764, }, + { .compatible = "ti,tps65224-q1", .data = (void *)TPS65224, }, {} }; MODULE_DEVICE_TABLE(of, tps6594_spi_of_match_table);@@ -101,15 +102,18 @@ static int tps6594_spi_probe(struct spi_device *spi) tps->reg =spi_get_chipselect (spi,0 ); tps->irq = spi->irq; - tps->regmap =devm_regmap_init (dev,NULL , spi, &tps6594_spi_regmap_config);
drivers/mfd/tps6594-spi.c static int tps6594_spi_probe(struct spi_device *spi) · line 111
Quoted 10 lines
drivers/mfd/tps6594-spi.c +2
-3-if (IS_ERR (tps->regmap)) -return dev_err_probe (dev,PTR_ERR (tps->regmap),"Failed to init regmap\n" ); - match =of_match_device (tps6594_spi_of_match_table, dev);if (!match)return dev_err_probe (dev, -EINVAL ,"Failed to find matching chip ID\n" ); tps->chip_id = (unsigned long )match->data; +if (tps->chip_id ==TPS65224 ) + tps6594_spi_regmap_config.volatile_table = &tps65224_volatile_table;
Similar to my comment on the i2c series, but to be more specific:
Rather than use the .data pointer in the of_match_table as simply a chip_id, instead make that into a struct that can contain chip-specific values/pointers etc, and then each compatible can have a custom struct (if needed.)
This way, at probe/match time, all the chip-specific data is setup using that struct, so that at runtime, there doesn't need to be any "if (chip_id)" checking.
Kevin
Re: [RESEND PATCH v1 05/13] mfd: tps6594-spi: Add TI TPS65224 PMIC SPI
Hello Kevin,
Quoted 62 lines · Kevin
Quoted 42 lines · Bhargav Raviprakash
Add support for TPS65224 PMIC in the TPS6594 driver as they share significant functional overlap.
Signed-off-by Bhargav Raviprakash <[email protected]>--- drivers/mfd/tps6594-spi.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)drivers/mfd/tps6594-spi.c +3
-3@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 /* -* SPI access driver for TI TPS6594/TPS6593/LP8764 PMICs +* SPI access driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs * * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ */ @@ -66,7 +66,7 @@ static int tps6594_spi_reg_write(void *context, unsigned int reg, unsigned int vreturn spi_write (spi, buf, count); } -static const struct regmap_config tps6594_spi_regmap_config = { +static struct regmap_config tps6594_spi_regmap_config = { .reg_bits =16 , .val_bits =8 , .max_register =TPS6594_REG_DWD_FAIL_CNT_REG ,@@ -81,6 +81,7 @@ static const struct of_device_id tps6594_spi_of_match_table[] = { { .compatible = "ti,tps6594-q1", .data = (void *)TPS6594, }, { .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, }, { .compatible = "ti,lp8764-q1", .data = (void *)LP8764, }, + { .compatible = "ti,tps65224-q1", .data = (void *)TPS65224, }, {} }; MODULE_DEVICE_TABLE(of, tps6594_spi_of_match_table);@@ -101,15 +102,18 @@ static int tps6594_spi_probe(struct spi_device *spi) tps->reg =spi_get_chipselect (spi,0 ); tps->irq = spi->irq; - tps->regmap =devm_regmap_init (dev,NULL , spi, &tps6594_spi_regmap_config);drivers/mfd/tps6594-spi.c static int tps6594_spi_probe(struct spi_device *spi) · line 111
Quoted 10 lines
drivers/mfd/tps6594-spi.c +2
-3-if (IS_ERR (tps->regmap)) -return dev_err_probe (dev,PTR_ERR (tps->regmap),"Failed to init regmap\n" ); - match =of_match_device (tps6594_spi_of_match_table, dev);if (!match)return dev_err_probe (dev, -EINVAL ,"Failed to find matching chip ID\n" ); tps->chip_id = (unsigned long )match->data; +if (tps->chip_id ==TPS65224 ) + tps6594_spi_regmap_config.volatile_table = &tps65224_volatile_table;Similar to my comment on the i2c series, but to be more specific:
Rather than use the .data pointer in the
of_match_tableas simply achip_id, instead make that into a struct that can contain chip-specific values/pointers etc, and then each compatible can have a custom struct (if needed.)
Quoted 5 lines
This way, at probe/match time, all the chip-specific data is setup using that struct, so that at runtime, there doesn't need to be any "if (
chip_id)" checking.Kevin
Thanks for the feedback!
We will implement the same in the next version.
Regards,
Bhargav
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH RESEND 6/13 mfd: tps6594-core: Add TI TPS65224 PMIC core
In reply to Bhargav RaviprakashAdd functionality of the TPS65224 PMIC to the TPS6594 core driver. This includes adding IRQ resource, MFD cells, and device initialization for TPS65224.
--- drivers/mfd/tps6594-core.c | 242 ++++++++++++++++++++++++++++++++++--- 1 file changed, 228 insertions(+), 14 deletions(-)
drivers/mfd/tps6594-core.c +228 -14
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 /* -* Core functions for TI TPS6594/TPS6593/LP8764 PMICs +* Core functions for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs * * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ */
@@ -278,16 +278,172 @@ static const unsigned int tps6594_irq_reg[] = { TPS6594_REG_RTC_STATUS, }; +/* TPS65224 Resources */ + +static const struct resource tps65224_regulator_resources[] = { +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_BUCK1_UVOV ,TPS65224_IRQ_NAME_BUCK1_UVOV ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_BUCK2_UVOV ,TPS65224_IRQ_NAME_BUCK2_UVOV ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_BUCK3_UVOV ,TPS65224_IRQ_NAME_BUCK3_UVOV ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_BUCK4_UVOV ,TPS65224_IRQ_NAME_BUCK4_UVOV ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_LDO1_UVOV ,TPS65224_IRQ_NAME_LDO1_UVOV ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_LDO2_UVOV ,TPS65224_IRQ_NAME_LDO2_UVOV ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_LDO3_UVOV ,TPS65224_IRQ_NAME_LDO3_UVOV ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_VCCA_UVOV ,TPS65224_IRQ_NAME_VCCA_UVOV ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_VMON1_UVOV ,TPS65224_IRQ_NAME_VMON1_UVOV ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_VMON2_UVOV ,TPS65224_IRQ_NAME_VMON2_UVOV ), +}; + +static const struct resource tps65224_pinctrl_resources[] = { +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_GPIO1 ,TPS65224_IRQ_NAME_GPIO1 ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_GPIO2 ,TPS65224_IRQ_NAME_GPIO2 ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_GPIO3 ,TPS65224_IRQ_NAME_GPIO3 ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_GPIO4 ,TPS65224_IRQ_NAME_GPIO4 ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_GPIO5 ,TPS65224_IRQ_NAME_GPIO5 ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_GPIO6 ,TPS65224_IRQ_NAME_GPIO6 ), +}; + +static const struct resource tps65224_pfsm_resources[] = { +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_VSENSE ,TPS65224_IRQ_NAME_VSENSE ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_ENABLE ,TPS65224_IRQ_NAME_ENABLE ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_PB_SHORT ,TPS65224_IRQ_NAME_PB_SHORT ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_FSD ,TPS65224_IRQ_NAME_FSD ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_SOFT_REBOOT ,TPS65224_IRQ_NAME_SOFT_REBOOT ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_BIST_PASS ,TPS65224_IRQ_NAME_BIST_PASS ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_EXT_CLK ,TPS65224_IRQ_NAME_EXT_CLK ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_REG_UNLOCK ,TPS65224_IRQ_NAME_REG_UNLOCK ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_TWARN ,TPS65224_IRQ_NAME_TWARN ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_PB_LONG ,TPS65224_IRQ_NAME_PB_LONG ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_PB_FALL ,TPS65224_IRQ_NAME_PB_FALL ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_PB_RISE ,TPS65224_IRQ_NAME_PB_RISE ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_TSD_ORD ,TPS65224_IRQ_NAME_TSD_ORD ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_BIST_FAIL ,TPS65224_IRQ_NAME_BIST_FAIL ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_REG_CRC_ERR ,TPS65224_IRQ_NAME_REG_CRC_ERR ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_RECOV_CNT ,TPS65224_IRQ_NAME_RECOV_CNT ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_TSD_IMM ,TPS65224_IRQ_NAME_TSD_IMM ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_VCCA_OVP ,TPS65224_IRQ_NAME_VCCA_OVP ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_PFSM_ERR ,TPS65224_IRQ_NAME_PFSM_ERR ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_BG_XMON ,TPS65224_IRQ_NAME_BG_XMON ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_IMM_SHUTDOWN ,TPS65224_IRQ_NAME_IMM_SHUTDOWN ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_ORD_SHUTDOWN ,TPS65224_IRQ_NAME_ORD_SHUTDOWN ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_MCU_PWR_ERR ,TPS65224_IRQ_NAME_MCU_PWR_ERR ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_SOC_PWR_ERR ,TPS65224_IRQ_NAME_SOC_PWR_ERR ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_COMM_ERR ,TPS65224_IRQ_NAME_COMM_ERR ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_I2C2_ERR ,TPS65224_IRQ_NAME_I2C2_ERR ), +}; + +static const struct resource tps65224_esm_resources[] = { +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_ESM_MCU_PIN ,TPS65224_IRQ_NAME_ESM_MCU_PIN ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_ESM_MCU_FAIL ,TPS65224_IRQ_NAME_ESM_MCU_FAIL ), +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_ESM_MCU_RST ,TPS65224_IRQ_NAME_ESM_MCU_RST ), +}; + +static const struct resource tps65224_adc_resources[] = { +DEFINE_RES_IRQ_NAMED (TPS65224_IRQ_ADC_CONV_READY ,TPS65224_IRQ_NAME_ADC_CONV_READY ), +}; + +static const struct mfd_cell tps65224_common_cells[] = { +MFD_CELL_RES ("tps65224-adc" , tps65224_adc_resources), +MFD_CELL_RES ("tps6594-esm" , tps65224_esm_resources), +MFD_CELL_RES ("tps6594-pfsm" , tps65224_pfsm_resources), +MFD_CELL_RES ("tps6594-pinctrl" , tps65224_pinctrl_resources), +MFD_CELL_RES ("tps6594-regulator" , tps65224_regulator_resources), +}; + +static const struct regmap_irq tps65224_irqs[] = { +/* INT_BUCK register */ +REGMAP_IRQ_REG (TPS65224_IRQ_BUCK1_UVOV ,0 ,TPS65224_BIT_BUCK1_UVOV_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_BUCK2_UVOV ,0 ,TPS65224_BIT_BUCK2_UVOV_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_BUCK3_UVOV ,0 ,TPS65224_BIT_BUCK3_UVOV_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_BUCK4_UVOV ,0 ,TPS65224_BIT_BUCK4_UVOV_INT ), + +/* INT_VMON_LDO register */ +REGMAP_IRQ_REG (TPS65224_IRQ_LDO1_UVOV ,1 ,TPS65224_BIT_LDO1_UVOV_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_LDO2_UVOV ,1 ,TPS65224_BIT_LDO2_UVOV_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_LDO3_UVOV ,1 ,TPS65224_BIT_LDO3_UVOV_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_VCCA_UVOV ,1 ,TPS65224_BIT_VCCA_UVOV_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_VMON1_UVOV ,1 ,TPS65224_BIT_VMON1_UVOV_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_VMON2_UVOV ,1 ,TPS65224_BIT_VMON2_UVOV_INT ), + +/* INT_GPIO register */ +REGMAP_IRQ_REG (TPS65224_IRQ_GPIO1 ,2 ,TPS65224_BIT_GPIO1_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_GPIO2 ,2 ,TPS65224_BIT_GPIO2_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_GPIO3 ,2 ,TPS65224_BIT_GPIO3_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_GPIO4 ,2 ,TPS65224_BIT_GPIO4_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_GPIO5 ,2 ,TPS65224_BIT_GPIO5_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_GPIO6 ,2 ,TPS65224_BIT_GPIO6_INT ), + +/* INT_STARTUP register */ +REGMAP_IRQ_REG (TPS65224_IRQ_VSENSE ,3 ,TPS65224_BIT_VSENSE_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_ENABLE ,3 ,TPS6594_BIT_ENABLE_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_PB_SHORT ,3 ,TPS65224_BIT_PB_SHORT_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_FSD ,3 ,TPS6594_BIT_FSD_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_SOFT_REBOOT ,3 ,TPS6594_BIT_SOFT_REBOOT_INT ), + +/* INT_MISC register */ +REGMAP_IRQ_REG (TPS65224_IRQ_BIST_PASS ,4 ,TPS6594_BIT_BIST_PASS_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_EXT_CLK ,4 ,TPS6594_BIT_EXT_CLK_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_REG_UNLOCK ,4 ,TPS65224_BIT_REG_UNLOCK_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_TWARN ,4 ,TPS6594_BIT_TWARN_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_PB_LONG ,4 ,TPS65224_BIT_PB_LONG_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_PB_FALL ,4 ,TPS65224_BIT_PB_FALL_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_PB_RISE ,4 ,TPS65224_BIT_PB_RISE_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_ADC_CONV_READY ,4 ,TPS65224_BIT_ADC_CONV_READY_INT ), + +/* INT_MODERATE_ERR register */ +REGMAP_IRQ_REG (TPS65224_IRQ_TSD_ORD ,5 ,TPS6594_BIT_TSD_ORD_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_BIST_FAIL ,5 ,TPS6594_BIT_BIST_FAIL_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_REG_CRC_ERR ,5 ,TPS6594_BIT_REG_CRC_ERR_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_RECOV_CNT ,5 ,TPS6594_BIT_RECOV_CNT_INT ), + +/* INT_SEVERE_ERR register */ +REGMAP_IRQ_REG (TPS65224_IRQ_TSD_IMM ,6 ,TPS6594_BIT_TSD_IMM_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_VCCA_OVP ,6 ,TPS6594_BIT_VCCA_OVP_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_PFSM_ERR ,6 ,TPS6594_BIT_PFSM_ERR_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_BG_XMON ,6 ,TPS65224_BIT_BG_XMON_INT ), + +/* INT_FSM_ERR register */ +REGMAP_IRQ_REG (TPS65224_IRQ_IMM_SHUTDOWN ,7 ,TPS6594_BIT_IMM_SHUTDOWN_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_ORD_SHUTDOWN ,7 ,TPS6594_BIT_ORD_SHUTDOWN_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_MCU_PWR_ERR ,7 ,TPS6594_BIT_MCU_PWR_ERR_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_SOC_PWR_ERR ,7 ,TPS6594_BIT_SOC_PWR_ERR_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_COMM_ERR ,7 ,TPS6594_BIT_COMM_ERR_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_I2C2_ERR ,7 ,TPS65224_BIT_I2C2_ERR_INT ), + +/* INT_ESM register */ +REGMAP_IRQ_REG (TPS65224_IRQ_ESM_MCU_PIN ,8 ,TPS6594_BIT_ESM_MCU_PIN_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_ESM_MCU_FAIL ,8 ,TPS6594_BIT_ESM_MCU_FAIL_INT ), +REGMAP_IRQ_REG (TPS65224_IRQ_ESM_MCU_RST ,8 ,TPS6594_BIT_ESM_MCU_RST_INT ), +}; + +static const unsigned int tps65224_irq_reg[] = { +TPS6594_REG_INT_BUCK , +TPS6594_REG_INT_LDO_VMON , +TPS6594_REG_INT_GPIO , +TPS6594_REG_INT_STARTUP , +TPS6594_REG_INT_MISC , +TPS6594_REG_INT_MODERATE_ERR , +TPS6594_REG_INT_SEVERE_ERR , +TPS6594_REG_INT_FSM_ERR , +TPS6594_REG_INT_ESM , +}; +static inline unsigned int tps6594_get_irq_reg (struct regmap_irq_chip_data *data,unsigned int base,int index) {return tps6594_irq_reg[index]; }; +static inline unsigned int tps65224_get_irq_reg (struct regmap_irq_chip_data *data, +unsigned int base,int index) +{ +return tps65224_irq_reg[index]; +}; +static int tps6594_handle_post_irq (void *irq_drv_data) {struct tps6594 *tps = irq_drv_data;int ret =0 ; +unsigned int regmap_reg, mask_val;/* * When CRC is enabled, writing to a read-only bit triggers an error,
@@ -299,10 +455,17 @@ static int tps6594_handle_post_irq(void *irq_drv_data)* COMM_ADR_ERR_INT bit set. Clear immediately this bit to avoid raising * a new interrupt. */ -if (tps->use_crc) - ret =regmap_write_bits (tps->regmap,TPS6594_REG_INT_COMM_ERR , -TPS6594_BIT_COMM_ADR_ERR_INT , -TPS6594_BIT_COMM_ADR_ERR_INT ); +if (tps->use_crc) { +if (tps->chip_id ==TPS65224 ) { + regmap_reg =TPS6594_REG_INT_FSM_ERR ; + mask_val =TPS6594_BIT_COMM_ERR_INT ; + }else { + regmap_reg =TPS6594_REG_INT_COMM_ERR ; + mask_val =TPS6594_BIT_COMM_ADR_ERR_INT ; + } + + ret =regmap_write_bits (tps->regmap, regmap_reg, mask_val, mask_val); + }return ret; };
@@ -319,6 +482,18 @@ static struct regmap_irq_chip tps6594_irq_chip = { .handle_post_irq = tps6594_handle_post_irq, }; +static struct regmap_irq_chip tps65224_irq_chip = { + .ack_base =TPS6594_REG_INT_BUCK , + .ack_invert =1 , + .clear_ack =1 , + .init_ack_masked =1 , + .num_regs =ARRAY_SIZE (tps65224_irq_reg), + .irqs = tps65224_irqs, + .num_irqs =ARRAY_SIZE (tps65224_irqs), + .get_irq_reg = tps65224_get_irq_reg, + .handle_post_irq = tps6594_handle_post_irq, +}; +static const struct regmap_range tps6594_volatile_ranges[] = {regmap_reg_range (TPS6594_REG_INT_TOP ,TPS6594_REG_STAT_READBACK_ERR ),regmap_reg_range (TPS6594_REG_RTC_STATUS ,TPS6594_REG_RTC_STATUS ),
@@ -330,17 +505,35 @@ const struct regmap_access_table tps6594_volatile_table = { };EXPORT_SYMBOL_GPL (tps6594_volatile_table); +static const struct regmap_range tps65224_volatile_ranges[] = { +regmap_reg_range (TPS6594_REG_INT_TOP ,TPS6594_REG_STAT_SEVERE_ERR ), +}; + +const struct regmap_access_table tps65224_volatile_table = { + .yes_ranges = tps65224_volatile_ranges, + .n_yes_ranges =ARRAY_SIZE (tps65224_volatile_ranges), +}; +EXPORT_SYMBOL_GPL (tps65224_volatile_table); +static int tps6594_check_crc_mode (struct tps6594 *tps,bool primary_pmic) {int ret; +unsigned int regmap_reg, mask_val; + +if (tps->chip_id ==TPS65224 ) { + regmap_reg =TPS6594_REG_CONFIG_2 ; + mask_val =TPS65224_BIT_I2C1_SPI_CRC_EN ; + }else { + regmap_reg =TPS6594_REG_SERIAL_IF_CONFIG ; + mask_val =TPS6594_BIT_I2C1_SPI_CRC_EN ; + };/* * Check if CRC is enabled. * Once CRC is enabled, it can't be disabled until next power cycle. */ tps->use_crc = true; - ret =regmap_test_bits (tps->regmap,TPS6594_REG_SERIAL_IF_CONFIG , -TPS6594_BIT_I2C1_SPI_CRC_EN ); + ret =regmap_test_bits (tps->regmap, regmap_reg, mask_val);if (ret ==0 ) { ret = -EIO ; }else if (ret >0 ) {
@@ -355,6 +548,15 @@ static int tps6594_check_crc_mode(struct tps6594 *tps, bool primary_pmic)static int tps6594_set_crc_feature (struct tps6594 *tps) {int ret; +unsigned int regmap_reg, mask_val; + +if (tps->chip_id ==TPS65224 ) { + regmap_reg =TPS6594_REG_CONFIG_2 ; + mask_val =TPS65224_BIT_I2C1_SPI_CRC_EN ; + }else { + regmap_reg =TPS6594_REG_FSM_I2C_TRIGGERS ; + mask_val =TPS6594_BIT_TRIGGER_I2C (2 ); + } ret =tps6594_check_crc_mode (tps, true);if (ret) {
@@ -363,8 +565,7 @@ static int tps6594_set_crc_feature(struct tps6594 *tps)* on primary PMIC. */ tps->use_crc = false; - ret =regmap_write_bits (tps->regmap,TPS6594_REG_FSM_I2C_TRIGGERS , -TPS6594_BIT_TRIGGER_I2C (2 ),TPS6594_BIT_TRIGGER_I2C (2 )); + ret =regmap_write_bits (tps->regmap, regmap_reg, mask_val, mask_val);if (ret)return ret;
@@ -420,6 +621,9 @@ int tps6594_device_init(struct tps6594 *tps, bool enable_crc) {struct device *dev = tps->dev;int ret; +struct regmap_irq_chip *irq_chip; +const struct mfd_cell *cells; +int n_cells;if (enable_crc) { ret =tps6594_enable_crc (tps);
@@ -440,19 +644,28 @@ int tps6594_device_init(struct tps6594 *tps, bool enable_crc)if (!tps6594_irq_chip.name)return -ENOMEM ; +if (tps->chip_id ==TPS65224 ) { + irq_chip = &tps65224_irq_chip; + n_cells =ARRAY_SIZE (tps65224_common_cells); + cells = tps65224_common_cells; + }else { + irq_chip = &tps6594_irq_chip; + n_cells =ARRAY_SIZE (tps6594_common_cells); + cells = tps6594_common_cells; + } + ret =devm_regmap_add_irq_chip (dev, tps->regmap, tps->irq,IRQF_SHARED |IRQF_ONESHOT , -0 , &tps6594_irq_chip, &tps->irq_data); +0 , irq_chip, &tps->irq_data);if (ret)return dev_err_probe (dev, ret,"Failed to add regmap IRQ\n" ); - ret =devm_mfd_add_devices (dev,PLATFORM_DEVID_AUTO , tps6594_common_cells, -ARRAY_SIZE (tps6594_common_cells),NULL ,0 , + ret =devm_mfd_add_devices (dev,PLATFORM_DEVID_AUTO , cells, n_cells,NULL ,0 ,regmap_irq_get_domain (tps->irq_data));if (ret)return dev_err_probe (dev, ret,"Failed to add common child devices\n" ); -/* No RTC for LP8764 */ -if (tps->chip_id !=LP8764 ) { +/* No RTC for LP8764 and TPS65224 */ +if (tps->chip_id !=LP8764 && tps->chip_id !=TPS65224 ) { ret =devm_mfd_add_devices (dev,PLATFORM_DEVID_AUTO , tps6594_rtc_cells,ARRAY_SIZE (tps6594_rtc_cells),NULL ,0 ,regmap_irq_get_domain (tps->irq_data));
@@ -465,5 +678,6 @@ int tps6594_device_init(struct tps6594 *tps, bool enable_crc)EXPORT_SYMBOL_GPL (tps6594_device_init);MODULE_AUTHOR ("Julien Panis <[email protected]>" ); +MODULE_AUTHOR ("Bhargav Raviprakash <[email protected]" );MODULE_DESCRIPTION ("TPS6594 Driver" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.25.1
PATCH RESEND 7/13 misc: tps6594-pfsm: Add TI TPS65224 PMIC PFSM
In reply to Bhargav RaviprakashAdd support for TPS65224 PFSM in the TPS6594 PFSM driver as they share significant functionality.
--- drivers/misc/tps6594-pfsm.c | 55 +++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 15 deletions(-)
drivers/misc/tps6594-pfsm.c +40 -15
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 /* -* PFSM (Pre-configurable Finite State Machine) driver for TI TPS6594/TPS6593/LP8764 PMICs +* PFSM (Pre-configurable Finite State Machine) driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs * * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ */
@@ -34,15 +34,17 @@#define TPS6594_FILE_TO_PFSM (f) container_of((f)->private_data, struct tps6594_pfsm, miscdev) -/** +/* * struct tps6594_pfsm - device private data structure * * @miscdev: misc device infos * @regmap: regmap for accessing the device registers +* @chip_id: chip identifier of the device */ struct tps6594_pfsm {struct miscdevice miscdev;struct regmap *regmap; +unsigned long chip_id; }; static ssize_t tps6594_pfsm_read(struct file *f, char __user *buf,
@@ -133,21 +135,29 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long astruct tps6594_pfsm *pfsm =TPS6594_FILE_TO_PFSM (f);struct pmic_state_opt state_opt;void __user *argp = (void __user *)arg; +unsigned int regmap_reg, mask;int ret = -ENOIOCTLCMD ;switch (cmd) {case PMIC_GOTO_STANDBY : -/* Disable LP mode */ - ret =regmap_clear_bits (pfsm->regmap,TPS6594_REG_RTC_CTRL_2 , -TPS6594_BIT_LP_STANDBY_SEL ); -if (ret) -return ret; +/* Disable LP mode on TPS6594 Family PMIC */ +if (pfsm->chip_id !=TPS65224 ) { + ret =regmap_clear_bits (pfsm->regmap,TPS6594_REG_RTC_CTRL_2 , +TPS6594_BIT_LP_STANDBY_SEL ); + +if (ret) +return ret; + }/* Force trigger */ ret =regmap_write_bits (pfsm->regmap,TPS6594_REG_FSM_I2C_TRIGGERS ,TPS6594_BIT_TRIGGER_I2C (0 ),TPS6594_BIT_TRIGGER_I2C (0 ));break ;case PMIC_GOTO_LP_STANDBY : +/* TPS65224 does not support LP STANDBY */ +if (pfsm->chip_id ==TPS65224 ) +return ret; +/* Enable LP mode */ ret =regmap_set_bits (pfsm->regmap,TPS6594_REG_RTC_CTRL_2 ,TPS6594_BIT_LP_STANDBY_SEL );
@@ -169,6 +179,10 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a TPS6594_BIT_NSLEEP1B | TPS6594_BIT_NSLEEP2B);break ;case PMIC_SET_MCU_ONLY_STATE : +/* TPS65224 does not support MCU_ONLY_STATE */ +if (pfsm->chip_id ==TPS65224 ) +return ret; +if (copy_from_user (&state_opt, argp,sizeof (state_opt)))return -EFAULT ;
@@ -192,14 +206,20 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long areturn -EFAULT ;/* Configure wake-up destination */ +if (pfsm->chip_id ==TPS65224 ) { + regmap_reg =TPS65224_REG_STARTUP_CTRL ; + mask =TPS65224_MASK_STARTUP_DEST ; + }else { + regmap_reg =TPS6594_REG_RTC_CTRL_2 ; + mask =TPS6594_MASK_STARTUP_DEST ; + } +if (state_opt.mcu_only_startup_dest) - ret =regmap_write_bits (pfsm->regmap,TPS6594_REG_RTC_CTRL_2 , -TPS6594_MASK_STARTUP_DEST , -TPS6594_STARTUP_DEST_MCU_ONLY ); + ret =regmap_write_bits (pfsm->regmap, regmap_reg, + mask,TPS6594_STARTUP_DEST_MCU_ONLY );else - ret =regmap_write_bits (pfsm->regmap,TPS6594_REG_RTC_CTRL_2 , -TPS6594_MASK_STARTUP_DEST , -TPS6594_STARTUP_DEST_ACTIVE ); + ret =regmap_write_bits (pfsm->regmap, regmap_reg, + mask,TPS6594_STARTUP_DEST_ACTIVE );if (ret)return ret;
@@ -210,8 +230,12 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long areturn ret;/* Modify NSLEEP1-2 bits */ - ret =regmap_clear_bits (pfsm->regmap,TPS6594_REG_FSM_NSLEEP_TRIGGERS , -TPS6594_BIT_NSLEEP2B ); +if (pfsm->chip_id ==TPS65224 ) + ret =regmap_clear_bits (pfsm->regmap,TPS6594_REG_FSM_NSLEEP_TRIGGERS , +TPS6594_BIT_NSLEEP1B ); +else + ret =regmap_clear_bits (pfsm->regmap,TPS6594_REG_FSM_NSLEEP_TRIGGERS , +TPS6594_BIT_NSLEEP2B );break ; }
@@ -262,6 +286,7 @@ static int tps6594_pfsm_probe(struct platform_device *pdev) tps->chip_id, tps->reg); pfsm->miscdev.fops = &tps6594_pfsm_fops; pfsm->miscdev.parent = dev->parent; + pfsm->chip_id = tps->chip_id;for (i =0 ; i < pdev->num_resources ; i++) { irq =platform_get_irq_byname (pdev, pdev->resource[i].name);
Signature · 1 line
2.25.1
PATCH RESEND 8/13 misc: tps6594-esm: reversion check limited to TPS6594 family
In reply to Bhargav RaviprakashThe reversion check is only applicable on TPS6594 family of PMICs. Conditionally add that check if the chip_id is one of the PMIC in the TPS6594 family.
--- drivers/misc/tps6594-esm.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/misc/tps6594-esm.c +11 -7
@@ -45,13 +45,17 @@ static int tps6594_esm_probe(struct platform_device *pdev)* As a consequence, ESM can not be used on those PMIC. * Check the version and return an error in case of revision 1. */ - ret =regmap_read (tps->regmap,TPS6594_REG_DEV_REV , &rev); -if (ret) -return dev_err_probe (dev, ret, -"Failed to read PMIC revision\n" ); -if (rev ==TPS6594_DEV_REV_1 ) -return dev_err_probe (dev, -ENODEV , -"ESM not supported for revision 1 PMIC\n" ); +if (tps->chip_id ==TPS6594 || + tps->chip_id ==TPS6593 || + tps->chip_id ==LP8764 ) { + ret =regmap_read (tps->regmap,TPS6594_REG_DEV_REV , &rev); +if (ret) +return dev_err_probe (dev, ret, +"Failed to read PMIC revision\n" ); +if (rev ==TPS6594_DEV_REV_1 ) +return dev_err_probe (dev, -ENODEV , +"ESM not supported for revision 1 PMIC\n" ); + }for (i =0 ; i < pdev->num_resources; i++) { irq =platform_get_irq_byname (pdev, pdev->resource[i].name);
Signature · 1 line
2.25.1
PATCH RESEND 9/13 misc: tps6594-esm: use regmap_field
In reply to Bhargav RaviprakashUse regmap_field and associated APIs to update the ESM_MODE_CFG and ESM_START registers. This helps in adding support for TPS65224 PMIC.
--- drivers/misc/tps6594-esm.c | 60 ++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 15 deletions(-)
drivers/misc/tps6594-esm.c +45 -15
@@ -15,6 +15,19 @@#define TPS6594_DEV_REV_1 0x08 +#define ESM_MODE_CFG_SET 0xff +#define ESM_START_SET 0xff +#define ESM_MODE_CFG_CLR 0x0 +#define ESM_START_CLR 0x0 + +static struct reg_field tps6594_esm_mode_cfg =REG_FIELD (TPS6594_REG_ESM_SOC_MODE_CFG ,5 ,6 ); +static struct reg_field tps6594_esm_start =REG_FIELD (TPS6594_REG_ESM_SOC_START_REG ,0 ,0 ); + +struct tps6594_esm { +struct regmap_field *esm_mode_cfg; +struct regmap_field *esm_start; +}; +static irqreturn_t tps6594_esm_isr (int irq,void *dev_id) {struct platform_device *pdev = dev_id;
@@ -34,6 +47,7 @@ static int tps6594_esm_probe(struct platform_device *pdev) {struct tps6594 *tps =dev_get_drvdata (pdev->dev.parent);struct device *dev = &pdev->dev; +struct tps6594_esm *esm;unsigned int rev;int irq;int ret;
@@ -69,13 +83,30 @@ static int tps6594_esm_probe(struct platform_device *pdev)return dev_err_probe (dev, ret,"Failed to request irq\n" ); } - ret =regmap_set_bits (tps->regmap,TPS6594_REG_ESM_SOC_MODE_CFG , -TPS6594_BIT_ESM_SOC_EN |TPS6594_BIT_ESM_SOC_ENDRV ); + esm =devm_kzalloc (dev,sizeof (struct tps6594_esm ),GFP_KERNEL ); +if (!esm) +return -ENOMEM ; + + esm->esm_mode_cfg =devm_regmap_field_alloc (dev, tps->regmap, tps6594_esm_mode_cfg); + esm->esm_start =devm_regmap_field_alloc (dev, tps->regmap, tps6594_esm_start); + +if (IS_ERR (esm->esm_mode_cfg)) { +dev_err (dev,"esm_mode_cfg reg field init failed\n" ); +return PTR_ERR (esm->esm_mode_cfg); + } + +if (IS_ERR (esm->esm_start)) { +dev_err (dev,"esm_start reg field init failed\n" ); +return PTR_ERR (esm->esm_start); + } + +platform_set_drvdata (pdev, esm); + + ret =regmap_field_write (esm->esm_mode_cfg,ESM_MODE_CFG_SET );if (ret)return dev_err_probe (dev, ret,"Failed to configure ESM\n" ); - ret =regmap_set_bits (tps->regmap,TPS6594_REG_ESM_SOC_START_REG , -TPS6594_BIT_ESM_SOC_START ); + ret =regmap_field_write (esm->esm_start,ESM_START_SET );if (ret)return dev_err_probe (dev, ret,"Failed to start ESM\n" );
@@ -87,19 +118,17 @@ static int tps6594_esm_probe(struct platform_device *pdev)static void tps6594_esm_remove (struct platform_device *pdev) { -struct tps6594 *tps =dev_get_drvdata (pdev->dev.parent);struct device *dev = &pdev->dev; +struct tps6594_esm *esm =platform_get_drvdata (pdev);int ret; - ret =regmap_clear_bits (tps->regmap,TPS6594_REG_ESM_SOC_START_REG , -TPS6594_BIT_ESM_SOC_START ); + ret =regmap_field_write (esm->esm_start,ESM_START_CLR );if (ret) {dev_err (dev,"Failed to stop ESM\n" ); goto out; } - ret =regmap_clear_bits (tps->regmap,TPS6594_REG_ESM_SOC_MODE_CFG , -TPS6594_BIT_ESM_SOC_EN |TPS6594_BIT_ESM_SOC_ENDRV ); + ret =regmap_field_write (esm->esm_mode_cfg,ESM_MODE_CFG_CLR );if (ret)dev_err (dev,"Failed to unconfigure ESM\n" );
@@ -110,11 +139,12 @@ static void tps6594_esm_remove(struct platform_device *pdev)static int tps6594_esm_suspend (struct device *dev) { -struct tps6594 *tps =dev_get_drvdata (dev->parent); + struct platform_device *pdev = container_of(dev, struct platform_device, dev); +struct tps6594_esm *esm =platform_get_drvdata (pdev); +int ret; - ret =regmap_clear_bits (tps->regmap,TPS6594_REG_ESM_SOC_START_REG , -TPS6594_BIT_ESM_SOC_START ); + ret =regmap_field_write (esm->esm_start,ESM_START_CLR );pm_runtime_put_sync (dev);
@@ -123,12 +153,12 @@ static int tps6594_esm_suspend(struct device *dev)static int tps6594_esm_resume (struct device *dev) { -struct tps6594 *tps =dev_get_drvdata (dev->parent); + struct platform_device *pdev = container_of(dev, struct platform_device, dev); +struct tps6594_esm *esm =platform_get_drvdata (pdev);pm_runtime_get_sync (dev); -return regmap_set_bits (tps->regmap,TPS6594_REG_ESM_SOC_START_REG , -TPS6594_BIT_ESM_SOC_START ); +return regmap_field_write (esm->esm_start,ESM_START_SET ); } static DEFINE_SIMPLE_DEV_PM_OPS(tps6594_esm_pm_ops, tps6594_esm_suspend, tps6594_esm_resume);
Signature · 1 line
2.25.1
PATCH RESEND 10/13 misc: tps6594-esm: Add TI TPS65224 PMIC ESM
In reply to Bhargav RaviprakashAdd support for TPS65224 Error Signal Monitor in the TPS6594 ESM driver as they share significant functionality.
--- drivers/misc/tps6594-esm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/misc/tps6594-esm.c +12 -3
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 /* -* ESM (Error Signal Monitor) driver for TI TPS6594/TPS6593/LP8764 PMICs +* ESM (Error Signal Monitor) driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs * * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ */
@@ -20,6 +20,8 @@#define ESM_MODE_CFG_CLR 0x0#define ESM_START_CLR 0x0 +static struct reg_field tps65224_esm_mode_cfg =REG_FIELD (TPS6594_REG_ESM_MCU_MODE_CFG ,5 ,6 ); +static struct reg_field tps65224_esm_start =REG_FIELD (TPS6594_REG_ESM_MCU_START_REG ,0 ,0 );static struct reg_field tps6594_esm_mode_cfg =REG_FIELD (TPS6594_REG_ESM_SOC_MODE_CFG ,5 ,6 );static struct reg_field tps6594_esm_start =REG_FIELD (TPS6594_REG_ESM_SOC_START_REG ,0 ,0 );
@@ -87,8 +89,14 @@ static int tps6594_esm_probe(struct platform_device *pdev)if (!esm)return -ENOMEM ; - esm->esm_mode_cfg =devm_regmap_field_alloc (dev, tps->regmap, tps6594_esm_mode_cfg); - esm->esm_start =devm_regmap_field_alloc (dev, tps->regmap, tps6594_esm_start); +if (tps->chip_id ==TPS65224 ) { + esm->esm_mode_cfg =devm_regmap_field_alloc (dev, tps->regmap, + tps65224_esm_mode_cfg); + esm->esm_start =devm_regmap_field_alloc (dev, tps->regmap, tps65224_esm_start); + }else { + esm->esm_mode_cfg =devm_regmap_field_alloc (dev, tps->regmap, tps6594_esm_mode_cfg); + esm->esm_start =devm_regmap_field_alloc (dev, tps->regmap, tps6594_esm_start); + }if (IS_ERR (esm->esm_mode_cfg)) {dev_err (dev,"esm_mode_cfg reg field init failed\n" );
@@ -176,5 +184,6 @@ module_platform_driver(tps6594_esm_driver);MODULE_ALIAS ("platform:tps6594-esm" );MODULE_AUTHOR ("Julien Panis <[email protected]>" ); +MODULE_AUTHOR ("Bhargav Raviprakash <[email protected]>" );MODULE_DESCRIPTION ("TPS6594 Error Signal Monitor Driver" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.25.1
PATCH RESEND 11/13 regulator: tps6594-regulator: Add TI TPS65224 PMIC regulators
In reply to Bhargav RaviprakashFrom: Nirmala Devi Mal Nadar <[email protected]>
Add support for TPS65224 regulators (bucks and LDOs) to TPS6594 driver as they have significant functional overlap.
TPS65224 PMIC has 4 buck regulators and 3 LDOs. BUCK12 can operate in dual phase.
The output voltages are configurable and are meant to supply power to the main processor and other components.
--- drivers/regulator/Kconfig | 4 +- drivers/regulator/tps6594-regulator.c | 244 +++++++++++++++++++++++--- 2 files changed, 218 insertions(+), 30 deletions(-)
drivers/regulator/Kconfig +3 -1
@@ -1563,13 +1563,15 @@ config REGULATOR_TPS6594 depends on MFD_TPS6594 && OF default MFD_TPS6594 help - This driver supports TPS6594 voltage regulator chips. + This driver supports TPS6594 series and TPS65224 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. + TPS65224 PMIC has 4 BUCKs and 3 LDOs. BUCK12 can be used in dual phase. + All BUCKs and LDOs volatge can be controlled through software. config REGULATOR_TPS6524X tristate "TI TPS6524X Power regulators"
drivers/regulator/tps6594-regulator.c +215 -29
377 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH RESEND 12/13 pinctrl: pinctrl-tps6594: Add TPS65224 PMIC pinctrl and GPIO
In reply to Bhargav RaviprakashFrom: Nirmala Devi Mal Nadar <[email protected]>
Add support for TPS65224 pinctrl and GPIOs to TPS6594 driver as they have significant functional overlap.
TPS65224 PMIC has 6 GPIOS which can be configured as GPIO or other dedicated device functions.
--- drivers/pinctrl/pinctrl-tps6594.c | 287 +++++++++++++++++++++++++----- 1 file changed, 246 insertions(+), 41 deletions(-)
drivers/pinctrl/pinctrl-tps6594.c +246 -41
@@ -14,8 +14,6 @@#include <linux/mfd/tps6594.h> -#define TPS6594_PINCTRL_PINS_NB 11 -#define TPS6594_PINCTRL_GPIO_FUNCTION 0#define TPS6594_PINCTRL_SCL_I2C2_CS_SPI_FUNCTION 1#define TPS6594_PINCTRL_TRIG_WDOG_FUNCTION 1
@@ -40,17 +38,40 @@#define TPS6594_PINCTRL_SYNCCLKOUT_FUNCTION_GPIO8 3#define TPS6594_PINCTRL_CLK32KOUT_FUNCTION_GPIO9 3 +/* TPS65224 pin muxval */ +#define TPS65224_PINCTRL_SDA_I2C2_SDO_SPI_FUNCTION 1 +#define TPS65224_PINCTRL_SCL_I2C2_CS_SPI_FUNCTION 1 +#define TPS65224_PINCTRL_VMON1_FUNCTION 1 +#define TPS65224_PINCTRL_VMON2_FUNCTION 1 +#define TPS65224_PINCTRL_WKUP_FUNCTION 1 +#define TPS65224_PINCTRL_NSLEEP2_FUNCTION 2 +#define TPS65224_PINCTRL_NSLEEP1_FUNCTION 2 +#define TPS65224_PINCTRL_SYNCCLKIN_FUNCTION 2 +#define TPS65224_PINCTRL_NERR_MCU_FUNCTION 2 +#define TPS65224_PINCTRL_NINT_FUNCTION 3 +#define TPS65224_PINCTRL_TRIG_WDOG_FUNCTION 3 +#define TPS65224_PINCTRL_PB_FUNCTION 3 +#define TPS65224_PINCTRL_ADC_IN_FUNCTION 3 + +/* TPS65224 Special muxval for recalcitrant pins */ +#define TPS65224_PINCTRL_NSLEEP2_FUNCTION_GPIO5 1 +#define TPS65224_PINCTRL_WKUP_FUNCTION_GPIO5 4 +#define TPS65224_PINCTRL_SYNCCLKIN_FUNCTION_GPIO5 3 +#define TPS6594_OFFSET_GPIO_SEL 5 -#define FUNCTION (fname, v) \ +#define TPS65224_NGPIO_PER_REG 6 +#define TPS6594_NGPIO_PER_REG 8 + +#define FUNCTION (dev_name, fname, v) \ { \ .pinfunction = PINCTRL_PINFUNCTION(#fname, \ - tps6594_##fname##_func_group_names, \ - ARRAY_SIZE(tps6594_##fname##_func_group_names)),\ + dev_name##_##fname##_func_group_names, \ + ARRAY_SIZE(dev_name##_##fname##_func_group_names)),\ .muxval = v, \ } -static const struct pinctrl_pin_desc tps6594_pins[TPS6594_PINCTRL_PINS_NB ] = { +static const struct pinctrl_pin_desc tps6594_pins[] = {PINCTRL_PIN (0 ,"GPIO0" ),PINCTRL_PIN (1 ,"GPIO1" ),PINCTRL_PIN (2 ,"GPIO2" ),PINCTRL_PIN (3 ,"GPIO3" ),PINCTRL_PIN (4 ,"GPIO4" ),PINCTRL_PIN (5 ,"GPIO5" ),
@@ -143,30 +164,127 @@ static const char *const tps6594_syncclkin_func_group_names[] = { "GPIO9", }; +static const struct pinctrl_pin_desc tps65224_pins[] = { +PINCTRL_PIN (0 ,"GPIO0" ),PINCTRL_PIN (1 ,"GPIO1" ), +PINCTRL_PIN (2 ,"GPIO2" ),PINCTRL_PIN (3 ,"GPIO3" ), +PINCTRL_PIN (4 ,"GPIO4" ),PINCTRL_PIN (5 ,"GPIO5" ), +}; + +static const char *const tps65224_gpio_func_group_names[] = { +"GPIO0" ,"GPIO1" ,"GPIO2" ,"GPIO3" ,"GPIO4" ,"GPIO5" , +}; + +static const char *const tps65224_sda_i2c2_sdo_spi_func_group_names[] = { +"GPIO0" , +}; + +static const char *const tps65224_nsleep2_func_group_names[] = { +"GPIO0" ,"GPIO5" , +}; + +static const char *const tps65224_nint_func_group_names[] = { +"GPIO0" , +}; + +static const char *const tps65224_scl_i2c2_cs_spi_func_group_names[] = { +"GPIO1" , +}; + +static const char *const tps65224_nsleep1_func_group_names[] = { +"GPIO1" ,"GPIO2" ,"GPIO3" , +}; + +static const char *const tps65224_trig_wdog_func_group_names[] = { +"GPIO1" , +}; + +static const char *const tps65224_vmon1_func_group_names[] = { +"GPIO2" , +}; + +static const char *const tps65224_pb_func_group_names[] = { +"GPIO2" , +}; + +static const char *const tps65224_vmon2_func_group_names[] = { +"GPIO3" , +}; + +static const char *const tps65224_adc_in_func_group_names[] = { +"GPIO3" ,"GPIO4" , +}; + +static const char *const tps65224_wkup_func_group_names[] = { +"GPIO4" ,"GPIO5" , +}; + +static const char *const tps65224_syncclkin_func_group_names[] = { +"GPIO4" ,"GPIO5" , +}; + +static const char *const tps65224_nerr_mcu_func_group_names[] = { +"GPIO5" , +}; +struct tps6594_pinctrl_function {struct pinfunction pinfunction;u8 muxval; }; +struct muxval_remap { +unsigned int group; +u8 muxval; +u8 remap; +}; + +struct muxval_remap tps65224_muxval_remap[] = { + {5 ,TPS6594_PINCTRL_DISABLE_WDOG_FUNCTION ,TPS65224_PINCTRL_WKUP_FUNCTION_GPIO5 }, + {5 ,TPS65224_PINCTRL_SYNCCLKIN_FUNCTION ,TPS65224_PINCTRL_SYNCCLKIN_FUNCTION_GPIO5 }, + {5 ,TPS65224_PINCTRL_NSLEEP2_FUNCTION ,TPS65224_PINCTRL_NSLEEP2_FUNCTION_GPIO5 }, +}; + +struct muxval_remap tps6594_muxval_remap[] = { + {8 ,TPS6594_PINCTRL_DISABLE_WDOG_FUNCTION ,TPS6594_PINCTRL_DISABLE_WDOG_FUNCTION_GPIO8 }, + {8 ,TPS6594_PINCTRL_SYNCCLKOUT_FUNCTION ,TPS6594_PINCTRL_SYNCCLKOUT_FUNCTION_GPIO8 }, + {9 ,TPS6594_PINCTRL_CLK32KOUT_FUNCTION ,TPS6594_PINCTRL_CLK32KOUT_FUNCTION_GPIO9 }, +}; +static const struct tps6594_pinctrl_function pinctrl_functions[] = { -FUNCTION (gpio,TPS6594_PINCTRL_GPIO_FUNCTION ), -FUNCTION (nsleep1,TPS6594_PINCTRL_NSLEEP1_FUNCTION ), -FUNCTION (nsleep2,TPS6594_PINCTRL_NSLEEP2_FUNCTION ), -FUNCTION (wkup1,TPS6594_PINCTRL_WKUP1_FUNCTION ), -FUNCTION (wkup2,TPS6594_PINCTRL_WKUP2_FUNCTION ), -FUNCTION (scl_i2c2_cs_spi,TPS6594_PINCTRL_SCL_I2C2_CS_SPI_FUNCTION ), -FUNCTION (nrstout_soc,TPS6594_PINCTRL_NRSTOUT_SOC_FUNCTION ), -FUNCTION (trig_wdog,TPS6594_PINCTRL_TRIG_WDOG_FUNCTION ), -FUNCTION (sda_i2c2_sdo_spi,TPS6594_PINCTRL_SDA_I2C2_SDO_SPI_FUNCTION ), -FUNCTION (clk32kout,TPS6594_PINCTRL_CLK32KOUT_FUNCTION ), -FUNCTION (nerr_soc,TPS6594_PINCTRL_NERR_SOC_FUNCTION ), -FUNCTION (sclk_spmi,TPS6594_PINCTRL_SCLK_SPMI_FUNCTION ), -FUNCTION (sdata_spmi,TPS6594_PINCTRL_SDATA_SPMI_FUNCTION ), -FUNCTION (nerr_mcu,TPS6594_PINCTRL_NERR_MCU_FUNCTION ), -FUNCTION (syncclkout,TPS6594_PINCTRL_SYNCCLKOUT_FUNCTION ), -FUNCTION (disable_wdog,TPS6594_PINCTRL_DISABLE_WDOG_FUNCTION ), -FUNCTION (pdog,TPS6594_PINCTRL_PDOG_FUNCTION ), -FUNCTION (syncclkin,TPS6594_PINCTRL_SYNCCLKIN_FUNCTION ), +FUNCTION (tps6594, gpio,TPS6594_PINCTRL_GPIO_FUNCTION ), +FUNCTION (tps6594, nsleep1,TPS6594_PINCTRL_NSLEEP1_FUNCTION ), +FUNCTION (tps6594, nsleep2,TPS6594_PINCTRL_NSLEEP2_FUNCTION ), +FUNCTION (tps6594, wkup1,TPS6594_PINCTRL_WKUP1_FUNCTION ), +FUNCTION (tps6594, wkup2,TPS6594_PINCTRL_WKUP2_FUNCTION ), +FUNCTION (tps6594, scl_i2c2_cs_spi,TPS6594_PINCTRL_SCL_I2C2_CS_SPI_FUNCTION ), +FUNCTION (tps6594, nrstout_soc,TPS6594_PINCTRL_NRSTOUT_SOC_FUNCTION ), +FUNCTION (tps6594, trig_wdog,TPS6594_PINCTRL_TRIG_WDOG_FUNCTION ), +FUNCTION (tps6594, sda_i2c2_sdo_spi,TPS6594_PINCTRL_SDA_I2C2_SDO_SPI_FUNCTION ), +FUNCTION (tps6594, clk32kout,TPS6594_PINCTRL_CLK32KOUT_FUNCTION ), +FUNCTION (tps6594, nerr_soc,TPS6594_PINCTRL_NERR_SOC_FUNCTION ), +FUNCTION (tps6594, sclk_spmi,TPS6594_PINCTRL_SCLK_SPMI_FUNCTION ), +FUNCTION (tps6594, sdata_spmi,TPS6594_PINCTRL_SDATA_SPMI_FUNCTION ), +FUNCTION (tps6594, nerr_mcu,TPS6594_PINCTRL_NERR_MCU_FUNCTION ), +FUNCTION (tps6594, syncclkout,TPS6594_PINCTRL_SYNCCLKOUT_FUNCTION ), +FUNCTION (tps6594, disable_wdog,TPS6594_PINCTRL_DISABLE_WDOG_FUNCTION ), +FUNCTION (tps6594, pdog,TPS6594_PINCTRL_PDOG_FUNCTION ), +FUNCTION (tps6594, syncclkin,TPS6594_PINCTRL_SYNCCLKIN_FUNCTION ), +}; + +static const struct tps6594_pinctrl_function tps65224_pinctrl_functions[] = { +FUNCTION (tps65224, gpio,TPS6594_PINCTRL_GPIO_FUNCTION ), +FUNCTION (tps65224, sda_i2c2_sdo_spi,TPS65224_PINCTRL_SDA_I2C2_SDO_SPI_FUNCTION ), +FUNCTION (tps65224, nsleep2,TPS65224_PINCTRL_NSLEEP2_FUNCTION ), +FUNCTION (tps65224, nint,TPS65224_PINCTRL_NINT_FUNCTION ), +FUNCTION (tps65224, scl_i2c2_cs_spi,TPS65224_PINCTRL_SCL_I2C2_CS_SPI_FUNCTION ), +FUNCTION (tps65224, nsleep1,TPS65224_PINCTRL_NSLEEP1_FUNCTION ), +FUNCTION (tps65224, trig_wdog,TPS65224_PINCTRL_TRIG_WDOG_FUNCTION ), +FUNCTION (tps65224, vmon1,TPS65224_PINCTRL_VMON1_FUNCTION ), +FUNCTION (tps65224, pb,TPS65224_PINCTRL_PB_FUNCTION ), +FUNCTION (tps65224, vmon2,TPS65224_PINCTRL_VMON2_FUNCTION ), +FUNCTION (tps65224, adc_in,TPS65224_PINCTRL_ADC_IN_FUNCTION ), +FUNCTION (tps65224, wkup,TPS65224_PINCTRL_WKUP_FUNCTION ), +FUNCTION (tps65224, syncclkin,TPS65224_PINCTRL_SYNCCLKIN_FUNCTION ), +FUNCTION (tps65224, nerr_mcu,TPS65224_PINCTRL_NERR_MCU_FUNCTION ), };struct tps6594_pinctrl {
@@ -201,7 +319,21 @@ static int tps6594_gpio_regmap_xlate(struct gpio_regmap *gpio,static int tps6594_pmx_func_cnt (struct pinctrl_dev *pctldev) { -return ARRAY_SIZE (pinctrl_functions); +struct tps6594_pinctrl *pinctrl =pinctrl_dev_get_drvdata (pctldev); +int func_cnt =0 ; + +switch (pinctrl->tps->chip_id) { +case TPS65224 : + func_cnt =ARRAY_SIZE (tps65224_pinctrl_functions); +break ; +case TPS6594 : + func_cnt =ARRAY_SIZE (pinctrl_functions); +break ; +default : +break ; + } + +return func_cnt; } static const char *tps6594_pmx_func_name(struct pinctrl_dev *pctldev,
@@ -229,10 +361,26 @@ static int tps6594_pmx_set(struct tps6594_pinctrl *pinctrl, unsigned int pin, u8 muxval) {u8 mux_sel_val = muxval <<TPS6594_OFFSET_GPIO_SEL ; +u8 mux_sel_mask =0 ; + +switch (pinctrl->tps->chip_id) { +case TPS65224 : + mux_sel_mask =TPS65224_MASK_GPIO_SEL ; +/* GPIO6 has a different mask in TPS65224*/ +if (pin ==5 ) + mux_sel_mask =TPS65224_MASK_GPIO_SEL_GPIO6 ; + mux_sel_mask =TPS6594_MASK_GPIO_SEL ; +break ; +case TPS6594 : + mux_sel_mask =TPS6594_MASK_GPIO_SEL ; +break ; +default : +break ; + }return regmap_update_bits (pinctrl->tps->regmap,TPS6594_REG_GPIOX_CONF (pin), -TPS6594_MASK_GPIO_SEL , mux_sel_val); + mux_sel_mask, mux_sel_val); } static int tps6594_pmx_set_mux(struct pinctrl_dev *pctldev,
@@ -240,16 +388,28 @@ static int tps6594_pmx_set_mux(struct pinctrl_dev *pctldev, {struct tps6594_pinctrl *pinctrl =pinctrl_dev_get_drvdata (pctldev);u8 muxval = pinctrl->funcs[function].muxval; +unsigned int remap_cnt =0 ; +struct muxval_remap *remap;/* Some pins don't have the same muxval for the same function... */ -if (group ==8 ) { -if (muxval ==TPS6594_PINCTRL_DISABLE_WDOG_FUNCTION ) - muxval =TPS6594_PINCTRL_DISABLE_WDOG_FUNCTION_GPIO8 ; -else if (muxval ==TPS6594_PINCTRL_SYNCCLKOUT_FUNCTION ) - muxval =TPS6594_PINCTRL_SYNCCLKOUT_FUNCTION_GPIO8 ; - }else if (group ==9 ) { -if (muxval ==TPS6594_PINCTRL_CLK32KOUT_FUNCTION ) - muxval =TPS6594_PINCTRL_CLK32KOUT_FUNCTION_GPIO9 ; +switch (pinctrl->tps->chip_id) { +case TPS65224 : + remap = tps65224_muxval_remap; + remap_cnt =ARRAY_SIZE (tps65224_muxval_remap); +break ; +case TPS6594 : + remap = tps6594_muxval_remap; + remap_cnt =ARRAY_SIZE (tps6594_muxval_remap); +break ; +default : +break ; + } + +for (unsigned int i =0 ; i < remap_cnt; i++) { +if (group == remap[i].group && muxval == remap[i].muxval) { + muxval = remap[i].remap; +break ; + } }return tps6594_pmx_set (pinctrl, group, muxval);
@@ -276,7 +436,21 @@ static const struct pinmux_ops tps6594_pmx_ops = {static int tps6594_groups_cnt (struct pinctrl_dev *pctldev) { -return ARRAY_SIZE (tps6594_pins); +struct tps6594_pinctrl *pinctrl =pinctrl_dev_get_drvdata (pctldev); +int num_pins =0 ; + +switch (pinctrl->tps->chip_id) { +case TPS65224 : + num_pins =ARRAY_SIZE (tps65224_pins); +break ; +case TPS6594 : + num_pins =ARRAY_SIZE (tps6594_pins); +break ; +default : +break ; + } + +return num_pins; } static int tps6594_group_pins(struct pinctrl_dev *pctldev,
@@ -320,8 +494,18 @@ static int tps6594_pinctrl_probe(struct platform_device *pdev)return -ENOMEM ; pctrl_desc->name =dev_name (dev); pctrl_desc->owner =THIS_MODULE ; - pctrl_desc->pins = tps6594_pins; - pctrl_desc->npins =ARRAY_SIZE (tps6594_pins); +switch (tps->chip_id) { +case TPS65224 : + pctrl_desc->pins = tps65224_pins; + pctrl_desc->npins =ARRAY_SIZE (tps65224_pins); +break ; +case TPS6594 : + pctrl_desc->pins = tps6594_pins; + pctrl_desc->npins =ARRAY_SIZE (tps6594_pins); +break ; +default : +break ; + } pctrl_desc->pctlops = &tps6594_pctrl_ops; pctrl_desc->pmxops = &tps6594_pmx_ops;
@@ -329,8 +513,18 @@ static int tps6594_pinctrl_probe(struct platform_device *pdev)if (!pinctrl)return -ENOMEM ; pinctrl->tps =dev_get_drvdata (dev->parent); - pinctrl->funcs = pinctrl_functions; - pinctrl->pins = tps6594_pins; +switch (pinctrl->tps->chip_id) { +case TPS65224 : + pinctrl->funcs = tps65224_pinctrl_functions; + pinctrl->pins = tps65224_pins; +break ; +case TPS6594 : + pinctrl->funcs = pinctrl_functions; + pinctrl->pins = tps6594_pins; +break ; +default : +break ; + } pinctrl->pctl_dev =devm_pinctrl_register (dev, pctrl_desc, pinctrl);if (IS_ERR (pinctrl->pctl_dev)) return dev_err_probe(dev, PTR_ERR(pinctrl->pctl_dev),
@@ -338,8 +532,18 @@ static int tps6594_pinctrl_probe(struct platform_device *pdev) config.parent = tps->dev; config.regmap = tps->regmap; - config.ngpio =TPS6594_PINCTRL_PINS_NB ; - config.ngpio_per_reg =8 ; +switch (pinctrl->tps->chip_id) { +case TPS65224 : + config.ngpio =ARRAY_SIZE (tps65224_gpio_func_group_names); + config.ngpio_per_reg =TPS65224_NGPIO_PER_REG ; +break ; +case TPS6594 : + config.ngpio =ARRAY_SIZE (tps6594_gpio_func_group_names); + config.ngpio_per_reg =TPS6594_NGPIO_PER_REG ; +break ; +default : +break ; + } config.reg_dat_base =TPS6594_REG_GPIO_IN_1 ; config.reg_set_base =TPS6594_REG_GPIO_OUT_1 ; config.reg_dir_out_base =TPS6594_REG_GPIOX_CONF (0 );
@@ -369,5 +573,6 @@ static struct platform_driver tps6594_pinctrl_driver = {module_platform_driver (tps6594_pinctrl_driver);MODULE_AUTHOR ("Esteban Blanc <[email protected]>" ); +MODULE_AUTHOR ("Nirmala Devi Mal Nadar <[email protected]>" );MODULE_DESCRIPTION ("TPS6594 pinctrl and GPIO driver" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.25.1
PATCH RESEND 13/13 arch: arm64: dts: ti: k3-am62p5-sk: Add TPS65224 PMIC support in AM62P dts
In reply to Bhargav RaviprakashAdd support for TPS65224 PMIC in device tree of AM62P EVM. Adds regulator configuration, pinmux configurations and pmic device nodes.
--- arch/arm64/boot/dts/ti/k3-am62p5-sk.dts | 95 +++++++++++++++++++++++++ 1 file changed, 95 insertions(+)
arch/arm64/boot/dts/ti/k3-am62p5-sk.dts +95 -0
@@ -112,6 +112,16 @@ vddshv_sdio: regulator-3 { bootph-all; }; + vcc_3v3_main: regulator-4 { + compatible = "regulator-fixed"; + regulator-name = "vcc_3v3_main"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vmain_pd>; + regulator-always-on; + regulator-boot-on; + }; + leds { compatible = "gpio-leds"; pinctrl-names = "default";
@@ -580,6 +590,12 @@ &main_uart1 { &mcu_pmx0 { bootph-all; + pmic_irq_pins_default: pmic-irq-default-pins { + pinctrl-single,pins = < + AM62PX_MCU_IOPAD(0x000, PIN_INPUT, 7) /* (B10) MCU_GPIO0_0 */ + >; + }; + wkup_uart0_pins_default: wkup-uart0-default-pins { pinctrl-single,pins = < AM62PX_MCU_IOPAD(0x02c, PIN_INPUT, 0) /* (C7) WKUP_UART0_CTSn */
@@ -589,6 +605,13 @@ AM62PX_MCU_IOPAD(0x028, PIN_OUTPUT, 0) /* (D7) WKUP_UART0_TXD */ >; bootph-all; }; + + wkup_i2c0_pins_default: wkup-i2c0-default-pins { + pinctrl-single,pins = < + AM62PX_MCU_IOPAD(0x04c, PIN_INPUT, 0) /* (A13) WKUP_I2C0_SCL */ + AM62PX_MCU_IOPAD(0x050, PIN_INPUT, 0) /* (C11) WKUP_I2C0_SDA */ + >; + }; }; &wkup_uart0 {
@@ -599,6 +622,78 @@ &wkup_uart0 { bootph-all; }; +&wkup_i2c0 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&wkup_i2c0_pins_default>; + clock-frequency = <400000>; + + tps65224: pmic@48 { + compatible = "ti,tps65224-q1"; + reg = <0x48>; + pinctrl-names = "default"; + pinctrl-0 = <&pmic_irq_pins_default>; + interrupt-parent = <&mcu_gpio0>; + interrupts = <0 IRQ_TYPE_EDGE_FALLING>; + ti,primary-pmic; + + gpio-controller; + #gpio-cells = <2>; + + buck12-supply = <&vcc_3v3_main>; + buck3-supply = <&vcc_3v3_main>; + buck4-supply = <&vcc_3v3_main>; + + ldo1-supply = <&vcc_3v3_main>; + ldo2-supply = <&vcc_3v3_main>; + ldo3-supply = <&vcc1v8_sys>; + + regulators { + vcc_core: buck12 { + regulator-name = "vcc_core_buck12"; + regulator-min-microvolt = <715000>; + regulator-max-microvolt = <895000>; + regulator-always-on; + }; + + vcc1v8_sys: buck3 { + regulator-name = "vcc1v8_sys_buck3"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + }; + + vcc1v1: buck4 { + regulator-name = "vcc1v1_buck4"; + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1100000>; + regulator-always-on; + }; + + vdda1v8: ldo1 { + regulator-name = "vdda1v8_ldo1"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + }; + + dvdd3v3: ldo2 { + regulator-name = "dvdd3v3_ldo2"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + + vcc_0v85: ldo3 { + regulator-name = "vcc_0v85_ldo3"; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <850000>; + regulator-always-on; + }; + }; + }; +}; + /* mcu_gpio0 and mcu_gpio_intr are reserved for mcu firmware usage */ &mcu_gpio0 { status = "reserved";
Signature · 1 line
2.25.1