360-MIPS-BCM63XX-add-support-for-raw-sproms.patch 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. From cedee63bc73f8b7d45b8c0cba1236986812c1f83 Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <jogo@openwrt.org>
  3. Date: Tue, 29 Jul 2014 22:16:36 +0200
  4. Subject: [PATCH 05/10] MIPS: BCM63XX: add support for "raw" sproms
  5. Allow using raw sprom content as templates.
  6. Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  7. ---
  8. arch/mips/bcm63xx/sprom.c | 482 ++++++++++++++++++++++++++++++++++++++++++++++
  9. 1 file changed, 482 insertions(+)
  10. --- a/arch/mips/bcm63xx/sprom.c
  11. +++ b/arch/mips/bcm63xx/sprom.c
  12. @@ -55,13 +55,492 @@ int bcm63xx_get_fallback_sprom(struct ss
  13. return -EINVAL;
  14. }
  15. }
  16. +
  17. +/* FIXME: use lib_sprom after submission upstream */
  18. +
  19. +/* Get the word-offset for a SSB_SPROM_XXX define. */
  20. +#define SPOFF(offset) ((offset) / sizeof(u16))
  21. +/* Helper to extract some _offset, which is one of the SSB_SPROM_XXX defines. */
  22. +#define SPEX16(_outvar, _offset, _mask, _shift) \
  23. + out->_outvar = ((in[SPOFF(_offset)] & (_mask)) >> (_shift))
  24. +#define SPEX32(_outvar, _offset, _mask, _shift) \
  25. + out->_outvar = ((((u32)in[SPOFF((_offset)+2)] << 16 | \
  26. + in[SPOFF(_offset)]) & (_mask)) >> (_shift))
  27. +#define SPEX(_outvar, _offset, _mask, _shift) \
  28. + SPEX16(_outvar, _offset, _mask, _shift)
  29. +
  30. +#define SPEX_ARRAY8(_field, _offset, _mask, _shift) \
  31. + do { \
  32. + SPEX(_field[0], _offset + 0, _mask, _shift); \
  33. + SPEX(_field[1], _offset + 2, _mask, _shift); \
  34. + SPEX(_field[2], _offset + 4, _mask, _shift); \
  35. + SPEX(_field[3], _offset + 6, _mask, _shift); \
  36. + SPEX(_field[4], _offset + 8, _mask, _shift); \
  37. + SPEX(_field[5], _offset + 10, _mask, _shift); \
  38. + SPEX(_field[6], _offset + 12, _mask, _shift); \
  39. + SPEX(_field[7], _offset + 14, _mask, _shift); \
  40. + } while (0)
  41. +
  42. +
  43. +static s8 r123_extract_antgain(u8 sprom_revision, const u16 *in,
  44. + u16 mask, u16 shift)
  45. +{
  46. + u16 v;
  47. + u8 gain;
  48. +
  49. + v = in[SPOFF(SSB_SPROM1_AGAIN)];
  50. + gain = (v & mask) >> shift;
  51. + if (gain == 0xFF)
  52. + gain = 2; /* If unset use 2dBm */
  53. + if (sprom_revision == 1) {
  54. + /* Convert to Q5.2 */
  55. + gain <<= 2;
  56. + } else {
  57. + /* Q5.2 Fractional part is stored in 0xC0 */
  58. + gain = ((gain & 0xC0) >> 6) | ((gain & 0x3F) << 2);
  59. + }
  60. +
  61. + return (s8)gain;
  62. +}
  63. +
  64. +static void sprom_extract_r23(struct ssb_sprom *out, const u16 *in)
  65. +{
  66. + SPEX(boardflags_hi, SSB_SPROM2_BFLHI, 0xFFFF, 0);
  67. + SPEX(opo, SSB_SPROM2_OPO, SSB_SPROM2_OPO_VALUE, 0);
  68. + SPEX(pa1lob0, SSB_SPROM2_PA1LOB0, 0xFFFF, 0);
  69. + SPEX(pa1lob1, SSB_SPROM2_PA1LOB1, 0xFFFF, 0);
  70. + SPEX(pa1lob2, SSB_SPROM2_PA1LOB2, 0xFFFF, 0);
  71. + SPEX(pa1hib0, SSB_SPROM2_PA1HIB0, 0xFFFF, 0);
  72. + SPEX(pa1hib1, SSB_SPROM2_PA1HIB1, 0xFFFF, 0);
  73. + SPEX(pa1hib2, SSB_SPROM2_PA1HIB2, 0xFFFF, 0);
  74. + SPEX(maxpwr_ah, SSB_SPROM2_MAXP_A, SSB_SPROM2_MAXP_A_HI, 0);
  75. + SPEX(maxpwr_al, SSB_SPROM2_MAXP_A, SSB_SPROM2_MAXP_A_LO,
  76. + SSB_SPROM2_MAXP_A_LO_SHIFT);
  77. +}
  78. +
  79. +static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in)
  80. +{
  81. + u16 loc[3];
  82. +
  83. + if (out->revision == 3) /* rev 3 moved MAC */
  84. + loc[0] = SSB_SPROM3_IL0MAC;
  85. + else {
  86. + loc[0] = SSB_SPROM1_IL0MAC;
  87. + loc[1] = SSB_SPROM1_ET0MAC;
  88. + loc[2] = SSB_SPROM1_ET1MAC;
  89. + }
  90. +
  91. + SPEX(et0phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0A, 0);
  92. + SPEX(et1phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1A,
  93. + SSB_SPROM1_ETHPHY_ET1A_SHIFT);
  94. + SPEX(et0mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0M, 14);
  95. + SPEX(et1mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1M, 15);
  96. + SPEX(board_rev, SSB_SPROM1_BINF, SSB_SPROM1_BINF_BREV, 0);
  97. + SPEX(board_type, SSB_SPROM1_SPID, 0xFFFF, 0);
  98. + if (out->revision == 1)
  99. + SPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE,
  100. + SSB_SPROM1_BINF_CCODE_SHIFT);
  101. + SPEX(ant_available_a, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTA,
  102. + SSB_SPROM1_BINF_ANTA_SHIFT);
  103. + SPEX(ant_available_bg, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTBG,
  104. + SSB_SPROM1_BINF_ANTBG_SHIFT);
  105. + SPEX(pa0b0, SSB_SPROM1_PA0B0, 0xFFFF, 0);
  106. + SPEX(pa0b1, SSB_SPROM1_PA0B1, 0xFFFF, 0);
  107. + SPEX(pa0b2, SSB_SPROM1_PA0B2, 0xFFFF, 0);
  108. + SPEX(pa1b0, SSB_SPROM1_PA1B0, 0xFFFF, 0);
  109. + SPEX(pa1b1, SSB_SPROM1_PA1B1, 0xFFFF, 0);
  110. + SPEX(pa1b2, SSB_SPROM1_PA1B2, 0xFFFF, 0);
  111. + SPEX(gpio0, SSB_SPROM1_GPIOA, SSB_SPROM1_GPIOA_P0, 0);
  112. + SPEX(gpio1, SSB_SPROM1_GPIOA, SSB_SPROM1_GPIOA_P1,
  113. + SSB_SPROM1_GPIOA_P1_SHIFT);
  114. + SPEX(gpio2, SSB_SPROM1_GPIOB, SSB_SPROM1_GPIOB_P2, 0);
  115. + SPEX(gpio3, SSB_SPROM1_GPIOB, SSB_SPROM1_GPIOB_P3,
  116. + SSB_SPROM1_GPIOB_P3_SHIFT);
  117. + SPEX(maxpwr_a, SSB_SPROM1_MAXPWR, SSB_SPROM1_MAXPWR_A,
  118. + SSB_SPROM1_MAXPWR_A_SHIFT);
  119. + SPEX(maxpwr_bg, SSB_SPROM1_MAXPWR, SSB_SPROM1_MAXPWR_BG, 0);
  120. + SPEX(itssi_a, SSB_SPROM1_ITSSI, SSB_SPROM1_ITSSI_A,
  121. + SSB_SPROM1_ITSSI_A_SHIFT);
  122. + SPEX(itssi_bg, SSB_SPROM1_ITSSI, SSB_SPROM1_ITSSI_BG, 0);
  123. + SPEX(boardflags_lo, SSB_SPROM1_BFLLO, 0xFFFF, 0);
  124. +
  125. + SPEX(alpha2[0], SSB_SPROM1_CCODE, 0xff00, 8);
  126. + SPEX(alpha2[1], SSB_SPROM1_CCODE, 0x00ff, 0);
  127. +
  128. + /* Extract the antenna gain values. */
  129. + out->antenna_gain.a0 = r123_extract_antgain(out->revision, in,
  130. + SSB_SPROM1_AGAIN_BG,
  131. + SSB_SPROM1_AGAIN_BG_SHIFT);
  132. + out->antenna_gain.a1 = r123_extract_antgain(out->revision, in,
  133. + SSB_SPROM1_AGAIN_A,
  134. + SSB_SPROM1_AGAIN_A_SHIFT);
  135. + if (out->revision >= 2)
  136. + sprom_extract_r23(out, in);
  137. +}
  138. +
  139. +/* Revs 4 5 and 8 have partially shared layout */
  140. +static void sprom_extract_r458(struct ssb_sprom *out, const u16 *in)
  141. +{
  142. + SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01,
  143. + SSB_SPROM4_TXPID2G0, SSB_SPROM4_TXPID2G0_SHIFT);
  144. + SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01,
  145. + SSB_SPROM4_TXPID2G1, SSB_SPROM4_TXPID2G1_SHIFT);
  146. + SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23,
  147. + SSB_SPROM4_TXPID2G2, SSB_SPROM4_TXPID2G2_SHIFT);
  148. + SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23,
  149. + SSB_SPROM4_TXPID2G3, SSB_SPROM4_TXPID2G3_SHIFT);
  150. +
  151. + SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01,
  152. + SSB_SPROM4_TXPID5GL0, SSB_SPROM4_TXPID5GL0_SHIFT);
  153. + SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01,
  154. + SSB_SPROM4_TXPID5GL1, SSB_SPROM4_TXPID5GL1_SHIFT);
  155. + SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23,
  156. + SSB_SPROM4_TXPID5GL2, SSB_SPROM4_TXPID5GL2_SHIFT);
  157. + SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23,
  158. + SSB_SPROM4_TXPID5GL3, SSB_SPROM4_TXPID5GL3_SHIFT);
  159. +
  160. + SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01,
  161. + SSB_SPROM4_TXPID5G0, SSB_SPROM4_TXPID5G0_SHIFT);
  162. + SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01,
  163. + SSB_SPROM4_TXPID5G1, SSB_SPROM4_TXPID5G1_SHIFT);
  164. + SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23,
  165. + SSB_SPROM4_TXPID5G2, SSB_SPROM4_TXPID5G2_SHIFT);
  166. + SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23,
  167. + SSB_SPROM4_TXPID5G3, SSB_SPROM4_TXPID5G3_SHIFT);
  168. +
  169. + SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01,
  170. + SSB_SPROM4_TXPID5GH0, SSB_SPROM4_TXPID5GH0_SHIFT);
  171. + SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01,
  172. + SSB_SPROM4_TXPID5GH1, SSB_SPROM4_TXPID5GH1_SHIFT);
  173. + SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23,
  174. + SSB_SPROM4_TXPID5GH2, SSB_SPROM4_TXPID5GH2_SHIFT);
  175. + SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23,
  176. + SSB_SPROM4_TXPID5GH3, SSB_SPROM4_TXPID5GH3_SHIFT);
  177. +}
  178. +
  179. +static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
  180. +{
  181. + u16 il0mac_offset;
  182. +
  183. + if (out->revision == 4)
  184. + il0mac_offset = SSB_SPROM4_IL0MAC;
  185. + else
  186. + il0mac_offset = SSB_SPROM5_IL0MAC;
  187. +
  188. + SPEX(et0phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET0A, 0);
  189. + SPEX(et1phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET1A,
  190. + SSB_SPROM4_ETHPHY_ET1A_SHIFT);
  191. + SPEX(board_rev, SSB_SPROM4_BOARDREV, 0xFFFF, 0);
  192. + SPEX(board_type, SSB_SPROM1_SPID, 0xFFFF, 0);
  193. + if (out->revision == 4) {
  194. + SPEX(alpha2[0], SSB_SPROM4_CCODE, 0xff00, 8);
  195. + SPEX(alpha2[1], SSB_SPROM4_CCODE, 0x00ff, 0);
  196. + SPEX(boardflags_lo, SSB_SPROM4_BFLLO, 0xFFFF, 0);
  197. + SPEX(boardflags_hi, SSB_SPROM4_BFLHI, 0xFFFF, 0);
  198. + SPEX(boardflags2_lo, SSB_SPROM4_BFL2LO, 0xFFFF, 0);
  199. + SPEX(boardflags2_hi, SSB_SPROM4_BFL2HI, 0xFFFF, 0);
  200. + } else {
  201. + SPEX(alpha2[0], SSB_SPROM5_CCODE, 0xff00, 8);
  202. + SPEX(alpha2[1], SSB_SPROM5_CCODE, 0x00ff, 0);
  203. + SPEX(boardflags_lo, SSB_SPROM5_BFLLO, 0xFFFF, 0);
  204. + SPEX(boardflags_hi, SSB_SPROM5_BFLHI, 0xFFFF, 0);
  205. + SPEX(boardflags2_lo, SSB_SPROM5_BFL2LO, 0xFFFF, 0);
  206. + SPEX(boardflags2_hi, SSB_SPROM5_BFL2HI, 0xFFFF, 0);
  207. + }
  208. + SPEX(ant_available_a, SSB_SPROM4_ANTAVAIL, SSB_SPROM4_ANTAVAIL_A,
  209. + SSB_SPROM4_ANTAVAIL_A_SHIFT);
  210. + SPEX(ant_available_bg, SSB_SPROM4_ANTAVAIL, SSB_SPROM4_ANTAVAIL_BG,
  211. + SSB_SPROM4_ANTAVAIL_BG_SHIFT);
  212. + SPEX(maxpwr_bg, SSB_SPROM4_MAXP_BG, SSB_SPROM4_MAXP_BG_MASK, 0);
  213. + SPEX(itssi_bg, SSB_SPROM4_MAXP_BG, SSB_SPROM4_ITSSI_BG,
  214. + SSB_SPROM4_ITSSI_BG_SHIFT);
  215. + SPEX(maxpwr_a, SSB_SPROM4_MAXP_A, SSB_SPROM4_MAXP_A_MASK, 0);
  216. + SPEX(itssi_a, SSB_SPROM4_MAXP_A, SSB_SPROM4_ITSSI_A,
  217. + SSB_SPROM4_ITSSI_A_SHIFT);
  218. + if (out->revision == 4) {
  219. + SPEX(gpio0, SSB_SPROM4_GPIOA, SSB_SPROM4_GPIOA_P0, 0);
  220. + SPEX(gpio1, SSB_SPROM4_GPIOA, SSB_SPROM4_GPIOA_P1,
  221. + SSB_SPROM4_GPIOA_P1_SHIFT);
  222. + SPEX(gpio2, SSB_SPROM4_GPIOB, SSB_SPROM4_GPIOB_P2, 0);
  223. + SPEX(gpio3, SSB_SPROM4_GPIOB, SSB_SPROM4_GPIOB_P3,
  224. + SSB_SPROM4_GPIOB_P3_SHIFT);
  225. + } else {
  226. + SPEX(gpio0, SSB_SPROM5_GPIOA, SSB_SPROM5_GPIOA_P0, 0);
  227. + SPEX(gpio1, SSB_SPROM5_GPIOA, SSB_SPROM5_GPIOA_P1,
  228. + SSB_SPROM5_GPIOA_P1_SHIFT);
  229. + SPEX(gpio2, SSB_SPROM5_GPIOB, SSB_SPROM5_GPIOB_P2, 0);
  230. + SPEX(gpio3, SSB_SPROM5_GPIOB, SSB_SPROM5_GPIOB_P3,
  231. + SSB_SPROM5_GPIOB_P3_SHIFT);
  232. + }
  233. +
  234. + /* Extract the antenna gain values. */
  235. + SPEX(antenna_gain.a0, SSB_SPROM4_AGAIN01,
  236. + SSB_SPROM4_AGAIN0, SSB_SPROM4_AGAIN0_SHIFT);
  237. + SPEX(antenna_gain.a1, SSB_SPROM4_AGAIN01,
  238. + SSB_SPROM4_AGAIN1, SSB_SPROM4_AGAIN1_SHIFT);
  239. + SPEX(antenna_gain.a2, SSB_SPROM4_AGAIN23,
  240. + SSB_SPROM4_AGAIN2, SSB_SPROM4_AGAIN2_SHIFT);
  241. + SPEX(antenna_gain.a3, SSB_SPROM4_AGAIN23,
  242. + SSB_SPROM4_AGAIN3, SSB_SPROM4_AGAIN3_SHIFT);
  243. +
  244. + sprom_extract_r458(out, in);
  245. +
  246. + /* TODO - get remaining rev 4 stuff needed */
  247. +}
  248. +
  249. +static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in)
  250. +{
  251. + int i;
  252. + u16 o;
  253. + u16 pwr_info_offset[] = {
  254. + SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
  255. + SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
  256. + };
  257. + BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
  258. + ARRAY_SIZE(out->core_pwr_info));
  259. +
  260. + SPEX(board_rev, SSB_SPROM8_BOARDREV, 0xFFFF, 0);
  261. + SPEX(board_type, SSB_SPROM1_SPID, 0xFFFF, 0);
  262. + SPEX(alpha2[0], SSB_SPROM8_CCODE, 0xff00, 8);
  263. + SPEX(alpha2[1], SSB_SPROM8_CCODE, 0x00ff, 0);
  264. + SPEX(boardflags_lo, SSB_SPROM8_BFLLO, 0xFFFF, 0);
  265. + SPEX(boardflags_hi, SSB_SPROM8_BFLHI, 0xFFFF, 0);
  266. + SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, 0xFFFF, 0);
  267. + SPEX(boardflags2_hi, SSB_SPROM8_BFL2HI, 0xFFFF, 0);
  268. + SPEX(ant_available_a, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_A,
  269. + SSB_SPROM8_ANTAVAIL_A_SHIFT);
  270. + SPEX(ant_available_bg, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_BG,
  271. + SSB_SPROM8_ANTAVAIL_BG_SHIFT);
  272. + SPEX(maxpwr_bg, SSB_SPROM8_MAXP_BG, SSB_SPROM8_MAXP_BG_MASK, 0);
  273. + SPEX(itssi_bg, SSB_SPROM8_MAXP_BG, SSB_SPROM8_ITSSI_BG,
  274. + SSB_SPROM8_ITSSI_BG_SHIFT);
  275. + SPEX(maxpwr_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_MAXP_A_MASK, 0);
  276. + SPEX(itssi_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_ITSSI_A,
  277. + SSB_SPROM8_ITSSI_A_SHIFT);
  278. + SPEX(maxpwr_ah, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AH_MASK, 0);
  279. + SPEX(maxpwr_al, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AL_MASK,
  280. + SSB_SPROM8_MAXP_AL_SHIFT);
  281. + SPEX(gpio0, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P0, 0);
  282. + SPEX(gpio1, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P1,
  283. + SSB_SPROM8_GPIOA_P1_SHIFT);
  284. + SPEX(gpio2, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P2, 0);
  285. + SPEX(gpio3, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P3,
  286. + SSB_SPROM8_GPIOB_P3_SHIFT);
  287. + SPEX(tri2g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI2G, 0);
  288. + SPEX(tri5g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI5G,
  289. + SSB_SPROM8_TRI5G_SHIFT);
  290. + SPEX(tri5gl, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GL, 0);
  291. + SPEX(tri5gh, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GH,
  292. + SSB_SPROM8_TRI5GH_SHIFT);
  293. + SPEX(rxpo2g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO2G, 0);
  294. + SPEX(rxpo5g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO5G,
  295. + SSB_SPROM8_RXPO5G_SHIFT);
  296. + SPEX(rssismf2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMF2G, 0);
  297. + SPEX(rssismc2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMC2G,
  298. + SSB_SPROM8_RSSISMC2G_SHIFT);
  299. + SPEX(rssisav2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISAV2G,
  300. + SSB_SPROM8_RSSISAV2G_SHIFT);
  301. + SPEX(bxa2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_BXA2G,
  302. + SSB_SPROM8_BXA2G_SHIFT);
  303. + SPEX(rssismf5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMF5G, 0);
  304. + SPEX(rssismc5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMC5G,
  305. + SSB_SPROM8_RSSISMC5G_SHIFT);
  306. + SPEX(rssisav5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISAV5G,
  307. + SSB_SPROM8_RSSISAV5G_SHIFT);
  308. + SPEX(bxa5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_BXA5G,
  309. + SSB_SPROM8_BXA5G_SHIFT);
  310. + SPEX(pa0b0, SSB_SPROM8_PA0B0, 0xFFFF, 0);
  311. + SPEX(pa0b1, SSB_SPROM8_PA0B1, 0xFFFF, 0);
  312. + SPEX(pa0b2, SSB_SPROM8_PA0B2, 0xFFFF, 0);
  313. + SPEX(pa1b0, SSB_SPROM8_PA1B0, 0xFFFF, 0);
  314. + SPEX(pa1b1, SSB_SPROM8_PA1B1, 0xFFFF, 0);
  315. + SPEX(pa1b2, SSB_SPROM8_PA1B2, 0xFFFF, 0);
  316. + SPEX(pa1lob0, SSB_SPROM8_PA1LOB0, 0xFFFF, 0);
  317. + SPEX(pa1lob1, SSB_SPROM8_PA1LOB1, 0xFFFF, 0);
  318. + SPEX(pa1lob2, SSB_SPROM8_PA1LOB2, 0xFFFF, 0);
  319. + SPEX(pa1hib0, SSB_SPROM8_PA1HIB0, 0xFFFF, 0);
  320. + SPEX(pa1hib1, SSB_SPROM8_PA1HIB1, 0xFFFF, 0);
  321. + SPEX(pa1hib2, SSB_SPROM8_PA1HIB2, 0xFFFF, 0);
  322. + SPEX(cck2gpo, SSB_SPROM8_CCK2GPO, 0xFFFF, 0);
  323. + SPEX32(ofdm2gpo, SSB_SPROM8_OFDM2GPO, 0xFFFFFFFF, 0);
  324. + SPEX32(ofdm5glpo, SSB_SPROM8_OFDM5GLPO, 0xFFFFFFFF, 0);
  325. + SPEX32(ofdm5gpo, SSB_SPROM8_OFDM5GPO, 0xFFFFFFFF, 0);
  326. + SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, 0xFFFFFFFF, 0);
  327. +
  328. + /* Extract the antenna gain values. */
  329. + SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
  330. + SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
  331. + SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
  332. + SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
  333. + SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
  334. + SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
  335. + SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
  336. + SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
  337. +
  338. + /* Extract cores power info info */
  339. + for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
  340. + o = pwr_info_offset[i];
  341. + SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
  342. + SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT);
  343. + SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
  344. + SSB_SPROM8_2G_MAXP, 0);
  345. +
  346. + SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0);
  347. + SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0);
  348. + SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0);
  349. +
  350. + SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
  351. + SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT);
  352. + SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
  353. + SSB_SPROM8_5G_MAXP, 0);
  354. + SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP,
  355. + SSB_SPROM8_5GH_MAXP, 0);
  356. + SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP,
  357. + SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT);
  358. +
  359. + SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0);
  360. + SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0);
  361. + SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0);
  362. + SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0);
  363. + SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0);
  364. + SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0);
  365. + SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0);
  366. + SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0);
  367. + SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0);
  368. + }
  369. +
  370. + /* Extract FEM info */
  371. + SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G,
  372. + SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT);
  373. + SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G,
  374. + SSB_SROM8_FEM_EXTPA_GAIN, SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
  375. + SPEX(fem.ghz2.pdet_range, SSB_SPROM8_FEM2G,
  376. + SSB_SROM8_FEM_PDET_RANGE, SSB_SROM8_FEM_PDET_RANGE_SHIFT);
  377. + SPEX(fem.ghz2.tr_iso, SSB_SPROM8_FEM2G,
  378. + SSB_SROM8_FEM_TR_ISO, SSB_SROM8_FEM_TR_ISO_SHIFT);
  379. + SPEX(fem.ghz2.antswlut, SSB_SPROM8_FEM2G,
  380. + SSB_SROM8_FEM_ANTSWLUT, SSB_SROM8_FEM_ANTSWLUT_SHIFT);
  381. +
  382. + SPEX(fem.ghz5.tssipos, SSB_SPROM8_FEM5G,
  383. + SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT);
  384. + SPEX(fem.ghz5.extpa_gain, SSB_SPROM8_FEM5G,
  385. + SSB_SROM8_FEM_EXTPA_GAIN, SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
  386. + SPEX(fem.ghz5.pdet_range, SSB_SPROM8_FEM5G,
  387. + SSB_SROM8_FEM_PDET_RANGE, SSB_SROM8_FEM_PDET_RANGE_SHIFT);
  388. + SPEX(fem.ghz5.tr_iso, SSB_SPROM8_FEM5G,
  389. + SSB_SROM8_FEM_TR_ISO, SSB_SROM8_FEM_TR_ISO_SHIFT);
  390. + SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G,
  391. + SSB_SROM8_FEM_ANTSWLUT, SSB_SROM8_FEM_ANTSWLUT_SHIFT);
  392. +
  393. + SPEX(leddc_on_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_ON,
  394. + SSB_SPROM8_LEDDC_ON_SHIFT);
  395. + SPEX(leddc_off_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_OFF,
  396. + SSB_SPROM8_LEDDC_OFF_SHIFT);
  397. +
  398. + SPEX(txchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_TXCHAIN,
  399. + SSB_SPROM8_TXRXC_TXCHAIN_SHIFT);
  400. + SPEX(rxchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_RXCHAIN,
  401. + SSB_SPROM8_TXRXC_RXCHAIN_SHIFT);
  402. + SPEX(antswitch, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_SWITCH,
  403. + SSB_SPROM8_TXRXC_SWITCH_SHIFT);
  404. +
  405. + SPEX(opo, SSB_SPROM8_OFDM2GPO, 0x00ff, 0);
  406. +
  407. + SPEX_ARRAY8(mcs2gpo, SSB_SPROM8_2G_MCSPO, ~0, 0);
  408. + SPEX_ARRAY8(mcs5gpo, SSB_SPROM8_5G_MCSPO, ~0, 0);
  409. + SPEX_ARRAY8(mcs5glpo, SSB_SPROM8_5GL_MCSPO, ~0, 0);
  410. + SPEX_ARRAY8(mcs5ghpo, SSB_SPROM8_5GH_MCSPO, ~0, 0);
  411. +
  412. + SPEX(rawtempsense, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_RAWTEMP,
  413. + SSB_SPROM8_RAWTS_RAWTEMP_SHIFT);
  414. + SPEX(measpower, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_MEASPOWER,
  415. + SSB_SPROM8_RAWTS_MEASPOWER_SHIFT);
  416. + SPEX(tempsense_slope, SSB_SPROM8_OPT_CORRX,
  417. + SSB_SPROM8_OPT_CORRX_TEMP_SLOPE,
  418. + SSB_SPROM8_OPT_CORRX_TEMP_SLOPE_SHIFT);
  419. + SPEX(tempcorrx, SSB_SPROM8_OPT_CORRX, SSB_SPROM8_OPT_CORRX_TEMPCORRX,
  420. + SSB_SPROM8_OPT_CORRX_TEMPCORRX_SHIFT);
  421. + SPEX(tempsense_option, SSB_SPROM8_OPT_CORRX,
  422. + SSB_SPROM8_OPT_CORRX_TEMP_OPTION,
  423. + SSB_SPROM8_OPT_CORRX_TEMP_OPTION_SHIFT);
  424. + SPEX(freqoffset_corr, SSB_SPROM8_HWIQ_IQSWP,
  425. + SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR,
  426. + SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR_SHIFT);
  427. + SPEX(iqcal_swp_dis, SSB_SPROM8_HWIQ_IQSWP,
  428. + SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP,
  429. + SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP_SHIFT);
  430. + SPEX(hw_iqcal_en, SSB_SPROM8_HWIQ_IQSWP, SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL,
  431. + SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL_SHIFT);
  432. +
  433. + SPEX(bw40po, SSB_SPROM8_BW40PO, ~0, 0);
  434. + SPEX(cddpo, SSB_SPROM8_CDDPO, ~0, 0);
  435. + SPEX(stbcpo, SSB_SPROM8_STBCPO, ~0, 0);
  436. + SPEX(bwduppo, SSB_SPROM8_BWDUPPO, ~0, 0);
  437. +
  438. + SPEX(tempthresh, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_TRESH,
  439. + SSB_SPROM8_THERMAL_TRESH_SHIFT);
  440. + SPEX(tempoffset, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_OFFSET,
  441. + SSB_SPROM8_THERMAL_OFFSET_SHIFT);
  442. + SPEX(phycal_tempdelta, SSB_SPROM8_TEMPDELTA,
  443. + SSB_SPROM8_TEMPDELTA_PHYCAL,
  444. + SSB_SPROM8_TEMPDELTA_PHYCAL_SHIFT);
  445. + SPEX(temps_period, SSB_SPROM8_TEMPDELTA, SSB_SPROM8_TEMPDELTA_PERIOD,
  446. + SSB_SPROM8_TEMPDELTA_PERIOD_SHIFT);
  447. + SPEX(temps_hysteresis, SSB_SPROM8_TEMPDELTA,
  448. + SSB_SPROM8_TEMPDELTA_HYSTERESIS,
  449. + SSB_SPROM8_TEMPDELTA_HYSTERESIS_SHIFT);
  450. + sprom_extract_r458(out, in);
  451. +
  452. + /* TODO - get remaining rev 8 stuff needed */
  453. +}
  454. +
  455. +static int sprom_extract(struct ssb_sprom *out, const u16 *in, u16 size)
  456. +{
  457. + memset(out, 0, sizeof(*out));
  458. +
  459. + out->revision = in[size - 1] & 0x00FF;
  460. + memset(out->et0mac, 0xFF, 6); /* preset et0 and et1 mac */
  461. + memset(out->et1mac, 0xFF, 6);
  462. +
  463. + switch (out->revision) {
  464. + case 1:
  465. + case 2:
  466. + case 3:
  467. + sprom_extract_r123(out, in);
  468. + break;
  469. + case 4:
  470. + case 5:
  471. + sprom_extract_r45(out, in);
  472. + break;
  473. + case 8:
  474. + sprom_extract_r8(out, in);
  475. + break;
  476. + default:
  477. + pr_warn("Unsupported SPROM revision %d detected. Will extract v1\n",
  478. + out->revision);
  479. + out->revision = 1;
  480. + sprom_extract_r123(out, in);
  481. + }
  482. +
  483. + if (out->boardflags_lo == 0xFFFF)
  484. + out->boardflags_lo = 0; /* per specs */
  485. + if (out->boardflags_hi == 0xFFFF)
  486. + out->boardflags_hi = 0; /* per specs */
  487. +
  488. + return 0;
  489. +}
  490. +
  491. +static __initdata u16 template_sprom[220];
  492. #endif
  493. +
  494. int __init bcm63xx_register_fallback_sprom(struct fallback_sprom_data *data)
  495. {
  496. int ret = 0;
  497. #ifdef CONFIG_SSB_PCIHOST
  498. + u16 size = 0;
  499. +
  500. switch (data->type) {
  501. case SPROM_DEFAULT:
  502. memcpy(&bcm63xx_sprom, &bcm63xx_default_sprom,
  503. @@ -71,6 +550,9 @@ int __init bcm63xx_register_fallback_spr
  504. return -EINVAL;
  505. }
  506. + if (size > 0)
  507. + sprom_extract(&bcm63xx_sprom, template_sprom, size);
  508. +
  509. memcpy(bcm63xx_sprom.il0mac, data->mac_addr, ETH_ALEN);
  510. memcpy(bcm63xx_sprom.et0mac, data->mac_addr, ETH_ALEN);
  511. memcpy(bcm63xx_sprom.et1mac, data->mac_addr, ETH_ALEN);