From patchwork Wed Nov 23 05:35:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 13053062 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00050C433FE for ; Wed, 23 Nov 2022 05:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZmOuo2jVKhQMkS4ttc3x7fIoDtzPVAy1F4+oNwKOfuY=; b=Z8dIkg1bn7lR1g Hd2BqQAi0Bni0KjtM/FCDKbuqmpX+w5EEYAcNJ8cMbd5KLbgs4//dfyqE5NU/QN3iobDKKCaR07p3 n9qI/URDoVXiJ78Uxuy20HfFG/5cCt54340h9sgq6l1SD2aqd5CmSPCDX/BRIbtgXQn05D7wXa/sV OOndKstzXBWkeMMNqkjoJ4mGEV1nHj4LKa0z3/GLEQfP1WiUtpltINkH53E064sT/a6no/mCUj1kl URVzR3HVFE8xufjFxAmytohbG1lgXrsi0GWn8U3il6bvkWnC3/ZszKo9hGJwFhRSRHFRbQ8dkd/ux w7p0nSL2JUSnPhLyJx3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxiQd-00EKZs-Ng; Wed, 23 Nov 2022 05:36:11 +0000 Received: from lelv0143.ext.ti.com ([198.47.23.248]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxiQF-00EKP6-NJ for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 05:35:49 +0000 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2AN5ZfVO069638; Tue, 22 Nov 2022 23:35:41 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1669181741; bh=gtv691NYVsk28aiaN9x+rwnIaXxKLu3uYt/E+Q7kN6I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BpIJeO2pZ42hJEy9CW+9MLKnbJf8SbCeSBknQZI7xDiCesEzMnRITGQZrKYXf6I7E 6wshFVGMfIBhFz9ozBdxB+cXVZ8xRTxr64kv5XlFkB8JmnPwUZ4DIvt/fwBToDSZ8O bL9GIMl4texVlTTZnH9XD/Ox73FcUbWTyBZPCU4o= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2AN5ZfJw009670 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 22 Nov 2022 23:35:41 -0600 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Tue, 22 Nov 2022 23:35:40 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Tue, 22 Nov 2022 23:35:40 -0600 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2AN5ZbBF119209; Tue, 22 Nov 2022 23:35:39 -0600 From: Matt Ranostay To: , , , , , , , CC: , , , , Matt Ranostay Subject: [PATCH v5 1/4] dt-bindings: mfd: ti,tps6594: add TPS6594 PMIC support Date: Tue, 22 Nov 2022 21:35:09 -0800 Message-ID: <20221123053512.1195309-2-mranostay@ti.com> X-Mailer: git-send-email 2.38.GIT In-Reply-To: <20221123053512.1195309-1-mranostay@ti.com> References: <20221123053512.1195309-1-mranostay@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221122_213547_890682_5B6CA838 X-CRM114-Status: GOOD ( 11.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add documentation for the TPS6594 PMIC including its RTC and GPIO functionalities. Signed-off-by: Matt Ranostay Reviewed-by: Tony Lindgren --- .../devicetree/bindings/mfd/ti,tps6594.yaml | 69 +++++++++++++++++++ 1 file changed, 69 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..0de0db87dbf7 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/ti,tps6594.yaml @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/ti,tps6594.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TPS6594 Power Management Integrated Circuit (PMIC) + +description: | + TPS6594 Power Management Integrated Circuit (PMIC) + https://www.ti.com/lit/ds/symlink/tps6594-q1.pdf + +maintainers: + - Keerthy + +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,tps6594-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"; + }; + }; + }; + +... From patchwork Wed Nov 23 05:35:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 13053063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D37DC4332F for ; Wed, 23 Nov 2022 05:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RedFz6Potjzg9rvIP7o5wxTdnJqHEE0y1Cl/45XCt2w=; b=ZXQBhTMbqhqCab H2ZX4//skvuXBeT+bQL8Q8aix0frh6DBF2Ulbbpo6IS7GsZpo6kLxJ75N79Dxy8mPY5vxiGHykBce /Rkd+Gy8T+FGaMRIWSbctZHZ4wKbgt65jM3sCi6LxecuR5o1t3U4UvGR+KSFcbnjF4cj1CCswYmGZ iUqqUMxYx9NXfZSswBSHh9+AorNUP5aGndFSpcCWzPSJbQgf/UVQQd05qsTVcIkKyqYOu1xf+fZq5 A8Aeo0uJP2eFafANDkZLiUWAKOMYc8/dkcaJaZOlMffHzWji2vrcE5Y4z+H63ykon6u1YaeFNBEOV fzT+57eymcnWgMbt+kYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxiR0-00EKiq-Ds; Wed, 23 Nov 2022 05:36:34 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxiQM-00EKSv-Um for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 05:35:57 +0000 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2AN5ZkKA115327; Tue, 22 Nov 2022 23:35:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1669181746; bh=tA1+Xm5vcxi2u2VEj2z6DAUNH7zFuQWnUWprauTHUXU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=G7HITg7IH3VEdvObsqvZSTsqayblNeXA0xUNYazFzKkE3CPcPhIGc3q3aIgg2JlH/ Rhhm5r5HZbn8JQXI1nQpkpUEiQ0jWLiYAxOQ8fv4o+47c2yH6679AydgOdNwSYcAMa GH4Ft5gpAFsU9lWXFX44Lw+WVWfNsoR5z729FLrs= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2AN5ZkIw047938 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 22 Nov 2022 23:35:46 -0600 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Tue, 22 Nov 2022 23:35:46 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Tue, 22 Nov 2022 23:35:46 -0600 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2AN5Zgav112779; Tue, 22 Nov 2022 23:35:44 -0600 From: Matt Ranostay To: , , , , , , , CC: , , , , Keerthy , Matt Ranostay Subject: [PATCH v5 2/4] mfd: tps6594: Add support for TPS6594 PMIC devices Date: Tue, 22 Nov 2022 21:35:10 -0800 Message-ID: <20221123053512.1195309-3-mranostay@ti.com> X-Mailer: git-send-email 2.38.GIT In-Reply-To: <20221123053512.1195309-1-mranostay@ti.com> References: <20221123053512.1195309-1-mranostay@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221122_213555_187941_EFF1D175 X-CRM114-Status: GOOD ( 22.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Keerthy The TPS6594 chip is a PMIC, and contains the following components: - GPIO controller - RTC Signed-off-by: Keerthy Signed-off-by: Matt Ranostay Reviewed-by: Tony Lindgren --- drivers/mfd/Kconfig | 14 +++++ drivers/mfd/Makefile | 1 + drivers/mfd/tps6594.c | 113 ++++++++++++++++++++++++++++++++++++ include/linux/mfd/tps6594.h | 84 +++++++++++++++++++++++++++ 4 files changed, 212 insertions(+) create mode 100644 drivers/mfd/tps6594.c create mode 100644 include/linux/mfd/tps6594.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 6653d03e0fe3..c54f2959a200 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_TPS6594 + tristate "TI TPS6594 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 TPS6594 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 tps6594. + 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..b4fdfcc57831 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_TPS6594) += tps6594.o obj-$(CONFIG_MENELAUS) += menelaus.o obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o diff --git a/drivers/mfd/tps6594.c b/drivers/mfd/tps6594.c new file mode 100644 index 000000000000..a7f80833e8fc --- /dev/null +++ b/drivers/mfd/tps6594.c @@ -0,0 +1,113 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Driver for TPS6594 PMIC chips + * + * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/ + * Author: Keerthy + */ + +#include +#include +#include +#include +#include +#include +#include + +static const struct regmap_config tps6594_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = TPS6594_REG_MAX, +}; + +static const struct mfd_cell tps6594_cells[] = { + { .name = "tps6594-gpio" }, + { .name = "tps6594-rtc" }, +}; + +static struct tps6594 *tps; + +static void tps6594_power_off(void) +{ + regmap_write(tps->regmap, TPS6594_FSM_NSLEEP_TRIGGERS, + TPS6594_FSM_NSLEEP_NSLEEP1B | TPS6594_FSM_NSLEEP_NSLEEP2B); + + regmap_write(tps->regmap, TPS6594_INT_STARTUP, + TPS6594_INT_STARTUP_NPWRON_START_INT | + TPS6594_INT_STARTUP_ENABLE_INT | TPS6594_INT_STARTUP_RTC_INT | + TPS6594_INT_STARTUP_SOFT_REBOOT_INT); + + regmap_write(tps->regmap, TPS6594_INT_MISC, + TPS6594_INT_MISC_BIST_PASS_INT | + TPS6594_INT_MISC_EXT_CLK_INT | TPS6594_INT_MISC_TWARN_INT); + + regmap_write(tps->regmap, TPS6594_CONFIG_1, + TPS6594_CONFIG_NSLEEP1_MASK | TPS6594_CONFIG_NSLEEP2_MASK); + + regmap_write(tps->regmap, TPS6594_FSM_I2C_TRIGGERS, + TPS6594_FSM_I2C_TRIGGERS_I2C0); +} + +static int tps6594_probe(struct i2c_client *client) +{ + struct tps6594 *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, &tps6594_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, TPS6594_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, tps6594_cells, + ARRAY_SIZE(tps6594_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 = tps6594_power_off; + + return 0; +} + +static const struct of_device_id of_tps6594_match_table[] = { + { .compatible = "ti,tps6594", }, + {} +}; +MODULE_DEVICE_TABLE(of, of_tps6594_match_table); + +static const struct i2c_device_id tps6594_id_table[] = { + { "tps6594", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, tps6594_id_table); + +static struct i2c_driver tps6594_driver = { + .driver = { + .name = "tps6594", + .of_match_table = of_tps6594_match_table, + }, + .probe_new = tps6594_probe, + .id_table = tps6594_id_table, +}; +module_i2c_driver(tps6594_driver); + +MODULE_AUTHOR("J Keerthy "); +MODULE_DESCRIPTION("TPS6594 PMIC device driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/tps6594.h b/include/linux/mfd/tps6594.h new file mode 100644 index 000000000000..f721ec9880dd --- /dev/null +++ b/include/linux/mfd/tps6594.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Core driver interface for TI TPS6594 PMIC family + * + * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/ + */ + +#ifndef __MFD_TPS6594_H +#define __MFD_TPS6594_H + +#include + +/* TPS6594 chip ID list */ +#define TPS6594 0x00 + +/* All register addresses */ +#define TPS6594_REG_DEV_REV 0x01 +#define TPS6594_INT_STARTUP 0x65 +#define TPS6594_INT_MISC 0x66 +#define TPS6594_CONFIG_1 0x7d +#define TPS6594_FSM_I2C_TRIGGERS 0x85 +#define TPS6594_FSM_NSLEEP_TRIGGERS 0x86 + +#define TPS6594_RTC_SECONDS 0xb5 +#define TPS6594_RTC_MINUTES 0xb6 +#define TPS6594_RTC_HOURS 0xb7 +#define TPS6594_RTC_DAYS 0xb8 +#define TPS6594_RTC_MONTHS 0xb9 +#define TPS6594_RTC_YEARS 0xba +#define TPS6594_RTC_WEEKS 0xbb +#define TPS6594_ALARM_SECONDS 0xbc +#define TPS6594_ALARM_MINUTES 0xbd +#define TPS6594_ALARM_HOURS 0xbe +#define TPS6594_ALARM_DAYS 0xbf +#define TPS6594_ALARM_MONTHS 0xc0 +#define TPS6594_ALARM_YEARS 0xc1 +#define TPS6594_RTC_CTRL_1 0xc2 +#define TPS6594_RTC_CTRL_2 0xc3 +#define TPS6594_RTC_STATUS 0xc4 +#define TPS6594_RTC_INTERRUPTS 0xc5 +#define TPS6594_REG_MAX 0xd0 + +/* Register field definitions */ +#define TPS6594_DEV_REV_DEV_ID 0xff + +#define TPS6594_INT_STARTUP_NPWRON_START_INT BIT(0) +#define TPS6594_INT_STARTUP_ENABLE_INT BIT(1) +#define TPS6594_INT_STARTUP_RTC_INT BIT(2) +#define TPS6594_INT_STARTUP_FSD_INT BIT(4) +#define TPS6594_INT_STARTUP_SOFT_REBOOT_INT BIT(5) + +#define TPS6594_INT_MISC_BIST_PASS_INT BIT(0) +#define TPS6594_INT_MISC_EXT_CLK_INT BIT(1) +#define TPS6594_INT_MISC_TWARN_INT BIT(3) + +#define TPS6594_CONFIG_NSLEEP1_MASK BIT(6) +#define TPS6594_CONFIG_NSLEEP2_MASK BIT(7) + +#define TPS6594_FSM_I2C_TRIGGERS_I2C0 BIT(0) + +#define TPS6594_FSM_NSLEEP_NSLEEP1B BIT(0) +#define TPS6594_FSM_NSLEEP_NSLEEP2B BIT(1) + +#define TPS6594_RTC_CTRL_REG_GET_TIME BIT(6) +#define TPS6594_RTC_CTRL_REG_STOP_RTC BIT(0) +#define TPS6594_RTC_INTERRUPTS_REG_IT_ALARM BIT(3) + +#define TPS6594_RTC_STATUS_RUN BIT(1) + +/** + * struct tps6594 - state holder for the tps6594 driver + * @dev: struct device pointer for MFD device + * @rev: revision of the tps6594 + * @lock: lock guarding the data structure + * @regmap: register map of the tps6594 PMIC + * + * Device data may be used to access the TPS6594 chip + */ +struct tps6594 { + struct device *dev; + u8 rev; + struct regmap *regmap; +}; +#endif /* __MFD_TPS6594_H */ From patchwork Wed Nov 23 05:35:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 13053064 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2E0D7C433FE for ; Wed, 23 Nov 2022 05:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aOmqAOm689Uel1aGydLDVoCI10t30by8sE5EXS0GtMA=; b=JLrrz9xeIhdCba pTs/3DWrSoKXxO2WVr34ZHeuAwYHSCv/cSYso5HzJU4RgLbVaFie299uQXQYXXBuFPnC2HDQxnLLA BlvT1VUwc3LZMflK30r6wvVebkNxUn09xh+4yWeLqu9rSYyvDx9lho995XGmkZS5WrPbnss8lcLXa +6dAeIqYFCUB48STnfPfB5Uu6Vz42PHl+pMxw3a1GomlHOWbjRJWVHCPG44kfS5jRPB4Q31fA2qIh MFaGa77/qeRXDm4ZhacOKwnLBVdzrScQ6Rc+MirGvrOtNYNI+q5brvMT0cdiUTS0jB5/0viAfd08Z ZNs3QJqYEksId90OTMPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxiRM-00EKsW-Ls; Wed, 23 Nov 2022 05:36:56 +0000 Received: from lelv0142.ext.ti.com ([198.47.23.249]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxiQR-00EKVJ-5Y for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 05:36:01 +0000 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2AN5ZqYR091873; Tue, 22 Nov 2022 23:35:52 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1669181752; bh=pA7rNBLnZJLX6IHNL1cRAdQltQJ9JWw3hDD16aE5CXY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Ak2CzTGILo9EvlgR+bYkVlwJWyUMXc6lPzbI+rtviWjFhjL9nKqR/XN7s4wSsSsMs WUjM58b/J4swf9jypSqndUfv4DxUdgQa1SDNXrvGLqBr/y/otpoeCxb/MRnMKS6Oa9 agtMznJtScNV8JX6kYuDsKU8VWtY71OuPc73mPl0= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2AN5Zq9u002736 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 22 Nov 2022 23:35:52 -0600 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Tue, 22 Nov 2022 23:35:52 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Tue, 22 Nov 2022 23:35:52 -0600 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2AN5ZmKo112823; Tue, 22 Nov 2022 23:35:51 -0600 From: Matt Ranostay To: , , , , , , , CC: , , , , Keerthy , Matt Ranostay Subject: [PATCH v5 3/4] rtc: rtc-tps6594: Add support for TPS6594 PMIC RTC Date: Tue, 22 Nov 2022 21:35:11 -0800 Message-ID: <20221123053512.1195309-4-mranostay@ti.com> X-Mailer: git-send-email 2.38.GIT In-Reply-To: <20221123053512.1195309-1-mranostay@ti.com> References: <20221123053512.1195309-1-mranostay@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221122_213559_331579_7F2087C4 X-CRM114-Status: GOOD ( 23.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Keerthy Add support for TPS6594 PMIC RTC. However, currently only get/set of time + date functionality is supported. Signed-off-by: Keerthy Signed-off-by: Matt Ranostay Reviewed-by: Tony Lindgren --- drivers/rtc/Kconfig | 10 +++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-tps6594.c | 155 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 drivers/rtc/rtc-tps6594.c diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index ab9a1f814119..519dc544b083 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_TPS6594 + tristate "TI TPS6594 RTC driver" + depends on MFD_TPS6594 || COMPILE_TEST + help + If you say yes here you get support for the RTC of TI TPS6594 series PMIC + chips. + + This driver can also be built as a module. If so, the module + will be called rtc-tps6594. + 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..4493a13f989d 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_TPS6594) += rtc-tps6594.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-tps6594.c b/drivers/rtc/rtc-tps6594.c new file mode 100644 index 000000000000..6e85ea8551a2 --- /dev/null +++ b/drivers/rtc/rtc-tps6594.c @@ -0,0 +1,155 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * rtc-tps6594.c -- TPS6594 Real Time Clock driver. + * + * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct tps6594_rtc { + struct rtc_device *rtc; + struct device *dev; +}; + +#define TPS6594_RTC_POLL 20000 +#define TPS6594_RTC_TIMEOUT 100000 + +#define TPS6594_NUM_TIME_REGS (TPS6594_RTC_YEARS - TPS6594_RTC_SECONDS + 1) + +static int tps6594_rtc_read_time(struct device *dev, struct rtc_time *tm) +{ + unsigned char rtc_data[TPS6594_NUM_TIME_REGS]; + struct tps6594 *tps6594 = dev_get_drvdata(dev->parent); + int ret; + + /* Reset TPS6594_RTC_CTRL_REG_GET_TIME bit to zero, required for latch */ + ret = regmap_update_bits(tps6594->regmap, TPS6594_RTC_CTRL_1, + TPS6594_RTC_CTRL_REG_GET_TIME, 0); + if (ret < 0) + return ret; + + /* Copy RTC counting registers to static registers or latches */ + ret = regmap_update_bits(tps6594->regmap, TPS6594_RTC_CTRL_1, + TPS6594_RTC_CTRL_REG_GET_TIME, TPS6594_RTC_CTRL_REG_GET_TIME); + if (ret < 0) + return ret; + + ret = regmap_bulk_read(tps6594->regmap, TPS6594_RTC_SECONDS, + rtc_data, TPS6594_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 tps6594_rtc_set_time(struct device *dev, struct rtc_time *tm) +{ + unsigned char rtc_data[TPS6594_NUM_TIME_REGS]; + struct tps6594 *tps6594 = 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(tps6594->regmap, TPS6594_RTC_CTRL_1, + TPS6594_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(tps6594->regmap, TPS6594_RTC_STATUS, + val, !(val & TPS6594_RTC_STATUS_RUN), + TPS6594_RTC_POLL, TPS6594_RTC_TIMEOUT); + if (ret) { + dev_err(dev, "RTC_STATUS is still RUNNING\n"); + return ret; + } + + ret = regmap_bulk_write(tps6594->regmap, TPS6594_RTC_SECONDS, + rtc_data, TPS6594_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(tps6594->regmap, TPS6594_RTC_CTRL_1, + TPS6594_RTC_CTRL_REG_STOP_RTC, + TPS6594_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 tps6594_rtc_ops = { + .read_time = tps6594_rtc_read_time, + .set_time = tps6594_rtc_set_time, +}; + +static int tps6594_rtc_probe(struct platform_device *pdev) +{ + struct tps6594_rtc *tps6594_rtc; + + tps6594_rtc = devm_kzalloc(&pdev->dev, sizeof(*tps6594_rtc), GFP_KERNEL); + if (!tps6594_rtc) + return -ENOMEM; + + tps6594_rtc->dev = &pdev->dev; + platform_set_drvdata(pdev, tps6594_rtc); + + tps6594_rtc->rtc = devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(tps6594_rtc->rtc)) + return PTR_ERR(tps6594_rtc->rtc); + + tps6594_rtc->rtc->ops = &tps6594_rtc_ops; + + return devm_rtc_register_device(tps6594_rtc->rtc); +} + +static const struct of_device_id of_tps6594_rtc_match[] = { + { .compatible = "ti,tps6594-rtc", }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_tps6594_rtc_match); + +static struct platform_driver tps6594_rtc_driver = { + .probe = tps6594_rtc_probe, + .driver = { + .name = "tps6594-rtc", + .of_match_table = of_tps6594_rtc_match, + }, +}; + +module_platform_driver(tps6594_rtc_driver); + +MODULE_ALIAS("platform:tps6594-rtc"); +MODULE_DESCRIPTION("TI TPS6594 series RTC driver"); +MODULE_AUTHOR("Keerthy J "); +MODULE_LICENSE("GPL"); From patchwork Wed Nov 23 05:35:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 13053065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77FC1C4332F for ; Wed, 23 Nov 2022 05:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mmzuA7sW63gtlI7+FXejgnD9N3KgTTTV1Bn3OXLXSUM=; b=kmB57jB2Wo2+pt W09frTWMecyDpMjcJBnJvc+Hlzy/Yc6RXLUstPvmt9EcbtPvw2t8+D3r9UTLaHLztgsFwSJtjDCA7 glHRmjLDSSxIecEYXQ+Yq86mb1IQvMvBr/SHN2nWYYWfAoiyUP95AzP0HtdyhsQSuANDoI26jwFNU 0B6y7lVEGCPraU3gZgtONpdvZJDV/cshmmGXSp5iBSRdUcilmPP4oEtI/dIILCGXVwpaSBDr/bBMP ZSkSwhQm4bhpnOaT0ZvlsunekRn6f2inAjD/4kpN7bVLLVPBKthc8wTfqrMpH6fRjoOlGVvtZra+/ UznK/ECF6Yd345wbbNlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxiRg-00EL1c-Sa; Wed, 23 Nov 2022 05:37:17 +0000 Received: from lelv0143.ext.ti.com ([198.47.23.248]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxiQT-00EKWL-22 for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 05:36:02 +0000 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2AN5ZvWT069671; Tue, 22 Nov 2022 23:35:57 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1669181758; bh=NdO5jA3a9LFnnECIA7JkH+5Zum+nigvcUum3+kHD5KU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=bLxgDAwOfyX3N40QnVDrriHadmNhCnNCO6SZY+x2/EPtJxOL5pUE7rvfqiaiJoY5A WtY7hQ0eJRECEZhDwYORQR5MsTxFyE7r+o3hqOTSlQWD3QSUANS9U76pqs/dY307mU qPCfrTTzh0sE7BN9ZJy15TDKmwWGzTxdGsCJRdNA= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2AN5ZvM2047985 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 22 Nov 2022 23:35:57 -0600 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Tue, 22 Nov 2022 23:35:57 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Tue, 22 Nov 2022 23:35:57 -0600 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2AN5Zs96119355; Tue, 22 Nov 2022 23:35:56 -0600 From: Matt Ranostay To: , , , , , , , CC: , , , , Matt Ranostay Subject: [PATCH v5 4/4] gpio: gpio-tps6594: add GPIO support for TPS6594 PMIC Date: Tue, 22 Nov 2022 21:35:12 -0800 Message-ID: <20221123053512.1195309-5-mranostay@ti.com> X-Mailer: git-send-email 2.38.GIT In-Reply-To: <20221123053512.1195309-1-mranostay@ti.com> References: <20221123053512.1195309-1-mranostay@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221122_213601_219640_B9DB6C17 X-CRM114-Status: GOOD ( 20.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for TPS6594 PMICs GPIO interface that has 11 that can be configured as input or outputs. Signed-off-by: Matt Ranostay Reviewed-by: Tony Lindgren Reviewed-by: Michael Walle --- drivers/gpio/Kconfig | 9 +++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tps6594.c | 78 +++++++++++++++++++++++++++++++++++++ include/linux/mfd/tps6594.h | 4 ++ 4 files changed, 92 insertions(+) create mode 100644 drivers/gpio/gpio-tps6594.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index ec7cfd4f52b1..f34b3746075a 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_TPS6594 + tristate "TI TPS6594 GPIO driver" + depends on MFD_TPS6594 || COMPILE_TEST + select REGMAP + select GPIO_REGMAP + help + Select this option to enable GPIO driver for the TPS6954 + 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..31bef1cc112f 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_TPS6594) += gpio-tps6594.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-tps6594.c b/drivers/gpio/gpio-tps6594.c new file mode 100644 index 000000000000..983c37a77266 --- /dev/null +++ b/drivers/gpio/gpio-tps6594.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * GPIO driver for TI TPS6594 PMICs + * + * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include +#include +#include +#include + +#include +#include +#include + +#define GPIO_BANK_SIZE 8 +#define GPIO_CFG_MASK BIT(0) + +static int tps6594_regmap_xlate(struct gpio_regmap *gpio, + unsigned int base, unsigned int offset, + unsigned int *reg, unsigned int *mask) +{ + if (base == TPS6594_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 tps6594_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 = TPS6594_GPIO_IN; + config.reg_set_base = TPS6594_GPIO_OUT; + config.reg_dir_out_base = TPS6594_GPIO_CONF; + config.reg_mask_xlate = tps6594_regmap_xlate; + + return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(&pdev->dev, &config)); +} + +static const struct of_device_id of_tps6594_gpio_match[] = { + { .compatible = "ti,tps6594-gpio", }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_tps6594_gpio_match); + +static struct platform_driver tps6594_gpio_driver = { + .driver = { + .name = "tps6594-gpio", + .of_match_table = of_tps6594_gpio_match, + }, + .probe = tps6594_gpio_probe, +}; +module_platform_driver(tps6594_gpio_driver); + +MODULE_ALIAS("platform:tps6594-gpio"); +MODULE_AUTHOR("Matt Ranostay "); +MODULE_DESCRIPTION("TPS6594 GPIO driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/tps6594.h b/include/linux/mfd/tps6594.h index f721ec9880dd..758b1bc44178 100644 --- a/include/linux/mfd/tps6594.h +++ b/include/linux/mfd/tps6594.h @@ -21,6 +21,10 @@ #define TPS6594_FSM_I2C_TRIGGERS 0x85 #define TPS6594_FSM_NSLEEP_TRIGGERS 0x86 +#define TPS6594_GPIO_CONF 0x31 +#define TPS6594_GPIO_OUT 0x3d +#define TPS6594_GPIO_IN 0x3f + #define TPS6594_RTC_SECONDS 0xb5 #define TPS6594_RTC_MINUTES 0xb6 #define TPS6594_RTC_HOURS 0xb7