gpio: rockchip: Make the gpio base added at gpiolib

It looks like should add gpio base in the gpiolib instead of
each gpio or pinctrl driver, and base defined in the gpio.h.

If the definition of base is 0, then it is the same as the
original, now the definition of base is 1000.

The dynamic assignment of a range of valid GPIOs should be
also from the defined base.

Change-Id: I636bc71a5ba078fd5e1bc9a476cdcf942aa8010a
Signed-off-by: David Wu <david.wu@rock-chips.com>
This commit is contained in:
David Wu
2017-12-22 10:37:32 +08:00
committed by Tao Huang
parent 18cb8e2d64
commit 545abf2ec4
2 changed files with 8 additions and 5 deletions
+7 -4
View File
@@ -126,7 +126,7 @@ EXPORT_SYMBOL_GPL(gpiod_to_chip);
static int gpiochip_find_base(int ngpio)
{
struct gpio_chip *chip;
int base = ARCH_NR_GPIOS - ngpio;
int base = ARCH_NR_GPIOS - ngpio + ARCH_GPIO_BASE;
list_for_each_entry_reverse(chip, &gpio_chips, list) {
/* found a free space? */
@@ -301,18 +301,21 @@ int gpiochip_add(struct gpio_chip *chip)
unsigned long flags;
int status = 0;
unsigned id;
int base = chip->base;
int base;
struct gpio_desc *descs;
chip->base += ARCH_GPIO_BASE;
base = chip->base;
descs = kcalloc(chip->ngpio, sizeof(descs[0]), GFP_KERNEL);
if (!descs)
return -ENOMEM;
spin_lock_irqsave(&gpio_lock, flags);
if (base < 0) {
if (base < ARCH_GPIO_BASE) {
base = gpiochip_find_base(chip->ngpio);
if (base < 0) {
if (base < ARCH_GPIO_BASE) {
status = base;
spin_unlock_irqrestore(&gpio_lock, flags);
goto err_free_descs;
+1 -1
View File
@@ -3179,7 +3179,7 @@ static int rockchip_gpiolib_register(struct platform_device *pdev,
bank->gpio_chip = rockchip_gpiolib_chip;
gc = &bank->gpio_chip;
gc->base = ARCH_GPIO_BASE + bank->pin_base;
gc->base = bank->pin_base;
gc->ngpio = bank->nr_pins;
gc->dev = &pdev->dev;
gc->of_node = bank->of_node;