]> git.sur5r.net Git - u-boot/blobdiff - drivers/pci/pci-uclass.c
mtd: pxa3xx_nand: Correct null dereference
[u-boot] / drivers / pci / pci-uclass.c
index 478bdc99b7518fd377e05fd4c5890a00d89f8060..d01bfc12e44f28ec58a30d93eaca55aef63923f0 100644 (file)
@@ -22,7 +22,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int pci_get_bus(int busnum, struct udevice **busp)
+int pci_get_bus(int busnum, struct udevice **busp)
 {
        int ret;
 
@@ -41,20 +41,6 @@ static int pci_get_bus(int busnum, struct udevice **busp)
        return ret;
 }
 
-struct pci_controller *pci_bus_to_hose(int busnum)
-{
-       struct udevice *bus;
-       int ret;
-
-       ret = pci_get_bus(busnum, &bus);
-       if (ret) {
-               debug("%s: Cannot get bus %d: ret=%d\n", __func__, busnum, ret);
-               return NULL;
-       }
-
-       return dev_get_uclass_priv(bus);
-}
-
 struct udevice *pci_get_controller(struct udevice *dev)
 {
        while (device_is_on_pci_bus(dev))
@@ -674,9 +660,7 @@ int pci_bind_bus_devices(struct udevice *bus)
                /* Find this device in the device tree */
                ret = pci_bus_find_devfn(bus, PCI_MASK_BUS(bdf), &dev);
 
-               /* Search for a driver */
-
-               /* If nothing in the device tree, bind a generic device */
+               /* If nothing in the device tree, bind a device */
                if (ret == -ENODEV) {
                        struct pci_device_id find_id;
                        ulong val;
@@ -1069,6 +1053,14 @@ u32 dm_pci_read_bar32(struct udevice *dev, int barnum)
                return addr & PCI_BASE_ADDRESS_MEM_MASK;
 }
 
+void dm_pci_write_bar32(struct udevice *dev, int barnum, u32 addr)
+{
+       int bar;
+
+       bar = PCI_BASE_ADDRESS_0 + barnum * 4;
+       dm_pci_write_config32(dev, bar, addr);
+}
+
 static int _dm_pci_bus_to_phys(struct udevice *ctlr,
                               pci_addr_t bus_addr, unsigned long flags,
                               unsigned long skip_mask, phys_addr_t *pa)
@@ -1249,3 +1241,18 @@ U_BOOT_DRIVER(pci_generic_drv) = {
        .id             = UCLASS_PCI_GENERIC,
        .of_match       = pci_generic_ids,
 };
+
+void pci_init(void)
+{
+       struct udevice *bus;
+
+       /*
+        * Enumerate all known controller devices. Enumeration has the side-
+        * effect of probing them, so PCIe devices will be enumerated too.
+        */
+       for (uclass_first_device(UCLASS_PCI, &bus);
+            bus;
+            uclass_next_device(&bus)) {
+               ;
+       }
+}