diff options
Diffstat (limited to 'drivers/pinctrl/pinctrl-bcm2835.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-bcm2835.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/drivers/pinctrl/pinctrl-bcm2835.c b/drivers/pinctrl/pinctrl-bcm2835.c index b8e9b60372..57c1aee3af 100644 --- a/drivers/pinctrl/pinctrl-bcm2835.c +++ b/drivers/pinctrl/pinctrl-bcm2835.c @@ -1,20 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Author: Carlo Caione <carlo@carlocaione.org> * * GPIO code based on linux/arch/arm/mach-bcm2708/bcm2708_gpio.c * * pinctrl part added by Tomaz Solc <tomaz.solc@tablix.org> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #include <common.h> @@ -52,6 +42,10 @@ struct bcm2835_gpio_chip { struct pinctrl_device pctl; }; +struct plat_data { + unsigned ngpios; +}; + static int bcm2835_set_function(struct gpio_chip *chip, unsigned gpio, int function) { struct bcm2835_gpio_chip *bcmgpio = container_of(chip, struct bcm2835_gpio_chip, chip); @@ -147,12 +141,15 @@ static struct pinctrl_ops bcm2835_pinctrl_ops = { .set_state = bcm2835_pinctrl_set_state, }; -static int bcm2835_gpio_probe(struct device_d *dev) +static int bcm2835_gpio_probe(struct device *dev) { + const struct plat_data *plat_data; struct resource *iores; struct bcm2835_gpio_chip *bcmgpio; int ret; + plat_data = device_get_match_data(dev); + bcmgpio = xzalloc(sizeof(*bcmgpio)); iores = dev_request_mem_resource(dev, 0); if (IS_ERR(iores)) @@ -160,7 +157,8 @@ static int bcm2835_gpio_probe(struct device_d *dev) bcmgpio->base = IOMEM(iores->start); bcmgpio->chip.ops = &bcm2835_gpio_ops; bcmgpio->chip.base = 0; - bcmgpio->chip.ngpio = 54; + bcmgpio->chip.ngpio = plat_data->ngpios; + bcmgpio->chip.dev = dev; bcmgpio->pctl.ops = &bcm2835_pinctrl_ops; bcmgpio->pctl.dev = dev; @@ -191,22 +189,31 @@ err: return ret; } +static const struct plat_data bcm2835_plat_data = { + .ngpios = 54, +}; + +static const struct plat_data bcm2711_plat_data = { + .ngpios = 58, +}; + static __maybe_unused struct of_device_id bcm2835_gpio_dt_ids[] = { { .compatible = "brcm,bcm2835-gpio", + .data = &bcm2835_plat_data, + }, { + .compatible = "brcm,bcm2711-gpio", + .data = &bcm2711_plat_data, }, { /* sentinel */ } }; +MODULE_DEVICE_TABLE(of, bcm2835_gpio_dt_ids); -static struct driver_d bcm2835_gpio_driver = { +static struct driver bcm2835_gpio_driver = { .name = "bcm2835-gpio", .probe = bcm2835_gpio_probe, .of_compatible = DRV_OF_COMPAT(bcm2835_gpio_dt_ids), }; -static int bcm2835_gpio_add(void) -{ - return platform_driver_register(&bcm2835_gpio_driver); -} -coredevice_initcall(bcm2835_gpio_add); +core_platform_driver(bcm2835_gpio_driver); |