summaryrefslogtreecommitdiff
path: root/target/linux/brcm63xx/patches-4.1/356-MIPS-BCM63XX-move-fallback-sprom-support-into-its-ow.patch
blob: cec6c7e1a7c88157065453174a6c889ca06353de (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
From cc025e749a1fece61a6cc0d64bbe7b12472259cc Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jogo@openwrt.org>
Date: Tue, 29 Jul 2014 21:31:12 +0200
Subject: [PATCH 01/10] MIPS: BCM63XX: move fallback sprom support into its own
 unit

In preparation for enhancing it, move it into its own file. Require a
mac address to be passed as the argument to always "reserve" the mac
regardless of the inclusion state of SSB.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
---
 arch/mips/bcm63xx/Makefile                         |  2 +-
 arch/mips/bcm63xx/boards/board_common.c            | 53 ++--------------
 arch/mips/bcm63xx/sprom.c                          | 70 ++++++++++++++++++++++
 .../asm/mach-bcm63xx/bcm63xx_fallback_sprom.h      |  6 ++
 4 files changed, 83 insertions(+), 48 deletions(-)
 create mode 100644 arch/mips/bcm63xx/sprom.c
 create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h

--- a/arch/mips/bcm63xx/Makefile
+++ b/arch/mips/bcm63xx/Makefile
@@ -2,7 +2,7 @@ obj-y		+= clk.o cpu.o cs.o gpio.o irq.o
 		   setup.o timer.o dev-dsp.o dev-enet.o dev-flash.o \
 		   dev-pcmcia.o dev-rng.o dev-spi.o dev-hsspi.o dev-uart.o \
 		   dev-wdt.o dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o \
-		   usb-common.o
+		   usb-common.o sprom.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 
 obj-y		+= boards/
--- a/arch/mips/bcm63xx/boards/board_common.c
+++ b/arch/mips/bcm63xx/boards/board_common.c
@@ -40,44 +40,6 @@
 static struct board_info board;
 
 /*
- * Register a sane SPROMv2 to make the on-board
- * bcm4318 WLAN work
- */
-#ifdef CONFIG_SSB_PCIHOST
-static struct ssb_sprom bcm63xx_sprom = {
-	.revision		= 0x02,
-	.board_rev		= 0x17,
-	.country_code		= 0x0,
-	.ant_available_bg	= 0x3,
-	.pa0b0			= 0x15ae,
-	.pa0b1			= 0xfa85,
-	.pa0b2			= 0xfe8d,
-	.pa1b0			= 0xffff,
-	.pa1b1			= 0xffff,
-	.pa1b2			= 0xffff,
-	.gpio0			= 0xff,
-	.gpio1			= 0xff,
-	.gpio2			= 0xff,
-	.gpio3			= 0xff,
-	.maxpwr_bg		= 0x004c,
-	.itssi_bg		= 0x00,
-	.boardflags_lo		= 0x2848,
-	.boardflags_hi		= 0x0000,
-};
-
-int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
-{
-	if (bus->bustype == SSB_BUSTYPE_PCI) {
-		memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
-		return 0;
-	} else {
-		printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
-		return -EINVAL;
-	}
-}
-#endif
-
-/*
  * return board name for /proc/cpuinfo
  */
 const char *board_get_name(void)
@@ -180,6 +142,7 @@ static struct platform_device bcm63xx_gp
 int __init board_register_devices(void)
 {
 	int usbh_ports = 0;
+	u8 mac[ETH_ALEN];
 
 	if (board.has_uart0)
 		bcm63xx_uart_register(0);
@@ -224,15 +187,10 @@ int __init board_register_devices(void)
 	/* Generate MAC address for WLAN and register our SPROM,
 	 * do this after registering enet devices
 	 */
-#ifdef CONFIG_SSB_PCIHOST
-	if (!board_get_mac_address(bcm63xx_sprom.il0mac)) {
-		memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN);
-		memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
-		if (ssb_arch_register_fallback_sprom(
-				&bcm63xx_get_fallback_sprom) < 0)
-			pr_err(PFX "failed to register fallback SPROM\n");
-	}
-#endif
+
+	if (board_get_mac_address(mac) ||
+	    bcm63xx_register_fallback_sprom(mac))
+		pr_err(PFX "failed to register fallback SPROM\n");
 
 	bcm63xx_spi_register();
 
--- /dev/null
+++ b/arch/mips/bcm63xx/sprom.c
@@ -0,0 +1,70 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
+ * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/platform_device.h>
+#include <linux/ssb/ssb.h>
+#include <bcm63xx_fallback_sprom.h>
+#include <board_bcm963xx.h>
+
+#define PFX	"sprom: "
+
+/*
+ * Register a sane SPROMv2 to make the on-board
+ * bcm4318 WLAN work
+ */
+#ifdef CONFIG_SSB_PCIHOST
+static struct ssb_sprom bcm63xx_sprom = {
+	.revision		= 0x02,
+	.board_rev		= 0x17,
+	.country_code		= 0x0,
+	.ant_available_bg	= 0x3,
+	.pa0b0			= 0x15ae,
+	.pa0b1			= 0xfa85,
+	.pa0b2			= 0xfe8d,
+	.pa1b0			= 0xffff,
+	.pa1b1			= 0xffff,
+	.pa1b2			= 0xffff,
+	.gpio0			= 0xff,
+	.gpio1			= 0xff,
+	.gpio2			= 0xff,
+	.gpio3			= 0xff,
+	.maxpwr_bg		= 0x004c,
+	.itssi_bg		= 0x00,
+	.boardflags_lo		= 0x2848,
+	.boardflags_hi		= 0x0000,
+};
+
+int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
+{
+	if (bus->bustype == SSB_BUSTYPE_PCI) {
+		memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
+		return 0;
+	} else {
+		printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
+		return -EINVAL;
+	}
+}
+#endif
+
+int __init bcm63xx_register_fallback_sprom(u8 *mac)
+{
+	int ret = 0;
+
+#ifdef CONFIG_SSB_PCIHOST
+	memcpy(bcm63xx_sprom.il0mac, mac, ETH_ALEN);
+	memcpy(bcm63xx_sprom.et0mac, mac, ETH_ALEN);
+	memcpy(bcm63xx_sprom.et1mac, mac, ETH_ALEN);
+
+	ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_sprom);
+#endif
+	return ret;
+}
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
@@ -0,0 +1,6 @@
+#ifndef __BCM63XX_FALLBACK_SPROM
+#define __BCM63XX_FALLBACK_SPROM
+
+int bcm63xx_register_fallback_sprom(u8 *mac);
+
+#endif