public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/5] pmic: dm: Provide *trans_len() callback for pmic-uclass
Date: Thu, 26 Apr 2018 14:19:06 +0200	[thread overview]
Message-ID: <20180426121908.5014-3-lukma@denx.de> (raw)
In-Reply-To: <20180426121908.5014-1-lukma@denx.de>

This callback provides information of number of bytes to be sent/read
during single transfer, as some PMICs transfer more bytes at once (e.g.
MC34708 from NXP/Freescale).

At present the PMIC DM supports only transfers with one byte. The old PMIC
framework was able to transfer up till 3 bytes at once.

Let's provide the same capability to new PMIC framework.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
---

 drivers/power/pmic/pmic-uclass.c | 10 ++++++++++
 include/power/pmic.h             |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/drivers/power/pmic/pmic-uclass.c b/drivers/power/pmic/pmic-uclass.c
index 9347b40688..0148e5c883 100644
--- a/drivers/power/pmic/pmic-uclass.c
+++ b/drivers/power/pmic/pmic-uclass.c
@@ -105,6 +105,16 @@ int pmic_reg_count(struct udevice *dev)
 	return ops->reg_count(dev);
 }
 
+int pmic_trans_len(struct udevice *dev)
+{
+	const struct dm_pmic_ops *ops = dev_get_driver_ops(dev);
+
+	if (!ops || !ops->trans_len)
+		return -ENOSYS;
+
+	return ops->trans_len(dev);
+}
+
 int pmic_read(struct udevice *dev, uint reg, uint8_t *buffer, int len)
 {
 	const struct dm_pmic_ops *ops = dev_get_driver_ops(dev);
diff --git a/include/power/pmic.h b/include/power/pmic.h
index f2fe537fb7..d89f6be666 100644
--- a/include/power/pmic.h
+++ b/include/power/pmic.h
@@ -159,12 +159,14 @@ struct pmic {
  * @reg_count: device's register count
  * @read:      read 'len' bytes at "reg" and store it into the 'buffer'
  * @write:     write 'len' bytes from the 'buffer' to the register at 'reg' address
+ * @trans_len: device's number of data bytes for transfer
  */
 struct dm_pmic_ops {
 	int (*reg_count)(struct udevice *dev);
 	int (*read)(struct udevice *dev, uint reg, uint8_t *buffer, int len);
 	int (*write)(struct udevice *dev, uint reg, const uint8_t *buffer,
 		     int len);
+	int (*trans_len)(struct udevice *dev);
 };
 
 /**
-- 
2.11.0

  parent reply	other threads:[~2018-04-26 12:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-26 12:19 [U-Boot] [PATCH 1/5] pmic: fsl: Provide some more definitions for MC34708 PMIC Lukasz Majewski
2018-04-26 12:19 ` [U-Boot] [PATCH 2/5] pmic: fsl: Define number of bytes sent at once by " Lukasz Majewski
2018-04-26 12:19 ` Lukasz Majewski [this message]
2018-04-30 23:13   ` [U-Boot] [PATCH 3/5] pmic: dm: Provide *trans_len() callback for pmic-uclass Simon Glass
2018-04-26 12:19 ` [U-Boot] [PATCH 4/5] pmic: dm: Rewrite pmic_reg_{read|write} and pmic_clrsetbits to support transmissions larger than 1 byte Lukasz Majewski
2018-04-30 23:13   ` Simon Glass
2018-04-26 12:19 ` [U-Boot] [PATCH 5/5] pmic: dm: Add support for MC34708 for PMIC DM Lukasz Majewski

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=20180426121908.5014-3-lukma@denx.de \
    --to=lukma@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox