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
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 \
30 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
33 --- a/arch/mips/bcm63xx/boards/board_common.c
34 +++ b/arch/mips/bcm63xx/boards/board_common.c
36 static struct board_info board;
39 - * Register a sane SPROMv2 to make the on-board
42 -#ifdef CONFIG_SSB_PCIHOST
43 -static struct ssb_sprom bcm63xx_sprom = {
46 - .country_code = 0x0,
47 - .ant_available_bg = 0x3,
58 - .maxpwr_bg = 0x004c,
60 - .boardflags_lo = 0x2848,
61 - .boardflags_hi = 0x0000,
64 -int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
66 - if (bus->bustype == SSB_BUSTYPE_PCI) {
67 - memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
70 - printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
77 * return board name for /proc/cpuinfo
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)
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
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");
102 + if (board_get_mac_address(mac) ||
103 + bcm63xx_register_fallback_sprom(mac))
104 + pr_err(PFX "failed to register fallback SPROM\n");
106 bcm63xx_spi_register();
109 +++ b/arch/mips/bcm63xx/sprom.c
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.
116 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
117 + * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
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>
128 +#define PFX "sprom: "
131 + * Register a sane SPROMv2 to make the on-board
132 + * bcm4318 WLAN work
134 +#ifdef CONFIG_SSB_PCIHOST
135 +static struct ssb_sprom bcm63xx_sprom = {
138 + .country_code = 0x0,
139 + .ant_available_bg = 0x3,
150 + .maxpwr_bg = 0x004c,
152 + .boardflags_lo = 0x2848,
153 + .boardflags_hi = 0x0000,
156 +int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
158 + if (bus->bustype == SSB_BUSTYPE_PCI) {
159 + memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
162 + printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
168 +int __init bcm63xx_register_fallback_sprom(u8 *mac)
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);
177 + ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_sprom);
182 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
184 +#ifndef __BCM63XX_FALLBACK_SPROM
185 +#define __BCM63XX_FALLBACK_SPROM
187 +int bcm63xx_register_fallback_sprom(u8 *mac);