diff options
Diffstat (limited to 'drivers/pinctrl/pinctrl-at91.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-at91.c | 75 |
1 files changed, 32 insertions, 43 deletions
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 0da6332720..a3372a5035 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1,21 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2005 HP Labs * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> * Copyright (C) 2014 Raphaƫl Poggi - * - * See file CREDITS for list of people who contributed to this - * project. - * - * 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> @@ -29,10 +16,11 @@ #include <init.h> #include <driver.h> #include <getopt.h> +#include <deep-probe.h> -#include <mach/at91_pio.h> -#include <mach/gpio.h> -#include <mach/iomux.h> +#include <mach/at91/at91_pio.h> +#include <mach/at91/gpio.h> +#include <mach/at91/iomux.h> #include <pinctrl.h> @@ -60,17 +48,25 @@ struct at91_gpio_chip { #define DEBOUNCE_VAL_SHIFT 17 #define DEBOUNCE_VAL (0x3fff << DEBOUNCE_VAL_SHIFT) -static int gpio_banks; - static struct at91_gpio_chip gpio_chip[MAX_GPIO_BANKS]; static inline struct at91_gpio_chip *pin_to_controller(unsigned pin) { + struct at91_gpio_chip *chip; + pin /= MAX_NB_GPIO_PER_BANK; - if (likely(pin < gpio_banks)) - return &gpio_chip[pin]; + if (unlikely(pin >= MAX_GPIO_BANKS)) + return NULL; + + chip = &gpio_chip[pin]; + + if (!chip->regbase && deep_probe_is_supported()) { + char alias[] = "gpioX"; + scnprintf(alias, sizeof(alias), "gpio%u", pin); + of_device_ensure_probed_by_alias(alias); + } - return NULL; + return chip; } /** @@ -109,7 +105,7 @@ int at91_mux_pin(unsigned pin, enum at91_mux mux, int use_pullup) { struct at91_gpio_chip *at91_gpio = pin_to_controller(pin); void __iomem *pio; - struct device_d *dev; + struct device *dev; unsigned mask = pin_to_mask(pin); int bank = pin_to_bank(pin); @@ -383,15 +379,16 @@ static struct of_device_id at91_pinctrl_dt_ids[] = { /* sentinel */ } }; +MODULE_DEVICE_TABLE(of, at91_pinctrl_dt_ids); -static struct at91_pinctrl_mux_ops *at91_pinctrl_get_driver_data(struct device_d *dev) +static struct at91_pinctrl_mux_ops *at91_pinctrl_get_driver_data(struct device *dev) { struct at91_pinctrl_mux_ops *ops_data = NULL; int rc; - if (dev->device_node) { + if (dev->of_node) { const struct of_device_id *match; - match = of_match_node(at91_pinctrl_dt_ids, dev->device_node); + match = of_match_node(at91_pinctrl_dt_ids, dev->of_node); if (!match) ops_data = NULL; else @@ -482,7 +479,7 @@ static struct pinctrl_ops at91_pinctrl_ops = { .set_state = at91_pinctrl_set_state, }; -static int at91_pinctrl_probe(struct device_d *dev) +static int at91_pinctrl_probe(struct device *dev) { struct at91_pinctrl *info; int ret; @@ -522,18 +519,14 @@ static struct platform_device_id at91_pinctrl_ids[] = { }, }; -static struct driver_d at91_pinctrl_driver = { +static struct driver at91_pinctrl_driver = { .name = "pinctrl-at91", .probe = at91_pinctrl_probe, .id_table = at91_pinctrl_ids, .of_compatible = DRV_OF_COMPAT(at91_pinctrl_dt_ids), }; -static int at91_pinctrl_init(void) -{ - return platform_driver_register(&at91_pinctrl_driver); -} -core_initcall(at91_pinctrl_init); +core_platform_driver(at91_pinctrl_driver); static int at91_gpio_get(struct gpio_chip *chip, unsigned offset) { @@ -632,16 +625,17 @@ static struct of_device_id at91_gpio_dt_ids[] = { /* sentinel */ }, }; +MODULE_DEVICE_TABLE(of, at91_gpio_dt_ids); -static int at91_gpio_probe(struct device_d *dev) +static int at91_gpio_probe(struct device *dev) { struct at91_gpio_chip *at91_gpio; struct clk *clk; int ret; int alias_idx; - if (dev->device_node) - alias_idx = of_alias_get_id(dev->device_node, "gpio"); + if (dev->of_node) + alias_idx = of_alias_get_id(dev->of_node, "gpio"); else alias_idx = dev->id; @@ -669,7 +663,6 @@ static int at91_gpio_probe(struct device_d *dev) return ret; } - gpio_banks = max(gpio_banks, alias_idx + 1); at91_gpio->regbase = dev_request_mem_region_err_null(dev, 0); if (!at91_gpio->regbase) return -ENOENT; @@ -702,15 +695,11 @@ static struct platform_device_id at91_gpio_ids[] = { }, }; -static struct driver_d at91_gpio_driver = { +static struct driver at91_gpio_driver = { .name = "gpio-at91", .probe = at91_gpio_probe, .id_table = at91_gpio_ids, .of_compatible = DRV_OF_COMPAT(at91_gpio_dt_ids), }; -static int at91_gpio_init(void) -{ - return platform_driver_register(&at91_gpio_driver); -} -core_initcall(at91_gpio_init); +core_platform_driver(at91_gpio_driver); |