[U-Boot] [PATCH 02/13] dm: pinctrl: convert pinctrl-single to livetree

Patrick Delaunay patrick.delaunay at st.com
Wed Oct 23 13:44:37 UTC 2019


Convert 'pinctrl-single' using livetree functions
- ofnode_get_property
- ofnode_read_u32_default
- ofnode_read_u32_array
- ofnode_read_bool
- dev_read_addr
and get rid of DECLARE_GLOBAL_DATA_PTR.

Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
---

 drivers/pinctrl/pinctrl-single.c | 33 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 1dfc97dcea..67429d6995 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -9,8 +9,6 @@
 #include <linux/libfdt.h>
 #include <asm/io.h>
 
-DECLARE_GLOBAL_DATA_PTR;
-
 struct single_pdata {
 	fdt_addr_t base;	/* first configuration register */
 	int offset;		/* index of last configuration register */
@@ -117,13 +115,12 @@ static int single_configure_bits(struct udevice *dev,
 static int single_set_state(struct udevice *dev,
 			    struct udevice *config)
 {
-	const void *fdt = gd->fdt_blob;
 	const struct single_fdt_pin_cfg *prop;
 	const struct single_fdt_bits_cfg *prop_bits;
 	int len;
 
-	prop = fdt_getprop(fdt, dev_of_offset(config), "pinctrl-single,pins",
-			   &len);
+	prop = ofnode_get_property(dev_ofnode(dev), "pinctrl-single,pins",
+				   &len);
 
 	if (prop) {
 		dev_dbg(dev, "configuring pins for %s\n", config->name);
@@ -136,9 +133,9 @@ static int single_set_state(struct udevice *dev,
 	}
 
 	/* pinctrl-single,pins not found so check for pinctrl-single,bits */
-	prop_bits = fdt_getprop(fdt, dev_of_offset(config),
-				"pinctrl-single,bits",
-				    &len);
+	prop_bits = ofnode_get_property(dev_ofnode(dev),
+					"pinctrl-single,bits",
+					&len);
 	if (prop_bits) {
 		dev_dbg(dev, "configuring pins for %s\n", config->name);
 		if (len % sizeof(struct single_fdt_bits_cfg)) {
@@ -160,27 +157,27 @@ static int single_ofdata_to_platdata(struct udevice *dev)
 	int res;
 	struct single_pdata *pdata = dev->platdata;
 
-	pdata->width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
-				      "pinctrl-single,register-width", 0);
+	pdata->width = ofnode_read_u32_default(dev_ofnode(dev),
+					       "pinctrl-single,register-width",
+					       0);
 
-	res = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
-				   "reg", of_reg, 2);
+	res = ofnode_read_u32_array(dev_ofnode(dev), "reg", of_reg, 2);
 	if (res)
 		return res;
 	pdata->offset = of_reg[1] - pdata->width / 8;
 
-	addr = devfdt_get_addr(dev);
+	addr = dev_read_addr(dev);
 	if (addr == FDT_ADDR_T_NONE) {
 		dev_dbg(dev, "no valid base register address\n");
 		return -EINVAL;
 	}
 	pdata->base = addr;
 
-	pdata->mask = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
-				     "pinctrl-single,function-mask",
-				     0xffffffff);
-	pdata->bits_per_mux = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
-					      "pinctrl-single,bit-per-mux");
+	pdata->mask = ofnode_read_u32_default(dev_ofnode(dev),
+					      "pinctrl-single,function-mask",
+					      0xffffffff);
+	pdata->bits_per_mux = ofnode_read_bool(dev_ofnode(dev),
+					       "pinctrl-single,bit-per-mux");
 
 	return 0;
 }
-- 
2.17.1



More information about the U-Boot mailing list