Lines Matching +full:bus +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0
11 #include <linux/pci-ecam.h>
29 static int handle_ea_bar(u32 e0, int bar, struct pci_bus *bus, in handle_ea_bar() argument
32 void __iomem *addr; in handle_ea_bar() local
35 /* Entries are 16-byte aligned; bits[2,3] select word in entry */ in handle_ea_bar()
43 addr = bus->ops->map_bus(bus, devfn, bar); /* BAR 0 */ in handle_ea_bar()
44 if (!addr) { in handle_ea_bar()
48 v = readl(addr); in handle_ea_bar()
50 v |= 2; /* EA entry-1. Base-L */ in handle_ea_bar()
58 addr = bus->ops->map_bus(bus, devfn, bar); /* BAR 0 */ in handle_ea_bar()
59 if (!addr) { in handle_ea_bar()
63 barl_orig = readl(addr + 0); in handle_ea_bar()
64 writel(0xffffffff, addr + 0); in handle_ea_bar()
65 barl_rb = readl(addr + 0); in handle_ea_bar()
66 writel(barl_orig, addr + 0); in handle_ea_bar()
69 v |= 0xc; /* EA entry-2. Offset-L */ in handle_ea_bar()
74 addr = bus->ops->map_bus(bus, devfn, bar + 4); /* BAR 1 */ in handle_ea_bar()
75 if (!addr) { in handle_ea_bar()
79 v = readl(addr); /* EA entry-3. Base-H */ in handle_ea_bar()
86 static int thunder_ecam_p2_config_read(struct pci_bus *bus, unsigned int devfn, in thunder_ecam_p2_config_read() argument
89 struct pci_config_window *cfg = bus->sysdata; in thunder_ecam_p2_config_read()
91 void __iomem *addr; in thunder_ecam_p2_config_read() local
103 return pci_generic_config_read(bus, devfn, where, size, val); in thunder_ecam_p2_config_read()
106 addr = bus->ops->map_bus(bus, devfn, where_a); in thunder_ecam_p2_config_read()
107 if (!addr) { in thunder_ecam_p2_config_read()
112 v = readl(addr); in thunder_ecam_p2_config_read()
115 * Bit 44 of the 64-bit Base must match the same bit in in thunder_ecam_p2_config_read()
117 * the high-order 32 bits, shift everything down by 32 bits. in thunder_ecam_p2_config_read()
119 node_bits = upper_32_bits(cfg->res.start) & (1 << 12); in thunder_ecam_p2_config_read()
127 static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn, in thunder_ecam_config_read() argument
133 void __iomem *addr; in thunder_ecam_config_read() local
137 addr = bus->ops->map_bus(bus, devfn, 0xc); in thunder_ecam_config_read()
138 if (!addr) { in thunder_ecam_config_read()
143 v = readl(addr); in thunder_ecam_config_read()
145 /* Check for non type-00 header */ in thunder_ecam_config_read()
148 addr = bus->ops->map_bus(bus, devfn, 8); in thunder_ecam_config_read()
149 if (!addr) { in thunder_ecam_config_read()
154 class_rev = readl(addr); in thunder_ecam_config_read()
159 /* Pass-2 handling */ in thunder_ecam_config_read()
162 return thunder_ecam_p2_config_read(bus, devfn, where, in thunder_ecam_config_read()
173 /* BAR or SR-IOV BAR */ in thunder_ecam_config_read()
178 addr = bus->ops->map_bus(bus, devfn, 0); in thunder_ecam_config_read()
179 if (!addr) { in thunder_ecam_config_read()
184 vendor_device = readl(addr); in thunder_ecam_config_read()
188 pr_debug("%04x:%04x - Fix pass#: %08x, where: %03x, devfn: %03x\n", in thunder_ecam_config_read()
192 /* Check for non type-00 header */ in thunder_ecam_config_read()
198 addr = bus->ops->map_bus(bus, devfn, 0x70); in thunder_ecam_config_read()
199 if (!addr) { in thunder_ecam_config_read()
204 v = readl(addr); in thunder_ecam_config_read()
213 addr = bus->ops->map_bus(bus, devfn, where_a); in thunder_ecam_config_read()
214 if (!addr) { in thunder_ecam_config_read()
218 v = readl(addr); in thunder_ecam_config_read()
238 /* EA entry-0. PP=0, BAR0 Size:3 */ in thunder_ecam_config_read()
240 0x10, bus, devfn, where, in thunder_ecam_config_read()
243 /* EA entry-1. PP=0, BAR4 Size:3 */ in thunder_ecam_config_read()
245 0x20, bus, devfn, where, in thunder_ecam_config_read()
248 /* EA entry-2. PP=0, BAR2, Size:3 */ in thunder_ecam_config_read()
250 0x18, bus, devfn, where, in thunder_ecam_config_read()
253 /* EA entry-2. PP=4, VF_BAR0 (9), Size:3 */ in thunder_ecam_config_read()
255 0x1a4, bus, devfn, where, in thunder_ecam_config_read()
258 /* EA entry-3. PP=4, VF_BAR4 (d), Size:3 */ in thunder_ecam_config_read()
260 0x1b4, bus, devfn, where, in thunder_ecam_config_read()
270 addr = bus->ops->map_bus(bus, devfn, where_a); in thunder_ecam_config_read()
271 if (!addr) { in thunder_ecam_config_read()
275 v = readl(addr); in thunder_ecam_config_read()
303 /* Enabled, not-Write, SP=ff, PP=05, BEI=6, ES=4 */ in thunder_ecam_config_read()
309 v = 0x00000002; /* Base-L 64-bit */ in thunder_ecam_config_read()
314 v = 0xfffffffe; /* MaxOffset-L 64-bit */ in thunder_ecam_config_read()
319 v = 0x00008430; /* NIC Base-H */ in thunder_ecam_config_read()
324 v = 0x0000000f; /* MaxOffset-H */ in thunder_ecam_config_read()
330 return pci_generic_config_read(bus, devfn, where, size, val); in thunder_ecam_config_read()
333 static int thunder_ecam_config_write(struct pci_bus *bus, unsigned int devfn, in thunder_ecam_config_write() argument
342 /* BAR or SR-IOV BAR */ in thunder_ecam_config_write()
345 return pci_generic_config_write(bus, devfn, where, size, val); in thunder_ecam_config_write()
360 .compatible = "cavium,pci-host-thunder-ecam",