From: Lukasz Majewski <lukma@denx.de>
To: Tom Rini <trini@konsulko.com>, u-boot@lists.denx.de
Cc: "Lukasz Majewski" <lukma@denx.de>,
"Andre Przywara" <andre.przywara@arm.com>,
"Bin Meng" <bmeng.cn@gmail.com>,
"Jaehoon Chung" <jh80.chung@samsung.com>,
"Marek Behún" <marek.behun@nic.cz>,
"Quentin Schulz" <quentin.schulz@theobroma-systems.com>,
"Samuel Holland" <samuel@sholland.org>,
"Simon Glass" <sjg@chromium.org>,
"Stephan Gerhold" <stephan@gerhold.net>
Subject: [PATCH 2/3] power: pmic: Provide DM_PMIC support for tps65217 driver
Date: Tue, 22 Feb 2022 09:03:59 +0100 [thread overview]
Message-ID: <20220222080401.6859-2-lukma@denx.de> (raw)
In-Reply-To: <20220222080401.6859-1-lukma@denx.de>
The tps65217 PMIC driver is used with am335x SoC based designs.
It is used in the SPL (MLO) as well, so the DM conversion only is
for u-boot proper.
This driver only allows simple reading/writing/dumping of the content
of its registers and requires the DM_I2C for proper operation.
Moreover, new CONFIG_PMIC_TPS65217 has been introduced in Kconfig
to be used with boards, which both support DM_PMIC and DM_I2C.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
drivers/power/pmic/Kconfig | 8 +++
drivers/power/pmic/pmic_tps65217.c | 82 ++++++++++++++++++++++++++++++
2 files changed, 90 insertions(+)
diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
index ce0adb18a4..c7739228da 100644
--- a/drivers/power/pmic/Kconfig
+++ b/drivers/power/pmic/Kconfig
@@ -306,6 +306,14 @@ config PMIC_TPS65090
only, and you can enable the regulator/charger drivers separately if
required.
+config PMIC_TPS65217
+ bool "Enable driver for Texas Instruments TPS65217 PMIC"
+ ---help---
+ The TPS65217 is a PMIC containing several LDOs, DC to DC convertors,
+ FETs and a battery charger. This driver provides register access
+ only, and you can enable the regulator/charger drivers separately if
+ required.
+
config PMIC_PALMAS
bool "Enable driver for Texas Instruments PALMAS PMIC"
---help---
diff --git a/drivers/power/pmic/pmic_tps65217.c b/drivers/power/pmic/pmic_tps65217.c
index c7f532df4d..ccbf223593 100644
--- a/drivers/power/pmic/pmic_tps65217.c
+++ b/drivers/power/pmic/pmic_tps65217.c
@@ -6,8 +6,13 @@
#include <common.h>
#include <i2c.h>
+#include <dm.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <power/pmic.h>
#include <power/tps65217.h>
+#if !CONFIG_IS_ENABLED(DM_PMIC)
struct udevice *tps65217_dev __section(".data") = NULL;
/**
@@ -148,3 +153,80 @@ int power_tps65217_init(unsigned char bus)
#endif
return 0;
}
+#else /* CONFIG_IS_ENABLED(DM_PMIC) */
+static const struct pmic_child_info pmic_children_info[] = {
+ { .prefix = "ldo", .driver = "tps65217_ldo" },
+ { },
+};
+
+static int tps65217_reg_count(struct udevice *dev)
+{
+ return TPS65217_PMIC_NUM_OF_REGS;
+}
+
+static int tps65217_write(struct udevice *dev, uint reg, const uint8_t *buff,
+ int len)
+{
+ if (dm_i2c_write(dev, reg, buff, len)) {
+ pr_err("write error to device: %p register: %#x!\n", dev, reg);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int tps65217_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+ int ret;
+
+ ret = dm_i2c_read(dev, reg, buff, len);
+ if (ret) {
+ pr_err("read error %d from device: %p register: %#x!\n", ret,
+ dev, reg);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int tps65217_bind(struct udevice *dev)
+{
+ ofnode regulators_node;
+ int children;
+
+ regulators_node = dev_read_subnode(dev, "regulators");
+ if (!ofnode_valid(regulators_node)) {
+ debug("%s: %s regulators subnode not found!\n", __func__,
+ dev->name);
+ return -ENXIO;
+ }
+
+ debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
+
+ children = pmic_bind_children(dev, regulators_node, pmic_children_info);
+ if (!children)
+ debug("%s: %s - no child found\n", __func__, dev->name);
+
+ /* Always return success for this device */
+ return 0;
+}
+
+static struct dm_pmic_ops tps65217_ops = {
+ .reg_count = tps65217_reg_count,
+ .read = tps65217_read,
+ .write = tps65217_write,
+};
+
+static const struct udevice_id tps65217_ids[] = {
+ { .compatible = "ti,tps65217" },
+ { }
+};
+
+U_BOOT_DRIVER(pmic_tps65217) = {
+ .name = "tps65217 pmic",
+ .id = UCLASS_PMIC,
+ .of_match = tps65217_ids,
+ .bind = tps65217_bind,
+ .ops = &tps65217_ops,
+};
+#endif
--
2.20.1
next prev parent reply other threads:[~2022-02-22 8:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220222080425epcas1p2d9b60c85b505dbc59fa34fdb61400d28@epcas1p2.samsung.com>
2022-02-22 8:03 ` [PATCH 1/3] power: Rename CONFIG_POWER_TPS65217 with CONFIG_PMIC_TPS65217 Lukasz Majewski
2022-02-22 8:03 ` Lukasz Majewski [this message]
2022-03-06 23:14 ` [PATCH 2/3] power: pmic: Provide DM_PMIC support for tps65217 driver Jaehoon Chung
2022-02-22 8:04 ` [PATCH 3/3] defconfig: Enable DM_PMIC and DM PMIC_TPS65217 on AM335x EVM board Lukasz Majewski
2022-03-03 9:29 ` [PATCH 1/3] power: Rename CONFIG_POWER_TPS65217 with CONFIG_PMIC_TPS65217 Lukasz Majewski
2022-03-06 23:13 ` Jaehoon Chung
2022-03-10 18:52 ` Tom Rini
2022-03-11 12:09 ` Lukasz Majewski
2022-03-11 12:16 ` Tom Rini
2022-03-11 13:35 ` Lukasz Majewski
2022-03-11 13:52 ` Tom Rini
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=20220222080401.6859-2-lukma@denx.de \
--to=lukma@denx.de \
--cc=andre.przywara@arm.com \
--cc=bmeng.cn@gmail.com \
--cc=jh80.chung@samsung.com \
--cc=marek.behun@nic.cz \
--cc=quentin.schulz@theobroma-systems.com \
--cc=samuel@sholland.org \
--cc=sjg@chromium.org \
--cc=stephan@gerhold.net \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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.