Lines Matching defs:rpc

80 static inline u32 rt3883_pci_r32(struct rt3883_pci_controller *rpc,
83 return ioread32(rpc->base + reg);
86 static inline void rt3883_pci_w32(struct rt3883_pci_controller *rpc,
89 iowrite32(val, rpc->base + reg);
99 static u32 rt3883_pci_read_cfg32(struct rt3883_pci_controller *rpc,
109 rt3883_pci_w32(rpc, address, RT3883_PCI_REG_CFGADDR);
110 ret = rt3883_pci_r32(rpc, RT3883_PCI_REG_CFGDATA);
115 static void rt3883_pci_write_cfg32(struct rt3883_pci_controller *rpc,
124 rt3883_pci_w32(rpc, address, RT3883_PCI_REG_CFGADDR);
125 rt3883_pci_w32(rpc, val, RT3883_PCI_REG_CFGDATA);
130 struct rt3883_pci_controller *rpc;
133 rpc = irq_desc_get_handler_data(desc);
135 pending = rt3883_pci_r32(rpc, RT3883_PCI_REG_PCIINT) &
136 rt3883_pci_r32(rpc, RT3883_PCI_REG_PCIENA);
146 irq = irq_find_mapping(rpc->irq_domain, bit);
155 struct rt3883_pci_controller *rpc;
158 rpc = irq_data_get_irq_chip_data(d);
160 t = rt3883_pci_r32(rpc, RT3883_PCI_REG_PCIENA);
161 rt3883_pci_w32(rpc, t | BIT(d->hwirq), RT3883_PCI_REG_PCIENA);
163 rt3883_pci_r32(rpc, RT3883_PCI_REG_PCIENA);
168 struct rt3883_pci_controller *rpc;
171 rpc = irq_data_get_irq_chip_data(d);
173 t = rt3883_pci_r32(rpc, RT3883_PCI_REG_PCIENA);
174 rt3883_pci_w32(rpc, t & ~BIT(d->hwirq), RT3883_PCI_REG_PCIENA);
176 rt3883_pci_r32(rpc, RT3883_PCI_REG_PCIENA);
201 struct rt3883_pci_controller *rpc)
205 irq = irq_of_parse_and_map(rpc->intc_of_node, 0);
207 dev_err(dev, "%pOF has no IRQ", rpc->intc_of_node);
212 rt3883_pci_w32(rpc, 0, RT3883_PCI_REG_PCIENA);
214 rpc->irq_domain =
215 irq_domain_add_linear(rpc->intc_of_node, RT3883_PCI_IRQ_COUNT,
217 rpc);
218 if (!rpc->irq_domain) {
223 irq_set_chained_handler_and_data(irq, rt3883_pci_irq_handler, rpc);
231 struct rt3883_pci_controller *rpc;
236 rpc = pci_bus_to_rt3883_controller(bus);
238 if (!rpc->pcie_ready && bus->number == 1)
244 rt3883_pci_w32(rpc, address, RT3883_PCI_REG_CFGADDR);
245 data = rt3883_pci_r32(rpc, RT3883_PCI_REG_CFGDATA);
265 struct rt3883_pci_controller *rpc;
270 rpc = pci_bus_to_rt3883_controller(bus);
272 if (!rpc->pcie_ready && bus->number == 1)
278 rt3883_pci_w32(rpc, address, RT3883_PCI_REG_CFGADDR);
279 data = rt3883_pci_r32(rpc, RT3883_PCI_REG_CFGDATA);
295 rt3883_pci_w32(rpc, data, RT3883_PCI_REG_CFGDATA);
305 static void rt3883_pci_preinit(struct rt3883_pci_controller *rpc, unsigned mode)
372 rt3883_pci_w32(rpc, t, RT3883_PCI_REG_PCICFG);
375 rt3883_pci_r32(rpc, RT3883_PCI_REG_PCICFG);
381 t = rt3883_pci_r32(rpc, RT3883_PCI_REG_STATUS(1));
383 rpc->pcie_ready = t & BIT(0);
385 if (!rpc->pcie_ready) {
405 rt3883_pci_w32(rpc, 0x79, RT3883_PCI_REG_ARBCTL);
410 struct rt3883_pci_controller *rpc;
419 rpc = devm_kzalloc(dev, sizeof(*rpc), GFP_KERNEL);
420 if (!rpc)
424 rpc->base = devm_ioremap_resource(dev, res);
425 if (IS_ERR(rpc->base))
426 return PTR_ERR(rpc->base);
431 rpc->intc_of_node = child;
436 if (!rpc->intc_of_node) {
438 rpc->intc_of_node,
446 rpc->pci_controller.of_node = child;
451 if (!rpc->pci_controller.of_node) {
453 rpc->intc_of_node,
460 for_each_available_child_of_node(rpc->pci_controller.of_node, child) {
492 rt3883_pci_preinit(rpc, mode);
494 rpc->pci_controller.pci_ops = &rt3883_pci_ops;
495 rpc->pci_controller.io_resource = &rpc->io_res;
496 rpc->pci_controller.mem_resource = &rpc->mem_res;
499 pci_load_of_ranges(&rpc->pci_controller,
500 rpc->pci_controller.of_node);
502 rt3883_pci_w32(rpc, rpc->mem_res.start, RT3883_PCI_REG_MEMBASE);
503 rt3883_pci_w32(rpc, rpc->io_res.start, RT3883_PCI_REG_IOBASE);
505 ioport_resource.start = rpc->io_res.start;
506 ioport_resource.end = rpc->io_res.end;
509 rt3883_pci_w32(rpc, 0x03ff0000, RT3883_PCI_REG_BAR0SETUP(0));
510 rt3883_pci_w32(rpc, RT3883_MEMORY_BASE, RT3883_PCI_REG_IMBASEBAR0(0));
511 rt3883_pci_w32(rpc, 0x08021814, RT3883_PCI_REG_ID(0));
512 rt3883_pci_w32(rpc, 0x00800001, RT3883_PCI_REG_CLASS(0));
513 rt3883_pci_w32(rpc, 0x28801814, RT3883_PCI_REG_SUBID(0));
516 rt3883_pci_w32(rpc, 0x03ff0000, RT3883_PCI_REG_BAR0SETUP(1));
517 rt3883_pci_w32(rpc, RT3883_MEMORY_BASE, RT3883_PCI_REG_IMBASEBAR0(1));
518 rt3883_pci_w32(rpc, 0x08021814, RT3883_PCI_REG_ID(1));
519 rt3883_pci_w32(rpc, 0x06040001, RT3883_PCI_REG_CLASS(1));
520 rt3883_pci_w32(rpc, 0x28801814, RT3883_PCI_REG_SUBID(1));
522 err = rt3883_pci_irq_init(dev, rpc);
527 val = rt3883_pci_read_cfg32(rpc, 0, 0x01, 0, PCI_COMMAND);
529 rt3883_pci_write_cfg32(rpc, 0, 0x01, 0, PCI_COMMAND, val);
532 val = rt3883_pci_read_cfg32(rpc, 0, 0x00, 0, PCI_COMMAND);
534 rt3883_pci_write_cfg32(rpc, 0, 0x00, 0, PCI_COMMAND, val);
537 rt3883_pci_w32(rpc, 0x03ff0001, RT3883_PCI_REG_BAR0SETUP(0));
538 rt3883_pci_w32(rpc, 0x03ff0001, RT3883_PCI_REG_BAR0SETUP(1));
540 rt3883_pci_write_cfg32(rpc, 0, RT3883_P2P_BR_DEVNUM, 0,
544 rt3883_pci_read_cfg32(rpc, 0, RT3883_P2P_BR_DEVNUM, 0,
547 rt3883_pci_write_cfg32(rpc, 0, RT3883_P2P_BR_DEVNUM, 0,
551 register_pci_controller(&rpc->pci_controller);
556 of_node_put(rpc->pci_controller.of_node);
558 of_node_put(rpc->intc_of_node);