brcm63xx: remove legacy led/button related patches
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-4.1 / 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,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 \
27 - usb-common.o
28 + usb-common.o sprom.o
29 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
30
31 obj-y += boards/
32 --- a/arch/mips/bcm63xx/boards/board_common.c
33 +++ b/arch/mips/bcm63xx/boards/board_common.c
34 @@ -40,44 +40,6 @@
35 static struct board_info board;
36
37 /*
38 - * Register a sane SPROMv2 to make the on-board
39 - * bcm4318 WLAN work
40 - */
41 -#ifdef CONFIG_SSB_PCIHOST
42 -static struct ssb_sprom bcm63xx_sprom = {
43 - .revision = 0x02,
44 - .board_rev = 0x17,
45 - .country_code = 0x0,
46 - .ant_available_bg = 0x3,
47 - .pa0b0 = 0x15ae,
48 - .pa0b1 = 0xfa85,
49 - .pa0b2 = 0xfe8d,
50 - .pa1b0 = 0xffff,
51 - .pa1b1 = 0xffff,
52 - .pa1b2 = 0xffff,
53 - .gpio0 = 0xff,
54 - .gpio1 = 0xff,
55 - .gpio2 = 0xff,
56 - .gpio3 = 0xff,
57 - .maxpwr_bg = 0x004c,
58 - .itssi_bg = 0x00,
59 - .boardflags_lo = 0x2848,
60 - .boardflags_hi = 0x0000,
61 -};
62 -
63 -int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
64 -{
65 - if (bus->bustype == SSB_BUSTYPE_PCI) {
66 - memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
67 - return 0;
68 - } else {
69 - printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
70 - return -EINVAL;
71 - }
72 -}
73 -#endif
74 -
75 -/*
76 * return board name for /proc/cpuinfo
77 */
78 const char *board_get_name(void)
79 @@ -180,6 +142,7 @@ static struct platform_device bcm63xx_gp
80 int __init board_register_devices(void)
81 {
82 int usbh_ports = 0;
83 + u8 mac[ETH_ALEN];
84
85 if (board.has_uart0)
86 bcm63xx_uart_register(0);
87 @@ -224,15 +187,10 @@ int __init board_register_devices(void)
88 /* Generate MAC address for WLAN and register our SPROM,
89 * do this after registering enet devices
90 */
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");
98 - }
99 -#endif
100 +
101 + if (board_get_mac_address(mac) ||
102 + bcm63xx_register_fallback_sprom(mac))
103 + pr_err(PFX "failed to register fallback SPROM\n");
104
105 bcm63xx_spi_register();
106
107 --- /dev/null
108 +++ b/arch/mips/bcm63xx/sprom.c
109 @@ -0,0 +1,70 @@
110 +/*
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.
114 + *
115 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
116 + * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
117 + */
118 +
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>
126 +
127 +#define PFX "sprom: "
128 +
129 +/*
130 + * Register a sane SPROMv2 to make the on-board
131 + * bcm4318 WLAN work
132 + */
133 +#ifdef CONFIG_SSB_PCIHOST
134 +static struct ssb_sprom bcm63xx_sprom = {
135 + .revision = 0x02,
136 + .board_rev = 0x17,
137 + .country_code = 0x0,
138 + .ant_available_bg = 0x3,
139 + .pa0b0 = 0x15ae,
140 + .pa0b1 = 0xfa85,
141 + .pa0b2 = 0xfe8d,
142 + .pa1b0 = 0xffff,
143 + .pa1b1 = 0xffff,
144 + .pa1b2 = 0xffff,
145 + .gpio0 = 0xff,
146 + .gpio1 = 0xff,
147 + .gpio2 = 0xff,
148 + .gpio3 = 0xff,
149 + .maxpwr_bg = 0x004c,
150 + .itssi_bg = 0x00,
151 + .boardflags_lo = 0x2848,
152 + .boardflags_hi = 0x0000,
153 +};
154 +
155 +int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
156 +{
157 + if (bus->bustype == SSB_BUSTYPE_PCI) {
158 + memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
159 + return 0;
160 + } else {
161 + printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
162 + return -EINVAL;
163 + }
164 +}
165 +#endif
166 +
167 +int __init bcm63xx_register_fallback_sprom(u8 *mac)
168 +{
169 + int ret = 0;
170 +
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);
175 +
176 + ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_sprom);
177 +#endif
178 + return ret;
179 +}
180 --- /dev/null
181 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
182 @@ -0,0 +1,6 @@
183 +#ifndef __BCM63XX_FALLBACK_SPROM
184 +#define __BCM63XX_FALLBACK_SPROM
185 +
186 +int bcm63xx_register_fallback_sprom(u8 *mac);
187 +
188 +#endif