brcm47xx: rename target to bcm47xx
[openwrt/staging/wigyori.git] / target / linux / brcm63xx / patches-4.14 / 356-MIPS-BCM63XX-move-fallback-sprom-support-into-its-ow.patch
1 From cc025e749a1fece61a6cc0d64bbe7b12472259cc Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Tue, 29 Jul 2014 21:31:12 +0200
4 Subject: [PATCH 01/10] MIPS: BCM63XX: move fallback sprom support into its own
5 unit
6
7 In preparation for enhancing it, move it into its own file. Require a
8 mac address to be passed as the argument to always "reserve" the mac
9 regardless of the inclusion state of SSB.
10
11 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
12 ---
13 arch/mips/bcm63xx/Makefile | 2 +-
14 arch/mips/bcm63xx/boards/board_common.c | 53 ++--------------
15 arch/mips/bcm63xx/sprom.c | 70 ++++++++++++++++++++++
16 .../asm/mach-bcm63xx/bcm63xx_fallback_sprom.h | 6 ++
17 4 files changed, 83 insertions(+), 48 deletions(-)
18 create mode 100644 arch/mips/bcm63xx/sprom.c
19 create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
20
21 --- a/arch/mips/bcm63xx/Makefile
22 +++ b/arch/mips/bcm63xx/Makefile
23 @@ -2,7 +2,8 @@
24 obj-y += clk.o cpu.o cs.o gpio.o irq.o nvram.o prom.o reset.o \
25 setup.o timer.o dev-enet.o dev-flash.o dev-pcmcia.o \
26 dev-rng.o dev-spi.o dev-hsspi.o dev-uart.o dev-wdt.o \
27 - dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o usb-common.o
28 + dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o usb-common.o \
29 + sprom.o
30 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
31
32 obj-y += boards/
33 --- a/arch/mips/bcm63xx/boards/board_common.c
34 +++ b/arch/mips/bcm63xx/boards/board_common.c
35 @@ -39,44 +39,6 @@
36 static struct board_info board;
37
38 /*
39 - * Register a sane SPROMv2 to make the on-board
40 - * bcm4318 WLAN work
41 - */
42 -#ifdef CONFIG_SSB_PCIHOST
43 -static struct ssb_sprom bcm63xx_sprom = {
44 - .revision = 0x02,
45 - .board_rev = 0x17,
46 - .country_code = 0x0,
47 - .ant_available_bg = 0x3,
48 - .pa0b0 = 0x15ae,
49 - .pa0b1 = 0xfa85,
50 - .pa0b2 = 0xfe8d,
51 - .pa1b0 = 0xffff,
52 - .pa1b1 = 0xffff,
53 - .pa1b2 = 0xffff,
54 - .gpio0 = 0xff,
55 - .gpio1 = 0xff,
56 - .gpio2 = 0xff,
57 - .gpio3 = 0xff,
58 - .maxpwr_bg = 0x004c,
59 - .itssi_bg = 0x00,
60 - .boardflags_lo = 0x2848,
61 - .boardflags_hi = 0x0000,
62 -};
63 -
64 -int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
65 -{
66 - if (bus->bustype == SSB_BUSTYPE_PCI) {
67 - memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
68 - return 0;
69 - } else {
70 - printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
71 - return -EINVAL;
72 - }
73 -}
74 -#endif
75 -
76 -/*
77 * return board name for /proc/cpuinfo
78 */
79 const char *board_get_name(void)
80 @@ -179,6 +141,7 @@ static struct platform_device bcm63xx_gp
81 int __init board_register_devices(void)
82 {
83 int usbh_ports = 0;
84 + u8 mac[ETH_ALEN];
85
86 if (board.has_uart0)
87 bcm63xx_uart_register(0);
88 @@ -220,15 +183,10 @@ int __init board_register_devices(void)
89 /* Generate MAC address for WLAN and register our SPROM,
90 * do this after registering enet devices
91 */
92 -#ifdef CONFIG_SSB_PCIHOST
93 - if (!board_get_mac_address(bcm63xx_sprom.il0mac)) {
94 - memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN);
95 - memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
96 - if (ssb_arch_register_fallback_sprom(
97 - &bcm63xx_get_fallback_sprom) < 0)
98 - pr_err(PFX "failed to register fallback SPROM\n");
99 - }
100 -#endif
101 +
102 + if (board_get_mac_address(mac) ||
103 + bcm63xx_register_fallback_sprom(mac))
104 + pr_err(PFX "failed to register fallback SPROM\n");
105
106 bcm63xx_spi_register();
107
108 --- /dev/null
109 +++ b/arch/mips/bcm63xx/sprom.c
110 @@ -0,0 +1,70 @@
111 +/*
112 + * This file is subject to the terms and conditions of the GNU General Public
113 + * License. See the file "COPYING" in the main directory of this archive
114 + * for more details.
115 + *
116 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
117 + * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
118 + */
119 +
120 +#include <linux/init.h>
121 +#include <linux/kernel.h>
122 +#include <linux/string.h>
123 +#include <linux/platform_device.h>
124 +#include <linux/ssb/ssb.h>
125 +#include <bcm63xx_fallback_sprom.h>
126 +#include <board_bcm963xx.h>
127 +
128 +#define PFX "sprom: "
129 +
130 +/*
131 + * Register a sane SPROMv2 to make the on-board
132 + * bcm4318 WLAN work
133 + */
134 +#ifdef CONFIG_SSB_PCIHOST
135 +static struct ssb_sprom bcm63xx_sprom = {
136 + .revision = 0x02,
137 + .board_rev = 0x17,
138 + .country_code = 0x0,
139 + .ant_available_bg = 0x3,
140 + .pa0b0 = 0x15ae,
141 + .pa0b1 = 0xfa85,
142 + .pa0b2 = 0xfe8d,
143 + .pa1b0 = 0xffff,
144 + .pa1b1 = 0xffff,
145 + .pa1b2 = 0xffff,
146 + .gpio0 = 0xff,
147 + .gpio1 = 0xff,
148 + .gpio2 = 0xff,
149 + .gpio3 = 0xff,
150 + .maxpwr_bg = 0x004c,
151 + .itssi_bg = 0x00,
152 + .boardflags_lo = 0x2848,
153 + .boardflags_hi = 0x0000,
154 +};
155 +
156 +int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
157 +{
158 + if (bus->bustype == SSB_BUSTYPE_PCI) {
159 + memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
160 + return 0;
161 + } else {
162 + printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
163 + return -EINVAL;
164 + }
165 +}
166 +#endif
167 +
168 +int __init bcm63xx_register_fallback_sprom(u8 *mac)
169 +{
170 + int ret = 0;
171 +
172 +#ifdef CONFIG_SSB_PCIHOST
173 + memcpy(bcm63xx_sprom.il0mac, mac, ETH_ALEN);
174 + memcpy(bcm63xx_sprom.et0mac, mac, ETH_ALEN);
175 + memcpy(bcm63xx_sprom.et1mac, mac, ETH_ALEN);
176 +
177 + ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_sprom);
178 +#endif
179 + return ret;
180 +}
181 --- /dev/null
182 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
183 @@ -0,0 +1,6 @@
184 +#ifndef __BCM63XX_FALLBACK_SPROM
185 +#define __BCM63XX_FALLBACK_SPROM
186 +
187 +int bcm63xx_register_fallback_sprom(u8 *mac);
188 +
189 +#endif