Lines Matching +full:nr +full:- +full:gpios

1 // SPDX-License-Identifier: GPL-2.0-only
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 */
70 * This structure controls the active GPIOs, which may be a subset
84 static void via_gpio_set(struct gpio_chip *chip, unsigned int nr, in via_gpio_set() argument
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()
104 static int via_gpio_dir_out(struct gpio_chip *chip, unsigned int nr, in via_gpio_dir_out() argument
107 via_gpio_set(chip, nr, value); in via_gpio_dir_out()
115 static int via_gpio_dir_input(struct gpio_chip *chip, unsigned int nr) in via_gpio_dir_input() argument
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()
129 static int via_gpio_get(struct gpio_chip *chip, unsigned int nr) in via_gpio_get() argument
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()
152 .base = -1,
163 via_write_reg_mask(VIASR, gpio->vg_port_index, 0x02, 0x02); in viafb_gpio_enable()
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()
214 * Set up entries for all GPIOs which have been configured to in viafb_gpio_probe()
222 if (gpio->vg_port_index == port_cfg[i].ioport_index) { in viafb_gpio_probe()
225 gpio->vg_name; in viafb_gpio_probe()
233 printk(KERN_INFO "viafb: no GPIOs configured\n"); 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()
252 printk(KERN_ERR "viafb: failed to add gpios (%d)\n", ret); 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",