Lines Matching refs:apc

191 static inline u32 ar2315_pci_reg_read(struct ar2315_pci_ctrl *apc, u32 reg)  in ar2315_pci_reg_read()  argument
193 return __raw_readl(apc->mmr_mem + reg); in ar2315_pci_reg_read()
196 static inline void ar2315_pci_reg_write(struct ar2315_pci_ctrl *apc, u32 reg, in ar2315_pci_reg_write() argument
199 __raw_writel(val, apc->mmr_mem + reg); in ar2315_pci_reg_write()
202 static inline void ar2315_pci_reg_mask(struct ar2315_pci_ctrl *apc, u32 reg, in ar2315_pci_reg_mask() argument
205 u32 ret = ar2315_pci_reg_read(apc, reg); in ar2315_pci_reg_mask()
209 ar2315_pci_reg_write(apc, reg, ret); in ar2315_pci_reg_mask()
212 static int ar2315_pci_cfg_access(struct ar2315_pci_ctrl *apc, unsigned devfn, in ar2315_pci_cfg_access() argument
227 ar2315_pci_reg_write(apc, AR2315_PCI_ISR, AR2315_PCI_INT_ABORT); in ar2315_pci_cfg_access()
229 ar2315_pci_reg_mask(apc, AR2315_PCI_MISC_CONFIG, 0, in ar2315_pci_cfg_access()
234 value = __raw_readl(apc->cfg_mem + addr); in ar2315_pci_cfg_access()
236 isr = ar2315_pci_reg_read(apc, AR2315_PCI_ISR); in ar2315_pci_cfg_access()
243 __raw_writel(value, apc->cfg_mem + addr); in ar2315_pci_cfg_access()
244 isr = ar2315_pci_reg_read(apc, AR2315_PCI_ISR); in ar2315_pci_cfg_access()
254 ar2315_pci_reg_write(apc, AR2315_PCI_ISR, AR2315_PCI_INT_ABORT); in ar2315_pci_cfg_access()
260 ar2315_pci_reg_mask(apc, AR2315_PCI_MISC_CONFIG, AR2315_PCIMISC_CFG_SEL, in ar2315_pci_cfg_access()
267 static inline int ar2315_pci_local_cfg_rd(struct ar2315_pci_ctrl *apc, in ar2315_pci_local_cfg_rd() argument
270 return ar2315_pci_cfg_access(apc, devfn, where, sizeof(u32), val, in ar2315_pci_local_cfg_rd()
274 static inline int ar2315_pci_local_cfg_wr(struct ar2315_pci_ctrl *apc, in ar2315_pci_local_cfg_wr() argument
277 return ar2315_pci_cfg_access(apc, devfn, where, sizeof(u32), &val, in ar2315_pci_local_cfg_wr()
284 struct ar2315_pci_ctrl *apc = ar2315_pci_bus_to_apc(bus); in ar2315_pci_cfg_read() local
289 return ar2315_pci_cfg_access(apc, devfn, where, size, value, false); in ar2315_pci_cfg_read()
295 struct ar2315_pci_ctrl *apc = ar2315_pci_bus_to_apc(bus); in ar2315_pci_cfg_write() local
300 return ar2315_pci_cfg_access(apc, devfn, where, size, &value, true); in ar2315_pci_cfg_write()
308 static int ar2315_pci_host_setup(struct ar2315_pci_ctrl *apc) in ar2315_pci_host_setup() argument
314 res = ar2315_pci_local_cfg_rd(apc, devfn, PCI_VENDOR_ID, &id); in ar2315_pci_host_setup()
319 ar2315_pci_local_cfg_wr(apc, devfn, PCI_BASE_ADDRESS_0, in ar2315_pci_host_setup()
321 ar2315_pci_local_cfg_wr(apc, devfn, PCI_BASE_ADDRESS_1, in ar2315_pci_host_setup()
323 ar2315_pci_local_cfg_wr(apc, devfn, PCI_BASE_ADDRESS_2, in ar2315_pci_host_setup()
327 ar2315_pci_local_cfg_wr(apc, devfn, PCI_COMMAND, PCI_COMMAND_MEMORY | in ar2315_pci_host_setup()
337 struct ar2315_pci_ctrl *apc = irq_desc_get_handler_data(desc); in ar2315_pci_irq_handler() local
338 u32 pending = ar2315_pci_reg_read(apc, AR2315_PCI_ISR) & in ar2315_pci_irq_handler()
339 ar2315_pci_reg_read(apc, AR2315_PCI_IMR); in ar2315_pci_irq_handler()
343 ret = generic_handle_domain_irq(apc->domain, __ffs(pending)); in ar2315_pci_irq_handler()
351 struct ar2315_pci_ctrl *apc = irq_data_get_irq_chip_data(d); in ar2315_pci_irq_mask() local
353 ar2315_pci_reg_mask(apc, AR2315_PCI_IMR, BIT(d->hwirq), 0); in ar2315_pci_irq_mask()
358 struct ar2315_pci_ctrl *apc = irq_data_get_irq_chip_data(d); in ar2315_pci_irq_mask_ack() local
361 ar2315_pci_reg_mask(apc, AR2315_PCI_IMR, m, 0); in ar2315_pci_irq_mask_ack()
362 ar2315_pci_reg_write(apc, AR2315_PCI_ISR, m); in ar2315_pci_irq_mask_ack()
367 struct ar2315_pci_ctrl *apc = irq_data_get_irq_chip_data(d); in ar2315_pci_irq_unmask() local
369 ar2315_pci_reg_mask(apc, AR2315_PCI_IMR, 0, BIT(d->hwirq)); in ar2315_pci_irq_unmask()
391 static void ar2315_pci_irq_init(struct ar2315_pci_ctrl *apc) in ar2315_pci_irq_init() argument
393 ar2315_pci_reg_mask(apc, AR2315_PCI_IER, AR2315_PCI_IER_ENABLE, 0); in ar2315_pci_irq_init()
394 ar2315_pci_reg_mask(apc, AR2315_PCI_IMR, (AR2315_PCI_INT_ABORT | in ar2315_pci_irq_init()
397 apc->irq_ext = irq_create_mapping(apc->domain, AR2315_PCI_IRQ_EXT); in ar2315_pci_irq_init()
399 irq_set_chained_handler_and_data(apc->irq, ar2315_pci_irq_handler, in ar2315_pci_irq_init()
400 apc); in ar2315_pci_irq_init()
404 ar2315_pci_reg_write(apc, AR2315_PCI_ISR, AR2315_PCI_INT_ABORT | in ar2315_pci_irq_init()
406 ar2315_pci_reg_mask(apc, AR2315_PCI_IER, 0, AR2315_PCI_IER_ENABLE); in ar2315_pci_irq_init()
411 struct ar2315_pci_ctrl *apc; in ar2315_pci_probe() local
416 apc = devm_kzalloc(dev, sizeof(*apc), GFP_KERNEL); in ar2315_pci_probe()
417 if (!apc) in ar2315_pci_probe()
423 apc->irq = irq; in ar2315_pci_probe()
425 apc->mmr_mem = devm_platform_ioremap_resource_byname(pdev, in ar2315_pci_probe()
427 if (IS_ERR(apc->mmr_mem)) in ar2315_pci_probe()
428 return PTR_ERR(apc->mmr_mem); in ar2315_pci_probe()
435 apc->mem_res.name = "AR2315 PCI mem space"; in ar2315_pci_probe()
436 apc->mem_res.parent = res; in ar2315_pci_probe()
437 apc->mem_res.start = res->start; in ar2315_pci_probe()
438 apc->mem_res.end = res->end; in ar2315_pci_probe()
439 apc->mem_res.flags = IORESOURCE_MEM; in ar2315_pci_probe()
442 apc->cfg_mem = devm_ioremap(dev, res->start, in ar2315_pci_probe()
444 if (!apc->cfg_mem) { in ar2315_pci_probe()
450 ar2315_pci_reg_mask(apc, AR2315_PCI_MISC_CONFIG, in ar2315_pci_probe()
456 ar2315_pci_reg_mask(apc, AR2315_PCI_MISC_CONFIG, in ar2315_pci_probe()
460 ar2315_pci_reg_write(apc, AR2315_PCI_UNCACHE_CFG, in ar2315_pci_probe()
464 ar2315_pci_reg_read(apc, AR2315_PCI_UNCACHE_CFG); in ar2315_pci_probe()
468 err = ar2315_pci_host_setup(apc); in ar2315_pci_probe()
472 apc->domain = irq_domain_add_linear(NULL, AR2315_PCI_IRQ_COUNT, in ar2315_pci_probe()
473 &ar2315_pci_irq_domain_ops, apc); in ar2315_pci_probe()
474 if (!apc->domain) { in ar2315_pci_probe()
479 ar2315_pci_irq_init(apc); in ar2315_pci_probe()
482 apc->io_res.name = "AR2315 IO space"; in ar2315_pci_probe()
483 apc->io_res.start = 0; in ar2315_pci_probe()
484 apc->io_res.end = 0; in ar2315_pci_probe()
485 apc->io_res.flags = IORESOURCE_IO; in ar2315_pci_probe()
487 apc->pci_ctrl.pci_ops = &ar2315_pci_ops; in ar2315_pci_probe()
488 apc->pci_ctrl.mem_resource = &apc->mem_res; in ar2315_pci_probe()
489 apc->pci_ctrl.io_resource = &apc->io_res; in ar2315_pci_probe()
491 register_pci_controller(&apc->pci_ctrl); in ar2315_pci_probe()
513 struct ar2315_pci_ctrl *apc = ar2315_pci_bus_to_apc(dev->bus); in pcibios_map_irq() local
515 return slot ? 0 : apc->irq_ext; in pcibios_map_irq()