From 07234dc8bd2a9bd7948220b146f13cf95580b1a2 Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Thu, 4 Oct 2012 15:45:54 +0000
Subject: [PATCH] bcma: do not initialize deactivated PCIe cores

Before it was tried to initialize the deactivated PCIe core in client
mode, but this causes the SoC to hang. Just do not initialize it at all
and ignore the core it is not working and nothing is connected to it
when the specific bit is set in the boardflags.

SVN-Revision: 33620
---
 ...ot-initialize-deactivated-PCIe-cores.patch | 26 +++++++++++++++++++
 .../240-bcma-pcie-config-access.patch         | 12 ++++-----
 2 files changed, 32 insertions(+), 6 deletions(-)
 create mode 100644 target/linux/brcm47xx/patches-3.3/204-bcma-do-not-initialize-deactivated-PCIe-cores.patch

diff --git a/target/linux/brcm47xx/patches-3.3/204-bcma-do-not-initialize-deactivated-PCIe-cores.patch b/target/linux/brcm47xx/patches-3.3/204-bcma-do-not-initialize-deactivated-PCIe-cores.patch
new file mode 100644
index 0000000000..302ac8d954
--- /dev/null
+++ b/target/linux/brcm47xx/patches-3.3/204-bcma-do-not-initialize-deactivated-PCIe-cores.patch
@@ -0,0 +1,26 @@
+--- a/drivers/bcma/driver_pci_host.c
++++ b/drivers/bcma/driver_pci_host.c
+@@ -35,11 +35,6 @@ bool __devinit bcma_core_pci_is_in_hostm
+ 	    chipid_top != 0x5300)
+ 		return false;
+ 
+-	if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
+-		bcma_info(bus, "This PCI core is disabled and not working\n");
+-		return false;
+-	}
+-
+ 	bcma_core_enable(pc->core, 0);
+ 
+ 	return !mips_busprobe32(tmp, pc->core->io_addr);
+@@ -396,6 +391,11 @@ void __devinit bcma_core_pci_hostmode_in
+ 
+ 	bcma_info(bus, "PCIEcore in host mode found\n");
+ 
++	if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
++		bcma_info(bus, "This PCIE core is disabled and not working\n");
++		return;
++	}
++
+ 	pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
+ 	if (!pc_host)  {
+ 		bcma_err(bus, "can not allocate memory");
diff --git a/target/linux/brcm47xx/patches-3.3/240-bcma-pcie-config-access.patch b/target/linux/brcm47xx/patches-3.3/240-bcma-pcie-config-access.patch
index 874c249b0f..91b8a4191c 100644
--- a/target/linux/brcm47xx/patches-3.3/240-bcma-pcie-config-access.patch
+++ b/target/linux/brcm47xx/patches-3.3/240-bcma-pcie-config-access.patch
@@ -1,6 +1,6 @@
 --- a/drivers/bcma/driver_pci_host.c
 +++ b/drivers/bcma/driver_pci_host.c
-@@ -99,19 +99,19 @@ static int bcma_extpci_read_config(struc
+@@ -94,19 +94,19 @@ static int bcma_extpci_read_config(struc
  	if (dev == 0) {
  		/* we support only two functions on device 0 */
  		if (func > 1)
@@ -23,7 +23,7 @@
  			val = pcicore_read32(pc, addr);
  		}
  	} else {
-@@ -127,8 +127,6 @@ static int bcma_extpci_read_config(struc
+@@ -122,8 +122,6 @@ static int bcma_extpci_read_config(struc
  			val = 0xffffffff;
  			goto unmap;
  		}
@@ -32,7 +32,7 @@
  	}
  	val >>= (8 * (off & 3));
  
-@@ -156,7 +154,7 @@ static int bcma_extpci_write_config(stru
+@@ -151,7 +149,7 @@ static int bcma_extpci_write_config(stru
  				   const void *buf, int len)
  {
  	int err = -EINVAL;
@@ -41,7 +41,7 @@
  	void __iomem *mmio = 0;
  	u16 chipid = pc->core->bus->chipinfo.id;
  
-@@ -164,16 +162,22 @@ static int bcma_extpci_write_config(stru
+@@ -159,16 +157,22 @@ static int bcma_extpci_write_config(stru
  	if (unlikely(len != 1 && len != 2 && len != 4))
  		goto out;
  	if (dev == 0) {
@@ -70,7 +70,7 @@
  		}
  	} else {
  		addr = bcma_get_cfgspace_addr(pc, dev, func, off);
-@@ -192,12 +196,10 @@ static int bcma_extpci_write_config(stru
+@@ -187,12 +191,10 @@ static int bcma_extpci_write_config(stru
  
  	switch (len) {
  	case 1:
@@ -83,7 +83,7 @@
  		val &= ~(0xFFFF << (8 * (off & 3)));
  		val |= *((const u16 *)buf) << (8 * (off & 3));
  		break;
-@@ -205,13 +207,14 @@ static int bcma_extpci_write_config(stru
+@@ -200,13 +202,14 @@ static int bcma_extpci_write_config(stru
  		val = *((const u32 *)buf);
  		break;
  	}
-- 
2.30.2