[PATCH v5 1/2] gpio: tps65219: Update _IDX & _OFFSET macro prefix

Shree Ramamoorthy posted 2 patches 3 months, 1 week ago
There is a newer version of this series
[PATCH v5 1/2] gpio: tps65219: Update _IDX & _OFFSET macro prefix
Posted by Shree Ramamoorthy 3 months, 1 week ago
TPS65215 and TPS65219 are overlapping PMIC devices. While their regulator
features differe, the GPIO features are the same. In the TPS65219 MFD
driver, the 2 PMICs share the same "tps65219-gpio" compatible string to
limit support for TPS65215 in this GPIO driver to comments.

The TPS6521X_GPIO0_IDX and TPS6521X_GPIO0_OFFSET macro name prefixes are
updated to indicate these macros apply to both PMICs.

Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpio-tps65219.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-tps65219.c b/drivers/gpio/gpio-tps65219.c
index 526640c39a11..3c762103babc 100644
--- a/drivers/gpio/gpio-tps65219.c
+++ b/drivers/gpio/gpio-tps65219.c
@@ -1,8 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * GPIO driver for TI TPS65219 PMICs
+ * GPIO driver for TI TPS65215/TPS65219 PMICs
  *
- * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
+ * Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com/
  */
 
 #include <linux/bits.h>
@@ -13,8 +13,15 @@
 #include <linux/regmap.h>
 
 #define TPS65219_GPIO0_DIR_MASK		BIT(3)
-#define TPS65219_GPIO0_OFFSET		2
-#define TPS65219_GPIO0_IDX		0
+#define TPS6521X_GPIO0_OFFSET		2
+#define TPS6521X_GPIO0_IDX		0
+
+/*
+ * TPS65215 & TPS65219 GPIO mapping
+ * Linux gpio offset 0 -> GPIO (pin16) -> bit_offset 2
+ * Linux gpio offset 1 -> GPO1 (pin8 ) -> bit_offset 0
+ * Linux gpio offset 2 -> GPO2 (pin17) -> bit_offset 1
+ */
 
 struct tps65219_gpio {
 	struct gpio_chip gpio_chip;
@@ -26,7 +33,7 @@ static int tps65219_gpio_get_direction(struct gpio_chip *gc, unsigned int offset
 	struct tps65219_gpio *gpio = gpiochip_get_data(gc);
 	int ret, val;
 
-	if (offset != TPS65219_GPIO0_IDX)
+	if (offset != TPS6521X_GPIO0_IDX)
 		return GPIO_LINE_DIRECTION_OUT;
 
 	ret = regmap_read(gpio->tps->regmap, TPS65219_REG_MFP_1_CONFIG, &val);
@@ -42,7 +49,7 @@ static int tps65219_gpio_get(struct gpio_chip *gc, unsigned int offset)
 	struct device *dev = gpio->tps->dev;
 	int ret, val;
 
-	if (offset != TPS65219_GPIO0_IDX) {
+	if (offset != TPS6521X_GPIO0_IDX) {
 		dev_err(dev, "GPIO%d is output only, cannot get\n", offset);
 		return -ENOTSUPP;
 	}
@@ -71,7 +78,7 @@ static void tps65219_gpio_set(struct gpio_chip *gc, unsigned int offset, int val
 	struct device *dev = gpio->tps->dev;
 	int v, mask, bit;
 
-	bit = (offset == TPS65219_GPIO0_IDX) ? TPS65219_GPIO0_OFFSET : offset - 1;
+	bit = (offset == TPS6521X_GPIO0_IDX) ? TPS6521X_GPIO0_OFFSET : offset - 1;
 
 	mask = BIT(bit);
 	v = value ? mask : 0;
@@ -117,7 +124,7 @@ static int tps65219_gpio_direction_input(struct gpio_chip *gc, unsigned int offs
 	struct tps65219_gpio *gpio = gpiochip_get_data(gc);
 	struct device *dev = gpio->tps->dev;
 
-	if (offset != TPS65219_GPIO0_IDX) {
+	if (offset != TPS6521X_GPIO0_IDX) {
 		dev_err(dev, "GPIO%d is output only, cannot change to input\n", offset);
 		return -ENOTSUPP;
 	}
@@ -131,7 +138,7 @@ static int tps65219_gpio_direction_input(struct gpio_chip *gc, unsigned int offs
 static int tps65219_gpio_direction_output(struct gpio_chip *gc, unsigned int offset, int value)
 {
 	tps65219_gpio_set(gc, offset, value);
-	if (offset != TPS65219_GPIO0_IDX)
+	if (offset != TPS6521X_GPIO0_IDX)
 		return 0;
 
 	if (tps65219_gpio_get_direction(gc, offset) == GPIO_LINE_DIRECTION_OUT)
@@ -179,5 +186,5 @@ module_platform_driver(tps65219_gpio_driver);
 
 MODULE_ALIAS("platform:tps65219-gpio");
 MODULE_AUTHOR("Jonathan Cormier <jcormier@criticallink.com>");
-MODULE_DESCRIPTION("TPS65219 GPIO driver");
+MODULE_DESCRIPTION("TPS65215/TPS65219 GPIO driver");
 MODULE_LICENSE("GPL");
-- 
2.43.0
Re: [PATCH v5 1/2] gpio: tps65219: Update _IDX & _OFFSET macro prefix
Posted by Jon Cormier 3 months ago
On Wed, Jul 2, 2025 at 12:49 PM Shree Ramamoorthy <s-ramamoorthy@ti.com> wrote:
>
> TPS65215 and TPS65219 are overlapping PMIC devices. While their regulator
> features differe, the GPIO features are the same. In the TPS65219 MFD
> driver, the 2 PMICs share the same "tps65219-gpio" compatible string to
> limit support for TPS65215 in this GPIO driver to comments.
>
> The TPS6521X_GPIO0_IDX and TPS6521X_GPIO0_OFFSET macro name prefixes are
> updated to indicate these macros apply to both PMICs.
>
> Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
> Reviewed-by: Roger Quadros <rogerq@kernel.org>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Jonathan Cormier <jcormier@criticallink.com>
> ---
>  drivers/gpio/gpio-tps65219.c | 27 +++++++++++++++++----------
>  1 file changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpio/gpio-tps65219.c b/drivers/gpio/gpio-tps65219.c
> index 526640c39a11..3c762103babc 100644
> --- a/drivers/gpio/gpio-tps65219.c
> +++ b/drivers/gpio/gpio-tps65219.c
> @@ -1,8 +1,8 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /*
> - * GPIO driver for TI TPS65219 PMICs
> + * GPIO driver for TI TPS65215/TPS65219 PMICs
>   *
> - * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
> + * Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com/
>   */
>
>  #include <linux/bits.h>
> @@ -13,8 +13,15 @@
>  #include <linux/regmap.h>
>
>  #define TPS65219_GPIO0_DIR_MASK                BIT(3)
> -#define TPS65219_GPIO0_OFFSET          2
> -#define TPS65219_GPIO0_IDX             0
> +#define TPS6521X_GPIO0_OFFSET          2
> +#define TPS6521X_GPIO0_IDX             0
> +
> +/*
> + * TPS65215 & TPS65219 GPIO mapping
> + * Linux gpio offset 0 -> GPIO (pin16) -> bit_offset 2
> + * Linux gpio offset 1 -> GPO1 (pin8 ) -> bit_offset 0
> + * Linux gpio offset 2 -> GPO2 (pin17) -> bit_offset 1
> + */
>
>  struct tps65219_gpio {
>         struct gpio_chip gpio_chip;
> @@ -26,7 +33,7 @@ static int tps65219_gpio_get_direction(struct gpio_chip *gc, unsigned int offset
>         struct tps65219_gpio *gpio = gpiochip_get_data(gc);
>         int ret, val;
>
> -       if (offset != TPS65219_GPIO0_IDX)
> +       if (offset != TPS6521X_GPIO0_IDX)
>                 return GPIO_LINE_DIRECTION_OUT;
>
>         ret = regmap_read(gpio->tps->regmap, TPS65219_REG_MFP_1_CONFIG, &val);
> @@ -42,7 +49,7 @@ static int tps65219_gpio_get(struct gpio_chip *gc, unsigned int offset)
>         struct device *dev = gpio->tps->dev;
>         int ret, val;
>
> -       if (offset != TPS65219_GPIO0_IDX) {
> +       if (offset != TPS6521X_GPIO0_IDX) {
>                 dev_err(dev, "GPIO%d is output only, cannot get\n", offset);
>                 return -ENOTSUPP;
>         }
> @@ -71,7 +78,7 @@ static void tps65219_gpio_set(struct gpio_chip *gc, unsigned int offset, int val
>         struct device *dev = gpio->tps->dev;
>         int v, mask, bit;
>
> -       bit = (offset == TPS65219_GPIO0_IDX) ? TPS65219_GPIO0_OFFSET : offset - 1;
> +       bit = (offset == TPS6521X_GPIO0_IDX) ? TPS6521X_GPIO0_OFFSET : offset - 1;
>
>         mask = BIT(bit);
>         v = value ? mask : 0;
> @@ -117,7 +124,7 @@ static int tps65219_gpio_direction_input(struct gpio_chip *gc, unsigned int offs
>         struct tps65219_gpio *gpio = gpiochip_get_data(gc);
>         struct device *dev = gpio->tps->dev;
>
> -       if (offset != TPS65219_GPIO0_IDX) {
> +       if (offset != TPS6521X_GPIO0_IDX) {
>                 dev_err(dev, "GPIO%d is output only, cannot change to input\n", offset);
>                 return -ENOTSUPP;
>         }
> @@ -131,7 +138,7 @@ static int tps65219_gpio_direction_input(struct gpio_chip *gc, unsigned int offs
>  static int tps65219_gpio_direction_output(struct gpio_chip *gc, unsigned int offset, int value)
>  {
>         tps65219_gpio_set(gc, offset, value);
> -       if (offset != TPS65219_GPIO0_IDX)
> +       if (offset != TPS6521X_GPIO0_IDX)
>                 return 0;
>
>         if (tps65219_gpio_get_direction(gc, offset) == GPIO_LINE_DIRECTION_OUT)
> @@ -179,5 +186,5 @@ module_platform_driver(tps65219_gpio_driver);
>
>  MODULE_ALIAS("platform:tps65219-gpio");
>  MODULE_AUTHOR("Jonathan Cormier <jcormier@criticallink.com>");
> -MODULE_DESCRIPTION("TPS65219 GPIO driver");
> +MODULE_DESCRIPTION("TPS65215/TPS65219 GPIO driver");
>  MODULE_LICENSE("GPL");
> --
> 2.43.0
>


-- 
Jonathan Cormier
Senior Software Engineer

Voice:  315.425.4045 x222

http://www.CriticalLink.com
6712 Brooklawn Parkway, Syracuse, NY 13211
Re: [PATCH v5 1/2] gpio: tps65219: Update _IDX & _OFFSET macro prefix
Posted by Bartosz Golaszewski 3 months ago
On Wed, Jul 2, 2025 at 6:51 PM Shree Ramamoorthy <s-ramamoorthy@ti.com> wrote:
>
> TPS65215 and TPS65219 are overlapping PMIC devices. While their regulator
> features differe, the GPIO features are the same. In the TPS65219 MFD
> driver, the 2 PMICs share the same "tps65219-gpio" compatible string to
> limit support for TPS65215 in this GPIO driver to comments.
>
> The TPS6521X_GPIO0_IDX and TPS6521X_GPIO0_OFFSET macro name prefixes are
> updated to indicate these macros apply to both PMICs.
>
> Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
> Reviewed-by: Roger Quadros <rogerq@kernel.org>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/gpio/gpio-tps65219.c | 27 +++++++++++++++++----------
>  1 file changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpio/gpio-tps65219.c b/drivers/gpio/gpio-tps65219.c
> index 526640c39a11..3c762103babc 100644
> --- a/drivers/gpio/gpio-tps65219.c
> +++ b/drivers/gpio/gpio-tps65219.c
> @@ -1,8 +1,8 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /*
> - * GPIO driver for TI TPS65219 PMICs
> + * GPIO driver for TI TPS65215/TPS65219 PMICs
>   *
> - * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
> + * Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com/

Should be 2022,2025.

Bart
Re: [PATCH v5 1/2] gpio: tps65219: Update _IDX & _OFFSET macro prefix
Posted by Shree Ramamoorthy 3 months ago
On 7/3/2025 4:51 AM, Bartosz Golaszewski wrote:
> On Wed, Jul 2, 2025 at 6:51 PM Shree Ramamoorthy <s-ramamoorthy@ti.com> wrote:
>> TPS65215 and TPS65219 are overlapping PMIC devices. While their regulator
>> features differe, the GPIO features are the same. In the TPS65219 MFD
>> driver, the 2 PMICs share the same "tps65219-gpio" compatible string to
>> limit support for TPS65215 in this GPIO driver to comments.
>>
>> The TPS6521X_GPIO0_IDX and TPS6521X_GPIO0_OFFSET macro name prefixes are
>> updated to indicate these macros apply to both PMICs.
>>
>> Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@ti.com>
>> Reviewed-by: Roger Quadros <rogerq@kernel.org>
>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>> ---
>>  drivers/gpio/gpio-tps65219.c | 27 +++++++++++++++++----------
>>  1 file changed, 17 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/gpio/gpio-tps65219.c b/drivers/gpio/gpio-tps65219.c
>> index 526640c39a11..3c762103babc 100644
>> --- a/drivers/gpio/gpio-tps65219.c
>> +++ b/drivers/gpio/gpio-tps65219.c
>> @@ -1,8 +1,8 @@
>>  // SPDX-License-Identifier: GPL-2.0
>>  /*
>> - * GPIO driver for TI TPS65219 PMICs
>> + * GPIO driver for TI TPS65215/TPS65219 PMICs
>>   *
>> - * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
>> + * Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com/
> Should be 2022,2025.

Will consolidate the copyright years, thanks!

>
> Bart