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