X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=drivers%2Fgpio%2Fomap_gpio.c;h=c986ef03805cc817141d7a02d85d8da99942bb34;hb=5575f79bdaa824a90747d5a3d063b5219521b066;hp=79a975ce71b7ef5de446d61ef0cec79daa247e9c;hpb=dc7df68f21093039b3ab1a1702f5b7cd3e621431;p=platform%2Fkernel%2Fu-boot.git diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c index 79a975c..c986ef0 100644 --- a/drivers/gpio/omap_gpio.c +++ b/drivers/gpio/omap_gpio.c @@ -30,7 +30,7 @@ DECLARE_GLOBAL_DATA_PTR; #define OMAP_GPIO_DIR_OUT 0 #define OMAP_GPIO_DIR_IN 1 -#ifdef CONFIG_DM_GPIO +#if CONFIG_IS_ENABLED(DM_GPIO) #define GPIO_PER_BANK 32 @@ -41,11 +41,6 @@ struct gpio_bank { #endif -static inline int get_gpio_index(int gpio) -{ - return gpio & 0x1f; -} - int gpio_is_valid(int gpio) { return (gpio >= 0) && (gpio < OMAP_MAX_GPIO); @@ -121,7 +116,11 @@ static int _get_gpio_value(const struct gpio_bank *bank, int gpio) return (__raw_readl(reg) & (1 << gpio)) != 0; } -#ifndef CONFIG_DM_GPIO +#if !CONFIG_IS_ENABLED(DM_GPIO) +static inline int get_gpio_index(int gpio) +{ + return gpio & 0x1f; +} static inline const struct gpio_bank *get_gpio_bank(int gpio) { @@ -288,11 +287,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; @@ -302,6 +299,7 @@ static int omap_gpio_probe(struct udevice *dev) return 0; } +#if !CONFIG_IS_ENABLED(OF_CONTROL) static int omap_gpio_bind(struct udevice *dev) { struct omap_gpio_platdata *plat = dev_get_platdata(dev); @@ -334,7 +332,9 @@ static int omap_gpio_bind(struct udevice *dev) return 0; } +#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" }, @@ -342,15 +342,38 @@ static const struct udevice_id omap_gpio_ids[] = { { } }; +static int omap_gpio_ofdata_to_platdata(struct udevice *dev) +{ + struct omap_gpio_platdata *plat = dev_get_platdata(dev); + fdt_addr_t addr; + + addr = devfdt_get_addr(dev); + if (addr == FDT_ADDR_T_NONE) + return -EINVAL; + + plat->base = addr; + return 0; +} +#endif + U_BOOT_DRIVER(gpio_omap) = { .name = "gpio_omap", .id = UCLASS_GPIO, - .ops = &gpio_omap_ops, +#if CONFIG_IS_ENABLED(OF_CONTROL) +#if !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = omap_gpio_ids, - .bind = omap_gpio_bind, + .ofdata_to_platdata = of_match_ptr(omap_gpio_ofdata_to_platdata), + .platdata_auto_alloc_size = sizeof(struct omap_gpio_platdata), +#endif +#else + .bind = omap_gpio_bind, +#endif + .ops = &gpio_omap_ops, .probe = omap_gpio_probe, .priv_auto_alloc_size = sizeof(struct gpio_bank), +#if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, +#endif }; -#endif /* CONFIG_DM_GPIO */ +#endif /* !DM_GPIO */