Lines Matching +full:bus +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0-only
18 #include <asm/pci-bridge.h>
19 #include <asm/isa-bridge.h>
22 #include <asm/ppc-pci.h>
26 #define PA_PXP_CFA(bus, devfn, off) (((bus) << 20) | ((devfn) << 12) | (off)) argument
28 static inline int pa_pxp_offset_valid(u8 bus, u8 devfn, int offset) in pa_pxp_offset_valid() argument
31 * well, so allow larger offset. It's really a two-function device but the in pa_pxp_offset_valid()
34 if (bus == 0 && devfn == 0) in pa_pxp_offset_valid()
41 u8 bus, u8 devfn, int offset) in pa_pxp_cfg_addr() argument
43 return hose->cfg_data + PA_PXP_CFA(bus, devfn, offset); in pa_pxp_cfg_addr()
58 static int workaround_5945(struct pci_bus *bus, unsigned int devfn, in workaround_5945() argument
62 void volatile __iomem *addr, *dummy; in workaround_5945() local
66 if (!is_root_port(bus->number, devfn) || !is_5945_reg(offset)) in workaround_5945()
69 hose = pci_bus_to_host(bus); in workaround_5945()
71 addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset & ~0x3); in workaround_5945()
75 * and write back what we read. We must read/write the full 32-bit in workaround_5945()
78 dummy = pa_pxp_cfg_addr(hose, bus->number, devfn, 0x10); in workaround_5945()
80 tmp = in_le32(addr); in workaround_5945()
81 out_le32(addr, tmp); in workaround_5945()
106 static void sb600_set_flag(int bus) in sb600_set_flag() argument
114 dn = of_find_compatible_node(NULL, "isa", "pasemi,1682m-iob"); in sb600_set_flag()
134 if (bus == SB600_BUS) { in sb600_set_flag()
136 * This is the SB600's bus, tell the PCI-e root port in sb600_set_flag()
137 * to allow non-zero devices to enumerate. in sb600_set_flag()
151 static void sb600_set_flag(int bus) in sb600_set_flag() argument
156 static int pa_pxp_read_config(struct pci_bus *bus, unsigned int devfn, in pa_pxp_read_config() argument
160 void volatile __iomem *addr; in pa_pxp_read_config() local
162 hose = pci_bus_to_host(bus); in pa_pxp_read_config()
166 if (!pa_pxp_offset_valid(bus->number, devfn, offset)) in pa_pxp_read_config()
169 if (workaround_5945(bus, devfn, offset, len, val)) in pa_pxp_read_config()
172 addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset); in pa_pxp_read_config()
174 sb600_set_flag(bus->number); in pa_pxp_read_config()
182 *val = in_8(addr); in pa_pxp_read_config()
185 *val = in_le16(addr); in pa_pxp_read_config()
188 *val = in_le32(addr); in pa_pxp_read_config()
195 static int pa_pxp_write_config(struct pci_bus *bus, unsigned int devfn, in pa_pxp_write_config() argument
199 void volatile __iomem *addr; in pa_pxp_write_config() local
201 hose = pci_bus_to_host(bus); in pa_pxp_write_config()
205 if (!pa_pxp_offset_valid(bus->number, devfn, offset)) in pa_pxp_write_config()
208 addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset); in pa_pxp_write_config()
210 sb600_set_flag(bus->number); in pa_pxp_write_config()
218 out_8(addr, val); in pa_pxp_write_config()
221 out_le16(addr, val); in pa_pxp_write_config()
224 out_le32(addr, val); in pa_pxp_write_config()
237 hose->ops = &pa_pxp_ops; in setup_pa_pxp()
238 hose->cfg_data = ioremap(0xe0000000, 0x10000000); in setup_pa_pxp()
249 return -ENOMEM; in pas_add_bridge()
251 hose->first_busno = 0; in pas_add_bridge()
252 hose->last_busno = 0xff; in pas_add_bridge()
253 hose->controller_ops = pasemi_pci_controller_ops; in pas_add_bridge()
257 pr_info("Found PA-PXP PCI host bridge.\n"); in pas_add_bridge()
291 hose = pci_bus_to_host(dev->bus); in pasemi_pci_getcfgaddr()
293 return (void __iomem *)pa_pxp_cfg_addr(hose, dev->bus->number, dev->devfn, offset); in pasemi_pci_getcfgaddr()