From: Matt Ranostay <mranostay@ti.com>
To: <vigneshr@ti.com>, <robh@kernel.org>,
<krzysztof.kozlowski@linaro.org>, <a.zummo@towertech.it>,
<linus.walleij@linaro.org>, <lee@kernel.org>, <brgl@bgdev.pl>
Cc: <linux-arm-kernel@lists.infradead.org>,
<devicetree@vger.kernel.org>, <linux-gpio@vger.kernel.org>,
<linux-rtc@vger.kernel.org>, Matt Ranostay <mranostay@ti.com>
Subject: [PATCH v4 4/4] gpio: gpio-tps6594x: add GPIO support for TPS6594x PMIC
Date: Fri, 18 Nov 2022 01:22:18 -0800 [thread overview]
Message-ID: <20221118092218.480147-5-mranostay@ti.com> (raw)
In-Reply-To: <20221118092218.480147-1-mranostay@ti.com>
Add support for TPS6594X PMICs GPIO interface that has 11 that can be
configured as input or outputs.
Signed-off-by: Matt Ranostay <mranostay@ti.com>
---
drivers/gpio/Kconfig | 9 +++++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-tps6594x.c | 78 ++++++++++++++++++++++++++++++++++++
include/linux/mfd/tps6594x.h | 4 ++
4 files changed, 92 insertions(+)
create mode 100644 drivers/gpio/gpio-tps6594x.c
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index ec7cfd4f52b1..6b65c790efe7 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -1405,6 +1405,15 @@ config GPIO_TPS65912
help
This driver supports TPS65912 GPIO chip.
+config GPIO_TPS6594X
+ tristate "TI TPS6594X GPIO driver"
+ depends on MFD_TPS6594X || COMPILE_TEST
+ select REGMAP
+ select GPIO_REGMAP
+ help
+ Select this option to enable GPIO driver for the TPS6954X
+ PMIC chip family. There are 11 GPIOs that can be configured.
+
config GPIO_TPS68470
tristate "TPS68470 GPIO"
depends on INTEL_SKL_INT3472
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 010587025fc8..9892f9adc5b5 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -159,6 +159,7 @@ obj-$(CONFIG_GPIO_TPS65218) += gpio-tps65218.o
obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o
obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o
obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o
+obj-$(CONFIG_GPIO_TPS6594X) += gpio-tps6594x.o
obj-$(CONFIG_GPIO_TPS68470) += gpio-tps68470.o
obj-$(CONFIG_GPIO_TQMX86) += gpio-tqmx86.o
obj-$(CONFIG_GPIO_TS4800) += gpio-ts4800.o
diff --git a/drivers/gpio/gpio-tps6594x.c b/drivers/gpio/gpio-tps6594x.c
new file mode 100644
index 000000000000..733fedba70cb
--- /dev/null
+++ b/drivers/gpio/gpio-tps6594x.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * GPIO driver for TI TPS6594x PMICs
+ *
+ * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+#include <linux/gpio/regmap.h>
+#include <linux/gpio/driver.h>
+#include <linux/mfd/tps6594x.h>
+
+#define GPIO_BANK_SIZE 8
+#define GPIO_CFG_MASK BIT(0)
+
+static int tps6594x_regmap_xlate(struct gpio_regmap *gpio,
+ unsigned int base, unsigned int offset,
+ unsigned int *reg, unsigned int *mask)
+{
+ if (base == TPS6594X_GPIO_CONF) {
+ *reg = base + offset;
+ *mask = GPIO_CFG_MASK;
+ } else {
+ unsigned int line = offset % GPIO_BANK_SIZE;
+ unsigned int stride = offset / GPIO_BANK_SIZE;
+
+ *reg = base + stride;
+ *mask = BIT(line);
+ }
+
+ return 0;
+}
+
+static int tps6594x_gpio_probe(struct platform_device *pdev)
+{
+ struct gpio_regmap_config config = {0};
+ struct regmap *regmap;
+
+ regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ if (!regmap)
+ return -ENODEV;
+
+ config.regmap = regmap;
+ config.parent = &pdev->dev;
+ config.ngpio = 11;
+ config.ngpio_per_reg = GPIO_BANK_SIZE;
+
+ config.reg_dat_base = TPS6594X_GPIO_IN;
+ config.reg_set_base = TPS6594X_GPIO_OUT;
+ config.reg_dir_out_base = TPS6594X_GPIO_CONF;
+ config.reg_mask_xlate = tps6594x_regmap_xlate;
+
+ return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(&pdev->dev, &config));
+}
+
+static const struct of_device_id of_tps6594x_gpio_match[] = {
+ { .compatible = "ti,tps6594-gpio", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, of_tps6594x_gpio_match);
+
+static struct platform_driver tps6594x_gpio_driver = {
+ .driver = {
+ .name = "tps6594-gpio",
+ .of_match_table = of_tps6594x_gpio_match,
+ },
+ .probe = tps6594x_gpio_probe,
+};
+module_platform_driver(tps6594x_gpio_driver);
+
+MODULE_ALIAS("platform:tps6594-gpio");
+MODULE_AUTHOR("Matt Ranostay <mranostay@ti.com>");
+MODULE_DESCRIPTION("TPS6594X GPIO driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/tps6594x.h b/include/linux/mfd/tps6594x.h
index 5a6af0da9223..155618e4d5d0 100644
--- a/include/linux/mfd/tps6594x.h
+++ b/include/linux/mfd/tps6594x.h
@@ -21,6 +21,10 @@
#define TPS6594X_FSM_I2C_TRIGGERS 0x85
#define TPS6594X_FSM_NSLEEP_TRIGGERS 0x86
+#define TPS6594X_GPIO_CONF 0x31
+#define TPS6594X_GPIO_OUT 0x3d
+#define TPS6594X_GPIO_IN 0x3f
+
#define TPS6594X_RTC_SECONDS 0xb5
#define TPS6594X_RTC_MINUTES 0xb6
#define TPS6594X_RTC_HOURS 0xb7
--
2.38.GIT
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-11-18 9:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-18 9:22 [PATCH v4 0/4] mfd: add tps6594x support for Jacinto platforms Matt Ranostay
2022-11-18 9:22 ` [PATCH v4 1/4] Documentation: ti,tps6594: Add DT bindings for the TPS6594x PMIC Matt Ranostay
2022-11-18 10:21 ` Krzysztof Kozlowski
2022-11-19 4:23 ` Matt Ranostay
2022-11-18 13:31 ` Rob Herring
2022-11-18 9:22 ` [PATCH v4 2/4] MFD: TPS6594x: Add new PMIC device driver for TPS6594x chips Matt Ranostay
2022-11-18 10:23 ` Krzysztof Kozlowski
2022-11-19 4:17 ` Matt Ranostay
2022-11-18 9:22 ` [PATCH v4 3/4] rtc: rtc-tps6594x: Add support for TPS6594X PMIC RTC Matt Ranostay
2022-11-18 9:22 ` Matt Ranostay [this message]
2022-11-28 18:08 ` [PATCH v4 4/4] gpio: gpio-tps6594x: add GPIO support for TPS6594x PMIC Bartosz Golaszewski
2022-11-28 20:38 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221118092218.480147-5-mranostay@ti.com \
--to=mranostay@ti.com \
--cc=a.zummo@towertech.it \
--cc=brgl@bgdev.pl \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=lee@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=robh@kernel.org \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox