Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * arch/arm/plat-iop/gpio.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * GPIO handling for Intel IOP3xx processors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/gpio/driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define IOP3XX_GPOE	0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define IOP3XX_GPID	0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define IOP3XX_GPOD	0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static int iop3xx_gpio_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	struct gpio_chip *gc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	void __iomem *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	if (!gc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	base = devm_platform_ioremap_resource(pdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	if (IS_ERR(base))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		return PTR_ERR(base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	err = bgpio_init(gc, &pdev->dev, 1, base + IOP3XX_GPID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 			 base + IOP3XX_GPOD, NULL, NULL, base + IOP3XX_GPOE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	gc->base = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	gc->owner = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	gc->label = "gpio-iop";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	return devm_gpiochip_add_data(&pdev->dev, gc, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static struct platform_driver iop3xx_gpio_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		.name = "gpio-iop",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	.probe = iop3xx_gpio_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static int __init iop3xx_gpio_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	return platform_driver_register(&iop3xx_gpio_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) arch_initcall(iop3xx_gpio_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) MODULE_DESCRIPTION("GPIO handling for Intel IOP3xx processors");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) MODULE_LICENSE("GPL");