Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: xilinx: Rename xilinx_pcie_port to xilinx_pcie

Rename struct xilinx_pcie_port to xilinx_pcie to match the convention of
<driver>_pcie. No functional change intended.

Link: https://lore.kernel.org/r/20211223011054.1227810-23-helgaas@kernel.org
Signed-off-by: Fan Fei <ffclaire1224@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>

authored by

Fan Fei and committed by
Bjorn Helgaas
0519f73a 24d174a1

+79 -79
+79 -79
drivers/pci/controller/pcie-xilinx.c
··· 91 91 #define XILINX_NUM_MSI_IRQS 128 92 92 93 93 /** 94 - * struct xilinx_pcie_port - PCIe port information 95 - * @reg_base: IO Mapped Register Base 94 + * struct xilinx_pcie - PCIe port information 96 95 * @dev: Device pointer 96 + * @reg_base: IO Mapped Register Base 97 97 * @msi_map: Bitmap of allocated MSIs 98 98 * @map_lock: Mutex protecting the MSI allocation 99 99 * @msi_domain: MSI IRQ domain pointer 100 100 * @leg_domain: Legacy IRQ domain pointer 101 101 * @resources: Bus Resources 102 102 */ 103 - struct xilinx_pcie_port { 104 - void __iomem *reg_base; 103 + struct xilinx_pcie { 105 104 struct device *dev; 105 + void __iomem *reg_base; 106 106 unsigned long msi_map[BITS_TO_LONGS(XILINX_NUM_MSI_IRQS)]; 107 107 struct mutex map_lock; 108 108 struct irq_domain *msi_domain; ··· 110 110 struct list_head resources; 111 111 }; 112 112 113 - static inline u32 pcie_read(struct xilinx_pcie_port *port, u32 reg) 113 + static inline u32 pcie_read(struct xilinx_pcie *pcie, u32 reg) 114 114 { 115 - return readl(port->reg_base + reg); 115 + return readl(pcie->reg_base + reg); 116 116 } 117 117 118 - static inline void pcie_write(struct xilinx_pcie_port *port, u32 val, u32 reg) 118 + static inline void pcie_write(struct xilinx_pcie *pcie, u32 val, u32 reg) 119 119 { 120 - writel(val, port->reg_base + reg); 120 + writel(val, pcie->reg_base + reg); 121 121 } 122 122 123 - static inline bool xilinx_pcie_link_up(struct xilinx_pcie_port *port) 123 + static inline bool xilinx_pcie_link_up(struct xilinx_pcie *pcie) 124 124 { 125 - return (pcie_read(port, XILINX_PCIE_REG_PSCR) & 125 + return (pcie_read(pcie, XILINX_PCIE_REG_PSCR) & 126 126 XILINX_PCIE_REG_PSCR_LNKUP) ? 1 : 0; 127 127 } 128 128 129 129 /** 130 130 * xilinx_pcie_clear_err_interrupts - Clear Error Interrupts 131 - * @port: PCIe port information 131 + * @pcie: PCIe port information 132 132 */ 133 - static void xilinx_pcie_clear_err_interrupts(struct xilinx_pcie_port *port) 133 + static void xilinx_pcie_clear_err_interrupts(struct xilinx_pcie *pcie) 134 134 { 135 - struct device *dev = port->dev; 136 - unsigned long val = pcie_read(port, XILINX_PCIE_REG_RPEFR); 135 + struct device *dev = pcie->dev; 136 + unsigned long val = pcie_read(pcie, XILINX_PCIE_REG_RPEFR); 137 137 138 138 if (val & XILINX_PCIE_RPEFR_ERR_VALID) { 139 139 dev_dbg(dev, "Requester ID %lu\n", 140 140 val & XILINX_PCIE_RPEFR_REQ_ID); 141 - pcie_write(port, XILINX_PCIE_RPEFR_ALL_MASK, 141 + pcie_write(pcie, XILINX_PCIE_RPEFR_ALL_MASK, 142 142 XILINX_PCIE_REG_RPEFR); 143 143 } 144 144 } ··· 152 152 */ 153 153 static bool xilinx_pcie_valid_device(struct pci_bus *bus, unsigned int devfn) 154 154 { 155 - struct xilinx_pcie_port *port = bus->sysdata; 155 + struct xilinx_pcie *pcie = bus->sysdata; 156 156 157 - /* Check if link is up when trying to access downstream ports */ 157 + /* Check if link is up when trying to access downstream pcie ports */ 158 158 if (!pci_is_root_bus(bus)) { 159 - if (!xilinx_pcie_link_up(port)) 159 + if (!xilinx_pcie_link_up(pcie)) 160 160 return false; 161 161 } else if (devfn > 0) { 162 162 /* Only one device down on each root port */ ··· 177 177 static void __iomem *xilinx_pcie_map_bus(struct pci_bus *bus, 178 178 unsigned int devfn, int where) 179 179 { 180 - struct xilinx_pcie_port *port = bus->sysdata; 180 + struct xilinx_pcie *pcie = bus->sysdata; 181 181 182 182 if (!xilinx_pcie_valid_device(bus, devfn)) 183 183 return NULL; 184 184 185 - return port->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where); 185 + return pcie->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where); 186 186 } 187 187 188 188 /* PCIe operations */ ··· 215 215 216 216 static void xilinx_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) 217 217 { 218 - struct xilinx_pcie_port *pcie = irq_data_get_irq_chip_data(data); 218 + struct xilinx_pcie *pcie = irq_data_get_irq_chip_data(data); 219 219 phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K); 220 220 221 221 msg->address_lo = lower_32_bits(pa); ··· 232 232 static int xilinx_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, 233 233 unsigned int nr_irqs, void *args) 234 234 { 235 - struct xilinx_pcie_port *port = domain->host_data; 235 + struct xilinx_pcie *pcie = domain->host_data; 236 236 int hwirq, i; 237 237 238 - mutex_lock(&port->map_lock); 238 + mutex_lock(&pcie->map_lock); 239 239 240 - hwirq = bitmap_find_free_region(port->msi_map, XILINX_NUM_MSI_IRQS, order_base_2(nr_irqs)); 240 + hwirq = bitmap_find_free_region(pcie->msi_map, XILINX_NUM_MSI_IRQS, order_base_2(nr_irqs)); 241 241 242 - mutex_unlock(&port->map_lock); 242 + mutex_unlock(&pcie->map_lock); 243 243 244 244 if (hwirq < 0) 245 245 return -ENOSPC; ··· 256 256 unsigned int nr_irqs) 257 257 { 258 258 struct irq_data *d = irq_domain_get_irq_data(domain, virq); 259 - struct xilinx_pcie_port *port = domain->host_data; 259 + struct xilinx_pcie *pcie = domain->host_data; 260 260 261 - mutex_lock(&port->map_lock); 261 + mutex_lock(&pcie->map_lock); 262 262 263 - bitmap_release_region(port->msi_map, d->hwirq, order_base_2(nr_irqs)); 263 + bitmap_release_region(pcie->msi_map, d->hwirq, order_base_2(nr_irqs)); 264 264 265 - mutex_unlock(&port->map_lock); 265 + mutex_unlock(&pcie->map_lock); 266 266 } 267 267 268 268 static const struct irq_domain_ops xilinx_msi_domain_ops = { ··· 275 275 .chip = &xilinx_msi_top_chip, 276 276 }; 277 277 278 - static int xilinx_allocate_msi_domains(struct xilinx_pcie_port *pcie) 278 + static int xilinx_allocate_msi_domains(struct xilinx_pcie *pcie) 279 279 { 280 280 struct fwnode_handle *fwnode = dev_fwnode(pcie->dev); 281 281 struct irq_domain *parent; ··· 298 298 return 0; 299 299 } 300 300 301 - static void xilinx_free_msi_domains(struct xilinx_pcie_port *pcie) 301 + static void xilinx_free_msi_domains(struct xilinx_pcie *pcie) 302 302 { 303 303 struct irq_domain *parent = pcie->msi_domain->parent; 304 304 ··· 342 342 */ 343 343 static irqreturn_t xilinx_pcie_intr_handler(int irq, void *data) 344 344 { 345 - struct xilinx_pcie_port *port = (struct xilinx_pcie_port *)data; 346 - struct device *dev = port->dev; 345 + struct xilinx_pcie *pcie = (struct xilinx_pcie *)data; 346 + struct device *dev = pcie->dev; 347 347 u32 val, mask, status; 348 348 349 349 /* Read interrupt decode and mask registers */ 350 - val = pcie_read(port, XILINX_PCIE_REG_IDR); 351 - mask = pcie_read(port, XILINX_PCIE_REG_IMR); 350 + val = pcie_read(pcie, XILINX_PCIE_REG_IDR); 351 + mask = pcie_read(pcie, XILINX_PCIE_REG_IMR); 352 352 353 353 status = val & mask; 354 354 if (!status) ··· 371 371 372 372 if (status & XILINX_PCIE_INTR_CORRECTABLE) { 373 373 dev_warn(dev, "Correctable error message\n"); 374 - xilinx_pcie_clear_err_interrupts(port); 374 + xilinx_pcie_clear_err_interrupts(pcie); 375 375 } 376 376 377 377 if (status & XILINX_PCIE_INTR_NONFATAL) { 378 378 dev_warn(dev, "Non fatal error message\n"); 379 - xilinx_pcie_clear_err_interrupts(port); 379 + xilinx_pcie_clear_err_interrupts(pcie); 380 380 } 381 381 382 382 if (status & XILINX_PCIE_INTR_FATAL) { 383 383 dev_warn(dev, "Fatal error message\n"); 384 - xilinx_pcie_clear_err_interrupts(port); 384 + xilinx_pcie_clear_err_interrupts(pcie); 385 385 } 386 386 387 387 if (status & (XILINX_PCIE_INTR_INTX | XILINX_PCIE_INTR_MSI)) { 388 388 struct irq_domain *domain; 389 389 390 - val = pcie_read(port, XILINX_PCIE_REG_RPIFR1); 390 + val = pcie_read(pcie, XILINX_PCIE_REG_RPIFR1); 391 391 392 392 /* Check whether interrupt valid */ 393 393 if (!(val & XILINX_PCIE_RPIFR1_INTR_VALID)) { ··· 397 397 398 398 /* Decode the IRQ number */ 399 399 if (val & XILINX_PCIE_RPIFR1_MSI_INTR) { 400 - val = pcie_read(port, XILINX_PCIE_REG_RPIFR2) & 400 + val = pcie_read(pcie, XILINX_PCIE_REG_RPIFR2) & 401 401 XILINX_PCIE_RPIFR2_MSG_DATA; 402 - domain = port->msi_domain->parent; 402 + domain = pcie->msi_domain->parent; 403 403 } else { 404 404 val = (val & XILINX_PCIE_RPIFR1_INTR_MASK) >> 405 405 XILINX_PCIE_RPIFR1_INTR_SHIFT; 406 - domain = port->leg_domain; 406 + domain = pcie->leg_domain; 407 407 } 408 408 409 409 /* Clear interrupt FIFO register 1 */ 410 - pcie_write(port, XILINX_PCIE_RPIFR1_ALL_MASK, 410 + pcie_write(pcie, XILINX_PCIE_RPIFR1_ALL_MASK, 411 411 XILINX_PCIE_REG_RPIFR1); 412 412 413 413 generic_handle_domain_irq(domain, val); ··· 442 442 443 443 error: 444 444 /* Clear the Interrupt Decode register */ 445 - pcie_write(port, status, XILINX_PCIE_REG_IDR); 445 + pcie_write(pcie, status, XILINX_PCIE_REG_IDR); 446 446 447 447 return IRQ_HANDLED; 448 448 } 449 449 450 450 /** 451 451 * xilinx_pcie_init_irq_domain - Initialize IRQ domain 452 - * @port: PCIe port information 452 + * @pcie: PCIe port information 453 453 * 454 454 * Return: '0' on success and error value on failure 455 455 */ 456 - static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port) 456 + static int xilinx_pcie_init_irq_domain(struct xilinx_pcie *pcie) 457 457 { 458 - struct device *dev = port->dev; 458 + struct device *dev = pcie->dev; 459 459 struct device_node *pcie_intc_node; 460 460 int ret; 461 461 ··· 466 466 return -ENODEV; 467 467 } 468 468 469 - port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, 469 + pcie->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, 470 470 &intx_domain_ops, 471 - port); 471 + pcie); 472 472 of_node_put(pcie_intc_node); 473 - if (!port->leg_domain) { 473 + if (!pcie->leg_domain) { 474 474 dev_err(dev, "Failed to get a INTx IRQ domain\n"); 475 475 return -ENODEV; 476 476 } 477 477 478 478 /* Setup MSI */ 479 479 if (IS_ENABLED(CONFIG_PCI_MSI)) { 480 - phys_addr_t pa = ALIGN_DOWN(virt_to_phys(port), SZ_4K); 480 + phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K); 481 481 482 - ret = xilinx_allocate_msi_domains(port); 482 + ret = xilinx_allocate_msi_domains(pcie); 483 483 if (ret) 484 484 return ret; 485 485 486 - pcie_write(port, upper_32_bits(pa), XILINX_PCIE_REG_MSIBASE1); 487 - pcie_write(port, lower_32_bits(pa), XILINX_PCIE_REG_MSIBASE2); 486 + pcie_write(pcie, upper_32_bits(pa), XILINX_PCIE_REG_MSIBASE1); 487 + pcie_write(pcie, lower_32_bits(pa), XILINX_PCIE_REG_MSIBASE2); 488 488 } 489 489 490 490 return 0; ··· 492 492 493 493 /** 494 494 * xilinx_pcie_init_port - Initialize hardware 495 - * @port: PCIe port information 495 + * @pcie: PCIe port information 496 496 */ 497 - static void xilinx_pcie_init_port(struct xilinx_pcie_port *port) 497 + static void xilinx_pcie_init_port(struct xilinx_pcie *pcie) 498 498 { 499 - struct device *dev = port->dev; 499 + struct device *dev = pcie->dev; 500 500 501 - if (xilinx_pcie_link_up(port)) 501 + if (xilinx_pcie_link_up(pcie)) 502 502 dev_info(dev, "PCIe Link is UP\n"); 503 503 else 504 504 dev_info(dev, "PCIe Link is DOWN\n"); 505 505 506 506 /* Disable all interrupts */ 507 - pcie_write(port, ~XILINX_PCIE_IDR_ALL_MASK, 507 + pcie_write(pcie, ~XILINX_PCIE_IDR_ALL_MASK, 508 508 XILINX_PCIE_REG_IMR); 509 509 510 510 /* Clear pending interrupts */ 511 - pcie_write(port, pcie_read(port, XILINX_PCIE_REG_IDR) & 511 + pcie_write(pcie, pcie_read(pcie, XILINX_PCIE_REG_IDR) & 512 512 XILINX_PCIE_IMR_ALL_MASK, 513 513 XILINX_PCIE_REG_IDR); 514 514 515 515 /* Enable all interrupts we handle */ 516 - pcie_write(port, XILINX_PCIE_IMR_ENABLE_MASK, XILINX_PCIE_REG_IMR); 516 + pcie_write(pcie, XILINX_PCIE_IMR_ENABLE_MASK, XILINX_PCIE_REG_IMR); 517 517 518 518 /* Enable the Bridge enable bit */ 519 - pcie_write(port, pcie_read(port, XILINX_PCIE_REG_RPSC) | 519 + pcie_write(pcie, pcie_read(pcie, XILINX_PCIE_REG_RPSC) | 520 520 XILINX_PCIE_REG_RPSC_BEN, 521 521 XILINX_PCIE_REG_RPSC); 522 522 } 523 523 524 524 /** 525 525 * xilinx_pcie_parse_dt - Parse Device tree 526 - * @port: PCIe port information 526 + * @pcie: PCIe port information 527 527 * 528 528 * Return: '0' on success and error value on failure 529 529 */ 530 - static int xilinx_pcie_parse_dt(struct xilinx_pcie_port *port) 530 + static int xilinx_pcie_parse_dt(struct xilinx_pcie *pcie) 531 531 { 532 - struct device *dev = port->dev; 532 + struct device *dev = pcie->dev; 533 533 struct device_node *node = dev->of_node; 534 534 struct resource regs; 535 535 unsigned int irq; ··· 541 541 return err; 542 542 } 543 543 544 - port->reg_base = devm_pci_remap_cfg_resource(dev, &regs); 545 - if (IS_ERR(port->reg_base)) 546 - return PTR_ERR(port->reg_base); 544 + pcie->reg_base = devm_pci_remap_cfg_resource(dev, &regs); 545 + if (IS_ERR(pcie->reg_base)) 546 + return PTR_ERR(pcie->reg_base); 547 547 548 548 irq = irq_of_parse_and_map(node, 0); 549 549 err = devm_request_irq(dev, irq, xilinx_pcie_intr_handler, 550 550 IRQF_SHARED | IRQF_NO_THREAD, 551 - "xilinx-pcie", port); 551 + "xilinx-pcie", pcie); 552 552 if (err) { 553 553 dev_err(dev, "unable to request irq %d\n", irq); 554 554 return err; ··· 566 566 static int xilinx_pcie_probe(struct platform_device *pdev) 567 567 { 568 568 struct device *dev = &pdev->dev; 569 - struct xilinx_pcie_port *port; 569 + struct xilinx_pcie *pcie; 570 570 struct pci_host_bridge *bridge; 571 571 int err; 572 572 573 573 if (!dev->of_node) 574 574 return -ENODEV; 575 575 576 - bridge = devm_pci_alloc_host_bridge(dev, sizeof(*port)); 576 + bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); 577 577 if (!bridge) 578 578 return -ENODEV; 579 579 580 - port = pci_host_bridge_priv(bridge); 581 - mutex_init(&port->map_lock); 582 - port->dev = dev; 580 + pcie = pci_host_bridge_priv(bridge); 581 + mutex_init(&pcie->map_lock); 582 + pcie->dev = dev; 583 583 584 - err = xilinx_pcie_parse_dt(port); 584 + err = xilinx_pcie_parse_dt(pcie); 585 585 if (err) { 586 586 dev_err(dev, "Parsing DT failed\n"); 587 587 return err; 588 588 } 589 589 590 - xilinx_pcie_init_port(port); 590 + xilinx_pcie_init_port(pcie); 591 591 592 - err = xilinx_pcie_init_irq_domain(port); 592 + err = xilinx_pcie_init_irq_domain(pcie); 593 593 if (err) { 594 594 dev_err(dev, "Failed creating IRQ Domain\n"); 595 595 return err; 596 596 } 597 597 598 - bridge->sysdata = port; 598 + bridge->sysdata = pcie; 599 599 bridge->ops = &xilinx_pcie_ops; 600 600 601 601 err = pci_host_probe(bridge); 602 602 if (err) 603 - xilinx_free_msi_domains(port); 603 + xilinx_free_msi_domains(pcie); 604 604 605 605 return err; 606 606 }