Lines Matching refs:apc

190 static inline u32 ar2315_pci_reg_read(struct ar2315_pci_ctrl *apc, u32 reg)
192 return __raw_readl(apc->mmr_mem + reg);
195 static inline void ar2315_pci_reg_write(struct ar2315_pci_ctrl *apc, u32 reg,
198 __raw_writel(val, apc->mmr_mem + reg);
201 static inline void ar2315_pci_reg_mask(struct ar2315_pci_ctrl *apc, u32 reg,
204 u32 ret = ar2315_pci_reg_read(apc, reg);
208 ar2315_pci_reg_write(apc, reg, ret);
211 static int ar2315_pci_cfg_access(struct ar2315_pci_ctrl *apc, unsigned devfn,
226 ar2315_pci_reg_write(apc, AR2315_PCI_ISR, AR2315_PCI_INT_ABORT);
228 ar2315_pci_reg_mask(apc, AR2315_PCI_MISC_CONFIG, 0,
233 value = __raw_readl(apc->cfg_mem + addr);
235 isr = ar2315_pci_reg_read(apc, AR2315_PCI_ISR);
242 __raw_writel(value, apc->cfg_mem + addr);
243 isr = ar2315_pci_reg_read(apc, AR2315_PCI_ISR);
253 ar2315_pci_reg_write(apc, AR2315_PCI_ISR, AR2315_PCI_INT_ABORT);
259 ar2315_pci_reg_mask(apc, AR2315_PCI_MISC_CONFIG, AR2315_PCIMISC_CFG_SEL,
266 static inline int ar2315_pci_local_cfg_rd(struct ar2315_pci_ctrl *apc,
269 return ar2315_pci_cfg_access(apc, devfn, where, sizeof(u32), val,
273 static inline int ar2315_pci_local_cfg_wr(struct ar2315_pci_ctrl *apc,
276 return ar2315_pci_cfg_access(apc, devfn, where, sizeof(u32), &val,
283 struct ar2315_pci_ctrl *apc = ar2315_pci_bus_to_apc(bus);
288 return ar2315_pci_cfg_access(apc, devfn, where, size, value, false);
294 struct ar2315_pci_ctrl *apc = ar2315_pci_bus_to_apc(bus);
299 return ar2315_pci_cfg_access(apc, devfn, where, size, &value, true);
307 static int ar2315_pci_host_setup(struct ar2315_pci_ctrl *apc)
313 res = ar2315_pci_local_cfg_rd(apc, devfn, PCI_VENDOR_ID, &id);
318 ar2315_pci_local_cfg_wr(apc, devfn, PCI_BASE_ADDRESS_0,
320 ar2315_pci_local_cfg_wr(apc, devfn, PCI_BASE_ADDRESS_1,
322 ar2315_pci_local_cfg_wr(apc, devfn, PCI_BASE_ADDRESS_2,
326 ar2315_pci_local_cfg_wr(apc, devfn, PCI_COMMAND, PCI_COMMAND_MEMORY |
336 struct ar2315_pci_ctrl *apc = irq_desc_get_handler_data(desc);
337 u32 pending = ar2315_pci_reg_read(apc, AR2315_PCI_ISR) &
338 ar2315_pci_reg_read(apc, AR2315_PCI_IMR);
342 pci_irq = irq_find_mapping(apc->domain, __ffs(pending));
352 struct ar2315_pci_ctrl *apc = irq_data_get_irq_chip_data(d);
354 ar2315_pci_reg_mask(apc, AR2315_PCI_IMR, BIT(d->hwirq), 0);
359 struct ar2315_pci_ctrl *apc = irq_data_get_irq_chip_data(d);
362 ar2315_pci_reg_mask(apc, AR2315_PCI_IMR, m, 0);
363 ar2315_pci_reg_write(apc, AR2315_PCI_ISR, m);
368 struct ar2315_pci_ctrl *apc = irq_data_get_irq_chip_data(d);
370 ar2315_pci_reg_mask(apc, AR2315_PCI_IMR, 0, BIT(d->hwirq));
392 static void ar2315_pci_irq_init(struct ar2315_pci_ctrl *apc)
394 ar2315_pci_reg_mask(apc, AR2315_PCI_IER, AR2315_PCI_IER_ENABLE, 0);
395 ar2315_pci_reg_mask(apc, AR2315_PCI_IMR, (AR2315_PCI_INT_ABORT |
398 apc->irq_ext = irq_create_mapping(apc->domain, AR2315_PCI_IRQ_EXT);
400 irq_set_chained_handler_and_data(apc->irq, ar2315_pci_irq_handler,
401 apc);
405 ar2315_pci_reg_write(apc, AR2315_PCI_ISR, AR2315_PCI_INT_ABORT |
407 ar2315_pci_reg_mask(apc, AR2315_PCI_IER, 0, AR2315_PCI_IER_ENABLE);
412 struct ar2315_pci_ctrl *apc;
417 apc = devm_kzalloc(dev, sizeof(*apc), GFP_KERNEL);
418 if (!apc)
424 apc->irq = irq;
426 apc->mmr_mem = devm_platform_ioremap_resource_byname(pdev,
428 if (IS_ERR(apc->mmr_mem))
429 return PTR_ERR(apc->mmr_mem);
436 apc->mem_res.name = "AR2315 PCI mem space";
437 apc->mem_res.parent = res;
438 apc->mem_res.start = res->start;
439 apc->mem_res.end = res->end;
440 apc->mem_res.flags = IORESOURCE_MEM;
443 apc->cfg_mem = devm_ioremap(dev, res->start,
445 if (!apc->cfg_mem) {
451 ar2315_pci_reg_mask(apc, AR2315_PCI_MISC_CONFIG,
457 ar2315_pci_reg_mask(apc, AR2315_PCI_MISC_CONFIG,
461 ar2315_pci_reg_write(apc, AR2315_PCI_UNCACHE_CFG,
465 ar2315_pci_reg_read(apc, AR2315_PCI_UNCACHE_CFG);
469 err = ar2315_pci_host_setup(apc);
473 apc->domain = irq_domain_add_linear(NULL, AR2315_PCI_IRQ_COUNT,
474 &ar2315_pci_irq_domain_ops, apc);
475 if (!apc->domain) {
480 ar2315_pci_irq_init(apc);
483 apc->io_res.name = "AR2315 IO space";
484 apc->io_res.start = 0;
485 apc->io_res.end = 0;
486 apc->io_res.flags = IORESOURCE_IO,
488 apc->pci_ctrl.pci_ops = &ar2315_pci_ops;
489 apc->pci_ctrl.mem_resource = &apc->mem_res,
490 apc->pci_ctrl.io_resource = &apc->io_res,
492 register_pci_controller(&apc->pci_ctrl);
514 struct ar2315_pci_ctrl *apc = ar2315_pci_bus_to_apc(dev->bus);
516 return slot ? 0 : apc->irq_ext;