Skip to contentSkip to conversation

i2c: i2c-gpio: Convert to use APIs which support live DT

PATCH New Patrick Delaunay 3 participants 3 messages Sep 10, 2020 – Oct 24, 2020 I2C

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: i2c-gpio: Convert to use APIs which support live DT

Use ofnode_ or dev_ APIs instead of fdt_ and fdtdec_ APIs so that the driver can support live DT.

---

 drivers/i2c/i2c-gpio.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/i2c/i2c-gpio.c +3 -7
index cfdeadc752..381938c956 100644
@@ -18,8 +18,6 @@
 #define I2C_ACK		0
 #define I2C_NOACK	1
 
-DECLARE_GLOBAL_DATA_PTR;
-
 enum {
 	PIN_SDA = 0,
 	PIN_SCL,
@@ -334,8 +332,6 @@ static int i2c_gpio_drv_probe(struct udevice *dev)
 static int i2c_gpio_ofdata_to_platdata(struct udevice *dev)
 {
 	struct i2c_gpio_bus *bus = dev_get_priv(dev);
-	const void *blob = gd->fdt_blob;
-	int node = dev_of_offset(dev);
 	int ret;
 
 	ret = gpio_request_list_by_name(dev, "gpios", bus->gpios,
@@ -343,12 +339,12 @@ static int i2c_gpio_ofdata_to_platdata(struct udevice *dev)
 	if (ret < 0)
 		goto error;
 
-	bus->udelay = fdtdec_get_int(blob, node, "i2c-gpio,delay-us",
-				     DEFAULT_UDELAY);
+	bus->udelay = dev_read_u32_default(dev, "i2c-gpio,delay-us",
+					   DEFAULT_UDELAY);
 
 	bus->get_sda = i2c_gpio_sda_get;
 	bus->set_sda = i2c_gpio_sda_set;
-	if (fdtdec_get_bool(blob, node, "i2c-gpio,scl-output-only"))
+	if (dev_read_bool(dev, "i2c-gpio,scl-output-only"))
 		bus->set_scl = i2c_gpio_scl_set_output_only;
 	else
 		bus->set_scl = i2c_gpio_scl_set;
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 i2c: i2c-gpio: Convert to use APIs which support live DT

Hello Patrick,

Am 10.09.2020 um 18:25 schrieb Patrick Delaunay:

Quoted 8 lines

Use ofnode_ or dev_ APIs instead of fdt_ and fdtdec_ APIs so that the driver can support live DT.

---

  drivers/i2c/i2c-gpio.c | 10 +++-------
  1 file changed, 3 insertions(+), 7 deletions(-)

bye,
Heiko

Signature · 3 lines
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
#2 lore raw

PATCH 1/1 i2c: i2c-gpio: Convert to use APIs which support live DT

In reply to Patrick Delaunay
Quoted 5 lines · Patrick Delaunay

Use ofnode_ or dev_ APIs instead of fdt_ and fdtdec_ APIs so that the driver can support live DT.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201024/83ba47f6/attachment.sig>