314a6c490451b36e6f8d4b500ed0ab06890e771d
[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 --- a/arch/mips/bcm47xx/setup.c
31 +++ b/arch/mips/bcm47xx/setup.c
32 @@ -206,9 +206,6 @@ void __init bcm47xx_bus_setup(void)
33 err = bcma_host_soc_init(&bcm47xx_bus.bcma);
34 if (err)
35 panic("Failed to initialize BCMA bus (err %d)", err);
36 -
37 - bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo,
38 - NULL);
39 }
40 #endif
41
42 --- a/arch/mips/bcm47xx/sprom.c
43 +++ b/arch/mips/bcm47xx/sprom.c
44 @@ -640,19 +640,6 @@ void bcm47xx_fill_ssb_boardinfo(struct s
45 }
46 #endif
47
48 -#ifdef CONFIG_BCM47XX_BCMA
49 -void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
50 - const char *prefix)
51 -{
52 - nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0,
53 - true);
54 - if (!boardinfo->vendor)
55 - boardinfo->vendor = SSB_BOARDVENDOR_BCM;
56 -
57 - nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
58 -}
59 -#endif
60 -
61 #if defined(CONFIG_BCM47XX_SSB)
62 static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
63 {
64 @@ -707,33 +694,46 @@ static void bcm47xx_sprom_apply_prefix_a
65
66 static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
67 {
68 - char prefix[10];
69 + struct bcma_boardinfo *binfo = &bus->boardinfo;
70 struct bcma_device *core;
71 + char buf[10];
72 + char *prefix;
73 + bool fallback = false;
74
75 switch (bus->hosttype) {
76 case BCMA_HOSTTYPE_PCI:
77 memset(out, 0, sizeof(struct ssb_sprom));
78 - snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
79 + snprintf(buf, sizeof(buf), "pci/%u/%u/",
80 bus->host_pci->bus->number + 1,
81 PCI_SLOT(bus->host_pci->devfn));
82 - bcm47xx_sprom_apply_prefix_alias(prefix, sizeof(prefix));
83 - bcm47xx_fill_sprom(out, prefix, false);
84 - return 0;
85 + bcm47xx_sprom_apply_prefix_alias(buf, sizeof(buf));
86 + prefix = buf;
87 + break;
88 case BCMA_HOSTTYPE_SOC:
89 memset(out, 0, sizeof(struct ssb_sprom));
90 core = bcma_find_core(bus, BCMA_CORE_80211);
91 if (core) {
92 - snprintf(prefix, sizeof(prefix), "sb/%u/",
93 + snprintf(buf, sizeof(buf), "sb/%u/",
94 core->core_index);
95 - bcm47xx_fill_sprom(out, prefix, true);
96 + prefix = buf;
97 + fallback = true;
98 } else {
99 - bcm47xx_fill_sprom(out, NULL, false);
100 + prefix = NULL;
101 }
102 - return 0;
103 + break;
104 default:
105 pr_warn("Unable to fill SPROM for given bustype.\n");
106 return -EINVAL;
107 }
108 +
109 + nvram_read_u16(prefix, NULL, "boardvendor", &binfo->vendor, 0, true);
110 + if (!binfo->vendor)
111 + binfo->vendor = SSB_BOARDVENDOR_BCM;
112 + nvram_read_u16(prefix, NULL, "boardtype", &binfo->type, 0, true);
113 +
114 + bcm47xx_fill_sprom(out, prefix, fallback);
115 +
116 + return 0;
117 }
118 #endif
119
120 --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
121 +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
122 @@ -52,10 +52,6 @@ void bcm47xx_fill_sprom(struct ssb_sprom
123 void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
124 const char *prefix);
125 #endif
126 -#ifdef CONFIG_BCM47XX_BCMA
127 -void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
128 - const char *prefix);
129 -#endif
130
131 void bcm47xx_set_system_type(u16 chip_id);
132