i3c: dw: fix slave device setup and probe issues
Subsystems (2)
v2 cover i3c: dw: fix slave device setup and probe issues
This series fixes several issues in the DW I3C master driver and related infrastructure that prevented I3C read/write operations, and enables I3C support for Versal Gen 2.
Changes in v2:
- Use -ENOTSUPP instead of -EOPNOTSUPP as the reset stub in include/reset.h returns -ENOTSUPP when CONFIG_DM_RESET=n
Pranav Tilak (4):
i3c: dw: make resets optional in probe
cmd: i3c: fix list and current needing pre-selected controller
configs: versal2: enable I3C support
i3c: dw: fix slave device setup after DAA
cmd/i3c.c | 11 ++++++----- configs/amd_versal2_virt_defconfig | 3 +++ drivers/i3c/master.c | 1 - drivers/i3c/master/dw-i3c-master.c | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/4 i3c: dw: make resets optional in probe
Treat -ENOENT and -ENOTSUPP from reset_get_bulk() as non-fatal to support platforms where no resets are defined in the DTS. The resets property is not yet documented in the DT binding.
--- drivers/i3c/master/dw-i3c-master.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/dw-i3c-master.c +1 -1
@@ -972,7 +972,7 @@ static int dw_i3c_probe(struct udevice *dev) } ret =reset_get_bulk (dev, &master->resets); -if (ret) { +if (ret && ret != -ENOTSUPP && ret != -ENOENT ) {dev_err (dev,"Can't get reset: %d\n" , ret);return ret; }
Signature · 1 line
2.34.1
Re: [PATCH v2 1/4] i3c: dw: make resets optional in probe
Hi Thilak,
Quoted 26 lines · Pranav Tilak
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
Treat
-ENOENTand-ENOTSUPPfromreset_get_bulk()as non-fatal to support platforms where no resets are defined in the DTS. The resets property is not yet documented in the DT binding.Fixes 1009c96f1590 ("drivers: i3c: Add driver for MIPI DWI3C")Signed-off-by Pranav Tilak <[email protected]>--- drivers/i3c/master/dw-i3c-master.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i3c/master/dw-i3c-master.c +1
-2@@ -972,7 +972,7 @@ static int dw_i3c_probe(struct udevice *dev) } ret =reset_get_bulk (dev, &master->resets); -if (ret) { +if (ret && ret != -ENOTSUPP && ret != -ENOENT ) {dev_err (dev,"Can't get reset: %d\n" , ret);return ret; } --
Quoted 2 lines
2.34.1
PATCH v2 2/4 cmd: i3c: fix list and current needing pre-selected controller
In reply to Pranav TilakThe !currdev guard in do_i3c() was placed before the list and current handlers, causing both to fail when no controller is pre-selected. Move the guard to only protect device_list, write and read which actually need a controller.
--- cmd/i3c.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
cmd/i3c.c +6 -5
@@ -240,16 +240,17 @@ static int do_i3c(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])if (!is_i3c_subcommand (subcmd))return handle_i3c_select (subcmd); +if (!strcmp (subcmd,"list" )) +return handle_i3c_list (); +else if (!strcmp (subcmd,"current" )) +return handle_i3c_current (); +if (!currdev) {printf ("i3c: No I3C controller selected\n" );return CMD_RET_FAILURE ; } -if (!strcmp (subcmd,"list" )) -return handle_i3c_list (); -else if (!strcmp (subcmd,"current" )) -return handle_i3c_current (); -else if (!strcmp (subcmd,"device_list" )) +if (!strcmp (subcmd,"device_list" ))return handle_i3c_device_list ();else if (!strcmp (subcmd,"write" ))return handle_i3c_write (argc, argv);
Signature · 1 line
2.34.1
PATCH v2 3/4 configs: versal2: enable I3C support
In reply to Pranav TilakEnable I3C controller driver and command support for Versal Gen 2 by adding CONFIG_CMD_I3C, CONFIG_I3C and CONFIG_DW_I3C_MASTER.
--- configs/amd_versal2_virt_defconfig | 3 +++ 1 file changed, 3 insertions(+)
configs/amd_versal2_virt_defconfig +3 -0
@@ -46,6 +46,7 @@ CONFIG_CMD_CLK=y CONFIG_CMD_DFU=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y +CONFIG_CMD_I3C=y CONFIG_CMD_LSBLK=y CONFIG_CMD_MMC=y CONFIG_MMC_SPEED_MODE_SET=y
@@ -103,6 +104,8 @@ CONFIG_SYS_I2C_CADENCE=y CONFIG_I2C_MUX=y CONFIG_I2C_MUX_PCA9541=y CONFIG_I2C_MUX_PCA954x=y +CONFIG_I3C=y +CONFIG_DW_I3C_MASTER=y CONFIG_DM_MAILBOX=y CONFIG_ZYNQMP_IPI=y CONFIG_MISC=y
Signature · 1 line
2.34.1
PATCH v2 4/4 i3c: dw: fix slave device setup after DAA
In reply to Pranav Tilaki3c_master_add_i3c_dev_locked() incorrectly set master->this to the newly discovered slave device, causing i3c_master_attach_i3c_dev() to skip the attach_i3c_dev() callback. As a result the slave device never got its master_priv (DAT slot index) allocated, free_pos was never updated, and the DAT entry was never written.
Fix by removing the incorrect master->this assignment. Store the slave descriptor directly in master->i3cdev[pos] inside dw_i3c_master_attach_i3c_dev() where the DAT slot index is already known. Also check the return value of i3c_master_add_i3c_dev_locked() and skip num_i3cdevs increment on failure, fixing dummy devices shown when no slaves are present on the bus.
--- drivers/i3c/master.c | 1 - drivers/i3c/master/dw-i3c-master.c | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/i3c/master.c +0 -1
@@ -1443,7 +1443,6 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master,if (IS_ERR (newdev))return PTR_ERR (newdev); - master->this = newdev; ret =i3c_master_attach_i3c_dev (master, newdev);if (ret) goto err_free_dev;
drivers/i3c/master/dw-i3c-master.c +3 -2
@@ -671,8 +671,8 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)for (pos =0 ; pos < master->maxdevs; pos++) {if (newdevs &BIT (pos)) { -i3c_master_add_i3c_dev_locked (m, master->addrs[pos]); - master->i3cdev[pos] = m->this; +if (i3c_master_add_i3c_dev_locked (m, master->addrs[pos])) +continue ; master->num_i3cdevs++; } }
@@ -806,6 +806,7 @@ static int dw_i3c_master_attach_i3c_dev(struct i3c_dev_desc *dev) master->addrs[pos] = dev->info.dyn_addr ? : dev->info.static_addr; master->free_pos &= ~BIT (pos);i3c_dev_set_master_data (dev, data); + master->i3cdev[pos] = dev; writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->addrs[pos]), master->regs +
Signature · 1 line
2.34.1
Re: [PATCH v2 4/4] i3c: dw: fix slave device setup after DAA
Hi Pranav — thanks.
Quoted 58 lines · Pranav Tilak
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
i3c_master_add_i3c_dev_locked()incorrectly setmaster->thisto the newly discovered slave device, causingi3c_master_attach_i3c_dev()to skip theattach_i3c_dev()callback. As a result the slave device never got itsmaster_priv(DAT slot index) allocated,free_poswas never updated, and the DAT entry was never written.Fix by removing the incorrect
master->thisassignment. Store the slave descriptor directly in master->i3cdev[pos] insidedw_i3c_master_attach_i3c_dev()where the DAT slot index is already known. Also check the return value ofi3c_master_add_i3c_dev_locked()and skipnum_i3cdevsincrement on failure, fixing dummy devices shown when no slaves are present on the bus.Fixes 1009c96f1590 ("drivers: i3c: Add driver for MIPI DWI3C")Signed-off-by Pranav Tilak <[email protected]>--- drivers/i3c/master.c | 1 - drivers/i3c/master/dw-i3c-master.c | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/i3c/master.c +0
-1@@ -1443,7 +1443,6 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master,if (IS_ERR (newdev))return PTR_ERR (newdev); - master->this = newdev; ret =i3c_master_attach_i3c_dev (master, newdev);if (ret) goto err_free_dev;drivers/i3c/master/dw-i3c-master.c +3
-3@@ -671,8 +671,8 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)for (pos =0 ; pos < master->maxdevs; pos++) {if (newdevs &BIT (pos)) { -i3c_master_add_i3c_dev_locked (m, master->addrs[pos]); - master->i3cdev[pos] = m->this; +if (i3c_master_add_i3c_dev_locked (m, master->addrs[pos])) +continue ; master->num_i3cdevs++; } }@@ -806,6 +806,7 @@ static int dw_i3c_master_attach_i3c_dev(struct i3c_dev_desc *dev) master->addrs[pos] = dev->info.dyn_addr ? : dev->info.static_addr; master->free_pos &= ~BIT (pos);i3c_dev_set_master_data (dev, data); + master->i3cdev[pos] = dev; writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(master->addrs[pos]), master->regs + --
Quoted 2 lines
2.34.1
The master->this misuse before attach is a real bug (skips attach_i3c_dev for every slave). Removing that assignment and recording i3cdev[] inside dw_i3c_master_attach_i3c_dev() looks correct to me.
Hi Dinesh,
Quoted 14 lines · Pranav Tilak
This series fixes several issues in the DW I3C master driver and related infrastructure that prevented I3C read/write operations, and enables I3C support for Versal Gen 2.
Changes in v2:
- Use-ENOTSUPPinstead of-EOPNOTSUPPas the reset stub ininclude/reset.hreturns-ENOTSUPPwhenCONFIG_DM_RESET=nPranav Tilak (4):
i3c: dw: make resets optional in probe
cmd: i3c: fix list and current needing pre-selected controller
configs: versal2: enable I3C support
i3c: dw: fix slave device setup after DAA
Quoted 6 lines
cmd/i3c.c | 11 ++++++----- configs/amd_versal2_virt_defconfig | 3 +++ drivers/i3c/master.c | 1 - drivers/i3c/master/dw-i3c-master.c | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-)
Dinesh: Can you please look at 1/4 and 4/4 patches?
Thanks,
Michal
Hi Michal Simek,
Quoted 26 lines · Michal Simek
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
Hi Dinesh,
Quoted 14 lines · Pranav Tilak
This series fixes several issues in the DW I3C master driver and related infrastructure that prevented I3C read/write operations, and enables I3C support for Versal Gen 2.
Changes in v2:
- Use-ENOTSUPPinstead of-EOPNOTSUPPas the reset stub ininclude/reset.hreturns-ENOTSUPPwhenCONFIG_DM_RESET=nPranav Tilak (4):
i3c: dw: make resets optional in probe
cmd: i3c: fix list and current needing pre-selected controller
configs: versal2: enable I3C support
i3c: dw: fix slave device setup after DAAQuoted 6 lines
cmd/i3c.c | 11 ++++++----- configs/amd_versal2_virt_defconfig | 3 +++ drivers/i3c/master.c | 1 - drivers/i3c/master/dw-i3c-master.c | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-)
Quoted 4 lines
Dinesh: Can you please look at 1/4 and 4/4 patches?
Thanks,
Michal
Reviewed. Thanks!
Regards
Dinesh
Hi,
Quoted 29 lines · Dinesh
Hi Michal Simek,
Quoted 26 lines · Michal Simek
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
Hi Dinesh,
Quoted 20 lines · Pranav Tilak
This series fixes several issues in the DW I3C master driver and related infrastructure that prevented I3C read/write operations, and enables I3C support for Versal Gen 2.
Changes in v2:
- Use-ENOTSUPPinstead of-EOPNOTSUPPas the reset stub ininclude/reset.hreturns-ENOTSUPPwhenCONFIG_DM_RESET=nPranav Tilak (4):
i3c: dw: make resets optional in probe
cmd: i3c: fix list and current needing pre-selected controller
configs: versal2: enable I3C support
i3c: dw: fix slave device setup after DAAcmd/i3c.c | 11 ++++++----- configs/amd_versal2_virt_defconfig | 3 +++ drivers/i3c/master.c | 1 - drivers/i3c/master/dw-i3c-master.c | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-)
Quoted 6 lines
Quoted 4 lines
Dinesh: Can you please look at 1/4 and 4/4 patches?
Thanks,
MichalReviewed. Thanks!
Thanks.
Tom: Are you going to take it directly? Or do you want me to collect it? In patchwork it is assigned to you.
Thanks,
Michal
Quoted 37 lines · Michal Simek
Hi,
Quoted 34 lines · Dinesh
Hi Michal Simek,
Quoted 30 lines · Michal Simek
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
Hi Dinesh,
Quoted 14 lines · Pranav Tilak
This series fixes several issues in the DW I3C master driver and related infrastructure that prevented I3C read/write operations, and enables I3C support for Versal Gen 2.
Changes in v2:
- Use-ENOTSUPPinstead of-EOPNOTSUPPas the reset stub ininclude/reset.hreturns-ENOTSUPPwhenCONFIG_DM_RESET=nPranav Tilak (4):
i3c: dw: make resets optional in probe
cmd: i3c: fix list and current needing pre-selected controller
configs: versal2: enable I3C support
i3c: dw: fix slave device setup after DAAQuoted 6 lines
cmd/i3c.c | 11 ++++++----- configs/amd_versal2_virt_defconfig | 3 +++ drivers/i3c/master.c | 1 - drivers/i3c/master/dw-i3c-master.c | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-)Dinesh: Can you please look at 1/4 and 4/4 patches?
Thanks,
Michal
Quoted 6 lines
Quoted 1 line
Reviewed. Thanks!
Thanks.
Tom: Are you going to take it directly? Or do you want me to collect it? In patchwork it is assigned to you.
I was about to take it directly yesterday then I saw your email. I'll pick it up today.
Signature · 1 line
Tom
Quoted 9 lines · Pranav Tilak
This series fixes several issues in the DW I3C master driver and related infrastructure that prevented I3C read/write operations, and enables I3C support for Versal Gen 2.
Changes in v2:
- Use-ENOTSUPPinstead of-EOPNOTSUPPas the reset stub ininclude/reset.hreturns-ENOTSUPPwhenCONFIG_DM_RESET=n[...]
Applied to u-boot/main, thanks!
[1/4] i3c: dw: make resets optional in probe
commit: f077a6b07be1939eb5865fb6afe60ed3c545edb0
[2/4] cmd: i3c: fix list and current needing pre-selected controller
commit: b2062131b430e2ff3ef69dea9d8fc19e2e268c03
[3/4] configs: versal2: enable I3C support
commit: 331d9b8cf6345f4a041dd9f13e8565a1eb471d32
[4/4] i3c: dw: fix slave device setup after DAA
commit: 57b60ccd79790399d92d46ac1cde1086e4def7bdSignature · 1 line
Tom