aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatya Priya <quic_c_skakit@quicinc.com>2022-06-14 15:18:28 +0530
committerJohan Hovold <johan+linaro@kernel.org>2023-05-30 14:42:21 +0200
commit9f2f26434a5c650d162bacab41b961da6294b43e (patch)
treea700ccbe6fee1189364c51c37534e1eda6bb7863
parent4386af1f3dcf6c783967ec718da791290f324042 (diff)
mfd: pm8008: Use i2c_new_dummy_device() API
Use i2c_new_dummy_device() to register pm8008-regulator client present at a different address space, instead of defining a separate DT node. This avoids calling the probe twice for the same chip, once for each client pm8008-infra and pm8008-regulator. As a part of this define pm8008_regmap_init() to do regmap init for both the clients and define pm8008_get_regmap() to pass the regmap to the regulator driver. Signed-off-by: Satya Priya <quic_c_skakit@quicinc.com> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/1655200111-18357-7-git-send-email-quic_c_skakit@quicinc.com Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
-rw-r--r--drivers/mfd/qcom-pm8008.c42
-rw-r--r--include/linux/mfd/qcom_pm8008.h9
2 files changed, 49 insertions, 2 deletions
diff --git a/drivers/mfd/qcom-pm8008.c b/drivers/mfd/qcom-pm8008.c
index 6b414ccc128e7..bbec36c600ad8 100644
--- a/drivers/mfd/qcom-pm8008.c
+++ b/drivers/mfd/qcom-pm8008.c
@@ -9,6 +9,7 @@
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
+#include <linux/mfd/qcom_pm8008.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>
@@ -36,6 +37,10 @@ enum {
PM8008_NUM_PERIPHS,
};
+struct pm8008_data {
+ struct regmap *regulators_regmap;
+};
+
#define PM8008_PERIPH_0_BASE 0x900
#define PM8008_PERIPH_1_BASE 0x2400
#define PM8008_PERIPH_2_BASE 0xC000
@@ -144,6 +149,12 @@ static struct regmap_config qcom_mfd_regmap_cfg = {
.max_register = 0xFFFF,
};
+struct regmap *pm8008_get_regmap(const struct pm8008_data *chip)
+{
+ return chip->regulators_regmap;
+}
+EXPORT_SYMBOL_GPL(pm8008_get_regmap);
+
static int pm8008_probe_irq_peripherals(struct device *dev,
struct regmap *regmap,
int client_irq)
@@ -174,19 +185,46 @@ static int pm8008_probe_irq_peripherals(struct device *dev,
return 0;
}
+static struct regmap *pm8008_regmap_init(struct i2c_client *client,
+ struct pm8008_data *chip)
+{
+ struct regmap *regmap;
+
+ regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg);
+ if (!regmap)
+ return NULL;
+
+ i2c_set_clientdata(client, chip);
+ return regmap;
+}
+
static int pm8008_probe(struct i2c_client *client)
{
int rc;
struct device *dev;
struct regmap *regmap;
+ struct pm8008_data *chip;
struct gpio_desc *reset_gpio;
+ struct i2c_client *regulators_client;
+
+ chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
+ if (!chip)
+ return -ENOMEM;
dev = &client->dev;
- regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg);
+ regmap = pm8008_regmap_init(client, chip);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
- i2c_set_clientdata(client, regmap);
+ regulators_client = i2c_new_dummy_device(client->adapter, client->addr + 1);
+ if (IS_ERR(regulators_client)) {
+ dev_err(&client->dev, "can't attach client\n");
+ return PTR_ERR(regulators_client);
+ }
+
+ chip->regulators_regmap = pm8008_regmap_init(regulators_client, chip);
+ if (!chip->regulators_regmap)
+ return -ENODEV;
reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(reset_gpio))
diff --git a/include/linux/mfd/qcom_pm8008.h b/include/linux/mfd/qcom_pm8008.h
new file mode 100644
index 0000000000000..3814bff01cfc4
--- /dev/null
+++ b/include/linux/mfd/qcom_pm8008.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+// Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+#ifndef __QCOM_PM8008_H__
+#define __QCOM_PM8008_H__
+
+struct pm8008_data;
+struct regmap *pm8008_get_regmap(const struct pm8008_data *chip);
+
+#endif