All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] misc: i2c_eeprom: support DT pagesize property
@ 2019-04-07  9:38 Baruch Siach
  2019-04-07  9:38 ` [U-Boot] [PATCH 2/2] misc: i2c_eeprom: add eeprom write support Baruch Siach
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Baruch Siach @ 2019-04-07  9:38 UTC (permalink / raw)
  To: u-boot

Read the page size from DT when available.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 drivers/misc/i2c_eeprom.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c
index 29ad87c1d7b4..ce2cad44d8d4 100644
--- a/drivers/misc/i2c_eeprom.c
+++ b/drivers/misc/i2c_eeprom.c
@@ -50,6 +50,12 @@ static int i2c_eeprom_std_ofdata_to_platdata(struct udevice *dev)
 {
 	struct i2c_eeprom *priv = dev_get_priv(dev);
 	u64 data = dev_get_driver_data(dev);
+	u32 pagesize;
+
+	if (dev_read_u32(dev, "pagesize", &pagesize) == 0) {
+		priv->pagesize = pagesize;
+		return 0;
+	}
 
 	/* 6 bit -> page size of up to 2^63 (should be sufficient) */
 	priv->pagewidth = data & 0x3F;
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH 2/2] misc: i2c_eeprom: add eeprom write support
  2019-04-07  9:38 [U-Boot] [PATCH 1/2] misc: i2c_eeprom: support DT pagesize property Baruch Siach
@ 2019-04-07  9:38 ` Baruch Siach
  2019-04-10  5:30   ` Heiko Schocher
  2019-04-10  5:39   ` Heiko Schocher
  2019-04-10  5:25 ` [U-Boot] [PATCH 1/2] misc: i2c_eeprom: support DT pagesize property Heiko Schocher
  2019-04-10  5:39 ` Heiko Schocher
  2 siblings, 2 replies; 6+ messages in thread
From: Baruch Siach @ 2019-04-07  9:38 UTC (permalink / raw)
  To: u-boot

Write up to page size in each i2c transfer.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 drivers/misc/i2c_eeprom.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c
index ce2cad44d8d4..f25d0540075d 100644
--- a/drivers/misc/i2c_eeprom.c
+++ b/drivers/misc/i2c_eeprom.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <linux/err.h>
+#include <linux/kernel.h>
 #include <dm.h>
 #include <i2c.h>
 #include <i2c_eeprom.h>
@@ -38,7 +39,24 @@ static int i2c_eeprom_std_read(struct udevice *dev, int offset, uint8_t *buf,
 static int i2c_eeprom_std_write(struct udevice *dev, int offset,
 				const uint8_t *buf, int size)
 {
-	return -ENODEV;
+	struct i2c_eeprom *priv = dev_get_priv(dev);
+	int ret;
+
+	while (size > 0) {
+		int write_size = min_t(int, size, priv->pagesize);
+
+		ret = dm_i2c_write(dev, offset, buf, write_size);
+		if (ret)
+			return ret;
+
+		offset += write_size;
+		buf += write_size;
+		size -= write_size;
+
+		udelay(10000);
+	}
+
+	return 0;
 }
 
 static const struct i2c_eeprom_ops i2c_eeprom_std_ops = {
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH 1/2] misc: i2c_eeprom: support DT pagesize property
  2019-04-07  9:38 [U-Boot] [PATCH 1/2] misc: i2c_eeprom: support DT pagesize property Baruch Siach
  2019-04-07  9:38 ` [U-Boot] [PATCH 2/2] misc: i2c_eeprom: add eeprom write support Baruch Siach
@ 2019-04-10  5:25 ` Heiko Schocher
  2019-04-10  5:39 ` Heiko Schocher
  2 siblings, 0 replies; 6+ messages in thread
From: Heiko Schocher @ 2019-04-10  5:25 UTC (permalink / raw)
  To: u-boot

Hello Baruch,

Am 07.04.2019 um 11:38 schrieb Baruch Siach:
> Read the page size from DT when available.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>   drivers/misc/i2c_eeprom.c | 6 ++++++
>   1 file changed, 6 insertions(+)

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 at denx.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH 2/2] misc: i2c_eeprom: add eeprom write support
  2019-04-07  9:38 ` [U-Boot] [PATCH 2/2] misc: i2c_eeprom: add eeprom write support Baruch Siach
@ 2019-04-10  5:30   ` Heiko Schocher
  2019-04-10  5:39   ` Heiko Schocher
  1 sibling, 0 replies; 6+ messages in thread
From: Heiko Schocher @ 2019-04-10  5:30 UTC (permalink / raw)
  To: u-boot

Hello Baruch,

Am 07.04.2019 um 11:38 schrieb Baruch Siach:
> Write up to page size in each i2c transfer.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>   drivers/misc/i2c_eeprom.c | 20 +++++++++++++++++++-
>   1 file changed, 19 insertions(+), 1 deletion(-)

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 at denx.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH 1/2] misc: i2c_eeprom: support DT pagesize property
  2019-04-07  9:38 [U-Boot] [PATCH 1/2] misc: i2c_eeprom: support DT pagesize property Baruch Siach
  2019-04-07  9:38 ` [U-Boot] [PATCH 2/2] misc: i2c_eeprom: add eeprom write support Baruch Siach
  2019-04-10  5:25 ` [U-Boot] [PATCH 1/2] misc: i2c_eeprom: support DT pagesize property Heiko Schocher
@ 2019-04-10  5:39 ` Heiko Schocher
  2 siblings, 0 replies; 6+ messages in thread
From: Heiko Schocher @ 2019-04-10  5:39 UTC (permalink / raw)
  To: u-boot

Hello Baruch,

Am 07.04.2019 um 11:38 schrieb Baruch Siach:
> Read the page size from DT when available.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>   drivers/misc/i2c_eeprom.c | 6 ++++++
>   1 file changed, 6 insertions(+)

Applied to u-boot-i2c.git master

Thanks!

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 at denx.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH 2/2] misc: i2c_eeprom: add eeprom write support
  2019-04-07  9:38 ` [U-Boot] [PATCH 2/2] misc: i2c_eeprom: add eeprom write support Baruch Siach
  2019-04-10  5:30   ` Heiko Schocher
@ 2019-04-10  5:39   ` Heiko Schocher
  1 sibling, 0 replies; 6+ messages in thread
From: Heiko Schocher @ 2019-04-10  5:39 UTC (permalink / raw)
  To: u-boot

Hello Baruch,

Am 07.04.2019 um 11:38 schrieb Baruch Siach:
> Write up to page size in each i2c transfer.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>   drivers/misc/i2c_eeprom.c | 20 +++++++++++++++++++-
>   1 file changed, 19 insertions(+), 1 deletion(-)

Applied to u-boot-i2c.git master

Thanks!

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 at denx.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-04-10  5:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-07  9:38 [U-Boot] [PATCH 1/2] misc: i2c_eeprom: support DT pagesize property Baruch Siach
2019-04-07  9:38 ` [U-Boot] [PATCH 2/2] misc: i2c_eeprom: add eeprom write support Baruch Siach
2019-04-10  5:30   ` Heiko Schocher
2019-04-10  5:39   ` Heiko Schocher
2019-04-10  5:25 ` [U-Boot] [PATCH 1/2] misc: i2c_eeprom: support DT pagesize property Heiko Schocher
2019-04-10  5:39 ` Heiko Schocher

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.