Lines Matching +full:a +full:- +full:child +full:- +full:node +full:- +full:property

19 #include <asm/pci-bridge.h>
23 * get_int_prop - Decode a u32 from a device tree property
37 * pci_parse_of_flags - Parse the flags cell of a device tree PCI address
38 * @addr0: value of 1st cell of a device tree PCI address.
39 * @bridge: Set this flag if the address is from a bridge 'ranges' property
55 * do a config space read, it will be force-enabled if needed in pci_parse_of_flags()
67 * of_pci_parse_addrs - Parse PCI addresses assigned in the device tree node
68 * @node: device tree node for the PCI device
71 * This function parses the 'assigned-addresses' property of a PCI devices'
72 * device tree node and writes them into the associated pci_dev structure.
74 static void of_pci_parse_addrs(struct device_node *node, struct pci_dev *dev) in of_pci_parse_addrs() argument
83 addrs = of_get_property(node, "assigned-addresses", &proplen); in of_pci_parse_addrs()
87 for (; proplen >= 20; proplen -= 20, addrs += 5) { in of_pci_parse_addrs()
101 res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2]; in of_pci_parse_addrs()
102 } else if (i == dev->rom_base_reg) { in of_pci_parse_addrs()
103 res = &dev->resource[PCI_ROM_RESOURCE]; in of_pci_parse_addrs()
109 res->start = base; in of_pci_parse_addrs()
110 res->end = base + size - 1; in of_pci_parse_addrs()
111 res->flags = flags; in of_pci_parse_addrs()
112 res->name = pci_name(dev); in of_pci_parse_addrs()
117 * of_create_pci_dev - Given a device tree node on a pci bus, create a pci_dev
118 * @node: device tree node pointer
122 struct pci_dev *of_create_pci_dev(struct device_node *node, in of_create_pci_dev() argument
132 type = of_get_property(node, "device_type", NULL); in of_create_pci_dev()
138 dev->bus = bus; in of_create_pci_dev()
139 dev->dev.of_node = of_node_get(node); in of_create_pci_dev()
140 dev->dev.parent = bus->bridge; in of_create_pci_dev()
141 dev->dev.bus = &pci_bus_type; in of_create_pci_dev()
142 dev->devfn = devfn; in of_create_pci_dev()
143 dev->multifunction = 0; /* maybe a lie? */ in of_create_pci_dev()
144 dev->needs_freset = 0; /* pcie fundamental reset required */ in of_create_pci_dev()
147 list_for_each_entry(slot, &dev->bus->slots, list) in of_create_pci_dev()
148 if (PCI_SLOT(dev->devfn) == slot->number) in of_create_pci_dev()
149 dev->slot = slot; in of_create_pci_dev()
151 dev->vendor = get_int_prop(node, "vendor-id", 0xffff); in of_create_pci_dev()
152 dev->device = get_int_prop(node, "device-id", 0xffff); in of_create_pci_dev()
153 dev->subsystem_vendor = get_int_prop(node, "subsystem-vendor-id", 0); in of_create_pci_dev()
154 dev->subsystem_device = get_int_prop(node, "subsystem-id", 0); in of_create_pci_dev()
156 dev->cfg_size = pci_cfg_space_size(dev); in of_create_pci_dev()
158 dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(bus), in of_create_pci_dev()
159 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); in of_create_pci_dev()
160 dev->class = get_int_prop(node, "class-code", 0); in of_create_pci_dev()
161 dev->revision = get_int_prop(node, "revision-id", 0); in of_create_pci_dev()
163 pr_debug(" class: 0x%x\n", dev->class); in of_create_pci_dev()
164 pr_debug(" revision: 0x%x\n", dev->revision); in of_create_pci_dev()
166 dev->current_state = 4; /* unknown power state */ in of_create_pci_dev()
167 dev->error_state = pci_channel_io_normal; in of_create_pci_dev()
168 dev->dma_mask = 0xffffffff; in of_create_pci_dev()
174 /* a PCI-PCI bridge */ in of_create_pci_dev()
175 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE; in of_create_pci_dev()
176 dev->rom_base_reg = PCI_ROM_ADDRESS1; in of_create_pci_dev()
179 dev->hdr_type = PCI_HEADER_TYPE_CARDBUS; in of_create_pci_dev()
181 dev->hdr_type = PCI_HEADER_TYPE_NORMAL; in of_create_pci_dev()
182 dev->rom_base_reg = PCI_ROM_ADDRESS; in of_create_pci_dev()
183 /* Maybe do a default OF mapping here */ in of_create_pci_dev()
184 dev->irq = NO_IRQ; in of_create_pci_dev()
187 of_pci_parse_addrs(node, dev); in of_create_pci_dev()
198 * of_scan_pci_bridge - Set up a PCI bridge and scan for child nodes
199 * @node: device tree node of bridge
203 * this routine in turn call of_scan_bus() recusively to scan for more child
208 struct device_node *node = dev->dev.of_node; in of_scan_pci_bridge() local
216 pr_debug("of_scan_pci_bridge(%s)\n", node->full_name); in of_scan_pci_bridge()
218 /* parse bus-range property */ in of_scan_pci_bridge()
219 busrange = of_get_property(node, "bus-range", &len); in of_scan_pci_bridge()
221 printk(KERN_DEBUG "Can't get bus-range for PCI-PCI bridge %s\n", in of_scan_pci_bridge()
222 node->full_name); in of_scan_pci_bridge()
225 ranges = of_get_property(node, "ranges", &len); in of_scan_pci_bridge()
227 printk(KERN_DEBUG "Can't get ranges for PCI-PCI bridge %s\n", in of_scan_pci_bridge()
228 node->full_name); in of_scan_pci_bridge()
232 bus = pci_add_new_bus(dev->bus, dev, busrange[0]); in of_scan_pci_bridge()
235 node->full_name); in of_scan_pci_bridge()
239 bus->primary = dev->bus->number; in of_scan_pci_bridge()
240 bus->subordinate = busrange[1]; in of_scan_pci_bridge()
241 bus->bridge_ctl = 0; in of_scan_pci_bridge()
243 /* parse ranges property */ in of_scan_pci_bridge()
244 /* PCI #address-cells == 3 and #size-cells == 2 always */ in of_scan_pci_bridge()
245 res = &dev->resource[PCI_BRIDGE_RESOURCES]; in of_scan_pci_bridge()
246 for (i = 0; i < PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES; ++i) { in of_scan_pci_bridge()
247 res->flags = 0; in of_scan_pci_bridge()
248 bus->resource[i] = res; in of_scan_pci_bridge()
252 for (; len >= 32; len -= 32, ranges += 8) { in of_scan_pci_bridge()
258 res = bus->resource[0]; in of_scan_pci_bridge()
259 if (res->flags) { in of_scan_pci_bridge()
261 " for bridge %s\n", node->full_name); in of_scan_pci_bridge()
265 if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) { in of_scan_pci_bridge()
267 " for bridge %s\n", node->full_name); in of_scan_pci_bridge()
270 res = bus->resource[i]; in of_scan_pci_bridge()
273 res->start = of_read_number(&ranges[1], 2); in of_scan_pci_bridge()
274 res->end = res->start + size - 1; in of_scan_pci_bridge()
275 res->flags = flags; in of_scan_pci_bridge()
277 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), in of_scan_pci_bridge()
278 bus->number); in of_scan_pci_bridge()
279 pr_debug(" bus name: %s\n", bus->name); in of_scan_pci_bridge()
287 of_scan_bus(node, bus); in of_scan_pci_bridge()
294 * __of_scan_bus - given a PCI bus node, setup bus and scan for child devices
295 * @node: device tree node for the PCI bus
299 static void __devinit __of_scan_bus(struct device_node *node, in __of_scan_bus() argument
302 struct device_node *child; in __of_scan_bus() local
308 node->full_name, bus->number); in __of_scan_bus()
311 for_each_child_of_node(node, child) { in __of_scan_bus()
312 pr_debug(" * %s\n", child->full_name); in __of_scan_bus()
313 if (!of_device_is_available(child)) in __of_scan_bus()
315 reg = of_get_property(child, "reg", &reglen); in __of_scan_bus()
320 /* create a new pci_dev for this device */ in __of_scan_bus()
321 dev = of_create_pci_dev(child, bus, devfn); in __of_scan_bus()
324 pr_debug(" dev header type: %x\n", dev->hdr_type); in __of_scan_bus()
334 /* Now scan child busses */ in __of_scan_bus()
335 list_for_each_entry(dev, &bus->devices, bus_list) { in __of_scan_bus()
336 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || in __of_scan_bus()
337 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { in __of_scan_bus()
344 * of_scan_bus - given a PCI bus node, setup bus and scan for child devices
345 * @node: device tree node for the PCI bus
348 void __devinit of_scan_bus(struct device_node *node, in of_scan_bus() argument
351 __of_scan_bus(node, bus, 0); in of_scan_bus()
356 * of_rescan_bus - given a PCI bus node, scan for child devices
357 * @node: device tree node for the PCI bus
360 * Same as of_scan_bus, but for a pci_bus structure that has already been
363 void __devinit of_rescan_bus(struct device_node *node, in of_rescan_bus() argument
366 __of_scan_bus(node, bus, 1); in of_rescan_bus()