diff mbox series

[1/4] i2c: sun6i_p2wi: Initialize chips in .child_pre_probe

Message ID 20220318045237.56237-2-samuel@sholland.org
State Accepted
Commit 48457f7ab031884d749e84440f4e5ae798e77c39
Delegated to: Andre Przywara
Headers show
Series sunxi: Fixes for DM I2C drivers | expand

Commit Message

Samuel Holland March 18, 2022, 4:52 a.m. UTC
Chips attached to the P2WI bus require an initialization command before
they can be used. (Specifically, this switches the chip from I2C mode
to P2WI mode.) The driver does this in its .probe_chip hook, under the
assumption that .probe_chip is called during child probe. This is not
the case; .probe_chip is only called by dm_i2c_probe, which is intended
for use by board-level code, not for chips with OF nodes.

Since this initialization command must be run before a child chip can be
used, do it before probing each child.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 drivers/i2c/sun6i_p2wi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andre Przywara April 4, 2022, 2:25 p.m. UTC | #1
On Thu, 17 Mar 2022 23:52:33 -0500
Samuel Holland <samuel@sholland.org> wrote:

Hi,

> Chips attached to the P2WI bus require an initialization command before
> they can be used. (Specifically, this switches the chip from I2C mode
> to P2WI mode.) The driver does this in its .probe_chip hook, under the
> assumption that .probe_chip is called during child probe. This is not
> the case; .probe_chip is only called by dm_i2c_probe, which is intended
> for use by board-level code, not for chips with OF nodes.

Indeed, I see that code path only triggered explicitly by board specific
code, none of those places being compiled for sunxi.

So without looking too deep or having the ability to test this, it looks
alright to me anyway.

Acked-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre

> Since this initialization command must be run before a child chip can be
> used, do it before probing each child.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
> 
>  drivers/i2c/sun6i_p2wi.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/sun6i_p2wi.c b/drivers/i2c/sun6i_p2wi.c
> index c9e1b3fcd5..da7f540509 100644
> --- a/drivers/i2c/sun6i_p2wi.c
> +++ b/drivers/i2c/sun6i_p2wi.c
> @@ -191,11 +191,12 @@ static int sun6i_p2wi_probe(struct udevice *bus)
>  static int sun6i_p2wi_child_pre_probe(struct udevice *child)
>  {
>  	struct dm_i2c_chip *chip = dev_get_parent_plat(child);
> +	struct udevice *bus = child->parent;
>  
>  	/* Ensure each transfer is for a single register. */
>  	chip->flags |= DM_I2C_CHIP_RD_ADDRESS | DM_I2C_CHIP_WR_ADDRESS;
>  
> -	return 0;
> +	return sun6i_p2wi_probe_chip(bus, chip->chip_addr, 0);
>  }
>  
>  static const struct dm_i2c_ops sun6i_p2wi_ops = {
diff mbox series

Patch

diff --git a/drivers/i2c/sun6i_p2wi.c b/drivers/i2c/sun6i_p2wi.c
index c9e1b3fcd5..da7f540509 100644
--- a/drivers/i2c/sun6i_p2wi.c
+++ b/drivers/i2c/sun6i_p2wi.c
@@ -191,11 +191,12 @@  static int sun6i_p2wi_probe(struct udevice *bus)
 static int sun6i_p2wi_child_pre_probe(struct udevice *child)
 {
 	struct dm_i2c_chip *chip = dev_get_parent_plat(child);
+	struct udevice *bus = child->parent;
 
 	/* Ensure each transfer is for a single register. */
 	chip->flags |= DM_I2C_CHIP_RD_ADDRESS | DM_I2C_CHIP_WR_ADDRESS;
 
-	return 0;
+	return sun6i_p2wi_probe_chip(bus, chip->chip_addr, 0);
 }
 
 static const struct dm_i2c_ops sun6i_p2wi_ops = {