Lines Matching refs:txgpio
49 struct thunderx_gpio *txgpio; member
75 static bool thunderx_gpio_is_gpio_nowarn(struct thunderx_gpio *txgpio, in thunderx_gpio_is_gpio_nowarn() argument
78 u64 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_is_gpio_nowarn()
87 static bool thunderx_gpio_is_gpio(struct thunderx_gpio *txgpio, in thunderx_gpio_is_gpio() argument
90 bool rv = thunderx_gpio_is_gpio_nowarn(txgpio, line); in thunderx_gpio_is_gpio()
99 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_request() local
101 return thunderx_gpio_is_gpio(txgpio, line) ? 0 : -EIO; in thunderx_gpio_request()
106 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_dir_in() local
108 if (!thunderx_gpio_is_gpio(txgpio, line)) in thunderx_gpio_dir_in()
111 raw_spin_lock(&txgpio->lock); in thunderx_gpio_dir_in()
112 clear_bit(line, txgpio->invert_mask); in thunderx_gpio_dir_in()
113 clear_bit(line, txgpio->od_mask); in thunderx_gpio_dir_in()
114 writeq(txgpio->line_entries[line].fil_bits, in thunderx_gpio_dir_in()
115 txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_dir_in()
116 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_dir_in()
123 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_set() local
127 void __iomem *reg = txgpio->register_base + in thunderx_gpio_set()
136 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_dir_out() local
137 u64 bit_cfg = txgpio->line_entries[line].fil_bits | GPIO_BIT_CFG_TX_OE; in thunderx_gpio_dir_out()
139 if (!thunderx_gpio_is_gpio(txgpio, line)) in thunderx_gpio_dir_out()
142 raw_spin_lock(&txgpio->lock); in thunderx_gpio_dir_out()
146 if (test_bit(line, txgpio->invert_mask)) in thunderx_gpio_dir_out()
149 if (test_bit(line, txgpio->od_mask)) in thunderx_gpio_dir_out()
152 writeq(bit_cfg, txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_dir_out()
154 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_dir_out()
160 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_get_direction() local
163 if (!thunderx_gpio_is_gpio_nowarn(txgpio, line)) in thunderx_gpio_get_direction()
171 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_get_direction()
189 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_set_config() local
190 void __iomem *reg = txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET; in thunderx_gpio_set_config()
192 if (!thunderx_gpio_is_gpio(txgpio, line)) in thunderx_gpio_set_config()
195 raw_spin_lock(&txgpio->lock); in thunderx_gpio_set_config()
196 orig_invert = test_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
198 orig_od = test_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
201 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_set_config()
209 set_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
211 set_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
216 clear_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
218 clear_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
235 txgpio->line_entries[line].fil_bits = in thunderx_gpio_set_config()
239 bit_cfg |= txgpio->line_entries[line].fil_bits; in thunderx_gpio_set_config()
240 writeq(bit_cfg, txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_set_config()
246 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_set_config()
261 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_get() local
264 u64 read_bits = readq(txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_RX_DAT); in thunderx_gpio_get()
267 if (test_bit(line, txgpio->invert_mask)) in thunderx_gpio_get()
279 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_set_multiple() local
284 writeq(set_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET); in thunderx_gpio_set_multiple()
285 writeq(clear_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_CLR); in thunderx_gpio_set_multiple()
292 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_ack() local
295 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_ack()
301 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_mask() local
304 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_mask()
310 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_mask_ack() local
313 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_mask_ack()
319 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_unmask() local
322 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_unmask()
329 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_set_type() local
331 &txgpio->line_entries[irqd_to_hwirq(d)]; in thunderx_gpio_irq_set_type()
345 raw_spin_lock(&txgpio->lock); in thunderx_gpio_irq_set_type()
348 set_bit(txline->line, txgpio->invert_mask); in thunderx_gpio_irq_set_type()
350 clear_bit(txline->line, txgpio->invert_mask); in thunderx_gpio_irq_set_type()
352 clear_bit(txline->line, txgpio->od_mask); in thunderx_gpio_irq_set_type()
353 writeq(bit_cfg, txgpio->register_base + bit_cfg_reg(txline->line)); in thunderx_gpio_irq_set_type()
354 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_irq_set_type()
398 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_child_to_parent_hwirq() local
402 irq = txgpio->msix_entries[child].vector; in thunderx_gpio_child_to_parent_hwirq()
430 struct thunderx_gpio *txgpio; in thunderx_gpio_probe() local
436 txgpio = devm_kzalloc(dev, sizeof(*txgpio), GFP_KERNEL); in thunderx_gpio_probe()
437 if (!txgpio) in thunderx_gpio_probe()
440 raw_spin_lock_init(&txgpio->lock); in thunderx_gpio_probe()
441 chip = &txgpio->chip; in thunderx_gpio_probe()
443 pci_set_drvdata(pdev, txgpio); in thunderx_gpio_probe()
458 txgpio->register_base = tbl[0]; in thunderx_gpio_probe()
459 if (!txgpio->register_base) { in thunderx_gpio_probe()
468 txgpio->base_msi = 48; in thunderx_gpio_probe()
470 u64 c = readq(txgpio->register_base + GPIO_CONST); in thunderx_gpio_probe()
473 txgpio->base_msi = (c >> 8) & 0xff; in thunderx_gpio_probe()
476 txgpio->msix_entries = devm_kcalloc(dev, in thunderx_gpio_probe()
479 if (!txgpio->msix_entries) { in thunderx_gpio_probe()
484 txgpio->line_entries = devm_kcalloc(dev, in thunderx_gpio_probe()
488 if (!txgpio->line_entries) { in thunderx_gpio_probe()
494 u64 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(i)); in thunderx_gpio_probe()
496 txgpio->msix_entries[i].entry = txgpio->base_msi + (2 * i); in thunderx_gpio_probe()
497 txgpio->line_entries[i].line = i; in thunderx_gpio_probe()
498 txgpio->line_entries[i].txgpio = txgpio; in thunderx_gpio_probe()
504 txgpio->line_entries[i].fil_bits = bit_cfg ? in thunderx_gpio_probe()
508 set_bit(i, txgpio->od_mask); in thunderx_gpio_probe()
510 set_bit(i, txgpio->invert_mask); in thunderx_gpio_probe()
515 err = pci_enable_msix_range(pdev, txgpio->msix_entries, ngpio, ngpio); in thunderx_gpio_probe()
537 irq_get_irq_data(txgpio->msix_entries[0].vector)->domain; in thunderx_gpio_probe()
543 err = devm_gpiochip_add_data(dev, chip, txgpio); in thunderx_gpio_probe()
556 txgpio->msix_entries[i].vector, in thunderx_gpio_probe()
573 struct thunderx_gpio *txgpio = pci_get_drvdata(pdev); in thunderx_gpio_remove() local
575 for (i = 0; i < txgpio->chip.ngpio; i++) in thunderx_gpio_remove()
576 irq_domain_pop_irq(txgpio->chip.irq.domain, in thunderx_gpio_remove()
577 txgpio->msix_entries[i].vector); in thunderx_gpio_remove()
579 irq_domain_remove(txgpio->chip.irq.domain); in thunderx_gpio_remove()