2
0

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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. From 5ed5b5e9614fa5b02da699ab565af76c7e63d64d Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <[email protected]>
  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 \
  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. @@ -33,6 +33,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. @@ -248,9 +249,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, board.caldata[i].led_active_high);
  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, board.caldata[i].led_active_high);
  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. --- /dev/null
  56. +++ b/arch/mips/bcm63xx/pci-rt2x00-fixup.c
  57. @@ -0,0 +1,72 @@
  58. +/*
  59. + * Broadcom BCM63XX RT2x00 EEPROM fixup helper.
  60. + *
  61. + * Copyright (C) 2012 Álvaro Fernández Rojas <[email protected]>
  62. + *
  63. + * Based on
  64. + *
  65. + * Broadcom BCM63XX Ath9k EEPROM fixup helper.
  66. + *
  67. + * Copyright (C) 2012 Jonas Gorski <[email protected]>
  68. + *
  69. + * This program is free software; you can redistribute it and/or modify it
  70. + * under the terms of the GNU General Public License version 2 as published
  71. + * by the Free Software Foundation.
  72. + */
  73. +
  74. +#include <linux/if_ether.h>
  75. +#include <linux/pci.h>
  76. +#include <linux/platform_device.h>
  77. +#include <linux/rt2x00_platform.h>
  78. +
  79. +#include <bcm63xx_nvram.h>
  80. +#include <pci_rt2x00_fixup.h>
  81. +
  82. +struct rt2x00_fixup {
  83. + unsigned slot;
  84. + u8 mac[ETH_ALEN];
  85. + struct rt2x00_platform_data pdata;
  86. +};
  87. +
  88. +static int rt2x00_num_fixups;
  89. +static struct rt2x00_fixup rt2x00_fixups[2] = {
  90. + {
  91. + .slot = 255,
  92. + },
  93. + {
  94. + .slot = 255,
  95. + },
  96. +};
  97. +
  98. +static void rt2x00_pci_fixup(struct pci_dev *dev)
  99. +{
  100. + unsigned i;
  101. + struct rt2x00_platform_data *pdata = NULL;
  102. +
  103. + for (i = 0; i < rt2x00_num_fixups; i++) {
  104. + if (rt2x00_fixups[i].slot != PCI_SLOT(dev->devfn))
  105. + continue;
  106. +
  107. + pdata = &rt2x00_fixups[i].pdata;
  108. + break;
  109. + }
  110. +
  111. + dev->dev.platform_data = pdata;
  112. +}
  113. +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_RALINK, PCI_ANY_ID, rt2x00_pci_fixup);
  114. +
  115. +void __init pci_enable_rt2x00_fixup(unsigned slot, char* eeprom)
  116. +{
  117. + if (rt2x00_num_fixups >= ARRAY_SIZE(rt2x00_fixups))
  118. + return;
  119. +
  120. + rt2x00_fixups[rt2x00_num_fixups].slot = slot;
  121. + rt2x00_fixups[rt2x00_num_fixups].pdata.eeprom_file_name = kstrdup(eeprom, GFP_KERNEL);
  122. +
  123. + if (bcm63xx_nvram_get_mac_address(rt2x00_fixups[rt2x00_num_fixups].mac))
  124. + return;
  125. +
  126. + rt2x00_fixups[rt2x00_num_fixups].pdata.mac_address = rt2x00_fixups[rt2x00_num_fixups].mac;
  127. + rt2x00_num_fixups++;
  128. +}
  129. +
  130. --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
  131. +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
  132. @@ -10,6 +10,7 @@
  133. #include <bcm63xx_dev_dsp.h>
  134. #include <bcm63xx_fallback_sprom.h>
  135. #include <pci_ath9k_fixup.h>
  136. +#include <pci_rt2x00_fixup.h>
  137. /*
  138. * flash mapping
  139. @@ -17,12 +18,16 @@
  140. #define BCM963XX_CFE_VERSION_OFFSET 0x570
  141. #define BCM963XX_NVRAM_OFFSET 0x580
  142. -struct ath9k_caldata {
  143. +struct bcm63xx_caldata {
  144. + unsigned int vendor;
  145. unsigned int slot;
  146. u32 caldata_offset;
  147. + /* Atheros */
  148. unsigned int endian_check:1;
  149. int led_pin;
  150. bool led_active_high;
  151. + /* Ralink */
  152. + char* eeprom;
  153. };
  154. /*
  155. @@ -46,7 +51,7 @@ struct board_info {
  156. unsigned int has_caldata:2;
  157. /* wifi calibration data config */
  158. - struct ath9k_caldata caldata[2];
  159. + struct bcm63xx_caldata caldata[2];
  160. /* ethernet config */
  161. struct bcm63xx_enet_platform_data enet0;
  162. --- /dev/null
  163. +++ b/arch/mips/include/asm/mach-bcm63xx/pci_rt2x00_fixup.h
  164. @@ -0,0 +1,9 @@
  165. +#ifndef _PCI_RT2X00_FIXUP
  166. +#define _PCI_RT2X00_FIXUP
  167. +
  168. +#define PCI_VENDOR_ID_RALINK 0x1814
  169. +
  170. +void pci_enable_rt2x00_fixup(unsigned slot, char* eeprom) __init;
  171. +
  172. +#endif /* _PCI_RT2X00_FIXUP */
  173. +