blob: e355c5961eb9f27f029a7fcd9bc6684bf564636c [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;
39
40 return devm_gpiochip_add_data(&pdev->dev, gc, NULL);
Arnaud Patard63f385c2008-07-08 23:07:48 +010041}
Linus Walleij7b85b862013-09-09 16:39:51 +020042
43static struct platform_driver iop3xx_gpio_driver = {
44 .driver = {
45 .name = "gpio-iop",
Linus Walleij7b85b862013-09-09 16:39:51 +020046 },
47 .probe = iop3xx_gpio_probe,
48};
49
50static int __init iop3xx_gpio_init(void)
51{
52 return platform_driver_register(&iop3xx_gpio_driver);
53}
54arch_initcall(iop3xx_gpio_init);
Jesse Chan97b03132017-11-20 12:54:52 -080055
56MODULE_DESCRIPTION("GPIO handling for Intel IOP3xx processors");
57MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
58MODULE_LICENSE("GPL");