X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Fgpio%2Fbcm2835_gpio.c;h=f4b67f1cf0aff523a19bcaf6bcf64833f0c1abca;hb=abdbefba2a4e9666f798de13b4b88021f23b19f3;hp=cd5480ee0940f1ea1443217fbae1e7a8ceed283b;hpb=4faf5f93c61632c18e435dc6a190b30893786a10;p=oweals%2Fu-boot.git diff --git a/drivers/gpio/bcm2835_gpio.c b/drivers/gpio/bcm2835_gpio.c index cd5480ee09..f4b67f1cf0 100644 --- a/drivers/gpio/bcm2835_gpio.c +++ b/drivers/gpio/bcm2835_gpio.c @@ -1,12 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2012 Vikram Narayananan * - * - * SPDX-License-Identifier: GPL-2.0+ */ #include #include +#include #include #include #include @@ -14,6 +14,7 @@ struct bcm2835_gpios { struct bcm2835_gpio_regs *reg; + struct udevice *pinctrl; }; static int bcm2835_gpio_direction_input(struct udevice *dev, unsigned gpio) @@ -29,7 +30,7 @@ static int bcm2835_gpio_direction_input(struct udevice *dev, unsigned gpio) return 0; } -static int bcm2835_gpio_direction_output(struct udevice *dev, unsigned gpio, +static int bcm2835_gpio_direction_output(struct udevice *dev, unsigned int gpio, int value) { struct bcm2835_gpios *gpios = dev_get_priv(dev); @@ -73,19 +74,12 @@ static int bcm2835_gpio_set_value(struct udevice *dev, unsigned gpio, return 0; } -int bcm2835_gpio_get_func_id(struct udevice *dev, unsigned gpio) -{ - struct bcm2835_gpios *gpios = dev_get_priv(dev); - u32 val; - - val = readl(&gpios->reg->gpfsel[BCM2835_GPIO_FSEL_BANK(gpio)]); - - return (val >> BCM2835_GPIO_FSEL_SHIFT(gpio) & BCM2835_GPIO_FSEL_MASK); -} - static int bcm2835_gpio_get_function(struct udevice *dev, unsigned offset) { - int funcid = bcm2835_gpio_get_func_id(dev, offset); + struct bcm2835_gpios *priv = dev_get_priv(dev); + int funcid; + + funcid = pinctrl_get_gpio_mux(priv->pinctrl, 0, offset); switch (funcid) { case BCM2835_GPIO_OUTPUT: @@ -97,7 +91,6 @@ static int bcm2835_gpio_get_function(struct udevice *dev, unsigned offset) } } - static const struct dm_gpio_ops gpio_bcm2835_ops = { .direction_input = bcm2835_gpio_direction_input, .direction_output = bcm2835_gpio_direction_output, @@ -116,21 +109,19 @@ static int bcm2835_gpio_probe(struct udevice *dev) uc_priv->gpio_count = BCM2835_GPIO_COUNT; gpios->reg = (struct bcm2835_gpio_regs *)plat->base; + /* We know we're spawned by the pinctrl driver */ + gpios->pinctrl = dev->parent; + return 0; } #if CONFIG_IS_ENABLED(OF_CONTROL) -static const struct udevice_id bcm2835_gpio_id[] = { - {.compatible = "brcm,bcm2835-gpio"}, - {} -}; - static int bcm2835_gpio_ofdata_to_platdata(struct udevice *dev) { struct bcm2835_gpio_platdata *plat = dev_get_platdata(dev); fdt_addr_t addr; - addr = dev_get_addr(dev); + addr = devfdt_get_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; @@ -142,7 +133,6 @@ static int bcm2835_gpio_ofdata_to_platdata(struct udevice *dev) U_BOOT_DRIVER(gpio_bcm2835) = { .name = "gpio_bcm2835", .id = UCLASS_GPIO, - .of_match = of_match_ptr(bcm2835_gpio_id), .ofdata_to_platdata = of_match_ptr(bcm2835_gpio_ofdata_to_platdata), .platdata_auto_alloc_size = sizeof(struct bcm2835_gpio_platdata), .ops = &gpio_bcm2835_ops,