777a82bd9b3f39266258d07643cd118f9c177f0e
[openwrt/openwrt.git] / target / linux / brcm47xx / patches-4.1 / 033-03-MIPS-BCM47xx-Fetch-board-info-directly-in-callback-f.patch
1 From d8cfb5037bfc875e6dc8e09e4caceb443c04ff6a Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Mon, 26 Oct 2015 11:13:16 +0100
4 Subject: [PATCH 3/3] MIPS: BCM47xx: Fetch board info directly in callback
5 function
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 This drops another symbol dependency between setup.c and sprom.c which
11 will allow us to make SPROM code a separated module (and share it with
12 ARM).
13 Patch tested on Linksys WRT300N V1.
14
15 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
16 Cc: Hauke Mehrtens <hauke@hauke-m.de>
17 Cc: linux-mips@linux-mips.org
18 Patchwork: https://patchwork.linux-mips.org/patch/11360/
19 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
20 ---
21 arch/mips/bcm47xx/setup.c | 19 ++++++++++++++++++-
22 arch/mips/bcm47xx/sprom.c | 13 -------------
23 arch/mips/include/asm/mach-bcm47xx/bcm47xx.h | 5 -----
24 3 files changed, 18 insertions(+), 19 deletions(-)
25
26 --- a/arch/mips/bcm47xx/setup.c
27 +++ b/arch/mips/bcm47xx/setup.c
28 @@ -105,11 +105,28 @@ static int bcm47xx_get_invariants(struct
29 struct ssb_init_invariants *iv)
30 {
31 char buf[20];
32 + int len, err;
33
34 /* Fill boardinfo structure */
35 memset(&iv->boardinfo, 0 , sizeof(struct ssb_boardinfo));
36
37 - bcm47xx_fill_ssb_boardinfo(&iv->boardinfo, NULL);
38 + len = bcm47xx_nvram_getenv("boardvendor", buf, sizeof(buf));
39 + if (len > 0) {
40 + err = kstrtou16(strim(buf), 0, &iv->boardinfo.vendor);
41 + if (err)
42 + pr_warn("Couldn't parse nvram board vendor entry with value \"%s\"\n",
43 + buf);
44 + }
45 + if (!iv->boardinfo.vendor)
46 + iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
47 +
48 + len = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf));
49 + if (len > 0) {
50 + err = kstrtou16(strim(buf), 0, &iv->boardinfo.type);
51 + if (err)
52 + pr_warn("Couldn't parse nvram board type entry with value \"%s\"\n",
53 + buf);
54 + }
55
56 memset(&iv->sprom, 0, sizeof(struct ssb_sprom));
57 bcm47xx_fill_sprom(&iv->sprom, NULL, false);
58 --- a/arch/mips/bcm47xx/sprom.c
59 +++ b/arch/mips/bcm47xx/sprom.c
60 @@ -599,19 +599,6 @@ void bcm47xx_fill_sprom(struct ssb_sprom
61 bcm47xx_sprom_fill_auto(sprom, prefix, fallback);
62 }
63
64 -#ifdef CONFIG_BCM47XX_SSB
65 -void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
66 - const char *prefix)
67 -{
68 - nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0,
69 - true);
70 - if (!boardinfo->vendor)
71 - boardinfo->vendor = SSB_BOARDVENDOR_BCM;
72 -
73 - nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
74 -}
75 -#endif
76 -
77 #if defined(CONFIG_BCM47XX_SSB)
78 static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
79 {
80 --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
81 +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
82 @@ -48,11 +48,6 @@ extern enum bcm47xx_bus_type bcm47xx_bus
83 void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix,
84 bool fallback);
85
86 -#ifdef CONFIG_BCM47XX_SSB
87 -void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
88 - const char *prefix);
89 -#endif
90 -
91 void bcm47xx_set_system_type(u16 chip_id);
92
93 #endif /* __ASM_BCM47XX_H */