18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * arch/arm/plat-iop/gpio.c 48c2ecf20Sopenharmony_ci * GPIO handling for Intel IOP3xx processors. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/err.h> 108c2ecf20Sopenharmony_ci#include <linux/module.h> 118c2ecf20Sopenharmony_ci#include <linux/gpio/driver.h> 128c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define IOP3XX_GPOE 0x0000 158c2ecf20Sopenharmony_ci#define IOP3XX_GPID 0x0004 168c2ecf20Sopenharmony_ci#define IOP3XX_GPOD 0x0008 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistatic int iop3xx_gpio_probe(struct platform_device *pdev) 198c2ecf20Sopenharmony_ci{ 208c2ecf20Sopenharmony_ci struct gpio_chip *gc; 218c2ecf20Sopenharmony_ci void __iomem *base; 228c2ecf20Sopenharmony_ci int err; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL); 258c2ecf20Sopenharmony_ci if (!gc) 268c2ecf20Sopenharmony_ci return -ENOMEM; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci base = devm_platform_ioremap_resource(pdev, 0); 298c2ecf20Sopenharmony_ci if (IS_ERR(base)) 308c2ecf20Sopenharmony_ci return PTR_ERR(base); 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci err = bgpio_init(gc, &pdev->dev, 1, base + IOP3XX_GPID, 338c2ecf20Sopenharmony_ci base + IOP3XX_GPOD, NULL, NULL, base + IOP3XX_GPOE, 0); 348c2ecf20Sopenharmony_ci if (err) 358c2ecf20Sopenharmony_ci return err; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci gc->base = 0; 388c2ecf20Sopenharmony_ci gc->owner = THIS_MODULE; 398c2ecf20Sopenharmony_ci gc->label = "gpio-iop"; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci return devm_gpiochip_add_data(&pdev->dev, gc, NULL); 428c2ecf20Sopenharmony_ci} 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistatic struct platform_driver iop3xx_gpio_driver = { 458c2ecf20Sopenharmony_ci .driver = { 468c2ecf20Sopenharmony_ci .name = "gpio-iop", 478c2ecf20Sopenharmony_ci }, 488c2ecf20Sopenharmony_ci .probe = iop3xx_gpio_probe, 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistatic int __init iop3xx_gpio_init(void) 528c2ecf20Sopenharmony_ci{ 538c2ecf20Sopenharmony_ci return platform_driver_register(&iop3xx_gpio_driver); 548c2ecf20Sopenharmony_ci} 558c2ecf20Sopenharmony_ciarch_initcall(iop3xx_gpio_init); 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("GPIO handling for Intel IOP3xx processors"); 588c2ecf20Sopenharmony_ciMODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); 598c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 60