020-ssb_update.patch 98 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206
  1. --- a/arch/mips/bcm47xx/nvram.c
  2. +++ b/arch/mips/bcm47xx/nvram.c
  3. @@ -43,8 +43,8 @@ static void early_nvram_init(void)
  4. #ifdef CONFIG_BCM47XX_SSB
  5. case BCM47XX_BUS_TYPE_SSB:
  6. mcore_ssb = &bcm47xx_bus.ssb.mipscore;
  7. - base = mcore_ssb->flash_window;
  8. - lim = mcore_ssb->flash_window_size;
  9. + base = mcore_ssb->pflash.window;
  10. + lim = mcore_ssb->pflash.window_size;
  11. break;
  12. #endif
  13. #ifdef CONFIG_BCM47XX_BCMA
  14. --- a/arch/mips/bcm47xx/wgt634u.c
  15. +++ b/arch/mips/bcm47xx/wgt634u.c
  16. @@ -156,10 +156,10 @@ static int __init wgt634u_init(void)
  17. SSB_CHIPCO_IRQ_GPIO);
  18. }
  19. - wgt634u_flash_data.width = mcore->flash_buswidth;
  20. - wgt634u_flash_resource.start = mcore->flash_window;
  21. - wgt634u_flash_resource.end = mcore->flash_window
  22. - + mcore->flash_window_size
  23. + wgt634u_flash_data.width = mcore->pflash.buswidth;
  24. + wgt634u_flash_resource.start = mcore->pflash.window;
  25. + wgt634u_flash_resource.end = mcore->pflash.window
  26. + + mcore->pflash.window_size
  27. - 1;
  28. return platform_add_devices(wgt634u_devices,
  29. ARRAY_SIZE(wgt634u_devices));
  30. --- a/drivers/ssb/Kconfig
  31. +++ b/drivers/ssb/Kconfig
  32. @@ -136,10 +136,15 @@ config SSB_DRIVER_MIPS
  33. If unsure, say N
  34. +config SSB_SFLASH
  35. + bool "SSB serial flash support"
  36. + depends on SSB_DRIVER_MIPS
  37. + default y
  38. +
  39. # Assumption: We are on embedded, if we compile the MIPS core.
  40. config SSB_EMBEDDED
  41. bool
  42. - depends on SSB_DRIVER_MIPS
  43. + depends on SSB_DRIVER_MIPS && SSB_PCICORE_HOSTMODE
  44. default y
  45. config SSB_DRIVER_EXTIF
  46. @@ -160,4 +165,12 @@ config SSB_DRIVER_GIGE
  47. If unsure, say N
  48. +config SSB_DRIVER_GPIO
  49. + bool "SSB GPIO driver"
  50. + depends on SSB && GPIOLIB
  51. + help
  52. + Driver to provide access to the GPIO pins on the bus.
  53. +
  54. + If unsure, say N
  55. +
  56. endmenu
  57. --- a/drivers/ssb/Makefile
  58. +++ b/drivers/ssb/Makefile
  59. @@ -11,10 +11,12 @@ ssb-$(CONFIG_SSB_SDIOHOST) += sdio.o
  60. # built-in drivers
  61. ssb-y += driver_chipcommon.o
  62. ssb-y += driver_chipcommon_pmu.o
  63. +ssb-$(CONFIG_SSB_SFLASH) += driver_chipcommon_sflash.o
  64. ssb-$(CONFIG_SSB_DRIVER_MIPS) += driver_mipscore.o
  65. ssb-$(CONFIG_SSB_DRIVER_EXTIF) += driver_extif.o
  66. ssb-$(CONFIG_SSB_DRIVER_PCICORE) += driver_pcicore.o
  67. ssb-$(CONFIG_SSB_DRIVER_GIGE) += driver_gige.o
  68. +ssb-$(CONFIG_SSB_DRIVER_GPIO) += driver_gpio.o
  69. # b43 pci-ssb-bridge driver
  70. # Not strictly a part of SSB, but kept here for convenience
  71. --- a/drivers/ssb/b43_pci_bridge.c
  72. +++ b/drivers/ssb/b43_pci_bridge.c
  73. @@ -29,11 +29,15 @@ static const struct pci_device_id b43_pc
  74. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4319) },
  75. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4320) },
  76. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4321) },
  77. + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4322) },
  78. + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43222) },
  79. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4324) },
  80. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4325) },
  81. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4328) },
  82. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4329) },
  83. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x432b) },
  84. + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x432c) },
  85. + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4350) },
  86. { 0, },
  87. };
  88. MODULE_DEVICE_TABLE(pci, b43_pci_bridge_tbl);
  89. --- a/drivers/ssb/driver_chipcommon.c
  90. +++ b/drivers/ssb/driver_chipcommon.c
  91. @@ -4,6 +4,7 @@
  92. *
  93. * Copyright 2005, Broadcom Corporation
  94. * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
  95. + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
  96. *
  97. * Licensed under the GNU/GPL. See COPYING for details.
  98. */
  99. @@ -12,6 +13,7 @@
  100. #include <linux/ssb/ssb_regs.h>
  101. #include <linux/export.h>
  102. #include <linux/pci.h>
  103. +#include <linux/bcm47xx_wdt.h>
  104. #include "ssb_private.h"
  105. @@ -280,13 +282,79 @@ static void calc_fast_powerup_delay(stru
  106. cc->fast_pwrup_delay = tmp;
  107. }
  108. +static u32 ssb_chipco_alp_clock(struct ssb_chipcommon *cc)
  109. +{
  110. + if (cc->capabilities & SSB_CHIPCO_CAP_PMU)
  111. + return ssb_pmu_get_alp_clock(cc);
  112. +
  113. + return 20000000;
  114. +}
  115. +
  116. +static u32 ssb_chipco_watchdog_get_max_timer(struct ssb_chipcommon *cc)
  117. +{
  118. + u32 nb;
  119. +
  120. + if (cc->capabilities & SSB_CHIPCO_CAP_PMU) {
  121. + if (cc->dev->id.revision < 26)
  122. + nb = 16;
  123. + else
  124. + nb = (cc->dev->id.revision >= 37) ? 32 : 24;
  125. + } else {
  126. + nb = 28;
  127. + }
  128. + if (nb == 32)
  129. + return 0xffffffff;
  130. + else
  131. + return (1 << nb) - 1;
  132. +}
  133. +
  134. +u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks)
  135. +{
  136. + struct ssb_chipcommon *cc = bcm47xx_wdt_get_drvdata(wdt);
  137. +
  138. + if (cc->dev->bus->bustype != SSB_BUSTYPE_SSB)
  139. + return 0;
  140. +
  141. + return ssb_chipco_watchdog_timer_set(cc, ticks);
  142. +}
  143. +
  144. +u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms)
  145. +{
  146. + struct ssb_chipcommon *cc = bcm47xx_wdt_get_drvdata(wdt);
  147. + u32 ticks;
  148. +
  149. + if (cc->dev->bus->bustype != SSB_BUSTYPE_SSB)
  150. + return 0;
  151. +
  152. + ticks = ssb_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms);
  153. + return ticks / cc->ticks_per_ms;
  154. +}
  155. +
  156. +static int ssb_chipco_watchdog_ticks_per_ms(struct ssb_chipcommon *cc)
  157. +{
  158. + struct ssb_bus *bus = cc->dev->bus;
  159. +
  160. + if (cc->capabilities & SSB_CHIPCO_CAP_PMU) {
  161. + /* based on 32KHz ILP clock */
  162. + return 32;
  163. + } else {
  164. + if (cc->dev->id.revision < 18)
  165. + return ssb_clockspeed(bus) / 1000;
  166. + else
  167. + return ssb_chipco_alp_clock(cc) / 1000;
  168. + }
  169. +}
  170. +
  171. void ssb_chipcommon_init(struct ssb_chipcommon *cc)
  172. {
  173. if (!cc->dev)
  174. return; /* We don't have a ChipCommon */
  175. +
  176. + spin_lock_init(&cc->gpio_lock);
  177. +
  178. if (cc->dev->id.revision >= 11)
  179. cc->status = chipco_read32(cc, SSB_CHIPCO_CHIPSTAT);
  180. - ssb_dprintk(KERN_INFO PFX "chipcommon status is 0x%x\n", cc->status);
  181. + ssb_dbg("chipcommon status is 0x%x\n", cc->status);
  182. if (cc->dev->id.revision >= 20) {
  183. chipco_write32(cc, SSB_CHIPCO_GPIOPULLUP, 0);
  184. @@ -297,6 +365,11 @@ void ssb_chipcommon_init(struct ssb_chip
  185. chipco_powercontrol_init(cc);
  186. ssb_chipco_set_clockmode(cc, SSB_CLKMODE_FAST);
  187. calc_fast_powerup_delay(cc);
  188. +
  189. + if (cc->dev->bus->bustype == SSB_BUSTYPE_SSB) {
  190. + cc->ticks_per_ms = ssb_chipco_watchdog_ticks_per_ms(cc);
  191. + cc->max_timer_ms = ssb_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
  192. + }
  193. }
  194. void ssb_chipco_suspend(struct ssb_chipcommon *cc)
  195. @@ -395,10 +468,27 @@ void ssb_chipco_timing_init(struct ssb_c
  196. }
  197. /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
  198. -void ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc, u32 ticks)
  199. +u32 ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc, u32 ticks)
  200. {
  201. - /* instant NMI */
  202. - chipco_write32(cc, SSB_CHIPCO_WATCHDOG, ticks);
  203. + u32 maxt;
  204. + enum ssb_clkmode clkmode;
  205. +
  206. + maxt = ssb_chipco_watchdog_get_max_timer(cc);
  207. + if (cc->capabilities & SSB_CHIPCO_CAP_PMU) {
  208. + if (ticks == 1)
  209. + ticks = 2;
  210. + else if (ticks > maxt)
  211. + ticks = maxt;
  212. + chipco_write32(cc, SSB_CHIPCO_PMU_WATCHDOG, ticks);
  213. + } else {
  214. + clkmode = ticks ? SSB_CLKMODE_FAST : SSB_CLKMODE_DYNAMIC;
  215. + ssb_chipco_set_clockmode(cc, clkmode);
  216. + if (ticks > maxt)
  217. + ticks = maxt;
  218. + /* instant NMI */
  219. + chipco_write32(cc, SSB_CHIPCO_WATCHDOG, ticks);
  220. + }
  221. + return ticks;
  222. }
  223. void ssb_chipco_irq_mask(struct ssb_chipcommon *cc, u32 mask, u32 value)
  224. @@ -418,28 +508,93 @@ u32 ssb_chipco_gpio_in(struct ssb_chipco
  225. u32 ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value)
  226. {
  227. - return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUT, mask, value);
  228. + unsigned long flags;
  229. + u32 res = 0;
  230. +
  231. + spin_lock_irqsave(&cc->gpio_lock, flags);
  232. + res = chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUT, mask, value);
  233. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  234. +
  235. + return res;
  236. }
  237. u32 ssb_chipco_gpio_outen(struct ssb_chipcommon *cc, u32 mask, u32 value)
  238. {
  239. - return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUTEN, mask, value);
  240. + unsigned long flags;
  241. + u32 res = 0;
  242. +
  243. + spin_lock_irqsave(&cc->gpio_lock, flags);
  244. + res = chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUTEN, mask, value);
  245. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  246. +
  247. + return res;
  248. }
  249. u32 ssb_chipco_gpio_control(struct ssb_chipcommon *cc, u32 mask, u32 value)
  250. {
  251. - return chipco_write32_masked(cc, SSB_CHIPCO_GPIOCTL, mask, value);
  252. + unsigned long flags;
  253. + u32 res = 0;
  254. +
  255. + spin_lock_irqsave(&cc->gpio_lock, flags);
  256. + res = chipco_write32_masked(cc, SSB_CHIPCO_GPIOCTL, mask, value);
  257. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  258. +
  259. + return res;
  260. }
  261. EXPORT_SYMBOL(ssb_chipco_gpio_control);
  262. u32 ssb_chipco_gpio_intmask(struct ssb_chipcommon *cc, u32 mask, u32 value)
  263. {
  264. - return chipco_write32_masked(cc, SSB_CHIPCO_GPIOIRQ, mask, value);
  265. + unsigned long flags;
  266. + u32 res = 0;
  267. +
  268. + spin_lock_irqsave(&cc->gpio_lock, flags);
  269. + res = chipco_write32_masked(cc, SSB_CHIPCO_GPIOIRQ, mask, value);
  270. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  271. +
  272. + return res;
  273. }
  274. u32 ssb_chipco_gpio_polarity(struct ssb_chipcommon *cc, u32 mask, u32 value)
  275. {
  276. - return chipco_write32_masked(cc, SSB_CHIPCO_GPIOPOL, mask, value);
  277. + unsigned long flags;
  278. + u32 res = 0;
  279. +
  280. + spin_lock_irqsave(&cc->gpio_lock, flags);
  281. + res = chipco_write32_masked(cc, SSB_CHIPCO_GPIOPOL, mask, value);
  282. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  283. +
  284. + return res;
  285. +}
  286. +
  287. +u32 ssb_chipco_gpio_pullup(struct ssb_chipcommon *cc, u32 mask, u32 value)
  288. +{
  289. + unsigned long flags;
  290. + u32 res = 0;
  291. +
  292. + if (cc->dev->id.revision < 20)
  293. + return 0xffffffff;
  294. +
  295. + spin_lock_irqsave(&cc->gpio_lock, flags);
  296. + res = chipco_write32_masked(cc, SSB_CHIPCO_GPIOPULLUP, mask, value);
  297. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  298. +
  299. + return res;
  300. +}
  301. +
  302. +u32 ssb_chipco_gpio_pulldown(struct ssb_chipcommon *cc, u32 mask, u32 value)
  303. +{
  304. + unsigned long flags;
  305. + u32 res = 0;
  306. +
  307. + if (cc->dev->id.revision < 20)
  308. + return 0xffffffff;
  309. +
  310. + spin_lock_irqsave(&cc->gpio_lock, flags);
  311. + res = chipco_write32_masked(cc, SSB_CHIPCO_GPIOPULLDOWN, mask, value);
  312. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  313. +
  314. + return res;
  315. }
  316. #ifdef CONFIG_SSB_SERIAL
  317. @@ -473,12 +628,7 @@ int ssb_chipco_serial_init(struct ssb_ch
  318. chipco_read32(cc, SSB_CHIPCO_CORECTL)
  319. | SSB_CHIPCO_CORECTL_UARTCLK0);
  320. } else if ((ccrev >= 11) && (ccrev != 15)) {
  321. - /* Fixed ALP clock */
  322. - baud_base = 20000000;
  323. - if (cc->capabilities & SSB_CHIPCO_CAP_PMU) {
  324. - /* FIXME: baud_base is different for devices with a PMU */
  325. - SSB_WARN_ON(1);
  326. - }
  327. + baud_base = ssb_chipco_alp_clock(cc);
  328. div = 1;
  329. if (ccrev >= 21) {
  330. /* Turn off UART clock before switching clocksource. */
  331. --- a/drivers/ssb/driver_chipcommon_pmu.c
  332. +++ b/drivers/ssb/driver_chipcommon_pmu.c
  333. @@ -13,6 +13,9 @@
  334. #include <linux/ssb/ssb_driver_chipcommon.h>
  335. #include <linux/delay.h>
  336. #include <linux/export.h>
  337. +#ifdef CONFIG_BCM47XX
  338. +#include <asm/mach-bcm47xx/nvram.h>
  339. +#endif
  340. #include "ssb_private.h"
  341. @@ -92,10 +95,6 @@ static void ssb_pmu0_pllinit_r0(struct s
  342. u32 pmuctl, tmp, pllctl;
  343. unsigned int i;
  344. - if ((bus->chip_id == 0x5354) && !crystalfreq) {
  345. - /* The 5354 crystal freq is 25MHz */
  346. - crystalfreq = 25000;
  347. - }
  348. if (crystalfreq)
  349. e = pmu0_plltab_find_entry(crystalfreq);
  350. if (!e)
  351. @@ -111,8 +110,8 @@ static void ssb_pmu0_pllinit_r0(struct s
  352. return;
  353. }
  354. - ssb_printk(KERN_INFO PFX "Programming PLL to %u.%03u MHz\n",
  355. - (crystalfreq / 1000), (crystalfreq % 1000));
  356. + ssb_info("Programming PLL to %u.%03u MHz\n",
  357. + crystalfreq / 1000, crystalfreq % 1000);
  358. /* First turn the PLL off. */
  359. switch (bus->chip_id) {
  360. @@ -139,7 +138,7 @@ static void ssb_pmu0_pllinit_r0(struct s
  361. }
  362. tmp = chipco_read32(cc, SSB_CHIPCO_CLKCTLST);
  363. if (tmp & SSB_CHIPCO_CLKCTLST_HAVEHT)
  364. - ssb_printk(KERN_EMERG PFX "Failed to turn the PLL off!\n");
  365. + ssb_emerg("Failed to turn the PLL off!\n");
  366. /* Set PDIV in PLL control 0. */
  367. pllctl = ssb_chipco_pll_read(cc, SSB_PMU0_PLLCTL0);
  368. @@ -250,8 +249,8 @@ static void ssb_pmu1_pllinit_r0(struct s
  369. return;
  370. }
  371. - ssb_printk(KERN_INFO PFX "Programming PLL to %u.%03u MHz\n",
  372. - (crystalfreq / 1000), (crystalfreq % 1000));
  373. + ssb_info("Programming PLL to %u.%03u MHz\n",
  374. + crystalfreq / 1000, crystalfreq % 1000);
  375. /* First turn the PLL off. */
  376. switch (bus->chip_id) {
  377. @@ -276,7 +275,7 @@ static void ssb_pmu1_pllinit_r0(struct s
  378. }
  379. tmp = chipco_read32(cc, SSB_CHIPCO_CLKCTLST);
  380. if (tmp & SSB_CHIPCO_CLKCTLST_HAVEHT)
  381. - ssb_printk(KERN_EMERG PFX "Failed to turn the PLL off!\n");
  382. + ssb_emerg("Failed to turn the PLL off!\n");
  383. /* Set p1div and p2div. */
  384. pllctl = ssb_chipco_pll_read(cc, SSB_PMU1_PLLCTL0);
  385. @@ -321,7 +320,11 @@ static void ssb_pmu_pll_init(struct ssb_
  386. u32 crystalfreq = 0; /* in kHz. 0 = keep default freq. */
  387. if (bus->bustype == SSB_BUSTYPE_SSB) {
  388. - /* TODO: The user may override the crystal frequency. */
  389. +#ifdef CONFIG_BCM47XX
  390. + char buf[20];
  391. + if (nvram_getenv("xtalfreq", buf, sizeof(buf)) >= 0)
  392. + crystalfreq = simple_strtoul(buf, NULL, 0);
  393. +#endif
  394. }
  395. switch (bus->chip_id) {
  396. @@ -330,7 +333,11 @@ static void ssb_pmu_pll_init(struct ssb_
  397. ssb_pmu1_pllinit_r0(cc, crystalfreq);
  398. break;
  399. case 0x4328:
  400. + ssb_pmu0_pllinit_r0(cc, crystalfreq);
  401. + break;
  402. case 0x5354:
  403. + if (crystalfreq == 0)
  404. + crystalfreq = 25000;
  405. ssb_pmu0_pllinit_r0(cc, crystalfreq);
  406. break;
  407. case 0x4322:
  408. @@ -339,10 +346,11 @@ static void ssb_pmu_pll_init(struct ssb_
  409. chipco_write32(cc, SSB_CHIPCO_PLLCTL_DATA, 0x380005C0);
  410. }
  411. break;
  412. + case 43222:
  413. + break;
  414. default:
  415. - ssb_printk(KERN_ERR PFX
  416. - "ERROR: PLL init unknown for device %04X\n",
  417. - bus->chip_id);
  418. + ssb_err("ERROR: PLL init unknown for device %04X\n",
  419. + bus->chip_id);
  420. }
  421. }
  422. @@ -427,6 +435,7 @@ static void ssb_pmu_resources_init(struc
  423. min_msk = 0xCBB;
  424. break;
  425. case 0x4322:
  426. + case 43222:
  427. /* We keep the default settings:
  428. * min_msk = 0xCBB
  429. * max_msk = 0x7FFFF
  430. @@ -462,9 +471,8 @@ static void ssb_pmu_resources_init(struc
  431. max_msk = 0xFFFFF;
  432. break;
  433. default:
  434. - ssb_printk(KERN_ERR PFX
  435. - "ERROR: PMU resource config unknown for device %04X\n",
  436. - bus->chip_id);
  437. + ssb_err("ERROR: PMU resource config unknown for device %04X\n",
  438. + bus->chip_id);
  439. }
  440. if (updown_tab) {
  441. @@ -516,8 +524,8 @@ void ssb_pmu_init(struct ssb_chipcommon
  442. pmucap = chipco_read32(cc, SSB_CHIPCO_PMU_CAP);
  443. cc->pmu.rev = (pmucap & SSB_CHIPCO_PMU_CAP_REVISION);
  444. - ssb_dprintk(KERN_DEBUG PFX "Found rev %u PMU (capabilities 0x%08X)\n",
  445. - cc->pmu.rev, pmucap);
  446. + ssb_dbg("Found rev %u PMU (capabilities 0x%08X)\n",
  447. + cc->pmu.rev, pmucap);
  448. if (cc->pmu.rev == 1)
  449. chipco_mask32(cc, SSB_CHIPCO_PMU_CTL,
  450. @@ -607,3 +615,102 @@ void ssb_pmu_set_ldo_paref(struct ssb_ch
  451. EXPORT_SYMBOL(ssb_pmu_set_ldo_voltage);
  452. EXPORT_SYMBOL(ssb_pmu_set_ldo_paref);
  453. +
  454. +static u32 ssb_pmu_get_alp_clock_clk0(struct ssb_chipcommon *cc)
  455. +{
  456. + u32 crystalfreq;
  457. + const struct pmu0_plltab_entry *e = NULL;
  458. +
  459. + crystalfreq = chipco_read32(cc, SSB_CHIPCO_PMU_CTL) &
  460. + SSB_CHIPCO_PMU_CTL_XTALFREQ >> SSB_CHIPCO_PMU_CTL_XTALFREQ_SHIFT;
  461. + e = pmu0_plltab_find_entry(crystalfreq);
  462. + BUG_ON(!e);
  463. + return e->freq * 1000;
  464. +}
  465. +
  466. +u32 ssb_pmu_get_alp_clock(struct ssb_chipcommon *cc)
  467. +{
  468. + struct ssb_bus *bus = cc->dev->bus;
  469. +
  470. + switch (bus->chip_id) {
  471. + case 0x5354:
  472. + ssb_pmu_get_alp_clock_clk0(cc);
  473. + default:
  474. + ssb_err("ERROR: PMU alp clock unknown for device %04X\n",
  475. + bus->chip_id);
  476. + return 0;
  477. + }
  478. +}
  479. +
  480. +u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc)
  481. +{
  482. + struct ssb_bus *bus = cc->dev->bus;
  483. +
  484. + switch (bus->chip_id) {
  485. + case 0x5354:
  486. + /* 5354 chip uses a non programmable PLL of frequency 240MHz */
  487. + return 240000000;
  488. + default:
  489. + ssb_err("ERROR: PMU cpu clock unknown for device %04X\n",
  490. + bus->chip_id);
  491. + return 0;
  492. + }
  493. +}
  494. +
  495. +u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc)
  496. +{
  497. + struct ssb_bus *bus = cc->dev->bus;
  498. +
  499. + switch (bus->chip_id) {
  500. + case 0x5354:
  501. + return 120000000;
  502. + default:
  503. + ssb_err("ERROR: PMU controlclock unknown for device %04X\n",
  504. + bus->chip_id);
  505. + return 0;
  506. + }
  507. +}
  508. +
  509. +void ssb_pmu_spuravoid_pllupdate(struct ssb_chipcommon *cc, int spuravoid)
  510. +{
  511. + u32 pmu_ctl = 0;
  512. +
  513. + switch (cc->dev->bus->chip_id) {
  514. + case 0x4322:
  515. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL0, 0x11100070);
  516. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL1, 0x1014140a);
  517. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL5, 0x88888854);
  518. + if (spuravoid == 1)
  519. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL2, 0x05201828);
  520. + else
  521. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL2, 0x05001828);
  522. + pmu_ctl = SSB_CHIPCO_PMU_CTL_PLL_UPD;
  523. + break;
  524. + case 43222:
  525. + if (spuravoid == 1) {
  526. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL0, 0x11500008);
  527. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL1, 0x0C000C06);
  528. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL2, 0x0F600a08);
  529. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL3, 0x00000000);
  530. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL4, 0x2001E920);
  531. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL5, 0x88888815);
  532. + } else {
  533. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL0, 0x11100008);
  534. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL1, 0x0c000c06);
  535. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL2, 0x03000a08);
  536. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL3, 0x00000000);
  537. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL4, 0x200005c0);
  538. + ssb_chipco_pll_write(cc, SSB_PMU1_PLLCTL5, 0x88888855);
  539. + }
  540. + pmu_ctl = SSB_CHIPCO_PMU_CTL_PLL_UPD;
  541. + break;
  542. + default:
  543. + ssb_printk(KERN_ERR PFX
  544. + "Unknown spuravoidance settings for chip 0x%04X, not changing PLL\n",
  545. + cc->dev->bus->chip_id);
  546. + return;
  547. + }
  548. +
  549. + chipco_set32(cc, SSB_CHIPCO_PMU_CTL, pmu_ctl);
  550. +}
  551. +EXPORT_SYMBOL_GPL(ssb_pmu_spuravoid_pllupdate);
  552. --- /dev/null
  553. +++ b/drivers/ssb/driver_chipcommon_sflash.c
  554. @@ -0,0 +1,164 @@
  555. +/*
  556. + * Sonics Silicon Backplane
  557. + * ChipCommon serial flash interface
  558. + *
  559. + * Licensed under the GNU/GPL. See COPYING for details.
  560. + */
  561. +
  562. +#include <linux/ssb/ssb.h>
  563. +
  564. +#include "ssb_private.h"
  565. +
  566. +static struct resource ssb_sflash_resource = {
  567. + .name = "ssb_sflash",
  568. + .start = SSB_FLASH2,
  569. + .end = 0,
  570. + .flags = IORESOURCE_MEM | IORESOURCE_READONLY,
  571. +};
  572. +
  573. +struct platform_device ssb_sflash_dev = {
  574. + .name = "ssb_sflash",
  575. + .resource = &ssb_sflash_resource,
  576. + .num_resources = 1,
  577. +};
  578. +
  579. +struct ssb_sflash_tbl_e {
  580. + char *name;
  581. + u32 id;
  582. + u32 blocksize;
  583. + u16 numblocks;
  584. +};
  585. +
  586. +static const struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
  587. + { "M25P20", 0x11, 0x10000, 4, },
  588. + { "M25P40", 0x12, 0x10000, 8, },
  589. +
  590. + { "M25P16", 0x14, 0x10000, 32, },
  591. + { "M25P32", 0x15, 0x10000, 64, },
  592. + { "M25P64", 0x16, 0x10000, 128, },
  593. + { "M25FL128", 0x17, 0x10000, 256, },
  594. + { 0 },
  595. +};
  596. +
  597. +static const struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
  598. + { "SST25WF512", 1, 0x1000, 16, },
  599. + { "SST25VF512", 0x48, 0x1000, 16, },
  600. + { "SST25WF010", 2, 0x1000, 32, },
  601. + { "SST25VF010", 0x49, 0x1000, 32, },
  602. + { "SST25WF020", 3, 0x1000, 64, },
  603. + { "SST25VF020", 0x43, 0x1000, 64, },
  604. + { "SST25WF040", 4, 0x1000, 128, },
  605. + { "SST25VF040", 0x44, 0x1000, 128, },
  606. + { "SST25VF040B", 0x8d, 0x1000, 128, },
  607. + { "SST25WF080", 5, 0x1000, 256, },
  608. + { "SST25VF080B", 0x8e, 0x1000, 256, },
  609. + { "SST25VF016", 0x41, 0x1000, 512, },
  610. + { "SST25VF032", 0x4a, 0x1000, 1024, },
  611. + { "SST25VF064", 0x4b, 0x1000, 2048, },
  612. + { 0 },
  613. +};
  614. +
  615. +static const struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = {
  616. + { "AT45DB011", 0xc, 256, 512, },
  617. + { "AT45DB021", 0x14, 256, 1024, },
  618. + { "AT45DB041", 0x1c, 256, 2048, },
  619. + { "AT45DB081", 0x24, 256, 4096, },
  620. + { "AT45DB161", 0x2c, 512, 4096, },
  621. + { "AT45DB321", 0x34, 512, 8192, },
  622. + { "AT45DB642", 0x3c, 1024, 8192, },
  623. + { 0 },
  624. +};
  625. +
  626. +static void ssb_sflash_cmd(struct ssb_chipcommon *cc, u32 opcode)
  627. +{
  628. + int i;
  629. + chipco_write32(cc, SSB_CHIPCO_FLASHCTL,
  630. + SSB_CHIPCO_FLASHCTL_START | opcode);
  631. + for (i = 0; i < 1000; i++) {
  632. + if (!(chipco_read32(cc, SSB_CHIPCO_FLASHCTL) &
  633. + SSB_CHIPCO_FLASHCTL_BUSY))
  634. + return;
  635. + cpu_relax();
  636. + }
  637. + pr_err("SFLASH control command failed (timeout)!\n");
  638. +}
  639. +
  640. +/* Initialize serial flash access */
  641. +int ssb_sflash_init(struct ssb_chipcommon *cc)
  642. +{
  643. + struct ssb_sflash *sflash = &cc->dev->bus->mipscore.sflash;
  644. + const struct ssb_sflash_tbl_e *e;
  645. + u32 id, id2;
  646. +
  647. + switch (cc->capabilities & SSB_CHIPCO_CAP_FLASHT) {
  648. + case SSB_CHIPCO_FLASHT_STSER:
  649. + ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_DP);
  650. +
  651. + chipco_write32(cc, SSB_CHIPCO_FLASHADDR, 0);
  652. + ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_RES);
  653. + id = chipco_read32(cc, SSB_CHIPCO_FLASHDATA);
  654. +
  655. + chipco_write32(cc, SSB_CHIPCO_FLASHADDR, 1);
  656. + ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_RES);
  657. + id2 = chipco_read32(cc, SSB_CHIPCO_FLASHDATA);
  658. +
  659. + switch (id) {
  660. + case 0xbf:
  661. + for (e = ssb_sflash_sst_tbl; e->name; e++) {
  662. + if (e->id == id2)
  663. + break;
  664. + }
  665. + break;
  666. + case 0x13:
  667. + return -ENOTSUPP;
  668. + default:
  669. + for (e = ssb_sflash_st_tbl; e->name; e++) {
  670. + if (e->id == id)
  671. + break;
  672. + }
  673. + break;
  674. + }
  675. + if (!e->name) {
  676. + pr_err("Unsupported ST serial flash (id: 0x%X, id2: 0x%X)\n",
  677. + id, id2);
  678. + return -ENOTSUPP;
  679. + }
  680. +
  681. + break;
  682. + case SSB_CHIPCO_FLASHT_ATSER:
  683. + ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_AT_STATUS);
  684. + id = chipco_read32(cc, SSB_CHIPCO_FLASHDATA) & 0x3c;
  685. +
  686. + for (e = ssb_sflash_at_tbl; e->name; e++) {
  687. + if (e->id == id)
  688. + break;
  689. + }
  690. + if (!e->name) {
  691. + pr_err("Unsupported Atmel serial flash (id: 0x%X)\n",
  692. + id);
  693. + return -ENOTSUPP;
  694. + }
  695. +
  696. + break;
  697. + default:
  698. + pr_err("Unsupported flash type\n");
  699. + return -ENOTSUPP;
  700. + }
  701. +
  702. + sflash->window = SSB_FLASH2;
  703. + sflash->blocksize = e->blocksize;
  704. + sflash->numblocks = e->numblocks;
  705. + sflash->size = sflash->blocksize * sflash->numblocks;
  706. + sflash->present = true;
  707. +
  708. + pr_info("Found %s serial flash (size: %dKiB, blocksize: 0x%X, blocks: %d)\n",
  709. + e->name, sflash->size / 1024, e->blocksize, e->numblocks);
  710. +
  711. + /* Prepare platform device, but don't register it yet. It's too early,
  712. + * malloc (required by device_private_init) is not available yet. */
  713. + ssb_sflash_dev.resource[0].end = ssb_sflash_dev.resource[0].start +
  714. + sflash->size;
  715. + ssb_sflash_dev.dev.platform_data = sflash;
  716. +
  717. + return 0;
  718. +}
  719. --- a/drivers/ssb/driver_extif.c
  720. +++ b/drivers/ssb/driver_extif.c
  721. @@ -112,10 +112,37 @@ void ssb_extif_get_clockcontrol(struct s
  722. *m = extif_read32(extif, SSB_EXTIF_CLOCK_SB);
  723. }
  724. -void ssb_extif_watchdog_timer_set(struct ssb_extif *extif,
  725. - u32 ticks)
  726. +u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks)
  727. {
  728. + struct ssb_extif *extif = bcm47xx_wdt_get_drvdata(wdt);
  729. +
  730. + return ssb_extif_watchdog_timer_set(extif, ticks);
  731. +}
  732. +
  733. +u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms)
  734. +{
  735. + struct ssb_extif *extif = bcm47xx_wdt_get_drvdata(wdt);
  736. + u32 ticks = (SSB_EXTIF_WATCHDOG_CLK / 1000) * ms;
  737. +
  738. + ticks = ssb_extif_watchdog_timer_set(extif, ticks);
  739. +
  740. + return (ticks * 1000) / SSB_EXTIF_WATCHDOG_CLK;
  741. +}
  742. +
  743. +u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks)
  744. +{
  745. + if (ticks > SSB_EXTIF_WATCHDOG_MAX_TIMER)
  746. + ticks = SSB_EXTIF_WATCHDOG_MAX_TIMER;
  747. extif_write32(extif, SSB_EXTIF_WATCHDOG, ticks);
  748. +
  749. + return ticks;
  750. +}
  751. +
  752. +void ssb_extif_init(struct ssb_extif *extif)
  753. +{
  754. + if (!extif->dev)
  755. + return; /* We don't have a Extif core */
  756. + spin_lock_init(&extif->gpio_lock);
  757. }
  758. u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask)
  759. @@ -125,22 +152,50 @@ u32 ssb_extif_gpio_in(struct ssb_extif *
  760. u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask, u32 value)
  761. {
  762. - return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUT(0),
  763. + unsigned long flags;
  764. + u32 res = 0;
  765. +
  766. + spin_lock_irqsave(&extif->gpio_lock, flags);
  767. + res = extif_write32_masked(extif, SSB_EXTIF_GPIO_OUT(0),
  768. mask, value);
  769. + spin_unlock_irqrestore(&extif->gpio_lock, flags);
  770. +
  771. + return res;
  772. }
  773. u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask, u32 value)
  774. {
  775. - return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUTEN(0),
  776. + unsigned long flags;
  777. + u32 res = 0;
  778. +
  779. + spin_lock_irqsave(&extif->gpio_lock, flags);
  780. + res = extif_write32_masked(extif, SSB_EXTIF_GPIO_OUTEN(0),
  781. mask, value);
  782. + spin_unlock_irqrestore(&extif->gpio_lock, flags);
  783. +
  784. + return res;
  785. }
  786. u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask, u32 value)
  787. {
  788. - return extif_write32_masked(extif, SSB_EXTIF_GPIO_INTPOL, mask, value);
  789. + unsigned long flags;
  790. + u32 res = 0;
  791. +
  792. + spin_lock_irqsave(&extif->gpio_lock, flags);
  793. + res = extif_write32_masked(extif, SSB_EXTIF_GPIO_INTPOL, mask, value);
  794. + spin_unlock_irqrestore(&extif->gpio_lock, flags);
  795. +
  796. + return res;
  797. }
  798. u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask, u32 value)
  799. {
  800. - return extif_write32_masked(extif, SSB_EXTIF_GPIO_INTMASK, mask, value);
  801. + unsigned long flags;
  802. + u32 res = 0;
  803. +
  804. + spin_lock_irqsave(&extif->gpio_lock, flags);
  805. + res = extif_write32_masked(extif, SSB_EXTIF_GPIO_INTMASK, mask, value);
  806. + spin_unlock_irqrestore(&extif->gpio_lock, flags);
  807. +
  808. + return res;
  809. }
  810. --- /dev/null
  811. +++ b/drivers/ssb/driver_gpio.c
  812. @@ -0,0 +1,210 @@
  813. +/*
  814. + * Sonics Silicon Backplane
  815. + * GPIO driver
  816. + *
  817. + * Copyright 2011, Broadcom Corporation
  818. + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
  819. + *
  820. + * Licensed under the GNU/GPL. See COPYING for details.
  821. + */
  822. +
  823. +#include <linux/gpio.h>
  824. +#include <linux/export.h>
  825. +#include <linux/ssb/ssb.h>
  826. +
  827. +#include "ssb_private.h"
  828. +
  829. +static struct ssb_bus *ssb_gpio_get_bus(struct gpio_chip *chip)
  830. +{
  831. + return container_of(chip, struct ssb_bus, gpio);
  832. +}
  833. +
  834. +static int ssb_gpio_chipco_get_value(struct gpio_chip *chip, unsigned gpio)
  835. +{
  836. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  837. +
  838. + return !!ssb_chipco_gpio_in(&bus->chipco, 1 << gpio);
  839. +}
  840. +
  841. +static void ssb_gpio_chipco_set_value(struct gpio_chip *chip, unsigned gpio,
  842. + int value)
  843. +{
  844. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  845. +
  846. + ssb_chipco_gpio_out(&bus->chipco, 1 << gpio, value ? 1 << gpio : 0);
  847. +}
  848. +
  849. +static int ssb_gpio_chipco_direction_input(struct gpio_chip *chip,
  850. + unsigned gpio)
  851. +{
  852. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  853. +
  854. + ssb_chipco_gpio_outen(&bus->chipco, 1 << gpio, 0);
  855. + return 0;
  856. +}
  857. +
  858. +static int ssb_gpio_chipco_direction_output(struct gpio_chip *chip,
  859. + unsigned gpio, int value)
  860. +{
  861. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  862. +
  863. + ssb_chipco_gpio_outen(&bus->chipco, 1 << gpio, 1 << gpio);
  864. + ssb_chipco_gpio_out(&bus->chipco, 1 << gpio, value ? 1 << gpio : 0);
  865. + return 0;
  866. +}
  867. +
  868. +static int ssb_gpio_chipco_request(struct gpio_chip *chip, unsigned gpio)
  869. +{
  870. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  871. +
  872. + ssb_chipco_gpio_control(&bus->chipco, 1 << gpio, 0);
  873. + /* clear pulldown */
  874. + ssb_chipco_gpio_pulldown(&bus->chipco, 1 << gpio, 0);
  875. + /* Set pullup */
  876. + ssb_chipco_gpio_pullup(&bus->chipco, 1 << gpio, 1 << gpio);
  877. +
  878. + return 0;
  879. +}
  880. +
  881. +static void ssb_gpio_chipco_free(struct gpio_chip *chip, unsigned gpio)
  882. +{
  883. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  884. +
  885. + /* clear pullup */
  886. + ssb_chipco_gpio_pullup(&bus->chipco, 1 << gpio, 0);
  887. +}
  888. +
  889. +static int ssb_gpio_chipco_to_irq(struct gpio_chip *chip, unsigned gpio)
  890. +{
  891. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  892. +
  893. + if (bus->bustype == SSB_BUSTYPE_SSB)
  894. + return ssb_mips_irq(bus->chipco.dev) + 2;
  895. + else
  896. + return -EINVAL;
  897. +}
  898. +
  899. +static int ssb_gpio_chipco_init(struct ssb_bus *bus)
  900. +{
  901. + struct gpio_chip *chip = &bus->gpio;
  902. +
  903. + chip->label = "ssb_chipco_gpio";
  904. + chip->owner = THIS_MODULE;
  905. + chip->request = ssb_gpio_chipco_request;
  906. + chip->free = ssb_gpio_chipco_free;
  907. + chip->get = ssb_gpio_chipco_get_value;
  908. + chip->set = ssb_gpio_chipco_set_value;
  909. + chip->direction_input = ssb_gpio_chipco_direction_input;
  910. + chip->direction_output = ssb_gpio_chipco_direction_output;
  911. + chip->to_irq = ssb_gpio_chipco_to_irq;
  912. + chip->ngpio = 16;
  913. + /* There is just one SoC in one device and its GPIO addresses should be
  914. + * deterministic to address them more easily. The other buses could get
  915. + * a random base number. */
  916. + if (bus->bustype == SSB_BUSTYPE_SSB)
  917. + chip->base = 0;
  918. + else
  919. + chip->base = -1;
  920. +
  921. + return gpiochip_add(chip);
  922. +}
  923. +
  924. +#ifdef CONFIG_SSB_DRIVER_EXTIF
  925. +
  926. +static int ssb_gpio_extif_get_value(struct gpio_chip *chip, unsigned gpio)
  927. +{
  928. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  929. +
  930. + return !!ssb_extif_gpio_in(&bus->extif, 1 << gpio);
  931. +}
  932. +
  933. +static void ssb_gpio_extif_set_value(struct gpio_chip *chip, unsigned gpio,
  934. + int value)
  935. +{
  936. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  937. +
  938. + ssb_extif_gpio_out(&bus->extif, 1 << gpio, value ? 1 << gpio : 0);
  939. +}
  940. +
  941. +static int ssb_gpio_extif_direction_input(struct gpio_chip *chip,
  942. + unsigned gpio)
  943. +{
  944. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  945. +
  946. + ssb_extif_gpio_outen(&bus->extif, 1 << gpio, 0);
  947. + return 0;
  948. +}
  949. +
  950. +static int ssb_gpio_extif_direction_output(struct gpio_chip *chip,
  951. + unsigned gpio, int value)
  952. +{
  953. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  954. +
  955. + ssb_extif_gpio_outen(&bus->extif, 1 << gpio, 1 << gpio);
  956. + ssb_extif_gpio_out(&bus->extif, 1 << gpio, value ? 1 << gpio : 0);
  957. + return 0;
  958. +}
  959. +
  960. +static int ssb_gpio_extif_to_irq(struct gpio_chip *chip, unsigned gpio)
  961. +{
  962. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  963. +
  964. + if (bus->bustype == SSB_BUSTYPE_SSB)
  965. + return ssb_mips_irq(bus->extif.dev) + 2;
  966. + else
  967. + return -EINVAL;
  968. +}
  969. +
  970. +static int ssb_gpio_extif_init(struct ssb_bus *bus)
  971. +{
  972. + struct gpio_chip *chip = &bus->gpio;
  973. +
  974. + chip->label = "ssb_extif_gpio";
  975. + chip->owner = THIS_MODULE;
  976. + chip->get = ssb_gpio_extif_get_value;
  977. + chip->set = ssb_gpio_extif_set_value;
  978. + chip->direction_input = ssb_gpio_extif_direction_input;
  979. + chip->direction_output = ssb_gpio_extif_direction_output;
  980. + chip->to_irq = ssb_gpio_extif_to_irq;
  981. + chip->ngpio = 5;
  982. + /* There is just one SoC in one device and its GPIO addresses should be
  983. + * deterministic to address them more easily. The other buses could get
  984. + * a random base number. */
  985. + if (bus->bustype == SSB_BUSTYPE_SSB)
  986. + chip->base = 0;
  987. + else
  988. + chip->base = -1;
  989. +
  990. + return gpiochip_add(chip);
  991. +}
  992. +
  993. +#else
  994. +static int ssb_gpio_extif_init(struct ssb_bus *bus)
  995. +{
  996. + return -ENOTSUPP;
  997. +}
  998. +#endif
  999. +
  1000. +int ssb_gpio_init(struct ssb_bus *bus)
  1001. +{
  1002. + if (ssb_chipco_available(&bus->chipco))
  1003. + return ssb_gpio_chipco_init(bus);
  1004. + else if (ssb_extif_available(&bus->extif))
  1005. + return ssb_gpio_extif_init(bus);
  1006. + else
  1007. + SSB_WARN_ON(1);
  1008. +
  1009. + return -1;
  1010. +}
  1011. +
  1012. +int ssb_gpio_unregister(struct ssb_bus *bus)
  1013. +{
  1014. + if (ssb_chipco_available(&bus->chipco) ||
  1015. + ssb_extif_available(&bus->extif)) {
  1016. + return gpiochip_remove(&bus->gpio);
  1017. + } else {
  1018. + SSB_WARN_ON(1);
  1019. + }
  1020. +
  1021. + return -1;
  1022. +}
  1023. --- a/drivers/ssb/driver_mipscore.c
  1024. +++ b/drivers/ssb/driver_mipscore.c
  1025. @@ -10,6 +10,7 @@
  1026. #include <linux/ssb/ssb.h>
  1027. +#include <linux/mtd/physmap.h>
  1028. #include <linux/serial.h>
  1029. #include <linux/serial_core.h>
  1030. #include <linux/serial_reg.h>
  1031. @@ -17,6 +18,25 @@
  1032. #include "ssb_private.h"
  1033. +static const char * const part_probes[] = { "bcm47xxpart", NULL };
  1034. +
  1035. +static struct physmap_flash_data ssb_pflash_data = {
  1036. + .part_probe_types = part_probes,
  1037. +};
  1038. +
  1039. +static struct resource ssb_pflash_resource = {
  1040. + .name = "ssb_pflash",
  1041. + .flags = IORESOURCE_MEM,
  1042. +};
  1043. +
  1044. +struct platform_device ssb_pflash_dev = {
  1045. + .name = "physmap-flash",
  1046. + .dev = {
  1047. + .platform_data = &ssb_pflash_data,
  1048. + },
  1049. + .resource = &ssb_pflash_resource,
  1050. + .num_resources = 1,
  1051. +};
  1052. static inline u32 mips_read32(struct ssb_mipscore *mcore,
  1053. u16 offset)
  1054. @@ -147,21 +167,22 @@ static void set_irq(struct ssb_device *d
  1055. irqflag |= (ipsflag & ~ipsflag_irq_mask[irq]);
  1056. ssb_write32(mdev, SSB_IPSFLAG, irqflag);
  1057. }
  1058. - ssb_dprintk(KERN_INFO PFX
  1059. - "set_irq: core 0x%04x, irq %d => %d\n",
  1060. - dev->id.coreid, oldirq+2, irq+2);
  1061. + ssb_dbg("set_irq: core 0x%04x, irq %d => %d\n",
  1062. + dev->id.coreid, oldirq+2, irq+2);
  1063. }
  1064. static void print_irq(struct ssb_device *dev, unsigned int irq)
  1065. {
  1066. - int i;
  1067. static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
  1068. - ssb_dprintk(KERN_INFO PFX
  1069. - "core 0x%04x, irq :", dev->id.coreid);
  1070. - for (i = 0; i <= 6; i++) {
  1071. - ssb_dprintk(" %s%s", irq_name[i], i==irq?"*":" ");
  1072. - }
  1073. - ssb_dprintk("\n");
  1074. + ssb_dbg("core 0x%04x, irq : %s%s %s%s %s%s %s%s %s%s %s%s %s%s\n",
  1075. + dev->id.coreid,
  1076. + irq_name[0], irq == 0 ? "*" : " ",
  1077. + irq_name[1], irq == 1 ? "*" : " ",
  1078. + irq_name[2], irq == 2 ? "*" : " ",
  1079. + irq_name[3], irq == 3 ? "*" : " ",
  1080. + irq_name[4], irq == 4 ? "*" : " ",
  1081. + irq_name[5], irq == 5 ? "*" : " ",
  1082. + irq_name[6], irq == 6 ? "*" : " ");
  1083. }
  1084. static void dump_irq(struct ssb_bus *bus)
  1085. @@ -178,9 +199,9 @@ static void ssb_mips_serial_init(struct
  1086. {
  1087. struct ssb_bus *bus = mcore->dev->bus;
  1088. - if (bus->extif.dev)
  1089. + if (ssb_extif_available(&bus->extif))
  1090. mcore->nr_serial_ports = ssb_extif_serial_init(&bus->extif, mcore->serial_ports);
  1091. - else if (bus->chipco.dev)
  1092. + else if (ssb_chipco_available(&bus->chipco))
  1093. mcore->nr_serial_ports = ssb_chipco_serial_init(&bus->chipco, mcore->serial_ports);
  1094. else
  1095. mcore->nr_serial_ports = 0;
  1096. @@ -189,17 +210,42 @@ static void ssb_mips_serial_init(struct
  1097. static void ssb_mips_flash_detect(struct ssb_mipscore *mcore)
  1098. {
  1099. struct ssb_bus *bus = mcore->dev->bus;
  1100. + struct ssb_pflash *pflash = &mcore->pflash;
  1101. - mcore->flash_buswidth = 2;
  1102. - if (bus->chipco.dev) {
  1103. - mcore->flash_window = 0x1c000000;
  1104. - mcore->flash_window_size = 0x02000000;
  1105. + /* When there is no chipcommon on the bus there is 4MB flash */
  1106. + if (!ssb_chipco_available(&bus->chipco)) {
  1107. + pflash->present = true;
  1108. + pflash->buswidth = 2;
  1109. + pflash->window = SSB_FLASH1;
  1110. + pflash->window_size = SSB_FLASH1_SZ;
  1111. + goto ssb_pflash;
  1112. + }
  1113. +
  1114. + /* There is ChipCommon, so use it to read info about flash */
  1115. + switch (bus->chipco.capabilities & SSB_CHIPCO_CAP_FLASHT) {
  1116. + case SSB_CHIPCO_FLASHT_STSER:
  1117. + case SSB_CHIPCO_FLASHT_ATSER:
  1118. + pr_debug("Found serial flash\n");
  1119. + ssb_sflash_init(&bus->chipco);
  1120. + break;
  1121. + case SSB_CHIPCO_FLASHT_PARA:
  1122. + pr_debug("Found parallel flash\n");
  1123. + pflash->present = true;
  1124. + pflash->window = SSB_FLASH2;
  1125. + pflash->window_size = SSB_FLASH2_SZ;
  1126. if ((ssb_read32(bus->chipco.dev, SSB_CHIPCO_FLASH_CFG)
  1127. & SSB_CHIPCO_CFG_DS16) == 0)
  1128. - mcore->flash_buswidth = 1;
  1129. - } else {
  1130. - mcore->flash_window = 0x1fc00000;
  1131. - mcore->flash_window_size = 0x00400000;
  1132. + pflash->buswidth = 1;
  1133. + else
  1134. + pflash->buswidth = 2;
  1135. + break;
  1136. + }
  1137. +
  1138. +ssb_pflash:
  1139. + if (pflash->present) {
  1140. + ssb_pflash_data.width = pflash->buswidth;
  1141. + ssb_pflash_resource.start = pflash->window;
  1142. + ssb_pflash_resource.end = pflash->window + pflash->window_size;
  1143. }
  1144. }
  1145. @@ -208,9 +254,12 @@ u32 ssb_cpu_clock(struct ssb_mipscore *m
  1146. struct ssb_bus *bus = mcore->dev->bus;
  1147. u32 pll_type, n, m, rate = 0;
  1148. - if (bus->extif.dev) {
  1149. + if (bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU)
  1150. + return ssb_pmu_get_cpu_clock(&bus->chipco);
  1151. +
  1152. + if (ssb_extif_available(&bus->extif)) {
  1153. ssb_extif_get_clockcontrol(&bus->extif, &pll_type, &n, &m);
  1154. - } else if (bus->chipco.dev) {
  1155. + } else if (ssb_chipco_available(&bus->chipco)) {
  1156. ssb_chipco_get_clockcpu(&bus->chipco, &pll_type, &n, &m);
  1157. } else
  1158. return 0;
  1159. @@ -238,7 +287,7 @@ void ssb_mipscore_init(struct ssb_mipsco
  1160. if (!mcore->dev)
  1161. return; /* We don't have a MIPS core */
  1162. - ssb_dprintk(KERN_INFO PFX "Initializing MIPS core...\n");
  1163. + ssb_dbg("Initializing MIPS core...\n");
  1164. bus = mcore->dev->bus;
  1165. hz = ssb_clockspeed(bus);
  1166. @@ -246,9 +295,9 @@ void ssb_mipscore_init(struct ssb_mipsco
  1167. hz = 100000000;
  1168. ns = 1000000000 / hz;
  1169. - if (bus->extif.dev)
  1170. + if (ssb_extif_available(&bus->extif))
  1171. ssb_extif_timing_init(&bus->extif, ns);
  1172. - else if (bus->chipco.dev)
  1173. + else if (ssb_chipco_available(&bus->chipco))
  1174. ssb_chipco_timing_init(&bus->chipco, ns);
  1175. /* Assign IRQs to all cores on the bus, start with irq line 2, because serial usually takes 1 */
  1176. @@ -286,7 +335,7 @@ void ssb_mipscore_init(struct ssb_mipsco
  1177. break;
  1178. }
  1179. }
  1180. - ssb_dprintk(KERN_INFO PFX "after irq reconfiguration\n");
  1181. + ssb_dbg("after irq reconfiguration\n");
  1182. dump_irq(bus);
  1183. ssb_mips_serial_init(mcore);
  1184. --- a/drivers/ssb/driver_pcicore.c
  1185. +++ b/drivers/ssb/driver_pcicore.c
  1186. @@ -263,8 +263,7 @@ int ssb_pcicore_plat_dev_init(struct pci
  1187. return -ENODEV;
  1188. }
  1189. - ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
  1190. - pci_name(d));
  1191. + ssb_info("PCI: Fixing up device %s\n", pci_name(d));
  1192. /* Fix up interrupt lines */
  1193. d->irq = ssb_mips_irq(extpci_core->dev) + 2;
  1194. @@ -285,12 +284,12 @@ static void ssb_pcicore_fixup_pcibridge(
  1195. if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0)
  1196. return;
  1197. - ssb_printk(KERN_INFO "PCI: Fixing up bridge %s\n", pci_name(dev));
  1198. + ssb_info("PCI: Fixing up bridge %s\n", pci_name(dev));
  1199. /* Enable PCI bridge bus mastering and memory space */
  1200. pci_set_master(dev);
  1201. if (pcibios_enable_device(dev, ~0) < 0) {
  1202. - ssb_printk(KERN_ERR "PCI: SSB bridge enable failed\n");
  1203. + ssb_err("PCI: SSB bridge enable failed\n");
  1204. return;
  1205. }
  1206. @@ -299,8 +298,8 @@ static void ssb_pcicore_fixup_pcibridge(
  1207. /* Make sure our latency is high enough to handle the devices behind us */
  1208. lat = 168;
  1209. - ssb_printk(KERN_INFO "PCI: Fixing latency timer of device %s to %u\n",
  1210. - pci_name(dev), lat);
  1211. + ssb_info("PCI: Fixing latency timer of device %s to %u\n",
  1212. + pci_name(dev), lat);
  1213. pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
  1214. }
  1215. DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ssb_pcicore_fixup_pcibridge);
  1216. @@ -323,7 +322,7 @@ static void __devinit ssb_pcicore_init_h
  1217. return;
  1218. extpci_core = pc;
  1219. - ssb_dprintk(KERN_INFO PFX "PCIcore in host mode found\n");
  1220. + ssb_dbg("PCIcore in host mode found\n");
  1221. /* Reset devices on the external PCI bus */
  1222. val = SSB_PCICORE_CTL_RST_OE;
  1223. val |= SSB_PCICORE_CTL_CLK_OE;
  1224. @@ -338,7 +337,7 @@ static void __devinit ssb_pcicore_init_h
  1225. udelay(1); /* Assertion time demanded by the PCI standard */
  1226. if (pc->dev->bus->has_cardbus_slot) {
  1227. - ssb_dprintk(KERN_INFO PFX "CardBus slot detected\n");
  1228. + ssb_dbg("CardBus slot detected\n");
  1229. pc->cardbusmode = 1;
  1230. /* GPIO 1 resets the bridge */
  1231. ssb_gpio_out(pc->dev->bus, 1, 1);
  1232. --- a/drivers/ssb/embedded.c
  1233. +++ b/drivers/ssb/embedded.c
  1234. @@ -4,11 +4,13 @@
  1235. *
  1236. * Copyright 2005-2008, Broadcom Corporation
  1237. * Copyright 2006-2008, Michael Buesch <m@bues.ch>
  1238. + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
  1239. *
  1240. * Licensed under the GNU/GPL. See COPYING for details.
  1241. */
  1242. #include <linux/export.h>
  1243. +#include <linux/platform_device.h>
  1244. #include <linux/ssb/ssb.h>
  1245. #include <linux/ssb/ssb_embedded.h>
  1246. #include <linux/ssb/ssb_driver_pci.h>
  1247. @@ -32,6 +34,38 @@ int ssb_watchdog_timer_set(struct ssb_bu
  1248. }
  1249. EXPORT_SYMBOL(ssb_watchdog_timer_set);
  1250. +int ssb_watchdog_register(struct ssb_bus *bus)
  1251. +{
  1252. + struct bcm47xx_wdt wdt = {};
  1253. + struct platform_device *pdev;
  1254. +
  1255. + if (ssb_chipco_available(&bus->chipco)) {
  1256. + wdt.driver_data = &bus->chipco;
  1257. + wdt.timer_set = ssb_chipco_watchdog_timer_set_wdt;
  1258. + wdt.timer_set_ms = ssb_chipco_watchdog_timer_set_ms;
  1259. + wdt.max_timer_ms = bus->chipco.max_timer_ms;
  1260. + } else if (ssb_extif_available(&bus->extif)) {
  1261. + wdt.driver_data = &bus->extif;
  1262. + wdt.timer_set = ssb_extif_watchdog_timer_set_wdt;
  1263. + wdt.timer_set_ms = ssb_extif_watchdog_timer_set_ms;
  1264. + wdt.max_timer_ms = SSB_EXTIF_WATCHDOG_MAX_TIMER_MS;
  1265. + } else {
  1266. + return -ENODEV;
  1267. + }
  1268. +
  1269. + pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
  1270. + bus->busnumber, &wdt,
  1271. + sizeof(wdt));
  1272. + if (IS_ERR(pdev)) {
  1273. + ssb_dbg("can not register watchdog device, err: %li\n",
  1274. + PTR_ERR(pdev));
  1275. + return PTR_ERR(pdev);
  1276. + }
  1277. +
  1278. + bus->watchdog = pdev;
  1279. + return 0;
  1280. +}
  1281. +
  1282. u32 ssb_gpio_in(struct ssb_bus *bus, u32 mask)
  1283. {
  1284. unsigned long flags;
  1285. --- a/drivers/ssb/main.c
  1286. +++ b/drivers/ssb/main.c
  1287. @@ -13,6 +13,7 @@
  1288. #include <linux/delay.h>
  1289. #include <linux/io.h>
  1290. #include <linux/module.h>
  1291. +#include <linux/platform_device.h>
  1292. #include <linux/ssb/ssb.h>
  1293. #include <linux/ssb/ssb_regs.h>
  1294. #include <linux/ssb/ssb_driver_gige.h>
  1295. @@ -289,8 +290,8 @@ int ssb_devices_thaw(struct ssb_freeze_c
  1296. err = sdrv->probe(sdev, &sdev->id);
  1297. if (err) {
  1298. - ssb_printk(KERN_ERR PFX "Failed to thaw device %s\n",
  1299. - dev_name(sdev->dev));
  1300. + ssb_err("Failed to thaw device %s\n",
  1301. + dev_name(sdev->dev));
  1302. result = err;
  1303. }
  1304. ssb_driver_put(sdrv);
  1305. @@ -449,10 +450,23 @@ static void ssb_devices_unregister(struc
  1306. if (sdev->dev)
  1307. device_unregister(sdev->dev);
  1308. }
  1309. +
  1310. +#ifdef CONFIG_SSB_EMBEDDED
  1311. + if (bus->bustype == SSB_BUSTYPE_SSB)
  1312. + platform_device_unregister(bus->watchdog);
  1313. +#endif
  1314. }
  1315. void ssb_bus_unregister(struct ssb_bus *bus)
  1316. {
  1317. + int err;
  1318. +
  1319. + err = ssb_gpio_unregister(bus);
  1320. + if (err == -EBUSY)
  1321. + ssb_dbg("Some GPIOs are still in use\n");
  1322. + else if (err)
  1323. + ssb_dbg("Can not unregister GPIO driver: %i\n", err);
  1324. +
  1325. ssb_buses_lock();
  1326. ssb_devices_unregister(bus);
  1327. list_del(&bus->list);
  1328. @@ -498,8 +512,7 @@ static int ssb_devices_register(struct s
  1329. devwrap = kzalloc(sizeof(*devwrap), GFP_KERNEL);
  1330. if (!devwrap) {
  1331. - ssb_printk(KERN_ERR PFX
  1332. - "Could not allocate device\n");
  1333. + ssb_err("Could not allocate device\n");
  1334. err = -ENOMEM;
  1335. goto error;
  1336. }
  1337. @@ -538,9 +551,7 @@ static int ssb_devices_register(struct s
  1338. sdev->dev = dev;
  1339. err = device_register(dev);
  1340. if (err) {
  1341. - ssb_printk(KERN_ERR PFX
  1342. - "Could not register %s\n",
  1343. - dev_name(dev));
  1344. + ssb_err("Could not register %s\n", dev_name(dev));
  1345. /* Set dev to NULL to not unregister
  1346. * dev on error unwinding. */
  1347. sdev->dev = NULL;
  1348. @@ -550,6 +561,22 @@ static int ssb_devices_register(struct s
  1349. dev_idx++;
  1350. }
  1351. +#ifdef CONFIG_SSB_DRIVER_MIPS
  1352. + if (bus->mipscore.pflash.present) {
  1353. + err = platform_device_register(&ssb_pflash_dev);
  1354. + if (err)
  1355. + pr_err("Error registering parallel flash\n");
  1356. + }
  1357. +#endif
  1358. +
  1359. +#ifdef CONFIG_SSB_SFLASH
  1360. + if (bus->mipscore.sflash.present) {
  1361. + err = platform_device_register(&ssb_sflash_dev);
  1362. + if (err)
  1363. + pr_err("Error registering serial flash\n");
  1364. + }
  1365. +#endif
  1366. +
  1367. return 0;
  1368. error:
  1369. /* Unwind the already registered devices. */
  1370. @@ -577,6 +604,8 @@ static int __devinit ssb_attach_queued_b
  1371. if (err)
  1372. goto error;
  1373. ssb_pcicore_init(&bus->pcicore);
  1374. + if (bus->bustype == SSB_BUSTYPE_SSB)
  1375. + ssb_watchdog_register(bus);
  1376. ssb_bus_may_powerdown(bus);
  1377. err = ssb_devices_register(bus);
  1378. @@ -812,7 +841,13 @@ static int __devinit ssb_bus_register(st
  1379. if (err)
  1380. goto err_pcmcia_exit;
  1381. ssb_chipcommon_init(&bus->chipco);
  1382. + ssb_extif_init(&bus->extif);
  1383. ssb_mipscore_init(&bus->mipscore);
  1384. + err = ssb_gpio_init(bus);
  1385. + if (err == -ENOTSUPP)
  1386. + ssb_dbg("GPIO driver not activated\n");
  1387. + else if (err)
  1388. + ssb_dbg("Error registering GPIO driver: %i\n", err);
  1389. err = ssb_fetch_invariants(bus, get_invariants);
  1390. if (err) {
  1391. ssb_bus_may_powerdown(bus);
  1392. @@ -863,11 +898,11 @@ int __devinit ssb_bus_pcibus_register(st
  1393. err = ssb_bus_register(bus, ssb_pci_get_invariants, 0);
  1394. if (!err) {
  1395. - ssb_printk(KERN_INFO PFX "Sonics Silicon Backplane found on "
  1396. - "PCI device %s\n", dev_name(&host_pci->dev));
  1397. + ssb_info("Sonics Silicon Backplane found on PCI device %s\n",
  1398. + dev_name(&host_pci->dev));
  1399. } else {
  1400. - ssb_printk(KERN_ERR PFX "Failed to register PCI version"
  1401. - " of SSB with error %d\n", err);
  1402. + ssb_err("Failed to register PCI version of SSB with error %d\n",
  1403. + err);
  1404. }
  1405. return err;
  1406. @@ -888,8 +923,8 @@ int __devinit ssb_bus_pcmciabus_register
  1407. err = ssb_bus_register(bus, ssb_pcmcia_get_invariants, baseaddr);
  1408. if (!err) {
  1409. - ssb_printk(KERN_INFO PFX "Sonics Silicon Backplane found on "
  1410. - "PCMCIA device %s\n", pcmcia_dev->devname);
  1411. + ssb_info("Sonics Silicon Backplane found on PCMCIA device %s\n",
  1412. + pcmcia_dev->devname);
  1413. }
  1414. return err;
  1415. @@ -911,8 +946,8 @@ int __devinit ssb_bus_sdiobus_register(s
  1416. err = ssb_bus_register(bus, ssb_sdio_get_invariants, ~0);
  1417. if (!err) {
  1418. - ssb_printk(KERN_INFO PFX "Sonics Silicon Backplane found on "
  1419. - "SDIO device %s\n", sdio_func_id(func));
  1420. + ssb_info("Sonics Silicon Backplane found on SDIO device %s\n",
  1421. + sdio_func_id(func));
  1422. }
  1423. return err;
  1424. @@ -931,8 +966,8 @@ int __devinit ssb_bus_ssbbus_register(st
  1425. err = ssb_bus_register(bus, get_invariants, baseaddr);
  1426. if (!err) {
  1427. - ssb_printk(KERN_INFO PFX "Sonics Silicon Backplane found at "
  1428. - "address 0x%08lX\n", baseaddr);
  1429. + ssb_info("Sonics Silicon Backplane found at address 0x%08lX\n",
  1430. + baseaddr);
  1431. }
  1432. return err;
  1433. @@ -1094,6 +1129,9 @@ u32 ssb_clockspeed(struct ssb_bus *bus)
  1434. u32 plltype;
  1435. u32 clkctl_n, clkctl_m;
  1436. + if (bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU)
  1437. + return ssb_pmu_get_controlclock(&bus->chipco);
  1438. +
  1439. if (ssb_extif_available(&bus->extif))
  1440. ssb_extif_get_clockcontrol(&bus->extif, &plltype,
  1441. &clkctl_n, &clkctl_m);
  1442. @@ -1131,8 +1169,7 @@ static u32 ssb_tmslow_reject_bitmask(str
  1443. case SSB_IDLOW_SSBREV_27: /* same here */
  1444. return SSB_TMSLOW_REJECT; /* this is a guess */
  1445. default:
  1446. - printk(KERN_INFO "ssb: Backplane Revision 0x%.8X\n", rev);
  1447. - WARN_ON(1);
  1448. + WARN(1, KERN_INFO "ssb: Backplane Revision 0x%.8X\n", rev);
  1449. }
  1450. return (SSB_TMSLOW_REJECT | SSB_TMSLOW_REJECT_23);
  1451. }
  1452. @@ -1324,7 +1361,7 @@ out:
  1453. #endif
  1454. return err;
  1455. error:
  1456. - ssb_printk(KERN_ERR PFX "Bus powerdown failed\n");
  1457. + ssb_err("Bus powerdown failed\n");
  1458. goto out;
  1459. }
  1460. EXPORT_SYMBOL(ssb_bus_may_powerdown);
  1461. @@ -1347,7 +1384,7 @@ int ssb_bus_powerup(struct ssb_bus *bus,
  1462. return 0;
  1463. error:
  1464. - ssb_printk(KERN_ERR PFX "Bus powerup failed\n");
  1465. + ssb_err("Bus powerup failed\n");
  1466. return err;
  1467. }
  1468. EXPORT_SYMBOL(ssb_bus_powerup);
  1469. @@ -1455,15 +1492,13 @@ static int __init ssb_modinit(void)
  1470. err = b43_pci_ssb_bridge_init();
  1471. if (err) {
  1472. - ssb_printk(KERN_ERR "Broadcom 43xx PCI-SSB-bridge "
  1473. - "initialization failed\n");
  1474. + ssb_err("Broadcom 43xx PCI-SSB-bridge initialization failed\n");
  1475. /* don't fail SSB init because of this */
  1476. err = 0;
  1477. }
  1478. err = ssb_gige_init();
  1479. if (err) {
  1480. - ssb_printk(KERN_ERR "SSB Broadcom Gigabit Ethernet "
  1481. - "driver initialization failed\n");
  1482. + ssb_err("SSB Broadcom Gigabit Ethernet driver initialization failed\n");
  1483. /* don't fail SSB init because of this */
  1484. err = 0;
  1485. }
  1486. --- a/drivers/ssb/pci.c
  1487. +++ b/drivers/ssb/pci.c
  1488. @@ -56,7 +56,7 @@ int ssb_pci_switch_coreidx(struct ssb_bu
  1489. }
  1490. return 0;
  1491. error:
  1492. - ssb_printk(KERN_ERR PFX "Failed to switch to core %u\n", coreidx);
  1493. + ssb_err("Failed to switch to core %u\n", coreidx);
  1494. return -ENODEV;
  1495. }
  1496. @@ -67,10 +67,9 @@ int ssb_pci_switch_core(struct ssb_bus *
  1497. unsigned long flags;
  1498. #if SSB_VERBOSE_PCICORESWITCH_DEBUG
  1499. - ssb_printk(KERN_INFO PFX
  1500. - "Switching to %s core, index %d\n",
  1501. - ssb_core_name(dev->id.coreid),
  1502. - dev->core_index);
  1503. + ssb_info("Switching to %s core, index %d\n",
  1504. + ssb_core_name(dev->id.coreid),
  1505. + dev->core_index);
  1506. #endif
  1507. spin_lock_irqsave(&bus->bar_lock, flags);
  1508. @@ -178,6 +177,18 @@ err_pci:
  1509. #define SPEX(_outvar, _offset, _mask, _shift) \
  1510. SPEX16(_outvar, _offset, _mask, _shift)
  1511. +#define SPEX_ARRAY8(_field, _offset, _mask, _shift) \
  1512. + do { \
  1513. + SPEX(_field[0], _offset + 0, _mask, _shift); \
  1514. + SPEX(_field[1], _offset + 2, _mask, _shift); \
  1515. + SPEX(_field[2], _offset + 4, _mask, _shift); \
  1516. + SPEX(_field[3], _offset + 6, _mask, _shift); \
  1517. + SPEX(_field[4], _offset + 8, _mask, _shift); \
  1518. + SPEX(_field[5], _offset + 10, _mask, _shift); \
  1519. + SPEX(_field[6], _offset + 12, _mask, _shift); \
  1520. + SPEX(_field[7], _offset + 14, _mask, _shift); \
  1521. + } while (0)
  1522. +
  1523. static inline u8 ssb_crc8(u8 crc, u8 data)
  1524. {
  1525. @@ -219,6 +230,15 @@ static inline u8 ssb_crc8(u8 crc, u8 dat
  1526. return t[crc ^ data];
  1527. }
  1528. +static void sprom_get_mac(char *mac, const u16 *in)
  1529. +{
  1530. + int i;
  1531. + for (i = 0; i < 3; i++) {
  1532. + *mac++ = in[i] >> 8;
  1533. + *mac++ = in[i];
  1534. + }
  1535. +}
  1536. +
  1537. static u8 ssb_sprom_crc(const u16 *sprom, u16 size)
  1538. {
  1539. int word;
  1540. @@ -266,7 +286,7 @@ static int sprom_do_write(struct ssb_bus
  1541. u32 spromctl;
  1542. u16 size = bus->sprom_size;
  1543. - ssb_printk(KERN_NOTICE PFX "Writing SPROM. Do NOT turn off the power! Please stand by...\n");
  1544. + ssb_notice("Writing SPROM. Do NOT turn off the power! Please stand by...\n");
  1545. err = pci_read_config_dword(pdev, SSB_SPROMCTL, &spromctl);
  1546. if (err)
  1547. goto err_ctlreg;
  1548. @@ -274,17 +294,17 @@ static int sprom_do_write(struct ssb_bus
  1549. err = pci_write_config_dword(pdev, SSB_SPROMCTL, spromctl);
  1550. if (err)
  1551. goto err_ctlreg;
  1552. - ssb_printk(KERN_NOTICE PFX "[ 0%%");
  1553. + ssb_notice("[ 0%%");
  1554. msleep(500);
  1555. for (i = 0; i < size; i++) {
  1556. if (i == size / 4)
  1557. - ssb_printk("25%%");
  1558. + ssb_cont("25%%");
  1559. else if (i == size / 2)
  1560. - ssb_printk("50%%");
  1561. + ssb_cont("50%%");
  1562. else if (i == (size * 3) / 4)
  1563. - ssb_printk("75%%");
  1564. + ssb_cont("75%%");
  1565. else if (i % 2)
  1566. - ssb_printk(".");
  1567. + ssb_cont(".");
  1568. writew(sprom[i], bus->mmio + bus->sprom_offset + (i * 2));
  1569. mmiowb();
  1570. msleep(20);
  1571. @@ -297,12 +317,12 @@ static int sprom_do_write(struct ssb_bus
  1572. if (err)
  1573. goto err_ctlreg;
  1574. msleep(500);
  1575. - ssb_printk("100%% ]\n");
  1576. - ssb_printk(KERN_NOTICE PFX "SPROM written.\n");
  1577. + ssb_cont("100%% ]\n");
  1578. + ssb_notice("SPROM written\n");
  1579. return 0;
  1580. err_ctlreg:
  1581. - ssb_printk(KERN_ERR PFX "Could not access SPROM control register.\n");
  1582. + ssb_err("Could not access SPROM control register.\n");
  1583. return err;
  1584. }
  1585. @@ -327,11 +347,23 @@ static s8 r123_extract_antgain(u8 sprom_
  1586. return (s8)gain;
  1587. }
  1588. +static void sprom_extract_r23(struct ssb_sprom *out, const u16 *in)
  1589. +{
  1590. + SPEX(boardflags_hi, SSB_SPROM2_BFLHI, 0xFFFF, 0);
  1591. + SPEX(opo, SSB_SPROM2_OPO, SSB_SPROM2_OPO_VALUE, 0);
  1592. + SPEX(pa1lob0, SSB_SPROM2_PA1LOB0, 0xFFFF, 0);
  1593. + SPEX(pa1lob1, SSB_SPROM2_PA1LOB1, 0xFFFF, 0);
  1594. + SPEX(pa1lob2, SSB_SPROM2_PA1LOB2, 0xFFFF, 0);
  1595. + SPEX(pa1hib0, SSB_SPROM2_PA1HIB0, 0xFFFF, 0);
  1596. + SPEX(pa1hib1, SSB_SPROM2_PA1HIB1, 0xFFFF, 0);
  1597. + SPEX(pa1hib2, SSB_SPROM2_PA1HIB2, 0xFFFF, 0);
  1598. + SPEX(maxpwr_ah, SSB_SPROM2_MAXP_A, SSB_SPROM2_MAXP_A_HI, 0);
  1599. + SPEX(maxpwr_al, SSB_SPROM2_MAXP_A, SSB_SPROM2_MAXP_A_LO,
  1600. + SSB_SPROM2_MAXP_A_LO_SHIFT);
  1601. +}
  1602. +
  1603. static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in)
  1604. {
  1605. - int i;
  1606. - u16 v;
  1607. - s8 gain;
  1608. u16 loc[3];
  1609. if (out->revision == 3) /* rev 3 moved MAC */
  1610. @@ -341,19 +373,10 @@ static void sprom_extract_r123(struct ss
  1611. loc[1] = SSB_SPROM1_ET0MAC;
  1612. loc[2] = SSB_SPROM1_ET1MAC;
  1613. }
  1614. - for (i = 0; i < 3; i++) {
  1615. - v = in[SPOFF(loc[0]) + i];
  1616. - *(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
  1617. - }
  1618. + sprom_get_mac(out->il0mac, &in[SPOFF(loc[0])]);
  1619. if (out->revision < 3) { /* only rev 1-2 have et0, et1 */
  1620. - for (i = 0; i < 3; i++) {
  1621. - v = in[SPOFF(loc[1]) + i];
  1622. - *(((__be16 *)out->et0mac) + i) = cpu_to_be16(v);
  1623. - }
  1624. - for (i = 0; i < 3; i++) {
  1625. - v = in[SPOFF(loc[2]) + i];
  1626. - *(((__be16 *)out->et1mac) + i) = cpu_to_be16(v);
  1627. - }
  1628. + sprom_get_mac(out->et0mac, &in[SPOFF(loc[1])]);
  1629. + sprom_get_mac(out->et1mac, &in[SPOFF(loc[2])]);
  1630. }
  1631. SPEX(et0phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0A, 0);
  1632. SPEX(et1phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1A,
  1633. @@ -361,8 +384,10 @@ static void sprom_extract_r123(struct ss
  1634. SPEX(et0mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0M, 14);
  1635. SPEX(et1mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1M, 15);
  1636. SPEX(board_rev, SSB_SPROM1_BINF, SSB_SPROM1_BINF_BREV, 0);
  1637. - SPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE,
  1638. - SSB_SPROM1_BINF_CCODE_SHIFT);
  1639. + SPEX(board_type, SSB_SPROM1_SPID, 0xFFFF, 0);
  1640. + if (out->revision == 1)
  1641. + SPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE,
  1642. + SSB_SPROM1_BINF_CCODE_SHIFT);
  1643. SPEX(ant_available_a, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTA,
  1644. SSB_SPROM1_BINF_ANTA_SHIFT);
  1645. SPEX(ant_available_bg, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTBG,
  1646. @@ -386,24 +411,19 @@ static void sprom_extract_r123(struct ss
  1647. SSB_SPROM1_ITSSI_A_SHIFT);
  1648. SPEX(itssi_bg, SSB_SPROM1_ITSSI, SSB_SPROM1_ITSSI_BG, 0);
  1649. SPEX(boardflags_lo, SSB_SPROM1_BFLLO, 0xFFFF, 0);
  1650. - if (out->revision >= 2)
  1651. - SPEX(boardflags_hi, SSB_SPROM2_BFLHI, 0xFFFF, 0);
  1652. +
  1653. + SPEX(alpha2[0], SSB_SPROM1_CCODE, 0xff00, 8);
  1654. + SPEX(alpha2[1], SSB_SPROM1_CCODE, 0x00ff, 0);
  1655. /* Extract the antenna gain values. */
  1656. - gain = r123_extract_antgain(out->revision, in,
  1657. - SSB_SPROM1_AGAIN_BG,
  1658. - SSB_SPROM1_AGAIN_BG_SHIFT);
  1659. - out->antenna_gain.ghz24.a0 = gain;
  1660. - out->antenna_gain.ghz24.a1 = gain;
  1661. - out->antenna_gain.ghz24.a2 = gain;
  1662. - out->antenna_gain.ghz24.a3 = gain;
  1663. - gain = r123_extract_antgain(out->revision, in,
  1664. - SSB_SPROM1_AGAIN_A,
  1665. - SSB_SPROM1_AGAIN_A_SHIFT);
  1666. - out->antenna_gain.ghz5.a0 = gain;
  1667. - out->antenna_gain.ghz5.a1 = gain;
  1668. - out->antenna_gain.ghz5.a2 = gain;
  1669. - out->antenna_gain.ghz5.a3 = gain;
  1670. + out->antenna_gain.a0 = r123_extract_antgain(out->revision, in,
  1671. + SSB_SPROM1_AGAIN_BG,
  1672. + SSB_SPROM1_AGAIN_BG_SHIFT);
  1673. + out->antenna_gain.a1 = r123_extract_antgain(out->revision, in,
  1674. + SSB_SPROM1_AGAIN_A,
  1675. + SSB_SPROM1_AGAIN_A_SHIFT);
  1676. + if (out->revision >= 2)
  1677. + sprom_extract_r23(out, in);
  1678. }
  1679. /* Revs 4 5 and 8 have partially shared layout */
  1680. @@ -448,30 +468,30 @@ static void sprom_extract_r458(struct ss
  1681. static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
  1682. {
  1683. - int i;
  1684. - u16 v;
  1685. u16 il0mac_offset;
  1686. if (out->revision == 4)
  1687. il0mac_offset = SSB_SPROM4_IL0MAC;
  1688. else
  1689. il0mac_offset = SSB_SPROM5_IL0MAC;
  1690. - /* extract the MAC address */
  1691. - for (i = 0; i < 3; i++) {
  1692. - v = in[SPOFF(il0mac_offset) + i];
  1693. - *(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
  1694. - }
  1695. +
  1696. + sprom_get_mac(out->il0mac, &in[SPOFF(il0mac_offset)]);
  1697. +
  1698. SPEX(et0phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET0A, 0);
  1699. SPEX(et1phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET1A,
  1700. SSB_SPROM4_ETHPHY_ET1A_SHIFT);
  1701. + SPEX(board_rev, SSB_SPROM4_BOARDREV, 0xFFFF, 0);
  1702. + SPEX(board_type, SSB_SPROM1_SPID, 0xFFFF, 0);
  1703. if (out->revision == 4) {
  1704. - SPEX(country_code, SSB_SPROM4_CCODE, 0xFFFF, 0);
  1705. + SPEX(alpha2[0], SSB_SPROM4_CCODE, 0xff00, 8);
  1706. + SPEX(alpha2[1], SSB_SPROM4_CCODE, 0x00ff, 0);
  1707. SPEX(boardflags_lo, SSB_SPROM4_BFLLO, 0xFFFF, 0);
  1708. SPEX(boardflags_hi, SSB_SPROM4_BFLHI, 0xFFFF, 0);
  1709. SPEX(boardflags2_lo, SSB_SPROM4_BFL2LO, 0xFFFF, 0);
  1710. SPEX(boardflags2_hi, SSB_SPROM4_BFL2HI, 0xFFFF, 0);
  1711. } else {
  1712. - SPEX(country_code, SSB_SPROM5_CCODE, 0xFFFF, 0);
  1713. + SPEX(alpha2[0], SSB_SPROM5_CCODE, 0xff00, 8);
  1714. + SPEX(alpha2[1], SSB_SPROM5_CCODE, 0x00ff, 0);
  1715. SPEX(boardflags_lo, SSB_SPROM5_BFLLO, 0xFFFF, 0);
  1716. SPEX(boardflags_hi, SSB_SPROM5_BFLHI, 0xFFFF, 0);
  1717. SPEX(boardflags2_lo, SSB_SPROM5_BFL2LO, 0xFFFF, 0);
  1718. @@ -504,16 +524,14 @@ static void sprom_extract_r45(struct ssb
  1719. }
  1720. /* Extract the antenna gain values. */
  1721. - SPEX(antenna_gain.ghz24.a0, SSB_SPROM4_AGAIN01,
  1722. + SPEX(antenna_gain.a0, SSB_SPROM4_AGAIN01,
  1723. SSB_SPROM4_AGAIN0, SSB_SPROM4_AGAIN0_SHIFT);
  1724. - SPEX(antenna_gain.ghz24.a1, SSB_SPROM4_AGAIN01,
  1725. + SPEX(antenna_gain.a1, SSB_SPROM4_AGAIN01,
  1726. SSB_SPROM4_AGAIN1, SSB_SPROM4_AGAIN1_SHIFT);
  1727. - SPEX(antenna_gain.ghz24.a2, SSB_SPROM4_AGAIN23,
  1728. + SPEX(antenna_gain.a2, SSB_SPROM4_AGAIN23,
  1729. SSB_SPROM4_AGAIN2, SSB_SPROM4_AGAIN2_SHIFT);
  1730. - SPEX(antenna_gain.ghz24.a3, SSB_SPROM4_AGAIN23,
  1731. + SPEX(antenna_gain.a3, SSB_SPROM4_AGAIN23,
  1732. SSB_SPROM4_AGAIN3, SSB_SPROM4_AGAIN3_SHIFT);
  1733. - memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
  1734. - sizeof(out->antenna_gain.ghz5));
  1735. sprom_extract_r458(out, in);
  1736. @@ -523,14 +541,21 @@ static void sprom_extract_r45(struct ssb
  1737. static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in)
  1738. {
  1739. int i;
  1740. - u16 v;
  1741. + u16 o;
  1742. + u16 pwr_info_offset[] = {
  1743. + SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
  1744. + SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
  1745. + };
  1746. + BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
  1747. + ARRAY_SIZE(out->core_pwr_info));
  1748. /* extract the MAC address */
  1749. - for (i = 0; i < 3; i++) {
  1750. - v = in[SPOFF(SSB_SPROM8_IL0MAC) + i];
  1751. - *(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
  1752. - }
  1753. - SPEX(country_code, SSB_SPROM8_CCODE, 0xFFFF, 0);
  1754. + sprom_get_mac(out->il0mac, &in[SPOFF(SSB_SPROM8_IL0MAC)]);
  1755. +
  1756. + SPEX(board_rev, SSB_SPROM8_BOARDREV, 0xFFFF, 0);
  1757. + SPEX(board_type, SSB_SPROM1_SPID, 0xFFFF, 0);
  1758. + SPEX(alpha2[0], SSB_SPROM8_CCODE, 0xff00, 8);
  1759. + SPEX(alpha2[1], SSB_SPROM8_CCODE, 0x00ff, 0);
  1760. SPEX(boardflags_lo, SSB_SPROM8_BFLLO, 0xFFFF, 0);
  1761. SPEX(boardflags_hi, SSB_SPROM8_BFLHI, 0xFFFF, 0);
  1762. SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, 0xFFFF, 0);
  1763. @@ -596,16 +621,46 @@ static void sprom_extract_r8(struct ssb_
  1764. SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, 0xFFFFFFFF, 0);
  1765. /* Extract the antenna gain values. */
  1766. - SPEX(antenna_gain.ghz24.a0, SSB_SPROM8_AGAIN01,
  1767. + SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
  1768. SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
  1769. - SPEX(antenna_gain.ghz24.a1, SSB_SPROM8_AGAIN01,
  1770. + SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
  1771. SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
  1772. - SPEX(antenna_gain.ghz24.a2, SSB_SPROM8_AGAIN23,
  1773. + SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
  1774. SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
  1775. - SPEX(antenna_gain.ghz24.a3, SSB_SPROM8_AGAIN23,
  1776. + SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
  1777. SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
  1778. - memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
  1779. - sizeof(out->antenna_gain.ghz5));
  1780. +
  1781. + /* Extract cores power info info */
  1782. + for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
  1783. + o = pwr_info_offset[i];
  1784. + SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
  1785. + SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT);
  1786. + SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
  1787. + SSB_SPROM8_2G_MAXP, 0);
  1788. +
  1789. + SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0);
  1790. + SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0);
  1791. + SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0);
  1792. +
  1793. + SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
  1794. + SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT);
  1795. + SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
  1796. + SSB_SPROM8_5G_MAXP, 0);
  1797. + SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP,
  1798. + SSB_SPROM8_5GH_MAXP, 0);
  1799. + SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP,
  1800. + SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT);
  1801. +
  1802. + SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0);
  1803. + SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0);
  1804. + SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0);
  1805. + SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0);
  1806. + SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0);
  1807. + SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0);
  1808. + SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0);
  1809. + SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0);
  1810. + SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0);
  1811. + }
  1812. /* Extract FEM info */
  1813. SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G,
  1814. @@ -630,6 +685,63 @@ static void sprom_extract_r8(struct ssb_
  1815. SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G,
  1816. SSB_SROM8_FEM_ANTSWLUT, SSB_SROM8_FEM_ANTSWLUT_SHIFT);
  1817. + SPEX(leddc_on_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_ON,
  1818. + SSB_SPROM8_LEDDC_ON_SHIFT);
  1819. + SPEX(leddc_off_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_OFF,
  1820. + SSB_SPROM8_LEDDC_OFF_SHIFT);
  1821. +
  1822. + SPEX(txchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_TXCHAIN,
  1823. + SSB_SPROM8_TXRXC_TXCHAIN_SHIFT);
  1824. + SPEX(rxchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_RXCHAIN,
  1825. + SSB_SPROM8_TXRXC_RXCHAIN_SHIFT);
  1826. + SPEX(antswitch, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_SWITCH,
  1827. + SSB_SPROM8_TXRXC_SWITCH_SHIFT);
  1828. +
  1829. + SPEX(opo, SSB_SPROM8_OFDM2GPO, 0x00ff, 0);
  1830. +
  1831. + SPEX_ARRAY8(mcs2gpo, SSB_SPROM8_2G_MCSPO, ~0, 0);
  1832. + SPEX_ARRAY8(mcs5gpo, SSB_SPROM8_5G_MCSPO, ~0, 0);
  1833. + SPEX_ARRAY8(mcs5glpo, SSB_SPROM8_5GL_MCSPO, ~0, 0);
  1834. + SPEX_ARRAY8(mcs5ghpo, SSB_SPROM8_5GH_MCSPO, ~0, 0);
  1835. +
  1836. + SPEX(rawtempsense, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_RAWTEMP,
  1837. + SSB_SPROM8_RAWTS_RAWTEMP_SHIFT);
  1838. + SPEX(measpower, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_MEASPOWER,
  1839. + SSB_SPROM8_RAWTS_MEASPOWER_SHIFT);
  1840. + SPEX(tempsense_slope, SSB_SPROM8_OPT_CORRX,
  1841. + SSB_SPROM8_OPT_CORRX_TEMP_SLOPE,
  1842. + SSB_SPROM8_OPT_CORRX_TEMP_SLOPE_SHIFT);
  1843. + SPEX(tempcorrx, SSB_SPROM8_OPT_CORRX, SSB_SPROM8_OPT_CORRX_TEMPCORRX,
  1844. + SSB_SPROM8_OPT_CORRX_TEMPCORRX_SHIFT);
  1845. + SPEX(tempsense_option, SSB_SPROM8_OPT_CORRX,
  1846. + SSB_SPROM8_OPT_CORRX_TEMP_OPTION,
  1847. + SSB_SPROM8_OPT_CORRX_TEMP_OPTION_SHIFT);
  1848. + SPEX(freqoffset_corr, SSB_SPROM8_HWIQ_IQSWP,
  1849. + SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR,
  1850. + SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR_SHIFT);
  1851. + SPEX(iqcal_swp_dis, SSB_SPROM8_HWIQ_IQSWP,
  1852. + SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP,
  1853. + SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP_SHIFT);
  1854. + SPEX(hw_iqcal_en, SSB_SPROM8_HWIQ_IQSWP, SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL,
  1855. + SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL_SHIFT);
  1856. +
  1857. + SPEX(bw40po, SSB_SPROM8_BW40PO, ~0, 0);
  1858. + SPEX(cddpo, SSB_SPROM8_CDDPO, ~0, 0);
  1859. + SPEX(stbcpo, SSB_SPROM8_STBCPO, ~0, 0);
  1860. + SPEX(bwduppo, SSB_SPROM8_BWDUPPO, ~0, 0);
  1861. +
  1862. + SPEX(tempthresh, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_TRESH,
  1863. + SSB_SPROM8_THERMAL_TRESH_SHIFT);
  1864. + SPEX(tempoffset, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_OFFSET,
  1865. + SSB_SPROM8_THERMAL_OFFSET_SHIFT);
  1866. + SPEX(phycal_tempdelta, SSB_SPROM8_TEMPDELTA,
  1867. + SSB_SPROM8_TEMPDELTA_PHYCAL,
  1868. + SSB_SPROM8_TEMPDELTA_PHYCAL_SHIFT);
  1869. + SPEX(temps_period, SSB_SPROM8_TEMPDELTA, SSB_SPROM8_TEMPDELTA_PERIOD,
  1870. + SSB_SPROM8_TEMPDELTA_PERIOD_SHIFT);
  1871. + SPEX(temps_hysteresis, SSB_SPROM8_TEMPDELTA,
  1872. + SSB_SPROM8_TEMPDELTA_HYSTERESIS,
  1873. + SSB_SPROM8_TEMPDELTA_HYSTERESIS_SHIFT);
  1874. sprom_extract_r458(out, in);
  1875. /* TODO - get remaining rev 8 stuff needed */
  1876. @@ -641,7 +753,7 @@ static int sprom_extract(struct ssb_bus
  1877. memset(out, 0, sizeof(*out));
  1878. out->revision = in[size - 1] & 0x00FF;
  1879. - ssb_dprintk(KERN_DEBUG PFX "SPROM revision %d detected.\n", out->revision);
  1880. + ssb_dbg("SPROM revision %d detected\n", out->revision);
  1881. memset(out->et0mac, 0xFF, 6); /* preset et0 and et1 mac */
  1882. memset(out->et1mac, 0xFF, 6);
  1883. @@ -650,7 +762,7 @@ static int sprom_extract(struct ssb_bus
  1884. * number stored in the SPROM.
  1885. * Always extract r1. */
  1886. out->revision = 1;
  1887. - ssb_dprintk(KERN_DEBUG PFX "SPROM treated as revision %d\n", out->revision);
  1888. + ssb_dbg("SPROM treated as revision %d\n", out->revision);
  1889. }
  1890. switch (out->revision) {
  1891. @@ -667,9 +779,8 @@ static int sprom_extract(struct ssb_bus
  1892. sprom_extract_r8(out, in);
  1893. break;
  1894. default:
  1895. - ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
  1896. - " revision %d detected. Will extract"
  1897. - " v1\n", out->revision);
  1898. + ssb_warn("Unsupported SPROM revision %d detected. Will extract v1\n",
  1899. + out->revision);
  1900. out->revision = 1;
  1901. sprom_extract_r123(out, in);
  1902. }
  1903. @@ -689,7 +800,7 @@ static int ssb_pci_sprom_get(struct ssb_
  1904. u16 *buf;
  1905. if (!ssb_is_sprom_available(bus)) {
  1906. - ssb_printk(KERN_ERR PFX "No SPROM available!\n");
  1907. + ssb_err("No SPROM available!\n");
  1908. return -ENODEV;
  1909. }
  1910. if (bus->chipco.dev) { /* can be unavailable! */
  1911. @@ -708,7 +819,7 @@ static int ssb_pci_sprom_get(struct ssb_
  1912. } else {
  1913. bus->sprom_offset = SSB_SPROM_BASE1;
  1914. }
  1915. - ssb_dprintk(KERN_INFO PFX "SPROM offset is 0x%x\n", bus->sprom_offset);
  1916. + ssb_dbg("SPROM offset is 0x%x\n", bus->sprom_offset);
  1917. buf = kcalloc(SSB_SPROMSIZE_WORDS_R123, sizeof(u16), GFP_KERNEL);
  1918. if (!buf)
  1919. @@ -733,18 +844,15 @@ static int ssb_pci_sprom_get(struct ssb_
  1920. * available for this device in some other storage */
  1921. err = ssb_fill_sprom_with_fallback(bus, sprom);
  1922. if (err) {
  1923. - ssb_printk(KERN_WARNING PFX "WARNING: Using"
  1924. - " fallback SPROM failed (err %d)\n",
  1925. - err);
  1926. + ssb_warn("WARNING: Using fallback SPROM failed (err %d)\n",
  1927. + err);
  1928. } else {
  1929. - ssb_dprintk(KERN_DEBUG PFX "Using SPROM"
  1930. - " revision %d provided by"
  1931. - " platform.\n", sprom->revision);
  1932. + ssb_dbg("Using SPROM revision %d provided by platform\n",
  1933. + sprom->revision);
  1934. err = 0;
  1935. goto out_free;
  1936. }
  1937. - ssb_printk(KERN_WARNING PFX "WARNING: Invalid"
  1938. - " SPROM CRC (corrupt SPROM)\n");
  1939. + ssb_warn("WARNING: Invalid SPROM CRC (corrupt SPROM)\n");
  1940. }
  1941. }
  1942. err = sprom_extract(bus, sprom, buf, bus->sprom_size);
  1943. @@ -759,7 +867,6 @@ static void ssb_pci_get_boardinfo(struct
  1944. {
  1945. bi->vendor = bus->host_pci->subsystem_vendor;
  1946. bi->type = bus->host_pci->subsystem_device;
  1947. - bi->rev = bus->host_pci->revision;
  1948. }
  1949. int ssb_pci_get_invariants(struct ssb_bus *bus,
  1950. --- a/drivers/ssb/pcihost_wrapper.c
  1951. +++ b/drivers/ssb/pcihost_wrapper.c
  1952. @@ -38,7 +38,7 @@ static int ssb_pcihost_resume(struct pci
  1953. struct ssb_bus *ssb = pci_get_drvdata(dev);
  1954. int err;
  1955. - pci_set_power_state(dev, 0);
  1956. + pci_set_power_state(dev, PCI_D0);
  1957. err = pci_enable_device(dev);
  1958. if (err)
  1959. return err;
  1960. --- a/drivers/ssb/pcmcia.c
  1961. +++ b/drivers/ssb/pcmcia.c
  1962. @@ -143,7 +143,7 @@ int ssb_pcmcia_switch_coreidx(struct ssb
  1963. return 0;
  1964. error:
  1965. - ssb_printk(KERN_ERR PFX "Failed to switch to core %u\n", coreidx);
  1966. + ssb_err("Failed to switch to core %u\n", coreidx);
  1967. return err;
  1968. }
  1969. @@ -153,10 +153,9 @@ int ssb_pcmcia_switch_core(struct ssb_bu
  1970. int err;
  1971. #if SSB_VERBOSE_PCMCIACORESWITCH_DEBUG
  1972. - ssb_printk(KERN_INFO PFX
  1973. - "Switching to %s core, index %d\n",
  1974. - ssb_core_name(dev->id.coreid),
  1975. - dev->core_index);
  1976. + ssb_info("Switching to %s core, index %d\n",
  1977. + ssb_core_name(dev->id.coreid),
  1978. + dev->core_index);
  1979. #endif
  1980. err = ssb_pcmcia_switch_coreidx(bus, dev->core_index);
  1981. @@ -192,7 +191,7 @@ int ssb_pcmcia_switch_segment(struct ssb
  1982. return 0;
  1983. error:
  1984. - ssb_printk(KERN_ERR PFX "Failed to switch pcmcia segment\n");
  1985. + ssb_err("Failed to switch pcmcia segment\n");
  1986. return err;
  1987. }
  1988. @@ -549,44 +548,39 @@ static int ssb_pcmcia_sprom_write_all(st
  1989. bool failed = 0;
  1990. size_t size = SSB_PCMCIA_SPROM_SIZE;
  1991. - ssb_printk(KERN_NOTICE PFX
  1992. - "Writing SPROM. Do NOT turn off the power! "
  1993. - "Please stand by...\n");
  1994. + ssb_notice("Writing SPROM. Do NOT turn off the power! Please stand by...\n");
  1995. err = ssb_pcmcia_sprom_command(bus, SSB_PCMCIA_SPROMCTL_WRITEEN);
  1996. if (err) {
  1997. - ssb_printk(KERN_NOTICE PFX
  1998. - "Could not enable SPROM write access.\n");
  1999. + ssb_notice("Could not enable SPROM write access\n");
  2000. return -EBUSY;
  2001. }
  2002. - ssb_printk(KERN_NOTICE PFX "[ 0%%");
  2003. + ssb_notice("[ 0%%");
  2004. msleep(500);
  2005. for (i = 0; i < size; i++) {
  2006. if (i == size / 4)
  2007. - ssb_printk("25%%");
  2008. + ssb_cont("25%%");
  2009. else if (i == size / 2)
  2010. - ssb_printk("50%%");
  2011. + ssb_cont("50%%");
  2012. else if (i == (size * 3) / 4)
  2013. - ssb_printk("75%%");
  2014. + ssb_cont("75%%");
  2015. else if (i % 2)
  2016. - ssb_printk(".");
  2017. + ssb_cont(".");
  2018. err = ssb_pcmcia_sprom_write(bus, i, sprom[i]);
  2019. if (err) {
  2020. - ssb_printk(KERN_NOTICE PFX
  2021. - "Failed to write to SPROM.\n");
  2022. + ssb_notice("Failed to write to SPROM\n");
  2023. failed = 1;
  2024. break;
  2025. }
  2026. }
  2027. err = ssb_pcmcia_sprom_command(bus, SSB_PCMCIA_SPROMCTL_WRITEDIS);
  2028. if (err) {
  2029. - ssb_printk(KERN_NOTICE PFX
  2030. - "Could not disable SPROM write access.\n");
  2031. + ssb_notice("Could not disable SPROM write access\n");
  2032. failed = 1;
  2033. }
  2034. msleep(500);
  2035. if (!failed) {
  2036. - ssb_printk("100%% ]\n");
  2037. - ssb_printk(KERN_NOTICE PFX "SPROM written.\n");
  2038. + ssb_cont("100%% ]\n");
  2039. + ssb_notice("SPROM written\n");
  2040. }
  2041. return failed ? -EBUSY : 0;
  2042. @@ -676,14 +670,10 @@ static int ssb_pcmcia_do_get_invariants(
  2043. case SSB_PCMCIA_CIS_ANTGAIN:
  2044. GOTO_ERROR_ON(tuple->TupleDataLen != 2,
  2045. "antg tpl size");
  2046. - sprom->antenna_gain.ghz24.a0 = tuple->TupleData[1];
  2047. - sprom->antenna_gain.ghz24.a1 = tuple->TupleData[1];
  2048. - sprom->antenna_gain.ghz24.a2 = tuple->TupleData[1];
  2049. - sprom->antenna_gain.ghz24.a3 = tuple->TupleData[1];
  2050. - sprom->antenna_gain.ghz5.a0 = tuple->TupleData[1];
  2051. - sprom->antenna_gain.ghz5.a1 = tuple->TupleData[1];
  2052. - sprom->antenna_gain.ghz5.a2 = tuple->TupleData[1];
  2053. - sprom->antenna_gain.ghz5.a3 = tuple->TupleData[1];
  2054. + sprom->antenna_gain.a0 = tuple->TupleData[1];
  2055. + sprom->antenna_gain.a1 = tuple->TupleData[1];
  2056. + sprom->antenna_gain.a2 = tuple->TupleData[1];
  2057. + sprom->antenna_gain.a3 = tuple->TupleData[1];
  2058. break;
  2059. case SSB_PCMCIA_CIS_BFLAGS:
  2060. GOTO_ERROR_ON((tuple->TupleDataLen != 3) &&
  2061. @@ -704,7 +694,7 @@ static int ssb_pcmcia_do_get_invariants(
  2062. return -ENOSPC; /* continue with next entry */
  2063. error:
  2064. - ssb_printk(KERN_ERR PFX
  2065. + ssb_err(
  2066. "PCMCIA: Failed to fetch device invariants: %s\n",
  2067. error_description);
  2068. return -ENODEV;
  2069. @@ -726,7 +716,7 @@ int ssb_pcmcia_get_invariants(struct ssb
  2070. res = pcmcia_loop_tuple(bus->host_pcmcia, CISTPL_FUNCE,
  2071. ssb_pcmcia_get_mac, sprom);
  2072. if (res != 0) {
  2073. - ssb_printk(KERN_ERR PFX
  2074. + ssb_err(
  2075. "PCMCIA: Failed to fetch MAC address\n");
  2076. return -ENODEV;
  2077. }
  2078. @@ -737,7 +727,7 @@ int ssb_pcmcia_get_invariants(struct ssb
  2079. if ((res == 0) || (res == -ENOSPC))
  2080. return 0;
  2081. - ssb_printk(KERN_ERR PFX
  2082. + ssb_err(
  2083. "PCMCIA: Failed to fetch device invariants\n");
  2084. return -ENODEV;
  2085. }
  2086. @@ -847,6 +837,6 @@ int ssb_pcmcia_init(struct ssb_bus *bus)
  2087. return 0;
  2088. error:
  2089. - ssb_printk(KERN_ERR PFX "Failed to initialize PCMCIA host device\n");
  2090. + ssb_err("Failed to initialize PCMCIA host device\n");
  2091. return err;
  2092. }
  2093. --- a/drivers/ssb/scan.c
  2094. +++ b/drivers/ssb/scan.c
  2095. @@ -90,6 +90,8 @@ const char *ssb_core_name(u16 coreid)
  2096. return "ARM 1176";
  2097. case SSB_DEV_ARM_7TDMI:
  2098. return "ARM 7TDMI";
  2099. + case SSB_DEV_ARM_CM3:
  2100. + return "ARM Cortex M3";
  2101. }
  2102. return "UNKNOWN";
  2103. }
  2104. @@ -123,8 +125,7 @@ static u16 pcidev_to_chipid(struct pci_d
  2105. chipid_fallback = 0x4401;
  2106. break;
  2107. default:
  2108. - ssb_printk(KERN_ERR PFX
  2109. - "PCI-ID not in fallback list\n");
  2110. + ssb_err("PCI-ID not in fallback list\n");
  2111. }
  2112. return chipid_fallback;
  2113. @@ -150,8 +151,7 @@ static u8 chipid_to_nrcores(u16 chipid)
  2114. case 0x4704:
  2115. return 9;
  2116. default:
  2117. - ssb_printk(KERN_ERR PFX
  2118. - "CHIPID not in nrcores fallback list\n");
  2119. + ssb_err("CHIPID not in nrcores fallback list\n");
  2120. }
  2121. return 1;
  2122. @@ -318,12 +318,13 @@ int ssb_bus_scan(struct ssb_bus *bus,
  2123. bus->chip_package = 0;
  2124. }
  2125. }
  2126. + ssb_info("Found chip with id 0x%04X, rev 0x%02X and package 0x%02X\n",
  2127. + bus->chip_id, bus->chip_rev, bus->chip_package);
  2128. if (!bus->nr_devices)
  2129. bus->nr_devices = chipid_to_nrcores(bus->chip_id);
  2130. if (bus->nr_devices > ARRAY_SIZE(bus->devices)) {
  2131. - ssb_printk(KERN_ERR PFX
  2132. - "More than %d ssb cores found (%d)\n",
  2133. - SSB_MAX_NR_CORES, bus->nr_devices);
  2134. + ssb_err("More than %d ssb cores found (%d)\n",
  2135. + SSB_MAX_NR_CORES, bus->nr_devices);
  2136. goto err_unmap;
  2137. }
  2138. if (bus->bustype == SSB_BUSTYPE_SSB) {
  2139. @@ -365,8 +366,7 @@ int ssb_bus_scan(struct ssb_bus *bus,
  2140. nr_80211_cores++;
  2141. if (nr_80211_cores > 1) {
  2142. if (!we_support_multiple_80211_cores(bus)) {
  2143. - ssb_dprintk(KERN_INFO PFX "Ignoring additional "
  2144. - "802.11 core\n");
  2145. + ssb_dbg("Ignoring additional 802.11 core\n");
  2146. continue;
  2147. }
  2148. }
  2149. @@ -374,8 +374,7 @@ int ssb_bus_scan(struct ssb_bus *bus,
  2150. case SSB_DEV_EXTIF:
  2151. #ifdef CONFIG_SSB_DRIVER_EXTIF
  2152. if (bus->extif.dev) {
  2153. - ssb_printk(KERN_WARNING PFX
  2154. - "WARNING: Multiple EXTIFs found\n");
  2155. + ssb_warn("WARNING: Multiple EXTIFs found\n");
  2156. break;
  2157. }
  2158. bus->extif.dev = dev;
  2159. @@ -383,8 +382,7 @@ int ssb_bus_scan(struct ssb_bus *bus,
  2160. break;
  2161. case SSB_DEV_CHIPCOMMON:
  2162. if (bus->chipco.dev) {
  2163. - ssb_printk(KERN_WARNING PFX
  2164. - "WARNING: Multiple ChipCommon found\n");
  2165. + ssb_warn("WARNING: Multiple ChipCommon found\n");
  2166. break;
  2167. }
  2168. bus->chipco.dev = dev;
  2169. @@ -393,8 +391,7 @@ int ssb_bus_scan(struct ssb_bus *bus,
  2170. case SSB_DEV_MIPS_3302:
  2171. #ifdef CONFIG_SSB_DRIVER_MIPS
  2172. if (bus->mipscore.dev) {
  2173. - ssb_printk(KERN_WARNING PFX
  2174. - "WARNING: Multiple MIPS cores found\n");
  2175. + ssb_warn("WARNING: Multiple MIPS cores found\n");
  2176. break;
  2177. }
  2178. bus->mipscore.dev = dev;
  2179. @@ -415,8 +412,7 @@ int ssb_bus_scan(struct ssb_bus *bus,
  2180. }
  2181. }
  2182. if (bus->pcicore.dev) {
  2183. - ssb_printk(KERN_WARNING PFX
  2184. - "WARNING: Multiple PCI(E) cores found\n");
  2185. + ssb_warn("WARNING: Multiple PCI(E) cores found\n");
  2186. break;
  2187. }
  2188. bus->pcicore.dev = dev;
  2189. --- a/drivers/ssb/sdio.c
  2190. +++ b/drivers/ssb/sdio.c
  2191. @@ -551,14 +551,10 @@ int ssb_sdio_get_invariants(struct ssb_b
  2192. case SSB_SDIO_CIS_ANTGAIN:
  2193. GOTO_ERROR_ON(tuple->size != 2,
  2194. "antg tpl size");
  2195. - sprom->antenna_gain.ghz24.a0 = tuple->data[1];
  2196. - sprom->antenna_gain.ghz24.a1 = tuple->data[1];
  2197. - sprom->antenna_gain.ghz24.a2 = tuple->data[1];
  2198. - sprom->antenna_gain.ghz24.a3 = tuple->data[1];
  2199. - sprom->antenna_gain.ghz5.a0 = tuple->data[1];
  2200. - sprom->antenna_gain.ghz5.a1 = tuple->data[1];
  2201. - sprom->antenna_gain.ghz5.a2 = tuple->data[1];
  2202. - sprom->antenna_gain.ghz5.a3 = tuple->data[1];
  2203. + sprom->antenna_gain.a0 = tuple->data[1];
  2204. + sprom->antenna_gain.a1 = tuple->data[1];
  2205. + sprom->antenna_gain.a2 = tuple->data[1];
  2206. + sprom->antenna_gain.a3 = tuple->data[1];
  2207. break;
  2208. case SSB_SDIO_CIS_BFLAGS:
  2209. GOTO_ERROR_ON((tuple->size != 3) &&
  2210. --- a/drivers/ssb/sprom.c
  2211. +++ b/drivers/ssb/sprom.c
  2212. @@ -54,7 +54,7 @@ static int hex2sprom(u16 *sprom, const c
  2213. while (cnt < sprom_size_words) {
  2214. memcpy(tmp, dump, 4);
  2215. dump += 4;
  2216. - err = strict_strtoul(tmp, 16, &parsed);
  2217. + err = kstrtoul(tmp, 16, &parsed);
  2218. if (err)
  2219. return err;
  2220. sprom[cnt++] = swab16((u16)parsed);
  2221. @@ -127,13 +127,13 @@ ssize_t ssb_attr_sprom_store(struct ssb_
  2222. goto out_kfree;
  2223. err = ssb_devices_freeze(bus, &freeze);
  2224. if (err) {
  2225. - ssb_printk(KERN_ERR PFX "SPROM write: Could not freeze all devices\n");
  2226. + ssb_err("SPROM write: Could not freeze all devices\n");
  2227. goto out_unlock;
  2228. }
  2229. res = sprom_write(bus, sprom);
  2230. err = ssb_devices_thaw(&freeze);
  2231. if (err)
  2232. - ssb_printk(KERN_ERR PFX "SPROM write: Could not thaw all devices\n");
  2233. + ssb_err("SPROM write: Could not thaw all devices\n");
  2234. out_unlock:
  2235. mutex_unlock(&bus->sprom_mutex);
  2236. out_kfree:
  2237. --- a/drivers/ssb/ssb_private.h
  2238. +++ b/drivers/ssb/ssb_private.h
  2239. @@ -3,21 +3,33 @@
  2240. #include <linux/ssb/ssb.h>
  2241. #include <linux/types.h>
  2242. +#include <linux/bcm47xx_wdt.h>
  2243. #define PFX "ssb: "
  2244. #ifdef CONFIG_SSB_SILENT
  2245. -# define ssb_printk(fmt, x...) do { /* nothing */ } while (0)
  2246. +# define ssb_printk(fmt, ...) \
  2247. + do { if (0) printk(fmt, ##__VA_ARGS__); } while (0)
  2248. #else
  2249. -# define ssb_printk printk
  2250. +# define ssb_printk(fmt, ...) \
  2251. + printk(fmt, ##__VA_ARGS__)
  2252. #endif /* CONFIG_SSB_SILENT */
  2253. +#define ssb_emerg(fmt, ...) ssb_printk(KERN_EMERG PFX fmt, ##__VA_ARGS__)
  2254. +#define ssb_err(fmt, ...) ssb_printk(KERN_ERR PFX fmt, ##__VA_ARGS__)
  2255. +#define ssb_warn(fmt, ...) ssb_printk(KERN_WARNING PFX fmt, ##__VA_ARGS__)
  2256. +#define ssb_notice(fmt, ...) ssb_printk(KERN_NOTICE PFX fmt, ##__VA_ARGS__)
  2257. +#define ssb_info(fmt, ...) ssb_printk(KERN_INFO PFX fmt, ##__VA_ARGS__)
  2258. +#define ssb_cont(fmt, ...) ssb_printk(KERN_CONT fmt, ##__VA_ARGS__)
  2259. +
  2260. /* dprintk: Debugging printk; vanishes for non-debug compilation */
  2261. #ifdef CONFIG_SSB_DEBUG
  2262. -# define ssb_dprintk(fmt, x...) ssb_printk(fmt , ##x)
  2263. +# define ssb_dbg(fmt, ...) \
  2264. + ssb_printk(KERN_DEBUG PFX fmt, ##__VA_ARGS__)
  2265. #else
  2266. -# define ssb_dprintk(fmt, x...) do { /* nothing */ } while (0)
  2267. +# define ssb_dbg(fmt, ...) \
  2268. + do { if (0) printk(KERN_DEBUG PFX fmt, ##__VA_ARGS__); } while (0)
  2269. #endif
  2270. #ifdef CONFIG_SSB_DEBUG
  2271. @@ -207,4 +219,79 @@ static inline void b43_pci_ssb_bridge_ex
  2272. }
  2273. #endif /* CONFIG_SSB_B43_PCI_BRIDGE */
  2274. +/* driver_chipcommon_pmu.c */
  2275. +extern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc);
  2276. +extern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc);
  2277. +extern u32 ssb_pmu_get_alp_clock(struct ssb_chipcommon *cc);
  2278. +
  2279. +extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
  2280. + u32 ticks);
  2281. +extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
  2282. +
  2283. +/* driver_chipcommon_sflash.c */
  2284. +#ifdef CONFIG_SSB_SFLASH
  2285. +int ssb_sflash_init(struct ssb_chipcommon *cc);
  2286. +#else
  2287. +static inline int ssb_sflash_init(struct ssb_chipcommon *cc)
  2288. +{
  2289. + pr_err("Serial flash not supported\n");
  2290. + return 0;
  2291. +}
  2292. +#endif /* CONFIG_SSB_SFLASH */
  2293. +
  2294. +#ifdef CONFIG_SSB_DRIVER_MIPS
  2295. +extern struct platform_device ssb_pflash_dev;
  2296. +#endif
  2297. +
  2298. +#ifdef CONFIG_SSB_SFLASH
  2299. +extern struct platform_device ssb_sflash_dev;
  2300. +#endif
  2301. +
  2302. +#ifdef CONFIG_SSB_DRIVER_EXTIF
  2303. +extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);
  2304. +extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
  2305. +#else
  2306. +static inline u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
  2307. + u32 ticks)
  2308. +{
  2309. + return 0;
  2310. +}
  2311. +static inline u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt,
  2312. + u32 ms)
  2313. +{
  2314. + return 0;
  2315. +}
  2316. +#endif
  2317. +
  2318. +#ifdef CONFIG_SSB_EMBEDDED
  2319. +extern int ssb_watchdog_register(struct ssb_bus *bus);
  2320. +#else /* CONFIG_SSB_EMBEDDED */
  2321. +static inline int ssb_watchdog_register(struct ssb_bus *bus)
  2322. +{
  2323. + return 0;
  2324. +}
  2325. +#endif /* CONFIG_SSB_EMBEDDED */
  2326. +
  2327. +#ifdef CONFIG_SSB_DRIVER_EXTIF
  2328. +extern void ssb_extif_init(struct ssb_extif *extif);
  2329. +#else
  2330. +static inline void ssb_extif_init(struct ssb_extif *extif)
  2331. +{
  2332. +}
  2333. +#endif
  2334. +
  2335. +#ifdef CONFIG_SSB_DRIVER_GPIO
  2336. +extern int ssb_gpio_init(struct ssb_bus *bus);
  2337. +extern int ssb_gpio_unregister(struct ssb_bus *bus);
  2338. +#else /* CONFIG_SSB_DRIVER_GPIO */
  2339. +static inline int ssb_gpio_init(struct ssb_bus *bus)
  2340. +{
  2341. + return -ENOTSUPP;
  2342. +}
  2343. +static inline int ssb_gpio_unregister(struct ssb_bus *bus)
  2344. +{
  2345. + return 0;
  2346. +}
  2347. +#endif /* CONFIG_SSB_DRIVER_GPIO */
  2348. +
  2349. #endif /* LINUX_SSB_PRIVATE_H_ */
  2350. --- a/include/linux/ssb/ssb.h
  2351. +++ b/include/linux/ssb/ssb.h
  2352. @@ -6,8 +6,10 @@
  2353. #include <linux/types.h>
  2354. #include <linux/spinlock.h>
  2355. #include <linux/pci.h>
  2356. +#include <linux/gpio.h>
  2357. #include <linux/mod_devicetable.h>
  2358. #include <linux/dma-mapping.h>
  2359. +#include <linux/platform_device.h>
  2360. #include <linux/ssb/ssb_regs.h>
  2361. @@ -16,19 +18,29 @@ struct pcmcia_device;
  2362. struct ssb_bus;
  2363. struct ssb_driver;
  2364. +struct ssb_sprom_core_pwr_info {
  2365. + u8 itssi_2g, itssi_5g;
  2366. + u8 maxpwr_2g, maxpwr_5gl, maxpwr_5g, maxpwr_5gh;
  2367. + u16 pa_2g[4], pa_5gl[4], pa_5g[4], pa_5gh[4];
  2368. +};
  2369. +
  2370. struct ssb_sprom {
  2371. u8 revision;
  2372. - u8 il0mac[6]; /* MAC address for 802.11b/g */
  2373. - u8 et0mac[6]; /* MAC address for Ethernet */
  2374. - u8 et1mac[6]; /* MAC address for 802.11a */
  2375. + u8 il0mac[6] __aligned(sizeof(u16)); /* MAC address for 802.11b/g */
  2376. + u8 et0mac[6] __aligned(sizeof(u16)); /* MAC address for Ethernet */
  2377. + u8 et1mac[6] __aligned(sizeof(u16)); /* MAC address for 802.11a */
  2378. u8 et0phyaddr; /* MII address for enet0 */
  2379. u8 et1phyaddr; /* MII address for enet1 */
  2380. u8 et0mdcport; /* MDIO for enet0 */
  2381. u8 et1mdcport; /* MDIO for enet1 */
  2382. + u16 dev_id; /* Device ID overriding e.g. PCI ID */
  2383. u16 board_rev; /* Board revision number from SPROM. */
  2384. + u16 board_num; /* Board number from SPROM. */
  2385. + u16 board_type; /* Board type from SPROM. */
  2386. u8 country_code; /* Country Code */
  2387. - u16 leddc_on_time; /* LED Powersave Duty Cycle On Count */
  2388. - u16 leddc_off_time; /* LED Powersave Duty Cycle Off Count */
  2389. + char alpha2[2]; /* Country Code as two chars like EU or US */
  2390. + u8 leddc_on_time; /* LED Powersave Duty Cycle On Count */
  2391. + u8 leddc_off_time; /* LED Powersave Duty Cycle Off Count */
  2392. u8 ant_available_a; /* 2GHz antenna available bits (up to 4) */
  2393. u8 ant_available_bg; /* 5GHz antenna available bits (up to 4) */
  2394. u16 pa0b0;
  2395. @@ -47,10 +59,10 @@ struct ssb_sprom {
  2396. u8 gpio1; /* GPIO pin 1 */
  2397. u8 gpio2; /* GPIO pin 2 */
  2398. u8 gpio3; /* GPIO pin 3 */
  2399. - u16 maxpwr_bg; /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
  2400. - u16 maxpwr_al; /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
  2401. - u16 maxpwr_a; /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
  2402. - u16 maxpwr_ah; /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
  2403. + u8 maxpwr_bg; /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
  2404. + u8 maxpwr_al; /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
  2405. + u8 maxpwr_a; /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
  2406. + u8 maxpwr_ah; /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
  2407. u8 itssi_a; /* Idle TSSI Target for A-PHY */
  2408. u8 itssi_bg; /* Idle TSSI Target for B/G-PHY */
  2409. u8 tri2g; /* 2.4GHz TX isolation */
  2410. @@ -61,8 +73,8 @@ struct ssb_sprom {
  2411. u8 txpid5gl[4]; /* 4.9 - 5.1GHz TX power index */
  2412. u8 txpid5g[4]; /* 5.1 - 5.5GHz TX power index */
  2413. u8 txpid5gh[4]; /* 5.5 - ...GHz TX power index */
  2414. - u8 rxpo2g; /* 2GHz RX power offset */
  2415. - u8 rxpo5g; /* 5GHz RX power offset */
  2416. + s8 rxpo2g; /* 2GHz RX power offset */
  2417. + s8 rxpo5g; /* 5GHz RX power offset */
  2418. u8 rssisav2g; /* 2GHz RSSI params */
  2419. u8 rssismc2g;
  2420. u8 rssismf2g;
  2421. @@ -82,16 +94,13 @@ struct ssb_sprom {
  2422. u16 boardflags2_hi; /* Board flags (bits 48-63) */
  2423. /* TODO store board flags in a single u64 */
  2424. + struct ssb_sprom_core_pwr_info core_pwr_info[4];
  2425. +
  2426. /* Antenna gain values for up to 4 antennas
  2427. * on each band. Values in dBm/4 (Q5.2). Negative gain means the
  2428. * loss in the connectors is bigger than the gain. */
  2429. struct {
  2430. - struct {
  2431. - s8 a0, a1, a2, a3;
  2432. - } ghz24; /* 2.4GHz band */
  2433. - struct {
  2434. - s8 a0, a1, a2, a3;
  2435. - } ghz5; /* 5GHz band */
  2436. + s8 a0, a1, a2, a3;
  2437. } antenna_gain;
  2438. struct {
  2439. @@ -103,14 +112,85 @@ struct ssb_sprom {
  2440. } ghz5;
  2441. } fem;
  2442. - /* TODO - add any parameters needed from rev 2, 3, 4, 5 or 8 SPROMs */
  2443. + u16 mcs2gpo[8];
  2444. + u16 mcs5gpo[8];
  2445. + u16 mcs5glpo[8];
  2446. + u16 mcs5ghpo[8];
  2447. + u8 opo;
  2448. +
  2449. + u8 rxgainerr2ga[3];
  2450. + u8 rxgainerr5gla[3];
  2451. + u8 rxgainerr5gma[3];
  2452. + u8 rxgainerr5gha[3];
  2453. + u8 rxgainerr5gua[3];
  2454. +
  2455. + u8 noiselvl2ga[3];
  2456. + u8 noiselvl5gla[3];
  2457. + u8 noiselvl5gma[3];
  2458. + u8 noiselvl5gha[3];
  2459. + u8 noiselvl5gua[3];
  2460. +
  2461. + u8 regrev;
  2462. + u8 txchain;
  2463. + u8 rxchain;
  2464. + u8 antswitch;
  2465. + u16 cddpo;
  2466. + u16 stbcpo;
  2467. + u16 bw40po;
  2468. + u16 bwduppo;
  2469. +
  2470. + u8 tempthresh;
  2471. + u8 tempoffset;
  2472. + u16 rawtempsense;
  2473. + u8 measpower;
  2474. + u8 tempsense_slope;
  2475. + u8 tempcorrx;
  2476. + u8 tempsense_option;
  2477. + u8 freqoffset_corr;
  2478. + u8 iqcal_swp_dis;
  2479. + u8 hw_iqcal_en;
  2480. + u8 elna2g;
  2481. + u8 elna5g;
  2482. + u8 phycal_tempdelta;
  2483. + u8 temps_period;
  2484. + u8 temps_hysteresis;
  2485. + u8 measpower1;
  2486. + u8 measpower2;
  2487. + u8 pcieingress_war;
  2488. +
  2489. + /* power per rate from sromrev 9 */
  2490. + u16 cckbw202gpo;
  2491. + u16 cckbw20ul2gpo;
  2492. + u32 legofdmbw202gpo;
  2493. + u32 legofdmbw20ul2gpo;
  2494. + u32 legofdmbw205glpo;
  2495. + u32 legofdmbw20ul5glpo;
  2496. + u32 legofdmbw205gmpo;
  2497. + u32 legofdmbw20ul5gmpo;
  2498. + u32 legofdmbw205ghpo;
  2499. + u32 legofdmbw20ul5ghpo;
  2500. + u32 mcsbw202gpo;
  2501. + u32 mcsbw20ul2gpo;
  2502. + u32 mcsbw402gpo;
  2503. + u32 mcsbw205glpo;
  2504. + u32 mcsbw20ul5glpo;
  2505. + u32 mcsbw405glpo;
  2506. + u32 mcsbw205gmpo;
  2507. + u32 mcsbw20ul5gmpo;
  2508. + u32 mcsbw405gmpo;
  2509. + u32 mcsbw205ghpo;
  2510. + u32 mcsbw20ul5ghpo;
  2511. + u32 mcsbw405ghpo;
  2512. + u16 mcs32po;
  2513. + u16 legofdm40duppo;
  2514. + u8 sar2g;
  2515. + u8 sar5g;
  2516. };
  2517. /* Information about the PCB the circuitry is soldered on. */
  2518. struct ssb_boardinfo {
  2519. u16 vendor;
  2520. u16 type;
  2521. - u8 rev;
  2522. };
  2523. @@ -166,6 +246,7 @@ struct ssb_bus_ops {
  2524. #define SSB_DEV_MINI_MACPHY 0x823
  2525. #define SSB_DEV_ARM_1176 0x824
  2526. #define SSB_DEV_ARM_7TDMI 0x825
  2527. +#define SSB_DEV_ARM_CM3 0x82A
  2528. /* Vendor-ID values */
  2529. #define SSB_VENDOR_BROADCOM 0x4243
  2530. @@ -260,13 +341,61 @@ enum ssb_bustype {
  2531. #define SSB_BOARDVENDOR_DELL 0x1028 /* Dell */
  2532. #define SSB_BOARDVENDOR_HP 0x0E11 /* HP */
  2533. /* board_type */
  2534. +#define SSB_BOARD_BCM94301CB 0x0406
  2535. +#define SSB_BOARD_BCM94301MP 0x0407
  2536. +#define SSB_BOARD_BU4309 0x040A
  2537. +#define SSB_BOARD_BCM94309CB 0x040B
  2538. +#define SSB_BOARD_BCM4309MP 0x040C
  2539. +#define SSB_BOARD_BU4306 0x0416
  2540. #define SSB_BOARD_BCM94306MP 0x0418
  2541. #define SSB_BOARD_BCM4309G 0x0421
  2542. #define SSB_BOARD_BCM4306CB 0x0417
  2543. -#define SSB_BOARD_BCM4309MP 0x040C
  2544. +#define SSB_BOARD_BCM94306PC 0x0425 /* pcmcia 3.3v 4306 card */
  2545. +#define SSB_BOARD_BCM94306CBSG 0x042B /* with SiGe PA */
  2546. +#define SSB_BOARD_PCSG94306 0x042D /* with SiGe PA */
  2547. +#define SSB_BOARD_BU4704SD 0x042E /* with sdram */
  2548. +#define SSB_BOARD_BCM94704AGR 0x042F /* dual 11a/11g Router */
  2549. +#define SSB_BOARD_BCM94308MP 0x0430 /* 11a-only minipci */
  2550. +#define SSB_BOARD_BU4318 0x0447
  2551. +#define SSB_BOARD_CB4318 0x0448
  2552. +#define SSB_BOARD_MPG4318 0x0449
  2553. #define SSB_BOARD_MP4318 0x044A
  2554. -#define SSB_BOARD_BU4306 0x0416
  2555. -#define SSB_BOARD_BU4309 0x040A
  2556. +#define SSB_BOARD_SD4318 0x044B
  2557. +#define SSB_BOARD_BCM94306P 0x044C /* with SiGe */
  2558. +#define SSB_BOARD_BCM94303MP 0x044E
  2559. +#define SSB_BOARD_BCM94306MPM 0x0450
  2560. +#define SSB_BOARD_BCM94306MPL 0x0453
  2561. +#define SSB_BOARD_PC4303 0x0454 /* pcmcia */
  2562. +#define SSB_BOARD_BCM94306MPLNA 0x0457
  2563. +#define SSB_BOARD_BCM94306MPH 0x045B
  2564. +#define SSB_BOARD_BCM94306PCIV 0x045C
  2565. +#define SSB_BOARD_BCM94318MPGH 0x0463
  2566. +#define SSB_BOARD_BU4311 0x0464
  2567. +#define SSB_BOARD_BCM94311MC 0x0465
  2568. +#define SSB_BOARD_BCM94311MCAG 0x0466
  2569. +/* 4321 boards */
  2570. +#define SSB_BOARD_BU4321 0x046B
  2571. +#define SSB_BOARD_BU4321E 0x047C
  2572. +#define SSB_BOARD_MP4321 0x046C
  2573. +#define SSB_BOARD_CB2_4321 0x046D
  2574. +#define SSB_BOARD_CB2_4321_AG 0x0066
  2575. +#define SSB_BOARD_MC4321 0x046E
  2576. +/* 4325 boards */
  2577. +#define SSB_BOARD_BCM94325DEVBU 0x0490
  2578. +#define SSB_BOARD_BCM94325BGABU 0x0491
  2579. +#define SSB_BOARD_BCM94325SDGWB 0x0492
  2580. +#define SSB_BOARD_BCM94325SDGMDL 0x04AA
  2581. +#define SSB_BOARD_BCM94325SDGMDL2 0x04C6
  2582. +#define SSB_BOARD_BCM94325SDGMDL3 0x04C9
  2583. +#define SSB_BOARD_BCM94325SDABGWBA 0x04E1
  2584. +/* 4322 boards */
  2585. +#define SSB_BOARD_BCM94322MC 0x04A4
  2586. +#define SSB_BOARD_BCM94322USB 0x04A8 /* dualband */
  2587. +#define SSB_BOARD_BCM94322HM 0x04B0
  2588. +#define SSB_BOARD_BCM94322USB2D 0x04Bf /* single band discrete front end */
  2589. +/* 4312 boards */
  2590. +#define SSB_BOARD_BU4312 0x048A
  2591. +#define SSB_BOARD_BCM4312MCGSG 0x04B5
  2592. /* chip_package */
  2593. #define SSB_CHIPPACK_BCM4712S 1 /* Small 200pin 4712 */
  2594. #define SSB_CHIPPACK_BCM4712M 2 /* Medium 225pin 4712 */
  2595. @@ -354,7 +483,11 @@ struct ssb_bus {
  2596. #ifdef CONFIG_SSB_EMBEDDED
  2597. /* Lock for GPIO register access. */
  2598. spinlock_t gpio_lock;
  2599. + struct platform_device *watchdog;
  2600. #endif /* EMBEDDED */
  2601. +#ifdef CONFIG_SSB_DRIVER_GPIO
  2602. + struct gpio_chip gpio;
  2603. +#endif /* DRIVER_GPIO */
  2604. /* Internal-only stuff follows. Do not touch. */
  2605. struct list_head list;
  2606. --- a/include/linux/ssb/ssb_driver_chipcommon.h
  2607. +++ b/include/linux/ssb/ssb_driver_chipcommon.h
  2608. @@ -219,6 +219,7 @@
  2609. #define SSB_CHIPCO_PMU_CTL 0x0600 /* PMU control */
  2610. #define SSB_CHIPCO_PMU_CTL_ILP_DIV 0xFFFF0000 /* ILP div mask */
  2611. #define SSB_CHIPCO_PMU_CTL_ILP_DIV_SHIFT 16
  2612. +#define SSB_CHIPCO_PMU_CTL_PLL_UPD 0x00000400
  2613. #define SSB_CHIPCO_PMU_CTL_NOILPONW 0x00000200 /* No ILP on wait */
  2614. #define SSB_CHIPCO_PMU_CTL_HTREQEN 0x00000100 /* HT req enable */
  2615. #define SSB_CHIPCO_PMU_CTL_ALPREQEN 0x00000080 /* ALP req enable */
  2616. @@ -504,7 +505,9 @@
  2617. #define SSB_CHIPCO_FLASHCTL_ST_SE 0x02D8 /* Sector Erase */
  2618. #define SSB_CHIPCO_FLASHCTL_ST_BE 0x00C7 /* Bulk Erase */
  2619. #define SSB_CHIPCO_FLASHCTL_ST_DP 0x00B9 /* Deep Power-down */
  2620. -#define SSB_CHIPCO_FLASHCTL_ST_RSIG 0x03AB /* Read Electronic Signature */
  2621. +#define SSB_CHIPCO_FLASHCTL_ST_RES 0x03AB /* Read Electronic Signature */
  2622. +#define SSB_CHIPCO_FLASHCTL_ST_CSA 0x1000 /* Keep chip select asserted */
  2623. +#define SSB_CHIPCO_FLASHCTL_ST_SSE 0x0220 /* Sub-sector Erase */
  2624. /* Status register bits for ST flashes */
  2625. #define SSB_CHIPCO_FLASHSTA_ST_WIP 0x01 /* Write In Progress */
  2626. @@ -588,7 +591,10 @@ struct ssb_chipcommon {
  2627. u32 status;
  2628. /* Fast Powerup Delay constant */
  2629. u16 fast_pwrup_delay;
  2630. + spinlock_t gpio_lock;
  2631. struct ssb_chipcommon_pmu pmu;
  2632. + u32 ticks_per_ms;
  2633. + u32 max_timer_ms;
  2634. };
  2635. static inline bool ssb_chipco_available(struct ssb_chipcommon *cc)
  2636. @@ -628,8 +634,7 @@ enum ssb_clkmode {
  2637. extern void ssb_chipco_set_clockmode(struct ssb_chipcommon *cc,
  2638. enum ssb_clkmode mode);
  2639. -extern void ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc,
  2640. - u32 ticks);
  2641. +extern u32 ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc, u32 ticks);
  2642. void ssb_chipco_irq_mask(struct ssb_chipcommon *cc, u32 mask, u32 value);
  2643. @@ -642,6 +647,8 @@ u32 ssb_chipco_gpio_outen(struct ssb_chi
  2644. u32 ssb_chipco_gpio_control(struct ssb_chipcommon *cc, u32 mask, u32 value);
  2645. u32 ssb_chipco_gpio_intmask(struct ssb_chipcommon *cc, u32 mask, u32 value);
  2646. u32 ssb_chipco_gpio_polarity(struct ssb_chipcommon *cc, u32 mask, u32 value);
  2647. +u32 ssb_chipco_gpio_pullup(struct ssb_chipcommon *cc, u32 mask, u32 value);
  2648. +u32 ssb_chipco_gpio_pulldown(struct ssb_chipcommon *cc, u32 mask, u32 value);
  2649. #ifdef CONFIG_SSB_SERIAL
  2650. extern int ssb_chipco_serial_init(struct ssb_chipcommon *cc,
  2651. @@ -661,5 +668,6 @@ enum ssb_pmu_ldo_volt_id {
  2652. void ssb_pmu_set_ldo_voltage(struct ssb_chipcommon *cc,
  2653. enum ssb_pmu_ldo_volt_id id, u32 voltage);
  2654. void ssb_pmu_set_ldo_paref(struct ssb_chipcommon *cc, bool on);
  2655. +void ssb_pmu_spuravoid_pllupdate(struct ssb_chipcommon *cc, int spuravoid);
  2656. #endif /* LINUX_SSB_CHIPCO_H_ */
  2657. --- a/include/linux/ssb/ssb_driver_extif.h
  2658. +++ b/include/linux/ssb/ssb_driver_extif.h
  2659. @@ -152,12 +152,16 @@
  2660. /* watchdog */
  2661. #define SSB_EXTIF_WATCHDOG_CLK 48000000 /* Hz */
  2662. +#define SSB_EXTIF_WATCHDOG_MAX_TIMER ((1 << 28) - 1)
  2663. +#define SSB_EXTIF_WATCHDOG_MAX_TIMER_MS (SSB_EXTIF_WATCHDOG_MAX_TIMER \
  2664. + / (SSB_EXTIF_WATCHDOG_CLK / 1000))
  2665. #ifdef CONFIG_SSB_DRIVER_EXTIF
  2666. struct ssb_extif {
  2667. struct ssb_device *dev;
  2668. + spinlock_t gpio_lock;
  2669. };
  2670. static inline bool ssb_extif_available(struct ssb_extif *extif)
  2671. @@ -171,8 +175,7 @@ extern void ssb_extif_get_clockcontrol(s
  2672. extern void ssb_extif_timing_init(struct ssb_extif *extif,
  2673. unsigned long ns);
  2674. -extern void ssb_extif_watchdog_timer_set(struct ssb_extif *extif,
  2675. - u32 ticks);
  2676. +extern u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks);
  2677. /* Extif GPIO pin access */
  2678. u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask);
  2679. @@ -205,10 +208,52 @@ void ssb_extif_get_clockcontrol(struct s
  2680. }
  2681. static inline
  2682. -void ssb_extif_watchdog_timer_set(struct ssb_extif *extif,
  2683. - u32 ticks)
  2684. +void ssb_extif_timing_init(struct ssb_extif *extif, unsigned long ns)
  2685. {
  2686. }
  2687. +static inline
  2688. +u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks)
  2689. +{
  2690. + return 0;
  2691. +}
  2692. +
  2693. +static inline u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask)
  2694. +{
  2695. + return 0;
  2696. +}
  2697. +
  2698. +static inline u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask,
  2699. + u32 value)
  2700. +{
  2701. + return 0;
  2702. +}
  2703. +
  2704. +static inline u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask,
  2705. + u32 value)
  2706. +{
  2707. + return 0;
  2708. +}
  2709. +
  2710. +static inline u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask,
  2711. + u32 value)
  2712. +{
  2713. + return 0;
  2714. +}
  2715. +
  2716. +static inline u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask,
  2717. + u32 value)
  2718. +{
  2719. + return 0;
  2720. +}
  2721. +
  2722. +#ifdef CONFIG_SSB_SERIAL
  2723. +static inline int ssb_extif_serial_init(struct ssb_extif *extif,
  2724. + struct ssb_serial_port *ports)
  2725. +{
  2726. + return 0;
  2727. +}
  2728. +#endif /* CONFIG_SSB_SERIAL */
  2729. +
  2730. #endif /* CONFIG_SSB_DRIVER_EXTIF */
  2731. #endif /* LINUX_SSB_EXTIFCORE_H_ */
  2732. --- a/include/linux/ssb/ssb_driver_gige.h
  2733. +++ b/include/linux/ssb/ssb_driver_gige.h
  2734. @@ -2,6 +2,7 @@
  2735. #define LINUX_SSB_DRIVER_GIGE_H_
  2736. #include <linux/ssb/ssb.h>
  2737. +#include <linux/bug.h>
  2738. #include <linux/pci.h>
  2739. #include <linux/spinlock.h>
  2740. @@ -96,21 +97,16 @@ static inline bool ssb_gige_must_flush_p
  2741. return 0;
  2742. }
  2743. -#ifdef CONFIG_BCM47XX
  2744. -#include <asm/mach-bcm47xx/nvram.h>
  2745. /* Get the device MAC address */
  2746. -static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
  2747. -{
  2748. - char buf[20];
  2749. - if (nvram_getenv("et0macaddr", buf, sizeof(buf)) < 0)
  2750. - return;
  2751. - nvram_parse_macaddr(buf, macaddr);
  2752. -}
  2753. -#else
  2754. -static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
  2755. +static inline int ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
  2756. {
  2757. + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
  2758. + if (!dev)
  2759. + return -ENODEV;
  2760. +
  2761. + memcpy(macaddr, dev->dev->bus->sprom.et0mac, 6);
  2762. + return 0;
  2763. }
  2764. -#endif
  2765. extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
  2766. struct pci_dev *pdev);
  2767. @@ -174,6 +170,10 @@ static inline bool ssb_gige_must_flush_p
  2768. {
  2769. return 0;
  2770. }
  2771. +static inline int ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
  2772. +{
  2773. + return -ENODEV;
  2774. +}
  2775. #endif /* CONFIG_SSB_DRIVER_GIGE */
  2776. #endif /* LINUX_SSB_DRIVER_GIGE_H_ */
  2777. --- a/include/linux/ssb/ssb_driver_mips.h
  2778. +++ b/include/linux/ssb/ssb_driver_mips.h
  2779. @@ -13,6 +13,24 @@ struct ssb_serial_port {
  2780. unsigned int reg_shift;
  2781. };
  2782. +struct ssb_pflash {
  2783. + bool present;
  2784. + u8 buswidth;
  2785. + u32 window;
  2786. + u32 window_size;
  2787. +};
  2788. +
  2789. +#ifdef CONFIG_SSB_SFLASH
  2790. +struct ssb_sflash {
  2791. + bool present;
  2792. + u32 window;
  2793. + u32 blocksize;
  2794. + u16 numblocks;
  2795. + u32 size;
  2796. +
  2797. + void *priv;
  2798. +};
  2799. +#endif
  2800. struct ssb_mipscore {
  2801. struct ssb_device *dev;
  2802. @@ -20,9 +38,10 @@ struct ssb_mipscore {
  2803. int nr_serial_ports;
  2804. struct ssb_serial_port serial_ports[4];
  2805. - u8 flash_buswidth;
  2806. - u32 flash_window;
  2807. - u32 flash_window_size;
  2808. + struct ssb_pflash pflash;
  2809. +#ifdef CONFIG_SSB_SFLASH
  2810. + struct ssb_sflash sflash;
  2811. +#endif
  2812. };
  2813. extern void ssb_mipscore_init(struct ssb_mipscore *mcore);
  2814. @@ -41,6 +60,11 @@ void ssb_mipscore_init(struct ssb_mipsco
  2815. {
  2816. }
  2817. +static inline unsigned int ssb_mips_irq(struct ssb_device *dev)
  2818. +{
  2819. + return 0;
  2820. +}
  2821. +
  2822. #endif /* CONFIG_SSB_DRIVER_MIPS */
  2823. #endif /* LINUX_SSB_MIPSCORE_H_ */
  2824. --- a/include/linux/ssb/ssb_regs.h
  2825. +++ b/include/linux/ssb/ssb_regs.h
  2826. @@ -172,6 +172,7 @@
  2827. #define SSB_SPROMSIZE_WORDS_R4 220
  2828. #define SSB_SPROMSIZE_BYTES_R123 (SSB_SPROMSIZE_WORDS_R123 * sizeof(u16))
  2829. #define SSB_SPROMSIZE_BYTES_R4 (SSB_SPROMSIZE_WORDS_R4 * sizeof(u16))
  2830. +#define SSB_SPROMSIZE_WORDS_R10 230
  2831. #define SSB_SPROM_BASE1 0x1000
  2832. #define SSB_SPROM_BASE31 0x0800
  2833. #define SSB_SPROM_REVISION 0x007E
  2834. @@ -228,6 +229,7 @@
  2835. #define SSB_SPROM1_AGAIN_BG_SHIFT 0
  2836. #define SSB_SPROM1_AGAIN_A 0xFF00 /* A-PHY */
  2837. #define SSB_SPROM1_AGAIN_A_SHIFT 8
  2838. +#define SSB_SPROM1_CCODE 0x0076
  2839. /* SPROM Revision 2 (inherits from rev 1) */
  2840. #define SSB_SPROM2_BFLHI 0x0038 /* Boardflags (high 16 bits) */
  2841. @@ -267,6 +269,7 @@
  2842. #define SSB_SPROM3_OFDMGPO 0x107A /* G-PHY OFDM Power Offset (4 bytes, BigEndian) */
  2843. /* SPROM Revision 4 */
  2844. +#define SSB_SPROM4_BOARDREV 0x0042 /* Board revision */
  2845. #define SSB_SPROM4_BFLLO 0x0044 /* Boardflags (low 16 bits) */
  2846. #define SSB_SPROM4_BFLHI 0x0046 /* Board Flags Hi */
  2847. #define SSB_SPROM4_BFL2LO 0x0048 /* Board flags 2 (low 16 bits) */
  2848. @@ -287,11 +290,11 @@
  2849. #define SSB_SPROM4_ETHPHY_ET1A_SHIFT 5
  2850. #define SSB_SPROM4_ETHPHY_ET0M (1<<14) /* MDIO for enet0 */
  2851. #define SSB_SPROM4_ETHPHY_ET1M (1<<15) /* MDIO for enet1 */
  2852. -#define SSB_SPROM4_ANTAVAIL 0x005D /* Antenna available bitfields */
  2853. -#define SSB_SPROM4_ANTAVAIL_A 0x00FF /* A-PHY bitfield */
  2854. -#define SSB_SPROM4_ANTAVAIL_A_SHIFT 0
  2855. -#define SSB_SPROM4_ANTAVAIL_BG 0xFF00 /* B-PHY and G-PHY bitfield */
  2856. -#define SSB_SPROM4_ANTAVAIL_BG_SHIFT 8
  2857. +#define SSB_SPROM4_ANTAVAIL 0x005C /* Antenna available bitfields */
  2858. +#define SSB_SPROM4_ANTAVAIL_BG 0x00FF /* B-PHY and G-PHY bitfield */
  2859. +#define SSB_SPROM4_ANTAVAIL_BG_SHIFT 0
  2860. +#define SSB_SPROM4_ANTAVAIL_A 0xFF00 /* A-PHY bitfield */
  2861. +#define SSB_SPROM4_ANTAVAIL_A_SHIFT 8
  2862. #define SSB_SPROM4_AGAIN01 0x005E /* Antenna Gain (in dBm Q5.2) */
  2863. #define SSB_SPROM4_AGAIN0 0x00FF /* Antenna 0 */
  2864. #define SSB_SPROM4_AGAIN0_SHIFT 0
  2865. @@ -389,6 +392,11 @@
  2866. #define SSB_SPROM8_GPIOB_P2 0x00FF /* Pin 2 */
  2867. #define SSB_SPROM8_GPIOB_P3 0xFF00 /* Pin 3 */
  2868. #define SSB_SPROM8_GPIOB_P3_SHIFT 8
  2869. +#define SSB_SPROM8_LEDDC 0x009A
  2870. +#define SSB_SPROM8_LEDDC_ON 0xFF00 /* oncount */
  2871. +#define SSB_SPROM8_LEDDC_ON_SHIFT 8
  2872. +#define SSB_SPROM8_LEDDC_OFF 0x00FF /* offcount */
  2873. +#define SSB_SPROM8_LEDDC_OFF_SHIFT 0
  2874. #define SSB_SPROM8_ANTAVAIL 0x009C /* Antenna available bitfields*/
  2875. #define SSB_SPROM8_ANTAVAIL_A 0xFF00 /* A-PHY bitfield */
  2876. #define SSB_SPROM8_ANTAVAIL_A_SHIFT 8
  2877. @@ -404,6 +412,13 @@
  2878. #define SSB_SPROM8_AGAIN2_SHIFT 0
  2879. #define SSB_SPROM8_AGAIN3 0xFF00 /* Antenna 3 */
  2880. #define SSB_SPROM8_AGAIN3_SHIFT 8
  2881. +#define SSB_SPROM8_TXRXC 0x00A2
  2882. +#define SSB_SPROM8_TXRXC_TXCHAIN 0x000f
  2883. +#define SSB_SPROM8_TXRXC_TXCHAIN_SHIFT 0
  2884. +#define SSB_SPROM8_TXRXC_RXCHAIN 0x00f0
  2885. +#define SSB_SPROM8_TXRXC_RXCHAIN_SHIFT 4
  2886. +#define SSB_SPROM8_TXRXC_SWITCH 0xff00
  2887. +#define SSB_SPROM8_TXRXC_SWITCH_SHIFT 8
  2888. #define SSB_SPROM8_RSSIPARM2G 0x00A4 /* RSSI params for 2GHz */
  2889. #define SSB_SPROM8_RSSISMF2G 0x000F
  2890. #define SSB_SPROM8_RSSISMC2G 0x00F0
  2891. @@ -430,6 +445,7 @@
  2892. #define SSB_SPROM8_TRI5GH_SHIFT 8
  2893. #define SSB_SPROM8_RXPO 0x00AC /* RX power offsets */
  2894. #define SSB_SPROM8_RXPO2G 0x00FF /* 2GHz RX power offset */
  2895. +#define SSB_SPROM8_RXPO2G_SHIFT 0
  2896. #define SSB_SPROM8_RXPO5G 0xFF00 /* 5GHz RX power offset */
  2897. #define SSB_SPROM8_RXPO5G_SHIFT 8
  2898. #define SSB_SPROM8_FEM2G 0x00AE
  2899. @@ -445,10 +461,71 @@
  2900. #define SSB_SROM8_FEM_ANTSWLUT 0xF800
  2901. #define SSB_SROM8_FEM_ANTSWLUT_SHIFT 11
  2902. #define SSB_SPROM8_THERMAL 0x00B2
  2903. -#define SSB_SPROM8_MPWR_RAWTS 0x00B4
  2904. -#define SSB_SPROM8_TS_SLP_OPT_CORRX 0x00B6
  2905. -#define SSB_SPROM8_FOC_HWIQ_IQSWP 0x00B8
  2906. -#define SSB_SPROM8_PHYCAL_TEMPDELTA 0x00BA
  2907. +#define SSB_SPROM8_THERMAL_OFFSET 0x00ff
  2908. +#define SSB_SPROM8_THERMAL_OFFSET_SHIFT 0
  2909. +#define SSB_SPROM8_THERMAL_TRESH 0xff00
  2910. +#define SSB_SPROM8_THERMAL_TRESH_SHIFT 8
  2911. +/* Temp sense related entries */
  2912. +#define SSB_SPROM8_RAWTS 0x00B4
  2913. +#define SSB_SPROM8_RAWTS_RAWTEMP 0x01ff
  2914. +#define SSB_SPROM8_RAWTS_RAWTEMP_SHIFT 0
  2915. +#define SSB_SPROM8_RAWTS_MEASPOWER 0xfe00
  2916. +#define SSB_SPROM8_RAWTS_MEASPOWER_SHIFT 9
  2917. +#define SSB_SPROM8_OPT_CORRX 0x00B6
  2918. +#define SSB_SPROM8_OPT_CORRX_TEMP_SLOPE 0x00ff
  2919. +#define SSB_SPROM8_OPT_CORRX_TEMP_SLOPE_SHIFT 0
  2920. +#define SSB_SPROM8_OPT_CORRX_TEMPCORRX 0xfc00
  2921. +#define SSB_SPROM8_OPT_CORRX_TEMPCORRX_SHIFT 10
  2922. +#define SSB_SPROM8_OPT_CORRX_TEMP_OPTION 0x0300
  2923. +#define SSB_SPROM8_OPT_CORRX_TEMP_OPTION_SHIFT 8
  2924. +/* FOC: freiquency offset correction, HWIQ: H/W IOCAL enable, IQSWP: IQ CAL swap disable */
  2925. +#define SSB_SPROM8_HWIQ_IQSWP 0x00B8
  2926. +#define SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR 0x000f
  2927. +#define SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR_SHIFT 0
  2928. +#define SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP 0x0010
  2929. +#define SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP_SHIFT 4
  2930. +#define SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL 0x0020
  2931. +#define SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL_SHIFT 5
  2932. +#define SSB_SPROM8_TEMPDELTA 0x00BC
  2933. +#define SSB_SPROM8_TEMPDELTA_PHYCAL 0x00ff
  2934. +#define SSB_SPROM8_TEMPDELTA_PHYCAL_SHIFT 0
  2935. +#define SSB_SPROM8_TEMPDELTA_PERIOD 0x0f00
  2936. +#define SSB_SPROM8_TEMPDELTA_PERIOD_SHIFT 8
  2937. +#define SSB_SPROM8_TEMPDELTA_HYSTERESIS 0xf000
  2938. +#define SSB_SPROM8_TEMPDELTA_HYSTERESIS_SHIFT 12
  2939. +
  2940. +/* There are 4 blocks with power info sharing the same layout */
  2941. +#define SSB_SROM8_PWR_INFO_CORE0 0x00C0
  2942. +#define SSB_SROM8_PWR_INFO_CORE1 0x00E0
  2943. +#define SSB_SROM8_PWR_INFO_CORE2 0x0100
  2944. +#define SSB_SROM8_PWR_INFO_CORE3 0x0120
  2945. +
  2946. +#define SSB_SROM8_2G_MAXP_ITSSI 0x00
  2947. +#define SSB_SPROM8_2G_MAXP 0x00FF
  2948. +#define SSB_SPROM8_2G_ITSSI 0xFF00
  2949. +#define SSB_SPROM8_2G_ITSSI_SHIFT 8
  2950. +#define SSB_SROM8_2G_PA_0 0x02 /* 2GHz power amp settings */
  2951. +#define SSB_SROM8_2G_PA_1 0x04
  2952. +#define SSB_SROM8_2G_PA_2 0x06
  2953. +#define SSB_SROM8_5G_MAXP_ITSSI 0x08 /* 5GHz ITSSI and 5.3GHz Max Power */
  2954. +#define SSB_SPROM8_5G_MAXP 0x00FF
  2955. +#define SSB_SPROM8_5G_ITSSI 0xFF00
  2956. +#define SSB_SPROM8_5G_ITSSI_SHIFT 8
  2957. +#define SSB_SPROM8_5GHL_MAXP 0x0A /* 5.2GHz and 5.8GHz Max Power */
  2958. +#define SSB_SPROM8_5GH_MAXP 0x00FF
  2959. +#define SSB_SPROM8_5GL_MAXP 0xFF00
  2960. +#define SSB_SPROM8_5GL_MAXP_SHIFT 8
  2961. +#define SSB_SROM8_5G_PA_0 0x0C /* 5.3GHz power amp settings */
  2962. +#define SSB_SROM8_5G_PA_1 0x0E
  2963. +#define SSB_SROM8_5G_PA_2 0x10
  2964. +#define SSB_SROM8_5GL_PA_0 0x12 /* 5.2GHz power amp settings */
  2965. +#define SSB_SROM8_5GL_PA_1 0x14
  2966. +#define SSB_SROM8_5GL_PA_2 0x16
  2967. +#define SSB_SROM8_5GH_PA_0 0x18 /* 5.8GHz power amp settings */
  2968. +#define SSB_SROM8_5GH_PA_1 0x1A
  2969. +#define SSB_SROM8_5GH_PA_2 0x1C
  2970. +
  2971. +/* TODO: Make it deprecated */
  2972. #define SSB_SPROM8_MAXP_BG 0x00C0 /* Max Power 2GHz in path 1 */
  2973. #define SSB_SPROM8_MAXP_BG_MASK 0x00FF /* Mask for Max Power 2GHz */
  2974. #define SSB_SPROM8_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */
  2975. @@ -473,12 +550,23 @@
  2976. #define SSB_SPROM8_PA1HIB0 0x00D8 /* 5.8GHz power amp settings */
  2977. #define SSB_SPROM8_PA1HIB1 0x00DA
  2978. #define SSB_SPROM8_PA1HIB2 0x00DC
  2979. +
  2980. #define SSB_SPROM8_CCK2GPO 0x0140 /* CCK power offset */
  2981. #define SSB_SPROM8_OFDM2GPO 0x0142 /* 2.4GHz OFDM power offset */
  2982. #define SSB_SPROM8_OFDM5GPO 0x0146 /* 5.3GHz OFDM power offset */
  2983. #define SSB_SPROM8_OFDM5GLPO 0x014A /* 5.2GHz OFDM power offset */
  2984. #define SSB_SPROM8_OFDM5GHPO 0x014E /* 5.8GHz OFDM power offset */
  2985. +#define SSB_SPROM8_2G_MCSPO 0x0152
  2986. +#define SSB_SPROM8_5G_MCSPO 0x0162
  2987. +#define SSB_SPROM8_5GL_MCSPO 0x0172
  2988. +#define SSB_SPROM8_5GH_MCSPO 0x0182
  2989. +
  2990. +#define SSB_SPROM8_CDDPO 0x0192
  2991. +#define SSB_SPROM8_STBCPO 0x0194
  2992. +#define SSB_SPROM8_BW40PO 0x0196
  2993. +#define SSB_SPROM8_BWDUPPO 0x0198
  2994. +
  2995. /* Values for boardflags_lo read from SPROM */
  2996. #define SSB_BFL_BTCOEXIST 0x0001 /* implements Bluetooth coexistance */
  2997. #define SSB_BFL_PACTRL 0x0002 /* GPIO 9 controlling the PA */
  2998. --- /dev/null
  2999. +++ b/include/linux/bcm47xx_wdt.h
  3000. @@ -0,0 +1,19 @@
  3001. +#ifndef LINUX_BCM47XX_WDT_H_
  3002. +#define LINUX_BCM47XX_WDT_H_
  3003. +
  3004. +#include <linux/types.h>
  3005. +
  3006. +
  3007. +struct bcm47xx_wdt {
  3008. + u32 (*timer_set)(struct bcm47xx_wdt *, u32);
  3009. + u32 (*timer_set_ms)(struct bcm47xx_wdt *, u32);
  3010. + u32 max_timer_ms;
  3011. +
  3012. + void *driver_data;
  3013. +};
  3014. +
  3015. +static inline void *bcm47xx_wdt_get_drvdata(struct bcm47xx_wdt *wdt)
  3016. +{
  3017. + return wdt->driver_data;
  3018. +}
  3019. +#endif /* LINUX_BCM47XX_WDT_H_ */
  3020. --- a/drivers/net/wireless/b43/phy_n.c
  3021. +++ b/drivers/net/wireless/b43/phy_n.c
  3022. @@ -4259,7 +4259,8 @@ static void b43_nphy_pmu_spur_avoid(stru
  3023. #endif
  3024. #ifdef CONFIG_B43_SSB
  3025. case B43_BUS_SSB:
  3026. - /* FIXME */
  3027. + ssb_pmu_spuravoid_pllupdate(&dev->dev->sdev->bus->chipco,
  3028. + avoid);
  3029. break;
  3030. #endif
  3031. }