> -----Original Message----- > From: Heiko Schocher <[email protected]> > Sent: Saturday, 12 July 2025 4:17 pm > To: Maniyam, Dinesh <[email protected]>; [email protected] > Cc: Marek <[email protected]>; Simon <[email protected]>; > Simon Glass <[email protected]>; Tom Rini <[email protected]>; Dario > Binacchi <[email protected]>; Ilias Apalodimas > <[email protected]>; Heinrich Schuchardt <[email protected]>; > Jerome Forissier <[email protected]>; Mattijs Korpershoek > <[email protected]>; Ibai Erkiaga <[email protected]>; > Michal Simek <[email protected]>; Dmitry Rokosov > <[email protected]>; Jonas Karlman <[email protected]>; Sebastian > Reichel <[email protected]>; Tingting Meng > <[email protected]>; Chee, Tien Fong <[email protected]>; > Hea, Kok Kiang <[email protected]>; Ng, Boon Khai > <[email protected]>; Yuslaimi, Alif Zakuan > <[email protected]>; Hazim > <[email protected]>; Lim, Jit Loon > <[email protected]> > Subject: Re: [PATCH v5 09/12] cmd: Add i3c command support. > > [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.] > > Hello Dinesh, > > sorry for late reply... >
No problem, thanks for the review. > On 13.05.25 12:19, [email protected] wrote: > > From: Dinesh Maniyam <[email protected]> > > > > Add i3c command file to support select, get i3c device target list, > > read and write operation. > > > > Signed-off-by: Dinesh Maniyam <[email protected]> > > --- > > cmd/Kconfig | 6 + > > cmd/Makefile | 1 + > > cmd/i3c.c | 261 +++++++++++++++++++++++++++++ > > doc/usage/cmd/i3c.rst | 146 ++++++++++++++++ > > doc/usage/index.rst | 1 + > > drivers/i3c/master/dw-i3c-master.c | 35 +++- > > include/dw-i3c.h | 2 + > > include/i3c.h | 28 +++- > > 8 files changed, 478 insertions(+), 2 deletions(-) > > create mode 100644 cmd/i3c.c > > create mode 100644 doc/usage/cmd/i3c.rst > > [...] > > > diff --git a/cmd/i3c.c b/cmd/i3c.c > > new file mode 100644 > > index 00000000000..7d2bde714cd > > --- /dev/null > > +++ b/cmd/i3c.c > > @@ -0,0 +1,261 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +/* > > + * Copyright (C) 2025 Altera Corporation <www.altera.com> */ > > + > > +#include <bootretry.h> > > +#include <cli.h> > > +#include <command.h> > > +#include <console.h> > > +#include <dm.h> > > +#include <dw-i3c.h> > > +#include <edid.h> > > +#include <errno.h> > > +#include <hexdump.h> > > +#include <log.h> > > +#include <malloc.h> > > +#include <asm/byteorder.h> > > +#include <linux/compiler.h> > > +#include <linux/delay.h> > > +#include <u-boot/crc.h> > > +#include <linux/i3c/master.h> > > +#include <linux/printk.h> > > +#include <linux/types.h> > > + > > +static struct udevice *currdev; > > +static struct udevice *prevdev; > > +static struct dw_i3c_master *master; > > + > > +static void low_to_high_bytes(void *data, size_t size) { > > + u8 *byte_data = data; > > + size_t start = 0; > > + size_t end = size - 1; > > + > > + while (start < end) { > > + u8 temp = byte_data[start]; > > + > > + byte_data[start] = byte_data[end]; > > + byte_data[end] = temp; > > + start++; > > + end--; > > + } > > +} > > + > > +static int handle_i3c_select(const char *name) { > > + struct uclass *uc; > > + struct udevice *dev_list; > > + int ret = uclass_get_device_by_name(UCLASS_I3C, name, &currdev); > > + > > + if (ret) { > > + currdev = prevdev; > > + if (!currdev) { > > + ret = uclass_get(UCLASS_I3C, &uc); > > + if (ret) > > + return CMD_RET_FAILURE; > > + > > + uclass_foreach_dev(dev_list, uc) > > + printf("%s (%s)\n", dev_list->name, > > + dev_list->driver->name); > > + > > + printf("i3c: Host controller not initialized: %s\n", > > name); > > + return CMD_RET_FAILURE; > > + } > > + } else { > > + master = dev_get_priv(currdev); > > + printf("i3c: Current controller: %s\n", currdev->name); > > + prevdev = currdev; > > + } > > + > > + return CMD_RET_SUCCESS; > > +} > > + > > +static int handle_i3c_list(void) > > +{ > > + struct uclass *uc; > > + struct udevice *dev_list; > > + int ret = uclass_get(UCLASS_I3C, &uc); > > + > > + if (ret) > > + return CMD_RET_FAILURE; > > + > > + uclass_foreach_dev(dev_list, uc) > > + printf("%s (%s)\n", dev_list->name, > > + dev_list->driver->name); > > + > > + return CMD_RET_SUCCESS; > > +} > > + > > +static int handle_i3c_current(void) > > +{ > > + if (!currdev) > > + printf("i3c: No current controller selected\n"); > > + else > > + printf("i3c: Current controller: %s\n", currdev->name); > > + > > + return CMD_RET_SUCCESS; > > +} > > + > > +static int handle_i3c_device_list(void) { > > + if (!master) { > > + printf("i3c: No controller active\n"); > > + return CMD_RET_FAILURE; > > + } > > + > > + for (int i = 0; i < master->num_i3cdevs; i++) { > > + struct i3c_device_info *info = &master->i3cdev[i]->info; > > + > > + printf("Device %d:\n", i); > > + printf(" Static Address : 0x%02X\n", info->static_addr); > > + printf(" Dynamic Address : 0x%X\n", info->dyn_addr); > > + printf(" PID : %016llx\n", info->pid); > > + printf(" BCR : 0x%X\n", info->bcr); > > + printf(" DCR : 0x%X\n", info->dcr); > > + printf(" Max Read DS : 0x%X\n", info->max_read_ds); > > + printf(" Max Write DS : 0x%X\n", info->max_write_ds); > > + printf("\n"); > > + } > > + > > + return CMD_RET_SUCCESS; > > +} > > + > > +static int handle_i3c_write(int argc, char *const argv[]) { > > + if (argc < 5) > > + return CMD_RET_USAGE; > > + > > + if (!currdev) { > > + printf("i3c: No I3C controller selected\n"); > > + return CMD_RET_FAILURE; > > + } > > + > > + u32 mem_addr = hextoul(argv[2], NULL); > > + u32 num_bytes = hextoul(argv[3], NULL); > > + u32 dev_num_val = hextoul(argv[4], NULL); > > Please move the variable declaration to top of the function. Please fix this > for all > appearances, thanks! > > bye, > Heiko > -- Sure, I will fix this. Regards Dinesh > DENX Software Engineering GmbH, Managing Director: Johanna Denk, Tabea Lutz > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany > Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]

