Lines Matching refs:txgpio

48 	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()
186 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_set_config() local
187 void __iomem *reg = txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET; in thunderx_gpio_set_config()
189 if (!thunderx_gpio_is_gpio(txgpio, line)) in thunderx_gpio_set_config()
192 raw_spin_lock(&txgpio->lock); in thunderx_gpio_set_config()
193 orig_invert = test_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
195 orig_od = test_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
198 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_set_config()
206 set_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
208 set_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
213 clear_bit(line, txgpio->invert_mask); in thunderx_gpio_set_config()
215 clear_bit(line, txgpio->od_mask); in thunderx_gpio_set_config()
232 txgpio->line_entries[line].fil_bits = in thunderx_gpio_set_config()
236 bit_cfg |= txgpio->line_entries[line].fil_bits; in thunderx_gpio_set_config()
237 writeq(bit_cfg, txgpio->register_base + bit_cfg_reg(line)); in thunderx_gpio_set_config()
243 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_set_config()
258 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_get() local
261 u64 read_bits = readq(txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_RX_DAT); in thunderx_gpio_get()
264 if (test_bit(line, txgpio->invert_mask)) in thunderx_gpio_get()
276 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_set_multiple() local
281 writeq(set_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET); in thunderx_gpio_set_multiple()
282 writeq(clear_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_CLR); in thunderx_gpio_set_multiple()
291 txline->txgpio->register_base + intr_reg(txline->line)); in thunderx_gpio_irq_ack()
299 txline->txgpio->register_base + intr_reg(txline->line)); in thunderx_gpio_irq_mask()
307 txline->txgpio->register_base + intr_reg(txline->line)); in thunderx_gpio_irq_mask_ack()
315 txline->txgpio->register_base + intr_reg(txline->line)); in thunderx_gpio_irq_unmask()
322 struct thunderx_gpio *txgpio = txline->txgpio; in thunderx_gpio_irq_set_type() local
336 raw_spin_lock(&txgpio->lock); in thunderx_gpio_irq_set_type()
339 set_bit(txline->line, txgpio->invert_mask); in thunderx_gpio_irq_set_type()
341 clear_bit(txline->line, txgpio->invert_mask); in thunderx_gpio_irq_set_type()
343 clear_bit(txline->line, txgpio->od_mask); in thunderx_gpio_irq_set_type()
344 writeq(bit_cfg, txgpio->register_base + bit_cfg_reg(txline->line)); in thunderx_gpio_irq_set_type()
345 raw_spin_unlock(&txgpio->lock); in thunderx_gpio_irq_set_type()
365 struct thunderx_gpio *txgpio = txline->txgpio; in thunderx_gpio_irq_request_resources() local
369 r = gpiochip_lock_as_irq(&txgpio->chip, txline->line); in thunderx_gpio_irq_request_resources()
381 gpiochip_unlock_as_irq(&txgpio->chip, txline->line); in thunderx_gpio_irq_request_resources()
388 struct thunderx_gpio *txgpio = txline->txgpio; in thunderx_gpio_irq_release_resources() local
394 gpiochip_unlock_as_irq(&txgpio->chip, txline->line); in thunderx_gpio_irq_release_resources()
425 struct thunderx_gpio *txgpio = d->host_data; in thunderx_gpio_irq_translate() local
429 if (fwspec->param[0] >= txgpio->chip.ngpio) in thunderx_gpio_irq_translate()
452 struct thunderx_gpio *txgpio = gpiochip_get_data(chip); in thunderx_gpio_to_irq() local
454 return irq_find_mapping(txgpio->irqd, offset); in thunderx_gpio_to_irq()
462 struct thunderx_gpio *txgpio; in thunderx_gpio_probe() local
467 txgpio = devm_kzalloc(dev, sizeof(*txgpio), GFP_KERNEL); in thunderx_gpio_probe()
468 if (!txgpio) in thunderx_gpio_probe()
471 raw_spin_lock_init(&txgpio->lock); in thunderx_gpio_probe()
472 chip = &txgpio->chip; in thunderx_gpio_probe()
474 pci_set_drvdata(pdev, txgpio); in thunderx_gpio_probe()
489 txgpio->register_base = tbl[0]; in thunderx_gpio_probe()
490 if (!txgpio->register_base) { in thunderx_gpio_probe()
499 txgpio->base_msi = 48; in thunderx_gpio_probe()
501 u64 c = readq(txgpio->register_base + GPIO_CONST); in thunderx_gpio_probe()
504 txgpio->base_msi = (c >> 8) & 0xff; in thunderx_gpio_probe()
507 txgpio->msix_entries = devm_kcalloc(dev, in thunderx_gpio_probe()
510 if (!txgpio->msix_entries) { in thunderx_gpio_probe()
515 txgpio->line_entries = devm_kcalloc(dev, in thunderx_gpio_probe()
519 if (!txgpio->line_entries) { in thunderx_gpio_probe()
525 u64 bit_cfg = readq(txgpio->register_base + bit_cfg_reg(i)); in thunderx_gpio_probe()
527 txgpio->msix_entries[i].entry = txgpio->base_msi + (2 * i); in thunderx_gpio_probe()
528 txgpio->line_entries[i].line = i; in thunderx_gpio_probe()
529 txgpio->line_entries[i].txgpio = txgpio; in thunderx_gpio_probe()
535 txgpio->line_entries[i].fil_bits = bit_cfg ? in thunderx_gpio_probe()
539 set_bit(i, txgpio->od_mask); in thunderx_gpio_probe()
541 set_bit(i, txgpio->invert_mask); in thunderx_gpio_probe()
546 err = pci_enable_msix_range(pdev, txgpio->msix_entries, ngpio, ngpio); in thunderx_gpio_probe()
554txgpio->irqd = irq_domain_create_hierarchy(irq_get_irq_data(txgpio->msix_entries[0].vector)->domai… in thunderx_gpio_probe()
556 &thunderx_gpio_irqd_ops, txgpio); in thunderx_gpio_probe()
557 if (!txgpio->irqd) { in thunderx_gpio_probe()
564 err = irq_domain_push_irq(txgpio->irqd, in thunderx_gpio_probe()
565 txgpio->msix_entries[i].vector, in thunderx_gpio_probe()
566 &txgpio->line_entries[i]); in thunderx_gpio_probe()
586 err = devm_gpiochip_add_data(dev, chip, txgpio); in thunderx_gpio_probe()
601 struct thunderx_gpio *txgpio = pci_get_drvdata(pdev); in thunderx_gpio_remove() local
603 for (i = 0; i < txgpio->chip.ngpio; i++) in thunderx_gpio_remove()
604 irq_domain_pop_irq(txgpio->irqd, in thunderx_gpio_remove()
605 txgpio->msix_entries[i].vector); in thunderx_gpio_remove()
607 irq_domain_remove(txgpio->irqd); in thunderx_gpio_remove()