Root/target/linux/brcm63xx/patches-3.6/446-BCM63XX-add-a-fixup-for-rt2x00-devices.patch

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

Archive Download this file



interactive