Lines Matching refs:apc
56 static inline bool ar724x_pci_check_link(struct ar724x_pci_controller *apc) in ar724x_pci_check_link() argument
60 reset = __raw_readl(apc->ctrl_base + AR724X_PCI_REG_RESET); in ar724x_pci_check_link()
73 static int ar724x_pci_local_write(struct ar724x_pci_controller *apc, in ar724x_pci_local_write() argument
82 if (!apc->link_up) in ar724x_pci_local_write()
85 base = apc->crp_base; in ar724x_pci_local_write()
116 struct ar724x_pci_controller *apc; in ar724x_pci_read() local
120 apc = pci_bus_to_ar724x_controller(bus); in ar724x_pci_read()
121 if (!apc->link_up) in ar724x_pci_read()
127 base = apc->devcfg_base; in ar724x_pci_read()
150 apc->bar0_is_cached) { in ar724x_pci_read()
152 *value = apc->bar0_value; in ar724x_pci_read()
163 struct ar724x_pci_controller *apc; in ar724x_pci_write() local
168 apc = pci_bus_to_ar724x_controller(bus); in ar724x_pci_write()
169 if (!apc->link_up) in ar724x_pci_write()
187 apc->bar0_is_cached = true; in ar724x_pci_write()
188 apc->bar0_value = value; in ar724x_pci_write()
192 apc->bar0_is_cached = false; in ar724x_pci_write()
196 base = apc->devcfg_base; in ar724x_pci_write()
231 struct ar724x_pci_controller *apc; in ar724x_pci_irq_handler() local
235 apc = irq_desc_get_handler_data(desc); in ar724x_pci_irq_handler()
236 base = apc->ctrl_base; in ar724x_pci_irq_handler()
242 generic_handle_irq(apc->irq_base + 0); in ar724x_pci_irq_handler()
250 struct ar724x_pci_controller *apc; in ar724x_pci_irq_unmask() local
255 apc = irq_data_get_irq_chip_data(d); in ar724x_pci_irq_unmask()
256 base = apc->ctrl_base; in ar724x_pci_irq_unmask()
257 offset = apc->irq_base - d->irq; in ar724x_pci_irq_unmask()
271 struct ar724x_pci_controller *apc; in ar724x_pci_irq_mask() local
276 apc = irq_data_get_irq_chip_data(d); in ar724x_pci_irq_mask()
277 base = apc->ctrl_base; in ar724x_pci_irq_mask()
278 offset = apc->irq_base - d->irq; in ar724x_pci_irq_mask()
305 static void ar724x_pci_irq_init(struct ar724x_pci_controller *apc, in ar724x_pci_irq_init() argument
311 base = apc->ctrl_base; in ar724x_pci_irq_init()
316 apc->irq_base = ATH79_PCI_IRQ_BASE + (id * AR724X_PCI_IRQ_COUNT); in ar724x_pci_irq_init()
318 for (i = apc->irq_base; in ar724x_pci_irq_init()
319 i < apc->irq_base + AR724X_PCI_IRQ_COUNT; i++) { in ar724x_pci_irq_init()
322 irq_set_chip_data(i, apc); in ar724x_pci_irq_init()
325 irq_set_chained_handler_and_data(apc->irq, ar724x_pci_irq_handler, in ar724x_pci_irq_init()
326 apc); in ar724x_pci_irq_init()
329 static void ar724x_pci_hw_init(struct ar724x_pci_controller *apc) in ar724x_pci_hw_init() argument
349 app = __raw_readl(apc->ctrl_base + AR724X_PCI_REG_APP); in ar724x_pci_hw_init()
351 __raw_writel(app, apc->ctrl_base + AR724X_PCI_REG_APP); in ar724x_pci_hw_init()
357 } while (wait < 10 && !ar724x_pci_check_link(apc)); in ar724x_pci_hw_init()
362 struct ar724x_pci_controller *apc; in ar724x_pci_probe() local
370 apc = devm_kzalloc(&pdev->dev, sizeof(struct ar724x_pci_controller), in ar724x_pci_probe()
372 if (!apc) in ar724x_pci_probe()
375 apc->ctrl_base = devm_platform_ioremap_resource_byname(pdev, "ctrl_base"); in ar724x_pci_probe()
376 if (IS_ERR(apc->ctrl_base)) in ar724x_pci_probe()
377 return PTR_ERR(apc->ctrl_base); in ar724x_pci_probe()
379 apc->devcfg_base = devm_platform_ioremap_resource_byname(pdev, "cfg_base"); in ar724x_pci_probe()
380 if (IS_ERR(apc->devcfg_base)) in ar724x_pci_probe()
381 return PTR_ERR(apc->devcfg_base); in ar724x_pci_probe()
383 apc->crp_base = devm_platform_ioremap_resource_byname(pdev, "crp_base"); in ar724x_pci_probe()
384 if (IS_ERR(apc->crp_base)) in ar724x_pci_probe()
385 return PTR_ERR(apc->crp_base); in ar724x_pci_probe()
387 apc->irq = platform_get_irq(pdev, 0); in ar724x_pci_probe()
388 if (apc->irq < 0) in ar724x_pci_probe()
395 apc->io_res.parent = res; in ar724x_pci_probe()
396 apc->io_res.name = "PCI IO space"; in ar724x_pci_probe()
397 apc->io_res.start = res->start; in ar724x_pci_probe()
398 apc->io_res.end = res->end; in ar724x_pci_probe()
399 apc->io_res.flags = IORESOURCE_IO; in ar724x_pci_probe()
405 apc->mem_res.parent = res; in ar724x_pci_probe()
406 apc->mem_res.name = "PCI memory space"; in ar724x_pci_probe()
407 apc->mem_res.start = res->start; in ar724x_pci_probe()
408 apc->mem_res.end = res->end; in ar724x_pci_probe()
409 apc->mem_res.flags = IORESOURCE_MEM; in ar724x_pci_probe()
411 apc->pci_controller.pci_ops = &ar724x_pci_ops; in ar724x_pci_probe()
412 apc->pci_controller.io_resource = &apc->io_res; in ar724x_pci_probe()
413 apc->pci_controller.mem_resource = &apc->mem_res; in ar724x_pci_probe()
420 ar724x_pci_hw_init(apc); in ar724x_pci_probe()
422 apc->link_up = ar724x_pci_check_link(apc); in ar724x_pci_probe()
423 if (!apc->link_up) in ar724x_pci_probe()
426 ar724x_pci_irq_init(apc, id); in ar724x_pci_probe()
428 ar724x_pci_local_write(apc, PCI_COMMAND, 4, AR724X_PCI_CMD_INIT); in ar724x_pci_probe()
430 register_pci_controller(&apc->pci_controller); in ar724x_pci_probe()