gpio: dwapb_gpio: convert to livetree
Convert 'gpio_dwapb_bind' to iterate over subnodes using livetree functions (inspired from mt7621_gpio.c). Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
This commit is contained in:
		
							parent
							
								
									6cdd0a4e54
								
							
						
					
					
						commit
						1b898ffc04
					
				|  | @ -17,8 +17,6 @@ | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
| #include <reset.h> | #include <reset.h> | ||||||
| 
 | 
 | ||||||
| DECLARE_GLOBAL_DATA_PTR; |  | ||||||
| 
 |  | ||||||
| #define GPIO_SWPORT_DR(p)	(0x00 + (p) * 0xc) | #define GPIO_SWPORT_DR(p)	(0x00 + (p) * 0xc) | ||||||
| #define GPIO_SWPORT_DDR(p)	(0x04 + (p) * 0xc) | #define GPIO_SWPORT_DDR(p)	(0x04 + (p) * 0xc) | ||||||
| #define GPIO_INTEN		0x30 | #define GPIO_INTEN		0x30 | ||||||
|  | @ -150,10 +148,10 @@ static int gpio_dwapb_probe(struct udevice *dev) | ||||||
| static int gpio_dwapb_bind(struct udevice *dev) | static int gpio_dwapb_bind(struct udevice *dev) | ||||||
| { | { | ||||||
| 	struct gpio_dwapb_platdata *plat = dev_get_platdata(dev); | 	struct gpio_dwapb_platdata *plat = dev_get_platdata(dev); | ||||||
| 	const void *blob = gd->fdt_blob; |  | ||||||
| 	struct udevice *subdev; | 	struct udevice *subdev; | ||||||
| 	fdt_addr_t base; | 	fdt_addr_t base; | ||||||
| 	int ret, node, bank = 0; | 	int ret, bank = 0; | ||||||
|  | 	ofnode node; | ||||||
| 
 | 
 | ||||||
| 	/* If this is a child device, there is nothing to do here */ | 	/* If this is a child device, there is nothing to do here */ | ||||||
| 	if (plat) | 	if (plat) | ||||||
|  | @ -165,10 +163,9 @@ static int gpio_dwapb_bind(struct udevice *dev) | ||||||
| 		return -ENXIO; | 		return -ENXIO; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	for (node = fdt_first_subnode(blob, dev_of_offset(dev)); | 	for (node = dev_read_first_subnode(dev); ofnode_valid(node); | ||||||
| 	     node > 0; | 	     node = dev_read_next_subnode(node)) { | ||||||
| 	     node = fdt_next_subnode(blob, node)) { | 		if (!ofnode_read_bool(node, "gpio-controller")) | ||||||
| 		if (!fdtdec_get_bool(blob, node, "gpio-controller")) |  | ||||||
| 			continue; | 			continue; | ||||||
| 
 | 
 | ||||||
| 		plat = devm_kcalloc(dev, 1, sizeof(*plat), GFP_KERNEL); | 		plat = devm_kcalloc(dev, 1, sizeof(*plat), GFP_KERNEL); | ||||||
|  | @ -177,15 +174,15 @@ static int gpio_dwapb_bind(struct udevice *dev) | ||||||
| 
 | 
 | ||||||
| 		plat->base = base; | 		plat->base = base; | ||||||
| 		plat->bank = bank; | 		plat->bank = bank; | ||||||
| 		plat->pins = fdtdec_get_int(blob, node, "snps,nr-gpios", 0); | 		plat->pins = ofnode_read_u32_default(node, "snps,nr-gpios", 0); | ||||||
| 		plat->name = fdt_stringlist_get(blob, node, "bank-name", 0, | 
 | ||||||
| 						NULL); | 		if (ofnode_read_string_index(node, "bank-name", 0, | ||||||
| 		if (!plat->name) { | 					     &plat->name)) { | ||||||
| 			/*
 | 			/*
 | ||||||
| 			 * Fall back to node name. This means accessing pins | 			 * Fall back to node name. This means accessing pins | ||||||
| 			 * via bank name won't work. | 			 * via bank name won't work. | ||||||
| 			 */ | 			 */ | ||||||
| 			plat->name = fdt_get_name(blob, node, NULL); | 			plat->name = ofnode_get_name(node); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		ret = device_bind(dev, dev->driver, plat->name, | 		ret = device_bind(dev, dev->driver, plat->name, | ||||||
|  | @ -193,7 +190,7 @@ static int gpio_dwapb_bind(struct udevice *dev) | ||||||
| 		if (ret) | 		if (ret) | ||||||
| 			return ret; | 			return ret; | ||||||
| 
 | 
 | ||||||
| 		dev_set_of_offset(subdev, node); | 		dev->node = node; | ||||||
| 		bank++; | 		bank++; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue