Lines Matching refs:txgpio
48 struct thunderx_gpio *txgpio; member
74 static bool thunderx_gpio_is_gpio_nowarn(struct thunderx_gpio *txgpio, in thunderx_gpio_is_gpio_nowarn() argument
77 u64 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_is_gpio_nowarn()
86 static bool thunderx_gpio_is_gpio(struct thunderx_gpio *txgpio, in thunderx_gpio_is_gpio() argument
89 bool rv = thunderx_gpio_is_gpio_nowarn(txgpio, line); in thunderx_gpio_is_gpio()
98 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_request() local
100 return thunderx_gpio_is_gpio(txgpio, line) ? 0 : -EIO; in thunderx_gpio_request()
105 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_dir_in() local
107 if (!thunderx_gpio_is_gpio(txgpio, line)) in thunderx_gpio_dir_in()
110 raw_spin_lock(&txgpio->lock); in thunderx_gpio_dir_in()
111 clear_bit(line, txgpio->invert_mask); in thunderx_gpio_dir_in()
112 clear_bit(line, txgpio->od_mask); in thunderx_gpio_dir_in()
113 writeq(txgpio->line_entries[line].fil_bits, in thunderx_gpio_dir_in()
114 txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_dir_in()
115 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_dir_in()
122 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_set() local
126 void __iomem *reg = txgpio->register_base + in thunderx_gpio_set()
135 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_dir_out() local
136 u64 bit_cfg = txgpio->line_entries[line].fil_bits | GPIO_BIT_CFG_TX_OE; in thunderx_gpio_dir_out()
138 if (!thunderx_gpio_is_gpio(txgpio, line)) in thunderx_gpio_dir_out()
141 raw_spin_lock(&txgpio->lock); in thunderx_gpio_dir_out()
145 if (test_bit(line, txgpio->invert_mask)) in thunderx_gpio_dir_out()
148 if (test_bit(line, txgpio->od_mask)) in thunderx_gpio_dir_out()
151 writeq(bit_cfg, txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_dir_out()
153 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_dir_out()
159 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_get_direction() local
162 if (!thunderx_gpio_is_gpio_nowarn(txgpio, line)) in thunderx_gpio_get_direction()
170 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_get_direction()
185 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_set_config() local
186 void __iomem *reg = txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET; in thunderx_gpio_set_config()
188 if (!thunderx_gpio_is_gpio(txgpio, line)) in thunderx_gpio_set_config()
191 raw_spin_lock(&txgpio->lock); in thunderx_gpio_set_config()
192 orig_invert = test_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
194 orig_od = test_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
197 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_set_config()
205 set_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
207 set_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
212 clear_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
214 clear_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
231 txgpio->line_entries[line].fil_bits = in thunderx_gpio_set_config()
235 bit_cfg |= txgpio->line_entries[line].fil_bits; in thunderx_gpio_set_config()
236 writeq(bit_cfg, txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_set_config()
242 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_set_config()
257 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_get() local
260 u64 read_bits = readq(txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_RX_DAT); in thunderx_gpio_get()
263 if (test_bit(line, txgpio->invert_mask)) in thunderx_gpio_get()
275 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_set_multiple() local
280 writeq(set_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET); in thunderx_gpio_set_multiple()
281 writeq(clear_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_CLR); in thunderx_gpio_set_multiple()
288 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_ack() local
291 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_ack()
297 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_mask() local
300 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_mask()
306 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_mask_ack() local
309 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_mask_ack()
315 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_unmask() local
318 txgpio->register_base + intr_reg(irqd_to_hwirq(d))); in thunderx_gpio_irq_unmask()
325 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_irq_set_type() local
327 &txgpio->line_entries[irqd_to_hwirq(d)]; in thunderx_gpio_irq_set_type()
341 raw_spin_lock(&txgpio->lock); in thunderx_gpio_irq_set_type()
344 set_bit(txline->line, txgpio->invert_mask); in thunderx_gpio_irq_set_type()
346 clear_bit(txline->line, txgpio->invert_mask); in thunderx_gpio_irq_set_type()
348 clear_bit(txline->line, txgpio->od_mask); in thunderx_gpio_irq_set_type()
349 writeq(bit_cfg, txgpio->register_base + bit_cfg_reg(txline->line)); in thunderx_gpio_irq_set_type()
350 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_irq_set_type()
394 struct thunderx_gpio *txgpio = gpiochip_get_data(gc); in thunderx_gpio_child_to_parent_hwirq() local
396 *parent = txgpio->base_msi + (2 * child); in thunderx_gpio_child_to_parent_hwirq()
406 struct thunderx_gpio *txgpio; in thunderx_gpio_probe() local
412 txgpio = devm_kzalloc(dev, sizeof(*txgpio), GFP_KERNEL); in thunderx_gpio_probe()
413 if (!txgpio) in thunderx_gpio_probe()
416 raw_spin_lock_init(&txgpio->lock); in thunderx_gpio_probe()
417 chip = &txgpio->chip; in thunderx_gpio_probe()
419 pci_set_drvdata(pdev, txgpio); in thunderx_gpio_probe()
434 txgpio->register_base = tbl[0]; in thunderx_gpio_probe()
435 if (!txgpio->register_base) { in thunderx_gpio_probe()
444 txgpio->base_msi = 48; in thunderx_gpio_probe()
446 u64 c = readq(txgpio->register_base + GPIO_CONST); in thunderx_gpio_probe()
449 txgpio->base_msi = (c >> 8) & 0xff; in thunderx_gpio_probe()
452 txgpio->msix_entries = devm_kcalloc(dev, in thunderx_gpio_probe()
455 if (!txgpio->msix_entries) { in thunderx_gpio_probe()
460 txgpio->line_entries = devm_kcalloc(dev, in thunderx_gpio_probe()
464 if (!txgpio->line_entries) { in thunderx_gpio_probe()
470 u64 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(i)); in thunderx_gpio_probe()
472 txgpio->msix_entries[i].entry = txgpio->base_msi + (2 * i); in thunderx_gpio_probe()
473 txgpio->line_entries[i].line = i; in thunderx_gpio_probe()
474 txgpio->line_entries[i].txgpio = txgpio; in thunderx_gpio_probe()
480 txgpio->line_entries[i].fil_bits = bit_cfg ? in thunderx_gpio_probe()
484 set_bit(i, txgpio->od_mask); in thunderx_gpio_probe()
486 set_bit(i, txgpio->invert_mask); in thunderx_gpio_probe()
491 err = pci_enable_msix_range(pdev, txgpio->msix_entries, ngpio, ngpio); in thunderx_gpio_probe()
513 irq_get_irq_data(txgpio->msix_entries[0].vector)->domain; in thunderx_gpio_probe()
518 err = devm_gpiochip_add_data(dev, chip, txgpio); in thunderx_gpio_probe()
525 txgpio->msix_entries[i].vector, in thunderx_gpio_probe()
542 struct thunderx_gpio *txgpio = pci_get_drvdata(pdev); in thunderx_gpio_remove() local
544 for (i = 0; i < txgpio->chip.ngpio; i++) in thunderx_gpio_remove()
545 irq_domain_pop_irq(txgpio->chip.irq.domain, in thunderx_gpio_remove()
546 txgpio->msix_entries[i].vector); in thunderx_gpio_remove()
548 irq_domain_remove(txgpio->chip.irq.domain); in thunderx_gpio_remove()