Lines Matching +full:nr +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0-only
11 #include <linux/via-core.h>
12 #include <linux/via-gpio.h>
16 * The ports we know about. Note that the port-25 gpios are not
29 .vg_name = "VGPIO0", /* Guess - not in datasheet */
69 * This structure controls the active GPIOs, which may be a subset
83 static void via_gpio_set(struct gpio_chip *chip, unsigned int nr, in via_gpio_set() argument
91 spin_lock_irqsave(&cfg->vdev->reg_lock, flags); in via_gpio_set()
92 gpio = cfg->active_gpios[nr]; in via_gpio_set()
93 reg = via_read_reg(VIASR, gpio->vg_port_index); in via_gpio_set()
94 reg |= 0x40 << gpio->vg_mask_shift; /* output enable */ in via_gpio_set()
96 reg |= 0x10 << gpio->vg_mask_shift; in via_gpio_set()
98 reg &= ~(0x10 << gpio->vg_mask_shift); in via_gpio_set()
99 via_write_reg(VIASR, gpio->vg_port_index, reg); in via_gpio_set()
100 spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); in via_gpio_set()
103 static int via_gpio_dir_out(struct gpio_chip *chip, unsigned int nr, in via_gpio_dir_out() argument
106 via_gpio_set(chip, nr, value); in via_gpio_dir_out()
114 static int via_gpio_dir_input(struct gpio_chip *chip, unsigned int nr) in via_gpio_dir_input() argument
120 spin_lock_irqsave(&cfg->vdev->reg_lock, flags); in via_gpio_dir_input()
121 gpio = cfg->active_gpios[nr]; in via_gpio_dir_input()
122 via_write_reg_mask(VIASR, gpio->vg_port_index, 0, in via_gpio_dir_input()
123 0x40 << gpio->vg_mask_shift); in via_gpio_dir_input()
124 spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); in via_gpio_dir_input()
128 static int via_gpio_get(struct gpio_chip *chip, unsigned int nr) in via_gpio_get() argument
135 spin_lock_irqsave(&cfg->vdev->reg_lock, flags); in via_gpio_get()
136 gpio = cfg->active_gpios[nr]; in via_gpio_get()
137 reg = via_read_reg(VIASR, gpio->vg_port_index); in via_gpio_get()
138 spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); in via_gpio_get()
139 return !!(reg & (0x04 << gpio->vg_mask_shift)); in via_gpio_get()
151 .base = -1,
162 via_write_reg_mask(VIASR, gpio->vg_port_index, 0x02, 0x02); in viafb_gpio_enable()
167 via_write_reg_mask(VIASR, gpio->vg_port_index, 0, 0x02); in viafb_gpio_disable()
200 if (!strcmp(name, viafb_gpio_config.active_gpios[i]->vg_name)) in viafb_gpio_lookup()
202 return -1; in viafb_gpio_lookup()
211 struct viafb_dev *vdev = platdev->dev.platform_data; in viafb_gpio_probe()
212 struct via_port_cfg *port_cfg = vdev->port_cfg; in viafb_gpio_probe()
218 * Set up entries for all GPIOs which have been configured to in viafb_gpio_probe()
226 if (gpio->vg_port_index == port_cfg[i].ioport_index) { in viafb_gpio_probe()
229 gpio->vg_name; in viafb_gpio_probe()
237 printk(KERN_INFO "viafb: no GPIOs configured\n"); in viafb_gpio_probe()
244 spin_lock_irqsave(&viafb_gpio_config.vdev->reg_lock, flags); in viafb_gpio_probe()
247 spin_unlock_irqrestore(&viafb_gpio_config.vdev->reg_lock, flags); in viafb_gpio_probe()
251 viafb_gpio_config.gpio_chip.base = -1; /* Dynamic */ in viafb_gpio_probe()
255 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()
293 .name = "viafb-gpio",