All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] mfd: add tps6594x support for Jacinto platforms
@ 2022-11-18  9:22 ` Matt Ranostay
  0 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-18  9:22 UTC (permalink / raw)
  To: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Matt Ranostay

This patchset series adds support for the TPS6594x PMIC along with
initial support for its RTC + GPIO interface, and poweroff sequence.

Additionally, add usage of the PMIC for the various Jacintor platforms
devicetree's.

Changes from v1:
* Corrected devicetree documentation issues found with dt-schema
* Changed MFD references to PMIC reflecting the more valid use of driver
* Cleaning up variable naming and ordering within functions
* Adding gpio + regulator cells for upcoming driver support
* Switching from .probe to .probe_new API
* Revising comments within drivers to be more concise
* Adding device tree nodes for j721s2 and j721e platforms

Changes from v2:
* Adding gpio-tps6594x driver support
* Enabling gpio cell in MFD driver

Changes from v3:
* Refactoring gpio driver to use regmap gpio helpers
* Changing rtc driver to use more of device resource management 
* Minor code changes related to error messages that aren't useful
  being dropped
* Dropped wildcard in device-tree compatible, and i2c device id
* Dropped device tree changes from the series; since these should
  be in their own series later

Keerthy (2):
  MFD: TPS6594x: Add new PMIC device driver for TPS6594x chips
  rtc: rtc-tps6594x: Add support for TPS6594X PMIC RTC

Matt Ranostay (2):
  Documentation: ti,tps6594: Add DT bindings for the TPS6594x PMIC
  gpio: gpio-tps6594x: add GPIO support for TPS6594x PMIC

 .../devicetree/bindings/mfd/ti,tps6594.yaml   |  65 ++++++++
 drivers/gpio/Kconfig                          |   9 +
 drivers/gpio/Makefile                         |   1 +
 drivers/gpio/gpio-tps6594x.c                  |  78 +++++++++
 drivers/mfd/Kconfig                           |  14 ++
 drivers/mfd/Makefile                          |   1 +
 drivers/mfd/tps6594x.c                        | 113 +++++++++++++
 drivers/rtc/Kconfig                           |  10 ++
 drivers/rtc/Makefile                          |   1 +
 drivers/rtc/rtc-tps6594x.c                    | 155 ++++++++++++++++++
 include/linux/mfd/tps6594x.h                  |  88 ++++++++++
 11 files changed, 535 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
 create mode 100644 drivers/gpio/gpio-tps6594x.c
 create mode 100644 drivers/mfd/tps6594x.c
 create mode 100644 drivers/rtc/rtc-tps6594x.c
 create mode 100644 include/linux/mfd/tps6594x.h

-- 
2.38.GIT


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v4 0/4] mfd: add tps6594x support for Jacinto platforms
@ 2022-11-18  9:22 ` Matt Ranostay
  0 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-18  9:22 UTC (permalink / raw)
  To: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Matt Ranostay

This patchset series adds support for the TPS6594x PMIC along with
initial support for its RTC + GPIO interface, and poweroff sequence.

Additionally, add usage of the PMIC for the various Jacintor platforms
devicetree's.

Changes from v1:
* Corrected devicetree documentation issues found with dt-schema
* Changed MFD references to PMIC reflecting the more valid use of driver
* Cleaning up variable naming and ordering within functions
* Adding gpio + regulator cells for upcoming driver support
* Switching from .probe to .probe_new API
* Revising comments within drivers to be more concise
* Adding device tree nodes for j721s2 and j721e platforms

Changes from v2:
* Adding gpio-tps6594x driver support
* Enabling gpio cell in MFD driver

Changes from v3:
* Refactoring gpio driver to use regmap gpio helpers
* Changing rtc driver to use more of device resource management 
* Minor code changes related to error messages that aren't useful
  being dropped
* Dropped wildcard in device-tree compatible, and i2c device id
* Dropped device tree changes from the series; since these should
  be in their own series later

Keerthy (2):
  MFD: TPS6594x: Add new PMIC device driver for TPS6594x chips
  rtc: rtc-tps6594x: Add support for TPS6594X PMIC RTC

Matt Ranostay (2):
  Documentation: ti,tps6594: Add DT bindings for the TPS6594x PMIC
  gpio: gpio-tps6594x: add GPIO support for TPS6594x PMIC

 .../devicetree/bindings/mfd/ti,tps6594.yaml   |  65 ++++++++
 drivers/gpio/Kconfig                          |   9 +
 drivers/gpio/Makefile                         |   1 +
 drivers/gpio/gpio-tps6594x.c                  |  78 +++++++++
 drivers/mfd/Kconfig                           |  14 ++
 drivers/mfd/Makefile                          |   1 +
 drivers/mfd/tps6594x.c                        | 113 +++++++++++++
 drivers/rtc/Kconfig                           |  10 ++
 drivers/rtc/Makefile                          |   1 +
 drivers/rtc/rtc-tps6594x.c                    | 155 ++++++++++++++++++
 include/linux/mfd/tps6594x.h                  |  88 ++++++++++
 11 files changed, 535 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
 create mode 100644 drivers/gpio/gpio-tps6594x.c
 create mode 100644 drivers/mfd/tps6594x.c
 create mode 100644 drivers/rtc/rtc-tps6594x.c
 create mode 100644 include/linux/mfd/tps6594x.h

-- 
2.38.GIT


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v4 1/4] Documentation: ti,tps6594: Add DT bindings for the TPS6594x PMIC
  2022-11-18  9:22 ` Matt Ranostay
@ 2022-11-18  9:22   ` Matt Ranostay
  -1 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-18  9:22 UTC (permalink / raw)
  To: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Matt Ranostay

Add documentation for the TPS6594x PMIC including its RTC and GPIO
functionalities.

Signed-off-by: Matt Ranostay <mranostay@ti.com>
---
 .../devicetree/bindings/mfd/ti,tps6594.yaml   | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ti,tps6594.yaml

diff --git a/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
new file mode 100644
index 000000000000..81613bcef39d
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/ti,tps6594x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TPS6594x Power Management Integrated Circuit (PMIC)
+
+maintainers:
+  - Keerthy <j-keerthy@ti.com>
+
+properties:
+  compatible:
+    enum:
+      - ti,tps6594
+
+  reg:
+    const: 0x48
+
+  ti,system-power-controller:
+    type: boolean
+    description: PMIC is controlling the system power.
+
+  rtc:
+    type: object
+    $ref: /schemas/rtc/rtc.yaml#
+    unevaluatedProperties: false
+    properties:
+      compatible:
+        const: ti,tps6594-rtc
+
+  gpio:
+    type: object
+    unevaluatedProperties: false
+    properties:
+      compatible:
+        const: ti,tps6594x-gpio
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    i2c0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pmic: pmic@48 {
+            compatible = "ti,tps6594";
+            reg = <0x48>;
+
+            rtc {
+                compatible = "ti,tps6594-rtc";
+            };
+
+            gpio {
+                compatible = "ti,tps6594-gpio";
+            };
+        };
+    };
+
+...
-- 
2.38.GIT


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v4 1/4] Documentation: ti,tps6594: Add DT bindings for the TPS6594x PMIC
@ 2022-11-18  9:22   ` Matt Ranostay
  0 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-18  9:22 UTC (permalink / raw)
  To: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Matt Ranostay

Add documentation for the TPS6594x PMIC including its RTC and GPIO
functionalities.

Signed-off-by: Matt Ranostay <mranostay@ti.com>
---
 .../devicetree/bindings/mfd/ti,tps6594.yaml   | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ti,tps6594.yaml

diff --git a/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
new file mode 100644
index 000000000000..81613bcef39d
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/ti,tps6594x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TPS6594x Power Management Integrated Circuit (PMIC)
+
+maintainers:
+  - Keerthy <j-keerthy@ti.com>
+
+properties:
+  compatible:
+    enum:
+      - ti,tps6594
+
+  reg:
+    const: 0x48
+
+  ti,system-power-controller:
+    type: boolean
+    description: PMIC is controlling the system power.
+
+  rtc:
+    type: object
+    $ref: /schemas/rtc/rtc.yaml#
+    unevaluatedProperties: false
+    properties:
+      compatible:
+        const: ti,tps6594-rtc
+
+  gpio:
+    type: object
+    unevaluatedProperties: false
+    properties:
+      compatible:
+        const: ti,tps6594x-gpio
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    i2c0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pmic: pmic@48 {
+            compatible = "ti,tps6594";
+            reg = <0x48>;
+
+            rtc {
+                compatible = "ti,tps6594-rtc";
+            };
+
+            gpio {
+                compatible = "ti,tps6594-gpio";
+            };
+        };
+    };
+
+...
-- 
2.38.GIT


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v4 2/4] MFD: TPS6594x: Add new PMIC device driver for TPS6594x chips
  2022-11-18  9:22 ` Matt Ranostay
@ 2022-11-18  9:22   ` Matt Ranostay
  -1 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-18  9:22 UTC (permalink / raw)
  To: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Keerthy,
	Matt Ranostay

From: Keerthy <j-keerthy@ti.com>

The TPS6594x chip is a PMIC, and contains the following components:

- GPIO controller
- RTC

Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Matt Ranostay <mranostay@ti.com>
---
 drivers/mfd/Kconfig          |  14 +++++
 drivers/mfd/Makefile         |   1 +
 drivers/mfd/tps6594x.c       | 113 +++++++++++++++++++++++++++++++++++
 include/linux/mfd/tps6594x.h |  84 ++++++++++++++++++++++++++
 4 files changed, 212 insertions(+)
 create mode 100644 drivers/mfd/tps6594x.c
 create mode 100644 include/linux/mfd/tps6594x.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 6653d03e0fe3..f19178cf9c61 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1596,6 +1596,20 @@ config MFD_TI_LP873X
 	  This driver can also be built as a module. If so, the module
 	  will be called lp873x.
 
+config MFD_TPS6594X
+	tristate "TI TPS6594X Power Management IC"
+	depends on I2C && OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  If you say yes here then you get support for the TPS6594X series of
+	  Power Management Integrated Circuits (PMIC).
+	  These include voltage regulators, RTS, configurable
+	  General Purpose Outputs (GPO) that are used in portable devices.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called tps6594x.
+
 config MFD_TI_LP87565
 	tristate "TI LP87565 Power Management IC"
 	depends on I2C && OF
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 4dd479212b3a..51d7bfcd0a27 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -101,6 +101,7 @@ obj-$(CONFIG_MFD_TPS65910)	+= tps65910.o
 obj-$(CONFIG_MFD_TPS65912)	+= tps65912-core.o
 obj-$(CONFIG_MFD_TPS65912_I2C)	+= tps65912-i2c.o
 obj-$(CONFIG_MFD_TPS65912_SPI)  += tps65912-spi.o
+obj-$(CONFIG_MFD_TPS6594X)	+= tps6594x.o
 obj-$(CONFIG_MENELAUS)		+= menelaus.o
 
 obj-$(CONFIG_TWL4030_CORE)	+= twl-core.o twl4030-irq.o twl6030-irq.o
diff --git a/drivers/mfd/tps6594x.c b/drivers/mfd/tps6594x.c
new file mode 100644
index 000000000000..700e887a0966
--- /dev/null
+++ b/drivers/mfd/tps6594x.c
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Driver for tps6594x PMIC chips
+ *
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ * Author: Keerthy <j-keerthy@ti.com>
+ */
+
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/tps6594x.h>
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/regmap.h>
+
+static const struct regmap_config tps6594x_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = TPS6594X_REG_MAX,
+};
+
+static const struct mfd_cell tps6594x_cells[] = {
+	{ .name = "tps6594-gpio" },
+	{ .name = "tps6594-rtc" },
+};
+
+static struct tps6594x *tps;
+
+static void tps6594x_power_off(void)
+{
+	regmap_write(tps->regmap, TPS6594X_FSM_NSLEEP_TRIGGERS,
+		TPS6594X_FSM_NSLEEP_NSLEEP1B | TPS6594X_FSM_NSLEEP_NSLEEP2B);
+
+	regmap_write(tps->regmap, TPS6594X_INT_STARTUP,
+		TPS6594X_INT_STARTUP_NPWRON_START_INT |
+		TPS6594X_INT_STARTUP_ENABLE_INT | TPS6594X_INT_STARTUP_RTC_INT |
+		TPS6594X_INT_STARTUP_SOFT_REBOOT_INT);
+
+	regmap_write(tps->regmap, TPS6594X_INT_MISC,
+		TPS6594X_INT_MISC_BIST_PASS_INT |
+		TPS6594X_INT_MISC_EXT_CLK_INT | TPS6594X_INT_MISC_TWARN_INT);
+
+	regmap_write(tps->regmap, TPS6594X_CONFIG_1,
+		TPS6594X_CONFIG_NSLEEP1_MASK | TPS6594X_CONFIG_NSLEEP2_MASK);
+
+	regmap_write(tps->regmap, TPS6594X_FSM_I2C_TRIGGERS,
+		TPS6594X_FSM_I2C_TRIGGERS_I2C0);
+}
+
+static int tps6594x_probe(struct i2c_client *client)
+{
+	struct tps6594x *ddata;
+	struct device_node *node = client->dev.of_node;
+	unsigned int otpid;
+	int ret;
+
+	ddata = devm_kzalloc(&client->dev, sizeof(*ddata), GFP_KERNEL);
+	if (!ddata)
+		return -ENOMEM;
+
+	ddata->dev = &client->dev;
+
+	ddata->regmap = devm_regmap_init_i2c(client, &tps6594x_regmap_config);
+	if (IS_ERR(ddata->regmap))
+		return dev_err_probe(ddata->dev, PTR_ERR(ddata->regmap),
+			"Failed to initialize register map\n");
+
+	ret = regmap_read(ddata->regmap, TPS6594X_REG_DEV_REV, &otpid);
+	if (ret)
+		return dev_err_probe(ddata->dev, ret, "Failed to read OTP ID\n");
+
+	ddata->rev = otpid;
+	i2c_set_clientdata(client, ddata);
+
+	ret = mfd_add_devices(ddata->dev, PLATFORM_DEVID_AUTO, tps6594x_cells,
+			      ARRAY_SIZE(tps6594x_cells), NULL, 0, NULL);
+	if (ret)
+		return dev_err_probe(ddata->dev, ret, "Failed to register cells\n");
+
+	tps = ddata;
+
+	if (of_property_read_bool(node, "ti,system-power-controller"))
+		pm_power_off = tps6594x_power_off;
+
+	return 0;
+}
+
+static const struct of_device_id of_tps6594x_match_table[] = {
+	{ .compatible = "ti,tps6594", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, of_tps6594x_match_table);
+
+static const struct i2c_device_id tps6594x_id_table[] = {
+	{ "tps6594", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, tps6594x_id_table);
+
+static struct i2c_driver tps6594x_driver = {
+	.driver	= {
+		.name	= "tps6594",
+		.of_match_table = of_tps6594x_match_table,
+	},
+	.probe_new	= tps6594x_probe,
+	.id_table	= tps6594x_id_table,
+};
+module_i2c_driver(tps6594x_driver);
+
+MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
+MODULE_DESCRIPTION("TPS6594X PMIC device driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/tps6594x.h b/include/linux/mfd/tps6594x.h
new file mode 100644
index 000000000000..5a6af0da9223
--- /dev/null
+++ b/include/linux/mfd/tps6594x.h
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Core driver interface for TI TPS6594x PMIC family
+ *
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#ifndef __MFD_TPS6594X_H
+#define __MFD_TPS6594X_H
+
+#include <linux/bits.h>
+
+/* TPS6594x chip ID list */
+#define TPS6594X			0x00
+
+/* All register addresses */
+#define TPS6594X_REG_DEV_REV			0x01
+#define TPS6594X_INT_STARTUP			0x65
+#define TPS6594X_INT_MISC			0x66
+#define TPS6594X_CONFIG_1			0x7d
+#define TPS6594X_FSM_I2C_TRIGGERS		0x85
+#define TPS6594X_FSM_NSLEEP_TRIGGERS		0x86
+
+#define TPS6594X_RTC_SECONDS			0xb5
+#define TPS6594X_RTC_MINUTES			0xb6
+#define TPS6594X_RTC_HOURS			0xb7
+#define TPS6594X_RTC_DAYS			0xb8
+#define TPS6594X_RTC_MONTHS			0xb9
+#define TPS6594X_RTC_YEARS			0xba
+#define TPS6594X_RTC_WEEKS			0xbb
+#define TPS6594X_ALARM_SECONDS			0xbc
+#define TPS6594X_ALARM_MINUTES			0xbd
+#define TPS6594X_ALARM_HOURS			0xbe
+#define TPS6594X_ALARM_DAYS			0xbf
+#define TPS6594X_ALARM_MONTHS			0xc0
+#define TPS6594X_ALARM_YEARS			0xc1
+#define TPS6594X_RTC_CTRL_1			0xc2
+#define TPS6594X_RTC_CTRL_2			0xc3
+#define TPS6594X_RTC_STATUS			0xc4
+#define TPS6594X_RTC_INTERRUPTS			0xc5
+#define TPS6594X_REG_MAX			0xd0
+
+/* Register field definitions */
+#define TPS6594X_DEV_REV_DEV_ID			0xff
+
+#define TPS6594X_INT_STARTUP_NPWRON_START_INT	BIT(0)
+#define TPS6594X_INT_STARTUP_ENABLE_INT		BIT(1)
+#define TPS6594X_INT_STARTUP_RTC_INT		BIT(2)
+#define TPS6594X_INT_STARTUP_FSD_INT		BIT(4)
+#define TPS6594X_INT_STARTUP_SOFT_REBOOT_INT	BIT(5)
+
+#define TPS6594X_INT_MISC_BIST_PASS_INT		BIT(0)
+#define TPS6594X_INT_MISC_EXT_CLK_INT		BIT(1)
+#define TPS6594X_INT_MISC_TWARN_INT		BIT(3)
+
+#define TPS6594X_CONFIG_NSLEEP1_MASK		BIT(6)
+#define TPS6594X_CONFIG_NSLEEP2_MASK		BIT(7)
+
+#define TPS6594X_FSM_I2C_TRIGGERS_I2C0		BIT(0)
+
+#define TPS6594X_FSM_NSLEEP_NSLEEP1B		BIT(0)
+#define TPS6594X_FSM_NSLEEP_NSLEEP2B		BIT(1)
+
+#define TPS6594X_RTC_CTRL_REG_GET_TIME		BIT(6)
+#define TPS6594X_RTC_CTRL_REG_STOP_RTC		BIT(0)
+#define TPS6594X_RTC_INTERRUPTS_REG_IT_ALARM	BIT(3)
+
+#define TPS6594X_RTC_STATUS_RUN			BIT(1)
+
+/**
+ * struct tps6594x - state holder for the tps6594x driver
+ * @dev: struct device pointer for MFD device
+ * @rev: revision of the tps6594x
+ * @lock: lock guarding the data structure
+ * @regmap: register map of the tps6594x PMIC
+ *
+ * Device data may be used to access the TPS6594X chip
+ */
+struct tps6594x {
+	struct device *dev;
+	u8 rev;
+	struct regmap *regmap;
+};
+#endif /* __MFD_TPS6594X_H */
-- 
2.38.GIT


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v4 2/4] MFD: TPS6594x: Add new PMIC device driver for TPS6594x chips
@ 2022-11-18  9:22   ` Matt Ranostay
  0 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-18  9:22 UTC (permalink / raw)
  To: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Keerthy,
	Matt Ranostay

From: Keerthy <j-keerthy@ti.com>

The TPS6594x chip is a PMIC, and contains the following components:

- GPIO controller
- RTC

Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Matt Ranostay <mranostay@ti.com>
---
 drivers/mfd/Kconfig          |  14 +++++
 drivers/mfd/Makefile         |   1 +
 drivers/mfd/tps6594x.c       | 113 +++++++++++++++++++++++++++++++++++
 include/linux/mfd/tps6594x.h |  84 ++++++++++++++++++++++++++
 4 files changed, 212 insertions(+)
 create mode 100644 drivers/mfd/tps6594x.c
 create mode 100644 include/linux/mfd/tps6594x.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 6653d03e0fe3..f19178cf9c61 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1596,6 +1596,20 @@ config MFD_TI_LP873X
 	  This driver can also be built as a module. If so, the module
 	  will be called lp873x.
 
+config MFD_TPS6594X
+	tristate "TI TPS6594X Power Management IC"
+	depends on I2C && OF
+	select MFD_CORE
+	select REGMAP_I2C
+	help
+	  If you say yes here then you get support for the TPS6594X series of
+	  Power Management Integrated Circuits (PMIC).
+	  These include voltage regulators, RTS, configurable
+	  General Purpose Outputs (GPO) that are used in portable devices.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called tps6594x.
+
 config MFD_TI_LP87565
 	tristate "TI LP87565 Power Management IC"
 	depends on I2C && OF
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 4dd479212b3a..51d7bfcd0a27 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -101,6 +101,7 @@ obj-$(CONFIG_MFD_TPS65910)	+= tps65910.o
 obj-$(CONFIG_MFD_TPS65912)	+= tps65912-core.o
 obj-$(CONFIG_MFD_TPS65912_I2C)	+= tps65912-i2c.o
 obj-$(CONFIG_MFD_TPS65912_SPI)  += tps65912-spi.o
+obj-$(CONFIG_MFD_TPS6594X)	+= tps6594x.o
 obj-$(CONFIG_MENELAUS)		+= menelaus.o
 
 obj-$(CONFIG_TWL4030_CORE)	+= twl-core.o twl4030-irq.o twl6030-irq.o
diff --git a/drivers/mfd/tps6594x.c b/drivers/mfd/tps6594x.c
new file mode 100644
index 000000000000..700e887a0966
--- /dev/null
+++ b/drivers/mfd/tps6594x.c
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Driver for tps6594x PMIC chips
+ *
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ * Author: Keerthy <j-keerthy@ti.com>
+ */
+
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/tps6594x.h>
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/regmap.h>
+
+static const struct regmap_config tps6594x_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = TPS6594X_REG_MAX,
+};
+
+static const struct mfd_cell tps6594x_cells[] = {
+	{ .name = "tps6594-gpio" },
+	{ .name = "tps6594-rtc" },
+};
+
+static struct tps6594x *tps;
+
+static void tps6594x_power_off(void)
+{
+	regmap_write(tps->regmap, TPS6594X_FSM_NSLEEP_TRIGGERS,
+		TPS6594X_FSM_NSLEEP_NSLEEP1B | TPS6594X_FSM_NSLEEP_NSLEEP2B);
+
+	regmap_write(tps->regmap, TPS6594X_INT_STARTUP,
+		TPS6594X_INT_STARTUP_NPWRON_START_INT |
+		TPS6594X_INT_STARTUP_ENABLE_INT | TPS6594X_INT_STARTUP_RTC_INT |
+		TPS6594X_INT_STARTUP_SOFT_REBOOT_INT);
+
+	regmap_write(tps->regmap, TPS6594X_INT_MISC,
+		TPS6594X_INT_MISC_BIST_PASS_INT |
+		TPS6594X_INT_MISC_EXT_CLK_INT | TPS6594X_INT_MISC_TWARN_INT);
+
+	regmap_write(tps->regmap, TPS6594X_CONFIG_1,
+		TPS6594X_CONFIG_NSLEEP1_MASK | TPS6594X_CONFIG_NSLEEP2_MASK);
+
+	regmap_write(tps->regmap, TPS6594X_FSM_I2C_TRIGGERS,
+		TPS6594X_FSM_I2C_TRIGGERS_I2C0);
+}
+
+static int tps6594x_probe(struct i2c_client *client)
+{
+	struct tps6594x *ddata;
+	struct device_node *node = client->dev.of_node;
+	unsigned int otpid;
+	int ret;
+
+	ddata = devm_kzalloc(&client->dev, sizeof(*ddata), GFP_KERNEL);
+	if (!ddata)
+		return -ENOMEM;
+
+	ddata->dev = &client->dev;
+
+	ddata->regmap = devm_regmap_init_i2c(client, &tps6594x_regmap_config);
+	if (IS_ERR(ddata->regmap))
+		return dev_err_probe(ddata->dev, PTR_ERR(ddata->regmap),
+			"Failed to initialize register map\n");
+
+	ret = regmap_read(ddata->regmap, TPS6594X_REG_DEV_REV, &otpid);
+	if (ret)
+		return dev_err_probe(ddata->dev, ret, "Failed to read OTP ID\n");
+
+	ddata->rev = otpid;
+	i2c_set_clientdata(client, ddata);
+
+	ret = mfd_add_devices(ddata->dev, PLATFORM_DEVID_AUTO, tps6594x_cells,
+			      ARRAY_SIZE(tps6594x_cells), NULL, 0, NULL);
+	if (ret)
+		return dev_err_probe(ddata->dev, ret, "Failed to register cells\n");
+
+	tps = ddata;
+
+	if (of_property_read_bool(node, "ti,system-power-controller"))
+		pm_power_off = tps6594x_power_off;
+
+	return 0;
+}
+
+static const struct of_device_id of_tps6594x_match_table[] = {
+	{ .compatible = "ti,tps6594", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, of_tps6594x_match_table);
+
+static const struct i2c_device_id tps6594x_id_table[] = {
+	{ "tps6594", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, tps6594x_id_table);
+
+static struct i2c_driver tps6594x_driver = {
+	.driver	= {
+		.name	= "tps6594",
+		.of_match_table = of_tps6594x_match_table,
+	},
+	.probe_new	= tps6594x_probe,
+	.id_table	= tps6594x_id_table,
+};
+module_i2c_driver(tps6594x_driver);
+
+MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
+MODULE_DESCRIPTION("TPS6594X PMIC device driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/tps6594x.h b/include/linux/mfd/tps6594x.h
new file mode 100644
index 000000000000..5a6af0da9223
--- /dev/null
+++ b/include/linux/mfd/tps6594x.h
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Core driver interface for TI TPS6594x PMIC family
+ *
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#ifndef __MFD_TPS6594X_H
+#define __MFD_TPS6594X_H
+
+#include <linux/bits.h>
+
+/* TPS6594x chip ID list */
+#define TPS6594X			0x00
+
+/* All register addresses */
+#define TPS6594X_REG_DEV_REV			0x01
+#define TPS6594X_INT_STARTUP			0x65
+#define TPS6594X_INT_MISC			0x66
+#define TPS6594X_CONFIG_1			0x7d
+#define TPS6594X_FSM_I2C_TRIGGERS		0x85
+#define TPS6594X_FSM_NSLEEP_TRIGGERS		0x86
+
+#define TPS6594X_RTC_SECONDS			0xb5
+#define TPS6594X_RTC_MINUTES			0xb6
+#define TPS6594X_RTC_HOURS			0xb7
+#define TPS6594X_RTC_DAYS			0xb8
+#define TPS6594X_RTC_MONTHS			0xb9
+#define TPS6594X_RTC_YEARS			0xba
+#define TPS6594X_RTC_WEEKS			0xbb
+#define TPS6594X_ALARM_SECONDS			0xbc
+#define TPS6594X_ALARM_MINUTES			0xbd
+#define TPS6594X_ALARM_HOURS			0xbe
+#define TPS6594X_ALARM_DAYS			0xbf
+#define TPS6594X_ALARM_MONTHS			0xc0
+#define TPS6594X_ALARM_YEARS			0xc1
+#define TPS6594X_RTC_CTRL_1			0xc2
+#define TPS6594X_RTC_CTRL_2			0xc3
+#define TPS6594X_RTC_STATUS			0xc4
+#define TPS6594X_RTC_INTERRUPTS			0xc5
+#define TPS6594X_REG_MAX			0xd0
+
+/* Register field definitions */
+#define TPS6594X_DEV_REV_DEV_ID			0xff
+
+#define TPS6594X_INT_STARTUP_NPWRON_START_INT	BIT(0)
+#define TPS6594X_INT_STARTUP_ENABLE_INT		BIT(1)
+#define TPS6594X_INT_STARTUP_RTC_INT		BIT(2)
+#define TPS6594X_INT_STARTUP_FSD_INT		BIT(4)
+#define TPS6594X_INT_STARTUP_SOFT_REBOOT_INT	BIT(5)
+
+#define TPS6594X_INT_MISC_BIST_PASS_INT		BIT(0)
+#define TPS6594X_INT_MISC_EXT_CLK_INT		BIT(1)
+#define TPS6594X_INT_MISC_TWARN_INT		BIT(3)
+
+#define TPS6594X_CONFIG_NSLEEP1_MASK		BIT(6)
+#define TPS6594X_CONFIG_NSLEEP2_MASK		BIT(7)
+
+#define TPS6594X_FSM_I2C_TRIGGERS_I2C0		BIT(0)
+
+#define TPS6594X_FSM_NSLEEP_NSLEEP1B		BIT(0)
+#define TPS6594X_FSM_NSLEEP_NSLEEP2B		BIT(1)
+
+#define TPS6594X_RTC_CTRL_REG_GET_TIME		BIT(6)
+#define TPS6594X_RTC_CTRL_REG_STOP_RTC		BIT(0)
+#define TPS6594X_RTC_INTERRUPTS_REG_IT_ALARM	BIT(3)
+
+#define TPS6594X_RTC_STATUS_RUN			BIT(1)
+
+/**
+ * struct tps6594x - state holder for the tps6594x driver
+ * @dev: struct device pointer for MFD device
+ * @rev: revision of the tps6594x
+ * @lock: lock guarding the data structure
+ * @regmap: register map of the tps6594x PMIC
+ *
+ * Device data may be used to access the TPS6594X chip
+ */
+struct tps6594x {
+	struct device *dev;
+	u8 rev;
+	struct regmap *regmap;
+};
+#endif /* __MFD_TPS6594X_H */
-- 
2.38.GIT


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v4 3/4] rtc: rtc-tps6594x: Add support for TPS6594X PMIC RTC
  2022-11-18  9:22 ` Matt Ranostay
@ 2022-11-18  9:22   ` Matt Ranostay
  -1 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-18  9:22 UTC (permalink / raw)
  To: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Keerthy,
	Matt Ranostay

From: Keerthy <j-keerthy@ti.com>

Add support for TPS6594X PMIC RTC. However, currently only get/set of
time + date functionality is supported.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Matt Ranostay <mranostay@ti.com>
---
 drivers/rtc/Kconfig        |  10 +++
 drivers/rtc/Makefile       |   1 +
 drivers/rtc/rtc-tps6594x.c | 155 +++++++++++++++++++++++++++++++++++++
 3 files changed, 166 insertions(+)
 create mode 100644 drivers/rtc/rtc-tps6594x.c

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index ab9a1f814119..50e0de4d6eb3 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -588,6 +588,16 @@ config RTC_DRV_TPS65910
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-tps65910.
 
+config RTC_DRV_TPS6594X
+	tristate "TI TPS6594X RTC driver"
+	depends on MFD_TPS6594X || COMPILE_TEST
+	help
+	  If you say yes here you get support for the RTC of TI TPS6594X series PMIC
+	  chips.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-tps6594x.
+
 config RTC_DRV_RC5T583
 	tristate "RICOH 5T583 RTC driver"
 	depends on MFD_RC5T583
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index d3c042dcbc73..5e3a3b06fc20 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -175,6 +175,7 @@ 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_TPS65910)	+= rtc-tps65910.o
+obj-$(CONFIG_RTC_DRV_TPS6594X)	+= rtc-tps6594x.o
 obj-$(CONFIG_RTC_DRV_TWL4030)	+= rtc-twl.o
 obj-$(CONFIG_RTC_DRV_V3020)	+= rtc-v3020.o
 obj-$(CONFIG_RTC_DRV_VT8500)	+= rtc-vt8500.o
diff --git a/drivers/rtc/rtc-tps6594x.c b/drivers/rtc/rtc-tps6594x.c
new file mode 100644
index 000000000000..20fe076112e6
--- /dev/null
+++ b/drivers/rtc/rtc-tps6594x.c
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * rtc-tps6594x.c -- TPS6594x Real Time Clock driver.
+ *
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com
+ */
+
+#include <linux/bcd.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/mfd/tps6594x.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/rtc.h>
+#include <linux/types.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+struct tps6594x_rtc {
+	struct rtc_device	*rtc;
+	struct device		*dev;
+};
+
+#define TPS6594X_RTC_POLL	20000
+#define TPS6594X_RTC_TIMEOUT	100000
+
+#define TPS6594X_NUM_TIME_REGS	(TPS6594X_RTC_YEARS - TPS6594X_RTC_SECONDS + 1)
+
+static int tps6594x_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+	unsigned char rtc_data[TPS6594X_NUM_TIME_REGS];
+	struct tps6594x *tps6594x = dev_get_drvdata(dev->parent);
+	int ret;
+
+	/* Reset TPS6594X_RTC_CTRL_REG_GET_TIME bit to zero, required for latch */
+	ret = regmap_update_bits(tps6594x->regmap, TPS6594X_RTC_CTRL_1,
+		TPS6594X_RTC_CTRL_REG_GET_TIME, 0);
+	if (ret < 0)
+		return ret;
+
+	/* Copy RTC counting registers to static registers or latches */
+	ret = regmap_update_bits(tps6594x->regmap, TPS6594X_RTC_CTRL_1,
+		TPS6594X_RTC_CTRL_REG_GET_TIME, TPS6594X_RTC_CTRL_REG_GET_TIME);
+	if (ret < 0)
+		return ret;
+
+	ret = regmap_bulk_read(tps6594x->regmap, TPS6594X_RTC_SECONDS,
+			rtc_data, TPS6594X_NUM_TIME_REGS);
+	if (ret < 0)
+		return ret;
+
+	tm->tm_sec = bcd2bin(rtc_data[0]);
+	tm->tm_min = bcd2bin(rtc_data[1]);
+	tm->tm_hour = bcd2bin(rtc_data[2]);
+	tm->tm_mday = bcd2bin(rtc_data[3]);
+	tm->tm_mon = bcd2bin(rtc_data[4]) - 1;
+	tm->tm_year = bcd2bin(rtc_data[5]) + 100;
+
+	return ret;
+}
+
+static int tps6594x_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+	unsigned char rtc_data[TPS6594X_NUM_TIME_REGS];
+	struct tps6594x *tps6594x = dev_get_drvdata(dev->parent);
+	unsigned int val;
+	int ret;
+
+	rtc_data[0] = bin2bcd(tm->tm_sec);
+	rtc_data[1] = bin2bcd(tm->tm_min);
+	rtc_data[2] = bin2bcd(tm->tm_hour);
+	rtc_data[3] = bin2bcd(tm->tm_mday);
+	rtc_data[4] = bin2bcd(tm->tm_mon + 1);
+	rtc_data[5] = bin2bcd(tm->tm_year - 100);
+
+	/* Stop RTC while updating the RTC time registers */
+	ret = regmap_update_bits(tps6594x->regmap, TPS6594X_RTC_CTRL_1,
+				 TPS6594X_RTC_CTRL_REG_STOP_RTC, 0);
+	if (ret < 0) {
+		dev_err(dev, "RTC stop failed, err = %d\n", ret);
+		return ret;
+	}
+
+	/* Waiting till RTC isn't running */
+	ret = regmap_read_poll_timeout(tps6594x->regmap, TPS6594X_RTC_STATUS,
+				       val, !(val & TPS6594X_RTC_STATUS_RUN),
+				       TPS6594X_RTC_POLL, TPS6594X_RTC_TIMEOUT);
+	if (ret) {
+		dev_err(dev, "RTC_STATUS is still RUNNING\n");
+		return ret;
+	}
+
+	ret = regmap_bulk_write(tps6594x->regmap, TPS6594X_RTC_SECONDS,
+		rtc_data, TPS6594X_NUM_TIME_REGS);
+	if (ret < 0) {
+		dev_err(dev, "RTC_SECONDS reg write failed, err = %d\n", ret);
+		return ret;
+	}
+
+	/* Start back RTC */
+	ret = regmap_update_bits(tps6594x->regmap, TPS6594X_RTC_CTRL_1,
+				 TPS6594X_RTC_CTRL_REG_STOP_RTC,
+				 TPS6594X_RTC_CTRL_REG_STOP_RTC);
+	if (ret < 0)
+		dev_err(dev, "RTC start failed, err = %d\n", ret);
+
+	return ret;
+}
+
+static const struct rtc_class_ops tps6594x_rtc_ops = {
+	.read_time	= tps6594x_rtc_read_time,
+	.set_time	= tps6594x_rtc_set_time,
+};
+
+static int tps6594x_rtc_probe(struct platform_device *pdev)
+{
+	struct tps6594x_rtc *tps6594x_rtc;
+
+	tps6594x_rtc = devm_kzalloc(&pdev->dev, sizeof(*tps6594x_rtc), GFP_KERNEL);
+	if (!tps6594x_rtc)
+		return -ENOMEM;
+
+	tps6594x_rtc->dev = &pdev->dev;
+	platform_set_drvdata(pdev, tps6594x_rtc);
+
+	tps6594x_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(tps6594x_rtc->rtc))
+		return PTR_ERR(tps6594x_rtc->rtc);
+
+	tps6594x_rtc->rtc->ops = &tps6594x_rtc_ops;
+
+	return devm_rtc_register_device(tps6594x_rtc->rtc);
+}
+
+static const struct of_device_id of_tps6594x_rtc_match[] = {
+	{ .compatible = "ti,tps6594-rtc", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, of_tps6594x_rtc_match);
+
+static struct platform_driver tps6594x_rtc_driver = {
+	.probe		= tps6594x_rtc_probe,
+	.driver		= {
+		.name	= "tps6594-rtc",
+		.of_match_table = of_tps6594x_rtc_match,
+	},
+};
+
+module_platform_driver(tps6594x_rtc_driver);
+
+MODULE_ALIAS("platform:tps6594-rtc");
+MODULE_DESCRIPTION("TI TPS6594x series RTC driver");
+MODULE_AUTHOR("Keerthy J <j-keerthy@ti.com>");
+MODULE_LICENSE("GPL");
-- 
2.38.GIT


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v4 3/4] rtc: rtc-tps6594x: Add support for TPS6594X PMIC RTC
@ 2022-11-18  9:22   ` Matt Ranostay
  0 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-18  9:22 UTC (permalink / raw)
  To: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Keerthy,
	Matt Ranostay

From: Keerthy <j-keerthy@ti.com>

Add support for TPS6594X PMIC RTC. However, currently only get/set of
time + date functionality is supported.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Matt Ranostay <mranostay@ti.com>
---
 drivers/rtc/Kconfig        |  10 +++
 drivers/rtc/Makefile       |   1 +
 drivers/rtc/rtc-tps6594x.c | 155 +++++++++++++++++++++++++++++++++++++
 3 files changed, 166 insertions(+)
 create mode 100644 drivers/rtc/rtc-tps6594x.c

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index ab9a1f814119..50e0de4d6eb3 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -588,6 +588,16 @@ config RTC_DRV_TPS65910
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-tps65910.
 
+config RTC_DRV_TPS6594X
+	tristate "TI TPS6594X RTC driver"
+	depends on MFD_TPS6594X || COMPILE_TEST
+	help
+	  If you say yes here you get support for the RTC of TI TPS6594X series PMIC
+	  chips.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-tps6594x.
+
 config RTC_DRV_RC5T583
 	tristate "RICOH 5T583 RTC driver"
 	depends on MFD_RC5T583
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index d3c042dcbc73..5e3a3b06fc20 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -175,6 +175,7 @@ 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_TPS65910)	+= rtc-tps65910.o
+obj-$(CONFIG_RTC_DRV_TPS6594X)	+= rtc-tps6594x.o
 obj-$(CONFIG_RTC_DRV_TWL4030)	+= rtc-twl.o
 obj-$(CONFIG_RTC_DRV_V3020)	+= rtc-v3020.o
 obj-$(CONFIG_RTC_DRV_VT8500)	+= rtc-vt8500.o
diff --git a/drivers/rtc/rtc-tps6594x.c b/drivers/rtc/rtc-tps6594x.c
new file mode 100644
index 000000000000..20fe076112e6
--- /dev/null
+++ b/drivers/rtc/rtc-tps6594x.c
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * rtc-tps6594x.c -- TPS6594x Real Time Clock driver.
+ *
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com
+ */
+
+#include <linux/bcd.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/mfd/tps6594x.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/rtc.h>
+#include <linux/types.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+struct tps6594x_rtc {
+	struct rtc_device	*rtc;
+	struct device		*dev;
+};
+
+#define TPS6594X_RTC_POLL	20000
+#define TPS6594X_RTC_TIMEOUT	100000
+
+#define TPS6594X_NUM_TIME_REGS	(TPS6594X_RTC_YEARS - TPS6594X_RTC_SECONDS + 1)
+
+static int tps6594x_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+	unsigned char rtc_data[TPS6594X_NUM_TIME_REGS];
+	struct tps6594x *tps6594x = dev_get_drvdata(dev->parent);
+	int ret;
+
+	/* Reset TPS6594X_RTC_CTRL_REG_GET_TIME bit to zero, required for latch */
+	ret = regmap_update_bits(tps6594x->regmap, TPS6594X_RTC_CTRL_1,
+		TPS6594X_RTC_CTRL_REG_GET_TIME, 0);
+	if (ret < 0)
+		return ret;
+
+	/* Copy RTC counting registers to static registers or latches */
+	ret = regmap_update_bits(tps6594x->regmap, TPS6594X_RTC_CTRL_1,
+		TPS6594X_RTC_CTRL_REG_GET_TIME, TPS6594X_RTC_CTRL_REG_GET_TIME);
+	if (ret < 0)
+		return ret;
+
+	ret = regmap_bulk_read(tps6594x->regmap, TPS6594X_RTC_SECONDS,
+			rtc_data, TPS6594X_NUM_TIME_REGS);
+	if (ret < 0)
+		return ret;
+
+	tm->tm_sec = bcd2bin(rtc_data[0]);
+	tm->tm_min = bcd2bin(rtc_data[1]);
+	tm->tm_hour = bcd2bin(rtc_data[2]);
+	tm->tm_mday = bcd2bin(rtc_data[3]);
+	tm->tm_mon = bcd2bin(rtc_data[4]) - 1;
+	tm->tm_year = bcd2bin(rtc_data[5]) + 100;
+
+	return ret;
+}
+
+static int tps6594x_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+	unsigned char rtc_data[TPS6594X_NUM_TIME_REGS];
+	struct tps6594x *tps6594x = dev_get_drvdata(dev->parent);
+	unsigned int val;
+	int ret;
+
+	rtc_data[0] = bin2bcd(tm->tm_sec);
+	rtc_data[1] = bin2bcd(tm->tm_min);
+	rtc_data[2] = bin2bcd(tm->tm_hour);
+	rtc_data[3] = bin2bcd(tm->tm_mday);
+	rtc_data[4] = bin2bcd(tm->tm_mon + 1);
+	rtc_data[5] = bin2bcd(tm->tm_year - 100);
+
+	/* Stop RTC while updating the RTC time registers */
+	ret = regmap_update_bits(tps6594x->regmap, TPS6594X_RTC_CTRL_1,
+				 TPS6594X_RTC_CTRL_REG_STOP_RTC, 0);
+	if (ret < 0) {
+		dev_err(dev, "RTC stop failed, err = %d\n", ret);
+		return ret;
+	}
+
+	/* Waiting till RTC isn't running */
+	ret = regmap_read_poll_timeout(tps6594x->regmap, TPS6594X_RTC_STATUS,
+				       val, !(val & TPS6594X_RTC_STATUS_RUN),
+				       TPS6594X_RTC_POLL, TPS6594X_RTC_TIMEOUT);
+	if (ret) {
+		dev_err(dev, "RTC_STATUS is still RUNNING\n");
+		return ret;
+	}
+
+	ret = regmap_bulk_write(tps6594x->regmap, TPS6594X_RTC_SECONDS,
+		rtc_data, TPS6594X_NUM_TIME_REGS);
+	if (ret < 0) {
+		dev_err(dev, "RTC_SECONDS reg write failed, err = %d\n", ret);
+		return ret;
+	}
+
+	/* Start back RTC */
+	ret = regmap_update_bits(tps6594x->regmap, TPS6594X_RTC_CTRL_1,
+				 TPS6594X_RTC_CTRL_REG_STOP_RTC,
+				 TPS6594X_RTC_CTRL_REG_STOP_RTC);
+	if (ret < 0)
+		dev_err(dev, "RTC start failed, err = %d\n", ret);
+
+	return ret;
+}
+
+static const struct rtc_class_ops tps6594x_rtc_ops = {
+	.read_time	= tps6594x_rtc_read_time,
+	.set_time	= tps6594x_rtc_set_time,
+};
+
+static int tps6594x_rtc_probe(struct platform_device *pdev)
+{
+	struct tps6594x_rtc *tps6594x_rtc;
+
+	tps6594x_rtc = devm_kzalloc(&pdev->dev, sizeof(*tps6594x_rtc), GFP_KERNEL);
+	if (!tps6594x_rtc)
+		return -ENOMEM;
+
+	tps6594x_rtc->dev = &pdev->dev;
+	platform_set_drvdata(pdev, tps6594x_rtc);
+
+	tps6594x_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(tps6594x_rtc->rtc))
+		return PTR_ERR(tps6594x_rtc->rtc);
+
+	tps6594x_rtc->rtc->ops = &tps6594x_rtc_ops;
+
+	return devm_rtc_register_device(tps6594x_rtc->rtc);
+}
+
+static const struct of_device_id of_tps6594x_rtc_match[] = {
+	{ .compatible = "ti,tps6594-rtc", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, of_tps6594x_rtc_match);
+
+static struct platform_driver tps6594x_rtc_driver = {
+	.probe		= tps6594x_rtc_probe,
+	.driver		= {
+		.name	= "tps6594-rtc",
+		.of_match_table = of_tps6594x_rtc_match,
+	},
+};
+
+module_platform_driver(tps6594x_rtc_driver);
+
+MODULE_ALIAS("platform:tps6594-rtc");
+MODULE_DESCRIPTION("TI TPS6594x series RTC driver");
+MODULE_AUTHOR("Keerthy J <j-keerthy@ti.com>");
+MODULE_LICENSE("GPL");
-- 
2.38.GIT


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v4 4/4] gpio: gpio-tps6594x: add GPIO support for TPS6594x PMIC
  2022-11-18  9:22 ` Matt Ranostay
@ 2022-11-18  9:22   ` Matt Ranostay
  -1 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-18  9:22 UTC (permalink / raw)
  To: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Matt Ranostay

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


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v4 4/4] gpio: gpio-tps6594x: add GPIO support for TPS6594x PMIC
@ 2022-11-18  9:22   ` Matt Ranostay
  0 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-18  9:22 UTC (permalink / raw)
  To: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Matt Ranostay

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

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 1/4] Documentation: ti,tps6594: Add DT bindings for the TPS6594x PMIC
  2022-11-18  9:22   ` Matt Ranostay
@ 2022-11-18 10:21     ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 24+ messages in thread
From: Krzysztof Kozlowski @ 2022-11-18 10:21 UTC (permalink / raw)
  To: Matt Ranostay, vigneshr, robh, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc

On 18/11/2022 10:22, Matt Ranostay wrote:
> Add documentation for the TPS6594x PMIC including its RTC and GPIO
> functionalities.
> 

This is a friendly reminder during the review process.

It seems my previous comments were not fully addressed. Maybe my
feedback got lost between the quotes, maybe you just forgot to apply it.
Please go back to the previous discussion and either implement all
requested changes or keep discussing them.

Thank you.

The comment was about proper subject prefix. Drop also redundant, second
"DT bindings" from the subject.


> Signed-off-by: Matt Ranostay <mranostay@ti.com>
> ---
>  .../devicetree/bindings/mfd/ti,tps6594.yaml   | 65 +++++++++++++++++++
>  1 file changed, 65 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> 
> diff --git a/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> new file mode 100644
> index 000000000000..81613bcef39d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> @@ -0,0 +1,65 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mfd/ti,tps6594x.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TPS6594x Power Management Integrated Circuit (PMIC)
> +
> +maintainers:
> +  - Keerthy <j-keerthy@ti.com>
> +
> +properties:
> +  compatible:
> +    enum:
> +      - ti,tps6594

tps6594 is the model name? So what was previous tps6594x used also in
title? This does not look correct.

> +
> +  reg:
> +    const: 0x48
> +
> +  ti,system-power-controller:
> +    type: boolean
> +    description: PMIC is controlling the system power.
> +
> +  rtc:
> +    type: object
> +    $ref: /schemas/rtc/rtc.yaml#
> +    unevaluatedProperties: false
> +    properties:
> +      compatible:
> +        const: ti,tps6594-rtc

Same problem.

> +
> +  gpio:
> +    type: object
> +    unevaluatedProperties: false
> +    properties:
> +      compatible:
> +        const: ti,tps6594x-gpio


Not fixed.



> +
> +additionalProperties: false
> +
> +required:
> +  - compatible
> +  - reg
> +
> +examples:
> +  - |
> +    i2c0 {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        pmic: pmic@48 {
> +            compatible = "ti,tps6594";
> +            reg = <0x48>;
> +
> +            rtc {
> +                compatible = "ti,tps6594-rtc";
> +            };
> +
> +            gpio {
> +                compatible = "ti,tps6594-gpio";

Does not look like you tested the bindings. Please run `make
dt_binding_check` (see
Documentation/devicetree/bindings/writing-schema.rst for instructions).


Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 1/4] Documentation: ti,tps6594: Add DT bindings for the TPS6594x PMIC
@ 2022-11-18 10:21     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 24+ messages in thread
From: Krzysztof Kozlowski @ 2022-11-18 10:21 UTC (permalink / raw)
  To: Matt Ranostay, vigneshr, robh, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc

On 18/11/2022 10:22, Matt Ranostay wrote:
> Add documentation for the TPS6594x PMIC including its RTC and GPIO
> functionalities.
> 

This is a friendly reminder during the review process.

It seems my previous comments were not fully addressed. Maybe my
feedback got lost between the quotes, maybe you just forgot to apply it.
Please go back to the previous discussion and either implement all
requested changes or keep discussing them.

Thank you.

The comment was about proper subject prefix. Drop also redundant, second
"DT bindings" from the subject.


> Signed-off-by: Matt Ranostay <mranostay@ti.com>
> ---
>  .../devicetree/bindings/mfd/ti,tps6594.yaml   | 65 +++++++++++++++++++
>  1 file changed, 65 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> 
> diff --git a/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> new file mode 100644
> index 000000000000..81613bcef39d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> @@ -0,0 +1,65 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mfd/ti,tps6594x.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TPS6594x Power Management Integrated Circuit (PMIC)
> +
> +maintainers:
> +  - Keerthy <j-keerthy@ti.com>
> +
> +properties:
> +  compatible:
> +    enum:
> +      - ti,tps6594

tps6594 is the model name? So what was previous tps6594x used also in
title? This does not look correct.

> +
> +  reg:
> +    const: 0x48
> +
> +  ti,system-power-controller:
> +    type: boolean
> +    description: PMIC is controlling the system power.
> +
> +  rtc:
> +    type: object
> +    $ref: /schemas/rtc/rtc.yaml#
> +    unevaluatedProperties: false
> +    properties:
> +      compatible:
> +        const: ti,tps6594-rtc

Same problem.

> +
> +  gpio:
> +    type: object
> +    unevaluatedProperties: false
> +    properties:
> +      compatible:
> +        const: ti,tps6594x-gpio


Not fixed.



> +
> +additionalProperties: false
> +
> +required:
> +  - compatible
> +  - reg
> +
> +examples:
> +  - |
> +    i2c0 {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        pmic: pmic@48 {
> +            compatible = "ti,tps6594";
> +            reg = <0x48>;
> +
> +            rtc {
> +                compatible = "ti,tps6594-rtc";
> +            };
> +
> +            gpio {
> +                compatible = "ti,tps6594-gpio";

Does not look like you tested the bindings. Please run `make
dt_binding_check` (see
Documentation/devicetree/bindings/writing-schema.rst for instructions).


Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 2/4] MFD: TPS6594x: Add new PMIC device driver for TPS6594x chips
  2022-11-18  9:22   ` Matt Ranostay
@ 2022-11-18 10:23     ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 24+ messages in thread
From: Krzysztof Kozlowski @ 2022-11-18 10:23 UTC (permalink / raw)
  To: Matt Ranostay, vigneshr, robh, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Keerthy

On 18/11/2022 10:22, Matt Ranostay wrote:
> From: Keerthy <j-keerthy@ti.com>
> 
> The TPS6594x chip is a PMIC, and contains the following components:

No improvements in the subject. The subject prefixes are lowercase.

In the binding you said device is "TPS6594", not TPS6594x.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 2/4] MFD: TPS6594x: Add new PMIC device driver for TPS6594x chips
@ 2022-11-18 10:23     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 24+ messages in thread
From: Krzysztof Kozlowski @ 2022-11-18 10:23 UTC (permalink / raw)
  To: Matt Ranostay, vigneshr, robh, a.zummo, linus.walleij, lee, brgl
  Cc: linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Keerthy

On 18/11/2022 10:22, Matt Ranostay wrote:
> From: Keerthy <j-keerthy@ti.com>
> 
> The TPS6594x chip is a PMIC, and contains the following components:

No improvements in the subject. The subject prefixes are lowercase.

In the binding you said device is "TPS6594", not TPS6594x.

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 1/4] Documentation: ti,tps6594: Add DT bindings for the TPS6594x PMIC
  2022-11-18  9:22   ` Matt Ranostay
@ 2022-11-18 13:31     ` Rob Herring
  -1 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2022-11-18 13:31 UTC (permalink / raw)
  To: Matt Ranostay
  Cc: brgl, devicetree, krzysztof.kozlowski, a.zummo, vigneshr,
	linux-gpio, linux-rtc, linux-arm-kernel, lee, linus.walleij


On Fri, 18 Nov 2022 01:22:15 -0800, Matt Ranostay wrote:
> Add documentation for the TPS6594x PMIC including its RTC and GPIO
> functionalities.
> 
> Signed-off-by: Matt Ranostay <mranostay@ti.com>
> ---
>  .../devicetree/bindings/mfd/ti,tps6594.yaml   | 65 +++++++++++++++++++
>  1 file changed, 65 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/mfd/ti,tps6594.yaml: $id: relative path/filename doesn't match actual path or filename
	expected: http://devicetree.org/schemas/mfd/ti,tps6594.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/ti,tps6594.example.dtb: pmic@48: gpio: Unevaluated properties are not allowed ('compatible' was unexpected)
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/ti,tps6594.example.dtb: pmic@48: gpio:compatible:0: 'ti,tps6594x-gpio' was expected
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
Documentation/devicetree/bindings/mfd/ti,tps6594.example.dtb:0:0: /example-0/i2c0/pmic@48/gpio: failed to match any schema with compatible: ['ti,tps6594-gpio']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20221118092218.480147-2-mranostay@ti.com

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command.


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 1/4] Documentation: ti,tps6594: Add DT bindings for the TPS6594x PMIC
@ 2022-11-18 13:31     ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2022-11-18 13:31 UTC (permalink / raw)
  To: Matt Ranostay
  Cc: brgl, devicetree, krzysztof.kozlowski, a.zummo, vigneshr,
	linux-gpio, linux-rtc, linux-arm-kernel, lee, linus.walleij


On Fri, 18 Nov 2022 01:22:15 -0800, Matt Ranostay wrote:
> Add documentation for the TPS6594x PMIC including its RTC and GPIO
> functionalities.
> 
> Signed-off-by: Matt Ranostay <mranostay@ti.com>
> ---
>  .../devicetree/bindings/mfd/ti,tps6594.yaml   | 65 +++++++++++++++++++
>  1 file changed, 65 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/mfd/ti,tps6594.yaml: $id: relative path/filename doesn't match actual path or filename
	expected: http://devicetree.org/schemas/mfd/ti,tps6594.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/ti,tps6594.example.dtb: pmic@48: gpio: Unevaluated properties are not allowed ('compatible' was unexpected)
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/ti,tps6594.example.dtb: pmic@48: gpio:compatible:0: 'ti,tps6594x-gpio' was expected
	From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
Documentation/devicetree/bindings/mfd/ti,tps6594.example.dtb:0:0: /example-0/i2c0/pmic@48/gpio: failed to match any schema with compatible: ['ti,tps6594-gpio']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20221118092218.480147-2-mranostay@ti.com

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 2/4] MFD: TPS6594x: Add new PMIC device driver for TPS6594x chips
  2022-11-18 10:23     ` Krzysztof Kozlowski
@ 2022-11-19  4:17       ` Matt Ranostay
  -1 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-19  4:17 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: vigneshr, robh, a.zummo, linus.walleij, lee, brgl,
	linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Keerthy

On Fri, Nov 18, 2022 at 11:23:05AM +0100, Krzysztof Kozlowski wrote:
> On 18/11/2022 10:22, Matt Ranostay wrote:
> > From: Keerthy <j-keerthy@ti.com>
> > 
> > The TPS6594x chip is a PMIC, and contains the following components:
> 
> No improvements in the subject. The subject prefixes are lowercase.
> 
> In the binding you said device is "TPS6594", not TPS6594x.
>

Sorry missed that :-/ will fix in future revisions

- Matt

> Best regards,
> Krzysztof
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 2/4] MFD: TPS6594x: Add new PMIC device driver for TPS6594x chips
@ 2022-11-19  4:17       ` Matt Ranostay
  0 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-19  4:17 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: vigneshr, robh, a.zummo, linus.walleij, lee, brgl,
	linux-arm-kernel, devicetree, linux-gpio, linux-rtc, Keerthy

On Fri, Nov 18, 2022 at 11:23:05AM +0100, Krzysztof Kozlowski wrote:
> On 18/11/2022 10:22, Matt Ranostay wrote:
> > From: Keerthy <j-keerthy@ti.com>
> > 
> > The TPS6594x chip is a PMIC, and contains the following components:
> 
> No improvements in the subject. The subject prefixes are lowercase.
> 
> In the binding you said device is "TPS6594", not TPS6594x.
>

Sorry missed that :-/ will fix in future revisions

- Matt

> Best regards,
> Krzysztof
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 1/4] Documentation: ti,tps6594: Add DT bindings for the TPS6594x PMIC
  2022-11-18 10:21     ` Krzysztof Kozlowski
@ 2022-11-19  4:23       ` Matt Ranostay
  -1 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-19  4:23 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: vigneshr, robh, a.zummo, linus.walleij, lee, brgl,
	linux-arm-kernel, devicetree, linux-gpio, linux-rtc

On Fri, Nov 18, 2022 at 11:21:57AM +0100, Krzysztof Kozlowski wrote:
> On 18/11/2022 10:22, Matt Ranostay wrote:
> > Add documentation for the TPS6594x PMIC including its RTC and GPIO
> > functionalities.
> > 
> 
> This is a friendly reminder during the review process.
> 
> It seems my previous comments were not fully addressed. Maybe my
> feedback got lost between the quotes, maybe you just forgot to apply it.
> Please go back to the previous discussion and either implement all
> requested changes or keep discussing them.
>
I missed serveral feedback suggestions in the last revision. Will try to be
a little more careful in the future.

> Thank you.
> 
> The comment was about proper subject prefix. Drop also redundant, second
> "DT bindings" from the subject.
> 
> 
> > Signed-off-by: Matt Ranostay <mranostay@ti.com>
> > ---
> >  .../devicetree/bindings/mfd/ti,tps6594.yaml   | 65 +++++++++++++++++++
> >  1 file changed, 65 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> > new file mode 100644
> > index 000000000000..81613bcef39d
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> > @@ -0,0 +1,65 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/mfd/ti,tps6594x.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: TPS6594x Power Management Integrated Circuit (PMIC)
> > +
> > +maintainers:
> > +  - Keerthy <j-keerthy@ti.com>
> > +
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - ti,tps6594
> 
> tps6594 is the model name? So what was previous tps6594x used also in
> title? This does not look correct.
>

So the actual part number is TPS6594-Q1. Would tps6594q1 be more concise
for naming across the device tree, and drivers?

- Matt

> > +
> > +  reg:
> > +    const: 0x48
> > +
> > +  ti,system-power-controller:
> > +    type: boolean
> > +    description: PMIC is controlling the system power.
> > +
> > +  rtc:
> > +    type: object
> > +    $ref: /schemas/rtc/rtc.yaml#
> > +    unevaluatedProperties: false
> > +    properties:
> > +      compatible:
> > +        const: ti,tps6594-rtc
> 
> Same problem.
> 
> > +
> > +  gpio:
> > +    type: object
> > +    unevaluatedProperties: false
> > +    properties:
> > +      compatible:
> > +        const: ti,tps6594x-gpio
> 
> 
> Not fixed.
> 
> 
> 
> > +
> > +additionalProperties: false
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +
> > +examples:
> > +  - |
> > +    i2c0 {
> > +        #address-cells = <1>;
> > +        #size-cells = <0>;
> > +
> > +        pmic: pmic@48 {
> > +            compatible = "ti,tps6594";
> > +            reg = <0x48>;
> > +
> > +            rtc {
> > +                compatible = "ti,tps6594-rtc";
> > +            };
> > +
> > +            gpio {
> > +                compatible = "ti,tps6594-gpio";
> 
> Does not look like you tested the bindings. Please run `make
> dt_binding_check` (see
> Documentation/devicetree/bindings/writing-schema.rst for instructions).
> 
> 
> Best regards,
> Krzysztof
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 1/4] Documentation: ti,tps6594: Add DT bindings for the TPS6594x PMIC
@ 2022-11-19  4:23       ` Matt Ranostay
  0 siblings, 0 replies; 24+ messages in thread
From: Matt Ranostay @ 2022-11-19  4:23 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: vigneshr, robh, a.zummo, linus.walleij, lee, brgl,
	linux-arm-kernel, devicetree, linux-gpio, linux-rtc

On Fri, Nov 18, 2022 at 11:21:57AM +0100, Krzysztof Kozlowski wrote:
> On 18/11/2022 10:22, Matt Ranostay wrote:
> > Add documentation for the TPS6594x PMIC including its RTC and GPIO
> > functionalities.
> > 
> 
> This is a friendly reminder during the review process.
> 
> It seems my previous comments were not fully addressed. Maybe my
> feedback got lost between the quotes, maybe you just forgot to apply it.
> Please go back to the previous discussion and either implement all
> requested changes or keep discussing them.
>
I missed serveral feedback suggestions in the last revision. Will try to be
a little more careful in the future.

> Thank you.
> 
> The comment was about proper subject prefix. Drop also redundant, second
> "DT bindings" from the subject.
> 
> 
> > Signed-off-by: Matt Ranostay <mranostay@ti.com>
> > ---
> >  .../devicetree/bindings/mfd/ti,tps6594.yaml   | 65 +++++++++++++++++++
> >  1 file changed, 65 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> > new file mode 100644
> > index 000000000000..81613bcef39d
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml
> > @@ -0,0 +1,65 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/mfd/ti,tps6594x.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: TPS6594x Power Management Integrated Circuit (PMIC)
> > +
> > +maintainers:
> > +  - Keerthy <j-keerthy@ti.com>
> > +
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - ti,tps6594
> 
> tps6594 is the model name? So what was previous tps6594x used also in
> title? This does not look correct.
>

So the actual part number is TPS6594-Q1. Would tps6594q1 be more concise
for naming across the device tree, and drivers?

- Matt

> > +
> > +  reg:
> > +    const: 0x48
> > +
> > +  ti,system-power-controller:
> > +    type: boolean
> > +    description: PMIC is controlling the system power.
> > +
> > +  rtc:
> > +    type: object
> > +    $ref: /schemas/rtc/rtc.yaml#
> > +    unevaluatedProperties: false
> > +    properties:
> > +      compatible:
> > +        const: ti,tps6594-rtc
> 
> Same problem.
> 
> > +
> > +  gpio:
> > +    type: object
> > +    unevaluatedProperties: false
> > +    properties:
> > +      compatible:
> > +        const: ti,tps6594x-gpio
> 
> 
> Not fixed.
> 
> 
> 
> > +
> > +additionalProperties: false
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +
> > +examples:
> > +  - |
> > +    i2c0 {
> > +        #address-cells = <1>;
> > +        #size-cells = <0>;
> > +
> > +        pmic: pmic@48 {
> > +            compatible = "ti,tps6594";
> > +            reg = <0x48>;
> > +
> > +            rtc {
> > +                compatible = "ti,tps6594-rtc";
> > +            };
> > +
> > +            gpio {
> > +                compatible = "ti,tps6594-gpio";
> 
> Does not look like you tested the bindings. Please run `make
> dt_binding_check` (see
> Documentation/devicetree/bindings/writing-schema.rst for instructions).
> 
> 
> Best regards,
> Krzysztof
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 4/4] gpio: gpio-tps6594x: add GPIO support for TPS6594x PMIC
  2022-11-18  9:22   ` Matt Ranostay
@ 2022-11-28 18:08     ` Bartosz Golaszewski
  -1 siblings, 0 replies; 24+ messages in thread
From: Bartosz Golaszewski @ 2022-11-28 18:08 UTC (permalink / raw)
  To: Matt Ranostay
  Cc: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee,
	linux-arm-kernel, devicetree, linux-gpio, linux-rtc

On Fri, Nov 18, 2022 at 10:22 AM Matt Ranostay <mranostay@ti.com> wrote:
>
> 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
>

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 4/4] gpio: gpio-tps6594x: add GPIO support for TPS6594x PMIC
@ 2022-11-28 18:08     ` Bartosz Golaszewski
  0 siblings, 0 replies; 24+ messages in thread
From: Bartosz Golaszewski @ 2022-11-28 18:08 UTC (permalink / raw)
  To: Matt Ranostay
  Cc: vigneshr, robh, krzysztof.kozlowski, a.zummo, linus.walleij, lee,
	linux-arm-kernel, devicetree, linux-gpio, linux-rtc

On Fri, Nov 18, 2022 at 10:22 AM Matt Ranostay <mranostay@ti.com> wrote:
>
> 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
>

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 4/4] gpio: gpio-tps6594x: add GPIO support for TPS6594x PMIC
  2022-11-18  9:22   ` Matt Ranostay
@ 2022-11-28 20:38     ` Linus Walleij
  -1 siblings, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2022-11-28 20:38 UTC (permalink / raw)
  To: Matt Ranostay
  Cc: vigneshr, robh, krzysztof.kozlowski, a.zummo, lee, brgl,
	linux-arm-kernel, devicetree, linux-gpio, linux-rtc

On Fri, Nov 18, 2022 at 10:22 AM Matt Ranostay <mranostay@ti.com> wrote:

> 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>

This looks really neat and clean with gpio-regmap.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 4/4] gpio: gpio-tps6594x: add GPIO support for TPS6594x PMIC
@ 2022-11-28 20:38     ` Linus Walleij
  0 siblings, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2022-11-28 20:38 UTC (permalink / raw)
  To: Matt Ranostay
  Cc: vigneshr, robh, krzysztof.kozlowski, a.zummo, lee, brgl,
	linux-arm-kernel, devicetree, linux-gpio, linux-rtc

On Fri, Nov 18, 2022 at 10:22 AM Matt Ranostay <mranostay@ti.com> wrote:

> 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>

This looks really neat and clean with gpio-regmap.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2022-11-28 20:39 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-18  9:22 [PATCH v4 0/4] mfd: add tps6594x support for Jacinto platforms Matt Ranostay
2022-11-18  9:22 ` 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  9:22   ` Matt Ranostay
2022-11-18 10:21   ` Krzysztof Kozlowski
2022-11-18 10:21     ` Krzysztof Kozlowski
2022-11-19  4:23     ` Matt Ranostay
2022-11-19  4:23       ` Matt Ranostay
2022-11-18 13:31   ` Rob Herring
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  9:22   ` Matt Ranostay
2022-11-18 10:23   ` Krzysztof Kozlowski
2022-11-18 10:23     ` Krzysztof Kozlowski
2022-11-19  4:17     ` Matt Ranostay
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
2022-11-18  9:22 ` [PATCH v4 4/4] gpio: gpio-tps6594x: add GPIO support for TPS6594x PMIC Matt Ranostay
2022-11-18  9:22   ` Matt Ranostay
2022-11-28 18:08   ` Bartosz Golaszewski
2022-11-28 18:08     ` Bartosz Golaszewski
2022-11-28 20:38   ` Linus Walleij
2022-11-28 20:38     ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.