linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Matt Ranostay <mranostay@ti.com>,
	brgl@bgdev.pl, lee@kernel.org, linus.walleij@linaro.org,
	kristo@kernel.org, alexandre.belloni@bootlin.com,
	a.zummo@towertech.it, krzysztof.kozlowski+dt@linaro.org,
	robh@kernel.org, vigneshr@ti.com
Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	linux-rtc@vger.kernel.org, linux-gpio@vger.kernel.org,
	Keerthy <j-keerthy@ti.com>
Subject: Re: [PATCH v3 2/7] MFD: TPS6594x: Add new PMIC device driver for TPS6594x chips
Date: Wed, 9 Nov 2022 09:52:11 +0100	[thread overview]
Message-ID: <c67ab598-c571-79fa-0f71-034332e9ffff@linaro.org> (raw)
In-Reply-To: <20221109065546.24912-3-mranostay@ti.com>

On 09/11/2022 07:55, Matt Ranostay wrote:
> From: Keerthy <j-keerthy@ti.com>
> 

Use subject prefixes matching the subsystem (git log --oneline -- ...).

> The TPS6594x chip is a PMIC, and contains the following components:
> 
> - GPIO controller
> - RTC
> 
> However initially only RTC is supported.
> 
> 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       | 120 +++++++++++++++++++++++++++++++++++
>  include/linux/mfd/tps6594x.h |  84 ++++++++++++++++++++++++
>  4 files changed, 219 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 6e920442366c..9a6dc6b69058 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..0de7946b6b8b
> --- /dev/null
> +++ b/drivers/mfd/tps6594x.c
> @@ -0,0 +1,120 @@
> +// 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 = "tps6594x-gpio" },
> +	{ .name = "tps6594x-rtc" },

You have compatibles for children, so use them.

> +};
> +
> +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)) {
> +		ret = PTR_ERR(ddata->regmap);
> +		dev_err(ddata->dev,
> +			"Failed to initialize register map: %d\n", ret);
> +		return ret;

return dev_err_probe

> +	}
> +
> +	ret = regmap_read(ddata->regmap, TPS6594X_REG_DEV_REV, &otpid);
> +	if (ret) {
> +		dev_err(ddata->dev, "Failed to read OTP ID\n");
> +		return ret;

return dev_err_probe

> +	}
> +
> +	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) {
> +		dev_err(ddata->dev, "Failed to register cells\n");
> +		return ret;

return dev_err_probe

> +	}
> +
> +	tps = ddata;
> +
> +	if (of_property_read_bool(node, "ti,system-power-controller"))
> +		pm_power_off = tps6594x_power_off;
> +
> +	return 0;
> +}

Best regards,
Krzysztof


  reply	other threads:[~2022-11-09  8:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09  6:55 [PATCH v3 0/7] mfd: add tps6594x support for Jacinto platforms Matt Ranostay
2022-11-09  6:55 ` [PATCH v3 1/7] Documentation: tps6594x: Add DT bindings for the TPS6594x PMIC Matt Ranostay
2022-11-09  8:46   ` Krzysztof Kozlowski
2022-11-09  6:55 ` [PATCH v3 2/7] MFD: TPS6594x: Add new PMIC device driver for TPS6594x chips Matt Ranostay
2022-11-09  8:52   ` Krzysztof Kozlowski [this message]
2022-11-09  6:55 ` [PATCH v3 3/7] rtc: rtc-tps6594x: Add support for TPS6594X PMIC RTC Matt Ranostay
2022-11-09  8:49   ` Krzysztof Kozlowski
2022-11-14 20:48   ` Alexandre Belloni
2022-11-09  6:55 ` [PATCH v3 4/7] gpio: tps6594x: add GPIO support for TPS6594x PMIC Matt Ranostay
2022-11-09  8:50   ` Krzysztof Kozlowski
2022-11-09  9:59   ` Linus Walleij
2022-11-10 10:12     ` Matt Ranostay
2022-11-10 10:15       ` Linus Walleij
2022-11-11  8:58         ` Matt Ranostay
2022-11-16  7:31           ` Michael Walle
2022-11-09  6:55 ` [PATCH v3 5/7] arm64: dts: ti: k3-j7200-common-proc-board: Add TPS6594x PMIC node Matt Ranostay
2022-11-09  8:52   ` Krzysztof Kozlowski
2022-11-09  6:55 ` [PATCH v3 6/7] arm64: dts: ti: k3-j721e-common-proc-board: " Matt Ranostay
2022-11-09  8:52   ` Krzysztof Kozlowski
2022-11-09  6:55 ` [PATCH v3 7/7] arm64: dts: ti: k3-j721s2-common-proc-board: " Matt Ranostay
2022-11-09  8:52   ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c67ab598-c571-79fa-0f71-034332e9ffff@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=brgl@bgdev.pl \
    --cc=devicetree@vger.kernel.org \
    --cc=j-keerthy@ti.com \
    --cc=kristo@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=mranostay@ti.com \
    --cc=robh@kernel.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).