kernel: fix bluetooth and zsmalloc for 3.14
[openwrt/svn-archive/archive.git] / target / linux / brcm63xx / patches-3.13 / 422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch
1 From 5ed5b5e9614fa5b02da699ab565af76c7e63d64d Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Mon, 7 Jan 2013 17:45:39 +0100
4 Subject: [PATCH 72/72] 446-BCM63XX-add-a-fixup-for-rt2x00-devices
5
6 ---
7 arch/mips/bcm63xx/Makefile | 2 +-
8 arch/mips/bcm63xx/boards/board_bcm963xx.c | 17 ++++-
9 arch/mips/bcm63xx/dev-flash.c | 2 +-
10 arch/mips/bcm63xx/pci-rt2x00-fixup.c | 71 ++++++++++++++++++++
11 .../include/asm/mach-bcm63xx/bcm63xx_dev_flash.h | 2 +-
12 .../mips/include/asm/mach-bcm63xx/board_bcm963xx.h | 9 ++-
13 .../include/asm/mach-bcm63xx/pci_rt2x00_fixup.h | 9 +++
14 7 files changed, 104 insertions(+), 8 deletions(-)
15 create mode 100644 arch/mips/bcm63xx/pci-rt2x00-fixup.c
16 create mode 100644 arch/mips/include/asm/mach-bcm63xx/pci_rt2x00_fixup.h
17
18 --- a/arch/mips/bcm63xx/Makefile
19 +++ b/arch/mips/bcm63xx/Makefile
20 @@ -2,7 +2,7 @@ obj-y += clk.o cpu.o cs.o gpio.o irq.o
21 setup.o timer.o dev-dsp.o dev-enet.o dev-flash.o \
22 dev-pcmcia.o dev-rng.o dev-spi.o dev-hsspi.o dev-uart.o \
23 dev-wdt.o dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o \
24 - pci-ath9k-fixup.o usb-common.o
25 + pci-ath9k-fixup.o pci-rt2x00-fixup.o usb-common.o
26 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
27
28 obj-y += boards/
29 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
30 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
31 @@ -34,6 +34,7 @@
32 #include <bcm63xx_dev_usb_usbd.h>
33 #include <board_bcm963xx.h>
34 #include <pci_ath9k_fixup.h>
35 +#include <pci_rt2x00_fixup.h>
36
37 #include <uapi/linux/bcm933xx_hcs.h>
38 #include <uapi/linux/bcm963xx_tag.h>
39 @@ -1065,9 +1066,19 @@ int __init board_register_devices(void)
40 }
41
42 /* register any fixups */
43 - for (i = 0; i < board.has_caldata; i++)
44 - pci_enable_ath9k_fixup(board.caldata[i].slot, board.caldata[i].caldata_offset,
45 - board.caldata[i].endian_check, board.caldata[i].led_pin);
46 + for (i = 0; i < board.has_caldata; i++) {
47 + switch (board.caldata[i].vendor) {
48 + case PCI_VENDOR_ID_ATHEROS:
49 + pci_enable_ath9k_fixup(board.caldata[i].slot,
50 + board.caldata[i].caldata_offset, board.caldata[i].endian_check,
51 + board.caldata[i].led_pin);
52 + break;
53 + case PCI_VENDOR_ID_RALINK:
54 + pci_enable_rt2x00_fixup(board.caldata[i].slot,
55 + board.caldata[i].eeprom);
56 + break;
57 + }
58 + }
59
60 return 0;
61 }
62 --- a/arch/mips/bcm63xx/dev-flash.c
63 +++ b/arch/mips/bcm63xx/dev-flash.c
64 @@ -193,7 +193,7 @@ void __init bcm63xx_flash_detect(void)
65 }
66 }
67
68 -int __init bcm63xx_flash_register(int num_caldata, struct ath9k_caldata *caldata)
69 +int __init bcm63xx_flash_register(int num_caldata, struct bcm63xx_caldata *caldata)
70 {
71 u32 val;
72 unsigned int i;
73 --- /dev/null
74 +++ b/arch/mips/bcm63xx/pci-rt2x00-fixup.c
75 @@ -0,0 +1,72 @@
76 +/*
77 + * Broadcom BCM63XX RT2x00 EEPROM fixup helper.
78 + *
79 + * Copyright (C) 2012 Álvaro Fernández Rojas <noltari@gmail.com>
80 + *
81 + * Based on
82 + *
83 + * Broadcom BCM63XX Ath9k EEPROM fixup helper.
84 + *
85 + * Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
86 + *
87 + * This program is free software; you can redistribute it and/or modify it
88 + * under the terms of the GNU General Public License version 2 as published
89 + * by the Free Software Foundation.
90 + */
91 +
92 +#include <linux/if_ether.h>
93 +#include <linux/pci.h>
94 +#include <linux/platform_device.h>
95 +#include <linux/rt2x00_platform.h>
96 +
97 +#include <bcm63xx_nvram.h>
98 +#include <pci_rt2x00_fixup.h>
99 +
100 +struct rt2x00_fixup {
101 + unsigned slot;
102 + u8 mac[ETH_ALEN];
103 + struct rt2x00_platform_data pdata;
104 +};
105 +
106 +static int rt2x00_num_fixups;
107 +static struct rt2x00_fixup rt2x00_fixups[2] = {
108 + {
109 + .slot = 255,
110 + },
111 + {
112 + .slot = 255,
113 + },
114 +};
115 +
116 +static void rt2x00_pci_fixup(struct pci_dev *dev)
117 +{
118 + unsigned i;
119 + struct rt2x00_platform_data *pdata = NULL;
120 +
121 + for (i = 0; i < rt2x00_num_fixups; i++) {
122 + if (rt2x00_fixups[i].slot != PCI_SLOT(dev->devfn))
123 + continue;
124 +
125 + pdata = &rt2x00_fixups[i].pdata;
126 + break;
127 + }
128 +
129 + dev->dev.platform_data = pdata;
130 +}
131 +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_RALINK, PCI_ANY_ID, rt2x00_pci_fixup);
132 +
133 +void __init pci_enable_rt2x00_fixup(unsigned slot, char* eeprom)
134 +{
135 + if (rt2x00_num_fixups >= ARRAY_SIZE(rt2x00_fixups))
136 + return;
137 +
138 + rt2x00_fixups[rt2x00_num_fixups].slot = slot;
139 + rt2x00_fixups[rt2x00_num_fixups].pdata.eeprom_file_name = kstrdup(eeprom, GFP_KERNEL);
140 +
141 + if (bcm63xx_nvram_get_mac_address(rt2x00_fixups[rt2x00_num_fixups].mac))
142 + return;
143 +
144 + rt2x00_fixups[rt2x00_num_fixups].pdata.mac_address = rt2x00_fixups[rt2x00_num_fixups].mac;
145 + rt2x00_num_fixups++;
146 +}
147 +
148 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
149 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
150 @@ -11,7 +11,7 @@ enum {
151
152 void bcm63xx_flash_detect(void);
153
154 -int __init bcm63xx_flash_register(int num_caldata, struct ath9k_caldata *caldata);
155 +int __init bcm63xx_flash_register(int num_caldata, struct bcm63xx_caldata *caldata);
156
157 int bcm63xx_flash_get_type(void);
158
159 --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
160 +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
161 @@ -9,6 +9,7 @@
162 #include <bcm63xx_dev_usb_usbd.h>
163 #include <bcm63xx_dev_dsp.h>
164 #include <pci_ath9k_fixup.h>
165 +#include <pci_rt2x00_fixup.h>
166
167 /*
168 * flash mapping
169 @@ -16,11 +17,15 @@
170 #define BCM963XX_CFE_VERSION_OFFSET 0x570
171 #define BCM963XX_NVRAM_OFFSET 0x580
172
173 -struct ath9k_caldata {
174 +struct bcm63xx_caldata {
175 + unsigned int vendor;
176 unsigned int slot;
177 u32 caldata_offset;
178 + /* Atheros */
179 unsigned int endian_check:1;
180 int led_pin;
181 + /* Ralink */
182 + char* eeprom;
183 };
184
185 /*
186 @@ -45,7 +50,7 @@ struct board_info {
187 unsigned int has_caldata:2;
188
189 /* wifi calibration data config */
190 - struct ath9k_caldata caldata[2];
191 + struct bcm63xx_caldata caldata[2];
192
193 /* ethernet config */
194 struct bcm63xx_enet_platform_data enet0;
195 --- /dev/null
196 +++ b/arch/mips/include/asm/mach-bcm63xx/pci_rt2x00_fixup.h
197 @@ -0,0 +1,9 @@
198 +#ifndef _PCI_RT2X00_FIXUP
199 +#define _PCI_RT2X00_FIXUP
200 +
201 +#define PCI_VENDOR_ID_RALINK 0x1814
202 +
203 +void pci_enable_rt2x00_fixup(unsigned slot, char* eeprom) __init;
204 +
205 +#endif /* _PCI_RT2X00_FIXUP */
206 +