Lines Matching refs:txgpio

47 	struct thunderx_gpio	*txgpio;  member
73 static bool thunderx_gpio_is_gpio_nowarn(struct thunderx_gpio *txgpio, in thunderx_gpio_is_gpio_nowarn() argument
76 u64 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_is_gpio_nowarn()
85 static bool thunderx_gpio_is_gpio(struct thunderx_gpio *txgpio, in thunderx_gpio_is_gpio() argument
88 bool rv = thunderx_gpio_is_gpio_nowarn(txgpio, line); in thunderx_gpio_is_gpio()
97 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_request() local
99 return thunderx_gpio_is_gpio(txgpio, line) ? 0 : -EIO; in thunderx_gpio_request()
104 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_dir_in() local
106 if (!thunderx_gpio_is_gpio(txgpio, line)) in thunderx_gpio_dir_in()
109 raw_spin_lock(&txgpio->lock); in thunderx_gpio_dir_in()
110 clear_bit(line, txgpio->invert_mask); in thunderx_gpio_dir_in()
111 clear_bit(line, txgpio->od_mask); in thunderx_gpio_dir_in()
112 writeq(txgpio->line_entries[line].fil_bits, in thunderx_gpio_dir_in()
113 txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_dir_in()
114 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_dir_in()
121 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_set() local
125 void __iomem *reg = txgpio->register_base + in thunderx_gpio_set()
134 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_dir_out() local
135 u64 bit_cfg = txgpio->line_entries[line].fil_bits | GPIO_BIT_CFG_TX_OE; in thunderx_gpio_dir_out()
137 if (!thunderx_gpio_is_gpio(txgpio, line)) in thunderx_gpio_dir_out()
140 raw_spin_lock(&txgpio->lock); in thunderx_gpio_dir_out()
144 if (test_bit(line, txgpio->invert_mask)) in thunderx_gpio_dir_out()
147 if (test_bit(line, txgpio->od_mask)) in thunderx_gpio_dir_out()
150 writeq(bit_cfg, txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_dir_out()
152 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_dir_out()
158 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_get_direction() local
161 if (!thunderx_gpio_is_gpio_nowarn(txgpio, line)) in thunderx_gpio_get_direction()
169 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_get_direction()
187 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_set_config() local
188 void __iomem *reg = txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET; in thunderx_gpio_set_config()
190 if (!thunderx_gpio_is_gpio(txgpio, line)) in thunderx_gpio_set_config()
193 raw_spin_lock(&txgpio->lock); in thunderx_gpio_set_config()
194 orig_invert = test_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
196 orig_od = test_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
199 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_set_config()
207 set_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
209 set_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
214 clear_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
216 clear_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
233 txgpio->line_entries[line].fil_bits = in thunderx_gpio_set_config()
237 bit_cfg |= txgpio->line_entries[line].fil_bits; in thunderx_gpio_set_config()
238 writeq(bit_cfg, txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_set_config()
244 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_set_config()
259 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_get() local
262 u64 read_bits = readq(txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_RX_DAT); in thunderx_gpio_get()
265 if (test_bit(line, txgpio->invert_mask)) in thunderx_gpio_get()
277 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_set_multiple() local
282 writeq(set_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET); in thunderx_gpio_set_multiple()
283 writeq(clear_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_CLR); in thunderx_gpio_set_multiple()
290 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_ack() local
293 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_ack()
299 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_mask() local
302 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_mask()
308 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_mask_ack() local
311 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_mask_ack()
317 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_unmask() local
320 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_unmask()
327 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_set_type() local
329 &txgpio->line_entries[irqd_to_hwirq(d)]; in thunderx_gpio_irq_set_type()
343 raw_spin_lock(&txgpio->lock); in thunderx_gpio_irq_set_type()
346 set_bit(txline->line, txgpio->invert_mask); in thunderx_gpio_irq_set_type()
348 clear_bit(txline->line, txgpio->invert_mask); in thunderx_gpio_irq_set_type()
350 clear_bit(txline->line, txgpio->od_mask); in thunderx_gpio_irq_set_type()
351 writeq(bit_cfg, txgpio->register_base + bit_cfg_reg(txline->line)); in thunderx_gpio_irq_set_type()
352 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_irq_set_type()
402 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_child_to_parent_hwirq() local
406 irq = txgpio->msix_entries[child].vector; in thunderx_gpio_child_to_parent_hwirq()
431 struct thunderx_gpio *txgpio; in thunderx_gpio_probe() local
437 txgpio = devm_kzalloc(dev, sizeof(*txgpio), GFP_KERNEL); in thunderx_gpio_probe()
438 if (!txgpio) in thunderx_gpio_probe()
441 raw_spin_lock_init(&txgpio->lock); in thunderx_gpio_probe()
442 chip = &txgpio->chip; in thunderx_gpio_probe()
444 pci_set_drvdata(pdev, txgpio); in thunderx_gpio_probe()
459 txgpio->register_base = tbl[0]; in thunderx_gpio_probe()
460 if (!txgpio->register_base) { in thunderx_gpio_probe()
469 txgpio->base_msi = 48; in thunderx_gpio_probe()
471 u64 c = readq(txgpio->register_base + GPIO_CONST); in thunderx_gpio_probe()
474 txgpio->base_msi = (c >> 8) & 0xff; in thunderx_gpio_probe()
477 txgpio->msix_entries = devm_kcalloc(dev, in thunderx_gpio_probe()
480 if (!txgpio->msix_entries) { in thunderx_gpio_probe()
485 txgpio->line_entries = devm_kcalloc(dev, in thunderx_gpio_probe()
489 if (!txgpio->line_entries) { in thunderx_gpio_probe()
495 u64 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(i)); in thunderx_gpio_probe()
497 txgpio->msix_entries[i].entry = txgpio->base_msi + (2 * i); in thunderx_gpio_probe()
498 txgpio->line_entries[i].line = i; in thunderx_gpio_probe()
499 txgpio->line_entries[i].txgpio = txgpio; in thunderx_gpio_probe()
505 txgpio->line_entries[i].fil_bits = bit_cfg ? in thunderx_gpio_probe()
509 set_bit(i, txgpio->od_mask); in thunderx_gpio_probe()
511 set_bit(i, txgpio->invert_mask); in thunderx_gpio_probe()
516 err = pci_enable_msix_range(pdev, txgpio->msix_entries, ngpio, ngpio); in thunderx_gpio_probe()
538 irq_get_irq_data(txgpio->msix_entries[0].vector)->domain; in thunderx_gpio_probe()
544 err = devm_gpiochip_add_data(dev, chip, txgpio); in thunderx_gpio_probe()
557 txgpio->msix_entries[i].vector, in thunderx_gpio_probe()
574 struct thunderx_gpio *txgpio = pci_get_drvdata(pdev); in thunderx_gpio_remove() local
576 for (i = 0; i < txgpio->chip.ngpio; i++) in thunderx_gpio_remove()
577 irq_domain_pop_irq(txgpio->chip.irq.domain, in thunderx_gpio_remove()
578 txgpio->msix_entries[i].vector); in thunderx_gpio_remove()
580 irq_domain_remove(txgpio->chip.irq.domain); in thunderx_gpio_remove()