Since commit 4baadb9e05c68962 ("ARM: shmobile: r8a7778: remove obsolete setup code"), Renesas R-Car SoCs are only supported in generic DT-only ARM multi-platform builds. The driver doesn't need to use platform data anymore, hence remove platform data configuration. Make gpio_rcar_priv.has_both_edge_trigger a boolean for consistency with gpio_rcar_info.has_both_edge_trigger. Move gpio_rcar_priv.irq_parent down while we're at it, to prevent gaps on 64-bit.
Unified · Split
| @@ -25,7 +25,6 @@ · 24 unmodified lines | ||
| 25 | 25 | #include <linux/module.h> |
| 26 | 26 | #include <linux/of.h> |
| 27 | 27 | #include <linux/pinctrl/consumer.h> |
| 28 | −#include <linux/platform_data/gpio-rcar.h> | |
| 29 | 28 | #include <linux/platform_device.h> |
| 30 | 29 | #include <linux/pm_runtime.h> |
| 31 | 30 | #include <linux/spinlock.h> |
| @@ -34,12 +33,12 @@ · 2 unmodified lines | ||
| 34 | 33 | struct gpio_rcar_priv { |
| 35 | 34 | void __iomem *base; |
| 36 | 35 | spinlock_t lock; |
| 37 | − struct gpio_rcar_config config; | |
| 38 | 36 | struct platform_device *pdev; |
| 39 | 37 | struct gpio_chip gpio_chip; |
| 40 | 38 | struct irq_chip irq_chip; |
| 41 | − unsigned int irq_parent; | |
| 42 | 39 | struct clk *clk; |
| 40 | + unsigned int irq_parent; | |
| 41 | + bool has_both_edge_trigger; | |
| 43 | 42 | }; |
| 44 | 43 | |
| 45 | 44 | #define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */ |
| @@ -121,7 +120,7 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p, · 75 unmodified lines | ||
| 121 | 120 | gpio_rcar_modify_bit(p, EDGLEVEL, hwirq, !level_trigger); |
| 122 | 121 | |
| 123 | 122 | /* Select one edge or both edges in BOTHEDGE */ |
| 124 | − if (p->config.has_both_edge_trigger) | |
| 123 | + if (p->has_both_edge_trigger) | |
| 125 | 124 | gpio_rcar_modify_bit(p, BOTHEDGE, hwirq, both); |
| 126 | 125 | |
| 127 | 126 | /* Select "Interrupt Input Mode" in IOINTSEL */ |
| @@ -161,7 +160,7 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type) · 33 unmodified lines | ||
| 161 | 160 | false); |
| 162 | 161 | break; |
| 163 | 162 | case IRQ_TYPE_EDGE_BOTH: |
| 164 | − if (!p->config.has_both_edge_trigger) | |
| 163 | + if (!p->has_both_edge_trigger) | |
| 165 | 164 | return -EINVAL; |
| 166 | 165 | gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false, |
| 167 | 166 | true); |
| @@ -355,39 +354,29 @@ static const struct of_device_id gpio_rcar_of_table[] = { · 187 unmodified lines | ||
| 355 | 354 | |
| 356 | 355 | MODULE_DEVICE_TABLE(of, gpio_rcar_of_table); |
| 357 | 356 | |
| 358 | −static int gpio_rcar_parse_pdata(struct gpio_rcar_priv *p) | |
| 357 | +static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins) | |
| 359 | 358 | { |
| 360 | − struct gpio_rcar_config *pdata = dev_get_platdata(&p->pdev->dev); | |
| 361 | 359 | struct device_node *np = p->pdev->dev.of_node; |
| 360 | + const struct of_device_id *match; | |
| 361 | + const struct gpio_rcar_info *info; | |
| 362 | 362 | struct of_phandle_args args; |
| 363 | 363 | int ret; |
| 364 | 364 | |
| 365 | − if (pdata) { | |
| 366 | − p->config = *pdata; | |
| 367 | − } else if (IS_ENABLED(CONFIG_OF) && np) { | |
| 368 | − const struct of_device_id *match; | |
| 369 | − const struct gpio_rcar_info *info; | |
| 365 | + match = of_match_node(gpio_rcar_of_table, np); | |
| 366 | + if (!match) | |
| 367 | + return -EINVAL; | |
| 370 | 368 | |
| 371 | − match = of_match_node(gpio_rcar_of_table, np); | |
| 372 | − if (!match) | |
| 373 | − return -EINVAL; | |
| 369 | + info = match->data; | |
| 374 | 370 | |
| 375 | − info = match->data; | |
| 371 | + ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args); | |
| 372 | + *npins = ret == 0 ? args.args[2] : RCAR_MAX_GPIO_PER_BANK; | |
| 373 | + p->has_both_edge_trigger = info->has_both_edge_trigger; | |
| 376 | 374 | |
| 377 | − ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, | |
| 378 | − &args); | |
| 379 | − p->config.number_of_pins = ret == 0 ? args.args[2] | |
| 380 | − : RCAR_MAX_GPIO_PER_BANK; | |
| 381 | − p->config.gpio_base = -1; | |
| 382 | − p->config.has_both_edge_trigger = info->has_both_edge_trigger; | |
| 383 | − } | |
| 384 | − | |
| 385 | − if (p->config.number_of_pins == 0 || | |
| 386 | − p->config.number_of_pins > RCAR_MAX_GPIO_PER_BANK) { | |
| 375 | + if (*npins == 0 || *npins > RCAR_MAX_GPIO_PER_BANK) { | |
| 387 | 376 | dev_warn(&p->pdev->dev, |
| 388 | − "Invalid number of gpio lines %u, using %u\n", | |
| 389 | − p->config.number_of_pins, RCAR_MAX_GPIO_PER_BANK); | |
| 390 | − p->config.number_of_pins = RCAR_MAX_GPIO_PER_BANK; | |
| 377 | + "Invalid number of gpio lines %u, using %u\n", *npins, | |
| 378 | + RCAR_MAX_GPIO_PER_BANK); | |
| 379 | + *npins = RCAR_MAX_GPIO_PER_BANK; | |
| 391 | 380 | } |
| 392 | 381 | |
| 393 | 382 | return 0; |
| @@ -401,6 +390,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) · 7 unmodified lines | ||
| 401 | 390 | struct irq_chip *irq_chip; |
| 402 | 391 | struct device *dev = &pdev->dev; |
| 403 | 392 | const char *name = dev_name(dev); |
| 393 | + unsigned int npins; | |
| 404 | 394 | int ret; |
| 405 | 395 | |
| 406 | 396 | p = devm_kzalloc(dev, sizeof(*p), GFP_KERNEL); |
| @@ -410,8 +400,8 @@ static int gpio_rcar_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 410 | 400 | p->pdev = pdev; |
| 411 | 401 | spin_lock_init(&p->lock); |
| 412 | 402 | |
| 413 | − /* Get device configuration from DT node or platform data. */ | |
| 414 | − ret = gpio_rcar_parse_pdata(p); | |
| 403 | + /* Get device configuration from DT node */ | |
| 404 | + ret = gpio_rcar_parse_dt(p, &npins); | |
| 415 | 405 | if (ret < 0) |
| 416 | 406 | return ret; |
| 417 | 407 | |
| @@ -451,8 +441,8 @@ static int gpio_rcar_probe(struct platform_device *pdev) · 33 unmodified lines | ||
| 451 | 441 | gpio_chip->label = name; |
| 452 | 442 | gpio_chip->parent = dev; |
| 453 | 443 | gpio_chip->owner = THIS_MODULE; |
| 454 | − gpio_chip->base = p->config.gpio_base; | |
| 455 | − gpio_chip->ngpio = p->config.number_of_pins; | |
| 444 | + gpio_chip->base = -1; | |
| 445 | + gpio_chip->ngpio = npins; | |
| 456 | 446 | |
| 457 | 447 | irq_chip = &p->irq_chip; |
| 458 | 448 | irq_chip->name = name; |
| @@ -468,8 +458,8 @@ static int gpio_rcar_probe(struct platform_device *pdev) · 9 unmodified lines | ||
| 468 | 458 | goto err0; |
| 469 | 459 | } |
| 470 | 460 | |
| 471 | − ret = gpiochip_irqchip_add(gpio_chip, irq_chip, p->config.irq_base, | |
| 472 | − handle_level_irq, IRQ_TYPE_NONE); | |
| 461 | + ret = gpiochip_irqchip_add(gpio_chip, irq_chip, 0, handle_level_irq, | |
| 462 | + IRQ_TYPE_NONE); | |
| 473 | 463 | if (ret) { |
| 474 | 464 | dev_err(dev, "cannot add irqchip\n"); |
| 475 | 465 | goto err1; |
| @@ -483,22 +473,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) · 7 unmodified lines | ||
| 483 | 473 | goto err1; |
| 484 | 474 | } |
| 485 | 475 | |
| 486 | − dev_info(dev, "driving %d GPIOs\n", p->config.number_of_pins); | |
| 487 | − | |
| 488 | − /* warn in case of mismatch if irq base is specified */ | |
| 489 | − if (p->config.irq_base) { | |
| 490 | − ret = irq_find_mapping(gpio_chip->irqdomain, 0); | |
| 491 | − if (p->config.irq_base != ret) | |
| 492 | − dev_warn(dev, "irq base mismatch (%u/%u)\n", | |
| 493 | − p->config.irq_base, ret); | |
| 494 | − } | |
| 495 | − | |
| 496 | − if (p->config.pctl_name) { | |
| 497 | − ret = gpiochip_add_pin_range(gpio_chip, p->config.pctl_name, 0, | |
| 498 | − gpio_chip->base, gpio_chip->ngpio); | |
| 499 | − if (ret < 0) | |
| 500 | − dev_warn(dev, "failed to add pin range\n"); | |
| 501 | − } | |
| 476 | + dev_info(dev, "driving %d GPIOs\n", npins); | |
| 502 | 477 | |
| 503 | 478 | return 0; |
| 504 | 479 | |
| @@ -1,29 +0,0 @@ | ||
| 1 | −/* | |
| 2 | − * Renesas R-Car GPIO Support | |
| 3 | − * | |
| 4 | − * Copyright (C) 2013 Magnus Damm | |
| 5 | − * | |
| 6 | − * This program is free software; you can redistribute it and/or modify | |
| 7 | − * it under the terms of the GNU General Public License as published by | |
| 8 | − * the Free Software Foundation; either version 2 of the License | |
| 9 | − * | |
| 10 | − * This program is distributed in the hope that it will be useful, | |
| 11 | − * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | − * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | − * GNU General Public License for more details. | |
| 14 | − */ | |
| 15 | − | |
| 16 | −#ifndef __GPIO_RCAR_H__ | |
| 17 | −#define __GPIO_RCAR_H__ | |
| 18 | − | |
| 19 | −struct gpio_rcar_config { | |
| 20 | − int gpio_base; | |
| 21 | − unsigned int irq_base; | |
| 22 | − unsigned int number_of_pins; | |
| 23 | − const char *pctl_name; | |
| 24 | − unsigned has_both_edge_trigger:1; | |
| 25 | −}; | |
| 26 | − | |
| 27 | −#define RCAR_GP_PIN(bank, pin) (((bank) * 32) + (pin)) | |
| 28 | − | |
| 29 | −#endif /* __GPIO_RCAR_H__ */ | |