diff options
Diffstat (limited to 'drivers/gpio')
| -rw-r--r-- | drivers/gpio/da8xx_gpio.c | 35 | ||||
| -rw-r--r-- | drivers/gpio/omap_gpio.c | 11 |
2 files changed, 33 insertions, 13 deletions
diff --git a/drivers/gpio/da8xx_gpio.c b/drivers/gpio/da8xx_gpio.c index 1a1d37ae2a4..b0d49cb46f0 100644 --- a/drivers/gpio/da8xx_gpio.c +++ b/drivers/gpio/da8xx_gpio.c @@ -13,6 +13,7 @@ #include <asm/gpio.h> #include <asm/arch/hardware.h> #include <asm/arch/davinci_misc.h> +#include <dt-bindings/gpio/gpio.h> #ifndef CONFIG_DM_GPIO static struct gpio_registry { @@ -429,20 +430,27 @@ int gpio_set_value(unsigned int gpio, int value) static struct davinci_gpio *davinci_get_gpio_bank(struct udevice *dev, unsigned int offset) { struct davinci_gpio_bank *bank = dev_get_priv(dev); + unsigned int addr; - /* The device tree is not broken into banks but the infrastructure is + /* + * The device tree is not broken into banks but the infrastructure is * expecting it this way, so we'll first include the 0x10 offset, then * calculate the bank manually based on the offset. + * Casting 'addr' as Unsigned long is needed to make the math work. */ - - return ((struct davinci_gpio *)bank->base) + 0x10 + (offset >> 5); + addr = ((unsigned long)(struct davinci_gpio *)bank->base) + + 0x10 + (0x28 * (offset >> 5)); + return (struct davinci_gpio *)addr; } static int davinci_gpio_direction_input(struct udevice *dev, unsigned int offset) { struct davinci_gpio *base = davinci_get_gpio_bank(dev, offset); - _gpio_direction_input(base, offset); + /* + * Fetch the address based on GPIO, but only pass the masked low 32-bits + */ + _gpio_direction_input(base, (offset & 0x1f)); return 0; } @@ -451,7 +459,7 @@ static int davinci_gpio_direction_output(struct udevice *dev, unsigned int offse { struct davinci_gpio *base = davinci_get_gpio_bank(dev, offset); - _gpio_direction_output(base, offset, value); + _gpio_direction_output(base, (offset & 0x1f), value); return 0; } @@ -459,7 +467,7 @@ static int davinci_gpio_get_value(struct udevice *dev, unsigned int offset) { struct davinci_gpio *base = davinci_get_gpio_bank(dev, offset); - return _gpio_get_value(base, offset); + return _gpio_get_value(base, (offset & 0x1f)); } static int davinci_gpio_set_value(struct udevice *dev, unsigned int offset, @@ -467,7 +475,7 @@ static int davinci_gpio_set_value(struct udevice *dev, unsigned int offset, { struct davinci_gpio *base = davinci_get_gpio_bank(dev, offset); - _gpio_set_value(base, offset, value); + _gpio_set_value(base, (offset & 0x1f), value); return 0; } @@ -485,12 +493,25 @@ static int davinci_gpio_get_function(struct udevice *dev, unsigned int offset) return GPIOF_OUTPUT; } +static int davinci_gpio_xlate(struct udevice *dev, struct gpio_desc *desc, + struct ofnode_phandle_args *args) +{ + desc->offset = args->args[0]; + + if (args->args[1] & GPIO_ACTIVE_LOW) + desc->flags = GPIOD_ACTIVE_LOW; + else + desc->flags = 0; + return 0; +} + static const struct dm_gpio_ops gpio_davinci_ops = { .direction_input = davinci_gpio_direction_input, .direction_output = davinci_gpio_direction_output, .get_value = davinci_gpio_get_value, .set_value = davinci_gpio_set_value, .get_function = davinci_gpio_get_function, + .xlate = davinci_gpio_xlate, }; static int davinci_gpio_probe(struct udevice *dev) diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c index 651f6994e41..555eba26622 100644 --- a/drivers/gpio/omap_gpio.c +++ b/drivers/gpio/omap_gpio.c @@ -288,11 +288,9 @@ static int omap_gpio_probe(struct udevice *dev) struct gpio_bank *bank = dev_get_priv(dev); struct omap_gpio_platdata *plat = dev_get_platdata(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - int banknum; char name[18], *str; - banknum = plat->bank_index; - sprintf(name, "GPIO%d_", banknum + 1); + sprintf(name, "gpio@%4x_", (unsigned int)plat->base); str = strdup(name); if (!str) return -ENOMEM; @@ -337,6 +335,7 @@ static int omap_gpio_bind(struct udevice *dev) } #endif +#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id omap_gpio_ids[] = { { .compatible = "ti,omap3-gpio" }, { .compatible = "ti,omap4-gpio" }, @@ -344,7 +343,6 @@ static const struct udevice_id omap_gpio_ids[] = { { } }; -#if CONFIG_IS_ENABLED(OF_CONTROL) static int omap_gpio_ofdata_to_platdata(struct udevice *dev) { struct omap_gpio_platdata *plat = dev_get_platdata(dev); @@ -363,14 +361,15 @@ U_BOOT_DRIVER(gpio_omap) = { .name = "gpio_omap", .id = UCLASS_GPIO, #if CONFIG_IS_ENABLED(OF_CONTROL) +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + .of_match = omap_gpio_ids, .ofdata_to_platdata = of_match_ptr(omap_gpio_ofdata_to_platdata), - .bind = dm_scan_fdt_dev, .platdata_auto_alloc_size = sizeof(struct omap_gpio_platdata), +#endif #else .bind = omap_gpio_bind, #endif .ops = &gpio_omap_ops, - .of_match = omap_gpio_ids, .probe = omap_gpio_probe, .priv_auto_alloc_size = sizeof(struct gpio_bank), .flags = DM_FLAG_PRE_RELOC, |
