All of lore.kernel.org
 help / color / mirror / Atom feed
From: Satya Priya <quic_c_skakit@quicinc.com>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
	Rob Herring <robh+dt@kernel.org>
Cc: Lee Jones <lee.jones@linaro.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, <linux-arm-msm@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<swboyd@chromium.org>, <quic_collinsd@quicinc.com>,
	<quic_subbaram@quicinc.com>, <quic_jprakash@quicinc.com>,
	Satya Priya <quic_c_skakit@quicinc.com>
Subject: [PATCH V9 3/6] mfd: pm8008: Add mfd cell struct to register LDOs
Date: Tue, 5 Apr 2022 19:20:30 +0530	[thread overview]
Message-ID: <1649166633-25872-4-git-send-email-quic_c_skakit@quicinc.com> (raw)
In-Reply-To: <1649166633-25872-1-git-send-email-quic_c_skakit@quicinc.com>

Add mfd cell struct to match with the "qcom,pm8008-regulator"
driver and a separate probe to add pm8008_regulator_devs.
This separate probe is required to ensure the regulators are
registered only with the mfd device which contains regulators.

Add the reset-gpio toggling in the pm8008_probe() to bring
pm8008 chip out of reset instead of doing it in DT node using
"output-high" property.

Signed-off-by: Satya Priya <quic_c_skakit@quicinc.com>
---
Changes in V6:
 - Changed the mfd_cell struct to have only name of the regulator driver.
 - Using device_get_match_data() instead of of_match_node() to match data.
 - Fixed few nits.

Changes in V7:
 - Fixed minor errors.

Changes in V8:
 - Split the probe for infra and regulator devices
 - Add the reset-gpio toggling in the infra driver probe

Changes in V9:
 - Fixed nits.

 drivers/mfd/qcom-pm8008.c | 80 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 78 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/qcom-pm8008.c b/drivers/mfd/qcom-pm8008.c
index c472d7f..c7781ab 100644
--- a/drivers/mfd/qcom-pm8008.c
+++ b/drivers/mfd/qcom-pm8008.c
@@ -4,10 +4,12 @@
  */
 
 #include <linux/bitops.h>
+#include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
+#include <linux/mfd/core.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
@@ -27,6 +29,10 @@
 #define INT_EN_CLR_OFFSET		0x16
 #define INT_LATCHED_STS_OFFSET		0x18
 
+static const struct mfd_cell pm8008_regulator_devs[] = {
+	MFD_CELL_NAME("qcom,pm8008-regulators"),
+};
+
 enum {
 	PM8008_MISC,
 	PM8008_TEMP_ALARM,
@@ -57,6 +63,7 @@ enum {
 struct pm8008_data {
 	struct device *dev;
 	struct regmap *regmap;
+	struct gpio_desc *reset_gpio;
 	int irq;
 	struct regmap_irq_chip_data *irq_data;
 };
@@ -239,13 +246,44 @@ static int pm8008_probe(struct i2c_client *client)
 			dev_err(chip->dev, "Failed to probe irq periphs: %d\n", rc);
 	}
 
+	chip->reset_gpio = devm_gpiod_get(chip->dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(chip->reset_gpio)) {
+		dev_err(chip->dev, "failed to acquire reset gpio\n");
+		return PTR_ERR(chip->reset_gpio);
+	}
+	gpiod_set_value(chip->reset_gpio, 1);
+
 	return devm_of_platform_populate(chip->dev);
 }
 
+static int pm8008_probe_regulators(struct i2c_client *client)
+{
+
+	int rc;
+	struct pm8008_data *chip;
+
+	chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
+	if (!chip)
+		return -ENOMEM;
+
+	chip->dev = &client->dev;
+	chip->regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg);
+	if (!chip->regmap)
+		return -ENODEV;
+
+	rc = devm_mfd_add_devices(chip->dev, 0, pm8008_regulator_devs,
+			ARRAY_SIZE(pm8008_regulator_devs), NULL, 0, NULL);
+	if (rc)
+		dev_err(chip->dev, "Failed to add children: %d\n", rc);
+
+	return rc;
+}
+
 static const struct of_device_id pm8008_match[] = {
 	{ .compatible = "qcom,pm8008", },
-	{ },
+	{ }
 };
+MODULE_DEVICE_TABLE(of, pm8008_match);
 
 static struct i2c_driver pm8008_mfd_driver = {
 	.driver = {
@@ -254,7 +292,45 @@ static struct i2c_driver pm8008_mfd_driver = {
 	},
 	.probe_new = pm8008_probe,
 };
-module_i2c_driver(pm8008_mfd_driver);
+
+static const struct of_device_id pm8008_regulators_match[] = {
+	{ .compatible = "qcom,pm8008-regulators", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, pm8008_regulators_match);
+
+static struct i2c_driver pm8008_regulators_driver = {
+	.driver = {
+		.name = "pm8008-regulators",
+		.of_match_table = pm8008_regulators_match,
+	},
+	.probe_new = pm8008_probe_regulators,
+};
+
+static int __init pm8008_i2c_init(void)
+{
+	int ret;
+
+	ret = i2c_add_driver(&pm8008_mfd_driver);
+	if (ret) {
+		pr_err("Failed to register driver for pm8008_infra: %d\n", ret);
+		return ret;
+	}
+
+	ret = i2c_add_driver(&pm8008_regulators_driver);
+	if (ret)
+		pr_err("Failed to register driver for pm8008_regulators: %d\n", ret);
+
+	return ret;
+}
+module_init(pm8008_i2c_init);
+
+static void __exit pm8008_i2c_exit(void)
+{
+	i2c_del_driver(&pm8008_mfd_driver);
+	i2c_del_driver(&pm8008_regulators_driver);
+}
+module_exit(pm8008_i2c_exit);
 
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("i2c:qcom-pm8008");
-- 
2.7.4


  parent reply	other threads:[~2022-04-05 23:34 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 13:50 [PATCH V9 0/6] Add Qualcomm Technologies, Inc. PM8008 regulator driver Satya Priya
2022-04-05 13:50 ` [PATCH V9 1/6] dt-bindings: mfd: pm8008: Add reset-gpios Satya Priya
2022-04-05 19:04   ` Stephen Boyd
2022-04-13  1:50   ` Rob Herring
2022-04-05 13:50 ` [PATCH V9 2/6] dt-bindings: mfd: pm8008: Add pm8008 regulator bindings Satya Priya
2022-04-05 19:05   ` Stephen Boyd
2022-04-13  1:51   ` Rob Herring
2022-04-05 13:50 ` Satya Priya [this message]
2022-04-05 19:08   ` [PATCH V9 3/6] mfd: pm8008: Add mfd cell struct to register LDOs Stephen Boyd
2022-04-06  9:19     ` Satya Priya Kakitapalli (Temp)
2022-04-05 13:50 ` [PATCH V9 4/6] regulator: Add a regulator driver for the PM8008 PMIC Satya Priya
2022-04-05 14:17   ` Mark Brown
2022-04-06  9:06     ` Satya Priya Kakitapalli (Temp)
2022-04-05 19:09   ` Stephen Boyd
2022-04-06  7:31     ` Mark Brown
2022-04-06 15:23       ` Stephen Boyd
2022-04-06 15:45         ` Mark Brown
2022-04-06 15:51           ` Stephen Boyd
2022-04-06 16:36             ` Mark Brown
2022-04-06 17:21               ` Stephen Boyd
2022-04-06 17:27                 ` Mark Brown
2022-04-06 18:16                   ` Stephen Boyd
2022-04-07  5:12                     ` Satya Priya Kakitapalli (Temp)
2022-04-06  9:38     ` Satya Priya Kakitapalli (Temp)
2022-04-05 19:09   ` Stephen Boyd
2022-04-06  9:26     ` Satya Priya Kakitapalli (Temp)
2022-04-05 13:50 ` [PATCH V9 5/6] arm64: dts: qcom: pm8008: Add base dts file Satya Priya
2022-04-05 19:11   ` Stephen Boyd
2022-04-06  9:27     ` Satya Priya Kakitapalli (Temp)
2022-04-05 13:50 ` [PATCH V9 6/6] arm64: dts: qcom: sc7280: Add pm8008 support for sc7280-idp Satya Priya
2022-04-05 19:13   ` Stephen Boyd

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=1649166633-25872-4-git-send-email-quic_c_skakit@quicinc.com \
    --to=quic_c_skakit@quicinc.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_collinsd@quicinc.com \
    --cc=quic_jprakash@quicinc.com \
    --cc=quic_subbaram@quicinc.com \
    --cc=robh+dt@kernel.org \
    --cc=swboyd@chromium.org \
    /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 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.