mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] .gitignore: Add generated scripts/rkimage to .gitignore
@ 2023-07-14  5:15 Alexander Shiyan
  2023-07-14  5:15 ` [PATCH 1/2] i2c: Added feature to get bus number from alias Alexander Shiyan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alexander Shiyan @ 2023-07-14  5:15 UTC (permalink / raw)
  To: barebox; +Cc: Alexander Shiyan

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 scripts/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/.gitignore b/scripts/.gitignore
index 3ca742ac6e..36b60ad56b 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -32,6 +32,7 @@ omap3-usb-loader
 omap3-usb-loader-target
 rk-usb-loader
 rk-usb-loader-target
+rkimage
 mips-relocs
 rsatoc
 stm32image
-- 
2.38.2




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] i2c: Added feature to get bus number from alias
  2023-07-14  5:15 [PATCH] .gitignore: Add generated scripts/rkimage to .gitignore Alexander Shiyan
@ 2023-07-14  5:15 ` Alexander Shiyan
  2023-07-26 11:55   ` Sascha Hauer
  2023-07-14  5:15 ` [PATCH] mfd: rk808: Add missing RK809 chip ID to poweroff handler Alexander Shiyan
  2023-07-14  5:15 ` [PATCH 2/2] i2c: rockchip: Get I2C bus number from devicetree alias Alexander Shiyan
  2 siblings, 1 reply; 5+ messages in thread
From: Alexander Shiyan @ 2023-07-14  5:15 UTC (permalink / raw)
  To: barebox; +Cc: Alexander Shiyan

For the correct assignment of the I2C bus number, let's use an alias
from the devicetree.

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/i2c/i2c.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 300365bd1f..df3b968a4b 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -701,17 +701,21 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adapter)
 	int ret;
 
 	if (adapter->nr < 0) {
-		int nr;
+		if (!adapter->dev.of_node) {
+			int nr = adapter->dev.id;
 
-		for (nr = 0;; nr++)
-			if (!i2c_get_adapter(nr))
-				break;
-		adapter->nr = nr;
-	} else {
-		if (i2c_get_adapter(adapter->nr))
-			return -EBUSY;
+			for (nr = 0;; nr++)
+				if (!i2c_get_adapter(nr))
+					break;
+			adapter->nr = nr;
+		} else
+			adapter->nr =
+				of_alias_get_id(adapter->dev.of_node, "i2c");
 	}
 
+	if (i2c_get_adapter(adapter->nr))
+		return -EBUSY;
+
 	adapter->dev.id = adapter->nr;
 	dev_set_name(&adapter->dev, "i2c");
 
-- 
2.38.2




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] mfd: rk808: Add missing RK809 chip ID to poweroff handler
  2023-07-14  5:15 [PATCH] .gitignore: Add generated scripts/rkimage to .gitignore Alexander Shiyan
  2023-07-14  5:15 ` [PATCH 1/2] i2c: Added feature to get bus number from alias Alexander Shiyan
@ 2023-07-14  5:15 ` Alexander Shiyan
  2023-07-14  5:15 ` [PATCH 2/2] i2c: rockchip: Get I2C bus number from devicetree alias Alexander Shiyan
  2 siblings, 0 replies; 5+ messages in thread
From: Alexander Shiyan @ 2023-07-14  5:15 UTC (permalink / raw)
  To: barebox; +Cc: Alexander Shiyan

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/mfd/rk808.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 738ba305ac..1361bb7101 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -224,6 +224,7 @@ static void rk808_poweroff(struct poweroff_handler *handler)
 		reg = RK808_DEVCTRL_REG,
 		bit = DEV_OFF_RST;
 		break;
+	case RK809_ID:
 	case RK817_ID:
 		reg = RK817_SYS_CFG(3);
 		bit = DEV_OFF;
-- 
2.38.2




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] i2c: rockchip: Get I2C bus number from devicetree alias
  2023-07-14  5:15 [PATCH] .gitignore: Add generated scripts/rkimage to .gitignore Alexander Shiyan
  2023-07-14  5:15 ` [PATCH 1/2] i2c: Added feature to get bus number from alias Alexander Shiyan
  2023-07-14  5:15 ` [PATCH] mfd: rk808: Add missing RK809 chip ID to poweroff handler Alexander Shiyan
@ 2023-07-14  5:15 ` Alexander Shiyan
  2 siblings, 0 replies; 5+ messages in thread
From: Alexander Shiyan @ 2023-07-14  5:15 UTC (permalink / raw)
  To: barebox; +Cc: Alexander Shiyan

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/i2c/busses/i2c-rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-rockchip.c b/drivers/i2c/busses/i2c-rockchip.c
index 23bf4a55d7..e8061fe540 100644
--- a/drivers/i2c/busses/i2c-rockchip.c
+++ b/drivers/i2c/busses/i2c-rockchip.c
@@ -432,7 +432,7 @@ static int rk_i2c_probe(struct device *dev)
 		return dev_err_probe(dev, PTR_ERR(i2c->clk), "Can't get bus clk\n");
 
 	i2c->adapter.master_xfer = rockchip_i2c_xfer;
-	i2c->adapter.nr = dev->id;
+	i2c->adapter.nr = -1;
 	i2c->adapter.dev.parent = dev;
 	i2c->adapter.dev.of_node = np;
 
-- 
2.38.2




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] i2c: Added feature to get bus number from alias
  2023-07-14  5:15 ` [PATCH 1/2] i2c: Added feature to get bus number from alias Alexander Shiyan
@ 2023-07-26 11:55   ` Sascha Hauer
  0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2023-07-26 11:55 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

Hi Alexander,

On Fri, Jul 14, 2023 at 08:15:08AM +0300, Alexander Shiyan wrote:
> For the correct assignment of the I2C bus number, let's use an alias
> from the devicetree.
> 
> Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
> ---
>  drivers/i2c/i2c.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
> index 300365bd1f..df3b968a4b 100644
> --- a/drivers/i2c/i2c.c
> +++ b/drivers/i2c/i2c.c
> @@ -701,17 +701,21 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adapter)
>  	int ret;
>  
>  	if (adapter->nr < 0) {
> -		int nr;
> +		if (!adapter->dev.of_node) {
> +			int nr = adapter->dev.id;

nr is initialized but the initialization value is never used.

>  
> -		for (nr = 0;; nr++)
> -			if (!i2c_get_adapter(nr))
> -				break;
> -		adapter->nr = nr;
> -	} else {
> -		if (i2c_get_adapter(adapter->nr))
> -			return -EBUSY;
> +			for (nr = 0;; nr++)
> +				if (!i2c_get_adapter(nr))
> +					break;
> +			adapter->nr = nr;
> +		} else
> +			adapter->nr =
> +				of_alias_get_id(adapter->dev.of_node, "i2c");

of_alias_get_id() can return a negative error code when no alias exists.
You should catch this and either error out or provide a fallback.

Sascha

>  
> +	if (i2c_get_adapter(adapter->nr))
> +		return -EBUSY;
> +
>  	adapter->dev.id = adapter->nr;
>  	dev_set_name(&adapter->dev, "i2c");
>  
> -- 
> 2.38.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-26 11:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-14  5:15 [PATCH] .gitignore: Add generated scripts/rkimage to .gitignore Alexander Shiyan
2023-07-14  5:15 ` [PATCH 1/2] i2c: Added feature to get bus number from alias Alexander Shiyan
2023-07-26 11:55   ` Sascha Hauer
2023-07-14  5:15 ` [PATCH] mfd: rk808: Add missing RK809 chip ID to poweroff handler Alexander Shiyan
2023-07-14  5:15 ` [PATCH 2/2] i2c: rockchip: Get I2C bus number from devicetree alias Alexander Shiyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox