[U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name
For !DM case busses are listed as ZynqMP> i2c bus Bus 0: zynq_0 Bus 1: zynq_0->PCA9544A@0x75:0 Bus 2: zynq_0->PCA9544A@0x75:1 Bus 3: zynq_0->PCA9544A@0x75:2 Bus 4: zynq_1 Bus 5: zynq_1->PCA9548@0x74:0 Bus 6: zynq_1->PCA9548@0x74:1 Bus 7: zynq_1->PCA9548@0x74:2 Bus 8: zynq_1->PCA9548@0x74:3 Bus 9: zynq_1->PCA9548@0x74:4 Bus 10: zynq_1->PCA9548@0x75:0 Bus 11: zynq_1->PCA9548@0x75:1 Bus 12: zynq_1->PCA9548@0x75:2 Bus 13: zynq_1->PCA9548@0x75:3 Bus 14: zynq_1->PCA9548@0x75:4 Bus 15: zynq_1->PCA9548@0x75:5 Bus 16: zynq_1->PCA9548@0x75:6 Bus 17: zynq_1->PCA9548@0x75:7 where is exactly describing i2c bus topology. By moving to DM case i2c mux buses are using names from DT and because i2c-muxes describing sub busses with the same names like i2c@0, etc it is hard to identify which bus is where. Linux is adding topology information to i2c-mux busses to identify them better. This patch is doing the same and composing bus name with topology information. When patch is applied with topology information on zcu102-revA. ZynqMP> i2c bus Bus 0: i2c@ff02 20: gpio@20, offset len 1, flags 0 21: gpio@21, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 2: i2c@ff02->i2c-mux@75->i2c@0 Bus 3: i2c@ff02->i2c-mux@75->i2c@1 Bus 4: i2c@ff02->i2c-mux@75->i2c@2 Bus 1: i2c@ff03 (active 1) 74: i2c-mux@74, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 5: i2c@ff03->i2c-mux@74->i2c@0 (active 5) 54: eeprom@54, offset len 1, flags 0 Bus 6: i2c@ff03->i2c-mux@74->i2c@1 Bus 7: i2c@ff03->i2c-mux@74->i2c@2 Bus 8: i2c@ff03->i2c-mux@74->i2c@3 Bus 9: i2c@ff03->i2c-mux@74->i2c@4 Bus 10: i2c@ff03->i2c-mux@75->i2c@0 Bus 11: i2c@ff03->i2c-mux@75->i2c@1 Bus 12: i2c@ff03->i2c-mux@75->i2c@2 Bus 13: i2c@ff03->i2c-mux@75->i2c@3 Bus 14: i2c@ff03->i2c-mux@75->i2c@4 Bus 15: i2c@ff03->i2c-mux@75->i2c@5 Bus 16: i2c@ff03->i2c-mux@75->i2c@6 Bus 17: i2c@ff03->i2c-mux@75->i2c@7 Behavior before the patch is applied. ZynqMP> i2c bus Bus 0: i2c@ff02 20: gpio@20, offset len 1, flags 0 21: gpio@21, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 2: i2c@0 Bus 3: i2c@1 Bus 4: i2c@2 Bus 1: i2c@ff03 (active 1) 74: i2c-mux@74, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 5: i2c@0 (active 5) 54: eeprom@54, offset len 1, flags 0 Bus 6: i2c@1 Bus 7: i2c@2 Bus 8: i2c@3 Bus 9: i2c@4 Bus 10: i2c@0 Bus 11: i2c@1 Bus 12: i2c@2 Bus 13: i2c@3 Bus 14: i2c@4 Bus 15: i2c@5 Bus 16: i2c@6 Bus 17: i2c@7 Signed-off-by: Michal Simek --- Changes in v2: - Fix headers - Change patch description to focus only on bus name drivers/i2c/muxes/i2c-mux-uclass.c | 29 ++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c index a680ee176253..8b1149997a19 100644 --- a/drivers/i2c/muxes/i2c-mux-uclass.c +++ b/drivers/i2c/muxes/i2c-mux-uclass.c @@ -59,11 +59,34 @@ static int i2c_mux_post_bind(struct udevice *mux) dev_for_each_subnode(node, mux) { struct udevice *dev; const char *name; + const char *arrow = "->"; + char *full_name; + int parent_name_len, arrow_len, mux_name_len, name_len; name = ofnode_get_name(node); - ret = device_bind_driver_to_node(mux, "i2c_mux_bus_drv", name, -node, &dev); - debug(" - bind ret=%d, %s\n", ret, dev ? dev->name : NULL); + + /* Calculate lenghts of strings */ + parent_name_len = strlen(mux->parent->name); + arrow_len = strlen(arrow); + mux_name_len = strlen(mux->name); + name_len = strlen(name); + + full_name = calloc(1, parent_name_len + arrow_len + + mux_name_len + arrow_len + name_len + 1); + if (!full_name) + return -ENOMEM; + + /* Compose bus name */ + strcat(full_name, mux->parent->name); + strcat(full_name, arrow); + strcat(full_name, mux->name); + strcat(full_name, arrow); + strcat(full_name, name); + + ret = device_bind_driver_to_node(mux, "i2c_mux_bus_drv", +full_name, node, &dev); + debug(" - bind ret=%d, %s, req_seq %d\n", ret, + dev ? dev->name : NULL, dev->req_seq); if (ret) return ret; } -- 1.9.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name
On Thu, 31 Jan 2019 at 08:31, Michal Simek wrote: > > For !DM case busses are listed as > ZynqMP> i2c bus > Bus 0: zynq_0 > Bus 1: zynq_0->PCA9544A@0x75:0 > Bus 2: zynq_0->PCA9544A@0x75:1 > Bus 3: zynq_0->PCA9544A@0x75:2 > Bus 4: zynq_1 > Bus 5: zynq_1->PCA9548@0x74:0 > Bus 6: zynq_1->PCA9548@0x74:1 > Bus 7: zynq_1->PCA9548@0x74:2 > Bus 8: zynq_1->PCA9548@0x74:3 > Bus 9: zynq_1->PCA9548@0x74:4 > Bus 10: zynq_1->PCA9548@0x75:0 > Bus 11: zynq_1->PCA9548@0x75:1 > Bus 12: zynq_1->PCA9548@0x75:2 > Bus 13: zynq_1->PCA9548@0x75:3 > Bus 14: zynq_1->PCA9548@0x75:4 > Bus 15: zynq_1->PCA9548@0x75:5 > Bus 16: zynq_1->PCA9548@0x75:6 > Bus 17: zynq_1->PCA9548@0x75:7 > > where is exactly describing i2c bus topology. > By moving to DM case i2c mux buses are using names from DT and because > i2c-muxes describing sub busses with the same names like i2c@0, etc it > is hard to identify which bus is where. > Linux is adding topology information to i2c-mux busses to identify them > better. > This patch is doing the same and composing bus name with topology > information. > > When patch is applied with topology information on zcu102-revA. > ZynqMP> i2c bus > Bus 0: i2c@ff02 >20: gpio@20, offset len 1, flags 0 >21: gpio@21, offset len 1, flags 0 >75: i2c-mux@75, offset len 1, flags 0 > Bus 2: i2c@ff02->i2c-mux@75->i2c@0 > Bus 3: i2c@ff02->i2c-mux@75->i2c@1 > Bus 4: i2c@ff02->i2c-mux@75->i2c@2 > Bus 1: i2c@ff03 (active 1) >74: i2c-mux@74, offset len 1, flags 0 >75: i2c-mux@75, offset len 1, flags 0 > Bus 5: i2c@ff03->i2c-mux@74->i2c@0 (active 5) >54: eeprom@54, offset len 1, flags 0 > Bus 6: i2c@ff03->i2c-mux@74->i2c@1 > Bus 7: i2c@ff03->i2c-mux@74->i2c@2 > Bus 8: i2c@ff03->i2c-mux@74->i2c@3 > Bus 9: i2c@ff03->i2c-mux@74->i2c@4 > Bus 10: i2c@ff03->i2c-mux@75->i2c@0 > Bus 11: i2c@ff03->i2c-mux@75->i2c@1 > Bus 12: i2c@ff03->i2c-mux@75->i2c@2 > Bus 13: i2c@ff03->i2c-mux@75->i2c@3 > Bus 14: i2c@ff03->i2c-mux@75->i2c@4 > Bus 15: i2c@ff03->i2c-mux@75->i2c@5 > Bus 16: i2c@ff03->i2c-mux@75->i2c@6 > Bus 17: i2c@ff03->i2c-mux@75->i2c@7 > > Behavior before the patch is applied. > ZynqMP> i2c bus > Bus 0: i2c@ff02 >20: gpio@20, offset len 1, flags 0 >21: gpio@21, offset len 1, flags 0 >75: i2c-mux@75, offset len 1, flags 0 > Bus 2: i2c@0 > Bus 3: i2c@1 > Bus 4: i2c@2 > Bus 1: i2c@ff03 (active 1) >74: i2c-mux@74, offset len 1, flags 0 >75: i2c-mux@75, offset len 1, flags 0 > Bus 5: i2c@0 (active 5) >54: eeprom@54, offset len 1, flags 0 > Bus 6: i2c@1 > Bus 7: i2c@2 > Bus 8: i2c@3 > Bus 9: i2c@4 > Bus 10: i2c@0 > Bus 11: i2c@1 > Bus 12: i2c@2 > Bus 13: i2c@3 > Bus 14: i2c@4 > Bus 15: i2c@5 > Bus 16: i2c@6 > Bus 17: i2c@7 > > Signed-off-by: Michal Simek > --- > > Changes in v2: > - Fix headers > - Change patch description to focus only on bus name > > drivers/i2c/muxes/i2c-mux-uclass.c | 29 ++--- > 1 file changed, 26 insertions(+), 3 deletions(-) Reviewed-by: Simon Glass ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name
Hello Michal, Am 31.01.2019 um 16:31 schrieb Michal Simek: For !DM case busses are listed as ZynqMP> i2c bus Bus 0: zynq_0 Bus 1: zynq_0->PCA9544A@0x75:0 Bus 2: zynq_0->PCA9544A@0x75:1 Bus 3: zynq_0->PCA9544A@0x75:2 Bus 4: zynq_1 Bus 5: zynq_1->PCA9548@0x74:0 Bus 6: zynq_1->PCA9548@0x74:1 Bus 7: zynq_1->PCA9548@0x74:2 Bus 8: zynq_1->PCA9548@0x74:3 Bus 9: zynq_1->PCA9548@0x74:4 Bus 10: zynq_1->PCA9548@0x75:0 Bus 11: zynq_1->PCA9548@0x75:1 Bus 12: zynq_1->PCA9548@0x75:2 Bus 13: zynq_1->PCA9548@0x75:3 Bus 14: zynq_1->PCA9548@0x75:4 Bus 15: zynq_1->PCA9548@0x75:5 Bus 16: zynq_1->PCA9548@0x75:6 Bus 17: zynq_1->PCA9548@0x75:7 where is exactly describing i2c bus topology. By moving to DM case i2c mux buses are using names from DT and because i2c-muxes describing sub busses with the same names like i2c@0, etc it is hard to identify which bus is where. Linux is adding topology information to i2c-mux busses to identify them better. This patch is doing the same and composing bus name with topology information. When patch is applied with topology information on zcu102-revA. ZynqMP> i2c bus Bus 0: i2c@ff02 20: gpio@20, offset len 1, flags 0 21: gpio@21, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 2: i2c@ff02->i2c-mux@75->i2c@0 Bus 3: i2c@ff02->i2c-mux@75->i2c@1 Bus 4: i2c@ff02->i2c-mux@75->i2c@2 Bus 1: i2c@ff03 (active 1) 74: i2c-mux@74, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 5: i2c@ff03->i2c-mux@74->i2c@0 (active 5) 54: eeprom@54, offset len 1, flags 0 Bus 6: i2c@ff03->i2c-mux@74->i2c@1 Bus 7: i2c@ff03->i2c-mux@74->i2c@2 Bus 8: i2c@ff03->i2c-mux@74->i2c@3 Bus 9: i2c@ff03->i2c-mux@74->i2c@4 Bus 10: i2c@ff03->i2c-mux@75->i2c@0 Bus 11: i2c@ff03->i2c-mux@75->i2c@1 Bus 12: i2c@ff03->i2c-mux@75->i2c@2 Bus 13: i2c@ff03->i2c-mux@75->i2c@3 Bus 14: i2c@ff03->i2c-mux@75->i2c@4 Bus 15: i2c@ff03->i2c-mux@75->i2c@5 Bus 16: i2c@ff03->i2c-mux@75->i2c@6 Bus 17: i2c@ff03->i2c-mux@75->i2c@7 Behavior before the patch is applied. ZynqMP> i2c bus Bus 0: i2c@ff02 20: gpio@20, offset len 1, flags 0 21: gpio@21, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 2: i2c@0 Bus 3: i2c@1 Bus 4: i2c@2 Bus 1: i2c@ff03 (active 1) 74: i2c-mux@74, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 5: i2c@0 (active 5) 54: eeprom@54, offset len 1, flags 0 Bus 6: i2c@1 Bus 7: i2c@2 Bus 8: i2c@3 Bus 9: i2c@4 Bus 10: i2c@0 Bus 11: i2c@1 Bus 12: i2c@2 Bus 13: i2c@3 Bus 14: i2c@4 Bus 15: i2c@5 Bus 16: i2c@6 Bus 17: i2c@7 Signed-off-by: Michal Simek --- Changes in v2: - Fix headers - Change patch description to focus only on bus name drivers/i2c/muxes/i2c-mux-uclass.c | 29 ++--- 1 file changed, 26 insertions(+), 3 deletions(-) Much more cleaner output, thanks! Reviewed-by: Heiko Schocher I have no chance to test this on another hardware, so if someone could test it, this would be nice. bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name
Hello Michal, Am 31.01.2019 um 16:31 schrieb Michal Simek: For !DM case busses are listed as ZynqMP> i2c bus Bus 0: zynq_0 Bus 1: zynq_0->PCA9544A@0x75:0 Bus 2: zynq_0->PCA9544A@0x75:1 Bus 3: zynq_0->PCA9544A@0x75:2 Bus 4: zynq_1 Bus 5: zynq_1->PCA9548@0x74:0 Bus 6: zynq_1->PCA9548@0x74:1 Bus 7: zynq_1->PCA9548@0x74:2 Bus 8: zynq_1->PCA9548@0x74:3 Bus 9: zynq_1->PCA9548@0x74:4 Bus 10: zynq_1->PCA9548@0x75:0 Bus 11: zynq_1->PCA9548@0x75:1 Bus 12: zynq_1->PCA9548@0x75:2 Bus 13: zynq_1->PCA9548@0x75:3 Bus 14: zynq_1->PCA9548@0x75:4 Bus 15: zynq_1->PCA9548@0x75:5 Bus 16: zynq_1->PCA9548@0x75:6 Bus 17: zynq_1->PCA9548@0x75:7 where is exactly describing i2c bus topology. By moving to DM case i2c mux buses are using names from DT and because i2c-muxes describing sub busses with the same names like i2c@0, etc it is hard to identify which bus is where. Linux is adding topology information to i2c-mux busses to identify them better. This patch is doing the same and composing bus name with topology information. When patch is applied with topology information on zcu102-revA. ZynqMP> i2c bus Bus 0: i2c@ff02 20: gpio@20, offset len 1, flags 0 21: gpio@21, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 2: i2c@ff02->i2c-mux@75->i2c@0 Bus 3: i2c@ff02->i2c-mux@75->i2c@1 Bus 4: i2c@ff02->i2c-mux@75->i2c@2 Bus 1: i2c@ff03 (active 1) 74: i2c-mux@74, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 5: i2c@ff03->i2c-mux@74->i2c@0 (active 5) 54: eeprom@54, offset len 1, flags 0 Bus 6: i2c@ff03->i2c-mux@74->i2c@1 Bus 7: i2c@ff03->i2c-mux@74->i2c@2 Bus 8: i2c@ff03->i2c-mux@74->i2c@3 Bus 9: i2c@ff03->i2c-mux@74->i2c@4 Bus 10: i2c@ff03->i2c-mux@75->i2c@0 Bus 11: i2c@ff03->i2c-mux@75->i2c@1 Bus 12: i2c@ff03->i2c-mux@75->i2c@2 Bus 13: i2c@ff03->i2c-mux@75->i2c@3 Bus 14: i2c@ff03->i2c-mux@75->i2c@4 Bus 15: i2c@ff03->i2c-mux@75->i2c@5 Bus 16: i2c@ff03->i2c-mux@75->i2c@6 Bus 17: i2c@ff03->i2c-mux@75->i2c@7 Behavior before the patch is applied. ZynqMP> i2c bus Bus 0: i2c@ff02 20: gpio@20, offset len 1, flags 0 21: gpio@21, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 2: i2c@0 Bus 3: i2c@1 Bus 4: i2c@2 Bus 1: i2c@ff03 (active 1) 74: i2c-mux@74, offset len 1, flags 0 75: i2c-mux@75, offset len 1, flags 0 Bus 5: i2c@0 (active 5) 54: eeprom@54, offset len 1, flags 0 Bus 6: i2c@1 Bus 7: i2c@2 Bus 8: i2c@3 Bus 9: i2c@4 Bus 10: i2c@0 Bus 11: i2c@1 Bus 12: i2c@2 Bus 13: i2c@3 Bus 14: i2c@4 Bus 15: i2c@5 Bus 16: i2c@6 Bus 17: i2c@7 Signed-off-by: Michal Simek --- Changes in v2: - Fix headers - Change patch description to focus only on bus name drivers/i2c/muxes/i2c-mux-uclass.c | 29 ++--- 1 file changed, 26 insertions(+), 3 deletions(-) Applied to u-boot-i2c.git master Thanks! bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot