[U-Boot] [PATCH 3/5] pmic: dm: Provide *trans_len() callback for pmic-uclass

Lukasz Majewski lukma at denx.de
Thu Apr 26 12:19:06 UTC 2018


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 at 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



More information about the U-Boot mailing list