Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Lennert Buytenhek | 72edd84 | 2006-09-18 23:23:07 +0100 | [diff] [blame] | 2 | /* |
| 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 Buytenhek | 72edd84 | 2006-09-18 23:23:07 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
Alexander Shiyan | 6d12541 | 2016-09-09 09:20:03 +0300 | [diff] [blame] | 9 | #include <linux/err.h> |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/gpio/driver.h> |
Linus Walleij | 7b85b86 | 2013-09-09 16:39:51 +0200 | [diff] [blame] | 12 | #include <linux/platform_device.h> |
Linus Walleij | f6ffa5e | 2013-09-09 15:00:40 +0200 | [diff] [blame] | 13 | |
Alexander Shiyan | 6d12541 | 2016-09-09 09:20:03 +0300 | [diff] [blame] | 14 | #define IOP3XX_GPOE 0x0000 |
| 15 | #define IOP3XX_GPID 0x0004 |
| 16 | #define IOP3XX_GPOD 0x0008 |
Arnaud Patard | 63f385c | 2008-07-08 23:07:48 +0100 | [diff] [blame] | 17 | |
Linus Walleij | 7b85b86 | 2013-09-09 16:39:51 +0200 | [diff] [blame] | 18 | static int iop3xx_gpio_probe(struct platform_device *pdev) |
Arnaud Patard | 63f385c | 2008-07-08 23:07:48 +0100 | [diff] [blame] | 19 | { |
Alexander Shiyan | 6d12541 | 2016-09-09 09:20:03 +0300 | [diff] [blame] | 20 | 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 Walleij | 7b85b86 | 2013-09-09 16:39:51 +0200 | [diff] [blame] | 27 | |
Enrico Weigelt, metux IT consult | 30f8c52 | 2019-03-11 19:54:53 +0100 | [diff] [blame] | 28 | base = devm_platform_ioremap_resource(pdev, 0); |
Bartlomiej Zolnierkiewicz | 138d876 | 2014-03-18 10:58:33 +0100 | [diff] [blame] | 29 | if (IS_ERR(base)) |
| 30 | return PTR_ERR(base); |
Linus Walleij | 7b85b86 | 2013-09-09 16:39:51 +0200 | [diff] [blame] | 31 | |
Alexander Shiyan | 6d12541 | 2016-09-09 09:20:03 +0300 | [diff] [blame] | 32 | 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 Walleij | fdb7e88 | 2019-06-01 00:37:56 +0200 | [diff] [blame] | 39 | gc->label = "gpio-iop"; |
Alexander Shiyan | 6d12541 | 2016-09-09 09:20:03 +0300 | [diff] [blame] | 40 | |
| 41 | return devm_gpiochip_add_data(&pdev->dev, gc, NULL); |
Arnaud Patard | 63f385c | 2008-07-08 23:07:48 +0100 | [diff] [blame] | 42 | } |
Linus Walleij | 7b85b86 | 2013-09-09 16:39:51 +0200 | [diff] [blame] | 43 | |
| 44 | static struct platform_driver iop3xx_gpio_driver = { |
| 45 | .driver = { |
| 46 | .name = "gpio-iop", |
Linus Walleij | 7b85b86 | 2013-09-09 16:39:51 +0200 | [diff] [blame] | 47 | }, |
| 48 | .probe = iop3xx_gpio_probe, |
| 49 | }; |
| 50 | |
| 51 | static int __init iop3xx_gpio_init(void) |
| 52 | { |
| 53 | return platform_driver_register(&iop3xx_gpio_driver); |
| 54 | } |
| 55 | arch_initcall(iop3xx_gpio_init); |
Jesse Chan | 97b0313 | 2017-11-20 12:54:52 -0800 | [diff] [blame] | 56 | |
| 57 | MODULE_DESCRIPTION("GPIO handling for Intel IOP3xx processors"); |
| 58 | MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); |
| 59 | MODULE_LICENSE("GPL"); |