linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] Modified quirk_mpc8641_transparent() to initialize bridge resources.
@ 2007-05-29 18:23 Jon Loeliger
  2007-05-29 20:49 ` Kumar Gala
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Loeliger @ 2007-05-29 18:23 UTC (permalink / raw)
  To: linuxppc-dev@ozlabs.org

From: Jon Loeliger <jdl@freescale.com>

The 8641 RC poses as a transparent bridge, but does not implement the
IO_BASE or IO_LIMIT registers in the config space.  This means that
the code which initializes the bridge resources ends up setting the
IO resources erroneously.

This change initializes the RC bridge resources from the device tree.

Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jon Loeliger <jdl@freescale.com>
---
 arch/powerpc/platforms/86xx/mpc86xx_hpcn.c |   63 +++++++++++++++++++++++++++-
 1 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 7034bca..94e3c50 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -318,6 +318,7 @@ static void __devinit quirk_uli5288(struct pci_dev *dev)
 static void __devinit quirk_uli5229(struct pci_dev *dev)
 {
 	unsigned short temp;
+
 	pci_write_config_word(dev, 0x04, 0x0405);
 	dev->class &= ~0x5;
 	pci_read_config_word(dev, 0x4a, &temp);
@@ -325,9 +326,67 @@ static void __devinit quirk_uli5229(struct pci_dev *dev)
 	pci_write_config_word(dev, 0x4a, temp);
 }
 
+#define GET_64BIT(prop, i)	((((u64) (prop)[(i)]) << 32) | (prop)[(i)+1])
+
 static void __devinit quirk_mpc8641_transparent(struct pci_dev *dev)
 {
+	const u32 *ranges;
+	struct resource *res;
+	int len;
+	int i;
+	unsigned int flags;
+	u64 size;
+	struct device_node *node;
+	struct pci_controller *hose;
+
+	/*
+	 * Make the bridge be transparent.
+	 */
 	dev->transparent = 1;
+
+	/*
+	 * parse ranges property
+	 * Ensure IO resource is placed in the PCI_BRIDGE_RESOURCES entry.
+	 * PCI #address-cells == 3 and #size-cells == 2 always
+	 */
+	node = pci_device_to_OF_node(dev);
+
+	hose = pci_bus_to_hose(dev->bus->number);
+	node = hose->arch_data;
+
+	ranges = of_get_property(node, "ranges", &len);
+	if (ranges == NULL) {
+		printk(KERN_DEBUG "Can't get ranges for PCI-PCI bridge %s\n",
+		       node->full_name);
+		return;
+	}
+
+	i = PCI_BRIDGE_RESOURCES + 1;
+	for (; len >= 24; len -= 24, ranges += 6) {
+		flags = of_bus_pci_get_flags(&ranges[0]);
+		size = GET_64BIT(ranges, 4);
+		if (flags == 0 || size == 0)
+			continue;
+		if (flags & IORESOURCE_IO) {
+			res = &dev->resource[PCI_BRIDGE_RESOURCES];
+			if (res->flags) {
+				printk(KERN_ERR "PCI: ignoring extra I/O range"
+				       " for bridge %s\n", node->full_name);
+				continue;
+			}
+		} else {
+			if (i >= PCI_NUM_RESOURCES) {
+				printk(KERN_ERR "PCI: too many memory ranges"
+				       " for bridge %s\n", node->full_name);
+				continue;
+			}
+			res = &dev->resource[i];
+			++i;
+		}
+		res->start = GET_64BIT(ranges, 1);
+		res->end = res->start + size - 1;
+		res->flags = flags;
+	}
 }
 
 static void __devinit early_uli5249(struct pci_dev *dev)
@@ -344,8 +403,8 @@ static void __devinit early_uli5249(struct pci_dev *dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, quirk_uli1575);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5288, quirk_uli5288);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, quirk_uli5229);
-DECLARE_PCI_FIXUP_HEADER(0x1957, 0x7010, quirk_mpc8641_transparent);
-DECLARE_PCI_FIXUP_HEADER(0x1957, 0x7011, quirk_mpc8641_transparent);
+DECLARE_PCI_FIXUP_EARLY(0x1957, 0x7010, quirk_mpc8641_transparent);
+DECLARE_PCI_FIXUP_EARLY(0x1957, 0x7011, quirk_mpc8641_transparent);
 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AL, 0x5249, early_uli5249);
 #endif /* CONFIG_PCI */
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] Modified quirk_mpc8641_transparent() to initialize bridge resources.
  2007-05-29 18:23 [PATCH 3/3] Modified quirk_mpc8641_transparent() to initialize bridge resources Jon Loeliger
@ 2007-05-29 20:49 ` Kumar Gala
  2007-05-31  6:48   ` [PATCH 3/3] Modified quirk_mpc8641_transparent() to initializebridge resources Zang Roy-r61911
  0 siblings, 1 reply; 5+ messages in thread
From: Kumar Gala @ 2007-05-29 20:49 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev@ozlabs.org


On May 29, 2007, at 1:23 PM, Jon Loeliger wrote:

> From: Jon Loeliger <jdl@freescale.com>
>
> The 8641 RC poses as a transparent bridge, but does not implement the
> IO_BASE or IO_LIMIT registers in the config space.  This means that
> the code which initializes the bridge resources ends up setting the
> IO resources erroneously.
>
> This change initializes the RC bridge resources from the device tree.
>
> Signed-off-by: Andy Fleming <afleming@freescale.com>
> Signed-off-by: Jon Loeliger <jdl@freescale.com>

Can this be merged with Zhang's "Set RC of mpc8641 to transparent  
bridge for transfer legacy I/O access." patch since it pretty much  
supersedes it.

- k

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 3/3] Modified quirk_mpc8641_transparent() to initializebridge resources.
  2007-05-29 20:49 ` Kumar Gala
@ 2007-05-31  6:48   ` Zang Roy-r61911
  2007-05-31 12:33     ` Kumar Gala
  2007-05-31 14:10     ` Jon Loeliger
  0 siblings, 2 replies; 5+ messages in thread
From: Zang Roy-r61911 @ 2007-05-31  6:48 UTC (permalink / raw)
  To: Kumar Gala, Loeliger Jon-LOELIGER; +Cc: linuxppc-dev

>=20
> On May 29, 2007, at 1:23 PM, Jon Loeliger wrote:
>=20
> > From: Jon Loeliger <jdl@freescale.com>
> >
> > The 8641 RC poses as a transparent bridge, but does not=20
> implement the
> > IO_BASE or IO_LIMIT registers in the config space.  This means that
> > the code which initializes the bridge resources ends up setting the
> > IO resources erroneously.
> >
> > This change initializes the RC bridge resources from the=20
> device tree.
> >
> > Signed-off-by: Andy Fleming <afleming@freescale.com>
> > Signed-off-by: Jon Loeliger <jdl@freescale.com>
>=20
> Can this be merged with Zhang's "Set RC of mpc8641 to transparent =20
> bridge for transfer legacy I/O access." patch since it pretty much =20
> supersedes it.

I should be!=20
But why apply them sperately?=20
They refect differnet content and stage. For end user, they will only
see the unified code :-).
Roy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] Modified quirk_mpc8641_transparent() to initializebridge resources.
  2007-05-31  6:48   ` [PATCH 3/3] Modified quirk_mpc8641_transparent() to initializebridge resources Zang Roy-r61911
@ 2007-05-31 12:33     ` Kumar Gala
  2007-05-31 14:10     ` Jon Loeliger
  1 sibling, 0 replies; 5+ messages in thread
From: Kumar Gala @ 2007-05-31 12:33 UTC (permalink / raw)
  To: Zang Roy-r61911; +Cc: linuxppc-dev


On May 31, 2007, at 1:48 AM, Zang Roy-r61911 wrote:

>>
>> On May 29, 2007, at 1:23 PM, Jon Loeliger wrote:
>>
>>> From: Jon Loeliger <jdl@freescale.com>
>>>
>>> The 8641 RC poses as a transparent bridge, but does not
>> implement the
>>> IO_BASE or IO_LIMIT registers in the config space.  This means that
>>> the code which initializes the bridge resources ends up setting the
>>> IO resources erroneously.
>>>
>>> This change initializes the RC bridge resources from the
>> device tree.
>>>
>>> Signed-off-by: Andy Fleming <afleming@freescale.com>
>>> Signed-off-by: Jon Loeliger <jdl@freescale.com>
>>
>> Can this be merged with Zhang's "Set RC of mpc8641 to transparent
>> bridge for transfer legacy I/O access." patch since it pretty much
>> supersedes it.
>
> I should be!
> But why apply them sperately?
> They refect differnet content and stage. For end user, they will only
> see the unified code :-).

The reason is that in the future someone may be doing a git-bisect to  
track down a bug and we like to have patches not break things if  
possible.

- k

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 3/3] Modified quirk_mpc8641_transparent() to initializebridge resources.
  2007-05-31  6:48   ` [PATCH 3/3] Modified quirk_mpc8641_transparent() to initializebridge resources Zang Roy-r61911
  2007-05-31 12:33     ` Kumar Gala
@ 2007-05-31 14:10     ` Jon Loeliger
  1 sibling, 0 replies; 5+ messages in thread
From: Jon Loeliger @ 2007-05-31 14:10 UTC (permalink / raw)
  To: Roy Zang; +Cc: linuxppc-dev@ozlabs.org

On Thu, 2007-05-31 at 01:48, Zang Roy-r61911 wrote:

> > Can this be merged with Zhang's "Set RC of mpc8641 to transparent  
> > bridge for transfer legacy I/O access." patch since it pretty much  
> > supersedes it.
> 
> I should be! 
> But why apply them sperately? 
> They refect differnet content and stage. For end user, they will only
> see the unified code :-).
> Roy

I have respun these two PCI-E patch sets into one and will post
them again.

jdl

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-05-31 14:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-29 18:23 [PATCH 3/3] Modified quirk_mpc8641_transparent() to initialize bridge resources Jon Loeliger
2007-05-29 20:49 ` Kumar Gala
2007-05-31  6:48   ` [PATCH 3/3] Modified quirk_mpc8641_transparent() to initializebridge resources Zang Roy-r61911
2007-05-31 12:33     ` Kumar Gala
2007-05-31 14:10     ` Jon Loeliger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).