Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * arch/arm/plat-iop/gpio.c
0004  * GPIO handling for Intel IOP3xx processors.
0005  *
0006  * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
0007  */
0008 
0009 #include <linux/err.h>
0010 #include <linux/module.h>
0011 #include <linux/gpio/driver.h>
0012 #include <linux/platform_device.h>
0013 
0014 #define IOP3XX_GPOE 0x0000
0015 #define IOP3XX_GPID 0x0004
0016 #define IOP3XX_GPOD 0x0008
0017 
0018 static int iop3xx_gpio_probe(struct platform_device *pdev)
0019 {
0020     struct gpio_chip *gc;
0021     void __iomem *base;
0022     int err;
0023 
0024     gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL);
0025     if (!gc)
0026         return -ENOMEM;
0027 
0028     base = devm_platform_ioremap_resource(pdev, 0);
0029     if (IS_ERR(base))
0030         return PTR_ERR(base);
0031 
0032     err = bgpio_init(gc, &pdev->dev, 1, base + IOP3XX_GPID,
0033              base + IOP3XX_GPOD, NULL, NULL, base + IOP3XX_GPOE, 0);
0034     if (err)
0035         return err;
0036 
0037     gc->base = 0;
0038     gc->owner = THIS_MODULE;
0039     gc->label = "gpio-iop";
0040 
0041     return devm_gpiochip_add_data(&pdev->dev, gc, NULL);
0042 }
0043 
0044 static struct platform_driver iop3xx_gpio_driver = {
0045     .driver = {
0046         .name = "gpio-iop",
0047     },
0048     .probe = iop3xx_gpio_probe,
0049 };
0050 
0051 static int __init iop3xx_gpio_init(void)
0052 {
0053     return platform_driver_register(&iop3xx_gpio_driver);
0054 }
0055 arch_initcall(iop3xx_gpio_init);
0056 
0057 MODULE_DESCRIPTION("GPIO handling for Intel IOP3xx processors");
0058 MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
0059 MODULE_LICENSE("GPL");