TI TPS6594 PMIC support (RTC, pinctrl, regulators)
Subsystems (5)
v4 cover TI TPS6594 PMIC support (RTC, pinctrl, regulators)
TPS6594 is a Power Management IC which provides regulators and others features like GPIOs, RTC, watchdog, ESMs (Error Signal Monitor), and PFSM (Pre-configurable Finite State Machine). The SoC and the PMIC can communicate through the I2C or SPI interfaces.
TPS6594 is the super-set device while TPS6593 and LP8764 are derivatives.
This series adds support to TI TPS6594 PMIC and its derivatives.
This should be applied on top of other patch series:
- https://lore.kernel.org/all/[email protected]/
For core MFD driver
The features implemented in this series are:
- RTC (child device)
- Pinmux/GPIO (child device)
- Regulator (child device)
RTC description:
The TPS6594 family has an RTC built-in, except for LP8764. It provides time and an alarm.
Pinmux/GPIO:
TPS6594 family has 11 GPIOs. Those GPIO can also serve different functions such as I2C or SPI interface, watchdog disable functions. The driver provides both pinmuxing for the functions and GPIO capability.
Regulator:
TPS6594/TPS6593: 5 BUCKs and 4LDOs
LP8764: 4 BUCKs and no LDO
Bucks can be used in multipahse mode.
Changes since v1:
https://lore.kernel.org/all/[email protected]/
Rtc:
- Removed struct tps6594_rtc.
- Removed some dev_err messages.
- Removed some comments.
- Remove some whitespaces in comments and error messages.
- Check if RTC is running before reading a timestamp in read_rtc.
- Stop RTC at the end of probe to wait for a timestamp to be set.
- Add default MFD_TPS6594 to Kconfig.
Pinctrl:
- Removed #define DEBUG.
- Add default MFD_TPS6594 to Kconfig.
- Fix typo and reword help message of Kconfig.
Regulators:
Further to Mark Brown review:
- File header whole block C++ style.
- Configuring modes not supported: omit all mode operations
- Log the error before notifying.
- Request the interrupts while registering the regulators (then remove the lookup function).
Further to Matti review:
- Postponed: devm_regulator_irq_helper() and regulator_irq_map_event_simple() can probably be used but code. refactoring is not so trivial. This can be done later as an enhancement after this patch list is merged.
Buck Multi phase management:
- Multiphase property can take an array when 2 multi phase buck, buck12 and buck34.
- Configuration multi phase buck34 without multiphase buck12 is not supported (when only one multiphase, must be buck12). Not clear from the spec but confirmed by TI.
- Supported multiphase conficurations: buck12, buck123, buck1234, buck12 + buck34.
- All interrupts are attached to the multiphase buck (ie: for regulator buck12, buck1 & buck2 interrupts are registered).
Changes since v2:
https://lore.kernel.org/all/[email protected]/
Rtc:
- Add logic to avoid reinitializing a working clock.
- Fix some multiline comments format.
Regulators:
Further to Mark Brown review:
- Log the error before notifying.
- Request the interrupts while registering the regulators. Further to Krzysztof Kozlowski:
https://lore.kernel.org/all/[email protected]/
- Remove ti, multi-phase-id property which is redundant with buck dts naming rules.
Changes since v3:
https://lore.kernel.org/lkml/[email protected]/
RTC:
- Add wakeup source
Pinctrl:
- Switch to GPIO_REGMAP framework
Esteban Blanc (2):
rtc: tps6594: Add driver for TPS6594 RTC
pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
Jerome Neanne (1):
regulator: tps6594-regulator: Add driver for TI TPS6594 regulators
drivers/pinctrl/Kconfig | 31 ++ drivers/pinctrl/Makefile | 2 + drivers/pinctrl/pinctrl-tps6594.c | 301 +++++++++++++ drivers/regulator/Kconfig | 13 + drivers/regulator/Makefile | 1 + drivers/regulator/tps6594-regulator.c | 620 ++++++++++++++++++++++++++ drivers/rtc/Kconfig | 9 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-tps6594.c | 479 ++++++++++++++++++++ include/linux/mfd/tps6594.h | 3 +- 10 files changed, 1459 insertions(+), 1 deletion(-) create mode 100644 drivers/pinctrl/pinctrl-tps6594.c create mode 100644 drivers/regulator/tps6594-regulator.c create mode 100644 drivers/rtc/rtc-tps6594.c
Signature · 1 line
2.39.2
PATCH v4 1/3 rtc: tps6594: Add driver for TPS6594 RTC
TPS6594 PMIC is a MFD. This patch adds support for the RTC found inside TPS6594 family of PMIC.
Alarm is also supported.
--- drivers/rtc/Kconfig | 9 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-tps6594.c | 479 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 489 insertions(+) create mode 100644 drivers/rtc/rtc-tps6594.c
drivers/rtc/Kconfig +9 -0
@@ -578,6 +578,15 @@ config RTC_DRV_TPS6586X along with alarm. This driver supports the RTC driver for the TPS6586X RTC module. +config RTC_DRV_TPS6594 + tristate "TI TPS6594 RTC driver" + depends on MFD_TPS6594 + default MFD_TPS6594 + help + TI Power Management IC TPS6594 supports RTC functionality + along with alarm. This driver supports the RTC driver for + the TPS6594 RTC module. + config RTC_DRV_TPS65910 tristate "TI TPS65910 RTC driver" depends on MFD_TPS65910
drivers/rtc/Makefile +1 -0
@@ -175,6 +175,7 @@ obj-$(CONFIG_RTC_DRV_TEGRA) += rtc-tegra.o obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o obj-$(CONFIG_RTC_DRV_TI_K3) += rtc-ti-k3.o obj-$(CONFIG_RTC_DRV_TPS6586X) += rtc-tps6586x.o +obj-$(CONFIG_RTC_DRV_TPS6594) += rtc-tps6594.o obj-$(CONFIG_RTC_DRV_TPS65910) += rtc-tps65910.o obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o
drivers/rtc/rtc-tps6594.c new file +479 -0
479 lines not on this page · raw message
Signature · 1 line
2.39.2
Re: [PATCH v4 1/3] rtc: tps6594: Add driver for TPS6594 RTC
Fri, May 12, 2023 at 04:17:53PM +0200, Esteban Blanc kirjoitti:
Quoted 4 lines
TPS6594 PMIC is a MFD. This patch adds support for the RTC found inside TPS6594 family of PMIC.
Alarm is also supported.
...
Quoted 4 lines
+/*
+ * Min and max values supported with 'offset' interface (swapped sign)
+ * After conversion, the values does not exceed the range [-32767, 33767] whichCOMP_REGmust
+ * conform to
Please, format it better and do not forget to use proper punctuation (commas, periods, etc.).
Quoted 3 lines
+ */
drivers/rtc/rtc-tps6594.c new file +2
-0+#define MIN_OFFSET (-277774) +#define MAX_OFFSET (277774)
...
drivers/rtc/rtc-tps6594.c line 49
Quoted 2 lines
drivers/rtc/rtc-tps6594.c new file +2
-0+/* Multiplier for ppb conversions */ +#define PPB_MULT (1000000000LL)
We have something in units.h. Can you use generic macro?
...
drivers/rtc/rtc-tps6594.c line 63
Quoted 4 lines
drivers/rtc/rtc-tps6594.c new file +4
-0+ ret =regmap_update_bits (tps->regmap,TPS6594_REG_RTC_INTERRUPTS , +TPS6594_BIT_IT_ALARM , val); + +return ret;
return regmap_update_bits(...);
...
drivers/rtc/rtc-tps6594.c line 74
Quoted 4 lines
drivers/rtc/rtc-tps6594.c new file +4
-0+/* +* Set GET_TIME to 0. This way, next time we set GET_TIME to 1 we are sure to store an +* up-to-date timestamp +*/
Please, check all your multi-line comments for proper punctuation.
...
drivers/rtc/rtc-tps6594.c line 103
Quoted 1 line
drivers/rtc/rtc-tps6594.c new file +1
-0+/* Check if RTC is running. */
Please, keep a single style for the one-line comments (with or without period at the end).
drivers/rtc/rtc-tps6594.c line 198
Quoted 1 line
drivers/rtc/rtc-tps6594.c new file +1
-0+ alm->enabled = int_val &TPS6594_BIT_IT_ALARM ?1 :0 ;
Ternary is reduntand.
Review
Quoted 1 line
(quoted diff) +1
-0+ return ret;
Why not return 0 explicitly? Or do you return positive value?
...
drivers/rtc/rtc-tps6594.c line 258
Quoted 2 lines
drivers/rtc/rtc-tps6594.c new file +2
-0+ comp_data[0 ] = (u16 )value &0xFF ; + comp_data[1 ] = ((u16 )value >>8 ) &0xFF ;
Use proper bitwise type, i.e. __le16.
...
drivers/rtc/rtc-tps6594.c line 294
Quoted 1 line
drivers/rtc/rtc-tps6594.c new file +1
-0+ value = (u16 )comp_data[0 ] | ((u16 )comp_data[1 ] <<8 );
Ditto.
...
drivers/rtc/rtc-tps6594.c line 312
Quoted 2 lines
drivers/rtc/rtc-tps6594.c new file +2
-0+/* Convert from RTC calibration register format to ppb format */ + tmp = calibration * (s64 )PPB_MULT ;
Is casting really needed?
drivers/rtc/rtc-tps6594.c line 316
Quoted 4 lines
drivers/rtc/rtc-tps6594.c new file +4
-0+if (tmp <0 ) + tmp -=TICKS_PER_HOUR /2LL ; +else + tmp +=TICKS_PER_HOUR /2LL ;
Is it guaranteed to have no overflow here?
drivers/rtc/rtc-tps6594.c line 325
Quoted 9 lines
drivers/rtc/rtc-tps6594.c new file +9
-0+ tmp =div_s64 (tmp,TICKS_PER_HOUR ); + +/* +* Offset value operates in negative way, so swap sign. +* See 8.3.10.5, (32768 - COMP_REG) +*/ + *offset = (long )-tmp; + +return ret;
ret?!
drivers/rtc/rtc-tps6594.c line 331
Quoted 6 lines
drivers/rtc/rtc-tps6594.c new file +6
-0+} + +static int tps6594_rtc_set_offset (struct device *dev,long offset) +{ +int calibration; +s64 tmp;
Similar questions here as per above routine.
Quoted 17 lines
drivers/rtc/rtc-tps6594.c new file +17
-0+/* Make sure offset value is within supported range */ +if (offset <MIN_OFFSET || offset >MAX_OFFSET ) +return -ERANGE ; + +/* Convert from ppb format to RTC calibration register format */ + tmp = offset * (s64 )TICKS_PER_HOUR ; +if (tmp <0 ) + tmp -=PPB_MULT /2LL ; +else + tmp +=PPB_MULT /2LL ; + tmp =div_s64 (tmp,PPB_MULT ); + +/* Offset value operates in negative way, so swap sign */ + calibration = (int )-tmp; + +return tps6594_rtc_set_calibration (dev, calibration); +}
...
drivers/rtc/rtc-tps6594.c line 390
Quoted 8 lines
drivers/rtc/rtc-tps6594.c new file +7
-0+static int tps6594_rtc_probe (struct platform_device *pdev) +{ +struct tps6594 *tps; +struct rtc_device *rtc; +int irq; +int ret; + tps =dev_get_drvdata (pdev->dev.parent);
Can be united with definition of tps above.
...
drivers/rtc/rtc-tps6594.c line 412
Quoted 3 lines
drivers/rtc/rtc-tps6594.c new file +3
-0+/* RTC not running */ +if (ret ==0 ) { +/* Start rtc */
RTC for the sake of consistency.
But I think one of the comment is redundant.
...
drivers/rtc/rtc-tps6594.c line 418
Quoted 1 line
drivers/rtc/rtc-tps6594.c new file +1
-0+mdelay (100 );
Such long delays have to be explicitly elaborated (in the comment on top).
Quoted 1 line
(quoted diff) +1
-0+ }
...
drivers/rtc/rtc-tps6594.c line 443
Quoted 4 lines
drivers/rtc/rtc-tps6594.c new file +4
-0+ irq =platform_get_irq_byname (pdev,TPS6594_IRQ_NAME_ALARM ); +if (irq <0 ) { +dev_err (&pdev->dev,"Failed to get irq\n" ); +return irq;
return dev_err_probe(...);
Quoted 1 line
(quoted diff) +1
-0+ }
...
Review
Quoted 2 lines
(quoted diff) +2
-0+ dev_err(&pdev->dev, "Failed to request_threaded_irq\n"); + return ret;
Ditto.
...
drivers/rtc/rtc-tps6594.c line 457
Quoted 2 lines
drivers/rtc/rtc-tps6594.c new file +2
-0+dev_err (&pdev->dev,"Failed to init rtc as wakeup source\n" ); +return ret;
Ditto.
...
Quoted 1 line
+
Blank line is not needed.
Quoted 1 line
+module_platform_driver(tps6594_rtc_driver);
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 1/3] rtc: tps6594: Add driver for TPS6594 RTC
Quoted 5 lines · CEST,
Fri, May 12, 2023 at 04:17:53PM +0200, Esteban Blanc kirjoitti:
drivers/rtc/rtc-tps6594.c line 49
Quoted 2 lines
drivers/rtc/rtc-tps6594.c new file +2
-0+/* Multiplier for ppb conversions */ +#define PPB_MULT (1000000000LL)We have something in
units.h. Can you use generic macro?
I found GIGA, NANO and NANOHZ_PER_HZ that have the same value in units.h. However I'm not sure any of them have the correct meaning in this situation.
Quoted 6 lines
drivers/rtc/rtc-tps6594.c line 74
Quoted 4 lines
drivers/rtc/rtc-tps6594.c new file +4
-0+/* +* Set GET_TIME to 0. This way, next time we set GET_TIME to 1 we are sure to store an +* up-to-date timestamp +*/ Please, check all your multi-line comments for proper punctuation.
Ok. I will do my best.
Quoted 4 lines
drivers/rtc/rtc-tps6594.c line 103
Quoted 1 line
drivers/rtc/rtc-tps6594.c new file +1
-0+/* Check if RTC is running. */ Please, keep a single style for the one-line comments (with or without period at the end).
Sure.
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ return ret;Why not return 0 explicitly? Or do you return positive value?
I should return 0 here, you are right.
Quoted 4 lines
drivers/rtc/rtc-tps6594.c line 258
Quoted 2 lines
drivers/rtc/rtc-tps6594.c new file +2
-0+ comp_data[0 ] = (u16 )value &0xFF ; + comp_data[1 ] = ((u16 )value >>8 ) &0xFF ;Use proper bitwise type, i.e.
__le16.
I was not aware of theses kind of types. Thanks!
Quoted 4 lines
drivers/rtc/rtc-tps6594.c line 312
Quoted 2 lines
drivers/rtc/rtc-tps6594.c new file +2
-0+/* Convert from RTC calibration register format to ppb format */ + tmp = calibration * (s64 )PPB_MULT ;Is casting really needed?
No it's not. Thanks!
Quoted 6 lines
drivers/rtc/rtc-tps6594.c line 316
Quoted 4 lines
drivers/rtc/rtc-tps6594.c new file +4
-0+if (tmp <0 ) + tmp -=TICKS_PER_HOUR /2LL ; +else + tmp +=TICKS_PER_HOUR /2LL ;Is it guaranteed to have no overflow here?
We know from tps6594_rtc_set_offset that the loaded value can't be more than 277774 (register default value is 0), So tmp can't exceed 277774000000000 which is lower than 2^63-1. No overflow here.
TICK_PER_HOUR / 2LL = 117964800, so at the end of this computation, tmp can have a maximum value of 277774117964800 which is still inferior to 2^63-1.
Quoted 11 lines
drivers/rtc/rtc-tps6594.c line 325
Quoted 9 lines
drivers/rtc/rtc-tps6594.c new file +9
-0+ tmp =div_s64 (tmp,TICKS_PER_HOUR ); + +/* +* Offset value operates in negative way, so swap sign. +* See 8.3.10.5, (32768 - COMP_REG) +*/ + *offset = (long )-tmp; + +return ret;ret?!
That's a mistake. Thanks!
Quoted 7 lines
drivers/rtc/rtc-tps6594.c line 412
Quoted 3 lines
drivers/rtc/rtc-tps6594.c new file +3
-0+/* RTC not running */ +if (ret ==0 ) { +/* Start rtc */ RTC for the sake of consistency.
But I think one of the comment is redundant.
I will remove the second one
Quoted 3 lines
drivers/rtc/rtc-tps6594.c line 418
Quoted 1 line
drivers/rtc/rtc-tps6594.c new file +1
-0+mdelay (100 );Such long delays have to be explicitly elaborated (in the comment on top).
This should just not be there.
Best regards,
Signature · 2 lines
Esteban Blanc BayLibre
Re: [PATCH v4 1/3] rtc: tps6594: Add driver for TPS6594 RTC
Quoted 2 lines · Esteban Blanc
Quoted 1 line · CEST,
Fri, May 12, 2023 at 04:17:53PM +0200, Esteban Blanc kirjoitti:
...
Quoted 8 lines
Quoted 4 lines
drivers/rtc/rtc-tps6594.c line 49
Quoted 2 lines
drivers/rtc/rtc-tps6594.c new file +2
-0+/* Multiplier for ppb conversions */ +#define PPB_MULT (1000000000LL)We have something in
units.h. Can you use generic macro?I found GIGA, NANO and
NANOHZ_PER_HZthat have the same value inunits.h. However I'm not sure any of them have the correct meaning in this situation.
MULT[IPLIER] has no units AFAIU, so SI macro can be used, no? NANO or GIGA depends on what the actual sign of the exponent of the multiplier is. Write it on paper and check the exponent in the equation(s) and hence decide which one to use.
...
Quoted 7 lines
Quoted 6 lines
drivers/rtc/rtc-tps6594.c line 316
Quoted 4 lines
drivers/rtc/rtc-tps6594.c new file +4
-0+if (tmp <0 ) + tmp -=TICKS_PER_HOUR /2LL ; +else + tmp +=TICKS_PER_HOUR /2LL ;Is it guaranteed to have no overflow here?
Quoted 7 lines
We know from
tps6594_rtc_set_offsetthat the loaded value can't be more than 277774 (register default value is 0), Sotmpcan't exceed 277774000000000 which is lower than 2^63-1. No overflow here.
TICK_PER_HOUR/ 2LL = 117964800, so at the end of this computation,tmpcan have a maximum value of 277774117964800 which is still inferior to 2^63-1.
Please add a respective comment.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 1/3] rtc: tps6594: Add driver for TPS6594 RTC
Quoted 11 lines · Andy Shevchenko
Quoted 2 lines · Esteban Blanc
Quoted 1 line · CEST,
Fri, May 12, 2023 at 04:17:53PM +0200, Esteban Blanc kirjoitti:
...
Quoted 5 lines
Quoted 4 lines
drivers/rtc/rtc-tps6594.c line 49
Quoted 2 lines
drivers/rtc/rtc-tps6594.c new file +2
-0+/* Multiplier for ppb conversions */ +#define PPB_MULT (1000000000LL)We have something in
units.h. Can you use generic macro?
Quoted 8 lines
Quoted 3 lines
I found GIGA, NANO and
NANOHZ_PER_HZthat have the same value inunits.h. However I'm not sure any of them have the correct meaning in this situation.MULT[IPLIER] has no units AFAIU, so SI macro can be used, no? NANO or GIGA depends on what the actual sign of the exponent of the multiplier is. Write it on paper and check the exponent in the equation(s) and hence decide which one to use.
Thanks. I've checked and it should be NANO.
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
drivers/rtc/rtc-tps6594.c line 316
Quoted 4 lines
drivers/rtc/rtc-tps6594.c new file +4
-0+if (tmp <0 ) + tmp -=TICKS_PER_HOUR /2LL ; +else + tmp +=TICKS_PER_HOUR /2LL ;Is it guaranteed to have no overflow here?
We know from
tps6594_rtc_set_offsetthat the loaded value can't be more than 277774 (register default value is 0), Sotmpcan't exceed 277774000000000 which is lower than 2^63-1. No overflow here.
Quoted 5 lines
Quoted 3 lines
TICK_PER_HOUR/ 2LL = 117964800, so at the end of this computation,tmpcan have a maximum value of 277774117964800 which is still inferior to 2^63-1.Please add a respective comment.
I've reformatted this and put it in a SAFETY comment.
Thanks for your help,
Signature · 2 lines
Esteban Blanc BayLibre
PATCH v4 2/3 pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
In reply to Esteban BlancTI TPS6594 PMIC has 11 GPIOs which can be used
for different functions.
This patch adds a pinctrl and GPIO drivers in
order to use those functions.
--- drivers/pinctrl/Kconfig | 31 +++ drivers/pinctrl/Makefile | 2 + drivers/pinctrl/pinctrl-tps6594.c | 301 ++++++++++++++++++++++++++++++ include/linux/mfd/tps6594.h | 3 +- 4 files changed, 336 insertions(+), 1 deletion(-) create mode 100644 drivers/pinctrl/pinctrl-tps6594.c
drivers/pinctrl/Kconfig +31 -0
@@ -480,6 +480,37 @@ config PINCTRL_TB10X depends on OF && ARC_PLAT_TB10X select GPIOLIB +config PINCTRL_THUNDERBAY + tristate "Generic pinctrl and GPIO driver for Intel Thunder Bay SoC" + depends on ARCH_THUNDERBAY || (ARM64 && COMPILE_TEST) + depends on HAS_IOMEM + select PINMUX + select PINCONF + select GENERIC_PINCONF + select GENERIC_PINCTRL_GROUPS + select GENERIC_PINMUX_FUNCTIONS + select GPIOLIB + select GPIOLIB_IRQCHIP + select GPIO_GENERIC + help + This selects pin control driver for the Intel Thunder Bay SoC. + It provides pin config functions such as pull-up, pull-down, + interrupt, drive strength, sec lock, Schmitt trigger, slew + rate control and direction control. This module will be + called as pinctrl-thunderbay. + +config PINCTRL_TPS6594 + tristate "Pinctrl and GPIO driver for TI TPS6594 PMIC" + depends on MFD_TPS6594 + default MFD_TPS6594 + select PINMUX + select GPIOLIB + select REGMAP + select GPIO_REGMAP + help + This driver supports GPIOs and pinmuxing for the TPS6594 + PMICs chip family. + config PINCTRL_ZYNQ bool "Pinctrl driver for Xilinx Zynq" depends on ARCH_ZYNQ
drivers/pinctrl/Makefile +2 -0
@@ -49,6 +49,8 @@ obj-$(CONFIG_PINCTRL_ST) += pinctrl-st.o obj-$(CONFIG_PINCTRL_STMFX) += pinctrl-stmfx.o obj-$(CONFIG_PINCTRL_SX150X) += pinctrl-sx150x.o obj-$(CONFIG_PINCTRL_TB10X) += pinctrl-tb10x.o +obj-$(CONFIG_PINCTRL_THUNDERBAY) += pinctrl-thunderbay.o +obj-$(CONFIG_PINCTRL_TPS6594) += pinctrl-tps6594.o obj-$(CONFIG_PINCTRL_ZYNQMP) += pinctrl-zynqmp.o obj-$(CONFIG_PINCTRL_ZYNQ) += pinctrl-zynq.o
drivers/pinctrl/pinctrl-tps6594.c new file +301 -0
301 lines not on this page · raw message
include/linux/mfd/tps6594.h +2 -1
@@ -47,7 +47,8 @@ enum pmic_id {#define TPS6594_REG_VMON2_PG_WINDOW 0x2f#define TPS6594_REG_VMON2_PG_LEVEL 0x30 -#define TPS6594_REG_GPIOX_CONF (gpio_inst) (0x31 + (gpio_inst)) +#define TPS6594_REG_GPIO1_CONF 0x31 +#define TPS6594_REG_GPIOX_CONF (gpio_inst) (TPS6594_REG_GPIO1_CONF + (gpio_inst))#define TPS6594_REG_NPWRON_CONF 0x3c#define TPS6594_REG_GPIO_OUT_1 0x3d#define TPS6594_REG_GPIO_OUT_2 0x3e
Signature · 1 line
2.39.2
Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
Fri, May 12, 2023 at 04:17:54PM +0200, Esteban Blanc kirjoitti:
Quoted 5 lines
TI TPS6594 PMIC has 11 GPIOs which can be used
for different functions.This patch adds a pinctrl and GPIO drivers in
order to use those functions.
...
Quoted 1 line
+config
PINCTRL_THUNDERBAY
Is it correct name? To me sounds not. The problem is that you use platform name for the non-platform-wide pin control, i.e. for PMIC exclusively. Did I miss anything?
drivers/pinctrl/Kconfig config PINCTRL_TB10X · line 485
Quoted 2 lines
drivers/pinctrl/Kconfig +2
-0+ tristate "Generic pinctrl and GPIO driver for Intel Thunder Bay SoC" + depends on ARCH_THUNDERBAY || (ARM64 && COMPILE_TEST)
This doesn't look correct, but I remember some Kconfig options that are using this way of dependency.
Quoted 5 lines
drivers/pinctrl/Kconfig +5
-0+ depends on HAS_IOMEM + select PINMUX + select PINCONF + select GENERIC_PINCONF + select GENERIC_PINCTRL_GROUPS
drivers/pinctrl/Kconfig config PINCTRL_TB10X · line 500
Quoted 10 lines
drivers/pinctrl/Kconfig +10
-0+ select GENERIC_PINMUX_FUNCTIONS + select GPIOLIB + select GPIOLIB_IRQCHIP + select GPIO_GENERIC + help + This selects pin control driver for the Intel Thunder Bay SoC. + It provides pin config functions such as pull-up, pull-down, + interrupt, drive strength, sec lock, Schmitt trigger, slew + rate control and direction control. This module will be + called as pinctrl-thunderbay.
Ah, the above simply a mistake. right?
Why is it in this patch?
drivers/pinctrl/Kconfig config PINCTRL_TB10X · line 512
Quoted 11 lines
drivers/pinctrl/Kconfig +11
-0+config PINCTRL_TPS6594 + tristate "Pinctrl and GPIO driver for TI TPS6594 PMIC" + depends on MFD_TPS6594 + default MFD_TPS6594 + select PINMUX + select GPIOLIB + select REGMAP + select GPIO_REGMAP + help + This driver supports GPIOs and pinmuxing for the TPS6594 + PMICs chip family.
Module name?
...
Quoted 1 line
+obj-$(CONFIG_PINCTRL_THUNDERBAY) += pinctrl-thunderbay.o
Huh?!
Quoted 1 line
+obj-$(CONFIG_PINCTRL_TPS6594) += pinctrl-tps6594.o
...
drivers/pinctrl/pinctrl-tps6594.c line 12
Quoted 5 lines
drivers/pinctrl/pinctrl-tps6594.c new file +5
-0+#include <linux/gpio/regmap.h> +#include <linux/gpio/driver.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/pinctrl/pinmux.h>
Ordered?
...
drivers/pinctrl/pinctrl-tps6594.c line 55
Quoted 3 lines
drivers/pinctrl/pinctrl-tps6594.c new file +3
-0+static const char *groups_name[TPS6594_PINCTRL_PINS_NB ] = { +"GPIO0" ,"GPIO1" ,"GPIO2" ,"GPIO3" ,"GPIO4" ,"GPIO5" , +"GPIO6" ,"GPIO7" ,"GPIO8" ,"GPIO9" ,"GPIO10"
Leave trailing comma even for known size.
Quoted 1 line
+};
...
drivers/pinctrl/pinctrl-tps6594.c line 62
Quoted 5 lines
drivers/pinctrl/pinctrl-tps6594.c new file +5
-0+struct tps6594_pinctrl_function { +const char *name; +u8 muxval; +const char **groups; +unsigned long ngroups;
We have struct pinfunction. Use it here (as embedded).
Quoted 1 line
+};
...
drivers/pinctrl/pinctrl-tps6594.c line 67
Quoted 3 lines
drivers/pinctrl/pinctrl-tps6594.c new file +3
-0+static const struct tps6594_pinctrl_function pinctrl_functions[] = { + {"gpio" ,TPS6594_PINCTRL_GPIO_FUNCTION , groups_name, +TPS6594_PINCTRL_PINS_NB },
Here and further use PINCTRL_PINFUNCTION() macro.
Quoted 1 line
+};
...
drivers/pinctrl/pinctrl-tps6594.c line 222
Quoted 7 lines
drivers/pinctrl/pinctrl-tps6594.c new file +7
-0+static int tps6594_group_pins (struct pinctrl_dev *pctldev, +unsigned int selector,const unsigned int **pins, +unsigned int *num_pins) +{ +struct tps6594_pinctrl *pinctrl =pinctrl_dev_get_drvdata (pctldev); + + *pins = (unsigned int *)&pinctrl->pins[selector];
Why casting?
Quoted 4 lines
drivers/pinctrl/pinctrl-tps6594.c new file +4
-0+ *num_pins =1 ; + +return 0 ; +}
...
drivers/pinctrl/pinctrl-tps6594.c line 268
Quoted 2 lines
drivers/pinctrl/pinctrl-tps6594.c new file +2
-0+ pinctrl->pctl_dev = +devm_pinctrl_register (&pdev->dev, pctrl_desc, pinctrl);
One line?
drivers/pinctrl/pinctrl-tps6594.c line 271
Quoted 3 lines
drivers/pinctrl/pinctrl-tps6594.c new file +3
-0+if (IS_ERR (pinctrl->pctl_dev)) { +dev_err (&pdev->dev,"Couldn't register pinctrl driver\n" ); +return PTR_ERR (pinctrl->pctl_dev);
return dev_err_probe(...);
Quoted 1 line
(quoted diff) +1
-0+ }
...
drivers/pinctrl/pinctrl-tps6594.c line 286
Quoted 4 lines
drivers/pinctrl/pinctrl-tps6594.c new file +4
-0+ pinctrl->gpio_regmap =devm_gpio_regmap_register (&pdev->dev, &config); +if (IS_ERR (pinctrl->gpio_regmap)) { +dev_err (&pdev->dev,"Couldn't register gpio_regmap driver\n" ); +return PTR_ERR (pinctrl->pctl_dev);
Ditto.
Quoted 4 lines
drivers/pinctrl/pinctrl-tps6594.c new file +4
-0+ } + +return 0 ; +}
...
include/linux/mfd/tps6594.h enum pmic_id { · line 51
Quoted 3 lines
include/linux/mfd/tps6594.h +2
-1-#define TPS6594_REG_GPIOX_CONF (gpio_inst) (0x31 + (gpio_inst)) +#define TPS6594_REG_GPIO1_CONF 0x31 +#define TPS6594_REG_GPIOX_CONF (gpio_inst) (TPS6594_REG_GPIO1_CONF + (gpio_inst))
Why? The original code with parameter 0 will issue the same.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
Quoted 31 lines · CEST,
Fri, May 12, 2023 at 04:17:54PM +0200, Esteban Blanc kirjoitti:
Quoted 5 lines
TI TPS6594 PMIC has 11 GPIOs which can be used
for different functions.This patch adds a pinctrl and GPIO drivers in
order to use those functions....
Quoted 1 line
+config
PINCTRL_THUNDERBAYIs it correct name? To me sounds not. The problem is that you use platform name for the non-platform-wide pin control, i.e. for PMIC exclusively. Did I miss anything?
drivers/pinctrl/Kconfig config PINCTRL_TB10X · line 485
Quoted 2 lines
drivers/pinctrl/Kconfig +2
-0+ tristate "Generic pinctrl and GPIO driver for Intel Thunder Bay SoC" + depends on ARCH_THUNDERBAY || (ARM64 && COMPILE_TEST)This doesn't look correct, but I remember some
Kconfigoptions that are using this way of dependency.Quoted 10 lines
drivers/pinctrl/Kconfig +10
-0+ depends on HAS_IOMEM + select PINMUX + select PINCONF + select GENERIC_PINCONF + select GENERIC_PINCTRL_GROUPS + select GENERIC_PINMUX_FUNCTIONS + select GPIOLIB + select GPIOLIB_IRQCHIP + select GPIO_GENERIC + help
Quoted 8 lines
drivers/pinctrl/Kconfig config PINCTRL_TB10X · line 500
Quoted 5 lines
drivers/pinctrl/Kconfig +5
-0+ This selects pin control driver for the Intel Thunder Bay SoC. + It provides pin config functions such as pull-up, pull-down, + interrupt, drive strength, sec lock, Schmitt trigger, slew + rate control and direction control. This module will be + called as pinctrl-thunderbay.Ah, the above simply a mistake. right?
Why is it in this patch?
I respond to all comments about PINCTRL_THUNDERBAY.
It is indeed a mistake on my side. I failed my rebase on 6.4-rc1... I will fix it for the next version.
Sorry about this...
Quoted 5 lines
Quoted 5 lines
drivers/pinctrl/Kconfig +5
-0+config PINCTRL_TPS6594 + tristate "Pinctrl and GPIO driver for TI TPS6594 PMIC" + depends on MFD_TPS6594 + default MFD_TPS6594 + select PINMUX
Quoted 8 lines
drivers/pinctrl/Kconfig config PINCTRL_TB10X · line 512
Quoted 6 lines
drivers/pinctrl/Kconfig +6
-0+ select GPIOLIB + select REGMAP + select GPIO_REGMAP + help + This driver supports GPIOs and pinmuxing for the TPS6594 + PMICs chip family.Module name?
I'm not sure to understand what you are looking for. Something like this ?:
To compile this driver as a module, choose M here: the module will be called pinctrl-tps6594.
Quoted 3 lines
Quoted 1 line
+obj-$(CONFIG_PINCTRL_THUNDERBAY) += pinctrl-thunderbay.o
Huh?!
Same as for Kconfig file, it's a mistake.
Quoted 8 lines
drivers/pinctrl/pinctrl-tps6594.c line 12
Quoted 5 lines
drivers/pinctrl/pinctrl-tps6594.c new file +5
-0+#include <linux/gpio/regmap.h> +#include <linux/gpio/driver.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/pinctrl/pinmux.h> Ordered?
It's not, I fix this.
Quoted 9 lines
drivers/pinctrl/pinctrl-tps6594.c line 222
Quoted 7 lines
drivers/pinctrl/pinctrl-tps6594.c new file +7
-0+static int tps6594_group_pins (struct pinctrl_dev *pctldev, +unsigned int selector,const unsigned int **pins, +unsigned int *num_pins) +{ +struct tps6594_pinctrl *pinctrl =pinctrl_dev_get_drvdata (pctldev); + + *pins = (unsigned int *)&pinctrl->pins[selector];Why casting?
It's an error, thanks.
Quoted 4 lines
drivers/pinctrl/pinctrl-tps6594.c line 268
Quoted 2 lines
drivers/pinctrl/pinctrl-tps6594.c new file +2
-0+ pinctrl->pctl_dev = +devm_pinctrl_register (&pdev->dev, pctrl_desc, pinctrl);One line?
I use clang-format quite extensively so I would rather keep it like that to still be able to just run it over the whole file without having to fix this line every time.
If you feel like I should not respect the 80 columns recommendation, I will fix it.
Quoted 5 lines
drivers/pinctrl/pinctrl-tps6594.c line 271
Quoted 3 lines
drivers/pinctrl/pinctrl-tps6594.c new file +3
-0+if (IS_ERR (pinctrl->pctl_dev)) { +dev_err (&pdev->dev,"Couldn't register pinctrl driver\n" ); +return PTR_ERR (pinctrl->pctl_dev);return dev_err_probe(...);
Did not know this one, I will use it. Thanks.
Quoted 5 lines
include/linux/mfd/tps6594.h enum pmic_id { · line 51
Quoted 3 lines
include/linux/mfd/tps6594.h +2
-1-#define TPS6594_REG_GPIOX_CONF (gpio_inst) (0x31 + (gpio_inst)) +#define TPS6594_REG_GPIO1_CONF 0x31 +#define TPS6594_REG_GPIOX_CONF (gpio_inst) (TPS6594_REG_GPIO1_CONF + (gpio_inst))Why? The original code with parameter 0 will issue the same.
I felt that replacing 0x31 with a constant would make the computation in TPS6594_REG_GPIOX_CONFIG more understandable. What do you think?
Thanks for your time. Sorry again about this "thunderbay" confusion... Note for the future, don't send patches on Fridays :)
Best regards,
Signature · 2 lines
Esteban Blanc BayLibre
Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
Quoted 2 lines · Esteban Blanc
Quoted 1 line · CEST,
Fri, May 12, 2023 at 04:17:54PM +0200, Esteban Blanc kirjoitti:
...
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
drivers/pinctrl/Kconfig +11
-0+config PINCTRL_TPS6594 + tristate "Pinctrl and GPIO driver for TI TPS6594 PMIC" + depends on MFD_TPS6594 + default MFD_TPS6594 + select PINMUX + select GPIOLIB + select REGMAP + select GPIO_REGMAP + help + This driver supports GPIOs and pinmuxing for the TPS6594 + PMICs chip family.
Quoted 7 lines
Quoted 1 line
Module name?
I'm not sure to understand what you are looking for. Something like this ?:
To compile this driver as a module, choose M here: the module will be called pinctrl-tps6594.
Yes.
...
Quoted 10 lines
Quoted 4 lines
drivers/pinctrl/pinctrl-tps6594.c line 268
Quoted 2 lines
drivers/pinctrl/pinctrl-tps6594.c new file +2
-0+ pinctrl->pctl_dev = +devm_pinctrl_register (&pdev->dev, pctrl_desc, pinctrl);One line?
I use clang-format quite extensively so I would rather keep it like that to still be able to just run it over the whole file without having to fix this line every time.
If you feel like I should not respect the 80 columns recommendation, I will fix it.
As you wish.
...
Quoted 8 lines
Quoted 5 lines
include/linux/mfd/tps6594.h enum pmic_id { · line 51
Quoted 3 lines
include/linux/mfd/tps6594.h +2
-1-#define TPS6594_REG_GPIOX_CONF (gpio_inst) (0x31 + (gpio_inst)) +#define TPS6594_REG_GPIO1_CONF 0x31 +#define TPS6594_REG_GPIOX_CONF (gpio_inst) (TPS6594_REG_GPIO1_CONF + (gpio_inst))Why? The original code with parameter 0 will issue the same.
I felt that replacing
0x31with a constant would make the computation inTPS6594_REG_GPIOX_CONFIGmore understandable. What do you think?
The question is why that register is so special that you need to have it as a constant explicitly?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Esteban Blanc
Quoted 1 line · CEST,
Fri, May 12, 2023 at 04:17:54PM +0200, Esteban Blanc kirjoitti:
...
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
include/linux/mfd/tps6594.h enum pmic_id { · line 51
Quoted 3 lines
include/linux/mfd/tps6594.h +2
-1-#define TPS6594_REG_GPIOX_CONF (gpio_inst) (0x31 + (gpio_inst)) +#define TPS6594_REG_GPIO1_CONF 0x31 +#define TPS6594_REG_GPIOX_CONF (gpio_inst) (TPS6594_REG_GPIO1_CONF + (gpio_inst))Why? The original code with parameter 0 will issue the same.
I felt that replacing
0x31with a constant would make the computation inTPS6594_REG_GPIOX_CONFIGmore understandable. What do you think?The question is why that register is so special that you need to have it as a constant explicitly?
It is not special, it's just the first one of the serie of config registers. I felt like just having 0x31 without context was a bit weird
Best regards,
Signature · 2 lines
Esteban Blanc BayLibre
Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
Quoted 4 lines · Esteban Blanc
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Esteban Blanc
Quoted 1 line · CEST,
Fri, May 12, 2023 at 04:17:54PM +0200, Esteban Blanc kirjoitti:
...
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
include/linux/mfd/tps6594.h enum pmic_id { · line 51
Quoted 3 lines
include/linux/mfd/tps6594.h +2
-1-#define TPS6594_REG_GPIOX_CONF (gpio_inst) (0x31 + (gpio_inst)) +#define TPS6594_REG_GPIO1_CONF 0x31 +#define TPS6594_REG_GPIOX_CONF (gpio_inst) (TPS6594_REG_GPIO1_CONF + (gpio_inst))Why? The original code with parameter 0 will issue the same.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I felt that replacing
0x31with a constant would make the computation inTPS6594_REG_GPIOX_CONFIGmore understandable. What do you think?The question is why that register is so special that you need to have it as a constant explicitly?
It is not special, it's just the first one of the serie of config registers. I felt like just having
0x31without context was a bit weird
I'm not sure I understand what 'context' you are talking about. This is pretty normal to have two kind of definitions (depending on the case):
1/
#define FOO_1 ... #define FOO_2 ...
and so on
2/
#define FOO(x) (... (x) ...)
Having a mix of them seems quite unusual.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
Quoted 17 lines · Andy Shevchenko
Quoted 4 lines · Esteban Blanc
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Esteban Blanc
Quoted 1 line · CEST,
Fri, May 12, 2023 at 04:17:54PM +0200, Esteban Blanc kirjoitti:
...
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
include/linux/mfd/tps6594.h enum pmic_id { · line 51
Quoted 3 lines
include/linux/mfd/tps6594.h +2
-1-#define TPS6594_REG_GPIOX_CONF (gpio_inst) (0x31 + (gpio_inst)) +#define TPS6594_REG_GPIO1_CONF 0x31 +#define TPS6594_REG_GPIOX_CONF (gpio_inst) (TPS6594_REG_GPIO1_CONF + (gpio_inst))Why? The original code with parameter 0 will issue the same.
I felt that replacing
0x31with a constant would make the computation inTPS6594_REG_GPIOX_CONFIGmore understandable. What do you think?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The question is why that register is so special that you need to have it as a constant explicitly?
It is not special, it's just the first one of the serie of config registers. I felt like just having
0x31without context was a bit weirdI'm not sure I understand what 'context' you are talking about.
I was trying to convey the fact that 0x31 was representing TPS6594_REG_GPIO1_CONF address. This way when looking at TPS6594_REG_GPIOX_CONF(...), one will better understand that this macro is just about offsetting from the first GPIO_CONF register.
Quoted 6 lines
This is pretty normal to have two kind of definitions (depending on the case):
1/#define FOO_1 ... #define FOO_2 ...
Quoted 8 lines
and so on
2/
#define FOO(x) (... (x) ...)Having a mix of them seems quite unusual.
I did not know that. I will revert this change for next version then.
Thanks again for your time. Best regards,
Signature · 2 lines
Esteban Blanc BayLibre
Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
Quoted 6 lines · Esteban Blanc
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Esteban Blanc
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Esteban Blanc
Quoted 1 line · CEST,
Fri, May 12, 2023 at 04:17:54PM +0200, Esteban Blanc kirjoitti:
...
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-1-#define TPS6594_REG_GPIOX_CONF(gpio_inst) (0x31 + (gpio_inst)) +#define TPS6594_REG_GPIO1_CONF 0x31 +#define TPS6594_REG_GPIOX_CONF(gpio_inst) (TPS6594_REG_GPIO1_CONF + (gpio_inst))Why? The original code with parameter 0 will issue the same.
I felt that replacing
0x31with a constant would make the computation inTPS6594_REG_GPIOX_CONFIGmore understandable. What do you think?The question is why that register is so special that you need to have it as a constant explicitly?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
It is not special, it's just the first one of the serie of config registers. I felt like just having
0x31without context was a bit weirdI'm not sure I understand what 'context' you are talking about.
I was trying to convey the fact that
0x31was representingTPS6594_REG_GPIO1_CONFaddress. This way when looking atTPS6594_REG_GPIOX_CONF(...), one will better understand that this macro is just about offsetting from the firstGPIO_CONFregister.
You can add a comment on top of the macro, so anybody can read and see what this macro is doing.
Quoted 6 lines
Quoted 6 lines
This is pretty normal to have two kind of definitions (depending on the case):
1/#define FOO_1 ... #define FOO_2 ...
Quoted 8 lines
Quoted 7 lines
and so on
2/
#define FOO(x) (... (x) ...)Having a mix of them seems quite unusual.
I did not know that. I will revert this change for next version then.
Don't get me wrong, it's possible to have, but since it's unusual it needs to be well justified. In the change you proposed you have changed that, but I haven't seen where the new definition is used (in *.c files).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
Quoted 25 lines · Andy Shevchenko
Quoted 6 lines · Esteban Blanc
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Esteban Blanc
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Esteban Blanc
Quoted 1 line · CEST,
Fri, May 12, 2023 at 04:17:54PM +0200, Esteban Blanc kirjoitti:
...
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-1-#define TPS6594_REG_GPIOX_CONF(gpio_inst) (0x31 + (gpio_inst)) +#define TPS6594_REG_GPIO1_CONF 0x31 +#define TPS6594_REG_GPIOX_CONF(gpio_inst) (TPS6594_REG_GPIO1_CONF + (gpio_inst))Why? The original code with parameter 0 will issue the same.
I felt that replacing
0x31with a constant would make the computation inTPS6594_REG_GPIOX_CONFIGmore understandable. What do you think?The question is why that register is so special that you need to have it as a constant explicitly?
It is not special, it's just the first one of the serie of config registers. I felt like just having
0x31without context was a bit weird
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
I'm not sure I understand what 'context' you are talking about.
I was trying to convey the fact that
0x31was representingTPS6594_REG_GPIO1_CONFaddress. This way when looking atTPS6594_REG_GPIOX_CONF(...), one will better understand that this macro is just about offsetting from the firstGPIO_CONFregister.You can add a comment on top of the macro, so anybody can read and see what this macro is doing.
Ok I will do that then. Thanks :)
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
This is pretty normal to have two kind of definitions (depending on the case):
1/#define FOO_1 ... #define FOO_2 ...and so on
2/
#define FOO(x) (... (x) ...)
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Having a mix of them seems quite unusual.
I did not know that. I will revert this change for next version then.
Don't get me wrong, it's possible to have, but since it's unusual it needs to be well justified. In the change you proposed you have changed that, but I haven't seen where the new definition is used (in *.c files).
GPIO1_CONF is only used by the GPIOX_CONF macro in the header.
Best regards,
Signature · 2 lines
Esteban Blanc BayLibre
Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
In reply to Andy ShevchenkoQuoted 46 lines · Andy Shevchenko
Quoted 6 lines · Esteban Blanc
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Esteban Blanc
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Esteban Blanc
Quoted 1 line · CEST,
Fri, May 12, 2023 at 04:17:54PM +0200, Esteban Blanc kirjoitti:
...
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-1-#define TPS6594_REG_GPIOX_CONF(gpio_inst) (0x31 + (gpio_inst)) +#define TPS6594_REG_GPIO1_CONF 0x31 +#define TPS6594_REG_GPIOX_CONF(gpio_inst) (TPS6594_REG_GPIO1_CONF + (gpio_inst))Why? The original code with parameter 0 will issue the same.
I felt that replacing
0x31with a constant would make the computation inTPS6594_REG_GPIOX_CONFIGmore understandable. What do you think?The question is why that register is so special that you need to have it as a constant explicitly?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
It is not special, it's just the first one of the serie of config registers. I felt like just having
0x31without context was a bit weirdI'm not sure I understand what 'context' you are talking about.
I was trying to convey the fact that
0x31was representingTPS6594_REG_GPIO1_CONFaddress. This way when looking atTPS6594_REG_GPIOX_CONF(...), one will better understand that this macro is just about offsetting from the firstGPIO_CONFregister.You can add a comment on top of the macro, so anybody can read and see what this macro is doing.
Quoted 12 lines
Quoted 12 lines
This is pretty normal to have two kind of definitions (depending on the case):
1/#define FOO_1 ... #define FOO_2 ...and so on
2/
#define FOO(x) (... (x) ...)
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Having a mix of them seems quite unusual.
I did not know that. I will revert this change for next version then.
Don't get me wrong, it's possible to have, but since it's unusual it needs to be well justified. In the change you proposed you have changed that, but I haven't seen where the new definition is used (in *.c files).
Actualy it used in 2 places:
- In the switch case of tps6594_gpio_regmap_xlate
- In tps6594_pinctrl_probe when setting reg_dir_out_base
I already sent a v5 with this change but I managed to fail my .config and this driver was not compiled... and it is not compiling... I feel so stupid.
I need to send a v6 now anyway. Should I convert all TPS6594_REG_GPIO1_CONF to TPS6594_REG_GPIOX_CONF(0)?
Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
Quoted 2 lines · Esteban Blanc
Quoted 1 line · Andy Shevchenko
On Wed, May 17, 2023 at 5:43 PM Esteban Blanc <[email protected]> wrote:
...
Quoted 5 lines
Quoted 4 lines
Don't get me wrong, it's possible to have, but since it's unusual it needs to be well justified. In the change you proposed you have changed that, but I haven't seen where the new definition is used (in *.c files).
Quoted 7 lines
Actualy it used in 2 places:
- In the switch case oftps6594_gpio_regmap_xlate
- Intps6594_pinctrl_probewhen settingreg_dir_out_baseI already sent a v5 with this change but I managed to fail my .config and this driver was not compiled... and it is not compiling... I feel so stupid.
People are prone to making mistakes. :-)
Quoted 2 lines
I need to send a v6 now anyway. Should I convert all
TPS6594_REG_GPIO1_CONFtoTPS6594_REG_GPIOX_CONF(0)?
Again, if you want to leave that definition you need to well justify why it's so special that code needs it. Easiest way is to use the macro with 0 as an argument.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Esteban Blanc
Quoted 1 line · Andy Shevchenko
On Wed, May 17, 2023 at 5:43 PM Esteban Blanc <[email protected]> wrote:
...
Quoted 6 lines
Quoted 2 lines
I need to send a v6 now anyway. Should I convert all
TPS6594_REG_GPIO1_CONFtoTPS6594_REG_GPIOX_CONF(0)?Again, if you want to leave that definition you need to well justify why it's so special that code needs it. Easiest way is to use the macro with 0 as an argument.
Ok. Thanks for your input and your patience :)
Best regards,
Signature · 2 lines
Esteban Blanc BayLibre
PATCH v4 3/3 regulator: tps6594-regulator: Add driver for TI TPS6594 regulators
In reply to Esteban BlancFrom: Jerome Neanne <[email protected]>
This patch adds support for TPS6594 regulators (bucks and LDOs). The output voltages are configurable and are meant to supply power to the main processor and other components.
Bucks can be used in single or multiphase mode, depending on PMIC part number.
--- drivers/regulator/Kconfig | 13 + drivers/regulator/Makefile | 1 + drivers/regulator/tps6594-regulator.c | 620 ++++++++++++++++++++++++++ 3 files changed, 634 insertions(+) create mode 100644 drivers/regulator/tps6594-regulator.c
drivers/regulator/Kconfig +13 -0
@@ -1463,6 +1463,19 @@ config REGULATOR_TPS65219 voltage regulators. It supports software based voltage control for different voltage domains. +config REGULATOR_TPS6594 + tristate "TI TPS6594 Power regulators" + depends on MFD_TPS6594 && OF + default MFD_TPS6594 + help + This driver supports TPS6594 voltage regulator chips. + TPS6594 series of PMICs have 5 BUCKs and 4 LDOs + voltage regulators. + BUCKs 1,2,3,4 can be used in single phase or multiphase mode. + Part number defines which single or multiphase mode is i used. + It supports software based voltage control + for different voltage domains. + config REGULATOR_TPS6524X tristate "TI TPS6524X Power regulators" depends on SPI
drivers/regulator/Makefile +1 -0
@@ -174,6 +174,7 @@ obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o +obj-$(CONFIG_REGULATOR_TPS6594) += tps6594-regulator.o obj-$(CONFIG_REGULATOR_TPS65132) += tps65132-regulator.o obj-$(CONFIG_REGULATOR_TPS68470) += tps68470-regulator.o obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o twl6030-regulator.o
drivers/regulator/tps6594-regulator.c new file +620 -0
620 lines not on this page · raw message
Signature · 1 line
2.39.2
Re: [PATCH v4 3/3] regulator: tps6594-regulator: Add driver for TI TPS6594 regulators
Fri, May 12, 2023 at 04:17:55PM +0200, Esteban Blanc kirjoitti:
Quoted 7 lines
From: Jerome Neanne <[email protected]>
This patch adds support for TPS6594 regulators (bucks and LDOs). The output voltages are configurable and are meant to supply power to the main processor and other components.
Bucks can be used in single or multiphase mode, depending on PMIC part number.
...
drivers/regulator/tps6594-regulator.c line 432
Quoted 8 lines
drivers/regulator/tps6594-regulator.c new file +8
-0+enum { +MULTI_BUCK12 , +MULTI_BUCK123 , +MULTI_BUCK1234 , +MULTI_BUCK12_34 , +MULTI_FIRST =MULTI_BUCK12 , +MULTI_LAST =MULTI_BUCK12_34 , +MULTI_NUM =MULTI_LAST -MULTI_FIRST +1
Missing TABs?
Quoted 1 line
(quoted diff) +1
-0+ };
...
drivers/regulator/tps6594-regulator.c line 447
Quoted 1 line
drivers/regulator/tps6594-regulator.c new file +1
-0+for (multi =MULTI_FIRST ; multi <MULTI_NUM ; multi++) {
Just a remark: spaces before ; are not standard.
drivers/regulator/tps6594-regulator.c line 452
Quoted 5 lines
drivers/regulator/tps6594-regulator.c new file +5
-0+ np =of_find_node_by_name (tps->dev->of_node, multiphases[multi]); + npname =of_node_full_name (np); + np_pmic_parent =of_get_parent (of_get_parent (np)); +if (strcmp ((of_node_full_name (np_pmic_parent)), tps->dev->of_node->full_name)) +continue ;
Isn't there an API to compare OF node name with a given parameter?
Quoted 5 lines
drivers/regulator/tps6594-regulator.c new file +5
-0+ delta =strcmp (npname, multiphases[multi]); +if (!delta) { +switch (multi) { +case MULTI_BUCK12 : + buck_multi[0 ] =1 ;
drivers/regulator/tps6594-regulator.c line 466
Quoted 10 lines
drivers/regulator/tps6594-regulator.c new file +9
-0+ buck_configured[0 ] =1 ; + buck_configured[1 ] =1 ; +break ; +/* multiphase buck34 is supported only with buck12 */ +case MULTI_BUCK12_34 : + buck_multi[0 ] =1 ; + buck_configured[0 ] =1 ; + buck_configured[1 ] =1 ; + buck_multi[1 ] =1 ;
Might be easier to read if this is grouped with [0] assignment above.
Quoted 19 lines
drivers/regulator/tps6594-regulator.c new file +19
-0+ buck_configured[2 ] =1 ; + buck_configured[3 ] =1 ; +break ; +case MULTI_BUCK123 : + buck_multi[2 ] =1 ; + buck_configured[0 ] =1 ; + buck_configured[1 ] =1 ; + buck_configured[2 ] =1 ; +break ; +case MULTI_BUCK1234 : + buck_multi[3 ] =1 ; + buck_configured[0 ] =1 ; + buck_configured[1 ] =1 ; + buck_configured[2 ] =1 ; + buck_configured[3 ] =1 ; +break ; + } + } + }
...
drivers/regulator/tps6594-regulator.c line 497
Quoted 7 lines
drivers/regulator/tps6594-regulator.c new file +7
-0+ irq_data = devm_kmalloc(tps->dev, + ARRAY_SIZE(tps6594_bucks_irq_types) * + REGS_INT_NB * + sizeof(struct tps6594_regulator_irq_data) + + ARRAY_SIZE(tps6594_ldos_irq_types) * + REGS_INT_NB * + sizeof(struct tps6594_regulator_irq_data),
We have respective macros in overflow.h that can be used here.
Quoted 3 lines
drivers/regulator/tps6594-regulator.c new file +3
-0+ GFP_KERNEL); +if (!irq_data) +return -ENOMEM ;
...
drivers/regulator/tps6594-regulator.c line 510
Quoted 5 lines
drivers/regulator/tps6594-regulator.c new file +5
-0+ rdev =devm_regulator_register (&pdev->dev, &multi_regs[i], &config); +if (IS_ERR (rdev)) { +dev_err (tps->dev,"failed to register %s regulator\n" , + pdev->name); +return PTR_ERR (rdev);
return dev_err_probe(...);
?
Quoted 1 line
(quoted diff) +1
-0+ }
...
drivers/regulator/tps6594-regulator.c line 548
Quoted 5 lines
drivers/regulator/tps6594-regulator.c new file +5
-0+ rdev =devm_regulator_register (&pdev->dev, &buck_regs[i], &config); +if (IS_ERR (rdev)) { +dev_err (tps->dev,"failed to register %s regulator\n" , + pdev->name); +return PTR_ERR (rdev);
Same question.
Quoted 1 line
(quoted diff) +1
-0+ }
...
drivers/regulator/tps6594-regulator.c line 564
Quoted 6 lines
drivers/regulator/tps6594-regulator.c new file +6
-0+ rdev =devm_regulator_register (&pdev->dev, &ldo_regs[i], &config); +if (IS_ERR (rdev)) { +dev_err (tps->dev, +"failed to register %s regulator\n" , + pdev->name); +return PTR_ERR (rdev);
Same question.
drivers/regulator/tps6594-regulator.c line 580
Quoted 6 lines
drivers/regulator/tps6594-regulator.c new file +5
-0+ } + irq_ext_reg_data =devm_kmalloc (tps->dev, + ext_reg_irq_nb * +sizeof (struct tps6594_ext_regulator_irq_data ), +GFP_KERNEL );
devm_kmalloc_array()
Quoted 2 lines
drivers/regulator/tps6594-regulator.c new file +2
-0+if (!irq_ext_reg_data) +return -ENOMEM ;
...
drivers/regulator/tps6594-regulator.c line 602
Quoted 9 lines
drivers/regulator/tps6594-regulator.c new file +9
-0+ error =devm_request_threaded_irq (tps->dev, irq,NULL , + tps6594_regulator_irq_handler, +IRQF_ONESHOT , + irq_type->irq_name, + &irq_ext_reg_data[i]); +if (error) { +dev_err (tps->dev,"failed to request %s IRQ %d: %d\n" , + irq_type->irq_name, irq, error); +return error;
return dev_err_probe(...);
?
Quoted 4 lines
drivers/regulator/tps6594-regulator.c new file +4
-0+ } + } +return 0 ; +}
Signature · 2 lines
With Best Regards, Andy Shevchenko