Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc3fb71c authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Paul Mackerras
Browse files

[POWERPC] pci32: Add flags modifying the PCI code behaviour



This adds to the 32 bits PCI code some flags, replacing the old
pci_assign_all_busses global, that allow us to control various
aspects of the PCI probing, such as whether to re-assign all
resources or not, or to not try to assign anything at all.

This also adds the flag x86 already has to avoid ISA alignment
on bridges that don't have ISA forwarding enabled (no legacy
devices on the top level bus) and sets it for PowerMacs.

Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent b9baa20b
Loading
Loading
Loading
Loading
+34 −8
Original line number Original line Diff line number Diff line
@@ -35,6 +35,9 @@ unsigned long isa_io_base = 0;
unsigned long pci_dram_offset = 0;
unsigned long pci_dram_offset = 0;
int pcibios_assign_bus_offset = 1;
int pcibios_assign_bus_offset = 1;


/* Default PCI flags is 0 */
unsigned int ppc_pci_flags;

void pcibios_make_OF_bus_map(void);
void pcibios_make_OF_bus_map(void);


static void pcibios_fixup_resources(struct pci_dev* dev);
static void pcibios_fixup_resources(struct pci_dev* dev);
@@ -48,7 +51,7 @@ static u8* pci_to_OF_bus_map;
/* By default, we don't re-assign bus numbers. We do this only on
/* By default, we don't re-assign bus numbers. We do this only on
 * some pmacs
 * some pmacs
 */
 */
int pci_assign_all_buses;
static int pci_assign_all_buses;


LIST_HEAD(hose_list);
LIST_HEAD(hose_list);


@@ -174,6 +177,14 @@ void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
}
}
EXPORT_SYMBOL(pcibios_bus_to_resource);
EXPORT_SYMBOL(pcibios_bus_to_resource);


static int skip_isa_ioresource_align(struct pci_dev *dev)
{
	if ((ppc_pci_flags & PPC_PCI_CAN_SKIP_ISA_ALIGN) &&
	    !(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA))
		return 1;
	return 0;
}

/*
/*
 * We need to avoid collisions with `mirrored' VGA ports
 * We need to avoid collisions with `mirrored' VGA ports
 * and other strange ISA hardware, so we always want the
 * and other strange ISA hardware, so we always want the
@@ -195,6 +206,8 @@ void pcibios_align_resource(void *data, struct resource *res,
	if (res->flags & IORESOURCE_IO) {
	if (res->flags & IORESOURCE_IO) {
		resource_size_t start = res->start;
		resource_size_t start = res->start;


		if (skip_isa_ioresource_align(dev))
			return;
		if (start & 0x300) {
		if (start & 0x300) {
			start = (start + 0x3ff) & ~0x3ff;
			start = (start + 0x3ff) & ~0x3ff;
			res->start = start;
			res->start = start;
@@ -253,6 +266,11 @@ pcibios_allocate_bus_resources(struct list_head *bus_list)
				pr = (res->flags & IORESOURCE_IO)?
				pr = (res->flags & IORESOURCE_IO)?
					&ioport_resource : &iomem_resource;
					&ioport_resource : &iomem_resource;
			else {
			else {
				/* Don't bother with non-root busses when
				 * re-assigning all resources.
				 */
				if (ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC)
					continue;
				pr = pci_find_parent_resource(bus->self, res);
				pr = pci_find_parent_resource(bus->self, res);
				if (pr == res) {
				if (pr == res) {
					/* this happens when the generic PCI
					/* this happens when the generic PCI
@@ -720,6 +738,9 @@ pcibios_init(void)


	printk(KERN_INFO "PCI: Probing PCI hardware\n");
	printk(KERN_INFO "PCI: Probing PCI hardware\n");


	if (ppc_pci_flags & PPC_PCI_REASSIGN_ALL_BUS)
		pci_assign_all_buses = 1;

	/* Scan all of the recorded PCI controllers.  */
	/* Scan all of the recorded PCI controllers.  */
	list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
	list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
		if (pci_assign_all_buses)
		if (pci_assign_all_buses)
@@ -746,13 +767,18 @@ pcibios_init(void)
	if (ppc_md.pcibios_fixup)
	if (ppc_md.pcibios_fixup)
		ppc_md.pcibios_fixup();
		ppc_md.pcibios_fixup();


	/* Allocate and assign resources */
	/* Allocate and assign resources. If we re-assign everything, then
	 * we skip the allocate phase
	 */
	pcibios_allocate_bus_resources(&pci_root_buses);
	pcibios_allocate_bus_resources(&pci_root_buses);
	if (!(ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC)) {
		pcibios_allocate_resources(0);
		pcibios_allocate_resources(0);
		pcibios_allocate_resources(1);
		pcibios_allocate_resources(1);

	}
	if (!(ppc_pci_flags & PPC_PCI_PROBE_ONLY)) {
		DBG("PCI: Assigning unassigned resouces...\n");
		DBG("PCI: Assigning unassigned resouces...\n");
		pci_assign_unassigned_resources();
		pci_assign_unassigned_resources();
	}


	/* Call machine dependent post-init code */
	/* Call machine dependent post-init code */
	if (ppc_md.pcibios_after_init)
	if (ppc_md.pcibios_after_init)
+0 −1
Original line number Original line Diff line number Diff line
@@ -40,7 +40,6 @@
#endif
#endif


unsigned long pci_probe_only = 1;
unsigned long pci_probe_only = 1;
int pci_assign_all_buses = 0;


static void fixup_resource(struct resource *res, struct pci_dev *dev);
static void fixup_resource(struct resource *res, struct pci_dev *dev);
static void do_bus_setup(struct pci_bus *bus);
static void do_bus_setup(struct pci_bus *bus);
+4 −2
Original line number Original line Diff line number Diff line
@@ -311,10 +311,12 @@ void __init find_and_init_phbs(void)
		if (prop)
		if (prop)
			pci_probe_only = *prop;
			pci_probe_only = *prop;


#ifdef CONFIG_PPC32 /* Will be made generic soon */
		prop = of_get_property(of_chosen,
		prop = of_get_property(of_chosen,
				"linux,pci-assign-all-buses", NULL);
				"linux,pci-assign-all-buses", NULL);
		if (prop)
		if (prop && *prop)
			pci_assign_all_buses = *prop;
			ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
#endif /* CONFIG_PPC32 */
	}
	}
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -363,7 +363,7 @@ mpc52xx_add_bridge(struct device_node *node)


	pr_debug("Adding MPC52xx PCI host bridge %s\n", node->full_name);
	pr_debug("Adding MPC52xx PCI host bridge %s\n", node->full_name);


	pci_assign_all_buses = 1;
	ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;


	if (of_address_to_resource(node, 0, &rsrc) != 0) {
	if (of_address_to_resource(node, 0, &rsrc) != 0) {
		printk(KERN_ERR "Can't get %s resources\n", node->full_name);
		printk(KERN_ERR "Can't get %s resources\n", node->full_name);
+1 −1
Original line number Original line Diff line number Diff line
@@ -53,7 +53,7 @@ static void __init pq2_pci_add_bridge(struct device_node *np)
	if (of_address_to_resource(np, 0, &r) || r.end - r.start < 0x10b)
	if (of_address_to_resource(np, 0, &r) || r.end - r.start < 0x10b)
		goto err;
		goto err;


	pci_assign_all_buses = 1;
	ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;


	hose = pcibios_alloc_controller(np);
	hose = pcibios_alloc_controller(np);
	if (!hose)
	if (!hose)
Loading