mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
powerpc/44x: Change GPIO driver to a proper platform driver
In order to drop legacy-of-mm-gpiochip dependency, first change the 44x GPIO driver to a proper platform driver. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/29d89aa43536714b193d9710301341f838fcb5b7.1755519343.git.christophe.leroy@csgroup.eu
This commit is contained in:
parent
7f9bcf1306
commit
1044dbaf2a
|
|
@ -18,6 +18,7 @@
|
||||||
#include <linux/gpio/driver.h>
|
#include <linux/gpio/driver.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
|
|
||||||
#define GPIO_MASK(gpio) (0x80000000 >> (gpio))
|
#define GPIO_MASK(gpio) (0x80000000 >> (gpio))
|
||||||
#define GPIO_MASK2(gpio) (0xc0000000 >> ((gpio) * 2))
|
#define GPIO_MASK2(gpio) (0xc0000000 >> ((gpio) * 2))
|
||||||
|
|
@ -155,42 +156,50 @@ ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init ppc4xx_add_gpiochips(void)
|
static int ppc4xx_gpio_probe(struct platform_device *ofdev)
|
||||||
{
|
{
|
||||||
struct device_node *np;
|
struct device *dev = &ofdev->dev;
|
||||||
|
struct device_node *np = dev->of_node;
|
||||||
|
struct ppc4xx_gpio_chip *chip;
|
||||||
|
struct of_mm_gpio_chip *mm_gc;
|
||||||
|
struct gpio_chip *gc;
|
||||||
|
|
||||||
for_each_compatible_node(np, NULL, "ibm,ppc4xx-gpio") {
|
chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
|
||||||
int ret;
|
if (!chip)
|
||||||
struct ppc4xx_gpio_chip *ppc4xx_gc;
|
return -ENOMEM;
|
||||||
struct of_mm_gpio_chip *mm_gc;
|
|
||||||
struct gpio_chip *gc;
|
|
||||||
|
|
||||||
ppc4xx_gc = kzalloc(sizeof(*ppc4xx_gc), GFP_KERNEL);
|
spin_lock_init(&chip->lock);
|
||||||
if (!ppc4xx_gc) {
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock_init(&ppc4xx_gc->lock);
|
mm_gc = &chip->mm_gc;
|
||||||
|
gc = &mm_gc->gc;
|
||||||
|
|
||||||
mm_gc = &ppc4xx_gc->mm_gc;
|
gc->ngpio = 32;
|
||||||
gc = &mm_gc->gc;
|
gc->direction_input = ppc4xx_gpio_dir_in;
|
||||||
|
gc->direction_output = ppc4xx_gpio_dir_out;
|
||||||
|
gc->get = ppc4xx_gpio_get;
|
||||||
|
gc->set = ppc4xx_gpio_set;
|
||||||
|
|
||||||
gc->ngpio = 32;
|
return of_mm_gpiochip_add_data(np, mm_gc, chip);
|
||||||
gc->direction_input = ppc4xx_gpio_dir_in;
|
|
||||||
gc->direction_output = ppc4xx_gpio_dir_out;
|
|
||||||
gc->get = ppc4xx_gpio_get;
|
|
||||||
gc->set = ppc4xx_gpio_set;
|
|
||||||
|
|
||||||
ret = of_mm_gpiochip_add_data(np, mm_gc, ppc4xx_gc);
|
|
||||||
if (ret)
|
|
||||||
goto err;
|
|
||||||
continue;
|
|
||||||
err:
|
|
||||||
pr_err("%pOF: registration failed with status %d\n", np, ret);
|
|
||||||
kfree(ppc4xx_gc);
|
|
||||||
/* try others anyway */
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
arch_initcall(ppc4xx_add_gpiochips);
|
|
||||||
|
static const struct of_device_id ppc4xx_gpio_match[] = {
|
||||||
|
{
|
||||||
|
.compatible = "ibm,ppc4xx-gpio",
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, ppc4xx_gpio_match);
|
||||||
|
|
||||||
|
static struct platform_driver ppc4xx_gpio_driver = {
|
||||||
|
.probe = ppc4xx_gpio_probe,
|
||||||
|
.driver = {
|
||||||
|
.name = "ppc4xx-gpio",
|
||||||
|
.of_match_table = ppc4xx_gpio_match,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static int __init ppc4xx_gpio_init(void)
|
||||||
|
{
|
||||||
|
return platform_driver_register(&ppc4xx_gpio_driver);
|
||||||
|
}
|
||||||
|
arch_initcall(ppc4xx_gpio_init);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user