[U-Boot] [PATCH 1/2] sunxi: gpio: Add .xlate function for gpio phandle resolution

sunxi uses a 2 cell phandle for gpio bindings. Also there are no seperate nodes for each pin bank.
Add a custom .xlate function to map gpio phandles to the correct pin bank device. This fixes gpio_request_by_name usage.
Fixes: 7aa974858422 ("dm: sunxi: Modify the GPIO driver to support driver model") Signed-off-by: Chen-Yu Tsai wens@csie.org --- drivers/gpio/sunxi_gpio.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c index 94abbeb39adc..e8accaa33302 100644 --- a/drivers/gpio/sunxi_gpio.c +++ b/drivers/gpio/sunxi_gpio.c @@ -19,6 +19,7 @@ #include <asm/io.h> #include <asm/gpio.h> #include <dm/device-internal.h> +#include <dt-bindings/gpio/gpio.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -215,12 +216,27 @@ static int sunxi_gpio_get_function(struct udevice *dev, unsigned offset) return GPIOF_FUNC; }
+static int sunxi_gpio_xlate(struct udevice *dev, struct gpio_desc *desc, + struct fdtdec_phandle_args *args) +{ + int ret; + + ret = device_get_child(dev, args->args[0], &desc->dev); + if (ret) + return ret; + desc->offset = args->args[1]; + desc->flags = args->args[2] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0; + + return 0; +} + static const struct dm_gpio_ops gpio_sunxi_ops = { .direction_input = sunxi_gpio_direction_input, .direction_output = sunxi_gpio_direction_output, .get_value = sunxi_gpio_get_value, .set_value = sunxi_gpio_set_value, .get_function = sunxi_gpio_get_function, + .xlate = sunxi_gpio_xlate, };
/**

MACPWR was used to bring the Ethernet PHY out of reset. The designware driver now supports the phy reset gpio binding, so this is no longer needed. In fact in requesting the same GPIO, it makes the designware driver fail to probe.
Signed-off-by: Chen-Yu Tsai wens@csie.org --- configs/Hummingbird_A31_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/Hummingbird_A31_defconfig b/configs/Hummingbird_A31_defconfig index 02bcdbf56af5..3b0c439c4f79 100644 --- a/configs/Hummingbird_A31_defconfig +++ b/configs/Hummingbird_A31_defconfig @@ -9,7 +9,7 @@ CONFIG_VIDEO_VGA_EXTERNAL_DAC_EN="PH25" CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31-hummingbird" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set CONFIG_SPL=y -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPA(21)" +CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII" # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set # CONFIG_CMD_FPGA is not set
participants (1)
-
Chen-Yu Tsai