blob: 7390b5ca09e30b4529157c64f4e887c963e7beb5 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Lennert Buytenhek72edd842006-09-18 23:23:07 +01002/*
3 * arch/arm/plat-iop/gpio.c
4 * GPIO handling for Intel IOP3xx processors.
5 *
6 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
Lennert Buytenhek72edd842006-09-18 23:23:07 +01007 */
8
Alexander Shiyan6d125412016-09-09 09:20:03 +03009#include <linux/err.h>
10#include <linux/module.h>
11#include <linux/gpio/driver.h>
Linus Walleij7b85b862013-09-09 16:39:51 +020012#include <linux/platform_device.h>
Linus Walleijf6ffa5e2013-09-09 15:00:40 +020013
Alexander Shiyan6d125412016-09-09 09:20:03 +030014#define IOP3XX_GPOE 0x0000
15#define IOP3XX_GPID 0x0004
16#define IOP3XX_GPOD 0x0008
Arnaud Patard63f385c2008-07-08 23:07:48 +010017
Linus Walleij7b85b862013-09-09 16:39:51 +020018static int iop3xx_gpio_probe(struct platform_device *pdev)
Arnaud Patard63f385c2008-07-08 23:07:48 +010019{
Alexander Shiyan6d125412016-09-09 09:20:03 +030020 struct gpio_chip *gc;
21 void __iomem *base;
22 int err;
23
24 gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL);
25 if (!gc)
26 return -ENOMEM;
Linus Walleij7b85b862013-09-09 16:39:51 +020027
Enrico Weigelt, metux IT consult30f8c522019-03-11 19:54:53 +010028 base = devm_platform_ioremap_resource(pdev, 0);
Bartlomiej Zolnierkiewicz138d8762014-03-18 10:58:33 +010029 if (IS_ERR(base))
30 return PTR_ERR(base);
Linus Walleij7b85b862013-09-09 16:39:51 +020031
Alexander Shiyan6d125412016-09-09 09:20:03 +030032 err = bgpio_init(gc, &pdev->dev, 1, base + IOP3XX_GPID,
33 base + IOP3XX_GPOD, NULL, NULL, base + IOP3XX_GPOE, 0);
34 if (err)
35 return err;
36
37 gc->base = 0;
38 gc->owner = THIS_MODULE;
Linus Walleijfdb7e882019-06-01 00:37:56 +020039 gc->label = "gpio-iop";
Alexander Shiyan6d125412016-09-09 09:20:03 +030040
41 return devm_gpiochip_add_data(&pdev->dev, gc, NULL);
Arnaud Patard63f385c2008-07-08 23:07:48 +010042}
Linus Walleij7b85b862013-09-09 16:39:51 +020043
44static struct platform_driver iop3xx_gpio_driver = {
45 .driver = {
46 .name = "gpio-iop",
Linus Walleij7b85b862013-09-09 16:39:51 +020047 },
48 .probe = iop3xx_gpio_probe,
49};
50
51static int __init iop3xx_gpio_init(void)
52{
53 return platform_driver_register(&iop3xx_gpio_driver);
54}
55arch_initcall(iop3xx_gpio_init);
Jesse Chan97b03132017-11-20 12:54:52 -080056
57MODULE_DESCRIPTION("GPIO handling for Intel IOP3xx processors");
58MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
59MODULE_LICENSE("GPL");