Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309065
b: refs/heads/master
c: a48cf37
h: refs/heads/master
i:
  309063: 3b1f2b6
v: v3
  • Loading branch information
John Crispin authored and Ralf Baechle committed May 15, 2012
1 parent cb15375 commit 5bbf2c4
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3572a2c37f667ee49333f8863722b8f43eac506b
refs/heads/master: a48cf37ac8a77ddd2370be3c9af411c622ebc425
6 changes: 6 additions & 0 deletions trunk/arch/mips/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include <linux/ioport.h>
#include <linux/of.h>

/*
* Each pci channel is a top-level PCI bus seem by CPU. A machine with
Expand All @@ -26,6 +27,7 @@
struct pci_controller {
struct pci_controller *next;
struct pci_bus *bus;
struct device_node *of_node;

struct pci_ops *pci_ops;
struct resource *mem_resource;
Expand Down Expand Up @@ -142,4 +144,8 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)

extern char * (*pcibios_plat_setup)(char *str);

/* this function parses memory ranges from a device node */
extern void __devinit pci_load_of_ranges(struct pci_controller *hose,
struct device_node *node);

#endif /* _ASM_PCI_H */
55 changes: 55 additions & 0 deletions trunk/arch/mips/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/init.h>
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/of_address.h>

#include <asm/cpu-info.h>

Expand Down Expand Up @@ -114,9 +115,63 @@ static void __devinit pcibios_scanbus(struct pci_controller *hose)
pci_bus_assign_resources(bus);
pci_enable_bridges(bus);
}
bus->dev.of_node = hose->of_node;
}
}

#ifdef CONFIG_OF
void __devinit pci_load_of_ranges(struct pci_controller *hose,
struct device_node *node)
{
const __be32 *ranges;
int rlen;
int pna = of_n_addr_cells(node);
int np = pna + 5;

pr_info("PCI host bridge %s ranges:\n", node->full_name);
ranges = of_get_property(node, "ranges", &rlen);
if (ranges == NULL)
return;
hose->of_node = node;

while ((rlen -= np * 4) >= 0) {
u32 pci_space;
struct resource *res = NULL;
u64 addr, size;

pci_space = be32_to_cpup(&ranges[0]);
addr = of_translate_address(node, ranges + 3);
size = of_read_number(ranges + pna + 3, 2);
ranges += np;
switch ((pci_space >> 24) & 0x3) {
case 1: /* PCI IO space */
pr_info(" IO 0x%016llx..0x%016llx\n",
addr, addr + size - 1);
hose->io_map_base =
(unsigned long)ioremap(addr, size);
res = hose->io_resource;
res->flags = IORESOURCE_IO;
break;
case 2: /* PCI Memory space */
case 3: /* PCI 64 bits Memory space */
pr_info(" MEM 0x%016llx..0x%016llx\n",
addr, addr + size - 1);
res = hose->mem_resource;
res->flags = IORESOURCE_MEM;
break;
}
if (res != NULL) {
res->start = addr;
res->name = node->full_name;
res->end = res->start + size - 1;
res->parent = NULL;
res->sibling = NULL;
res->child = NULL;
}
}
}
#endif

static DEFINE_MUTEX(pci_scan_mutex);

void __devinit register_pci_controller(struct pci_controller *hose)
Expand Down

0 comments on commit 5bbf2c4

Please sign in to comment.