diff mbox

[U-Boot,PATCHv5,2/4] power: as3722: Allow using on any i2c bus with any address

Message ID 20160905132952.27280-3-julian@jusst.de
State Changes Requested
Delegated to: Tom Warren
Headers show

Commit Message

Julian Scheel Sept. 5, 2016, 1:29 p.m. UTC
From: Alban Bedel <alban.bedel@avionic-design.de>

The init simply hardcoded the i2c bus and address to those used on
jetson. Extend the init function to take the bus number and device
address as parameter. As only jetson is using this code for now just
fix this single use of the function.

Change-Id: Ib6073a2cd29fa228d09d298aa6406f909ee5faae
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Signed-off-by: Julian Scheel <julian@jusst.de>
---
 board/nvidia/jetson-tk1/jetson-tk1.c | 2 +-
 drivers/power/as3722.c               | 4 +---
 include/power/as3722.h               | 2 +-
 3 files changed, 3 insertions(+), 5 deletions(-)

Comments

Stephen Warren Sept. 6, 2016, 4:51 p.m. UTC | #1
On 09/05/2016 07:29 AM, Julian Scheel wrote:
> From: Alban Bedel <alban.bedel@avionic-design.de>
>
> The init simply hardcoded the i2c bus and address to those used on
> jetson. Extend the init function to take the bus number and device
> address as parameter. As only jetson is using this code for now just
> fix this single use of the function.

Conceptually this patch seems fine, but it'll need fixing due to 
dropping/modifying patch 1 in the series.
diff mbox

Patch

diff --git a/board/nvidia/jetson-tk1/jetson-tk1.c b/board/nvidia/jetson-tk1/jetson-tk1.c
index a66b710..129c08b 100644
--- a/board/nvidia/jetson-tk1/jetson-tk1.c
+++ b/board/nvidia/jetson-tk1/jetson-tk1.c
@@ -42,7 +42,7 @@  int tegra_pcie_board_init(void)
 	struct udevice *pmic;
 	int err;
 
-	err = as3722_init(&pmic);
+	err = as3722_init(&pmic, 0, 0x40);
 	if (err) {
 		error("failed to initialize AS3722 PMIC: %d\n", err);
 		return err;
diff --git a/drivers/power/as3722.c b/drivers/power/as3722.c
index c09e1de..321d65d 100644
--- a/drivers/power/as3722.c
+++ b/drivers/power/as3722.c
@@ -243,12 +243,10 @@  int as3722_get(struct udevice **devp)
 	return i2c_get_chip_for_busnum(bus, address, 1, devp);
 }
 
-int as3722_init(struct udevice **devp)
+int as3722_init(struct udevice **devp, unsigned int bus, unsigned int address)
 {
 	struct udevice *pmic;
 	u8 id, revision;
-	const unsigned int bus = 0;
-	const unsigned int address = 0x40;
 	int err;
 
 	err = i2c_get_chip_for_busnum(bus, address, 1, &pmic);
diff --git a/include/power/as3722.h b/include/power/as3722.h
index 0f22482..c37b43a 100644
--- a/include/power/as3722.h
+++ b/include/power/as3722.h
@@ -14,7 +14,7 @@ 
 
 struct udevice;
 
-int as3722_init(struct udevice **devp);
+int as3722_init(struct udevice **devp, unsigned int bus, unsigned int address);
 int as3722_sd_enable(struct udevice *pmic, unsigned int sd);
 int as3722_sd_set_voltage(struct udevice *pmic, unsigned int sd, u8 value);
 int as3722_ldo_enable(struct udevice *pmic, unsigned int ldo);