aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm63xx/patches-3.14/365-MIPS-BCM63XX-allow-setting-a-pci-bus-device-for-fall.patch
blob: 40591e5f2e0fe76c5f96d62cb9b0d2a68721028b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
From f393eaacf178e7e8a61eb11a96edd7dfb35cb49d Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jogo@openwrt.org>
Date: Thu, 31 Jul 2014 20:39:44 +0200
Subject: [PATCH 10/10] MIPS: BCM63XX: allow setting a pci bus/device for
 fallback sprom

Warn if the set pci bus/slot does not match the actual request.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
---
 arch/mips/bcm63xx/sprom.c                          | 31 ++++++++++++++++++----
 .../asm/mach-bcm63xx/bcm63xx_fallback_sprom.h      |  3 +++
 2 files changed, 29 insertions(+), 5 deletions(-)

--- a/arch/mips/bcm63xx/sprom.c
+++ b/arch/mips/bcm63xx/sprom.c
@@ -381,13 +381,25 @@ static __initconst u16 bcm4331_sprom[] =
 
 #endif  /* CONFIG_BCMA_HOST_PCI */
 
-static struct ssb_sprom bcm63xx_sprom;
+struct fallback_sprom_match {
+	u8 pci_bus;
+	u8 pci_dev;
+	struct ssb_sprom sprom;
+};
+
+static struct fallback_sprom_match fallback_sprom;
 
 #if defined(CONFIG_SSB_PCIHOST)
 int bcm63xx_get_fallback_ssb_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
 {
 	if (bus->bustype == SSB_BUSTYPE_PCI) {
-		memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
+		if (bus->host_pci->bus->number != fallback_sprom.pci_bus ||
+		    PCI_SLOT(bus->host_pci->devfn) != fallback_sprom.pci_dev)
+			pr_warn("ssb_fallback_sprom: pci bus/device num mismatch: expected %i/%i, but got %i/%i\n",
+				fallback_sprom.pci_bus, fallback_sprom.pci_dev,
+				bus->host_pci->bus->number,
+				PCI_SLOT(bus->host_pci->devfn));
+		memcpy(out, &fallback_sprom.sprom, sizeof(struct ssb_sprom));
 		return 0;
 	} else {
 		printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
@@ -400,7 +412,13 @@ int bcm63xx_get_fallback_ssb_sprom(struc
 int bcm63xx_get_fallback_bcma_sprom(struct bcma_bus *bus, struct ssb_sprom *out)
 {
 	if (bus->hosttype == BCMA_HOSTTYPE_PCI) {
-		memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
+		if (bus->host_pci->bus->number != fallback_sprom.pci_bus ||
+		    PCI_SLOT(bus->host_pci->devfn) != fallback_sprom.pci_dev)
+			pr_warn("bcma_fallback_sprom: pci bus/device num mismatch: expected %i/%i, but got %i/%i\n",
+				fallback_sprom.pci_bus, fallback_sprom.pci_dev,
+				bus->host_pci->bus->number,
+				PCI_SLOT(bus->host_pci->devfn));
+		memcpy(out, &fallback_sprom.sprom, sizeof(struct ssb_sprom));
 		return 0;
 	} else {
 		printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
@@ -962,8 +980,8 @@ int __init bcm63xx_register_fallback_spr
 		break;
 #endif
 	case SPROM_DEFAULT:
-		memcpy(&bcm63xx_sprom, &bcm63xx_default_sprom,
-		       sizeof(bcm63xx_sprom));
+		memcpy(&fallback_sprom.sprom, &bcm63xx_default_sprom,
+		       sizeof(bcm63xx_default_sprom));
 		break;
 	default:
 		return -EINVAL;
@@ -973,12 +991,15 @@ int __init bcm63xx_register_fallback_spr
 		sprom_apply_fixups(template_sprom, data->board_fixups,
 				   data->num_board_fixups);
 
-		sprom_extract(&bcm63xx_sprom, template_sprom, size);
+		sprom_extract(&fallback_sprom.sprom, template_sprom, size);
 	}
 
-	memcpy(bcm63xx_sprom.il0mac, data->mac_addr, ETH_ALEN);
-	memcpy(bcm63xx_sprom.et0mac, data->mac_addr, ETH_ALEN);
-	memcpy(bcm63xx_sprom.et1mac, data->mac_addr, ETH_ALEN);
+	memcpy(fallback_sprom.sprom.il0mac, data->mac_addr, ETH_ALEN);
+	memcpy(fallback_sprom.sprom.et0mac, data->mac_addr, ETH_ALEN);
+	memcpy(fallback_sprom.sprom.et1mac, data->mac_addr, ETH_ALEN);
+
+	fallback_sprom.pci_bus = data->pci_bus;
+	fallback_sprom.pci_dev = data->pci_dev;
 #endif /* defined(CONFIG_SSB_PCIHOST) || defined(CONFIG_BCMA_HOST_PCI) */
 
 #if defined(CONFIG_SSB_PCIHOST)
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
@@ -30,6 +30,9 @@ struct fallback_sprom_data {
 	u8 mac_addr[ETH_ALEN];
 	enum sprom_type type;
 
+	u8 pci_bus;
+	u8 pci_dev;
+
 	struct sprom_fixup *board_fixups;
 	unsigned int num_board_fixups;
 };