History

gpio: rcar: Remove obsolete platform data support

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.

Geert Uytterhoeven committed 10 years ago

Commit 8b092be1 parent 0d1bb2b2 files · +26 −80Browse files

Unified · Split

2 files
  1. drivers/gpio/gpio-rcar.c +26 −51
  2. include/linux/platform_data/gpio-rcar.h +0 −29
drivers/gpio/gpio-rcar.c+26−51
@@ -25,7 +25,6 @@ · 24 unmodified lines
25#include <linux/module.h>25#include <linux/module.h>
26#include <linux/of.h>26#include <linux/of.h>
27#include <linux/pinctrl/consumer.h>27#include <linux/pinctrl/consumer.h>
28#include <linux/platform_data/gpio-rcar.h>
29#include <linux/platform_device.h>28#include <linux/platform_device.h>
30#include <linux/pm_runtime.h>29#include <linux/pm_runtime.h>
31#include <linux/spinlock.h>30#include <linux/spinlock.h>
@@ -34,12 +33,12 @@ · 2 unmodified lines
34struct gpio_rcar_priv {33struct gpio_rcar_priv {
35 void __iomem *base;34 void __iomem *base;
36 spinlock_t lock;35 spinlock_t lock;
37 struct gpio_rcar_config config;
38 struct platform_device *pdev;36 struct platform_device *pdev;
39 struct gpio_chip gpio_chip;37 struct gpio_chip gpio_chip;
40 struct irq_chip irq_chip;38 struct irq_chip irq_chip;
41 unsigned int irq_parent;
42 struct clk *clk;39 struct clk *clk;
40 unsigned int irq_parent;
41 bool has_both_edge_trigger;
43};42};
44 43
45#define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */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 gpio_rcar_modify_bit(p, EDGLEVEL, hwirq, !level_trigger);120 gpio_rcar_modify_bit(p, EDGLEVEL, hwirq, !level_trigger);
122 121
123 /* Select one edge or both edges in BOTHEDGE */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 gpio_rcar_modify_bit(p, BOTHEDGE, hwirq, both);124 gpio_rcar_modify_bit(p, BOTHEDGE, hwirq, both);
126 125
127 /* Select "Interrupt Input Mode" in IOINTSEL */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 false);160 false);
162 break;161 break;
163 case IRQ_TYPE_EDGE_BOTH:162 case IRQ_TYPE_EDGE_BOTH:
164 if (!p->config.has_both_edge_trigger)163 if (!p->has_both_edge_trigger)
165 return -EINVAL;164 return -EINVAL;
166 gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false,165 gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false,
167 true);166 true);
@@ -355,39 +354,29 @@ static const struct of_device_id gpio_rcar_of_table[] = { · 187 unmodified lines
355 354
356MODULE_DEVICE_TABLE(of, gpio_rcar_of_table);355MODULE_DEVICE_TABLE(of, gpio_rcar_of_table);
357 356
358static int gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)357static 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 struct device_node *np = p->pdev->dev.of_node;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 struct of_phandle_args args;362 struct of_phandle_args args;
363 int ret;363 int ret;
364 364
365 if (pdata) {365 match = of_match_node(gpio_rcar_of_table, np);
366 p->config = *pdata;366 if (!match)
367 } else if (IS_ENABLED(CONFIG_OF) && np) {367 return -EINVAL;
368 const struct of_device_id *match;
369 const struct gpio_rcar_info *info;
370 368
371 match = of_match_node(gpio_rcar_of_table, np);369 info = match->data;
372 if (!match)
373 return -EINVAL;
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,375 if (*npins == 0 || *npins > RCAR_MAX_GPIO_PER_BANK) {
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) {
387 dev_warn(&p->pdev->dev,376 dev_warn(&p->pdev->dev,
388 "Invalid number of gpio lines %u, using %u\n",377 "Invalid number of gpio lines %u, using %u\n", *npins,
389 p->config.number_of_pins, RCAR_MAX_GPIO_PER_BANK);378 RCAR_MAX_GPIO_PER_BANK);
390 p->config.number_of_pins = RCAR_MAX_GPIO_PER_BANK;379 *npins = RCAR_MAX_GPIO_PER_BANK;
391 }380 }
392 381
393 return 0;382 return 0;
@@ -401,6 +390,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) · 7 unmodified lines
401 struct irq_chip *irq_chip;390 struct irq_chip *irq_chip;
402 struct device *dev = &pdev->dev;391 struct device *dev = &pdev->dev;
403 const char *name = dev_name(dev);392 const char *name = dev_name(dev);
393 unsigned int npins;
404 int ret;394 int ret;
405 395
406 p = devm_kzalloc(dev, sizeof(*p), GFP_KERNEL);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 p->pdev = pdev;400 p->pdev = pdev;
411 spin_lock_init(&p->lock);401 spin_lock_init(&p->lock);
412 402
413 /* Get device configuration from DT node or platform data. */403 /* Get device configuration from DT node */
414 ret = gpio_rcar_parse_pdata(p);404 ret = gpio_rcar_parse_dt(p, &npins);
415 if (ret < 0)405 if (ret < 0)
416 return ret;406 return ret;
417 407
@@ -451,8 +441,8 @@ static int gpio_rcar_probe(struct platform_device *pdev) · 33 unmodified lines
451 gpio_chip->label = name;441 gpio_chip->label = name;
452 gpio_chip->parent = dev;442 gpio_chip->parent = dev;
453 gpio_chip->owner = THIS_MODULE;443 gpio_chip->owner = THIS_MODULE;
454 gpio_chip->base = p->config.gpio_base;444 gpio_chip->base = -1;
455 gpio_chip->ngpio = p->config.number_of_pins;445 gpio_chip->ngpio = npins;
456 446
457 irq_chip = &p->irq_chip;447 irq_chip = &p->irq_chip;
458 irq_chip->name = name;448 irq_chip->name = name;
@@ -468,8 +458,8 @@ static int gpio_rcar_probe(struct platform_device *pdev) · 9 unmodified lines
468 goto err0;458 goto err0;
469 }459 }
470 460
471 ret = gpiochip_irqchip_add(gpio_chip, irq_chip, p->config.irq_base,461 ret = gpiochip_irqchip_add(gpio_chip, irq_chip, 0, handle_level_irq,
472 handle_level_irq, IRQ_TYPE_NONE);462 IRQ_TYPE_NONE);
473 if (ret) {463 if (ret) {
474 dev_err(dev, "cannot add irqchip\n");464 dev_err(dev, "cannot add irqchip\n");
475 goto err1;465 goto err1;
@@ -483,22 +473,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) · 7 unmodified lines
483 goto err1;473 goto err1;
484 }474 }
485 475
486 dev_info(dev, "driving %d GPIOs\n", p->config.number_of_pins);476 dev_info(dev, "driving %d GPIOs\n", npins);
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 }
502 477
503 return 0;478 return 0;
504 479
include/linux/platform_data/gpio-rcar.h+0−29
@@ -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
19struct 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__ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t