From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 04/24] dm: i2c: Implement 'i2c bus' command for driver model
Date: Wed, 06 May 2015 07:44:24 +0200 [thread overview]
Message-ID: <5549AA38.2020804@denx.de> (raw)
In-Reply-To: <1430760687-28505-5-git-send-email-sjg@chromium.org>
Hello Simon,
Am 04.05.2015 19:30, schrieb Simon Glass:
> This command was missed in the conversion. Add it back for driver model.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> common/cmd_i2c.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 55 insertions(+), 8 deletions(-)
>
> diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
> index ad38cbf..1bc0db8 100644
> --- a/common/cmd_i2c.c
> +++ b/common/cmd_i2c.c
> @@ -1623,6 +1623,27 @@ int do_edid(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
> }
> #endif /* CONFIG_I2C_EDID */
>
> +#ifdef CONFIG_DM_I2C
> +static void show_bus(struct udevice *bus)
> +{
> + struct udevice *dev;
> +
> + printf("Bus %d:\t%s", bus->req_seq, bus->name);
> + if (device_active(bus))
> + printf(" (active %d)", bus->seq);
> + printf("\n");
> + for (device_find_first_child(bus, &dev);
> + dev;
> + device_find_next_child(&dev)) {
> + struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
> +
> + printf(" %02x: %s, offset len %x, flags %x\n",
> + chip->chip_addr, dev->name, chip->offset_len,
> + chip->flags);
> + }
> +}
> +#endif
> +
> /**
> * do_i2c_show_bus() - Handle the "i2c bus" command-line command
> * @cmdtp: Command data struct pointer
> @@ -1632,20 +1653,30 @@ int do_edid(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
> *
> * Returns zero always.
> */
> -#if defined(CONFIG_SYS_I2C)
> +#if defined(CONFIG_SYS_I2C) || defined(CONFIG_DM_I2C)
> static int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc,
> char * const argv[])
> {
> - int i;
> -#ifndef CONFIG_SYS_I2C_DIRECT_BUS
> - int j;
> -#endif
> -
> if (argc == 1) {
> /* show all busses */
> +#ifdef CONFIG_DM_I2C
> + struct udevice *bus;
> + struct uclass *uc;
> + int ret;
> +
> + ret = uclass_get(UCLASS_I2C, &uc);
> + if (ret)
> + return CMD_RET_FAILURE;
> + uclass_foreach_dev(bus, uc)
> + show_bus(bus);
> +#else
> + int i;
> +
> for (i = 0; i < CONFIG_SYS_NUM_I2C_BUSES; i++) {
> printf("Bus %d:\t%s", i, I2C_ADAP_NR(i)->name);
> #ifndef CONFIG_SYS_I2C_DIRECT_BUS
> + int j;
> +
I thought this drops an error, because var j is declared in the middle of
code, but just tried it with gcc 4.7.2 and gcc 4.8.1 vor the mgcoge board,
drops no warning, so:
Acked-by: Heiko Schocher <hs@denx.de>
Thanks!
bye,
Heiko
> for (j = 0; j < CONFIG_SYS_I2C_MAX_HOPS; j++) {
> if (i2c_bus[i].next_hop[j].chip == 0)
> break;
> @@ -1657,15 +1688,30 @@ static int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc,
> #endif
> printf("\n");
> }
> +#endif
> } else {
> + int i;
> +
> /* show specific bus */
> i = simple_strtoul(argv[1], NULL, 10);
> +#ifdef CONFIG_DM_I2C
> + struct udevice *bus;
> + int ret;
> +
> + ret = uclass_get_device_by_seq(UCLASS_I2C, i, &bus);
> + if (ret) {
> + printf("Invalid bus %d: err=%d\n", i, ret);
> + return CMD_RET_FAILURE;
> + }
> + show_bus(bus);
> +#else
> if (i >= CONFIG_SYS_NUM_I2C_BUSES) {
> printf("Invalid bus %d\n", i);
> return -1;
> }
> printf("Bus %d:\t%s", i, I2C_ADAP_NR(i)->name);
> #ifndef CONFIG_SYS_I2C_DIRECT_BUS
> + int j;
> for (j = 0; j < CONFIG_SYS_I2C_MAX_HOPS; j++) {
> if (i2c_bus[i].next_hop[j].chip == 0)
> break;
> @@ -1676,6 +1722,7 @@ static int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc,
> }
> #endif
> printf("\n");
> +#endif
> }
>
> return 0;
> @@ -1835,7 +1882,7 @@ static int do_i2c_reset(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv
> }
>
> static cmd_tbl_t cmd_i2c_sub[] = {
> -#if defined(CONFIG_SYS_I2C)
> +#if defined(CONFIG_SYS_I2C) || defined(CONFIG_DM_I2C)
> U_BOOT_CMD_MKENT(bus, 1, 1, do_i2c_show_bus, "", ""),
> #endif
> U_BOOT_CMD_MKENT(crc32, 3, 1, do_i2c_crc, "", ""),
> @@ -1902,7 +1949,7 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
> /***************************************************/
> #ifdef CONFIG_SYS_LONGHELP
> static char i2c_help_text[] =
> -#if defined(CONFIG_SYS_I2C)
> +#if defined(CONFIG_SYS_I2C) || defined(CONFIG_DM_I2C)
> "bus [muxtype:muxaddr:muxchannel] - show I2C bus info\n"
> #endif
> "crc32 chip address[.0, .1, .2] count - compute CRC32 checksum\n"
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2015-05-06 5:44 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-04 17:30 [U-Boot] [PATCH 01/24] usb: add device connection/disconnection detection Simon Glass
2015-05-04 17:30 ` [U-Boot] [PATCH 02/24] dm: usb: Implement usb_detect_change() for driver model Simon Glass
2015-05-04 20:55 ` Joe Hershberger
2015-05-04 17:30 ` [U-Boot] [PATCH 03/24] bootstage: Add IDs for SPI flash reading and decompression Simon Glass
2015-05-04 20:57 ` Joe Hershberger
2015-05-08 5:58 ` Jagan Teki
2015-05-12 22:40 ` Simon Glass
2015-05-04 17:30 ` [U-Boot] [PATCH 04/24] dm: i2c: Implement 'i2c bus' command for driver model Simon Glass
2015-05-04 20:35 ` Joe Hershberger
2015-05-06 5:44 ` Heiko Schocher [this message]
2015-05-06 14:34 ` Simon Glass
2015-05-12 22:40 ` Simon Glass
2015-05-04 17:30 ` [U-Boot] [PATCH 05/24] dm: i2c: Add a function to find out the chip offset length Simon Glass
2015-05-04 20:43 ` Joe Hershberger
2015-05-06 5:37 ` Heiko Schocher
2015-05-12 22:40 ` Simon Glass
2015-05-04 17:30 ` [U-Boot] [PATCH 06/24] tpm: Support using driver model with I2C Simon Glass
2015-05-12 22:40 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 07/24] tpm: Rename Infineon TPM to slb9645tt Simon Glass
2015-05-12 22:41 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 08/24] dm: gpio: Fix comment typo in GPIOD_IS_IN Simon Glass
2015-05-12 22:41 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 09/24] arm: Include the .got section in the binary Simon Glass
2015-05-12 22:41 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 10/24] arm: Add a prototype for save_boot_params_ret() Simon Glass
2015-05-04 21:09 ` Joe Hershberger
2015-05-12 22:41 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 11/24] arm: spl: Enable detecting when U-Boot is started from SPL Simon Glass
2015-05-04 20:39 ` Joe Hershberger
2015-05-04 17:31 ` [U-Boot] [PATCH 12/24] arm: Allow cleanup_before_linux() without disabling caches Simon Glass
2015-05-04 17:36 ` Marek Vasut
2015-05-04 17:49 ` Simon Glass
2015-05-04 18:02 ` Marek Vasut
2015-05-04 17:31 ` [U-Boot] [PATCH 13/24] sandbox: Add an implementation for cleanup_before_linux_select() Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 14/24] sandbox: Correct error handling in state_read_file() Simon Glass
2015-05-04 21:12 ` Joe Hershberger
2015-05-12 22:41 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 15/24] sandbox: Add missing errno.h includes in a few files Simon Glass
2015-05-12 22:41 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 16/24] sandbox: cros_ec: Support EC_CMD_ENTERING_MODE emulation Simon Glass
2015-05-12 22:41 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 17/24] sandbox: spi: Add newline to printf() in sandbox_sf_probe Simon Glass
2015-05-04 21:06 ` Joe Hershberger
2015-05-08 5:58 ` Jagan Teki
2015-05-12 22:41 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 18/24] sandbox: Fix warning in display_options Simon Glass
2015-05-04 21:45 ` Joe Hershberger
2015-05-12 22:41 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 19/24] sandbox: Support wide-screen LCD emulation Simon Glass
2015-05-04 21:27 ` Joe Hershberger
2015-05-04 21:36 ` Simon Glass
2015-05-12 22:41 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 20/24] lcd: Support colour lookup table on 16bpp display in BMP images Simon Glass
2015-05-04 21:42 ` Joe Hershberger
2015-05-04 17:31 ` [U-Boot] [PATCH 21/24] tegra124: Implement spl_was_boot_source() Simon Glass
2015-05-05 15:54 ` Stephen Warren
2015-05-05 16:02 ` Simon Glass
2015-05-05 16:10 ` Stephen Warren
2015-05-05 16:19 ` Simon Glass
2015-05-05 18:07 ` Stephen Warren
2015-05-06 19:04 ` Simon Glass
2015-05-04 17:31 ` [U-Boot] [PATCH 22/24] tegra: nyan-big: Allow TPM on I2C Simon Glass
2015-05-04 17:52 ` Stephen Warren
2015-05-04 17:31 ` [U-Boot] [PATCH 23/24] tegra: mmc: Set the removable flag correctly Simon Glass
2015-05-04 22:00 ` Joe Hershberger
2015-05-05 9:39 ` Pantelis Antoniou
2015-05-04 17:31 ` [U-Boot] [PATCH 24/24] tegra124: Expand SPL space by 8KB Simon Glass
2015-05-05 15:59 ` Stephen Warren
2015-05-05 16:03 ` Simon Glass
2015-05-05 16:12 ` Stephen Warren
2015-05-05 16:26 ` Simon Glass
2015-05-05 18:20 ` Stephen Warren
2015-05-06 19:04 ` Simon Glass
2015-05-05 16:03 ` Simon Glass
2015-05-05 16:13 ` Tom Warren
2015-05-12 22:40 ` [U-Boot] [PATCH 01/24] usb: add device connection/disconnection detection Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5549AA38.2020804@denx.de \
--to=hs@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox