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
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.
11 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
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
21 --- a/arch/mips/bcm63xx/Makefile
22 +++ b/arch/mips/bcm63xx/Makefile
23 @@ -2,7 +2,7 @@ obj-y += clk.o cpu.o cs.o gpio.o irq.o
24 setup.o timer.o dev-dsp.o dev-enet.o dev-flash.o \
25 dev-pcmcia.o dev-rng.o dev-spi.o dev-hsspi.o dev-uart.o \
26 dev-wdt.o dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o \
28 + usb-common.o sprom.o
29 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
32 --- a/arch/mips/bcm63xx/boards/board_common.c
33 +++ b/arch/mips/bcm63xx/boards/board_common.c
35 static struct board_info board;
38 - * Register a sane SPROMv2 to make the on-board
41 -#ifdef CONFIG_SSB_PCIHOST
42 -static struct ssb_sprom bcm63xx_sprom = {
45 - .country_code = 0x0,
46 - .ant_available_bg = 0x3,
57 - .maxpwr_bg = 0x004c,
59 - .boardflags_lo = 0x2848,
60 - .boardflags_hi = 0x0000,
63 -int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
65 - if (bus->bustype == SSB_BUSTYPE_PCI) {
66 - memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
69 - printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
76 * return board name for /proc/cpuinfo
78 const char *board_get_name(void)
79 @@ -195,6 +157,7 @@ int __init board_register_devices(void)
86 bcm63xx_uart_register(0);
87 @@ -239,15 +202,10 @@ int __init board_register_devices(void)
88 /* Generate MAC address for WLAN and register our SPROM,
89 * do this after registering enet devices
91 -#ifdef CONFIG_SSB_PCIHOST
92 - if (!board_get_mac_address(bcm63xx_sprom.il0mac)) {
93 - memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN);
94 - memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
95 - if (ssb_arch_register_fallback_sprom(
96 - &bcm63xx_get_fallback_sprom) < 0)
97 - pr_err(PFX "failed to register fallback SPROM\n");
101 + if (board_get_mac_address(mac) ||
102 + bcm63xx_register_fallback_sprom(mac))
103 + pr_err(PFX "failed to register fallback SPROM\n");
105 bcm63xx_spi_register();
108 +++ b/arch/mips/bcm63xx/sprom.c
111 + * This file is subject to the terms and conditions of the GNU General Public
112 + * License. See the file "COPYING" in the main directory of this archive
113 + * for more details.
115 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
116 + * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
119 +#include <linux/init.h>
120 +#include <linux/kernel.h>
121 +#include <linux/string.h>
122 +#include <linux/platform_device.h>
123 +#include <linux/ssb/ssb.h>
124 +#include <bcm63xx_fallback_sprom.h>
125 +#include <board_bcm963xx.h>
127 +#define PFX "sprom: "
130 + * Register a sane SPROMv2 to make the on-board
131 + * bcm4318 WLAN work
133 +#ifdef CONFIG_SSB_PCIHOST
134 +static struct ssb_sprom bcm63xx_sprom = {
137 + .country_code = 0x0,
138 + .ant_available_bg = 0x3,
149 + .maxpwr_bg = 0x004c,
151 + .boardflags_lo = 0x2848,
152 + .boardflags_hi = 0x0000,
155 +int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
157 + if (bus->bustype == SSB_BUSTYPE_PCI) {
158 + memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
161 + printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
167 +int __init bcm63xx_register_fallback_sprom(u8 *mac)
171 +#ifdef CONFIG_SSB_PCIHOST
172 + memcpy(bcm63xx_sprom.il0mac, mac, ETH_ALEN);
173 + memcpy(bcm63xx_sprom.et0mac, mac, ETH_ALEN);
174 + memcpy(bcm63xx_sprom.et1mac, mac, ETH_ALEN);
176 + ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_sprom);
181 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
183 +#ifndef __BCM63XX_FALLBACK_SPROM
184 +#define __BCM63XX_FALLBACK_SPROM
186 +int bcm63xx_register_fallback_sprom(u8 *mac);