blob: 98c7ff2a76e76a24194f2c3278af42f5d5c4ff9c [file] [log] [blame]
Lennert Buytenhek72edd842006-09-18 23:23:07 +01001/*
2 * arch/arm/plat-iop/gpio.c
3 * GPIO handling for Intel IOP3xx processors.
4 *
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 */
12
Alexander Shiyan6d125412016-09-09 09:20:03 +030013#include <linux/err.h>
14#include <linux/module.h>
15#include <linux/gpio/driver.h>
Linus Walleij7b85b862013-09-09 16:39:51 +020016#include <linux/platform_device.h>
Linus Walleijf6ffa5e2013-09-09 15:00:40 +020017
Alexander Shiyan6d125412016-09-09 09:20:03 +030018#define IOP3XX_GPOE 0x0000
19#define IOP3XX_GPID 0x0004
20#define IOP3XX_GPOD 0x0008
Arnaud Patard63f385c2008-07-08 23:07:48 +010021
Linus Walleij7b85b862013-09-09 16:39:51 +020022static int iop3xx_gpio_probe(struct platform_device *pdev)
Arnaud Patard63f385c2008-07-08 23:07:48 +010023{
Linus Walleij7b85b862013-09-09 16:39:51 +020024 struct resource *res;
Alexander Shiyan6d125412016-09-09 09:20:03 +030025 struct gpio_chip *gc;
26 void __iomem *base;
27 int err;
28
29 gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL);
30 if (!gc)
31 return -ENOMEM;
Linus Walleij7b85b862013-09-09 16:39:51 +020032
33 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Linus Walleije34ca9d2013-09-09 16:59:54 +020034 base = devm_ioremap_resource(&pdev->dev, res);
Bartlomiej Zolnierkiewicz138d8762014-03-18 10:58:33 +010035 if (IS_ERR(base))
36 return PTR_ERR(base);
Linus Walleij7b85b862013-09-09 16:39:51 +020037
Alexander Shiyan6d125412016-09-09 09:20:03 +030038 err = bgpio_init(gc, &pdev->dev, 1, base + IOP3XX_GPID,
39 base + IOP3XX_GPOD, NULL, NULL, base + IOP3XX_GPOE, 0);
40 if (err)
41 return err;
42
43 gc->base = 0;
44 gc->owner = THIS_MODULE;
45
46 return devm_gpiochip_add_data(&pdev->dev, gc, NULL);
Arnaud Patard63f385c2008-07-08 23:07:48 +010047}
Linus Walleij7b85b862013-09-09 16:39:51 +020048
49static struct platform_driver iop3xx_gpio_driver = {
50 .driver = {
51 .name = "gpio-iop",
Linus Walleij7b85b862013-09-09 16:39:51 +020052 },
53 .probe = iop3xx_gpio_probe,
54};
55
56static int __init iop3xx_gpio_init(void)
57{
58 return platform_driver_register(&iop3xx_gpio_driver);
59}
60arch_initcall(iop3xx_gpio_init);