lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231228100208.2932-3-karelb@gimli.ms.mff.cuni.cz>
Date: Thu, 28 Dec 2023 10:39:11 +0100
From: Karel Balej <karelb@...li.ms.mff.cuni.cz>
To: Karel Balej <balejk@...fyz.cz>,
	Lee Jones <lee@...nel.org>,
	Rob Herring <robh+dt@...nel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Liam Girdwood <lgirdwood@...il.com>,
	Mark Brown <broonie@...nel.org>,
	devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: Duje Mihanović <duje.mihanovic@...le.hr>,
	~postmarketos/upstreaming@...ts.sr.ht,
	phone-devel@...r.kernel.org
Subject: [RFC PATCH 2/5] mfd: 88pm88x: initialize the regulators regmaps

From: Karel Balej <balejk@...fyz.cz>

The regulators registers are accessed via a different I2C address than
the already implemented functionality. Initialize the new regmap for the
regulator driver to use. For 88PM886 the buck regmap is the same as LDO
regmap, however this is not the case for 88PM880.

Signed-off-by: Karel Balej <balejk@...fyz.cz>
---
 drivers/mfd/88pm88x.c       | 33 +++++++++++++++++++++++++++++++++
 include/linux/mfd/88pm88x.h |  4 ++++
 2 files changed, 37 insertions(+)

diff --git a/drivers/mfd/88pm88x.c b/drivers/mfd/88pm88x.c
index 3424d88a58f6..69a8e39d43b3 100644
--- a/drivers/mfd/88pm88x.c
+++ b/drivers/mfd/88pm88x.c
@@ -98,6 +98,35 @@ static int pm88x_power_off_handler(struct sys_off_data *data)
 	return NOTIFY_DONE;
 }
 
+static int pm88x_initialize_subregmaps(struct pm88x_chip *chip)
+{
+	struct i2c_client *page;
+	struct regmap *regmap;
+	int ret;
+
+	/* LDO page */
+	page = devm_i2c_new_dummy_device(&chip->client->dev, chip->client->adapter,
+					chip->client->addr + PM88X_PAGE_OFFSET_LDO);
+	if (IS_ERR(page)) {
+		ret = PTR_ERR(page);
+		dev_err(&chip->client->dev, "Failed to initialize LDO client: %d\n",
+				ret);
+		return ret;
+	}
+	regmap = devm_regmap_init_i2c(page, &pm88x_i2c_regmap);
+	if (IS_ERR(regmap)) {
+		ret = PTR_ERR(regmap);
+		dev_err(&chip->client->dev, "Failed to initialize LDO regmap: %d\n",
+				ret);
+		return ret;
+	}
+	chip->regmaps[PM88X_REGMAP_LDO] = regmap;
+	/* buck regmap is the same as LDO */
+	chip->regmaps[PM88X_REGMAP_BUCK] = regmap;
+
+	return 0;
+}
+
 static int pm88x_setup_irq(struct pm88x_chip *chip)
 {
 	int ret;
@@ -155,6 +184,10 @@ static int pm88x_probe(struct i2c_client *client)
 		return -EINVAL;
 	}
 
+	ret = pm88x_initialize_subregmaps(chip);
+	if (ret)
+		return ret;
+
 	ret = pm88x_setup_irq(chip);
 	if (ret)
 		return ret;
diff --git a/include/linux/mfd/88pm88x.h b/include/linux/mfd/88pm88x.h
index 9a335f6b9c07..703e6104c1d8 100644
--- a/include/linux/mfd/88pm88x.h
+++ b/include/linux/mfd/88pm88x.h
@@ -39,8 +39,12 @@
 
 #define PM88X_REG_AON_CTRL2		0xe2
 
+#define PM88X_PAGE_OFFSET_LDO		1
+
 enum pm88x_regmap_index {
 	PM88X_REGMAP_BASE,
+	PM88X_REGMAP_LDO,
+	PM88X_REGMAP_BUCK,
 
 	PM88X_REGMAP_NR
 };
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ