Lines Matching refs:apc

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