422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch 6.0 KB

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