d3873d4ae63316542d75bfe72cfed35bf8f66406
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-4.0 / 031-05-MIPS-BCM47xx-Read-board-info-for-all-bcma-buses.patch
1 From 12e1ab54dcd414c3579cfd26be9d9c9e1cab92ad Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Tue, 12 May 2015 13:05:18 +0200
4 Subject: [PATCH] MIPS: BCM47xx: Read board info for all bcma buses
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Extra bcma buses may be totally different models, see following dump:
10 boardtype=0x0646
11 pci/1/1/boardtype=0x0545
12 pci/2/1/boardtype=0x62b
13 We need to detect them properly to allow drivers apply some board
14 specific hacks.
15
16 [ralf@linux-mips.org: folded in Rafal's fix.]
17
18 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
19 Cc: linux-mips@linux-mips.org
20 Cc: Hauke Mehrtens <hauke@hauke-m.de>
21 Patchwork: https://patchwork.linux-mips.org/patch/10028/
22 Patchwork: https://patchwork.linux-mips.org/patch/10048/
23 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
24 ---
25 arch/mips/bcm47xx/setup.c | 3 --
26 arch/mips/bcm47xx/sprom.c | 44 ++++++++++++++--------------
27 arch/mips/include/asm/mach-bcm47xx/bcm47xx.h | 4 ---
28 3 files changed, 22 insertions(+), 29 deletions(-)
29
30 diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
31 index 82ff9fd..98c075f 100644
32 --- a/arch/mips/bcm47xx/setup.c
33 +++ b/arch/mips/bcm47xx/setup.c
34 @@ -206,9 +206,6 @@ void __init bcm47xx_bus_setup(void)
35 err = bcma_host_soc_init(&bcm47xx_bus.bcma);
36 if (err)
37 panic("Failed to initialize BCMA bus (err %d)", err);
38 -
39 - bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo,
40 - NULL);
41 }
42 #endif
43
44 diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
45 index 92a6c9d..b0d62e7 100644
46 --- a/arch/mips/bcm47xx/sprom.c
47 +++ b/arch/mips/bcm47xx/sprom.c
48 @@ -640,19 +640,6 @@ void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
49 }
50 #endif
51
52 -#ifdef CONFIG_BCM47XX_BCMA
53 -void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
54 - const char *prefix)
55 -{
56 - nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0,
57 - true);
58 - if (!boardinfo->vendor)
59 - boardinfo->vendor = SSB_BOARDVENDOR_BCM;
60 -
61 - nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
62 -}
63 -#endif
64 -
65 #if defined(CONFIG_BCM47XX_SSB)
66 static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
67 {
68 @@ -707,33 +694,46 @@ static void bcm47xx_sprom_apply_prefix_alias(char *prefix, size_t prefix_size)
69
70 static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
71 {
72 - char prefix[10];
73 + struct bcma_boardinfo *binfo = &bus->boardinfo;
74 struct bcma_device *core;
75 + char buf[10];
76 + char *prefix;
77 + bool fallback = false;
78
79 switch (bus->hosttype) {
80 case BCMA_HOSTTYPE_PCI:
81 memset(out, 0, sizeof(struct ssb_sprom));
82 - snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
83 + snprintf(buf, sizeof(buf), "pci/%u/%u/",
84 bus->host_pci->bus->number + 1,
85 PCI_SLOT(bus->host_pci->devfn));
86 - bcm47xx_sprom_apply_prefix_alias(prefix, sizeof(prefix));
87 - bcm47xx_fill_sprom(out, prefix, false);
88 - return 0;
89 + bcm47xx_sprom_apply_prefix_alias(buf, sizeof(buf));
90 + prefix = buf;
91 + break;
92 case BCMA_HOSTTYPE_SOC:
93 memset(out, 0, sizeof(struct ssb_sprom));
94 core = bcma_find_core(bus, BCMA_CORE_80211);
95 if (core) {
96 - snprintf(prefix, sizeof(prefix), "sb/%u/",
97 + snprintf(buf, sizeof(buf), "sb/%u/",
98 core->core_index);
99 - bcm47xx_fill_sprom(out, prefix, true);
100 + prefix = buf;
101 + fallback = true;
102 } else {
103 - bcm47xx_fill_sprom(out, NULL, false);
104 + prefix = NULL;
105 }
106 - return 0;
107 + break;
108 default:
109 pr_warn("Unable to fill SPROM for given bustype.\n");
110 return -EINVAL;
111 }
112 +
113 + nvram_read_u16(prefix, NULL, "boardvendor", &binfo->vendor, 0, true);
114 + if (!binfo->vendor)
115 + binfo->vendor = SSB_BOARDVENDOR_BCM;
116 + nvram_read_u16(prefix, NULL, "boardtype", &binfo->type, 0, true);
117 +
118 + bcm47xx_fill_sprom(out, prefix, fallback);
119 +
120 + return 0;
121 }
122 #endif
123
124 diff --git a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
125 index 8ed77f6..1461c10 100644
126 --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
127 +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
128 @@ -52,10 +52,6 @@ void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix,
129 void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
130 const char *prefix);
131 #endif
132 -#ifdef CONFIG_BCM47XX_BCMA
133 -void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
134 - const char *prefix);
135 -#endif
136
137 void bcm47xx_set_system_type(u16 chip_id);
138
139 --
140 1.8.4.5
141