Lines Matching +full:gpio +full:- +full:dir

1 // SPDX-License-Identifier: GPL-2.0-only
3 * GPIO controller in LSI ZEVIO SoCs.
5 * Author: Fabian Vogt <fabian@ritter-vogt.de>
17 #include <linux/gpio/driver.h>
21 * This chip has four gpio sections, each controls 8 GPIOs.
22 * Bit 0 in section 0 is GPIO 0, bit 2 in section 1 is GPIO 10.
25 …tp://hackspire.unsads.com/wiki/index.php/Memory-mapped_I/O_ports#90000000_-_General_Purpose_I.2FO_…
27 * 0x00-0x3F: Section 0
28 * +0x00: Masked interrupt status (read-only)
31 * +0x0C: W: Unmask interrupt (write-only)
34 * +0x18: Input (read-only)
36 * 0x40-0x7F: Section 1
37 * 0x80-0xBF: Section 2
38 * 0xC0-0xFF: Section 3
53 /* Bit number of GPIO in its section */
54 #define ZEVIO_GPIO_BIT(gpio) (gpio&7) argument
66 return readl(IOMEM(c->regs + section_offset + port_offset)); in zevio_gpio_port_get()
73 writel(val, IOMEM(c->regs + section_offset + port_offset)); in zevio_gpio_port_set()
80 u32 val, dir; in zevio_gpio_get() local
82 spin_lock(&controller->lock); in zevio_gpio_get()
83 dir = zevio_gpio_port_get(controller, pin, ZEVIO_GPIO_DIRECTION); in zevio_gpio_get()
84 if (dir & BIT(ZEVIO_GPIO_BIT(pin))) in zevio_gpio_get()
88 spin_unlock(&controller->lock); in zevio_gpio_get()
98 spin_lock(&controller->lock); in zevio_gpio_set()
106 spin_unlock(&controller->lock); in zevio_gpio_set()
114 spin_lock(&controller->lock); in zevio_gpio_direction_input()
120 spin_unlock(&controller->lock); in zevio_gpio_direction_input()
131 spin_lock(&controller->lock); in zevio_gpio_direction_output()
143 spin_unlock(&controller->lock); in zevio_gpio_direction_output()
155 return -ENXIO; in zevio_gpio_to_irq()
175 controller = devm_kzalloc(&pdev->dev, sizeof(*controller), GFP_KERNEL); in zevio_gpio_probe()
177 return -ENOMEM; in zevio_gpio_probe()
180 controller->chip = zevio_gpio_chip; in zevio_gpio_probe()
181 controller->chip.parent = &pdev->dev; in zevio_gpio_probe()
183 controller->regs = devm_platform_ioremap_resource(pdev, 0); in zevio_gpio_probe()
184 if (IS_ERR(controller->regs)) in zevio_gpio_probe()
185 return dev_err_probe(&pdev->dev, PTR_ERR(controller->regs), in zevio_gpio_probe()
188 status = devm_gpiochip_add_data(&pdev->dev, &controller->chip, controller); in zevio_gpio_probe()
190 dev_err(&pdev->dev, "failed to add gpiochip: %d\n", status); in zevio_gpio_probe()
194 spin_lock_init(&controller->lock); in zevio_gpio_probe()
197 for (i = 0; i < controller->chip.ngpio; i += 8) in zevio_gpio_probe()
200 dev_dbg(controller->chip.parent, "ZEVIO GPIO controller set up!\n"); in zevio_gpio_probe()
206 { .compatible = "lsi,zevio-gpio", },
212 .name = "gpio-zevio",