David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [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> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/err.h> |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/gpio/driver.h> |
| 12 | #include <linux/platform_device.h> |
| 13 | |
| 14 | #define IOP3XX_GPOE 0x0000 |
| 15 | #define IOP3XX_GPID 0x0004 |
| 16 | #define IOP3XX_GPOD 0x0008 |
| 17 | |
| 18 | static int iop3xx_gpio_probe(struct platform_device *pdev) |
| 19 | { |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [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; |
| 27 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 28 | base = devm_platform_ioremap_resource(pdev, 0); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 29 | if (IS_ERR(base)) |
| 30 | return PTR_ERR(base); |
| 31 | |
| 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; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 39 | gc->label = "gpio-iop"; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 40 | |
| 41 | return devm_gpiochip_add_data(&pdev->dev, gc, NULL); |
| 42 | } |
| 43 | |
| 44 | static struct platform_driver iop3xx_gpio_driver = { |
| 45 | .driver = { |
| 46 | .name = "gpio-iop", |
| 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); |
| 56 | |
| 57 | MODULE_DESCRIPTION("GPIO handling for Intel IOP3xx processors"); |
| 58 | MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); |
| 59 | MODULE_LICENSE("GPL"); |