* [PATCH 1/2] i2c: pcf8575: Remove not used members of pcf8575_chip structure
@ 2021-06-07 12:26 Lukasz Majewski
2021-06-07 12:26 ` [PATCH 2/2] i2c: pcf8575: Add support for 8 bit I2C IO expanders (like pca8574) Lukasz Majewski
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Lukasz Majewski @ 2021-06-07 12:26 UTC (permalink / raw)
To: u-boot; +Cc: Lukasz Majewski, Heiko Schocher, Simon Glass
Those members are not used anymore as ones from gpio_dev_priv
structure (when DM_GPIO support is enabled) are used instead.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
drivers/gpio/pcf8575_gpio.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/gpio/pcf8575_gpio.c b/drivers/gpio/pcf8575_gpio.c
index 359646266c93..bae9695f28b1 100644
--- a/drivers/gpio/pcf8575_gpio.c
+++ b/drivers/gpio/pcf8575_gpio.c
@@ -34,8 +34,6 @@
DECLARE_GLOBAL_DATA_PTR;
struct pcf8575_chip {
- int gpio_count; /* No. GPIOs supported by the chip */
-
/* NOTE: these chips have strange "quasi-bidirectional" I/O pins.
* We can't actually know whether a pin is configured (a) as output
* and driving the signal low, or (b) as input and reporting a low
@@ -49,7 +47,6 @@ struct pcf8575_chip {
* reset state. Otherwise it flags pins to be driven low.
*/
unsigned int out; /* software latch */
- const char *bank_name; /* Name of the expander bank */
};
/* Read/Write to 16-bit I/O expander */
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] i2c: pcf8575: Add support for 8 bit I2C IO expanders (like pca8574)
2021-06-07 12:26 [PATCH 1/2] i2c: pcf8575: Remove not used members of pcf8575_chip structure Lukasz Majewski
@ 2021-06-07 12:26 ` Lukasz Majewski
2021-06-19 8:37 ` Heiko Schocher
2021-07-23 12:34 ` Tom Rini
2021-06-19 8:36 ` [PATCH 1/2] i2c: pcf8575: Remove not used members of pcf8575_chip structure Heiko Schocher
2021-07-23 12:34 ` Tom Rini
2 siblings, 2 replies; 6+ messages in thread
From: Lukasz Majewski @ 2021-06-07 12:26 UTC (permalink / raw)
To: u-boot; +Cc: Lukasz Majewski, Heiko Schocher, Simon Glass
This patch add support for using NXP's pca8574 I2C IO expander, which
has only 8 IO lines.
After this change the .data member's information from struct udevice_id
are used to either sent one or two bytes.
Moreover, the '_le16' suffix from pcf8575_i2c_{write|read}_le16()
functions have been removed as now we also sent 8 bit data.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
drivers/gpio/pcf8575_gpio.c | 40 ++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/drivers/gpio/pcf8575_gpio.c b/drivers/gpio/pcf8575_gpio.c
index bae9695f28b1..d5930d941fc0 100644
--- a/drivers/gpio/pcf8575_gpio.c
+++ b/drivers/gpio/pcf8575_gpio.c
@@ -12,15 +12,9 @@
*
* Copyright (C) 2007 David Brownell
*
- */
-
-/*
- * NOTE: The driver and devicetree bindings are borrowed from Linux
- * Kernel, but driver does not support all PCF857x devices. It currently
- * supports PCF8575 16-bit expander by TI and NXP.
+ * Add support for 8 bit expanders - like pca8574
+ * Copyright (C) 2021 Lukasz Majewski - DENX Software Engineering
*
- * TODO(vigneshr@ti.com):
- * Support 8 bit PCF857x compatible expanders.
*/
#include <common.h>
@@ -49,15 +43,15 @@ struct pcf8575_chip {
unsigned int out; /* software latch */
};
-/* Read/Write to 16-bit I/O expander */
+/* Read/Write to I/O expander */
-static int pcf8575_i2c_write_le16(struct udevice *dev, unsigned int word)
+static int pcf8575_i2c_write(struct udevice *dev, unsigned int word)
{
struct dm_i2c_chip *chip = dev_get_parent_plat(dev);
u8 buf[2] = { word & 0xff, word >> 8, };
int ret;
- ret = dm_i2c_write(dev, 0, buf, 2);
+ ret = dm_i2c_write(dev, 0, buf, dev_get_driver_data(dev));
if (ret)
printf("%s i2c write failed to addr %x\n", __func__,
chip->chip_addr);
@@ -65,13 +59,13 @@ static int pcf8575_i2c_write_le16(struct udevice *dev, unsigned int word)
return ret;
}
-static int pcf8575_i2c_read_le16(struct udevice *dev)
+static int pcf8575_i2c_read(struct udevice *dev)
{
struct dm_i2c_chip *chip = dev_get_parent_plat(dev);
- u8 buf[2];
+ u8 buf[2] = {0x00, 0x00};
int ret;
- ret = dm_i2c_read(dev, 0, buf, 2);
+ ret = dm_i2c_read(dev, 0, buf, dev_get_driver_data(dev));
if (ret) {
printf("%s i2c read failed from addr %x\n", __func__,
chip->chip_addr);
@@ -87,7 +81,7 @@ static int pcf8575_direction_input(struct udevice *dev, unsigned offset)
int status;
plat->out |= BIT(offset);
- status = pcf8575_i2c_write_le16(dev, plat->out);
+ status = pcf8575_i2c_write(dev, plat->out);
return status;
}
@@ -103,7 +97,7 @@ static int pcf8575_direction_output(struct udevice *dev,
else
plat->out &= ~BIT(offset);
- ret = pcf8575_i2c_write_le16(dev, plat->out);
+ ret = pcf8575_i2c_write(dev, plat->out);
return ret;
}
@@ -112,7 +106,7 @@ static int pcf8575_get_value(struct udevice *dev, unsigned int offset)
{
int value;
- value = pcf8575_i2c_read_le16(dev);
+ value = pcf8575_i2c_read(dev);
return (value < 0) ? value : ((value & BIT(offset)) >> offset);
}
@@ -130,8 +124,11 @@ static int pcf8575_ofdata_plat(struct udevice *dev)
int n_latch;
- uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
- "gpio-count", 16);
+ /*
+ * Number of pins depends on the expander device and is specified
+ * in the struct udevice_id (as in the Linue kernel).
+ */
+ uc_priv->gpio_count = dev_get_driver_data(dev) * 8;
uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
"gpio-bank-name", NULL);
if (!uc_priv->bank_name)
@@ -163,8 +160,9 @@ static const struct dm_gpio_ops pcf8575_gpio_ops = {
};
static const struct udevice_id pcf8575_gpio_ids[] = {
- { .compatible = "nxp,pcf8575" },
- { .compatible = "ti,pcf8575" },
+ { .compatible = "nxp,pcf8575", .data = 2 },
+ { .compatible = "ti,pcf8575", .data = 2 },
+ { .compatible = "nxp,pca8574", .data = 1 },
{ }
};
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] i2c: pcf8575: Remove not used members of pcf8575_chip structure
2021-06-07 12:26 [PATCH 1/2] i2c: pcf8575: Remove not used members of pcf8575_chip structure Lukasz Majewski
2021-06-07 12:26 ` [PATCH 2/2] i2c: pcf8575: Add support for 8 bit I2C IO expanders (like pca8574) Lukasz Majewski
@ 2021-06-19 8:36 ` Heiko Schocher
2021-07-23 12:34 ` Tom Rini
2 siblings, 0 replies; 6+ messages in thread
From: Heiko Schocher @ 2021-06-19 8:36 UTC (permalink / raw)
To: Lukasz Majewski, u-boot; +Cc: Simon Glass
Hello Lukasz,
On 07.06.21 14:26, Lukasz Majewski wrote:
> Those members are not used anymore as ones from gpio_dev_priv
> structure (when DM_GPIO support is enabled) are used instead.
>
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> ---
>
> drivers/gpio/pcf8575_gpio.c | 3 ---
> 1 file changed, 3 deletions(-)
Reviewed-by: Heiko Schocher <hs@denx.de>
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: hs@denx.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] i2c: pcf8575: Add support for 8 bit I2C IO expanders (like pca8574)
2021-06-07 12:26 ` [PATCH 2/2] i2c: pcf8575: Add support for 8 bit I2C IO expanders (like pca8574) Lukasz Majewski
@ 2021-06-19 8:37 ` Heiko Schocher
2021-07-23 12:34 ` Tom Rini
1 sibling, 0 replies; 6+ messages in thread
From: Heiko Schocher @ 2021-06-19 8:37 UTC (permalink / raw)
To: Lukasz Majewski, u-boot; +Cc: Simon Glass
Hello Lukasz,
On 07.06.21 14:26, Lukasz Majewski wrote:
> This patch add support for using NXP's pca8574 I2C IO expander, which
> has only 8 IO lines.
>
> After this change the .data member's information from struct udevice_id
> are used to either sent one or two bytes.
>
> Moreover, the '_le16' suffix from pcf8575_i2c_{write|read}_le16()
> functions have been removed as now we also sent 8 bit data.
>
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
>
> ---
>
> drivers/gpio/pcf8575_gpio.c | 40 ++++++++++++++++++-------------------
> 1 file changed, 19 insertions(+), 21 deletions(-)
Reviewed-by: Heiko Schocher <hs@denx.de>
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: hs@denx.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] i2c: pcf8575: Remove not used members of pcf8575_chip structure
2021-06-07 12:26 [PATCH 1/2] i2c: pcf8575: Remove not used members of pcf8575_chip structure Lukasz Majewski
2021-06-07 12:26 ` [PATCH 2/2] i2c: pcf8575: Add support for 8 bit I2C IO expanders (like pca8574) Lukasz Majewski
2021-06-19 8:36 ` [PATCH 1/2] i2c: pcf8575: Remove not used members of pcf8575_chip structure Heiko Schocher
@ 2021-07-23 12:34 ` Tom Rini
2 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2021-07-23 12:34 UTC (permalink / raw)
To: Lukasz Majewski; +Cc: u-boot, Heiko Schocher, Simon Glass
[-- Attachment #1: Type: text/plain, Size: 345 bytes --]
On Mon, Jun 07, 2021 at 02:26:33PM +0200, Lukasz Majewski wrote:
> Those members are not used anymore as ones from gpio_dev_priv
> structure (when DM_GPIO support is enabled) are used instead.
>
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] i2c: pcf8575: Add support for 8 bit I2C IO expanders (like pca8574)
2021-06-07 12:26 ` [PATCH 2/2] i2c: pcf8575: Add support for 8 bit I2C IO expanders (like pca8574) Lukasz Majewski
2021-06-19 8:37 ` Heiko Schocher
@ 2021-07-23 12:34 ` Tom Rini
1 sibling, 0 replies; 6+ messages in thread
From: Tom Rini @ 2021-07-23 12:34 UTC (permalink / raw)
To: Lukasz Majewski; +Cc: u-boot, Heiko Schocher, Simon Glass
[-- Attachment #1: Type: text/plain, Size: 572 bytes --]
On Mon, Jun 07, 2021 at 02:26:34PM +0200, Lukasz Majewski wrote:
> This patch add support for using NXP's pca8574 I2C IO expander, which
> has only 8 IO lines.
>
> After this change the .data member's information from struct udevice_id
> are used to either sent one or two bytes.
>
> Moreover, the '_le16' suffix from pcf8575_i2c_{write|read}_le16()
> functions have been removed as now we also sent 8 bit data.
>
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-07-23 12:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07 12:26 [PATCH 1/2] i2c: pcf8575: Remove not used members of pcf8575_chip structure Lukasz Majewski
2021-06-07 12:26 ` [PATCH 2/2] i2c: pcf8575: Add support for 8 bit I2C IO expanders (like pca8574) Lukasz Majewski
2021-06-19 8:37 ` Heiko Schocher
2021-07-23 12:34 ` Tom Rini
2021-06-19 8:36 ` [PATCH 1/2] i2c: pcf8575: Remove not used members of pcf8575_chip structure Heiko Schocher
2021-07-23 12:34 ` Tom Rini
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.