Lines Matching +full:gpio +full:- +full:cfg

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Support for viafb GPIO ports.
9 #include <linux/gpio/driver.h>
10 #include <linux/gpio/machine.h>
12 #include <linux/via-core.h>
14 #include "via-gpio.h"
17 * The ports we know about. Note that the port-25 gpios are not
30 .vg_name = "VGPIO0", /* Guess - not in datasheet */
82 * GPIO access functions
87 struct viafb_gpio_cfg *cfg = gpiochip_get_data(chip); in via_gpio_set() local
89 struct viafb_gpio *gpio; in via_gpio_set() local
92 spin_lock_irqsave(&cfg->vdev->reg_lock, flags); in via_gpio_set()
93 gpio = cfg->active_gpios[nr]; in via_gpio_set()
94 reg = via_read_reg(VIASR, gpio->vg_port_index); in via_gpio_set()
95 reg |= 0x40 << gpio->vg_mask_shift; /* output enable */ in via_gpio_set()
97 reg |= 0x10 << gpio->vg_mask_shift; in via_gpio_set()
99 reg &= ~(0x10 << gpio->vg_mask_shift); in via_gpio_set()
100 via_write_reg(VIASR, gpio->vg_port_index, reg); in via_gpio_set()
101 spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); in via_gpio_set()
117 struct viafb_gpio_cfg *cfg = gpiochip_get_data(chip); in via_gpio_dir_input() local
118 struct viafb_gpio *gpio; in via_gpio_dir_input() local
121 spin_lock_irqsave(&cfg->vdev->reg_lock, flags); in via_gpio_dir_input()
122 gpio = cfg->active_gpios[nr]; in via_gpio_dir_input()
123 via_write_reg_mask(VIASR, gpio->vg_port_index, 0, in via_gpio_dir_input()
124 0x40 << gpio->vg_mask_shift); in via_gpio_dir_input()
125 spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); in via_gpio_dir_input()
131 struct viafb_gpio_cfg *cfg = gpiochip_get_data(chip); in via_gpio_get() local
133 struct viafb_gpio *gpio; in via_gpio_get() local
136 spin_lock_irqsave(&cfg->vdev->reg_lock, flags); in via_gpio_get()
137 gpio = cfg->active_gpios[nr]; in via_gpio_get()
138 reg = via_read_reg(VIASR, gpio->vg_port_index); in via_gpio_get()
139 spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); in via_gpio_get()
140 return !!(reg & (0x04 << gpio->vg_mask_shift)); in via_gpio_get()
146 .label = "VIAFB onboard GPIO",
152 .base = -1,
161 static void viafb_gpio_enable(struct viafb_gpio *gpio) in viafb_gpio_enable() argument
163 via_write_reg_mask(VIASR, gpio->vg_port_index, 0x02, 0x02); in viafb_gpio_enable()
166 static void viafb_gpio_disable(struct viafb_gpio *gpio) in viafb_gpio_disable() argument
168 via_write_reg_mask(VIASR, gpio->vg_port_index, 0, 0x02); in viafb_gpio_disable()
194 .dev_id = "viafb-camera",
196 GPIO_LOOKUP("via-gpio", 2, "VGPIO2", GPIO_ACTIVE_LOW),
197 GPIO_LOOKUP("via-gpio", 3, "VGPIO3", GPIO_ACTIVE_HIGH),
207 struct viafb_dev *vdev = platdev->dev.platform_data; in viafb_gpio_probe()
208 struct via_port_cfg *port_cfg = vdev->port_cfg; in viafb_gpio_probe()
210 struct viafb_gpio *gpio; in viafb_gpio_probe() local
220 for (gpio = viafb_all_gpios; in viafb_gpio_probe()
221 gpio < viafb_all_gpios + VIAFB_NUM_GPIOS; gpio++) in viafb_gpio_probe()
222 if (gpio->vg_port_index == port_cfg[i].ioport_index) { in viafb_gpio_probe()
223 viafb_gpio_config.active_gpios[ngpio] = gpio; in viafb_gpio_probe()
225 gpio->vg_name; in viafb_gpio_probe()
240 spin_lock_irqsave(&viafb_gpio_config.vdev->reg_lock, flags); in viafb_gpio_probe()
243 spin_unlock_irqrestore(&viafb_gpio_config.vdev->reg_lock, flags); in viafb_gpio_probe()
247 viafb_gpio_config.gpio_chip.base = -1; /* Dynamic */ in viafb_gpio_probe()
248 viafb_gpio_config.gpio_chip.label = "via-gpio"; in viafb_gpio_probe()
283 spin_lock_irqsave(&viafb_gpio_config.vdev->reg_lock, flags); in viafb_gpio_remove()
287 spin_unlock_irqrestore(&viafb_gpio_config.vdev->reg_lock, flags); in viafb_gpio_remove()
292 .name = "viafb-gpio",