From: Bastian Krause <bst@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>,
Bastian Krause <bst@pengutronix.de>
Subject: [PATCH] i2c: add pmic_reg_read() for PBL use
Date: Tue, 19 Dec 2023 17:11:35 +0100 [thread overview]
Message-ID: <20231219161135.1388398-1-bst@pengutronix.de> (raw)
Add a common PMIC read function to PBL which allows easy porting of
U-Boot's pmic_reg_read() in lowlevel board code.
Signed-off-by: Bastian Krause <bst@pengutronix.de>
---
include/pbl/pmic.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/include/pbl/pmic.h b/include/pbl/pmic.h
index 0f882c5649d..bd0583370ec 100644
--- a/include/pbl/pmic.h
+++ b/include/pbl/pmic.h
@@ -9,6 +9,27 @@ struct pmic_config {
u8 val;
};
+static void pmic_reg_read(struct pbl_i2c *i2c, int addr, u8 reg, void *buf)
+{
+ int ret;
+ struct i2c_msg msg[] = {
+ {
+ .addr = addr,
+ .buf = ®,
+ .len = 1,
+ }, {
+ .addr = addr,
+ .flags = I2C_M_RD,
+ .buf = buf,
+ .len = 1,
+ },
+ };
+
+ ret = pbl_i2c_xfer(i2c, msg, ARRAY_SIZE(msg));
+ if (ret != ARRAY_SIZE(msg))
+ pr_err("Failed to read from pmic@%x: %d\n", addr, ret);
+}
+
static void pmic_reg_write(struct pbl_i2c *i2c, int addr, u8 reg, u8 val)
{
int ret;
--
2.39.2
next reply other threads:[~2023-12-19 16:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 16:11 Bastian Krause [this message]
2023-12-19 16:21 ` Ahmad Fatoum
2024-01-02 9:11 ` Sascha Hauer
2024-01-02 9:13 ` Ahmad Fatoum
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=20231219161135.1388398-1-bst@pengutronix.de \
--to=bst@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox