* [PATCH] gpio: pca953x: add bus option to select the i2c bus.
@ 2020-12-08 7:32 Joseph Liu
2020-12-12 15:39 ` Simon Glass
0 siblings, 1 reply; 5+ messages in thread
From: Joseph Liu @ 2020-12-08 7:32 UTC (permalink / raw)
To: u-boot
From: Joseph Liu <kwliu@nuvoton.com>
If DM_I2C is used, the command "i2c dev" will not reassign
gd->cur_i2c_bus.
Add this bus option to change the active I2C bus.
Signed-off-by: Joseph Liu <kwliu@nuvoton.com>
---
drivers/gpio/pca953x.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index 4ab8cee2d1..b64f6ddcea 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -20,6 +20,7 @@
enum {
PCA953X_CMD_INFO,
+ PCA953X_CMD_BUS,
PCA953X_CMD_DEVICE,
PCA953X_CMD_OUTPUT,
PCA953X_CMD_INPUT,
@@ -194,6 +195,7 @@ static int pca953x_info(uint8_t chip)
}
static struct cmd_tbl cmd_pca953x[] = {
+ U_BOOT_CMD_MKENT(bus, 3, 0, (void *)PCA953X_CMD_BUS, "", ""),
U_BOOT_CMD_MKENT(device, 3, 0, (void *)PCA953X_CMD_DEVICE, "", ""),
U_BOOT_CMD_MKENT(output, 4, 0, (void *)PCA953X_CMD_OUTPUT, "", ""),
U_BOOT_CMD_MKENT(input, 3, 0, (void *)PCA953X_CMD_INPUT, "", ""),
@@ -205,6 +207,7 @@ static int do_pca953x(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
static uint8_t chip = CONFIG_SYS_I2C_PCA953X_ADDR;
+ uint8_t bus = 0;
int ret = CMD_RET_USAGE, val;
ulong ul_arg2 = 0;
ulong ul_arg3 = 0;
@@ -214,7 +217,7 @@ static int do_pca953x(struct cmd_tbl *cmdtp, int flag, int argc,
/* All commands but "device" require 'maxargs' arguments */
if (!c || !((argc == (c->maxargs)) ||
- (((long)c->cmd == PCA953X_CMD_DEVICE) &&
+ ((((long)c->cmd == PCA953X_CMD_DEVICE) || ((long)c->cmd == PCA953X_CMD_BUS)) &&
(argc == (c->maxargs - 1))))) {
return CMD_RET_USAGE;
}
@@ -233,7 +236,14 @@ static int do_pca953x(struct cmd_tbl *cmdtp, int flag, int argc,
if (ret)
ret = CMD_RET_FAILURE;
break;
+ case PCA953X_CMD_BUS:
+ if (argc == 3)
+ i2c_set_bus_num((uint8_t)ul_arg2);
+ bus = i2c_get_bus_num();
+ printf("Current i2c bus: 0x%x\n", bus);
+ ret = CMD_RET_SUCCESS;
+ break;
case PCA953X_CMD_DEVICE:
if (argc == 3)
chip = (uint8_t)ul_arg2;
@@ -280,6 +290,8 @@ static int do_pca953x(struct cmd_tbl *cmdtp, int flag, int argc,
U_BOOT_CMD(
pca953x, 5, 1, do_pca953x,
"pca953x gpio access",
+ "bus [num]\n"
+ " - show or set current i2c bus\n"
"device [dev]\n"
" - show or set current device address\n"
"pca953x info\n"
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] gpio: pca953x: add bus option to select the i2c bus.
2020-12-08 7:32 [PATCH] gpio: pca953x: add bus option to select the i2c bus Joseph Liu
@ 2020-12-12 15:39 ` Simon Glass
2020-12-12 18:51 ` Chris Packham
0 siblings, 1 reply; 5+ messages in thread
From: Simon Glass @ 2020-12-12 15:39 UTC (permalink / raw)
To: u-boot
Hi Joseph,
On Tue, 8 Dec 2020 at 00:32, Joseph Liu <maxdog988@gmail.com> wrote:
>
> From: Joseph Liu <kwliu@nuvoton.com>
>
> If DM_I2C is used, the command "i2c dev" will not reassign
> gd->cur_i2c_bus.
>
> Add this bus option to change the active I2C bus.
>
> Signed-off-by: Joseph Liu <kwliu@nuvoton.com>
> ---
> drivers/gpio/pca953x.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
This driver should be converted to driver model.
Regards,
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] gpio: pca953x: add bus option to select the i2c bus.
2020-12-12 15:39 ` Simon Glass
@ 2020-12-12 18:51 ` Chris Packham
2020-12-14 15:49 ` Simon Glass
0 siblings, 1 reply; 5+ messages in thread
From: Chris Packham @ 2020-12-12 18:51 UTC (permalink / raw)
To: u-boot
On Sun, 13 Dec 2020, 4:44 AM Simon Glass, <sjg@chromium.org> wrote:
> Hi Joseph,
>
> On Tue, 8 Dec 2020 at 00:32, Joseph Liu <maxdog988@gmail.com> wrote:
> >
> > From: Joseph Liu <kwliu@nuvoton.com>
> >
> > If DM_I2C is used, the command "i2c dev" will not reassign
> > gd->cur_i2c_bus.
> >
> > Add this bus option to change the active I2C bus.
> >
> > Signed-off-by: Joseph Liu <kwliu@nuvoton.com>
> > ---
> > drivers/gpio/pca953x.c | 14 +++++++++++++-
> > 1 file changed, 13 insertions(+), 1 deletion(-)
> >
>
> This driver should be converted to driver model.
>
It has been. See drivers/gpio/pca953x_gpio.c
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] gpio: pca953x: add bus option to select the i2c bus.
2020-12-12 18:51 ` Chris Packham
@ 2020-12-14 15:49 ` Simon Glass
2020-12-15 7:31 ` Chris Packham
0 siblings, 1 reply; 5+ messages in thread
From: Simon Glass @ 2020-12-14 15:49 UTC (permalink / raw)
To: u-boot
Hi Chris,
On Sat, 12 Dec 2020 at 11:51, Chris Packham <judge.packham@gmail.com> wrote:
>
>
>
> On Sun, 13 Dec 2020, 4:44 AM Simon Glass, <sjg@chromium.org> wrote:
>>
>> Hi Joseph,
>>
>> On Tue, 8 Dec 2020 at 00:32, Joseph Liu <maxdog988@gmail.com> wrote:
>> >
>> > From: Joseph Liu <kwliu@nuvoton.com>
>> >
>> > If DM_I2C is used, the command "i2c dev" will not reassign
>> > gd->cur_i2c_bus.
>> >
>> > Add this bus option to change the active I2C bus.
>> >
>> > Signed-off-by: Joseph Liu <kwliu@nuvoton.com>
>> > ---
>> > drivers/gpio/pca953x.c | 14 +++++++++++++-
>> > 1 file changed, 13 insertions(+), 1 deletion(-)
>> >
>>
>> This driver should be converted to driver model.
>
>
> It has been. See drivers/gpio/pca953x_gpio.c
I mean that it should use dm_i2c_read() instead of i2c_read(), so that
the problems of an 'active' i2c bus go away. Also it should use
devicetree.
Regards,
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] gpio: pca953x: add bus option to select the i2c bus.
2020-12-14 15:49 ` Simon Glass
@ 2020-12-15 7:31 ` Chris Packham
0 siblings, 0 replies; 5+ messages in thread
From: Chris Packham @ 2020-12-15 7:31 UTC (permalink / raw)
To: u-boot
On Tue, Dec 15, 2020 at 4:49 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Chris,
>
> On Sat, 12 Dec 2020 at 11:51, Chris Packham <judge.packham@gmail.com> wrote:
> >
> >
> >
> > On Sun, 13 Dec 2020, 4:44 AM Simon Glass, <sjg@chromium.org> wrote:
> >>
> >> Hi Joseph,
> >>
> >> On Tue, 8 Dec 2020 at 00:32, Joseph Liu <maxdog988@gmail.com> wrote:
> >> >
> >> > From: Joseph Liu <kwliu@nuvoton.com>
> >> >
> >> > If DM_I2C is used, the command "i2c dev" will not reassign
> >> > gd->cur_i2c_bus.
> >> >
> >> > Add this bus option to change the active I2C bus.
> >> >
> >> > Signed-off-by: Joseph Liu <kwliu@nuvoton.com>
> >> > ---
> >> > drivers/gpio/pca953x.c | 14 +++++++++++++-
> >> > 1 file changed, 13 insertions(+), 1 deletion(-)
> >> >
> >>
> >> This driver should be converted to driver model.
> >
> >
> > It has been. See drivers/gpio/pca953x_gpio.c
>
> I mean that it should use dm_i2c_read() instead of i2c_read(), so that
> the problems of an 'active' i2c bus go away. Also it should use
> devicetree.
That's what I'm saying, the pca953x_gpio.c is the DM version of the
pca953x.c driver. So the boards should be migrating to using the DM
driver and "gpio" commands instead of the old non-DM driver and
"pca953x" commands (not that my opinion counts for anything).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-12-15 7:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 7:32 [PATCH] gpio: pca953x: add bus option to select the i2c bus Joseph Liu
2020-12-12 15:39 ` Simon Glass
2020-12-12 18:51 ` Chris Packham
2020-12-14 15:49 ` Simon Glass
2020-12-15 7:31 ` Chris Packham
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.