025-bcma_backport.patch 160 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923
  1. --- a/drivers/bcma/Kconfig
  2. +++ b/drivers/bcma/Kconfig
  3. @@ -29,7 +29,7 @@ config BCMA_HOST_PCI
  4. config BCMA_DRIVER_PCI_HOSTMODE
  5. bool "Driver for PCI core working in hostmode"
  6. - depends on BCMA && MIPS
  7. + depends on BCMA && MIPS && BCMA_HOST_PCI
  8. help
  9. PCI core hostmode operation (external PCI bus).
  10. @@ -46,6 +46,33 @@ config BCMA_DRIVER_MIPS
  11. If unsure, say N
  12. +config BCMA_SFLASH
  13. + bool
  14. + depends on BCMA_DRIVER_MIPS
  15. + default y
  16. +
  17. +config BCMA_NFLASH
  18. + bool
  19. + depends on BCMA_DRIVER_MIPS
  20. + default y
  21. +
  22. +config BCMA_DRIVER_GMAC_CMN
  23. + bool "BCMA Broadcom GBIT MAC COMMON core driver"
  24. + depends on BCMA
  25. + help
  26. + Driver for the Broadcom GBIT MAC COMMON core attached to Broadcom
  27. + specific Advanced Microcontroller Bus.
  28. +
  29. + If unsure, say N
  30. +
  31. +config BCMA_DRIVER_GPIO
  32. + bool "BCMA GPIO driver"
  33. + depends on BCMA && GPIOLIB
  34. + help
  35. + Driver to provide access to the GPIO pins of the bcma bus.
  36. +
  37. + If unsure, say N
  38. +
  39. config BCMA_DEBUG
  40. bool "BCMA debugging"
  41. depends on BCMA
  42. --- a/drivers/bcma/Makefile
  43. +++ b/drivers/bcma/Makefile
  44. @@ -1,8 +1,12 @@
  45. bcma-y += main.o scan.o core.o sprom.o
  46. bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
  47. +bcma-$(CONFIG_BCMA_SFLASH) += driver_chipcommon_sflash.o
  48. +bcma-$(CONFIG_BCMA_NFLASH) += driver_chipcommon_nflash.o
  49. bcma-y += driver_pci.o
  50. bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
  51. bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
  52. +bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o
  53. +bcma-$(CONFIG_BCMA_DRIVER_GPIO) += driver_gpio.o
  54. bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
  55. bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
  56. obj-$(CONFIG_BCMA) += bcma.o
  57. --- a/drivers/bcma/bcma_private.h
  58. +++ b/drivers/bcma/bcma_private.h
  59. @@ -10,10 +10,19 @@
  60. #define BCMA_CORE_SIZE 0x1000
  61. +#define bcma_err(bus, fmt, ...) \
  62. + pr_err("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
  63. +#define bcma_warn(bus, fmt, ...) \
  64. + pr_warn("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
  65. +#define bcma_info(bus, fmt, ...) \
  66. + pr_info("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
  67. +#define bcma_debug(bus, fmt, ...) \
  68. + pr_debug("bus%d: " fmt, (bus)->num, ##__VA_ARGS__)
  69. +
  70. struct bcma_bus;
  71. /* main.c */
  72. -int bcma_bus_register(struct bcma_bus *bus);
  73. +int __devinit bcma_bus_register(struct bcma_bus *bus);
  74. void bcma_bus_unregister(struct bcma_bus *bus);
  75. int __init bcma_bus_early_register(struct bcma_bus *bus,
  76. struct bcma_device *core_cc,
  77. @@ -22,6 +31,8 @@ int __init bcma_bus_early_register(struc
  78. int bcma_bus_suspend(struct bcma_bus *bus);
  79. int bcma_bus_resume(struct bcma_bus *bus);
  80. #endif
  81. +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
  82. + u8 unit);
  83. /* scan.c */
  84. int bcma_bus_scan(struct bcma_bus *bus);
  85. @@ -39,8 +50,32 @@ void bcma_chipco_serial_init(struct bcma
  86. #endif /* CONFIG_BCMA_DRIVER_MIPS */
  87. /* driver_chipcommon_pmu.c */
  88. -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc);
  89. -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc);
  90. +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
  91. +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
  92. +
  93. +#ifdef CONFIG_BCMA_SFLASH
  94. +/* driver_chipcommon_sflash.c */
  95. +int bcma_sflash_init(struct bcma_drv_cc *cc);
  96. +extern struct platform_device bcma_sflash_dev;
  97. +#else
  98. +static inline int bcma_sflash_init(struct bcma_drv_cc *cc)
  99. +{
  100. + bcma_err(cc->core->bus, "Serial flash not supported\n");
  101. + return 0;
  102. +}
  103. +#endif /* CONFIG_BCMA_SFLASH */
  104. +
  105. +#ifdef CONFIG_BCMA_NFLASH
  106. +/* driver_chipcommon_nflash.c */
  107. +int bcma_nflash_init(struct bcma_drv_cc *cc);
  108. +extern struct platform_device bcma_nflash_dev;
  109. +#else
  110. +static inline int bcma_nflash_init(struct bcma_drv_cc *cc)
  111. +{
  112. + bcma_err(cc->core->bus, "NAND flash not supported\n");
  113. + return 0;
  114. +}
  115. +#endif /* CONFIG_BCMA_NFLASH */
  116. #ifdef CONFIG_BCMA_HOST_PCI
  117. /* host_pci.c */
  118. @@ -48,8 +83,24 @@ extern int __init bcma_host_pci_init(voi
  119. extern void __exit bcma_host_pci_exit(void);
  120. #endif /* CONFIG_BCMA_HOST_PCI */
  121. +/* driver_pci.c */
  122. +u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
  123. +
  124. +extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
  125. +
  126. #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
  127. -void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
  128. +bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
  129. +void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
  130. #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
  131. +#ifdef CONFIG_BCMA_DRIVER_GPIO
  132. +/* driver_gpio.c */
  133. +int bcma_gpio_init(struct bcma_drv_cc *cc);
  134. +#else
  135. +static inline int bcma_gpio_init(struct bcma_drv_cc *cc)
  136. +{
  137. + return -ENOTSUPP;
  138. +}
  139. +#endif /* CONFIG_BCMA_DRIVER_GPIO */
  140. +
  141. #endif
  142. --- a/drivers/bcma/core.c
  143. +++ b/drivers/bcma/core.c
  144. @@ -30,6 +30,7 @@ void bcma_core_disable(struct bcma_devic
  145. udelay(10);
  146. bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
  147. + bcma_aread32(core, BCMA_RESET_CTL);
  148. udelay(1);
  149. }
  150. EXPORT_SYMBOL_GPL(bcma_core_disable);
  151. @@ -64,7 +65,7 @@ void bcma_core_set_clockmode(struct bcma
  152. switch (clkmode) {
  153. case BCMA_CLKMODE_FAST:
  154. bcma_set32(core, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
  155. - udelay(64);
  156. + usleep_range(64, 300);
  157. for (i = 0; i < 1500; i++) {
  158. if (bcma_read32(core, BCMA_CLKCTLST) &
  159. BCMA_CLKCTLST_HAVEHT) {
  160. @@ -74,10 +75,10 @@ void bcma_core_set_clockmode(struct bcma
  161. udelay(10);
  162. }
  163. if (i)
  164. - pr_err("HT force timeout\n");
  165. + bcma_err(core->bus, "HT force timeout\n");
  166. break;
  167. case BCMA_CLKMODE_DYNAMIC:
  168. - pr_warn("Dynamic clockmode not supported yet!\n");
  169. + bcma_set32(core, BCMA_CLKCTLST, ~BCMA_CLKCTLST_FORCEHT);
  170. break;
  171. }
  172. }
  173. @@ -101,9 +102,9 @@ void bcma_core_pll_ctl(struct bcma_devic
  174. udelay(10);
  175. }
  176. if (i)
  177. - pr_err("PLL enable timeout\n");
  178. + bcma_err(core->bus, "PLL enable timeout\n");
  179. } else {
  180. - pr_warn("Disabling PLL not supported yet!\n");
  181. + bcma_warn(core->bus, "Disabling PLL not supported yet!\n");
  182. }
  183. }
  184. EXPORT_SYMBOL_GPL(bcma_core_pll_ctl);
  185. @@ -119,8 +120,8 @@ u32 bcma_core_dma_translation(struct bcm
  186. else
  187. return BCMA_DMA_TRANSLATION_DMA32_CMT;
  188. default:
  189. - pr_err("DMA translation unknown for host %d\n",
  190. - core->bus->hosttype);
  191. + bcma_err(core->bus, "DMA translation unknown for host %d\n",
  192. + core->bus->hosttype);
  193. }
  194. return BCMA_DMA_TRANSLATION_NONE;
  195. }
  196. --- a/drivers/bcma/driver_chipcommon.c
  197. +++ b/drivers/bcma/driver_chipcommon.c
  198. @@ -4,12 +4,15 @@
  199. *
  200. * Copyright 2005, Broadcom Corporation
  201. * Copyright 2006, 2007, Michael Buesch <[email protected]>
  202. + * Copyright 2012, Hauke Mehrtens <[email protected]>
  203. *
  204. * Licensed under the GNU/GPL. See COPYING for details.
  205. */
  206. #include "bcma_private.h"
  207. +#include <linux/bcm47xx_wdt.h>
  208. #include <linux/export.h>
  209. +#include <linux/platform_device.h>
  210. #include <linux/bcma/bcma.h>
  211. static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
  212. @@ -22,20 +25,120 @@ static inline u32 bcma_cc_write32_masked
  213. return value;
  214. }
  215. -void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
  216. +u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc)
  217. {
  218. - u32 leddc_on = 10;
  219. - u32 leddc_off = 90;
  220. + if (cc->capabilities & BCMA_CC_CAP_PMU)
  221. + return bcma_pmu_get_alp_clock(cc);
  222. - if (cc->setup_done)
  223. + return 20000000;
  224. +}
  225. +EXPORT_SYMBOL_GPL(bcma_chipco_get_alp_clock);
  226. +
  227. +static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
  228. +{
  229. + struct bcma_bus *bus = cc->core->bus;
  230. + u32 nb;
  231. +
  232. + if (cc->capabilities & BCMA_CC_CAP_PMU) {
  233. + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
  234. + nb = 32;
  235. + else if (cc->core->id.rev < 26)
  236. + nb = 16;
  237. + else
  238. + nb = (cc->core->id.rev >= 37) ? 32 : 24;
  239. + } else {
  240. + nb = 28;
  241. + }
  242. + if (nb == 32)
  243. + return 0xffffffff;
  244. + else
  245. + return (1 << nb) - 1;
  246. +}
  247. +
  248. +static u32 bcma_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
  249. + u32 ticks)
  250. +{
  251. + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
  252. +
  253. + return bcma_chipco_watchdog_timer_set(cc, ticks);
  254. +}
  255. +
  256. +static u32 bcma_chipco_watchdog_timer_set_ms_wdt(struct bcm47xx_wdt *wdt,
  257. + u32 ms)
  258. +{
  259. + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
  260. + u32 ticks;
  261. +
  262. + ticks = bcma_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms);
  263. + return ticks / cc->ticks_per_ms;
  264. +}
  265. +
  266. +static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc)
  267. +{
  268. + struct bcma_bus *bus = cc->core->bus;
  269. +
  270. + if (cc->capabilities & BCMA_CC_CAP_PMU) {
  271. + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
  272. + /* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP clock */
  273. + return bcma_chipco_get_alp_clock(cc) / 4000;
  274. + else
  275. + /* based on 32KHz ILP clock */
  276. + return 32;
  277. + } else {
  278. + return bcma_chipco_get_alp_clock(cc) / 1000;
  279. + }
  280. +}
  281. +
  282. +int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc)
  283. +{
  284. + struct bcm47xx_wdt wdt = {};
  285. + struct platform_device *pdev;
  286. +
  287. + wdt.driver_data = cc;
  288. + wdt.timer_set = bcma_chipco_watchdog_timer_set_wdt;
  289. + wdt.timer_set_ms = bcma_chipco_watchdog_timer_set_ms_wdt;
  290. + wdt.max_timer_ms = bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
  291. +
  292. + pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
  293. + cc->core->bus->num, &wdt,
  294. + sizeof(wdt));
  295. + if (IS_ERR(pdev))
  296. + return PTR_ERR(pdev);
  297. +
  298. + cc->watchdog = pdev;
  299. +
  300. + return 0;
  301. +}
  302. +
  303. +void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
  304. +{
  305. + if (cc->early_setup_done)
  306. return;
  307. + spin_lock_init(&cc->gpio_lock);
  308. +
  309. if (cc->core->id.rev >= 11)
  310. cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
  311. cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP);
  312. if (cc->core->id.rev >= 35)
  313. cc->capabilities_ext = bcma_cc_read32(cc, BCMA_CC_CAP_EXT);
  314. + if (cc->capabilities & BCMA_CC_CAP_PMU)
  315. + bcma_pmu_early_init(cc);
  316. +
  317. + cc->early_setup_done = true;
  318. +}
  319. +
  320. +void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
  321. +{
  322. + u32 leddc_on = 10;
  323. + u32 leddc_off = 90;
  324. +
  325. + if (cc->setup_done)
  326. + return;
  327. +
  328. + bcma_core_chipcommon_early_init(cc);
  329. +
  330. if (cc->core->id.rev >= 20) {
  331. bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, 0);
  332. bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, 0);
  333. @@ -44,7 +147,7 @@ void bcma_core_chipcommon_init(struct bc
  334. if (cc->capabilities & BCMA_CC_CAP_PMU)
  335. bcma_pmu_init(cc);
  336. if (cc->capabilities & BCMA_CC_CAP_PCTL)
  337. - pr_err("Power control not implemented!\n");
  338. + bcma_err(cc->core->bus, "Power control not implemented!\n");
  339. if (cc->core->id.rev >= 16) {
  340. if (cc->core->bus->sprom.leddc_on_time &&
  341. @@ -56,15 +159,33 @@ void bcma_core_chipcommon_init(struct bc
  342. ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
  343. (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
  344. }
  345. + cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc);
  346. cc->setup_done = true;
  347. }
  348. /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
  349. -void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
  350. +u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
  351. {
  352. - /* instant NMI */
  353. - bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
  354. + u32 maxt;
  355. + enum bcma_clkmode clkmode;
  356. +
  357. + maxt = bcma_chipco_watchdog_get_max_timer(cc);
  358. + if (cc->capabilities & BCMA_CC_CAP_PMU) {
  359. + if (ticks == 1)
  360. + ticks = 2;
  361. + else if (ticks > maxt)
  362. + ticks = maxt;
  363. + bcma_cc_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks);
  364. + } else {
  365. + clkmode = ticks ? BCMA_CLKMODE_FAST : BCMA_CLKMODE_DYNAMIC;
  366. + bcma_core_set_clockmode(cc->core, clkmode);
  367. + if (ticks > maxt)
  368. + ticks = maxt;
  369. + /* instant NMI */
  370. + bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
  371. + }
  372. + return ticks;
  373. }
  374. void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value)
  375. @@ -84,28 +205,99 @@ u32 bcma_chipco_gpio_in(struct bcma_drv_
  376. u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value)
  377. {
  378. - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
  379. + unsigned long flags;
  380. + u32 res;
  381. +
  382. + spin_lock_irqsave(&cc->gpio_lock, flags);
  383. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
  384. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  385. +
  386. + return res;
  387. }
  388. +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_out);
  389. u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value)
  390. {
  391. - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
  392. + unsigned long flags;
  393. + u32 res;
  394. +
  395. + spin_lock_irqsave(&cc->gpio_lock, flags);
  396. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
  397. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  398. +
  399. + return res;
  400. }
  401. +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_outen);
  402. +/*
  403. + * If the bit is set to 0, chipcommon controlls this GPIO,
  404. + * if the bit is set to 1, it is used by some part of the chip and not our code.
  405. + */
  406. u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value)
  407. {
  408. - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
  409. + unsigned long flags;
  410. + u32 res;
  411. +
  412. + spin_lock_irqsave(&cc->gpio_lock, flags);
  413. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
  414. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  415. +
  416. + return res;
  417. }
  418. EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control);
  419. u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value)
  420. {
  421. - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
  422. + unsigned long flags;
  423. + u32 res;
  424. +
  425. + spin_lock_irqsave(&cc->gpio_lock, flags);
  426. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
  427. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  428. +
  429. + return res;
  430. }
  431. u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value)
  432. {
  433. - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
  434. + unsigned long flags;
  435. + u32 res;
  436. +
  437. + spin_lock_irqsave(&cc->gpio_lock, flags);
  438. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
  439. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  440. +
  441. + return res;
  442. +}
  443. +
  444. +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value)
  445. +{
  446. + unsigned long flags;
  447. + u32 res;
  448. +
  449. + if (cc->core->id.rev < 20)
  450. + return 0;
  451. +
  452. + spin_lock_irqsave(&cc->gpio_lock, flags);
  453. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLUP, mask, value);
  454. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  455. +
  456. + return res;
  457. +}
  458. +
  459. +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value)
  460. +{
  461. + unsigned long flags;
  462. + u32 res;
  463. +
  464. + if (cc->core->id.rev < 20)
  465. + return 0;
  466. +
  467. + spin_lock_irqsave(&cc->gpio_lock, flags);
  468. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLDOWN, mask, value);
  469. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  470. +
  471. + return res;
  472. }
  473. #ifdef CONFIG_BCMA_DRIVER_MIPS
  474. @@ -118,8 +310,7 @@ void bcma_chipco_serial_init(struct bcma
  475. struct bcma_serial_port *ports = cc->serial_ports;
  476. if (ccrev >= 11 && ccrev != 15) {
  477. - /* Fixed ALP clock */
  478. - baud_base = bcma_pmu_alp_clock(cc);
  479. + baud_base = bcma_chipco_get_alp_clock(cc);
  480. if (ccrev >= 21) {
  481. /* Turn off UART clock before switching clocksource. */
  482. bcma_cc_write32(cc, BCMA_CC_CORECTL,
  483. @@ -137,8 +328,7 @@ void bcma_chipco_serial_init(struct bcma
  484. | BCMA_CC_CORECTL_UARTCLKEN);
  485. }
  486. } else {
  487. - pr_err("serial not supported on this device ccrev: 0x%x\n",
  488. - ccrev);
  489. + bcma_err(cc->core->bus, "serial not supported on this device ccrev: 0x%x\n", ccrev);
  490. return;
  491. }
  492. --- /dev/null
  493. +++ b/drivers/bcma/driver_chipcommon_nflash.c
  494. @@ -0,0 +1,44 @@
  495. +/*
  496. + * Broadcom specific AMBA
  497. + * ChipCommon NAND flash interface
  498. + *
  499. + * Licensed under the GNU/GPL. See COPYING for details.
  500. + */
  501. +
  502. +#include <linux/platform_device.h>
  503. +#include <linux/bcma/bcma.h>
  504. +
  505. +#include "bcma_private.h"
  506. +
  507. +struct platform_device bcma_nflash_dev = {
  508. + .name = "bcma_nflash",
  509. + .num_resources = 0,
  510. +};
  511. +
  512. +/* Initialize NAND flash access */
  513. +int bcma_nflash_init(struct bcma_drv_cc *cc)
  514. +{
  515. + struct bcma_bus *bus = cc->core->bus;
  516. +
  517. + if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
  518. + cc->core->id.rev != 0x38) {
  519. + bcma_err(bus, "NAND flash on unsupported board!\n");
  520. + return -ENOTSUPP;
  521. + }
  522. +
  523. + if (!(cc->capabilities & BCMA_CC_CAP_NFLASH)) {
  524. + bcma_err(bus, "NAND flash not present according to ChipCommon\n");
  525. + return -ENODEV;
  526. + }
  527. +
  528. + cc->nflash.present = true;
  529. + if (cc->core->id.rev == 38 &&
  530. + (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT))
  531. + cc->nflash.boot = true;
  532. +
  533. + /* Prepare platform device, but don't register it yet. It's too early,
  534. + * malloc (required by device_private_init) is not available yet. */
  535. + bcma_nflash_dev.dev.platform_data = &cc->nflash;
  536. +
  537. + return 0;
  538. +}
  539. --- a/drivers/bcma/driver_chipcommon_pmu.c
  540. +++ b/drivers/bcma/driver_chipcommon_pmu.c
  541. @@ -3,7 +3,8 @@
  542. * ChipCommon Power Management Unit driver
  543. *
  544. * Copyright 2009, Michael Buesch <[email protected]>
  545. - * Copyright 2007, Broadcom Corporation
  546. + * Copyright 2007, 2011, Broadcom Corporation
  547. + * Copyright 2011, 2012, Hauke Mehrtens <[email protected]>
  548. *
  549. * Licensed under the GNU/GPL. See COPYING for details.
  550. */
  551. @@ -12,12 +13,13 @@
  552. #include <linux/export.h>
  553. #include <linux/bcma/bcma.h>
  554. -static u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
  555. +u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
  556. {
  557. bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
  558. bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
  559. return bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
  560. }
  561. +EXPORT_SYMBOL_GPL(bcma_chipco_pll_read);
  562. void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
  563. {
  564. @@ -54,38 +56,19 @@ void bcma_chipco_regctl_maskset(struct b
  565. }
  566. EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
  567. -static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
  568. -{
  569. - struct bcma_bus *bus = cc->core->bus;
  570. -
  571. - switch (bus->chipinfo.id) {
  572. - case 0x4313:
  573. - case 0x4331:
  574. - case 43224:
  575. - case 43225:
  576. - break;
  577. - default:
  578. - pr_err("PLL init unknown for device 0x%04X\n",
  579. - bus->chipinfo.id);
  580. - }
  581. -}
  582. -
  583. static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
  584. {
  585. struct bcma_bus *bus = cc->core->bus;
  586. u32 min_msk = 0, max_msk = 0;
  587. switch (bus->chipinfo.id) {
  588. - case 0x4313:
  589. + case BCMA_CHIP_ID_BCM4313:
  590. min_msk = 0x200D;
  591. max_msk = 0xFFFF;
  592. break;
  593. - case 43224:
  594. - case 43225:
  595. - break;
  596. default:
  597. - pr_err("PMU resource config unknown for device 0x%04X\n",
  598. - bus->chipinfo.id);
  599. + bcma_debug(bus, "PMU resource config unknown or not needed for device 0x%04X\n",
  600. + bus->chipinfo.id);
  601. }
  602. /* Set the resource masks. */
  603. @@ -93,22 +76,12 @@ static void bcma_pmu_resources_init(stru
  604. bcma_cc_write32(cc, BCMA_CC_PMU_MINRES_MSK, min_msk);
  605. if (max_msk)
  606. bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
  607. -}
  608. -
  609. -void bcma_pmu_swreg_init(struct bcma_drv_cc *cc)
  610. -{
  611. - struct bcma_bus *bus = cc->core->bus;
  612. - switch (bus->chipinfo.id) {
  613. - case 0x4313:
  614. - case 0x4331:
  615. - case 43224:
  616. - case 43225:
  617. - break;
  618. - default:
  619. - pr_err("PMU switch/regulators init unknown for device "
  620. - "0x%04X\n", bus->chipinfo.id);
  621. - }
  622. + /*
  623. + * Add some delay; allow resources to come up and settle.
  624. + * Delay is required for SoC (early init).
  625. + */
  626. + mdelay(2);
  627. }
  628. /* Disable to allow reading SPROM. Don't know the adventages of enabling it. */
  629. @@ -122,51 +95,69 @@ void bcma_chipco_bcm4331_ext_pa_lines_ct
  630. val |= BCMA_CHIPCTL_4331_EXTPA_EN;
  631. if (bus->chipinfo.pkg == 9 || bus->chipinfo.pkg == 11)
  632. val |= BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
  633. + else if (bus->chipinfo.rev > 0)
  634. + val |= BCMA_CHIPCTL_4331_EXTPA_EN2;
  635. } else {
  636. val &= ~BCMA_CHIPCTL_4331_EXTPA_EN;
  637. + val &= ~BCMA_CHIPCTL_4331_EXTPA_EN2;
  638. val &= ~BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5;
  639. }
  640. bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
  641. }
  642. -void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
  643. +static void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
  644. {
  645. struct bcma_bus *bus = cc->core->bus;
  646. switch (bus->chipinfo.id) {
  647. - case 0x4313:
  648. - bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x7);
  649. + case BCMA_CHIP_ID_BCM4313:
  650. + /* enable 12 mA drive strenth for 4313 and set chipControl
  651. + register bit 1 */
  652. + bcma_chipco_chipctl_maskset(cc, 0,
  653. + ~BCMA_CCTRL_4313_12MA_LED_DRIVE,
  654. + BCMA_CCTRL_4313_12MA_LED_DRIVE);
  655. break;
  656. - case 0x4331:
  657. - /* BCM4331 workaround is SPROM-related, we put it in sprom.c */
  658. + case BCMA_CHIP_ID_BCM4331:
  659. + case BCMA_CHIP_ID_BCM43431:
  660. + /* Ext PA lines must be enabled for tx on BCM4331 */
  661. + bcma_chipco_bcm4331_ext_pa_lines_ctl(cc, true);
  662. break;
  663. - case 43224:
  664. + case BCMA_CHIP_ID_BCM43224:
  665. + case BCMA_CHIP_ID_BCM43421:
  666. + /* enable 12 mA drive strenth for 43224 and set chipControl
  667. + register bit 15 */
  668. if (bus->chipinfo.rev == 0) {
  669. - pr_err("Workarounds for 43224 rev 0 not fully "
  670. - "implemented\n");
  671. - bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x00F000F0);
  672. + bcma_cc_maskset32(cc, BCMA_CC_CHIPCTL,
  673. + ~BCMA_CCTRL_43224_GPIO_TOGGLE,
  674. + BCMA_CCTRL_43224_GPIO_TOGGLE);
  675. + bcma_chipco_chipctl_maskset(cc, 0,
  676. + ~BCMA_CCTRL_43224A0_12MA_LED_DRIVE,
  677. + BCMA_CCTRL_43224A0_12MA_LED_DRIVE);
  678. } else {
  679. - bcma_chipco_chipctl_maskset(cc, 0, ~0, 0xF0);
  680. + bcma_chipco_chipctl_maskset(cc, 0,
  681. + ~BCMA_CCTRL_43224B0_12MA_LED_DRIVE,
  682. + BCMA_CCTRL_43224B0_12MA_LED_DRIVE);
  683. }
  684. break;
  685. - case 43225:
  686. - break;
  687. default:
  688. - pr_err("Workarounds unknown for device 0x%04X\n",
  689. - bus->chipinfo.id);
  690. + bcma_debug(bus, "Workarounds unknown or not needed for device 0x%04X\n",
  691. + bus->chipinfo.id);
  692. }
  693. }
  694. -void bcma_pmu_init(struct bcma_drv_cc *cc)
  695. +void bcma_pmu_early_init(struct bcma_drv_cc *cc)
  696. {
  697. u32 pmucap;
  698. pmucap = bcma_cc_read32(cc, BCMA_CC_PMU_CAP);
  699. cc->pmu.rev = (pmucap & BCMA_CC_PMU_CAP_REVISION);
  700. - pr_debug("Found rev %u PMU (capabilities 0x%08X)\n", cc->pmu.rev,
  701. - pmucap);
  702. + bcma_debug(cc->core->bus, "Found rev %u PMU (capabilities 0x%08X)\n",
  703. + cc->pmu.rev, pmucap);
  704. +}
  705. +void bcma_pmu_init(struct bcma_drv_cc *cc)
  706. +{
  707. if (cc->pmu.rev == 1)
  708. bcma_cc_mask32(cc, BCMA_CC_PMU_CTL,
  709. ~BCMA_CC_PMU_CTL_NOILPONW);
  710. @@ -174,37 +165,47 @@ void bcma_pmu_init(struct bcma_drv_cc *c
  711. bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
  712. BCMA_CC_PMU_CTL_NOILPONW);
  713. - if (cc->core->id.id == 0x4329 && cc->core->id.rev == 2)
  714. - pr_err("Fix for 4329b0 bad LPOM state not implemented!\n");
  715. -
  716. - bcma_pmu_pll_init(cc);
  717. bcma_pmu_resources_init(cc);
  718. - bcma_pmu_swreg_init(cc);
  719. bcma_pmu_workarounds(cc);
  720. }
  721. -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
  722. +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc)
  723. {
  724. struct bcma_bus *bus = cc->core->bus;
  725. switch (bus->chipinfo.id) {
  726. - case 0x4716:
  727. - case 0x4748:
  728. - case 47162:
  729. - case 0x4313:
  730. - case 0x5357:
  731. - case 0x4749:
  732. - case 53572:
  733. + case BCMA_CHIP_ID_BCM4313:
  734. + case BCMA_CHIP_ID_BCM43224:
  735. + case BCMA_CHIP_ID_BCM43225:
  736. + case BCMA_CHIP_ID_BCM43227:
  737. + case BCMA_CHIP_ID_BCM43228:
  738. + case BCMA_CHIP_ID_BCM4331:
  739. + case BCMA_CHIP_ID_BCM43421:
  740. + case BCMA_CHIP_ID_BCM43428:
  741. + case BCMA_CHIP_ID_BCM43431:
  742. + case BCMA_CHIP_ID_BCM4716:
  743. + case BCMA_CHIP_ID_BCM47162:
  744. + case BCMA_CHIP_ID_BCM4748:
  745. + case BCMA_CHIP_ID_BCM4749:
  746. + case BCMA_CHIP_ID_BCM5357:
  747. + case BCMA_CHIP_ID_BCM53572:
  748. + case BCMA_CHIP_ID_BCM6362:
  749. /* always 20Mhz */
  750. return 20000 * 1000;
  751. - case 0x5356:
  752. - case 0x5300:
  753. + case BCMA_CHIP_ID_BCM4706:
  754. + case BCMA_CHIP_ID_BCM5356:
  755. /* always 25Mhz */
  756. return 25000 * 1000;
  757. + case BCMA_CHIP_ID_BCM43460:
  758. + case BCMA_CHIP_ID_BCM4352:
  759. + case BCMA_CHIP_ID_BCM4360:
  760. + if (cc->status & BCMA_CC_CHIPST_4360_XTAL_40MZ)
  761. + return 40000 * 1000;
  762. + else
  763. + return 20000 * 1000;
  764. default:
  765. - pr_warn("No ALP clock specified for %04X device, "
  766. - "pmu rev. %d, using default %d Hz\n",
  767. - bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
  768. + bcma_warn(bus, "No ALP clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
  769. + bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
  770. }
  771. return BCMA_CC_PMU_ALP_CLOCK;
  772. }
  773. @@ -212,7 +213,7 @@ u32 bcma_pmu_alp_clock(struct bcma_drv_c
  774. /* Find the output of the "m" pll divider given pll controls that start with
  775. * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
  776. */
  777. -static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
  778. +static u32 bcma_pmu_pll_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
  779. {
  780. u32 tmp, div, ndiv, p1, p2, fc;
  781. struct bcma_bus *bus = cc->core->bus;
  782. @@ -221,7 +222,8 @@ static u32 bcma_pmu_clock(struct bcma_dr
  783. BUG_ON(!m || m > 4);
  784. - if (bus->chipinfo.id == 0x5357 || bus->chipinfo.id == 0x4749) {
  785. + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
  786. + bus->chipinfo.id == BCMA_CHIP_ID_BCM4749) {
  787. /* Detect failure in clock setting */
  788. tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
  789. if (tmp & 0x40000)
  790. @@ -240,60 +242,95 @@ static u32 bcma_pmu_clock(struct bcma_dr
  791. ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT;
  792. /* Do calculation in Mhz */
  793. - fc = bcma_pmu_alp_clock(cc) / 1000000;
  794. + fc = bcma_pmu_get_alp_clock(cc) / 1000000;
  795. fc = (p1 * ndiv * fc) / p2;
  796. /* Return clock in Hertz */
  797. return (fc / div) * 1000000;
  798. }
  799. +static u32 bcma_pmu_pll_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
  800. +{
  801. + u32 tmp, ndiv, p1div, p2div;
  802. + u32 clock;
  803. +
  804. + BUG_ON(!m || m > 4);
  805. +
  806. + /* Get N, P1 and P2 dividers to determine CPU clock */
  807. + tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PMU6_4706_PROCPLL_OFF);
  808. + ndiv = (tmp & BCMA_CC_PMU6_4706_PROC_NDIV_INT_MASK)
  809. + >> BCMA_CC_PMU6_4706_PROC_NDIV_INT_SHIFT;
  810. + p1div = (tmp & BCMA_CC_PMU6_4706_PROC_P1DIV_MASK)
  811. + >> BCMA_CC_PMU6_4706_PROC_P1DIV_SHIFT;
  812. + p2div = (tmp & BCMA_CC_PMU6_4706_PROC_P2DIV_MASK)
  813. + >> BCMA_CC_PMU6_4706_PROC_P2DIV_SHIFT;
  814. +
  815. + tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
  816. + if (tmp & BCMA_CC_CHIPST_4706_PKG_OPTION)
  817. + /* Low cost bonding: Fixed reference clock 25MHz and m = 4 */
  818. + clock = (25000000 / 4) * ndiv * p2div / p1div;
  819. + else
  820. + /* Fixed reference clock 25MHz and m = 2 */
  821. + clock = (25000000 / 2) * ndiv * p2div / p1div;
  822. +
  823. + if (m == BCMA_CC_PMU5_MAINPLL_SSB)
  824. + clock = clock / 4;
  825. +
  826. + return clock;
  827. +}
  828. +
  829. /* query bus clock frequency for PMU-enabled chipcommon */
  830. -u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
  831. +static u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
  832. {
  833. struct bcma_bus *bus = cc->core->bus;
  834. switch (bus->chipinfo.id) {
  835. - case 0x4716:
  836. - case 0x4748:
  837. - case 47162:
  838. - return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
  839. - BCMA_CC_PMU5_MAINPLL_SSB);
  840. - case 0x5356:
  841. - return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
  842. - BCMA_CC_PMU5_MAINPLL_SSB);
  843. - case 0x5357:
  844. - case 0x4749:
  845. - return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
  846. - BCMA_CC_PMU5_MAINPLL_SSB);
  847. - case 0x5300:
  848. - return bcma_pmu_clock(cc, BCMA_CC_PMU4706_MAINPLL_PLL0,
  849. - BCMA_CC_PMU5_MAINPLL_SSB);
  850. - case 53572:
  851. + case BCMA_CHIP_ID_BCM4716:
  852. + case BCMA_CHIP_ID_BCM4748:
  853. + case BCMA_CHIP_ID_BCM47162:
  854. + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
  855. + BCMA_CC_PMU5_MAINPLL_SSB);
  856. + case BCMA_CHIP_ID_BCM5356:
  857. + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
  858. + BCMA_CC_PMU5_MAINPLL_SSB);
  859. + case BCMA_CHIP_ID_BCM5357:
  860. + case BCMA_CHIP_ID_BCM4749:
  861. + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
  862. + BCMA_CC_PMU5_MAINPLL_SSB);
  863. + case BCMA_CHIP_ID_BCM4706:
  864. + return bcma_pmu_pll_clock_bcm4706(cc,
  865. + BCMA_CC_PMU4706_MAINPLL_PLL0,
  866. + BCMA_CC_PMU5_MAINPLL_SSB);
  867. + case BCMA_CHIP_ID_BCM53572:
  868. return 75000000;
  869. default:
  870. - pr_warn("No backplane clock specified for %04X device, "
  871. - "pmu rev. %d, using default %d Hz\n",
  872. - bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
  873. + bcma_warn(bus, "No bus clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
  874. + bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
  875. }
  876. return BCMA_CC_PMU_HT_CLOCK;
  877. }
  878. /* query cpu clock frequency for PMU-enabled chipcommon */
  879. -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
  880. +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc)
  881. {
  882. struct bcma_bus *bus = cc->core->bus;
  883. - if (bus->chipinfo.id == 53572)
  884. + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572)
  885. return 300000000;
  886. + /* New PMUs can have different clock for bus and CPU */
  887. if (cc->pmu.rev >= 5) {
  888. u32 pll;
  889. switch (bus->chipinfo.id) {
  890. - case 0x5356:
  891. + case BCMA_CHIP_ID_BCM4706:
  892. + return bcma_pmu_pll_clock_bcm4706(cc,
  893. + BCMA_CC_PMU4706_MAINPLL_PLL0,
  894. + BCMA_CC_PMU5_MAINPLL_CPU);
  895. + case BCMA_CHIP_ID_BCM5356:
  896. pll = BCMA_CC_PMU5356_MAINPLL_PLL0;
  897. break;
  898. - case 0x5357:
  899. - case 0x4749:
  900. + case BCMA_CHIP_ID_BCM5357:
  901. + case BCMA_CHIP_ID_BCM4749:
  902. pll = BCMA_CC_PMU5357_MAINPLL_PLL0;
  903. break;
  904. default:
  905. @@ -301,10 +338,189 @@ u32 bcma_pmu_get_clockcpu(struct bcma_dr
  906. break;
  907. }
  908. - /* TODO: if (bus->chipinfo.id == 0x5300)
  909. - return si_4706_pmu_clock(sih, osh, cc, PMU4706_MAINPLL_PLL0, PMU5_MAINPLL_CPU); */
  910. - return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
  911. + return bcma_pmu_pll_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
  912. + }
  913. +
  914. + /* On old PMUs CPU has the same clock as the bus */
  915. + return bcma_pmu_get_bus_clock(cc);
  916. +}
  917. +
  918. +static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset,
  919. + u32 value)
  920. +{
  921. + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
  922. + bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, value);
  923. +}
  924. +
  925. +void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid)
  926. +{
  927. + u32 tmp = 0;
  928. + u8 phypll_offset = 0;
  929. + u8 bcm5357_bcm43236_p1div[] = {0x1, 0x5, 0x5};
  930. + u8 bcm5357_bcm43236_ndiv[] = {0x30, 0xf6, 0xfc};
  931. + struct bcma_bus *bus = cc->core->bus;
  932. +
  933. + switch (bus->chipinfo.id) {
  934. + case BCMA_CHIP_ID_BCM5357:
  935. + case BCMA_CHIP_ID_BCM4749:
  936. + case BCMA_CHIP_ID_BCM53572:
  937. + /* 5357[ab]0, 43236[ab]0, and 6362b0 */
  938. +
  939. + /* BCM5357 needs to touch PLL1_PLLCTL[02],
  940. + so offset PLL0_PLLCTL[02] by 6 */
  941. + phypll_offset = (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
  942. + bus->chipinfo.id == BCMA_CHIP_ID_BCM4749 ||
  943. + bus->chipinfo.id == BCMA_CHIP_ID_BCM53572) ? 6 : 0;
  944. +
  945. + /* RMW only the P1 divider */
  946. + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
  947. + BCMA_CC_PMU_PLL_CTL0 + phypll_offset);
  948. + tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
  949. + tmp &= (~(BCMA_CC_PMU1_PLL0_PC0_P1DIV_MASK));
  950. + tmp |= (bcm5357_bcm43236_p1div[spuravoid] << BCMA_CC_PMU1_PLL0_PC0_P1DIV_SHIFT);
  951. + bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
  952. +
  953. + /* RMW only the int feedback divider */
  954. + bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR,
  955. + BCMA_CC_PMU_PLL_CTL2 + phypll_offset);
  956. + tmp = bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
  957. + tmp &= ~(BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_MASK);
  958. + tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT;
  959. + bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
  960. +
  961. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  962. + break;
  963. +
  964. + case BCMA_CHIP_ID_BCM4331:
  965. + case BCMA_CHIP_ID_BCM43431:
  966. + if (spuravoid == 2) {
  967. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
  968. + 0x11500014);
  969. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
  970. + 0x0FC00a08);
  971. + } else if (spuravoid == 1) {
  972. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
  973. + 0x11500014);
  974. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
  975. + 0x0F600a08);
  976. + } else {
  977. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
  978. + 0x11100014);
  979. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
  980. + 0x03000a08);
  981. + }
  982. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  983. + break;
  984. +
  985. + case BCMA_CHIP_ID_BCM43224:
  986. + case BCMA_CHIP_ID_BCM43225:
  987. + case BCMA_CHIP_ID_BCM43421:
  988. + if (spuravoid == 1) {
  989. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
  990. + 0x11500010);
  991. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
  992. + 0x000C0C06);
  993. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
  994. + 0x0F600a08);
  995. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
  996. + 0x00000000);
  997. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
  998. + 0x2001E920);
  999. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
  1000. + 0x88888815);
  1001. + } else {
  1002. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
  1003. + 0x11100010);
  1004. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
  1005. + 0x000c0c06);
  1006. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
  1007. + 0x03000a08);
  1008. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
  1009. + 0x00000000);
  1010. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
  1011. + 0x200005c0);
  1012. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
  1013. + 0x88888815);
  1014. + }
  1015. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  1016. + break;
  1017. +
  1018. + case BCMA_CHIP_ID_BCM4716:
  1019. + case BCMA_CHIP_ID_BCM4748:
  1020. + case BCMA_CHIP_ID_BCM47162:
  1021. + if (spuravoid == 1) {
  1022. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
  1023. + 0x11500060);
  1024. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
  1025. + 0x080C0C06);
  1026. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
  1027. + 0x0F600000);
  1028. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
  1029. + 0x00000000);
  1030. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
  1031. + 0x2001E924);
  1032. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
  1033. + 0x88888815);
  1034. + } else {
  1035. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
  1036. + 0x11100060);
  1037. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
  1038. + 0x080c0c06);
  1039. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
  1040. + 0x03000000);
  1041. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
  1042. + 0x00000000);
  1043. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
  1044. + 0x200005c0);
  1045. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
  1046. + 0x88888815);
  1047. + }
  1048. +
  1049. + tmp = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW;
  1050. + break;
  1051. +
  1052. + case BCMA_CHIP_ID_BCM43227:
  1053. + case BCMA_CHIP_ID_BCM43228:
  1054. + case BCMA_CHIP_ID_BCM43428:
  1055. + /* LCNXN */
  1056. + /* PLL Settings for spur avoidance on/off mode,
  1057. + no on2 support for 43228A0 */
  1058. + if (spuravoid == 1) {
  1059. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
  1060. + 0x01100014);
  1061. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
  1062. + 0x040C0C06);
  1063. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
  1064. + 0x03140A08);
  1065. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
  1066. + 0x00333333);
  1067. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
  1068. + 0x202C2820);
  1069. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
  1070. + 0x88888815);
  1071. + } else {
  1072. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0,
  1073. + 0x11100014);
  1074. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1,
  1075. + 0x040c0c06);
  1076. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
  1077. + 0x03000a08);
  1078. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3,
  1079. + 0x00000000);
  1080. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4,
  1081. + 0x200005c0);
  1082. + bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
  1083. + 0x88888815);
  1084. + }
  1085. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  1086. + break;
  1087. + default:
  1088. + bcma_err(bus, "Unknown spuravoidance settings for chip 0x%04X, not changing PLL\n",
  1089. + bus->chipinfo.id);
  1090. + break;
  1091. }
  1092. - return bcma_pmu_get_clockcontrol(cc);
  1093. + tmp |= bcma_cc_read32(cc, BCMA_CC_PMU_CTL);
  1094. + bcma_cc_write32(cc, BCMA_CC_PMU_CTL, tmp);
  1095. }
  1096. +EXPORT_SYMBOL_GPL(bcma_pmu_spuravoid_pllupdate);
  1097. --- /dev/null
  1098. +++ b/drivers/bcma/driver_chipcommon_sflash.c
  1099. @@ -0,0 +1,165 @@
  1100. +/*
  1101. + * Broadcom specific AMBA
  1102. + * ChipCommon serial flash interface
  1103. + *
  1104. + * Licensed under the GNU/GPL. See COPYING for details.
  1105. + */
  1106. +
  1107. +#include <linux/platform_device.h>
  1108. +#include <linux/bcma/bcma.h>
  1109. +
  1110. +#include "bcma_private.h"
  1111. +
  1112. +static struct resource bcma_sflash_resource = {
  1113. + .name = "bcma_sflash",
  1114. + .start = BCMA_SOC_FLASH2,
  1115. + .end = 0,
  1116. + .flags = IORESOURCE_MEM | IORESOURCE_READONLY,
  1117. +};
  1118. +
  1119. +struct platform_device bcma_sflash_dev = {
  1120. + .name = "bcma_sflash",
  1121. + .resource = &bcma_sflash_resource,
  1122. + .num_resources = 1,
  1123. +};
  1124. +
  1125. +struct bcma_sflash_tbl_e {
  1126. + char *name;
  1127. + u32 id;
  1128. + u32 blocksize;
  1129. + u16 numblocks;
  1130. +};
  1131. +
  1132. +static struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
  1133. + { "M25P20", 0x11, 0x10000, 4, },
  1134. + { "M25P40", 0x12, 0x10000, 8, },
  1135. +
  1136. + { "M25P16", 0x14, 0x10000, 32, },
  1137. + { "M25P32", 0x15, 0x10000, 64, },
  1138. + { "M25P64", 0x16, 0x10000, 128, },
  1139. + { "M25FL128", 0x17, 0x10000, 256, },
  1140. + { 0 },
  1141. +};
  1142. +
  1143. +static struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
  1144. + { "SST25WF512", 1, 0x1000, 16, },
  1145. + { "SST25VF512", 0x48, 0x1000, 16, },
  1146. + { "SST25WF010", 2, 0x1000, 32, },
  1147. + { "SST25VF010", 0x49, 0x1000, 32, },
  1148. + { "SST25WF020", 3, 0x1000, 64, },
  1149. + { "SST25VF020", 0x43, 0x1000, 64, },
  1150. + { "SST25WF040", 4, 0x1000, 128, },
  1151. + { "SST25VF040", 0x44, 0x1000, 128, },
  1152. + { "SST25VF040B", 0x8d, 0x1000, 128, },
  1153. + { "SST25WF080", 5, 0x1000, 256, },
  1154. + { "SST25VF080B", 0x8e, 0x1000, 256, },
  1155. + { "SST25VF016", 0x41, 0x1000, 512, },
  1156. + { "SST25VF032", 0x4a, 0x1000, 1024, },
  1157. + { "SST25VF064", 0x4b, 0x1000, 2048, },
  1158. + { 0 },
  1159. +};
  1160. +
  1161. +static struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
  1162. + { "AT45DB011", 0xc, 256, 512, },
  1163. + { "AT45DB021", 0x14, 256, 1024, },
  1164. + { "AT45DB041", 0x1c, 256, 2048, },
  1165. + { "AT45DB081", 0x24, 256, 4096, },
  1166. + { "AT45DB161", 0x2c, 512, 4096, },
  1167. + { "AT45DB321", 0x34, 512, 8192, },
  1168. + { "AT45DB642", 0x3c, 1024, 8192, },
  1169. + { 0 },
  1170. +};
  1171. +
  1172. +static void bcma_sflash_cmd(struct bcma_drv_cc *cc, u32 opcode)
  1173. +{
  1174. + int i;
  1175. + bcma_cc_write32(cc, BCMA_CC_FLASHCTL,
  1176. + BCMA_CC_FLASHCTL_START | opcode);
  1177. + for (i = 0; i < 1000; i++) {
  1178. + if (!(bcma_cc_read32(cc, BCMA_CC_FLASHCTL) &
  1179. + BCMA_CC_FLASHCTL_BUSY))
  1180. + return;
  1181. + cpu_relax();
  1182. + }
  1183. + bcma_err(cc->core->bus, "SFLASH control command failed (timeout)!\n");
  1184. +}
  1185. +
  1186. +/* Initialize serial flash access */
  1187. +int bcma_sflash_init(struct bcma_drv_cc *cc)
  1188. +{
  1189. + struct bcma_bus *bus = cc->core->bus;
  1190. + struct bcma_sflash *sflash = &cc->sflash;
  1191. + struct bcma_sflash_tbl_e *e;
  1192. + u32 id, id2;
  1193. +
  1194. + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
  1195. + case BCMA_CC_FLASHT_STSER:
  1196. + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_DP);
  1197. +
  1198. + bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 0);
  1199. + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
  1200. + id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
  1201. +
  1202. + bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 1);
  1203. + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
  1204. + id2 = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
  1205. +
  1206. + switch (id) {
  1207. + case 0xbf:
  1208. + for (e = bcma_sflash_sst_tbl; e->name; e++) {
  1209. + if (e->id == id2)
  1210. + break;
  1211. + }
  1212. + break;
  1213. + case 0x13:
  1214. + return -ENOTSUPP;
  1215. + default:
  1216. + for (e = bcma_sflash_st_tbl; e->name; e++) {
  1217. + if (e->id == id)
  1218. + break;
  1219. + }
  1220. + break;
  1221. + }
  1222. + if (!e->name) {
  1223. + bcma_err(bus, "Unsupported ST serial flash (id: 0x%X, id2: 0x%X)\n", id, id2);
  1224. + return -ENOTSUPP;
  1225. + }
  1226. +
  1227. + break;
  1228. + case BCMA_CC_FLASHT_ATSER:
  1229. + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_AT_STATUS);
  1230. + id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA) & 0x3c;
  1231. +
  1232. + for (e = bcma_sflash_at_tbl; e->name; e++) {
  1233. + if (e->id == id)
  1234. + break;
  1235. + }
  1236. + if (!e->name) {
  1237. + bcma_err(bus, "Unsupported Atmel serial flash (id: 0x%X)\n", id);
  1238. + return -ENOTSUPP;
  1239. + }
  1240. +
  1241. + break;
  1242. + default:
  1243. + bcma_err(bus, "Unsupported flash type\n");
  1244. + return -ENOTSUPP;
  1245. + }
  1246. +
  1247. + sflash->window = BCMA_SOC_FLASH2;
  1248. + sflash->blocksize = e->blocksize;
  1249. + sflash->numblocks = e->numblocks;
  1250. + sflash->size = sflash->blocksize * sflash->numblocks;
  1251. + sflash->present = true;
  1252. +
  1253. + bcma_info(bus, "Found %s serial flash (size: %dKiB, blocksize: 0x%X, blocks: %d)\n",
  1254. + e->name, sflash->size / 1024, sflash->blocksize,
  1255. + sflash->numblocks);
  1256. +
  1257. + /* Prepare platform device, but don't register it yet. It's too early,
  1258. + * malloc (required by device_private_init) is not available yet. */
  1259. + bcma_sflash_dev.resource[0].end = bcma_sflash_dev.resource[0].start +
  1260. + sflash->size;
  1261. + bcma_sflash_dev.dev.platform_data = sflash;
  1262. +
  1263. + return 0;
  1264. +}
  1265. --- /dev/null
  1266. +++ b/drivers/bcma/driver_gmac_cmn.c
  1267. @@ -0,0 +1,14 @@
  1268. +/*
  1269. + * Broadcom specific AMBA
  1270. + * GBIT MAC COMMON Core
  1271. + *
  1272. + * Licensed under the GNU/GPL. See COPYING for details.
  1273. + */
  1274. +
  1275. +#include "bcma_private.h"
  1276. +#include <linux/bcma/bcma.h>
  1277. +
  1278. +void __devinit bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc)
  1279. +{
  1280. + mutex_init(&gc->phy_mutex);
  1281. +}
  1282. --- /dev/null
  1283. +++ b/drivers/bcma/driver_gpio.c
  1284. @@ -0,0 +1,98 @@
  1285. +/*
  1286. + * Broadcom specific AMBA
  1287. + * GPIO driver
  1288. + *
  1289. + * Copyright 2011, Broadcom Corporation
  1290. + * Copyright 2012, Hauke Mehrtens <[email protected]>
  1291. + *
  1292. + * Licensed under the GNU/GPL. See COPYING for details.
  1293. + */
  1294. +
  1295. +#include <linux/gpio.h>
  1296. +#include <linux/export.h>
  1297. +#include <linux/bcma/bcma.h>
  1298. +
  1299. +#include "bcma_private.h"
  1300. +
  1301. +static inline struct bcma_drv_cc *bcma_gpio_get_cc(struct gpio_chip *chip)
  1302. +{
  1303. + return container_of(chip, struct bcma_drv_cc, gpio);
  1304. +}
  1305. +
  1306. +static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
  1307. +{
  1308. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  1309. +
  1310. + return !!bcma_chipco_gpio_in(cc, 1 << gpio);
  1311. +}
  1312. +
  1313. +static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio,
  1314. + int value)
  1315. +{
  1316. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  1317. +
  1318. + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
  1319. +}
  1320. +
  1321. +static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
  1322. +{
  1323. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  1324. +
  1325. + bcma_chipco_gpio_outen(cc, 1 << gpio, 0);
  1326. + return 0;
  1327. +}
  1328. +
  1329. +static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio,
  1330. + int value)
  1331. +{
  1332. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  1333. +
  1334. + bcma_chipco_gpio_outen(cc, 1 << gpio, 1 << gpio);
  1335. + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
  1336. + return 0;
  1337. +}
  1338. +
  1339. +static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio)
  1340. +{
  1341. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  1342. +
  1343. + bcma_chipco_gpio_control(cc, 1 << gpio, 0);
  1344. + /* clear pulldown */
  1345. + bcma_chipco_gpio_pulldown(cc, 1 << gpio, 0);
  1346. + /* Set pullup */
  1347. + bcma_chipco_gpio_pullup(cc, 1 << gpio, 1 << gpio);
  1348. +
  1349. + return 0;
  1350. +}
  1351. +
  1352. +static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio)
  1353. +{
  1354. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  1355. +
  1356. + /* clear pullup */
  1357. + bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
  1358. +}
  1359. +
  1360. +int bcma_gpio_init(struct bcma_drv_cc *cc)
  1361. +{
  1362. + struct gpio_chip *chip = &cc->gpio;
  1363. +
  1364. + chip->label = "bcma_gpio";
  1365. + chip->owner = THIS_MODULE;
  1366. + chip->request = bcma_gpio_request;
  1367. + chip->free = bcma_gpio_free;
  1368. + chip->get = bcma_gpio_get_value;
  1369. + chip->set = bcma_gpio_set_value;
  1370. + chip->direction_input = bcma_gpio_direction_input;
  1371. + chip->direction_output = bcma_gpio_direction_output;
  1372. + chip->ngpio = 16;
  1373. + /* There is just one SoC in one device and its GPIO addresses should be
  1374. + * deterministic to address them more easily. The other buses could get
  1375. + * a random base number. */
  1376. + if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
  1377. + chip->base = 0;
  1378. + else
  1379. + chip->base = -1;
  1380. +
  1381. + return gpiochip_add(chip);
  1382. +}
  1383. --- a/drivers/bcma/driver_mips.c
  1384. +++ b/drivers/bcma/driver_mips.c
  1385. @@ -22,15 +22,15 @@
  1386. /* The 47162a0 hangs when reading MIPS DMP registers registers */
  1387. static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev)
  1388. {
  1389. - return dev->bus->chipinfo.id == 47162 && dev->bus->chipinfo.rev == 0 &&
  1390. - dev->id.id == BCMA_CORE_MIPS_74K;
  1391. + return dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM47162 &&
  1392. + dev->bus->chipinfo.rev == 0 && dev->id.id == BCMA_CORE_MIPS_74K;
  1393. }
  1394. /* The 5357b0 hangs when reading USB20H DMP registers */
  1395. static inline bool bcma_core_mips_bcm5357b0_quirk(struct bcma_device *dev)
  1396. {
  1397. - return (dev->bus->chipinfo.id == 0x5357 ||
  1398. - dev->bus->chipinfo.id == 0x4749) &&
  1399. + return (dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 ||
  1400. + dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM4749) &&
  1401. dev->bus->chipinfo.pkg == 11 &&
  1402. dev->id.id == BCMA_CORE_USB20_HOST;
  1403. }
  1404. @@ -74,11 +74,16 @@ static u32 bcma_core_mips_irqflag(struct
  1405. return dev->core_index;
  1406. flag = bcma_aread32(dev, BCMA_MIPS_OOBSELOUTA30);
  1407. - return flag & 0x1F;
  1408. + if (flag)
  1409. + return flag & 0x1F;
  1410. + else
  1411. + return 0x3f;
  1412. }
  1413. /* Get the MIPS IRQ assignment for a specified device.
  1414. * If unassigned, 0 is returned.
  1415. + * If disabled, 5 is returned.
  1416. + * If not supported, 6 is returned.
  1417. */
  1418. unsigned int bcma_core_mips_irq(struct bcma_device *dev)
  1419. {
  1420. @@ -87,13 +92,15 @@ unsigned int bcma_core_mips_irq(struct b
  1421. unsigned int irq;
  1422. irqflag = bcma_core_mips_irqflag(dev);
  1423. + if (irqflag == 0x3f)
  1424. + return 6;
  1425. - for (irq = 1; irq <= 4; irq++)
  1426. + for (irq = 0; irq <= 4; irq++)
  1427. if (bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq)) &
  1428. (1 << irqflag))
  1429. return irq;
  1430. - return 0;
  1431. + return 5;
  1432. }
  1433. EXPORT_SYMBOL(bcma_core_mips_irq);
  1434. @@ -114,8 +121,8 @@ static void bcma_core_mips_set_irq(struc
  1435. bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0),
  1436. bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) &
  1437. ~(1 << irqflag));
  1438. - else
  1439. - bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq), 0);
  1440. + else if (oldirq != 5)
  1441. + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(oldirq), 0);
  1442. /* assign the new one */
  1443. if (irq == 0) {
  1444. @@ -123,17 +130,17 @@ static void bcma_core_mips_set_irq(struc
  1445. bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) |
  1446. (1 << irqflag));
  1447. } else {
  1448. - u32 oldirqflag = bcma_read32(mdev,
  1449. - BCMA_MIPS_MIPS74K_INTMASK(irq));
  1450. - if (oldirqflag) {
  1451. + u32 irqinitmask = bcma_read32(mdev,
  1452. + BCMA_MIPS_MIPS74K_INTMASK(irq));
  1453. + if (irqinitmask) {
  1454. struct bcma_device *core;
  1455. /* backplane irq line is in use, find out who uses
  1456. * it and set user to irq 0
  1457. */
  1458. - list_for_each_entry_reverse(core, &bus->cores, list) {
  1459. + list_for_each_entry(core, &bus->cores, list) {
  1460. if ((1 << bcma_core_mips_irqflag(core)) ==
  1461. - oldirqflag) {
  1462. + irqinitmask) {
  1463. bcma_core_mips_set_irq(core, 0);
  1464. break;
  1465. }
  1466. @@ -143,15 +150,31 @@ static void bcma_core_mips_set_irq(struc
  1467. 1 << irqflag);
  1468. }
  1469. - pr_info("set_irq: core 0x%04x, irq %d => %d\n",
  1470. - dev->id.id, oldirq + 2, irq + 2);
  1471. + bcma_debug(bus, "set_irq: core 0x%04x, irq %d => %d\n",
  1472. + dev->id.id, oldirq <= 4 ? oldirq + 2 : 0, irq + 2);
  1473. +}
  1474. +
  1475. +static void bcma_core_mips_set_irq_name(struct bcma_bus *bus, unsigned int irq,
  1476. + u16 coreid, u8 unit)
  1477. +{
  1478. + struct bcma_device *core;
  1479. +
  1480. + core = bcma_find_core_unit(bus, coreid, unit);
  1481. + if (!core) {
  1482. + bcma_warn(bus,
  1483. + "Can not find core (id: 0x%x, unit %i) for IRQ configuration.\n",
  1484. + coreid, unit);
  1485. + return;
  1486. + }
  1487. +
  1488. + bcma_core_mips_set_irq(core, irq);
  1489. }
  1490. static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq)
  1491. {
  1492. int i;
  1493. static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
  1494. - printk(KERN_INFO KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
  1495. + printk(KERN_DEBUG KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
  1496. for (i = 0; i <= 6; i++)
  1497. printk(" %s%s", irq_name[i], i == irq ? "*" : " ");
  1498. printk("\n");
  1499. @@ -161,7 +184,7 @@ static void bcma_core_mips_dump_irq(stru
  1500. {
  1501. struct bcma_device *core;
  1502. - list_for_each_entry_reverse(core, &bus->cores, list) {
  1503. + list_for_each_entry(core, &bus->cores, list) {
  1504. bcma_core_mips_print_irq(core, bcma_core_mips_irq(core));
  1505. }
  1506. }
  1507. @@ -171,9 +194,9 @@ u32 bcma_cpu_clock(struct bcma_drv_mips
  1508. struct bcma_bus *bus = mcore->core->bus;
  1509. if (bus->drv_cc.capabilities & BCMA_CC_CAP_PMU)
  1510. - return bcma_pmu_get_clockcpu(&bus->drv_cc);
  1511. + return bcma_pmu_get_cpu_clock(&bus->drv_cc);
  1512. - pr_err("No PMU available, need this to get the cpu clock\n");
  1513. + bcma_err(bus, "No PMU available, need this to get the cpu clock\n");
  1514. return 0;
  1515. }
  1516. EXPORT_SYMBOL(bcma_cpu_clock);
  1517. @@ -181,76 +204,109 @@ EXPORT_SYMBOL(bcma_cpu_clock);
  1518. static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
  1519. {
  1520. struct bcma_bus *bus = mcore->core->bus;
  1521. + struct bcma_drv_cc *cc = &bus->drv_cc;
  1522. - switch (bus->drv_cc.capabilities & BCMA_CC_CAP_FLASHT) {
  1523. + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
  1524. case BCMA_CC_FLASHT_STSER:
  1525. case BCMA_CC_FLASHT_ATSER:
  1526. - pr_err("Serial flash not supported.\n");
  1527. + bcma_debug(bus, "Found serial flash\n");
  1528. + bcma_sflash_init(cc);
  1529. break;
  1530. case BCMA_CC_FLASHT_PARA:
  1531. - pr_info("found parallel flash.\n");
  1532. - bus->drv_cc.pflash.window = 0x1c000000;
  1533. - bus->drv_cc.pflash.window_size = 0x02000000;
  1534. + bcma_debug(bus, "Found parallel flash\n");
  1535. + cc->pflash.present = true;
  1536. + cc->pflash.window = BCMA_SOC_FLASH2;
  1537. + cc->pflash.window_size = BCMA_SOC_FLASH2_SZ;
  1538. - if ((bcma_read32(bus->drv_cc.core, BCMA_CC_FLASH_CFG) &
  1539. + if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) &
  1540. BCMA_CC_FLASH_CFG_DS) == 0)
  1541. - bus->drv_cc.pflash.buswidth = 1;
  1542. + cc->pflash.buswidth = 1;
  1543. else
  1544. - bus->drv_cc.pflash.buswidth = 2;
  1545. + cc->pflash.buswidth = 2;
  1546. break;
  1547. default:
  1548. - pr_err("flash not supported.\n");
  1549. + bcma_err(bus, "Flash type not supported\n");
  1550. + }
  1551. +
  1552. + if (cc->core->id.rev == 38 ||
  1553. + bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
  1554. + if (cc->capabilities & BCMA_CC_CAP_NFLASH) {
  1555. + bcma_debug(bus, "Found NAND flash\n");
  1556. + bcma_nflash_init(cc);
  1557. + }
  1558. }
  1559. }
  1560. +void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
  1561. +{
  1562. + struct bcma_bus *bus = mcore->core->bus;
  1563. +
  1564. + if (mcore->early_setup_done)
  1565. + return;
  1566. +
  1567. + bcma_chipco_serial_init(&bus->drv_cc);
  1568. + bcma_core_mips_flash_detect(mcore);
  1569. +
  1570. + mcore->early_setup_done = true;
  1571. +}
  1572. +
  1573. void bcma_core_mips_init(struct bcma_drv_mips *mcore)
  1574. {
  1575. struct bcma_bus *bus;
  1576. struct bcma_device *core;
  1577. bus = mcore->core->bus;
  1578. - pr_info("Initializing MIPS core...\n");
  1579. + if (mcore->setup_done)
  1580. + return;
  1581. +
  1582. + bcma_debug(bus, "Initializing MIPS core...\n");
  1583. - if (!mcore->setup_done)
  1584. - mcore->assigned_irqs = 1;
  1585. + bcma_core_mips_early_init(mcore);
  1586. - /* Assign IRQs to all cores on the bus */
  1587. - list_for_each_entry_reverse(core, &bus->cores, list) {
  1588. - int mips_irq;
  1589. - if (core->irq)
  1590. - continue;
  1591. -
  1592. - mips_irq = bcma_core_mips_irq(core);
  1593. - if (mips_irq > 4)
  1594. - core->irq = 0;
  1595. - else
  1596. - core->irq = mips_irq + 2;
  1597. - if (core->irq > 5)
  1598. - continue;
  1599. - switch (core->id.id) {
  1600. - case BCMA_CORE_PCI:
  1601. - case BCMA_CORE_PCIE:
  1602. - case BCMA_CORE_ETHERNET:
  1603. - case BCMA_CORE_ETHERNET_GBIT:
  1604. - case BCMA_CORE_MAC_GBIT:
  1605. - case BCMA_CORE_80211:
  1606. - case BCMA_CORE_USB20_HOST:
  1607. - /* These devices get their own IRQ line if available,
  1608. - * the rest goes on IRQ0
  1609. - */
  1610. - if (mcore->assigned_irqs <= 4)
  1611. - bcma_core_mips_set_irq(core,
  1612. - mcore->assigned_irqs++);
  1613. - break;
  1614. + switch (bus->chipinfo.id) {
  1615. + case BCMA_CHIP_ID_BCM4716:
  1616. + case BCMA_CHIP_ID_BCM4748:
  1617. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
  1618. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
  1619. + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
  1620. + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_PCIE, 0);
  1621. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
  1622. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
  1623. + break;
  1624. + case BCMA_CHIP_ID_BCM5356:
  1625. + case BCMA_CHIP_ID_BCM47162:
  1626. + case BCMA_CHIP_ID_BCM53572:
  1627. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
  1628. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
  1629. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
  1630. + break;
  1631. + case BCMA_CHIP_ID_BCM5357:
  1632. + case BCMA_CHIP_ID_BCM4749:
  1633. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
  1634. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
  1635. + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
  1636. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
  1637. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
  1638. + break;
  1639. + case BCMA_CHIP_ID_BCM4706:
  1640. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_PCIE, 0);
  1641. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_4706_MAC_GBIT,
  1642. + 0);
  1643. + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_PCIE, 1);
  1644. + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_USB20_HOST, 0);
  1645. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_4706_CHIPCOMMON,
  1646. + 0);
  1647. + break;
  1648. + default:
  1649. + list_for_each_entry(core, &bus->cores, list) {
  1650. + core->irq = bcma_core_mips_irq(core) + 2;
  1651. }
  1652. + bcma_err(bus,
  1653. + "Unknown device (0x%x) found, can not configure IRQs\n",
  1654. + bus->chipinfo.id);
  1655. }
  1656. - pr_info("IRQ reconfiguration done\n");
  1657. + bcma_debug(bus, "IRQ reconfiguration done\n");
  1658. bcma_core_mips_dump_irq(bus);
  1659. - if (mcore->setup_done)
  1660. - return;
  1661. -
  1662. - bcma_chipco_serial_init(&bus->drv_cc);
  1663. - bcma_core_mips_flash_detect(mcore);
  1664. mcore->setup_done = true;
  1665. }
  1666. --- a/drivers/bcma/driver_pci.c
  1667. +++ b/drivers/bcma/driver_pci.c
  1668. @@ -2,8 +2,9 @@
  1669. * Broadcom specific AMBA
  1670. * PCI Core
  1671. *
  1672. - * Copyright 2005, Broadcom Corporation
  1673. + * Copyright 2005, 2011, Broadcom Corporation
  1674. * Copyright 2006, 2007, Michael Buesch <[email protected]>
  1675. + * Copyright 2011, 2012, Hauke Mehrtens <[email protected]>
  1676. *
  1677. * Licensed under the GNU/GPL. See COPYING for details.
  1678. */
  1679. @@ -16,120 +17,124 @@
  1680. * R/W ops.
  1681. **************************************************/
  1682. -static u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address)
  1683. +u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address)
  1684. {
  1685. - pcicore_write32(pc, 0x130, address);
  1686. - pcicore_read32(pc, 0x130);
  1687. - return pcicore_read32(pc, 0x134);
  1688. + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address);
  1689. + pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR);
  1690. + return pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_DATA);
  1691. }
  1692. -#if 0
  1693. static void bcma_pcie_write(struct bcma_drv_pci *pc, u32 address, u32 data)
  1694. {
  1695. - pcicore_write32(pc, 0x130, address);
  1696. - pcicore_read32(pc, 0x130);
  1697. - pcicore_write32(pc, 0x134, data);
  1698. + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address);
  1699. + pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR);
  1700. + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data);
  1701. }
  1702. -#endif
  1703. static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
  1704. {
  1705. - const u16 mdio_control = 0x128;
  1706. - const u16 mdio_data = 0x12C;
  1707. u32 v;
  1708. int i;
  1709. - v = (1 << 30); /* Start of Transaction */
  1710. - v |= (1 << 28); /* Write Transaction */
  1711. - v |= (1 << 17); /* Turnaround */
  1712. - v |= (0x1F << 18);
  1713. + v = BCMA_CORE_PCI_MDIODATA_START;
  1714. + v |= BCMA_CORE_PCI_MDIODATA_WRITE;
  1715. + v |= (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
  1716. + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
  1717. + v |= (BCMA_CORE_PCI_MDIODATA_BLK_ADDR <<
  1718. + BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
  1719. + v |= BCMA_CORE_PCI_MDIODATA_TA;
  1720. v |= (phy << 4);
  1721. - pcicore_write32(pc, mdio_data, v);
  1722. + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
  1723. udelay(10);
  1724. for (i = 0; i < 200; i++) {
  1725. - v = pcicore_read32(pc, mdio_control);
  1726. - if (v & 0x100 /* Trans complete */)
  1727. + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
  1728. + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
  1729. break;
  1730. - msleep(1);
  1731. + usleep_range(1000, 2000);
  1732. }
  1733. }
  1734. static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address)
  1735. {
  1736. - const u16 mdio_control = 0x128;
  1737. - const u16 mdio_data = 0x12C;
  1738. int max_retries = 10;
  1739. u16 ret = 0;
  1740. u32 v;
  1741. int i;
  1742. - v = 0x80; /* Enable Preamble Sequence */
  1743. - v |= 0x2; /* MDIO Clock Divisor */
  1744. - pcicore_write32(pc, mdio_control, v);
  1745. + /* enable mdio access to SERDES */
  1746. + v = BCMA_CORE_PCI_MDIOCTL_PREAM_EN;
  1747. + v |= BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL;
  1748. + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, v);
  1749. if (pc->core->id.rev >= 10) {
  1750. max_retries = 200;
  1751. bcma_pcie_mdio_set_phy(pc, device);
  1752. + v = (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
  1753. + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
  1754. + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
  1755. + } else {
  1756. + v = (device << BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD);
  1757. + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
  1758. }
  1759. - v = (1 << 30); /* Start of Transaction */
  1760. - v |= (1 << 29); /* Read Transaction */
  1761. - v |= (1 << 17); /* Turnaround */
  1762. - if (pc->core->id.rev < 10)
  1763. - v |= (u32)device << 22;
  1764. - v |= (u32)address << 18;
  1765. - pcicore_write32(pc, mdio_data, v);
  1766. + v = BCMA_CORE_PCI_MDIODATA_START;
  1767. + v |= BCMA_CORE_PCI_MDIODATA_READ;
  1768. + v |= BCMA_CORE_PCI_MDIODATA_TA;
  1769. +
  1770. + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
  1771. /* Wait for the device to complete the transaction */
  1772. udelay(10);
  1773. for (i = 0; i < max_retries; i++) {
  1774. - v = pcicore_read32(pc, mdio_control);
  1775. - if (v & 0x100 /* Trans complete */) {
  1776. + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
  1777. + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE) {
  1778. udelay(10);
  1779. - ret = pcicore_read32(pc, mdio_data);
  1780. + ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
  1781. break;
  1782. }
  1783. - msleep(1);
  1784. + usleep_range(1000, 2000);
  1785. }
  1786. - pcicore_write32(pc, mdio_control, 0);
  1787. + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
  1788. return ret;
  1789. }
  1790. static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
  1791. u8 address, u16 data)
  1792. {
  1793. - const u16 mdio_control = 0x128;
  1794. - const u16 mdio_data = 0x12C;
  1795. int max_retries = 10;
  1796. u32 v;
  1797. int i;
  1798. - v = 0x80; /* Enable Preamble Sequence */
  1799. - v |= 0x2; /* MDIO Clock Divisor */
  1800. - pcicore_write32(pc, mdio_control, v);
  1801. + /* enable mdio access to SERDES */
  1802. + v = BCMA_CORE_PCI_MDIOCTL_PREAM_EN;
  1803. + v |= BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL;
  1804. + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, v);
  1805. if (pc->core->id.rev >= 10) {
  1806. max_retries = 200;
  1807. bcma_pcie_mdio_set_phy(pc, device);
  1808. + v = (BCMA_CORE_PCI_MDIODATA_DEV_ADDR <<
  1809. + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF);
  1810. + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF);
  1811. + } else {
  1812. + v = (device << BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD);
  1813. + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
  1814. }
  1815. - v = (1 << 30); /* Start of Transaction */
  1816. - v |= (1 << 28); /* Write Transaction */
  1817. - v |= (1 << 17); /* Turnaround */
  1818. - if (pc->core->id.rev < 10)
  1819. - v |= (u32)device << 22;
  1820. - v |= (u32)address << 18;
  1821. + v = BCMA_CORE_PCI_MDIODATA_START;
  1822. + v |= BCMA_CORE_PCI_MDIODATA_WRITE;
  1823. + v |= BCMA_CORE_PCI_MDIODATA_TA;
  1824. v |= data;
  1825. - pcicore_write32(pc, mdio_data, v);
  1826. + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v);
  1827. /* Wait for the device to complete the transaction */
  1828. udelay(10);
  1829. for (i = 0; i < max_retries; i++) {
  1830. - v = pcicore_read32(pc, mdio_control);
  1831. - if (v & 0x100 /* Trans complete */)
  1832. + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
  1833. + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
  1834. break;
  1835. - msleep(1);
  1836. + usleep_range(1000, 2000);
  1837. }
  1838. - pcicore_write32(pc, mdio_control, 0);
  1839. + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
  1840. }
  1841. /**************************************************
  1842. @@ -138,88 +143,108 @@ static void bcma_pcie_mdio_write(struct
  1843. static u8 bcma_pcicore_polarity_workaround(struct bcma_drv_pci *pc)
  1844. {
  1845. - return (bcma_pcie_read(pc, 0x204) & 0x10) ? 0xC0 : 0x80;
  1846. + u32 tmp;
  1847. +
  1848. + tmp = bcma_pcie_read(pc, BCMA_CORE_PCI_PLP_STATUSREG);
  1849. + if (tmp & BCMA_CORE_PCI_PLP_POLARITYINV_STAT)
  1850. + return BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE |
  1851. + BCMA_CORE_PCI_SERDES_RX_CTRL_POLARITY;
  1852. + else
  1853. + return BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE;
  1854. }
  1855. static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc)
  1856. {
  1857. - const u8 serdes_pll_device = 0x1D;
  1858. - const u8 serdes_rx_device = 0x1F;
  1859. u16 tmp;
  1860. - bcma_pcie_mdio_write(pc, serdes_rx_device, 1 /* Control */,
  1861. - bcma_pcicore_polarity_workaround(pc));
  1862. - tmp = bcma_pcie_mdio_read(pc, serdes_pll_device, 1 /* Control */);
  1863. - if (tmp & 0x4000)
  1864. - bcma_pcie_mdio_write(pc, serdes_pll_device, 1, tmp & ~0x4000);
  1865. + bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_RX,
  1866. + BCMA_CORE_PCI_SERDES_RX_CTRL,
  1867. + bcma_pcicore_polarity_workaround(pc));
  1868. + tmp = bcma_pcie_mdio_read(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL,
  1869. + BCMA_CORE_PCI_SERDES_PLL_CTRL);
  1870. + if (tmp & BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN)
  1871. + bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL,
  1872. + BCMA_CORE_PCI_SERDES_PLL_CTRL,
  1873. + tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN);
  1874. +}
  1875. +
  1876. +static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc)
  1877. +{
  1878. + struct bcma_device *core = pc->core;
  1879. + u16 val16, core_index;
  1880. + uint regoff;
  1881. +
  1882. + regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_PI_OFFSET);
  1883. + core_index = (u16)core->core_index;
  1884. +
  1885. + val16 = pcicore_read16(pc, regoff);
  1886. + if (((val16 & BCMA_CORE_PCI_SPROM_PI_MASK) >> BCMA_CORE_PCI_SPROM_PI_SHIFT)
  1887. + != core_index) {
  1888. + val16 = (core_index << BCMA_CORE_PCI_SPROM_PI_SHIFT) |
  1889. + (val16 & ~BCMA_CORE_PCI_SPROM_PI_MASK);
  1890. + pcicore_write16(pc, regoff, val16);
  1891. + }
  1892. +}
  1893. +
  1894. +/* Fix MISC config to allow coming out of L2/L3-Ready state w/o PRST */
  1895. +/* Needs to happen when coming out of 'standby'/'hibernate' */
  1896. +static void bcma_core_pci_config_fixup(struct bcma_drv_pci *pc)
  1897. +{
  1898. + u16 val16;
  1899. + uint regoff;
  1900. +
  1901. + regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_MISC_CONFIG);
  1902. +
  1903. + val16 = pcicore_read16(pc, regoff);
  1904. +
  1905. + if (!(val16 & BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST)) {
  1906. + val16 |= BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST;
  1907. + pcicore_write16(pc, regoff, val16);
  1908. + }
  1909. }
  1910. /**************************************************
  1911. * Init.
  1912. **************************************************/
  1913. -static void bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
  1914. +static void __devinit bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
  1915. {
  1916. + bcma_core_pci_fixcfg(pc);
  1917. bcma_pcicore_serdes_workaround(pc);
  1918. + bcma_core_pci_config_fixup(pc);
  1919. }
  1920. -static bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
  1921. -{
  1922. - struct bcma_bus *bus = pc->core->bus;
  1923. - u16 chipid_top;
  1924. -
  1925. - chipid_top = (bus->chipinfo.id & 0xFF00);
  1926. - if (chipid_top != 0x4700 &&
  1927. - chipid_top != 0x5300)
  1928. - return false;
  1929. -
  1930. -#ifdef CONFIG_SSB_DRIVER_PCICORE
  1931. - if (bus->sprom.boardflags_lo & SSB_BFL_NOPCI)
  1932. - return false;
  1933. -#endif /* CONFIG_SSB_DRIVER_PCICORE */
  1934. -
  1935. -#if 0
  1936. - /* TODO: on BCMA we use address from EROM instead of magic formula */
  1937. - u32 tmp;
  1938. - return !mips_busprobe32(tmp, (bus->mmio +
  1939. - (pc->core->core_index * BCMA_CORE_SIZE)));
  1940. -#endif
  1941. -
  1942. - return true;
  1943. -}
  1944. -
  1945. -void bcma_core_pci_init(struct bcma_drv_pci *pc)
  1946. +void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc)
  1947. {
  1948. if (pc->setup_done)
  1949. return;
  1950. - if (bcma_core_pci_is_in_hostmode(pc)) {
  1951. #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
  1952. + pc->hostmode = bcma_core_pci_is_in_hostmode(pc);
  1953. + if (pc->hostmode)
  1954. bcma_core_pci_hostmode_init(pc);
  1955. -#else
  1956. - pr_err("Driver compiled without support for hostmode PCI\n");
  1957. #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
  1958. - } else {
  1959. - bcma_core_pci_clientmode_init(pc);
  1960. - }
  1961. - pc->setup_done = true;
  1962. + if (!pc->hostmode)
  1963. + bcma_core_pci_clientmode_init(pc);
  1964. }
  1965. int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
  1966. bool enable)
  1967. {
  1968. - struct pci_dev *pdev = pc->core->bus->host_pci;
  1969. + struct pci_dev *pdev;
  1970. u32 coremask, tmp;
  1971. int err = 0;
  1972. - if (core->bus->hosttype != BCMA_HOSTTYPE_PCI) {
  1973. + if (!pc || core->bus->hosttype != BCMA_HOSTTYPE_PCI) {
  1974. /* This bcma device is not on a PCI host-bus. So the IRQs are
  1975. * not routed through the PCI core.
  1976. * So we must not enable routing through the PCI core. */
  1977. goto out;
  1978. }
  1979. + pdev = pc->core->bus->host_pci;
  1980. +
  1981. err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
  1982. if (err)
  1983. goto out;
  1984. @@ -236,3 +261,17 @@ out:
  1985. return err;
  1986. }
  1987. EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
  1988. +
  1989. +void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
  1990. +{
  1991. + u32 w;
  1992. +
  1993. + w = bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
  1994. + if (extend)
  1995. + w |= BCMA_CORE_PCI_ASPMTIMER_EXTEND;
  1996. + else
  1997. + w &= ~BCMA_CORE_PCI_ASPMTIMER_EXTEND;
  1998. + bcma_pcie_write(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG, w);
  1999. + bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
  2000. +}
  2001. +EXPORT_SYMBOL_GPL(bcma_core_pci_extend_L1timer);
  2002. --- a/drivers/bcma/driver_pci_host.c
  2003. +++ b/drivers/bcma/driver_pci_host.c
  2004. @@ -2,13 +2,600 @@
  2005. * Broadcom specific AMBA
  2006. * PCI Core in hostmode
  2007. *
  2008. + * Copyright 2005 - 2011, Broadcom Corporation
  2009. + * Copyright 2006, 2007, Michael Buesch <[email protected]>
  2010. + * Copyright 2011, 2012, Hauke Mehrtens <[email protected]>
  2011. + *
  2012. * Licensed under the GNU/GPL. See COPYING for details.
  2013. */
  2014. #include "bcma_private.h"
  2015. +#include <linux/pci.h>
  2016. +#include <linux/export.h>
  2017. #include <linux/bcma/bcma.h>
  2018. +#include <asm/paccess.h>
  2019. +
  2020. +/* Probe a 32bit value on the bus and catch bus exceptions.
  2021. + * Returns nonzero on a bus exception.
  2022. + * This is MIPS specific */
  2023. +#define mips_busprobe32(val, addr) get_dbe((val), ((u32 *)(addr)))
  2024. +
  2025. +/* Assume one-hot slot wiring */
  2026. +#define BCMA_PCI_SLOT_MAX 16
  2027. +#define PCI_CONFIG_SPACE_SIZE 256
  2028. +
  2029. +bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
  2030. +{
  2031. + struct bcma_bus *bus = pc->core->bus;
  2032. + u16 chipid_top;
  2033. + u32 tmp;
  2034. +
  2035. + chipid_top = (bus->chipinfo.id & 0xFF00);
  2036. + if (chipid_top != 0x4700 &&
  2037. + chipid_top != 0x5300)
  2038. + return false;
  2039. +
  2040. + bcma_core_enable(pc->core, 0);
  2041. +
  2042. + return !mips_busprobe32(tmp, pc->core->io_addr);
  2043. +}
  2044. +
  2045. +static u32 bcma_pcie_read_config(struct bcma_drv_pci *pc, u32 address)
  2046. +{
  2047. + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_ADDR, address);
  2048. + pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_ADDR);
  2049. + return pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_DATA);
  2050. +}
  2051. +
  2052. +static void bcma_pcie_write_config(struct bcma_drv_pci *pc, u32 address,
  2053. + u32 data)
  2054. +{
  2055. + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_ADDR, address);
  2056. + pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_ADDR);
  2057. + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_DATA, data);
  2058. +}
  2059. +
  2060. +static u32 bcma_get_cfgspace_addr(struct bcma_drv_pci *pc, unsigned int dev,
  2061. + unsigned int func, unsigned int off)
  2062. +{
  2063. + u32 addr = 0;
  2064. +
  2065. + /* Issue config commands only when the data link is up (atleast
  2066. + * one external pcie device is present).
  2067. + */
  2068. + if (dev >= 2 || !(bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_LSREG)
  2069. + & BCMA_CORE_PCI_DLLP_LSREG_LINKUP))
  2070. + goto out;
  2071. +
  2072. + /* Type 0 transaction */
  2073. + /* Slide the PCI window to the appropriate slot */
  2074. + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI1, BCMA_CORE_PCI_SBTOPCI_CFG0);
  2075. + /* Calculate the address */
  2076. + addr = pc->host_controller->host_cfg_addr;
  2077. + addr |= (dev << BCMA_CORE_PCI_CFG_SLOT_SHIFT);
  2078. + addr |= (func << BCMA_CORE_PCI_CFG_FUN_SHIFT);
  2079. + addr |= (off & ~3);
  2080. +
  2081. +out:
  2082. + return addr;
  2083. +}
  2084. -void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
  2085. +static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev,
  2086. + unsigned int func, unsigned int off,
  2087. + void *buf, int len)
  2088. {
  2089. - pr_err("No support for PCI core in hostmode yet\n");
  2090. + int err = -EINVAL;
  2091. + u32 addr, val;
  2092. + void __iomem *mmio = 0;
  2093. +
  2094. + WARN_ON(!pc->hostmode);
  2095. + if (unlikely(len != 1 && len != 2 && len != 4))
  2096. + goto out;
  2097. + if (dev == 0) {
  2098. + /* we support only two functions on device 0 */
  2099. + if (func > 1)
  2100. + return -EINVAL;
  2101. +
  2102. + /* accesses to config registers with offsets >= 256
  2103. + * requires indirect access.
  2104. + */
  2105. + if (off >= PCI_CONFIG_SPACE_SIZE) {
  2106. + addr = (func << 12);
  2107. + addr |= (off & 0x0FFF);
  2108. + val = bcma_pcie_read_config(pc, addr);
  2109. + } else {
  2110. + addr = BCMA_CORE_PCI_PCICFG0;
  2111. + addr |= (func << 8);
  2112. + addr |= (off & 0xfc);
  2113. + val = pcicore_read32(pc, addr);
  2114. + }
  2115. + } else {
  2116. + addr = bcma_get_cfgspace_addr(pc, dev, func, off);
  2117. + if (unlikely(!addr))
  2118. + goto out;
  2119. + err = -ENOMEM;
  2120. + mmio = ioremap_nocache(addr, sizeof(val));
  2121. + if (!mmio)
  2122. + goto out;
  2123. +
  2124. + if (mips_busprobe32(val, mmio)) {
  2125. + val = 0xffffffff;
  2126. + goto unmap;
  2127. + }
  2128. +
  2129. + val = readl(mmio);
  2130. + }
  2131. + val >>= (8 * (off & 3));
  2132. +
  2133. + switch (len) {
  2134. + case 1:
  2135. + *((u8 *)buf) = (u8)val;
  2136. + break;
  2137. + case 2:
  2138. + *((u16 *)buf) = (u16)val;
  2139. + break;
  2140. + case 4:
  2141. + *((u32 *)buf) = (u32)val;
  2142. + break;
  2143. + }
  2144. + err = 0;
  2145. +unmap:
  2146. + if (mmio)
  2147. + iounmap(mmio);
  2148. +out:
  2149. + return err;
  2150. +}
  2151. +
  2152. +static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev,
  2153. + unsigned int func, unsigned int off,
  2154. + const void *buf, int len)
  2155. +{
  2156. + int err = -EINVAL;
  2157. + u32 addr = 0, val = 0;
  2158. + void __iomem *mmio = 0;
  2159. + u16 chipid = pc->core->bus->chipinfo.id;
  2160. +
  2161. + WARN_ON(!pc->hostmode);
  2162. + if (unlikely(len != 1 && len != 2 && len != 4))
  2163. + goto out;
  2164. + if (dev == 0) {
  2165. + /* accesses to config registers with offsets >= 256
  2166. + * requires indirect access.
  2167. + */
  2168. + if (off < PCI_CONFIG_SPACE_SIZE) {
  2169. + addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0;
  2170. + addr |= (func << 8);
  2171. + addr |= (off & 0xfc);
  2172. + mmio = ioremap_nocache(addr, sizeof(val));
  2173. + if (!mmio)
  2174. + goto out;
  2175. + }
  2176. + } else {
  2177. + addr = bcma_get_cfgspace_addr(pc, dev, func, off);
  2178. + if (unlikely(!addr))
  2179. + goto out;
  2180. + err = -ENOMEM;
  2181. + mmio = ioremap_nocache(addr, sizeof(val));
  2182. + if (!mmio)
  2183. + goto out;
  2184. +
  2185. + if (mips_busprobe32(val, mmio)) {
  2186. + val = 0xffffffff;
  2187. + goto unmap;
  2188. + }
  2189. + }
  2190. +
  2191. + switch (len) {
  2192. + case 1:
  2193. + val = readl(mmio);
  2194. + val &= ~(0xFF << (8 * (off & 3)));
  2195. + val |= *((const u8 *)buf) << (8 * (off & 3));
  2196. + break;
  2197. + case 2:
  2198. + val = readl(mmio);
  2199. + val &= ~(0xFFFF << (8 * (off & 3)));
  2200. + val |= *((const u16 *)buf) << (8 * (off & 3));
  2201. + break;
  2202. + case 4:
  2203. + val = *((const u32 *)buf);
  2204. + break;
  2205. + }
  2206. + if (dev == 0 && !addr) {
  2207. + /* accesses to config registers with offsets >= 256
  2208. + * requires indirect access.
  2209. + */
  2210. + addr = (func << 12);
  2211. + addr |= (off & 0x0FFF);
  2212. + bcma_pcie_write_config(pc, addr, val);
  2213. + } else {
  2214. + writel(val, mmio);
  2215. +
  2216. + if (chipid == BCMA_CHIP_ID_BCM4716 ||
  2217. + chipid == BCMA_CHIP_ID_BCM4748)
  2218. + readl(mmio);
  2219. + }
  2220. +
  2221. + err = 0;
  2222. +unmap:
  2223. + if (mmio)
  2224. + iounmap(mmio);
  2225. +out:
  2226. + return err;
  2227. +}
  2228. +
  2229. +static int bcma_core_pci_hostmode_read_config(struct pci_bus *bus,
  2230. + unsigned int devfn,
  2231. + int reg, int size, u32 *val)
  2232. +{
  2233. + unsigned long flags;
  2234. + int err;
  2235. + struct bcma_drv_pci *pc;
  2236. + struct bcma_drv_pci_host *pc_host;
  2237. +
  2238. + pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops);
  2239. + pc = pc_host->pdev;
  2240. +
  2241. + spin_lock_irqsave(&pc_host->cfgspace_lock, flags);
  2242. + err = bcma_extpci_read_config(pc, PCI_SLOT(devfn),
  2243. + PCI_FUNC(devfn), reg, val, size);
  2244. + spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags);
  2245. +
  2246. + return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
  2247. +}
  2248. +
  2249. +static int bcma_core_pci_hostmode_write_config(struct pci_bus *bus,
  2250. + unsigned int devfn,
  2251. + int reg, int size, u32 val)
  2252. +{
  2253. + unsigned long flags;
  2254. + int err;
  2255. + struct bcma_drv_pci *pc;
  2256. + struct bcma_drv_pci_host *pc_host;
  2257. +
  2258. + pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops);
  2259. + pc = pc_host->pdev;
  2260. +
  2261. + spin_lock_irqsave(&pc_host->cfgspace_lock, flags);
  2262. + err = bcma_extpci_write_config(pc, PCI_SLOT(devfn),
  2263. + PCI_FUNC(devfn), reg, &val, size);
  2264. + spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags);
  2265. +
  2266. + return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
  2267. +}
  2268. +
  2269. +/* return cap_offset if requested capability exists in the PCI config space */
  2270. +static u8 __devinit bcma_find_pci_capability(struct bcma_drv_pci *pc,
  2271. + unsigned int dev,
  2272. + unsigned int func, u8 req_cap_id,
  2273. + unsigned char *buf, u32 *buflen)
  2274. +{
  2275. + u8 cap_id;
  2276. + u8 cap_ptr = 0;
  2277. + u32 bufsize;
  2278. + u8 byte_val;
  2279. +
  2280. + /* check for Header type 0 */
  2281. + bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val,
  2282. + sizeof(u8));
  2283. + if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
  2284. + return cap_ptr;
  2285. +
  2286. + /* check if the capability pointer field exists */
  2287. + bcma_extpci_read_config(pc, dev, func, PCI_STATUS, &byte_val,
  2288. + sizeof(u8));
  2289. + if (!(byte_val & PCI_STATUS_CAP_LIST))
  2290. + return cap_ptr;
  2291. +
  2292. + /* check if the capability pointer is 0x00 */
  2293. + bcma_extpci_read_config(pc, dev, func, PCI_CAPABILITY_LIST, &cap_ptr,
  2294. + sizeof(u8));
  2295. + if (cap_ptr == 0x00)
  2296. + return cap_ptr;
  2297. +
  2298. + /* loop thr'u the capability list and see if the requested capabilty
  2299. + * exists */
  2300. + bcma_extpci_read_config(pc, dev, func, cap_ptr, &cap_id, sizeof(u8));
  2301. + while (cap_id != req_cap_id) {
  2302. + bcma_extpci_read_config(pc, dev, func, cap_ptr + 1, &cap_ptr,
  2303. + sizeof(u8));
  2304. + if (cap_ptr == 0x00)
  2305. + return cap_ptr;
  2306. + bcma_extpci_read_config(pc, dev, func, cap_ptr, &cap_id,
  2307. + sizeof(u8));
  2308. + }
  2309. +
  2310. + /* found the caller requested capability */
  2311. + if ((buf != NULL) && (buflen != NULL)) {
  2312. + u8 cap_data;
  2313. +
  2314. + bufsize = *buflen;
  2315. + if (!bufsize)
  2316. + return cap_ptr;
  2317. +
  2318. + *buflen = 0;
  2319. +
  2320. + /* copy the cpability data excluding cap ID and next ptr */
  2321. + cap_data = cap_ptr + 2;
  2322. + if ((bufsize + cap_data) > PCI_CONFIG_SPACE_SIZE)
  2323. + bufsize = PCI_CONFIG_SPACE_SIZE - cap_data;
  2324. + *buflen = bufsize;
  2325. + while (bufsize--) {
  2326. + bcma_extpci_read_config(pc, dev, func, cap_data, buf,
  2327. + sizeof(u8));
  2328. + cap_data++;
  2329. + buf++;
  2330. + }
  2331. + }
  2332. +
  2333. + return cap_ptr;
  2334. +}
  2335. +
  2336. +/* If the root port is capable of returning Config Request
  2337. + * Retry Status (CRS) Completion Status to software then
  2338. + * enable the feature.
  2339. + */
  2340. +static void __devinit bcma_core_pci_enable_crs(struct bcma_drv_pci *pc)
  2341. +{
  2342. + struct bcma_bus *bus = pc->core->bus;
  2343. + u8 cap_ptr, root_ctrl, root_cap, dev;
  2344. + u16 val16;
  2345. + int i;
  2346. +
  2347. + cap_ptr = bcma_find_pci_capability(pc, 0, 0, PCI_CAP_ID_EXP, NULL,
  2348. + NULL);
  2349. + root_cap = cap_ptr + PCI_EXP_RTCAP;
  2350. + bcma_extpci_read_config(pc, 0, 0, root_cap, &val16, sizeof(u16));
  2351. + if (val16 & BCMA_CORE_PCI_RC_CRS_VISIBILITY) {
  2352. + /* Enable CRS software visibility */
  2353. + root_ctrl = cap_ptr + PCI_EXP_RTCTL;
  2354. + val16 = PCI_EXP_RTCTL_CRSSVE;
  2355. + bcma_extpci_read_config(pc, 0, 0, root_ctrl, &val16,
  2356. + sizeof(u16));
  2357. +
  2358. + /* Initiate a configuration request to read the vendor id
  2359. + * field of the device function's config space header after
  2360. + * 100 ms wait time from the end of Reset. If the device is
  2361. + * not done with its internal initialization, it must at
  2362. + * least return a completion TLP, with a completion status
  2363. + * of "Configuration Request Retry Status (CRS)". The root
  2364. + * complex must complete the request to the host by returning
  2365. + * a read-data value of 0001h for the Vendor ID field and
  2366. + * all 1s for any additional bytes included in the request.
  2367. + * Poll using the config reads for max wait time of 1 sec or
  2368. + * until we receive the successful completion status. Repeat
  2369. + * the procedure for all the devices.
  2370. + */
  2371. + for (dev = 1; dev < BCMA_PCI_SLOT_MAX; dev++) {
  2372. + for (i = 0; i < 100000; i++) {
  2373. + bcma_extpci_read_config(pc, dev, 0,
  2374. + PCI_VENDOR_ID, &val16,
  2375. + sizeof(val16));
  2376. + if (val16 != 0x1)
  2377. + break;
  2378. + udelay(10);
  2379. + }
  2380. + if (val16 == 0x1)
  2381. + bcma_err(bus, "PCI: Broken device in slot %d\n",
  2382. + dev);
  2383. + }
  2384. + }
  2385. +}
  2386. +
  2387. +void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
  2388. +{
  2389. + struct bcma_bus *bus = pc->core->bus;
  2390. + struct bcma_drv_pci_host *pc_host;
  2391. + u32 tmp;
  2392. + u32 pci_membase_1G;
  2393. + unsigned long io_map_base;
  2394. +
  2395. + bcma_info(bus, "PCIEcore in host mode found\n");
  2396. +
  2397. + if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
  2398. + bcma_info(bus, "This PCIE core is disabled and not working\n");
  2399. + return;
  2400. + }
  2401. +
  2402. + pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
  2403. + if (!pc_host) {
  2404. + bcma_err(bus, "can not allocate memory");
  2405. + return;
  2406. + }
  2407. +
  2408. + pc->host_controller = pc_host;
  2409. + pc_host->pci_controller.io_resource = &pc_host->io_resource;
  2410. + pc_host->pci_controller.mem_resource = &pc_host->mem_resource;
  2411. + pc_host->pci_controller.pci_ops = &pc_host->pci_ops;
  2412. + pc_host->pdev = pc;
  2413. +
  2414. + pci_membase_1G = BCMA_SOC_PCI_DMA;
  2415. + pc_host->host_cfg_addr = BCMA_SOC_PCI_CFG;
  2416. +
  2417. + pc_host->pci_ops.read = bcma_core_pci_hostmode_read_config;
  2418. + pc_host->pci_ops.write = bcma_core_pci_hostmode_write_config;
  2419. +
  2420. + pc_host->mem_resource.name = "BCMA PCIcore external memory",
  2421. + pc_host->mem_resource.start = BCMA_SOC_PCI_DMA;
  2422. + pc_host->mem_resource.end = BCMA_SOC_PCI_DMA + BCMA_SOC_PCI_DMA_SZ - 1;
  2423. + pc_host->mem_resource.flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED;
  2424. +
  2425. + pc_host->io_resource.name = "BCMA PCIcore external I/O",
  2426. + pc_host->io_resource.start = 0x100;
  2427. + pc_host->io_resource.end = 0x7FF;
  2428. + pc_host->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED;
  2429. +
  2430. + /* Reset RC */
  2431. + usleep_range(3000, 5000);
  2432. + pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE);
  2433. + usleep_range(1000, 2000);
  2434. + pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST |
  2435. + BCMA_CORE_PCI_CTL_RST_OE);
  2436. +
  2437. + /* 64 MB I/O access window. On 4716, use
  2438. + * sbtopcie0 to access the device registers. We
  2439. + * can't use address match 2 (1 GB window) region
  2440. + * as mips can't generate 64-bit address on the
  2441. + * backplane.
  2442. + */
  2443. + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4716 ||
  2444. + bus->chipinfo.id == BCMA_CHIP_ID_BCM4748) {
  2445. + pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
  2446. + pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
  2447. + BCMA_SOC_PCI_MEM_SZ - 1;
  2448. + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
  2449. + BCMA_CORE_PCI_SBTOPCI_MEM | BCMA_SOC_PCI_MEM);
  2450. + } else if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
  2451. + tmp = BCMA_CORE_PCI_SBTOPCI_MEM;
  2452. + tmp |= BCMA_CORE_PCI_SBTOPCI_PREF;
  2453. + tmp |= BCMA_CORE_PCI_SBTOPCI_BURST;
  2454. + if (pc->core->core_unit == 0) {
  2455. + pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
  2456. + pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
  2457. + BCMA_SOC_PCI_MEM_SZ - 1;
  2458. + pc_host->io_resource.start = 0x100;
  2459. + pc_host->io_resource.end = 0x47F;
  2460. + pci_membase_1G = BCMA_SOC_PCIE_DMA_H32;
  2461. + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
  2462. + tmp | BCMA_SOC_PCI_MEM);
  2463. + } else if (pc->core->core_unit == 1) {
  2464. + pc_host->mem_resource.start = BCMA_SOC_PCI1_MEM;
  2465. + pc_host->mem_resource.end = BCMA_SOC_PCI1_MEM +
  2466. + BCMA_SOC_PCI_MEM_SZ - 1;
  2467. + pc_host->io_resource.start = 0x480;
  2468. + pc_host->io_resource.end = 0x7FF;
  2469. + pci_membase_1G = BCMA_SOC_PCIE1_DMA_H32;
  2470. + pc_host->host_cfg_addr = BCMA_SOC_PCI1_CFG;
  2471. + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
  2472. + tmp | BCMA_SOC_PCI1_MEM);
  2473. + }
  2474. + } else
  2475. + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
  2476. + BCMA_CORE_PCI_SBTOPCI_IO);
  2477. +
  2478. + /* 64 MB configuration access window */
  2479. + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI1, BCMA_CORE_PCI_SBTOPCI_CFG0);
  2480. +
  2481. + /* 1 GB memory access window */
  2482. + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI2,
  2483. + BCMA_CORE_PCI_SBTOPCI_MEM | pci_membase_1G);
  2484. +
  2485. +
  2486. + /* As per PCI Express Base Spec 1.1 we need to wait for
  2487. + * at least 100 ms from the end of a reset (cold/warm/hot)
  2488. + * before issuing configuration requests to PCI Express
  2489. + * devices.
  2490. + */
  2491. + msleep(100);
  2492. +
  2493. + bcma_core_pci_enable_crs(pc);
  2494. +
  2495. + /* Enable PCI bridge BAR0 memory & master access */
  2496. + tmp = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  2497. + bcma_extpci_write_config(pc, 0, 0, PCI_COMMAND, &tmp, sizeof(tmp));
  2498. +
  2499. + /* Enable PCI interrupts */
  2500. + pcicore_write32(pc, BCMA_CORE_PCI_IMASK, BCMA_CORE_PCI_IMASK_INTA);
  2501. +
  2502. + /* Ok, ready to run, register it to the system.
  2503. + * The following needs change, if we want to port hostmode
  2504. + * to non-MIPS platform. */
  2505. + io_map_base = (unsigned long)ioremap_nocache(pc_host->mem_resource.start,
  2506. + resource_size(&pc_host->mem_resource));
  2507. + pc_host->pci_controller.io_map_base = io_map_base;
  2508. + set_io_port_base(pc_host->pci_controller.io_map_base);
  2509. + /* Give some time to the PCI controller to configure itself with the new
  2510. + * values. Not waiting at this point causes crashes of the machine. */
  2511. + usleep_range(10000, 15000);
  2512. + register_pci_controller(&pc_host->pci_controller);
  2513. + return;
  2514. +}
  2515. +
  2516. +/* Early PCI fixup for a device on the PCI-core bridge. */
  2517. +static void bcma_core_pci_fixup_pcibridge(struct pci_dev *dev)
  2518. +{
  2519. + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
  2520. + /* This is not a device on the PCI-core bridge. */
  2521. + return;
  2522. + }
  2523. + if (PCI_SLOT(dev->devfn) != 0)
  2524. + return;
  2525. +
  2526. + pr_info("PCI: Fixing up bridge %s\n", pci_name(dev));
  2527. +
  2528. + /* Enable PCI bridge bus mastering and memory space */
  2529. + pci_set_master(dev);
  2530. + if (pcibios_enable_device(dev, ~0) < 0) {
  2531. + pr_err("PCI: BCMA bridge enable failed\n");
  2532. + return;
  2533. + }
  2534. +
  2535. + /* Enable PCI bridge BAR1 prefetch and burst */
  2536. + pci_write_config_dword(dev, BCMA_PCI_BAR1_CONTROL, 3);
  2537. +}
  2538. +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_pcibridge);
  2539. +
  2540. +/* Early PCI fixup for all PCI-cores to set the correct memory address. */
  2541. +static void bcma_core_pci_fixup_addresses(struct pci_dev *dev)
  2542. +{
  2543. + struct resource *res;
  2544. + int pos, err;
  2545. +
  2546. + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
  2547. + /* This is not a device on the PCI-core bridge. */
  2548. + return;
  2549. + }
  2550. + if (PCI_SLOT(dev->devfn) == 0)
  2551. + return;
  2552. +
  2553. + pr_info("PCI: Fixing up addresses %s\n", pci_name(dev));
  2554. +
  2555. + for (pos = 0; pos < 6; pos++) {
  2556. + res = &dev->resource[pos];
  2557. + if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM)) {
  2558. + err = pci_assign_resource(dev, pos);
  2559. + if (err)
  2560. + pr_err("PCI: Problem fixing up the addresses on %s\n",
  2561. + pci_name(dev));
  2562. + }
  2563. + }
  2564. +}
  2565. +DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_addresses);
  2566. +
  2567. +/* This function is called when doing a pci_enable_device().
  2568. + * We must first check if the device is a device on the PCI-core bridge. */
  2569. +int bcma_core_pci_plat_dev_init(struct pci_dev *dev)
  2570. +{
  2571. + struct bcma_drv_pci_host *pc_host;
  2572. +
  2573. + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
  2574. + /* This is not a device on the PCI-core bridge. */
  2575. + return -ENODEV;
  2576. + }
  2577. + pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
  2578. + pci_ops);
  2579. +
  2580. + pr_info("PCI: Fixing up device %s\n", pci_name(dev));
  2581. +
  2582. + /* Fix up interrupt lines */
  2583. + dev->irq = bcma_core_mips_irq(pc_host->pdev->core) + 2;
  2584. + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  2585. +
  2586. + return 0;
  2587. +}
  2588. +EXPORT_SYMBOL(bcma_core_pci_plat_dev_init);
  2589. +
  2590. +/* PCI device IRQ mapping. */
  2591. +int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev)
  2592. +{
  2593. + struct bcma_drv_pci_host *pc_host;
  2594. +
  2595. + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
  2596. + /* This is not a device on the PCI-core bridge. */
  2597. + return -ENODEV;
  2598. + }
  2599. +
  2600. + pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
  2601. + pci_ops);
  2602. + return bcma_core_mips_irq(pc_host->pdev->core) + 2;
  2603. }
  2604. +EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq);
  2605. --- a/drivers/bcma/host_pci.c
  2606. +++ b/drivers/bcma/host_pci.c
  2607. @@ -18,7 +18,7 @@ static void bcma_host_pci_switch_core(st
  2608. pci_write_config_dword(core->bus->host_pci, BCMA_PCI_BAR0_WIN2,
  2609. core->wrap);
  2610. core->bus->mapped_core = core;
  2611. - pr_debug("Switched to core: 0x%X\n", core->id.id);
  2612. + bcma_debug(core->bus, "Switched to core: 0x%X\n", core->id.id);
  2613. }
  2614. /* Provides access to the requested core. Returns base offset that has to be
  2615. @@ -77,8 +77,8 @@ static void bcma_host_pci_write32(struct
  2616. }
  2617. #ifdef CONFIG_BCMA_BLOCKIO
  2618. -void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
  2619. - size_t count, u16 offset, u8 reg_width)
  2620. +static void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
  2621. + size_t count, u16 offset, u8 reg_width)
  2622. {
  2623. void __iomem *addr = core->bus->mmio + offset;
  2624. if (core->bus->mapped_core != core)
  2625. @@ -100,8 +100,9 @@ void bcma_host_pci_block_read(struct bcm
  2626. }
  2627. }
  2628. -void bcma_host_pci_block_write(struct bcma_device *core, const void *buffer,
  2629. - size_t count, u16 offset, u8 reg_width)
  2630. +static void bcma_host_pci_block_write(struct bcma_device *core,
  2631. + const void *buffer, size_t count,
  2632. + u16 offset, u8 reg_width)
  2633. {
  2634. void __iomem *addr = core->bus->mmio + offset;
  2635. if (core->bus->mapped_core != core)
  2636. @@ -139,7 +140,7 @@ static void bcma_host_pci_awrite32(struc
  2637. iowrite32(value, core->bus->mmio + (1 * BCMA_CORE_SIZE) + offset);
  2638. }
  2639. -const struct bcma_host_ops bcma_host_pci_ops = {
  2640. +static const struct bcma_host_ops bcma_host_pci_ops = {
  2641. .read8 = bcma_host_pci_read8,
  2642. .read16 = bcma_host_pci_read16,
  2643. .read32 = bcma_host_pci_read32,
  2644. @@ -154,8 +155,8 @@ const struct bcma_host_ops bcma_host_pci
  2645. .awrite32 = bcma_host_pci_awrite32,
  2646. };
  2647. -static int bcma_host_pci_probe(struct pci_dev *dev,
  2648. - const struct pci_device_id *id)
  2649. +static int __devinit bcma_host_pci_probe(struct pci_dev *dev,
  2650. + const struct pci_device_id *id)
  2651. {
  2652. struct bcma_bus *bus;
  2653. int err = -ENOMEM;
  2654. @@ -188,7 +189,7 @@ static int bcma_host_pci_probe(struct pc
  2655. /* SSB needed additional powering up, do we have any AMBA PCI cards? */
  2656. if (!pci_is_pcie(dev))
  2657. - pr_err("PCI card detected, report problems.\n");
  2658. + bcma_err(bus, "PCI card detected, report problems.\n");
  2659. /* Map MMIO */
  2660. err = -ENOMEM;
  2661. @@ -201,6 +202,9 @@ static int bcma_host_pci_probe(struct pc
  2662. bus->hosttype = BCMA_HOSTTYPE_PCI;
  2663. bus->ops = &bcma_host_pci_ops;
  2664. + bus->boardinfo.vendor = bus->host_pci->subsystem_vendor;
  2665. + bus->boardinfo.type = bus->host_pci->subsystem_device;
  2666. +
  2667. /* Register */
  2668. err = bcma_bus_register(bus);
  2669. if (err)
  2670. @@ -222,7 +226,7 @@ err_kfree_bus:
  2671. return err;
  2672. }
  2673. -static void bcma_host_pci_remove(struct pci_dev *dev)
  2674. +static void __devexit bcma_host_pci_remove(struct pci_dev *dev)
  2675. {
  2676. struct bcma_bus *bus = pci_get_drvdata(dev);
  2677. @@ -234,7 +238,7 @@ static void bcma_host_pci_remove(struct
  2678. pci_set_drvdata(dev, NULL);
  2679. }
  2680. -#ifdef CONFIG_PM
  2681. +#ifdef CONFIG_PM_SLEEP
  2682. static int bcma_host_pci_suspend(struct device *dev)
  2683. {
  2684. struct pci_dev *pdev = to_pci_dev(dev);
  2685. @@ -257,17 +261,20 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bc
  2686. bcma_host_pci_resume);
  2687. #define BCMA_PM_OPS (&bcma_pm_ops)
  2688. -#else /* CONFIG_PM */
  2689. +#else /* CONFIG_PM_SLEEP */
  2690. #define BCMA_PM_OPS NULL
  2691. -#endif /* CONFIG_PM */
  2692. +#endif /* CONFIG_PM_SLEEP */
  2693. static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
  2694. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
  2695. + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) },
  2696. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
  2697. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
  2698. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
  2699. + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
  2700. + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
  2701. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
  2702. { 0, },
  2703. };
  2704. @@ -277,7 +284,7 @@ static struct pci_driver bcma_pci_bridge
  2705. .name = "bcma-pci-bridge",
  2706. .id_table = bcma_pci_bridge_tbl,
  2707. .probe = bcma_host_pci_probe,
  2708. - .remove = bcma_host_pci_remove,
  2709. + .remove = __devexit_p(bcma_host_pci_remove),
  2710. .driver.pm = BCMA_PM_OPS,
  2711. };
  2712. --- a/drivers/bcma/host_soc.c
  2713. +++ b/drivers/bcma/host_soc.c
  2714. @@ -143,7 +143,7 @@ static void bcma_host_soc_awrite32(struc
  2715. writel(value, core->io_wrap + offset);
  2716. }
  2717. -const struct bcma_host_ops bcma_host_soc_ops = {
  2718. +static const struct bcma_host_ops bcma_host_soc_ops = {
  2719. .read8 = bcma_host_soc_read8,
  2720. .read16 = bcma_host_soc_read16,
  2721. .read32 = bcma_host_soc_read32,
  2722. --- a/drivers/bcma/main.c
  2723. +++ b/drivers/bcma/main.c
  2724. @@ -7,12 +7,19 @@
  2725. #include "bcma_private.h"
  2726. #include <linux/module.h>
  2727. +#include <linux/platform_device.h>
  2728. #include <linux/bcma/bcma.h>
  2729. #include <linux/slab.h>
  2730. MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
  2731. MODULE_LICENSE("GPL");
  2732. +/* contains the number the next bus should get. */
  2733. +static unsigned int bcma_bus_next_num = 0;
  2734. +
  2735. +/* bcma_buses_mutex locks the bcma_bus_next_num */
  2736. +static DEFINE_MUTEX(bcma_buses_mutex);
  2737. +
  2738. static int bcma_bus_match(struct device *dev, struct device_driver *drv);
  2739. static int bcma_device_probe(struct device *dev);
  2740. static int bcma_device_remove(struct device *dev);
  2741. @@ -55,7 +62,14 @@ static struct bus_type bcma_bus_type = {
  2742. .dev_attrs = bcma_device_attrs,
  2743. };
  2744. -static struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid)
  2745. +static u16 bcma_cc_core_id(struct bcma_bus *bus)
  2746. +{
  2747. + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
  2748. + return BCMA_CORE_4706_CHIPCOMMON;
  2749. + return BCMA_CORE_CHIPCOMMON;
  2750. +}
  2751. +
  2752. +struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid)
  2753. {
  2754. struct bcma_device *core;
  2755. @@ -65,6 +79,19 @@ static struct bcma_device *bcma_find_cor
  2756. }
  2757. return NULL;
  2758. }
  2759. +EXPORT_SYMBOL_GPL(bcma_find_core);
  2760. +
  2761. +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
  2762. + u8 unit)
  2763. +{
  2764. + struct bcma_device *core;
  2765. +
  2766. + list_for_each_entry(core, &bus->cores, list) {
  2767. + if (core->id.id == coreid && core->core_unit == unit)
  2768. + return core;
  2769. + }
  2770. + return NULL;
  2771. +}
  2772. static void bcma_release_core_dev(struct device *dev)
  2773. {
  2774. @@ -84,16 +111,18 @@ static int bcma_register_cores(struct bc
  2775. list_for_each_entry(core, &bus->cores, list) {
  2776. /* We support that cores ourself */
  2777. switch (core->id.id) {
  2778. + case BCMA_CORE_4706_CHIPCOMMON:
  2779. case BCMA_CORE_CHIPCOMMON:
  2780. case BCMA_CORE_PCI:
  2781. case BCMA_CORE_PCIE:
  2782. case BCMA_CORE_MIPS_74K:
  2783. + case BCMA_CORE_4706_MAC_GBIT_COMMON:
  2784. continue;
  2785. }
  2786. core->dev.release = bcma_release_core_dev;
  2787. core->dev.bus = &bcma_bus_type;
  2788. - dev_set_name(&core->dev, "bcma%d:%d", 0/*bus->num*/, dev_id);
  2789. + dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
  2790. switch (bus->hosttype) {
  2791. case BCMA_HOSTTYPE_PCI:
  2792. @@ -111,41 +140,90 @@ static int bcma_register_cores(struct bc
  2793. err = device_register(&core->dev);
  2794. if (err) {
  2795. - pr_err("Could not register dev for core 0x%03X\n",
  2796. - core->id.id);
  2797. + bcma_err(bus,
  2798. + "Could not register dev for core 0x%03X\n",
  2799. + core->id.id);
  2800. continue;
  2801. }
  2802. core->dev_registered = true;
  2803. dev_id++;
  2804. }
  2805. +#ifdef CONFIG_BCMA_SFLASH
  2806. + if (bus->drv_cc.sflash.present) {
  2807. + err = platform_device_register(&bcma_sflash_dev);
  2808. + if (err)
  2809. + bcma_err(bus, "Error registering serial flash\n");
  2810. + }
  2811. +#endif
  2812. +
  2813. +#ifdef CONFIG_BCMA_NFLASH
  2814. + if (bus->drv_cc.nflash.present) {
  2815. + err = platform_device_register(&bcma_nflash_dev);
  2816. + if (err)
  2817. + bcma_err(bus, "Error registering NAND flash\n");
  2818. + }
  2819. +#endif
  2820. + err = bcma_gpio_init(&bus->drv_cc);
  2821. + if (err == -ENOTSUPP)
  2822. + bcma_debug(bus, "GPIO driver not activated\n");
  2823. + else if (err)
  2824. + bcma_err(bus, "Error registering GPIO driver: %i\n", err);
  2825. +
  2826. + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
  2827. + err = bcma_chipco_watchdog_register(&bus->drv_cc);
  2828. + if (err)
  2829. + bcma_err(bus, "Error registering watchdog driver\n");
  2830. + }
  2831. +
  2832. return 0;
  2833. }
  2834. static void bcma_unregister_cores(struct bcma_bus *bus)
  2835. {
  2836. - struct bcma_device *core;
  2837. + struct bcma_device *core, *tmp;
  2838. - list_for_each_entry(core, &bus->cores, list) {
  2839. + list_for_each_entry_safe(core, tmp, &bus->cores, list) {
  2840. + list_del(&core->list);
  2841. if (core->dev_registered)
  2842. device_unregister(&core->dev);
  2843. }
  2844. + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
  2845. + platform_device_unregister(bus->drv_cc.watchdog);
  2846. }
  2847. -int bcma_bus_register(struct bcma_bus *bus)
  2848. +int __devinit bcma_bus_register(struct bcma_bus *bus)
  2849. {
  2850. int err;
  2851. struct bcma_device *core;
  2852. + mutex_lock(&bcma_buses_mutex);
  2853. + bus->num = bcma_bus_next_num++;
  2854. + mutex_unlock(&bcma_buses_mutex);
  2855. +
  2856. /* Scan for devices (cores) */
  2857. err = bcma_bus_scan(bus);
  2858. if (err) {
  2859. - pr_err("Failed to scan: %d\n", err);
  2860. + bcma_err(bus, "Failed to scan: %d\n", err);
  2861. return -1;
  2862. }
  2863. + /* Early init CC core */
  2864. + core = bcma_find_core(bus, bcma_cc_core_id(bus));
  2865. + if (core) {
  2866. + bus->drv_cc.core = core;
  2867. + bcma_core_chipcommon_early_init(&bus->drv_cc);
  2868. + }
  2869. +
  2870. + /* Try to get SPROM */
  2871. + err = bcma_sprom_get(bus);
  2872. + if (err == -ENOENT) {
  2873. + bcma_err(bus, "No SPROM available\n");
  2874. + } else if (err)
  2875. + bcma_err(bus, "Failed to get SPROM: %d\n", err);
  2876. +
  2877. /* Init CC core */
  2878. - core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
  2879. + core = bcma_find_core(bus, bcma_cc_core_id(bus));
  2880. if (core) {
  2881. bus->drv_cc.core = core;
  2882. bcma_core_chipcommon_init(&bus->drv_cc);
  2883. @@ -159,30 +237,47 @@ int bcma_bus_register(struct bcma_bus *b
  2884. }
  2885. /* Init PCIE core */
  2886. - core = bcma_find_core(bus, BCMA_CORE_PCIE);
  2887. + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0);
  2888. if (core) {
  2889. - bus->drv_pci.core = core;
  2890. - bcma_core_pci_init(&bus->drv_pci);
  2891. + bus->drv_pci[0].core = core;
  2892. + bcma_core_pci_init(&bus->drv_pci[0]);
  2893. }
  2894. - /* Try to get SPROM */
  2895. - err = bcma_sprom_get(bus);
  2896. - if (err == -ENOENT) {
  2897. - pr_err("No SPROM available\n");
  2898. - } else if (err)
  2899. - pr_err("Failed to get SPROM: %d\n", err);
  2900. + /* Init PCIE core */
  2901. + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1);
  2902. + if (core) {
  2903. + bus->drv_pci[1].core = core;
  2904. + bcma_core_pci_init(&bus->drv_pci[1]);
  2905. + }
  2906. +
  2907. + /* Init GBIT MAC COMMON core */
  2908. + core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
  2909. + if (core) {
  2910. + bus->drv_gmac_cmn.core = core;
  2911. + bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn);
  2912. + }
  2913. /* Register found cores */
  2914. bcma_register_cores(bus);
  2915. - pr_info("Bus registered\n");
  2916. + bcma_info(bus, "Bus registered\n");
  2917. return 0;
  2918. }
  2919. void bcma_bus_unregister(struct bcma_bus *bus)
  2920. {
  2921. + struct bcma_device *cores[3];
  2922. +
  2923. + cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
  2924. + cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
  2925. + cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
  2926. +
  2927. bcma_unregister_cores(bus);
  2928. +
  2929. + kfree(cores[2]);
  2930. + kfree(cores[1]);
  2931. + kfree(cores[0]);
  2932. }
  2933. int __init bcma_bus_early_register(struct bcma_bus *bus,
  2934. @@ -196,14 +291,14 @@ int __init bcma_bus_early_register(struc
  2935. bcma_init_bus(bus);
  2936. match.manuf = BCMA_MANUF_BCM;
  2937. - match.id = BCMA_CORE_CHIPCOMMON;
  2938. + match.id = bcma_cc_core_id(bus);
  2939. match.class = BCMA_CL_SIM;
  2940. match.rev = BCMA_ANY_REV;
  2941. /* Scan for chip common core */
  2942. err = bcma_bus_scan_early(bus, &match, core_cc);
  2943. if (err) {
  2944. - pr_err("Failed to scan for common core: %d\n", err);
  2945. + bcma_err(bus, "Failed to scan for common core: %d\n", err);
  2946. return -1;
  2947. }
  2948. @@ -215,25 +310,25 @@ int __init bcma_bus_early_register(struc
  2949. /* Scan for mips core */
  2950. err = bcma_bus_scan_early(bus, &match, core_mips);
  2951. if (err) {
  2952. - pr_err("Failed to scan for mips core: %d\n", err);
  2953. + bcma_err(bus, "Failed to scan for mips core: %d\n", err);
  2954. return -1;
  2955. }
  2956. - /* Init CC core */
  2957. - core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
  2958. + /* Early init CC core */
  2959. + core = bcma_find_core(bus, bcma_cc_core_id(bus));
  2960. if (core) {
  2961. bus->drv_cc.core = core;
  2962. - bcma_core_chipcommon_init(&bus->drv_cc);
  2963. + bcma_core_chipcommon_early_init(&bus->drv_cc);
  2964. }
  2965. - /* Init MIPS core */
  2966. + /* Early init MIPS core */
  2967. core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
  2968. if (core) {
  2969. bus->drv_mips.core = core;
  2970. - bcma_core_mips_init(&bus->drv_mips);
  2971. + bcma_core_mips_early_init(&bus->drv_mips);
  2972. }
  2973. - pr_info("Early bus registered\n");
  2974. + bcma_info(bus, "Early bus registered\n");
  2975. return 0;
  2976. }
  2977. @@ -259,8 +354,7 @@ int bcma_bus_resume(struct bcma_bus *bus
  2978. struct bcma_device *core;
  2979. /* Init CC core */
  2980. - core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
  2981. - if (core) {
  2982. + if (bus->drv_cc.core) {
  2983. bus->drv_cc.setup_done = false;
  2984. bcma_core_chipcommon_init(&bus->drv_cc);
  2985. }
  2986. --- a/drivers/bcma/scan.c
  2987. +++ b/drivers/bcma/scan.c
  2988. @@ -19,15 +19,27 @@ struct bcma_device_id_name {
  2989. u16 id;
  2990. const char *name;
  2991. };
  2992. -struct bcma_device_id_name bcma_device_names[] = {
  2993. +
  2994. +static const struct bcma_device_id_name bcma_arm_device_names[] = {
  2995. + { BCMA_CORE_4706_MAC_GBIT_COMMON, "BCM4706 GBit MAC Common" },
  2996. + { BCMA_CORE_ARM_1176, "ARM 1176" },
  2997. + { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" },
  2998. + { BCMA_CORE_ARM_CM3, "ARM CM3" },
  2999. +};
  3000. +
  3001. +static const struct bcma_device_id_name bcma_bcm_device_names[] = {
  3002. { BCMA_CORE_OOB_ROUTER, "OOB Router" },
  3003. + { BCMA_CORE_4706_CHIPCOMMON, "BCM4706 ChipCommon" },
  3004. + { BCMA_CORE_4706_SOC_RAM, "BCM4706 SOC RAM" },
  3005. + { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" },
  3006. + { BCMA_CORE_AMEMC, "AMEMC (DDR)" },
  3007. + { BCMA_CORE_ALTA, "ALTA (I2S)" },
  3008. { BCMA_CORE_INVALID, "Invalid" },
  3009. { BCMA_CORE_CHIPCOMMON, "ChipCommon" },
  3010. { BCMA_CORE_ILINE20, "ILine 20" },
  3011. { BCMA_CORE_SRAM, "SRAM" },
  3012. { BCMA_CORE_SDRAM, "SDRAM" },
  3013. { BCMA_CORE_PCI, "PCI" },
  3014. - { BCMA_CORE_MIPS, "MIPS" },
  3015. { BCMA_CORE_ETHERNET, "Fast Ethernet" },
  3016. { BCMA_CORE_V90, "V90" },
  3017. { BCMA_CORE_USB11_HOSTDEV, "USB 1.1 Hostdev" },
  3018. @@ -44,7 +56,6 @@ struct bcma_device_id_name bcma_device_n
  3019. { BCMA_CORE_PHY_A, "PHY A" },
  3020. { BCMA_CORE_PHY_B, "PHY B" },
  3021. { BCMA_CORE_PHY_G, "PHY G" },
  3022. - { BCMA_CORE_MIPS_3302, "MIPS 3302" },
  3023. { BCMA_CORE_USB11_HOST, "USB 1.1 Host" },
  3024. { BCMA_CORE_USB11_DEV, "USB 1.1 Device" },
  3025. { BCMA_CORE_USB20_HOST, "USB 2.0 Host" },
  3026. @@ -58,15 +69,11 @@ struct bcma_device_id_name bcma_device_n
  3027. { BCMA_CORE_PHY_N, "PHY N" },
  3028. { BCMA_CORE_SRAM_CTL, "SRAM Controller" },
  3029. { BCMA_CORE_MINI_MACPHY, "Mini MACPHY" },
  3030. - { BCMA_CORE_ARM_1176, "ARM 1176" },
  3031. - { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" },
  3032. { BCMA_CORE_PHY_LP, "PHY LP" },
  3033. { BCMA_CORE_PMU, "PMU" },
  3034. { BCMA_CORE_PHY_SSN, "PHY SSN" },
  3035. { BCMA_CORE_SDIO_DEV, "SDIO Device" },
  3036. - { BCMA_CORE_ARM_CM3, "ARM CM3" },
  3037. { BCMA_CORE_PHY_HT, "PHY HT" },
  3038. - { BCMA_CORE_MIPS_74K, "MIPS 74K" },
  3039. { BCMA_CORE_MAC_GBIT, "GBit MAC" },
  3040. { BCMA_CORE_DDR12_MEM_CTL, "DDR1/DDR2 Memory Controller" },
  3041. { BCMA_CORE_PCIE_RC, "PCIe Root Complex" },
  3042. @@ -79,16 +86,41 @@ struct bcma_device_id_name bcma_device_n
  3043. { BCMA_CORE_SHIM, "SHIM" },
  3044. { BCMA_CORE_DEFAULT, "Default" },
  3045. };
  3046. -const char *bcma_device_name(struct bcma_device_id *id)
  3047. +
  3048. +static const struct bcma_device_id_name bcma_mips_device_names[] = {
  3049. + { BCMA_CORE_MIPS, "MIPS" },
  3050. + { BCMA_CORE_MIPS_3302, "MIPS 3302" },
  3051. + { BCMA_CORE_MIPS_74K, "MIPS 74K" },
  3052. +};
  3053. +
  3054. +static const char *bcma_device_name(const struct bcma_device_id *id)
  3055. {
  3056. - int i;
  3057. + const struct bcma_device_id_name *names;
  3058. + int size, i;
  3059. - if (id->manuf == BCMA_MANUF_BCM) {
  3060. - for (i = 0; i < ARRAY_SIZE(bcma_device_names); i++) {
  3061. - if (bcma_device_names[i].id == id->id)
  3062. - return bcma_device_names[i].name;
  3063. - }
  3064. + /* search manufacturer specific names */
  3065. + switch (id->manuf) {
  3066. + case BCMA_MANUF_ARM:
  3067. + names = bcma_arm_device_names;
  3068. + size = ARRAY_SIZE(bcma_arm_device_names);
  3069. + break;
  3070. + case BCMA_MANUF_BCM:
  3071. + names = bcma_bcm_device_names;
  3072. + size = ARRAY_SIZE(bcma_bcm_device_names);
  3073. + break;
  3074. + case BCMA_MANUF_MIPS:
  3075. + names = bcma_mips_device_names;
  3076. + size = ARRAY_SIZE(bcma_mips_device_names);
  3077. + break;
  3078. + default:
  3079. + return "UNKNOWN";
  3080. + }
  3081. +
  3082. + for (i = 0; i < size; i++) {
  3083. + if (names[i].id == id->id)
  3084. + return names[i].name;
  3085. }
  3086. +
  3087. return "UNKNOWN";
  3088. }
  3089. @@ -212,6 +244,17 @@ static struct bcma_device *bcma_find_cor
  3090. return NULL;
  3091. }
  3092. +static struct bcma_device *bcma_find_core_reverse(struct bcma_bus *bus, u16 coreid)
  3093. +{
  3094. + struct bcma_device *core;
  3095. +
  3096. + list_for_each_entry_reverse(core, &bus->cores, list) {
  3097. + if (core->id.id == coreid)
  3098. + return core;
  3099. + }
  3100. + return NULL;
  3101. +}
  3102. +
  3103. static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
  3104. struct bcma_device_id *match, int core_num,
  3105. struct bcma_device *core)
  3106. @@ -252,11 +295,15 @@ static int bcma_get_next_core(struct bcm
  3107. /* check if component is a core at all */
  3108. if (wrappers[0] + wrappers[1] == 0) {
  3109. - /* we could save addrl of the router
  3110. - if (cid == BCMA_CORE_OOB_ROUTER)
  3111. - */
  3112. - bcma_erom_skip_component(bus, eromptr);
  3113. - return -ENXIO;
  3114. + /* Some specific cores don't need wrappers */
  3115. + switch (core->id.id) {
  3116. + case BCMA_CORE_4706_MAC_GBIT_COMMON:
  3117. + /* Not used yet: case BCMA_CORE_OOB_ROUTER: */
  3118. + break;
  3119. + default:
  3120. + bcma_erom_skip_component(bus, eromptr);
  3121. + return -ENXIO;
  3122. + }
  3123. }
  3124. if (bcma_erom_is_bridge(bus, eromptr)) {
  3125. @@ -286,6 +333,23 @@ static int bcma_get_next_core(struct bcm
  3126. return -EILSEQ;
  3127. }
  3128. + /* First Slave Address Descriptor should be port 0:
  3129. + * the main register space for the core
  3130. + */
  3131. + tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0);
  3132. + if (tmp <= 0) {
  3133. + /* Try again to see if it is a bridge */
  3134. + tmp = bcma_erom_get_addr_desc(bus, eromptr,
  3135. + SCAN_ADDR_TYPE_BRIDGE, 0);
  3136. + if (tmp <= 0) {
  3137. + return -EILSEQ;
  3138. + } else {
  3139. + bcma_info(bus, "Bridge found\n");
  3140. + return -ENXIO;
  3141. + }
  3142. + }
  3143. + core->addr = tmp;
  3144. +
  3145. /* get & parse slave ports */
  3146. for (i = 0; i < ports[1]; i++) {
  3147. for (j = 0; ; j++) {
  3148. @@ -298,7 +362,7 @@ static int bcma_get_next_core(struct bcm
  3149. break;
  3150. } else {
  3151. if (i == 0 && j == 0)
  3152. - core->addr = tmp;
  3153. + core->addr1 = tmp;
  3154. }
  3155. }
  3156. }
  3157. @@ -353,6 +417,7 @@ static int bcma_get_next_core(struct bcm
  3158. void bcma_init_bus(struct bcma_bus *bus)
  3159. {
  3160. s32 tmp;
  3161. + struct bcma_chipinfo *chipinfo = &(bus->chipinfo);
  3162. if (bus->init_done)
  3163. return;
  3164. @@ -363,9 +428,12 @@ void bcma_init_bus(struct bcma_bus *bus)
  3165. bcma_scan_switch_core(bus, BCMA_ADDR_BASE);
  3166. tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID);
  3167. - bus->chipinfo.id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT;
  3168. - bus->chipinfo.rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT;
  3169. - bus->chipinfo.pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT;
  3170. + chipinfo->id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT;
  3171. + chipinfo->rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT;
  3172. + chipinfo->pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT;
  3173. + bcma_info(bus, "Found chip with id 0x%04X, rev 0x%02X and package 0x%02X\n",
  3174. + chipinfo->id, chipinfo->rev, chipinfo->pkg);
  3175. +
  3176. bus->init_done = true;
  3177. }
  3178. @@ -392,9 +460,12 @@ int bcma_bus_scan(struct bcma_bus *bus)
  3179. bcma_scan_switch_core(bus, erombase);
  3180. while (eromptr < eromend) {
  3181. + struct bcma_device *other_core;
  3182. struct bcma_device *core = kzalloc(sizeof(*core), GFP_KERNEL);
  3183. - if (!core)
  3184. - return -ENOMEM;
  3185. + if (!core) {
  3186. + err = -ENOMEM;
  3187. + goto out;
  3188. + }
  3189. INIT_LIST_HEAD(&core->list);
  3190. core->bus = bus;
  3191. @@ -409,25 +480,28 @@ int bcma_bus_scan(struct bcma_bus *bus)
  3192. } else if (err == -ESPIPE) {
  3193. break;
  3194. }
  3195. - return err;
  3196. + goto out;
  3197. }
  3198. core->core_index = core_num++;
  3199. bus->nr_cores++;
  3200. + other_core = bcma_find_core_reverse(bus, core->id.id);
  3201. + core->core_unit = (other_core == NULL) ? 0 : other_core->core_unit + 1;
  3202. - pr_info("Core %d found: %s "
  3203. - "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
  3204. - core->core_index, bcma_device_name(&core->id),
  3205. - core->id.manuf, core->id.id, core->id.rev,
  3206. - core->id.class);
  3207. + bcma_info(bus, "Core %d found: %s (manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
  3208. + core->core_index, bcma_device_name(&core->id),
  3209. + core->id.manuf, core->id.id, core->id.rev,
  3210. + core->id.class);
  3211. - list_add(&core->list, &bus->cores);
  3212. + list_add_tail(&core->list, &bus->cores);
  3213. }
  3214. + err = 0;
  3215. +out:
  3216. if (bus->hosttype == BCMA_HOSTTYPE_SOC)
  3217. iounmap(eromptr);
  3218. - return 0;
  3219. + return err;
  3220. }
  3221. int __init bcma_bus_scan_early(struct bcma_bus *bus,
  3222. @@ -467,21 +541,21 @@ int __init bcma_bus_scan_early(struct bc
  3223. else if (err == -ESPIPE)
  3224. break;
  3225. else if (err < 0)
  3226. - return err;
  3227. + goto out;
  3228. core->core_index = core_num++;
  3229. bus->nr_cores++;
  3230. - pr_info("Core %d found: %s "
  3231. - "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
  3232. - core->core_index, bcma_device_name(&core->id),
  3233. - core->id.manuf, core->id.id, core->id.rev,
  3234. - core->id.class);
  3235. + bcma_info(bus, "Core %d found: %s (manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
  3236. + core->core_index, bcma_device_name(&core->id),
  3237. + core->id.manuf, core->id.id, core->id.rev,
  3238. + core->id.class);
  3239. - list_add(&core->list, &bus->cores);
  3240. + list_add_tail(&core->list, &bus->cores);
  3241. err = 0;
  3242. break;
  3243. }
  3244. +out:
  3245. if (bus->hosttype == BCMA_HOSTTYPE_SOC)
  3246. iounmap(eromptr);
  3247. --- a/drivers/bcma/scan.h
  3248. +++ b/drivers/bcma/scan.h
  3249. @@ -27,7 +27,7 @@
  3250. #define SCAN_CIB_NMW 0x0007C000
  3251. #define SCAN_CIB_NMW_SHIFT 14
  3252. #define SCAN_CIB_NSW 0x00F80000
  3253. -#define SCAN_CIB_NSW_SHIFT 17
  3254. +#define SCAN_CIB_NSW_SHIFT 19
  3255. #define SCAN_CIB_REV 0xFF000000
  3256. #define SCAN_CIB_REV_SHIFT 24
  3257. --- a/drivers/bcma/sprom.c
  3258. +++ b/drivers/bcma/sprom.c
  3259. @@ -2,6 +2,8 @@
  3260. * Broadcom specific AMBA
  3261. * SPROM reading
  3262. *
  3263. + * Copyright 2011, 2012, Hauke Mehrtens <[email protected]>
  3264. + *
  3265. * Licensed under the GNU/GPL. See COPYING for details.
  3266. */
  3267. @@ -14,7 +16,57 @@
  3268. #include <linux/dma-mapping.h>
  3269. #include <linux/slab.h>
  3270. -#define SPOFF(offset) ((offset) / sizeof(u16))
  3271. +static int(*get_fallback_sprom)(struct bcma_bus *dev, struct ssb_sprom *out);
  3272. +
  3273. +/**
  3274. + * bcma_arch_register_fallback_sprom - Registers a method providing a
  3275. + * fallback SPROM if no SPROM is found.
  3276. + *
  3277. + * @sprom_callback: The callback function.
  3278. + *
  3279. + * With this function the architecture implementation may register a
  3280. + * callback handler which fills the SPROM data structure. The fallback is
  3281. + * used for PCI based BCMA devices, where no valid SPROM can be found
  3282. + * in the shadow registers and to provide the SPROM for SoCs where BCMA is
  3283. + * to controll the system bus.
  3284. + *
  3285. + * This function is useful for weird architectures that have a half-assed
  3286. + * BCMA device hardwired to their PCI bus.
  3287. + *
  3288. + * This function is available for architecture code, only. So it is not
  3289. + * exported.
  3290. + */
  3291. +int bcma_arch_register_fallback_sprom(int (*sprom_callback)(struct bcma_bus *bus,
  3292. + struct ssb_sprom *out))
  3293. +{
  3294. + if (get_fallback_sprom)
  3295. + return -EEXIST;
  3296. + get_fallback_sprom = sprom_callback;
  3297. +
  3298. + return 0;
  3299. +}
  3300. +
  3301. +static int bcma_fill_sprom_with_fallback(struct bcma_bus *bus,
  3302. + struct ssb_sprom *out)
  3303. +{
  3304. + int err;
  3305. +
  3306. + if (!get_fallback_sprom) {
  3307. + err = -ENOENT;
  3308. + goto fail;
  3309. + }
  3310. +
  3311. + err = get_fallback_sprom(bus, out);
  3312. + if (err)
  3313. + goto fail;
  3314. +
  3315. + bcma_debug(bus, "Using SPROM revision %d provided by platform.\n",
  3316. + bus->sprom.revision);
  3317. + return 0;
  3318. +fail:
  3319. + bcma_warn(bus, "Using fallback SPROM failed (err %d)\n", err);
  3320. + return err;
  3321. +}
  3322. /**************************************************
  3323. * R/W ops.
  3324. @@ -124,10 +176,37 @@ static int bcma_sprom_valid(const u16 *s
  3325. * SPROM extraction.
  3326. **************************************************/
  3327. +#define SPOFF(offset) ((offset) / sizeof(u16))
  3328. +
  3329. +#define SPEX(_field, _offset, _mask, _shift) \
  3330. + bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift))
  3331. +
  3332. +#define SPEX32(_field, _offset, _mask, _shift) \
  3333. + bus->sprom._field = ((((u32)sprom[SPOFF((_offset)+2)] << 16 | \
  3334. + sprom[SPOFF(_offset)]) & (_mask)) >> (_shift))
  3335. +
  3336. +#define SPEX_ARRAY8(_field, _offset, _mask, _shift) \
  3337. + do { \
  3338. + SPEX(_field[0], _offset + 0, _mask, _shift); \
  3339. + SPEX(_field[1], _offset + 2, _mask, _shift); \
  3340. + SPEX(_field[2], _offset + 4, _mask, _shift); \
  3341. + SPEX(_field[3], _offset + 6, _mask, _shift); \
  3342. + SPEX(_field[4], _offset + 8, _mask, _shift); \
  3343. + SPEX(_field[5], _offset + 10, _mask, _shift); \
  3344. + SPEX(_field[6], _offset + 12, _mask, _shift); \
  3345. + SPEX(_field[7], _offset + 14, _mask, _shift); \
  3346. + } while (0)
  3347. +
  3348. static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
  3349. {
  3350. - u16 v;
  3351. + u16 v, o;
  3352. int i;
  3353. + u16 pwr_info_offset[] = {
  3354. + SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
  3355. + SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
  3356. + };
  3357. + BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
  3358. + ARRAY_SIZE(bus->sprom.core_pwr_info));
  3359. bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
  3360. SSB_SPROM_REVISION_REV;
  3361. @@ -137,107 +216,390 @@ static void bcma_sprom_extract_r8(struct
  3362. *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
  3363. }
  3364. - bus->sprom.board_rev = sprom[SPOFF(SSB_SPROM8_BOARDREV)];
  3365. + SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0);
  3366. +
  3367. + SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0,
  3368. + SSB_SPROM4_TXPID2G0_SHIFT);
  3369. + SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G1,
  3370. + SSB_SPROM4_TXPID2G1_SHIFT);
  3371. + SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G2,
  3372. + SSB_SPROM4_TXPID2G2_SHIFT);
  3373. + SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G3,
  3374. + SSB_SPROM4_TXPID2G3_SHIFT);
  3375. +
  3376. + SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL0,
  3377. + SSB_SPROM4_TXPID5GL0_SHIFT);
  3378. + SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL1,
  3379. + SSB_SPROM4_TXPID5GL1_SHIFT);
  3380. + SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL2,
  3381. + SSB_SPROM4_TXPID5GL2_SHIFT);
  3382. + SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL3,
  3383. + SSB_SPROM4_TXPID5GL3_SHIFT);
  3384. +
  3385. + SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G0,
  3386. + SSB_SPROM4_TXPID5G0_SHIFT);
  3387. + SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G1,
  3388. + SSB_SPROM4_TXPID5G1_SHIFT);
  3389. + SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G2,
  3390. + SSB_SPROM4_TXPID5G2_SHIFT);
  3391. + SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G3,
  3392. + SSB_SPROM4_TXPID5G3_SHIFT);
  3393. +
  3394. + SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH0,
  3395. + SSB_SPROM4_TXPID5GH0_SHIFT);
  3396. + SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH1,
  3397. + SSB_SPROM4_TXPID5GH1_SHIFT);
  3398. + SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH2,
  3399. + SSB_SPROM4_TXPID5GH2_SHIFT);
  3400. + SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH3,
  3401. + SSB_SPROM4_TXPID5GH3_SHIFT);
  3402. +
  3403. + SPEX(boardflags_lo, SSB_SPROM8_BFLLO, ~0, 0);
  3404. + SPEX(boardflags_hi, SSB_SPROM8_BFLHI, ~0, 0);
  3405. + SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, ~0, 0);
  3406. + SPEX(boardflags2_hi, SSB_SPROM8_BFL2HI, ~0, 0);
  3407. +
  3408. + SPEX(alpha2[0], SSB_SPROM8_CCODE, 0xff00, 8);
  3409. + SPEX(alpha2[1], SSB_SPROM8_CCODE, 0x00ff, 0);
  3410. +
  3411. + /* Extract cores power info info */
  3412. + for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
  3413. + o = pwr_info_offset[i];
  3414. + SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
  3415. + SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT);
  3416. + SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
  3417. + SSB_SPROM8_2G_MAXP, 0);
  3418. +
  3419. + SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0);
  3420. + SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0);
  3421. + SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0);
  3422. +
  3423. + SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
  3424. + SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT);
  3425. + SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
  3426. + SSB_SPROM8_5G_MAXP, 0);
  3427. + SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP,
  3428. + SSB_SPROM8_5GH_MAXP, 0);
  3429. + SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP,
  3430. + SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT);
  3431. +
  3432. + SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0);
  3433. + SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0);
  3434. + SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0);
  3435. + SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0);
  3436. + SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0);
  3437. + SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0);
  3438. + SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0);
  3439. + SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0);
  3440. + SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0);
  3441. + }
  3442. +
  3443. + SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TSSIPOS,
  3444. + SSB_SROM8_FEM_TSSIPOS_SHIFT);
  3445. + SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_EXTPA_GAIN,
  3446. + SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
  3447. + SPEX(fem.ghz2.pdet_range, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_PDET_RANGE,
  3448. + SSB_SROM8_FEM_PDET_RANGE_SHIFT);
  3449. + SPEX(fem.ghz2.tr_iso, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TR_ISO,
  3450. + SSB_SROM8_FEM_TR_ISO_SHIFT);
  3451. + SPEX(fem.ghz2.antswlut, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_ANTSWLUT,
  3452. + SSB_SROM8_FEM_ANTSWLUT_SHIFT);
  3453. +
  3454. + SPEX(fem.ghz5.tssipos, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TSSIPOS,
  3455. + SSB_SROM8_FEM_TSSIPOS_SHIFT);
  3456. + SPEX(fem.ghz5.extpa_gain, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_EXTPA_GAIN,
  3457. + SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
  3458. + SPEX(fem.ghz5.pdet_range, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_PDET_RANGE,
  3459. + SSB_SROM8_FEM_PDET_RANGE_SHIFT);
  3460. + SPEX(fem.ghz5.tr_iso, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TR_ISO,
  3461. + SSB_SROM8_FEM_TR_ISO_SHIFT);
  3462. + SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_ANTSWLUT,
  3463. + SSB_SROM8_FEM_ANTSWLUT_SHIFT);
  3464. +
  3465. + SPEX(ant_available_a, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_A,
  3466. + SSB_SPROM8_ANTAVAIL_A_SHIFT);
  3467. + SPEX(ant_available_bg, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_BG,
  3468. + SSB_SPROM8_ANTAVAIL_BG_SHIFT);
  3469. + SPEX(maxpwr_bg, SSB_SPROM8_MAXP_BG, SSB_SPROM8_MAXP_BG_MASK, 0);
  3470. + SPEX(itssi_bg, SSB_SPROM8_MAXP_BG, SSB_SPROM8_ITSSI_BG,
  3471. + SSB_SPROM8_ITSSI_BG_SHIFT);
  3472. + SPEX(maxpwr_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_MAXP_A_MASK, 0);
  3473. + SPEX(itssi_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_ITSSI_A,
  3474. + SSB_SPROM8_ITSSI_A_SHIFT);
  3475. + SPEX(maxpwr_ah, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AH_MASK, 0);
  3476. + SPEX(maxpwr_al, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AL_MASK,
  3477. + SSB_SPROM8_MAXP_AL_SHIFT);
  3478. + SPEX(gpio0, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P0, 0);
  3479. + SPEX(gpio1, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P1,
  3480. + SSB_SPROM8_GPIOA_P1_SHIFT);
  3481. + SPEX(gpio2, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P2, 0);
  3482. + SPEX(gpio3, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P3,
  3483. + SSB_SPROM8_GPIOB_P3_SHIFT);
  3484. + SPEX(tri2g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI2G, 0);
  3485. + SPEX(tri5g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI5G,
  3486. + SSB_SPROM8_TRI5G_SHIFT);
  3487. + SPEX(tri5gl, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GL, 0);
  3488. + SPEX(tri5gh, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GH,
  3489. + SSB_SPROM8_TRI5GH_SHIFT);
  3490. + SPEX(rxpo2g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO2G,
  3491. + SSB_SPROM8_RXPO2G_SHIFT);
  3492. + SPEX(rxpo5g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO5G,
  3493. + SSB_SPROM8_RXPO5G_SHIFT);
  3494. + SPEX(rssismf2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMF2G, 0);
  3495. + SPEX(rssismc2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMC2G,
  3496. + SSB_SPROM8_RSSISMC2G_SHIFT);
  3497. + SPEX(rssisav2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISAV2G,
  3498. + SSB_SPROM8_RSSISAV2G_SHIFT);
  3499. + SPEX(bxa2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_BXA2G,
  3500. + SSB_SPROM8_BXA2G_SHIFT);
  3501. + SPEX(rssismf5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMF5G, 0);
  3502. + SPEX(rssismc5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMC5G,
  3503. + SSB_SPROM8_RSSISMC5G_SHIFT);
  3504. + SPEX(rssisav5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISAV5G,
  3505. + SSB_SPROM8_RSSISAV5G_SHIFT);
  3506. + SPEX(bxa5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_BXA5G,
  3507. + SSB_SPROM8_BXA5G_SHIFT);
  3508. +
  3509. + SPEX(pa0b0, SSB_SPROM8_PA0B0, ~0, 0);
  3510. + SPEX(pa0b1, SSB_SPROM8_PA0B1, ~0, 0);
  3511. + SPEX(pa0b2, SSB_SPROM8_PA0B2, ~0, 0);
  3512. + SPEX(pa1b0, SSB_SPROM8_PA1B0, ~0, 0);
  3513. + SPEX(pa1b1, SSB_SPROM8_PA1B1, ~0, 0);
  3514. + SPEX(pa1b2, SSB_SPROM8_PA1B2, ~0, 0);
  3515. + SPEX(pa1lob0, SSB_SPROM8_PA1LOB0, ~0, 0);
  3516. + SPEX(pa1lob1, SSB_SPROM8_PA1LOB1, ~0, 0);
  3517. + SPEX(pa1lob2, SSB_SPROM8_PA1LOB2, ~0, 0);
  3518. + SPEX(pa1hib0, SSB_SPROM8_PA1HIB0, ~0, 0);
  3519. + SPEX(pa1hib1, SSB_SPROM8_PA1HIB1, ~0, 0);
  3520. + SPEX(pa1hib2, SSB_SPROM8_PA1HIB2, ~0, 0);
  3521. + SPEX(cck2gpo, SSB_SPROM8_CCK2GPO, ~0, 0);
  3522. + SPEX32(ofdm2gpo, SSB_SPROM8_OFDM2GPO, ~0, 0);
  3523. + SPEX32(ofdm5glpo, SSB_SPROM8_OFDM5GLPO, ~0, 0);
  3524. + SPEX32(ofdm5gpo, SSB_SPROM8_OFDM5GPO, ~0, 0);
  3525. + SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, ~0, 0);
  3526. +
  3527. + /* Extract the antenna gain values. */
  3528. + SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
  3529. + SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
  3530. + SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
  3531. + SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
  3532. + SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
  3533. + SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
  3534. + SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
  3535. + SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
  3536. +
  3537. + SPEX(leddc_on_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_ON,
  3538. + SSB_SPROM8_LEDDC_ON_SHIFT);
  3539. + SPEX(leddc_off_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_OFF,
  3540. + SSB_SPROM8_LEDDC_OFF_SHIFT);
  3541. +
  3542. + SPEX(txchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_TXCHAIN,
  3543. + SSB_SPROM8_TXRXC_TXCHAIN_SHIFT);
  3544. + SPEX(rxchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_RXCHAIN,
  3545. + SSB_SPROM8_TXRXC_RXCHAIN_SHIFT);
  3546. + SPEX(antswitch, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_SWITCH,
  3547. + SSB_SPROM8_TXRXC_SWITCH_SHIFT);
  3548. +
  3549. + SPEX(opo, SSB_SPROM8_OFDM2GPO, 0x00ff, 0);
  3550. +
  3551. + SPEX_ARRAY8(mcs2gpo, SSB_SPROM8_2G_MCSPO, ~0, 0);
  3552. + SPEX_ARRAY8(mcs5gpo, SSB_SPROM8_5G_MCSPO, ~0, 0);
  3553. + SPEX_ARRAY8(mcs5glpo, SSB_SPROM8_5GL_MCSPO, ~0, 0);
  3554. + SPEX_ARRAY8(mcs5ghpo, SSB_SPROM8_5GH_MCSPO, ~0, 0);
  3555. +
  3556. + SPEX(rawtempsense, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_RAWTEMP,
  3557. + SSB_SPROM8_RAWTS_RAWTEMP_SHIFT);
  3558. + SPEX(measpower, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_MEASPOWER,
  3559. + SSB_SPROM8_RAWTS_MEASPOWER_SHIFT);
  3560. + SPEX(tempsense_slope, SSB_SPROM8_OPT_CORRX,
  3561. + SSB_SPROM8_OPT_CORRX_TEMP_SLOPE,
  3562. + SSB_SPROM8_OPT_CORRX_TEMP_SLOPE_SHIFT);
  3563. + SPEX(tempcorrx, SSB_SPROM8_OPT_CORRX, SSB_SPROM8_OPT_CORRX_TEMPCORRX,
  3564. + SSB_SPROM8_OPT_CORRX_TEMPCORRX_SHIFT);
  3565. + SPEX(tempsense_option, SSB_SPROM8_OPT_CORRX,
  3566. + SSB_SPROM8_OPT_CORRX_TEMP_OPTION,
  3567. + SSB_SPROM8_OPT_CORRX_TEMP_OPTION_SHIFT);
  3568. + SPEX(freqoffset_corr, SSB_SPROM8_HWIQ_IQSWP,
  3569. + SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR,
  3570. + SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR_SHIFT);
  3571. + SPEX(iqcal_swp_dis, SSB_SPROM8_HWIQ_IQSWP,
  3572. + SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP,
  3573. + SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP_SHIFT);
  3574. + SPEX(hw_iqcal_en, SSB_SPROM8_HWIQ_IQSWP, SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL,
  3575. + SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL_SHIFT);
  3576. +
  3577. + SPEX(bw40po, SSB_SPROM8_BW40PO, ~0, 0);
  3578. + SPEX(cddpo, SSB_SPROM8_CDDPO, ~0, 0);
  3579. + SPEX(stbcpo, SSB_SPROM8_STBCPO, ~0, 0);
  3580. + SPEX(bwduppo, SSB_SPROM8_BWDUPPO, ~0, 0);
  3581. +
  3582. + SPEX(tempthresh, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_TRESH,
  3583. + SSB_SPROM8_THERMAL_TRESH_SHIFT);
  3584. + SPEX(tempoffset, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_OFFSET,
  3585. + SSB_SPROM8_THERMAL_OFFSET_SHIFT);
  3586. + SPEX(phycal_tempdelta, SSB_SPROM8_TEMPDELTA,
  3587. + SSB_SPROM8_TEMPDELTA_PHYCAL,
  3588. + SSB_SPROM8_TEMPDELTA_PHYCAL_SHIFT);
  3589. + SPEX(temps_period, SSB_SPROM8_TEMPDELTA, SSB_SPROM8_TEMPDELTA_PERIOD,
  3590. + SSB_SPROM8_TEMPDELTA_PERIOD_SHIFT);
  3591. + SPEX(temps_hysteresis, SSB_SPROM8_TEMPDELTA,
  3592. + SSB_SPROM8_TEMPDELTA_HYSTERESIS,
  3593. + SSB_SPROM8_TEMPDELTA_HYSTERESIS_SHIFT);
  3594. +}
  3595. +
  3596. +/*
  3597. + * Indicates the presence of external SPROM.
  3598. + */
  3599. +static bool bcma_sprom_ext_available(struct bcma_bus *bus)
  3600. +{
  3601. + u32 chip_status;
  3602. + u32 srom_control;
  3603. + u32 present_mask;
  3604. +
  3605. + if (bus->drv_cc.core->id.rev >= 31) {
  3606. + if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM))
  3607. + return false;
  3608. +
  3609. + srom_control = bcma_read32(bus->drv_cc.core,
  3610. + BCMA_CC_SROM_CONTROL);
  3611. + return srom_control & BCMA_CC_SROM_CONTROL_PRESENT;
  3612. + }
  3613. +
  3614. + /* older chipcommon revisions use chip status register */
  3615. + chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT);
  3616. + switch (bus->chipinfo.id) {
  3617. + case BCMA_CHIP_ID_BCM4313:
  3618. + present_mask = BCMA_CC_CHIPST_4313_SPROM_PRESENT;
  3619. + break;
  3620. +
  3621. + case BCMA_CHIP_ID_BCM4331:
  3622. + present_mask = BCMA_CC_CHIPST_4331_SPROM_PRESENT;
  3623. + break;
  3624. - bus->sprom.txpid2g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] &
  3625. - SSB_SPROM4_TXPID2G0) >> SSB_SPROM4_TXPID2G0_SHIFT;
  3626. - bus->sprom.txpid2g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] &
  3627. - SSB_SPROM4_TXPID2G1) >> SSB_SPROM4_TXPID2G1_SHIFT;
  3628. - bus->sprom.txpid2g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] &
  3629. - SSB_SPROM4_TXPID2G2) >> SSB_SPROM4_TXPID2G2_SHIFT;
  3630. - bus->sprom.txpid2g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] &
  3631. - SSB_SPROM4_TXPID2G3) >> SSB_SPROM4_TXPID2G3_SHIFT;
  3632. -
  3633. - bus->sprom.txpid5gl[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] &
  3634. - SSB_SPROM4_TXPID5GL0) >> SSB_SPROM4_TXPID5GL0_SHIFT;
  3635. - bus->sprom.txpid5gl[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] &
  3636. - SSB_SPROM4_TXPID5GL1) >> SSB_SPROM4_TXPID5GL1_SHIFT;
  3637. - bus->sprom.txpid5gl[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] &
  3638. - SSB_SPROM4_TXPID5GL2) >> SSB_SPROM4_TXPID5GL2_SHIFT;
  3639. - bus->sprom.txpid5gl[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] &
  3640. - SSB_SPROM4_TXPID5GL3) >> SSB_SPROM4_TXPID5GL3_SHIFT;
  3641. -
  3642. - bus->sprom.txpid5g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] &
  3643. - SSB_SPROM4_TXPID5G0) >> SSB_SPROM4_TXPID5G0_SHIFT;
  3644. - bus->sprom.txpid5g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] &
  3645. - SSB_SPROM4_TXPID5G1) >> SSB_SPROM4_TXPID5G1_SHIFT;
  3646. - bus->sprom.txpid5g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] &
  3647. - SSB_SPROM4_TXPID5G2) >> SSB_SPROM4_TXPID5G2_SHIFT;
  3648. - bus->sprom.txpid5g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] &
  3649. - SSB_SPROM4_TXPID5G3) >> SSB_SPROM4_TXPID5G3_SHIFT;
  3650. -
  3651. - bus->sprom.txpid5gh[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] &
  3652. - SSB_SPROM4_TXPID5GH0) >> SSB_SPROM4_TXPID5GH0_SHIFT;
  3653. - bus->sprom.txpid5gh[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] &
  3654. - SSB_SPROM4_TXPID5GH1) >> SSB_SPROM4_TXPID5GH1_SHIFT;
  3655. - bus->sprom.txpid5gh[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] &
  3656. - SSB_SPROM4_TXPID5GH2) >> SSB_SPROM4_TXPID5GH2_SHIFT;
  3657. - bus->sprom.txpid5gh[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] &
  3658. - SSB_SPROM4_TXPID5GH3) >> SSB_SPROM4_TXPID5GH3_SHIFT;
  3659. -
  3660. - bus->sprom.boardflags_lo = sprom[SPOFF(SSB_SPROM8_BFLLO)];
  3661. - bus->sprom.boardflags_hi = sprom[SPOFF(SSB_SPROM8_BFLHI)];
  3662. - bus->sprom.boardflags2_lo = sprom[SPOFF(SSB_SPROM8_BFL2LO)];
  3663. - bus->sprom.boardflags2_hi = sprom[SPOFF(SSB_SPROM8_BFL2HI)];
  3664. -
  3665. - bus->sprom.country_code = sprom[SPOFF(SSB_SPROM8_CCODE)];
  3666. -
  3667. - bus->sprom.fem.ghz2.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
  3668. - SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT;
  3669. - bus->sprom.fem.ghz2.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
  3670. - SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT;
  3671. - bus->sprom.fem.ghz2.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
  3672. - SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT;
  3673. - bus->sprom.fem.ghz2.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
  3674. - SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT;
  3675. - bus->sprom.fem.ghz2.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM2G)] &
  3676. - SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT;
  3677. -
  3678. - bus->sprom.fem.ghz5.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
  3679. - SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT;
  3680. - bus->sprom.fem.ghz5.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
  3681. - SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT;
  3682. - bus->sprom.fem.ghz5.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
  3683. - SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT;
  3684. - bus->sprom.fem.ghz5.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
  3685. - SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT;
  3686. - bus->sprom.fem.ghz5.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM5G)] &
  3687. - SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT;
  3688. + default:
  3689. + return true;
  3690. + }
  3691. +
  3692. + return chip_status & present_mask;
  3693. +}
  3694. +
  3695. +/*
  3696. + * Indicates that on-chip OTP memory is present and enabled.
  3697. + */
  3698. +static bool bcma_sprom_onchip_available(struct bcma_bus *bus)
  3699. +{
  3700. + u32 chip_status;
  3701. + u32 otpsize = 0;
  3702. + bool present;
  3703. +
  3704. + chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT);
  3705. + switch (bus->chipinfo.id) {
  3706. + case BCMA_CHIP_ID_BCM4313:
  3707. + present = chip_status & BCMA_CC_CHIPST_4313_OTP_PRESENT;
  3708. + break;
  3709. +
  3710. + case BCMA_CHIP_ID_BCM4331:
  3711. + present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT;
  3712. + break;
  3713. +
  3714. + case BCMA_CHIP_ID_BCM43224:
  3715. + case BCMA_CHIP_ID_BCM43225:
  3716. + /* for these chips OTP is always available */
  3717. + present = true;
  3718. + break;
  3719. + case BCMA_CHIP_ID_BCM43227:
  3720. + case BCMA_CHIP_ID_BCM43228:
  3721. + case BCMA_CHIP_ID_BCM43428:
  3722. + present = chip_status & BCMA_CC_CHIPST_43228_OTP_PRESENT;
  3723. + break;
  3724. + default:
  3725. + present = false;
  3726. + break;
  3727. + }
  3728. +
  3729. + if (present) {
  3730. + otpsize = bus->drv_cc.capabilities & BCMA_CC_CAP_OTPS;
  3731. + otpsize >>= BCMA_CC_CAP_OTPS_SHIFT;
  3732. + }
  3733. +
  3734. + return otpsize != 0;
  3735. +}
  3736. +
  3737. +/*
  3738. + * Verify OTP is filled and determine the byte
  3739. + * offset where SPROM data is located.
  3740. + *
  3741. + * On error, returns 0; byte offset otherwise.
  3742. + */
  3743. +static int bcma_sprom_onchip_offset(struct bcma_bus *bus)
  3744. +{
  3745. + struct bcma_device *cc = bus->drv_cc.core;
  3746. + u32 offset;
  3747. +
  3748. + /* verify OTP status */
  3749. + if ((bcma_read32(cc, BCMA_CC_OTPS) & BCMA_CC_OTPS_GU_PROG_HW) == 0)
  3750. + return 0;
  3751. +
  3752. + /* obtain bit offset from otplayout register */
  3753. + offset = (bcma_read32(cc, BCMA_CC_OTPL) & BCMA_CC_OTPL_GURGN_OFFSET);
  3754. + return BCMA_CC_SPROM + (offset >> 3);
  3755. }
  3756. int bcma_sprom_get(struct bcma_bus *bus)
  3757. {
  3758. - u16 offset;
  3759. + u16 offset = BCMA_CC_SPROM;
  3760. u16 *sprom;
  3761. int err = 0;
  3762. if (!bus->drv_cc.core)
  3763. return -EOPNOTSUPP;
  3764. - if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM))
  3765. - return -ENOENT;
  3766. + if (!bcma_sprom_ext_available(bus)) {
  3767. + bool sprom_onchip;
  3768. +
  3769. + /*
  3770. + * External SPROM takes precedence so check
  3771. + * on-chip OTP only when no external SPROM
  3772. + * is present.
  3773. + */
  3774. + sprom_onchip = bcma_sprom_onchip_available(bus);
  3775. + if (sprom_onchip) {
  3776. + /* determine offset */
  3777. + offset = bcma_sprom_onchip_offset(bus);
  3778. + }
  3779. + if (!offset || !sprom_onchip) {
  3780. + /*
  3781. + * Maybe there is no SPROM on the device?
  3782. + * Now we ask the arch code if there is some sprom
  3783. + * available for this device in some other storage.
  3784. + */
  3785. + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
  3786. + return err;
  3787. + }
  3788. + }
  3789. sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
  3790. GFP_KERNEL);
  3791. if (!sprom)
  3792. return -ENOMEM;
  3793. - if (bus->chipinfo.id == 0x4331)
  3794. + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
  3795. + bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
  3796. bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
  3797. - /* Most cards have SPROM moved by additional offset 0x30 (48 dwords).
  3798. - * According to brcm80211 this applies to cards with PCIe rev >= 6
  3799. - * TODO: understand this condition and use it */
  3800. - offset = (bus->chipinfo.id == 0x4331) ? BCMA_CC_SPROM :
  3801. - BCMA_CC_SPROM_PCIE6;
  3802. + bcma_debug(bus, "SPROM offset 0x%x\n", offset);
  3803. bcma_sprom_read(bus, offset, sprom);
  3804. - if (bus->chipinfo.id == 0x4331)
  3805. + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
  3806. + bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
  3807. bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
  3808. err = bcma_sprom_valid(sprom);
  3809. - if (err)
  3810. + if (err) {
  3811. + bcma_warn(bus, "invalid sprom read from the PCIe card, try to use fallback sprom\n");
  3812. + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
  3813. goto out;
  3814. + }
  3815. bcma_sprom_extract_r8(bus, sprom);
  3816. --- a/include/linux/bcma/bcma.h
  3817. +++ b/include/linux/bcma/bcma.h
  3818. @@ -7,9 +7,10 @@
  3819. #include <linux/bcma/bcma_driver_chipcommon.h>
  3820. #include <linux/bcma/bcma_driver_pci.h>
  3821. #include <linux/bcma/bcma_driver_mips.h>
  3822. +#include <linux/bcma/bcma_driver_gmac_cmn.h>
  3823. #include <linux/ssb/ssb.h> /* SPROM sharing */
  3824. -#include "bcma_regs.h"
  3825. +#include <linux/bcma/bcma_regs.h>
  3826. struct bcma_device;
  3827. struct bcma_bus;
  3828. @@ -26,6 +27,11 @@ struct bcma_chipinfo {
  3829. u8 pkg;
  3830. };
  3831. +struct bcma_boardinfo {
  3832. + u16 vendor;
  3833. + u16 type;
  3834. +};
  3835. +
  3836. enum bcma_clkmode {
  3837. BCMA_CLKMODE_FAST,
  3838. BCMA_CLKMODE_DYNAMIC,
  3839. @@ -65,6 +71,13 @@ struct bcma_host_ops {
  3840. /* Core-ID values. */
  3841. #define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */
  3842. +#define BCMA_CORE_4706_CHIPCOMMON 0x500
  3843. +#define BCMA_CORE_4706_SOC_RAM 0x50E
  3844. +#define BCMA_CORE_4706_MAC_GBIT 0x52D
  3845. +#define BCMA_CORE_AMEMC 0x52E /* DDR1/2 memory controller core */
  3846. +#define BCMA_CORE_ALTA 0x534 /* I2S core */
  3847. +#define BCMA_CORE_4706_MAC_GBIT_COMMON 0x5DC
  3848. +#define BCMA_CORE_DDR23_PHY 0x5DD
  3849. #define BCMA_CORE_INVALID 0x700
  3850. #define BCMA_CORE_CHIPCOMMON 0x800
  3851. #define BCMA_CORE_ILINE20 0x801
  3852. @@ -125,6 +138,41 @@ struct bcma_host_ops {
  3853. #define BCMA_MAX_NR_CORES 16
  3854. +/* Chip IDs of PCIe devices */
  3855. +#define BCMA_CHIP_ID_BCM4313 0x4313
  3856. +#define BCMA_CHIP_ID_BCM43224 43224
  3857. +#define BCMA_PKG_ID_BCM43224_FAB_CSM 0x8
  3858. +#define BCMA_PKG_ID_BCM43224_FAB_SMIC 0xa
  3859. +#define BCMA_CHIP_ID_BCM43225 43225
  3860. +#define BCMA_CHIP_ID_BCM43227 43227
  3861. +#define BCMA_CHIP_ID_BCM43228 43228
  3862. +#define BCMA_CHIP_ID_BCM43421 43421
  3863. +#define BCMA_CHIP_ID_BCM43428 43428
  3864. +#define BCMA_CHIP_ID_BCM43431 43431
  3865. +#define BCMA_CHIP_ID_BCM43460 43460
  3866. +#define BCMA_CHIP_ID_BCM4331 0x4331
  3867. +#define BCMA_CHIP_ID_BCM6362 0x6362
  3868. +#define BCMA_CHIP_ID_BCM4360 0x4360
  3869. +#define BCMA_CHIP_ID_BCM4352 0x4352
  3870. +
  3871. +/* Chip IDs of SoCs */
  3872. +#define BCMA_CHIP_ID_BCM4706 0x5300
  3873. +#define BCMA_PKG_ID_BCM4706L 1
  3874. +#define BCMA_CHIP_ID_BCM4716 0x4716
  3875. +#define BCMA_PKG_ID_BCM4716 8
  3876. +#define BCMA_PKG_ID_BCM4717 9
  3877. +#define BCMA_PKG_ID_BCM4718 10
  3878. +#define BCMA_CHIP_ID_BCM47162 47162
  3879. +#define BCMA_CHIP_ID_BCM4748 0x4748
  3880. +#define BCMA_CHIP_ID_BCM4749 0x4749
  3881. +#define BCMA_CHIP_ID_BCM5356 0x5356
  3882. +#define BCMA_CHIP_ID_BCM5357 0x5357
  3883. +#define BCMA_PKG_ID_BCM5358 9
  3884. +#define BCMA_PKG_ID_BCM47186 10
  3885. +#define BCMA_PKG_ID_BCM5357 11
  3886. +#define BCMA_CHIP_ID_BCM53572 53572
  3887. +#define BCMA_PKG_ID_BCM47188 9
  3888. +
  3889. struct bcma_device {
  3890. struct bcma_bus *bus;
  3891. struct bcma_device_id id;
  3892. @@ -136,8 +184,10 @@ struct bcma_device {
  3893. bool dev_registered;
  3894. u8 core_index;
  3895. + u8 core_unit;
  3896. u32 addr;
  3897. + u32 addr1;
  3898. u32 wrap;
  3899. void __iomem *io_addr;
  3900. @@ -175,6 +225,12 @@ int __bcma_driver_register(struct bcma_d
  3901. extern void bcma_driver_unregister(struct bcma_driver *drv);
  3902. +/* Set a fallback SPROM.
  3903. + * See kdoc at the function definition for complete documentation. */
  3904. +extern int bcma_arch_register_fallback_sprom(
  3905. + int (*sprom_callback)(struct bcma_bus *bus,
  3906. + struct ssb_sprom *out));
  3907. +
  3908. struct bcma_bus {
  3909. /* The MMIO area. */
  3910. void __iomem *mmio;
  3911. @@ -191,14 +247,18 @@ struct bcma_bus {
  3912. struct bcma_chipinfo chipinfo;
  3913. + struct bcma_boardinfo boardinfo;
  3914. +
  3915. struct bcma_device *mapped_core;
  3916. struct list_head cores;
  3917. u8 nr_cores;
  3918. u8 init_done:1;
  3919. + u8 num;
  3920. struct bcma_drv_cc drv_cc;
  3921. - struct bcma_drv_pci drv_pci;
  3922. + struct bcma_drv_pci drv_pci[2];
  3923. struct bcma_drv_mips drv_mips;
  3924. + struct bcma_drv_gmac_cmn drv_gmac_cmn;
  3925. /* We decided to share SPROM struct with SSB as long as we do not need
  3926. * any hacks for BCMA. This simplifies drivers code. */
  3927. @@ -282,6 +342,7 @@ static inline void bcma_maskset16(struct
  3928. bcma_write16(cc, offset, (bcma_read16(cc, offset) & mask) | set);
  3929. }
  3930. +extern struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid);
  3931. extern bool bcma_core_is_enabled(struct bcma_device *core);
  3932. extern void bcma_core_disable(struct bcma_device *core, u32 flags);
  3933. extern int bcma_core_enable(struct bcma_device *core, u32 flags);
  3934. @@ -289,6 +350,7 @@ extern void bcma_core_set_clockmode(stru
  3935. enum bcma_clkmode clkmode);
  3936. extern void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status,
  3937. bool on);
  3938. +extern u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset);
  3939. #define BCMA_DMA_TRANSLATION_MASK 0xC0000000
  3940. #define BCMA_DMA_TRANSLATION_NONE 0x00000000
  3941. #define BCMA_DMA_TRANSLATION_DMA32_CMT 0x40000000 /* Client Mode Translation for 32-bit DMA */
  3942. --- a/include/linux/bcma/bcma_driver_chipcommon.h
  3943. +++ b/include/linux/bcma/bcma_driver_chipcommon.h
  3944. @@ -1,6 +1,9 @@
  3945. #ifndef LINUX_BCMA_DRIVER_CC_H_
  3946. #define LINUX_BCMA_DRIVER_CC_H_
  3947. +#include <linux/platform_device.h>
  3948. +#include <linux/gpio.h>
  3949. +
  3950. /** ChipCommon core registers. **/
  3951. #define BCMA_CC_ID 0x0000
  3952. #define BCMA_CC_ID_ID 0x0000FFFF
  3953. @@ -24,7 +27,7 @@
  3954. #define BCMA_CC_FLASHT_NONE 0x00000000 /* No flash */
  3955. #define BCMA_CC_FLASHT_STSER 0x00000100 /* ST serial flash */
  3956. #define BCMA_CC_FLASHT_ATSER 0x00000200 /* Atmel serial flash */
  3957. -#define BCMA_CC_FLASHT_NFLASH 0x00000200
  3958. +#define BCMA_CC_FLASHT_NFLASH 0x00000200 /* NAND flash */
  3959. #define BCMA_CC_FLASHT_PARA 0x00000700 /* Parallel flash */
  3960. #define BCMA_CC_CAP_PLLT 0x00038000 /* PLL Type */
  3961. #define BCMA_PLLTYPE_NONE 0x00000000
  3962. @@ -45,6 +48,7 @@
  3963. #define BCMA_CC_CAP_PMU 0x10000000 /* PMU available (rev >= 20) */
  3964. #define BCMA_CC_CAP_ECI 0x20000000 /* ECI available (rev >= 20) */
  3965. #define BCMA_CC_CAP_SPROM 0x40000000 /* SPROM present */
  3966. +#define BCMA_CC_CAP_NFLASH 0x80000000 /* NAND flash present (rev >= 35 or BCM4706?) */
  3967. #define BCMA_CC_CORECTL 0x0008
  3968. #define BCMA_CC_CORECTL_UARTCLK0 0x00000001 /* Drive UART with internal clock */
  3969. #define BCMA_CC_CORECTL_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
  3970. @@ -56,6 +60,9 @@
  3971. #define BCMA_CC_OTPS_HW_PROTECT 0x00000001
  3972. #define BCMA_CC_OTPS_SW_PROTECT 0x00000002
  3973. #define BCMA_CC_OTPS_CID_PROTECT 0x00000004
  3974. +#define BCMA_CC_OTPS_GU_PROG_IND 0x00000F00 /* General Use programmed indication */
  3975. +#define BCMA_CC_OTPS_GU_PROG_IND_SHIFT 8
  3976. +#define BCMA_CC_OTPS_GU_PROG_HW 0x00000100 /* HW region programmed */
  3977. #define BCMA_CC_OTPC 0x0014 /* OTP control */
  3978. #define BCMA_CC_OTPC_RECWAIT 0xFF000000
  3979. #define BCMA_CC_OTPC_PROGWAIT 0x00FFFF00
  3980. @@ -72,6 +79,8 @@
  3981. #define BCMA_CC_OTPP_READ 0x40000000
  3982. #define BCMA_CC_OTPP_START 0x80000000
  3983. #define BCMA_CC_OTPP_BUSY 0x80000000
  3984. +#define BCMA_CC_OTPL 0x001C /* OTP layout */
  3985. +#define BCMA_CC_OTPL_GURGN_OFFSET 0x00000FFF /* offset of general use region */
  3986. #define BCMA_CC_IRQSTAT 0x0020
  3987. #define BCMA_CC_IRQMASK 0x0024
  3988. #define BCMA_CC_IRQ_GPIO 0x00000001 /* gpio intr */
  3989. @@ -79,6 +88,23 @@
  3990. #define BCMA_CC_IRQ_WDRESET 0x80000000 /* watchdog reset occurred */
  3991. #define BCMA_CC_CHIPCTL 0x0028 /* Rev >= 11 only */
  3992. #define BCMA_CC_CHIPSTAT 0x002C /* Rev >= 11 only */
  3993. +#define BCMA_CC_CHIPST_4313_SPROM_PRESENT 1
  3994. +#define BCMA_CC_CHIPST_4313_OTP_PRESENT 2
  3995. +#define BCMA_CC_CHIPST_4331_SPROM_PRESENT 2
  3996. +#define BCMA_CC_CHIPST_4331_OTP_PRESENT 4
  3997. +#define BCMA_CC_CHIPST_43228_ILP_DIV_EN 0x00000001
  3998. +#define BCMA_CC_CHIPST_43228_OTP_PRESENT 0x00000002
  3999. +#define BCMA_CC_CHIPST_43228_SERDES_REFCLK_PADSEL 0x00000004
  4000. +#define BCMA_CC_CHIPST_43228_SDIO_MODE 0x00000008
  4001. +#define BCMA_CC_CHIPST_43228_SDIO_OTP_PRESENT 0x00000010
  4002. +#define BCMA_CC_CHIPST_43228_SDIO_RESET 0x00000020
  4003. +#define BCMA_CC_CHIPST_4706_PKG_OPTION BIT(0) /* 0: full-featured package 1: low-cost package */
  4004. +#define BCMA_CC_CHIPST_4706_SFLASH_PRESENT BIT(1) /* 0: parallel, 1: serial flash is present */
  4005. +#define BCMA_CC_CHIPST_4706_SFLASH_TYPE BIT(2) /* 0: 8b-p/ST-s flash, 1: 16b-p/Atmal-s flash */
  4006. +#define BCMA_CC_CHIPST_4706_MIPS_BENDIAN BIT(3) /* 0: little, 1: big endian */
  4007. +#define BCMA_CC_CHIPST_4706_PCIE1_DISABLE BIT(5) /* PCIE1 enable strap pin */
  4008. +#define BCMA_CC_CHIPST_5357_NAND_BOOT BIT(4) /* NAND boot, valid for CC rev 38 and/or BCM5357 */
  4009. +#define BCMA_CC_CHIPST_4360_XTAL_40MZ 0x00000001
  4010. #define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */
  4011. #define BCMA_CC_JCMD_START 0x80000000
  4012. #define BCMA_CC_JCMD_BUSY 0x80000000
  4013. @@ -108,10 +134,58 @@
  4014. #define BCMA_CC_JCTL_EXT_EN 2 /* Enable external targets */
  4015. #define BCMA_CC_JCTL_EN 1 /* Enable Jtag master */
  4016. #define BCMA_CC_FLASHCTL 0x0040
  4017. +/* Start/busy bit in flashcontrol */
  4018. +#define BCMA_CC_FLASHCTL_OPCODE 0x000000ff
  4019. +#define BCMA_CC_FLASHCTL_ACTION 0x00000700
  4020. +#define BCMA_CC_FLASHCTL_CS_ACTIVE 0x00001000 /* Chip Select Active, rev >= 20 */
  4021. #define BCMA_CC_FLASHCTL_START 0x80000000
  4022. #define BCMA_CC_FLASHCTL_BUSY BCMA_CC_FLASHCTL_START
  4023. +/* Flashcontrol action + opcodes for ST flashes */
  4024. +#define BCMA_CC_FLASHCTL_ST_WREN 0x0006 /* Write Enable */
  4025. +#define BCMA_CC_FLASHCTL_ST_WRDIS 0x0004 /* Write Disable */
  4026. +#define BCMA_CC_FLASHCTL_ST_RDSR 0x0105 /* Read Status Register */
  4027. +#define BCMA_CC_FLASHCTL_ST_WRSR 0x0101 /* Write Status Register */
  4028. +#define BCMA_CC_FLASHCTL_ST_READ 0x0303 /* Read Data Bytes */
  4029. +#define BCMA_CC_FLASHCTL_ST_PP 0x0302 /* Page Program */
  4030. +#define BCMA_CC_FLASHCTL_ST_SE 0x02d8 /* Sector Erase */
  4031. +#define BCMA_CC_FLASHCTL_ST_BE 0x00c7 /* Bulk Erase */
  4032. +#define BCMA_CC_FLASHCTL_ST_DP 0x00b9 /* Deep Power-down */
  4033. +#define BCMA_CC_FLASHCTL_ST_RES 0x03ab /* Read Electronic Signature */
  4034. +#define BCMA_CC_FLASHCTL_ST_CSA 0x1000 /* Keep chip select asserted */
  4035. +#define BCMA_CC_FLASHCTL_ST_SSE 0x0220 /* Sub-sector Erase */
  4036. +/* Flashcontrol action + opcodes for Atmel flashes */
  4037. +#define BCMA_CC_FLASHCTL_AT_READ 0x07e8
  4038. +#define BCMA_CC_FLASHCTL_AT_PAGE_READ 0x07d2
  4039. +#define BCMA_CC_FLASHCTL_AT_STATUS 0x01d7
  4040. +#define BCMA_CC_FLASHCTL_AT_BUF1_WRITE 0x0384
  4041. +#define BCMA_CC_FLASHCTL_AT_BUF2_WRITE 0x0387
  4042. +#define BCMA_CC_FLASHCTL_AT_BUF1_ERASE_PROGRAM 0x0283
  4043. +#define BCMA_CC_FLASHCTL_AT_BUF2_ERASE_PROGRAM 0x0286
  4044. +#define BCMA_CC_FLASHCTL_AT_BUF1_PROGRAM 0x0288
  4045. +#define BCMA_CC_FLASHCTL_AT_BUF2_PROGRAM 0x0289
  4046. +#define BCMA_CC_FLASHCTL_AT_PAGE_ERASE 0x0281
  4047. +#define BCMA_CC_FLASHCTL_AT_BLOCK_ERASE 0x0250
  4048. +#define BCMA_CC_FLASHCTL_AT_BUF1_WRITE_ERASE_PROGRAM 0x0382
  4049. +#define BCMA_CC_FLASHCTL_AT_BUF2_WRITE_ERASE_PROGRAM 0x0385
  4050. +#define BCMA_CC_FLASHCTL_AT_BUF1_LOAD 0x0253
  4051. +#define BCMA_CC_FLASHCTL_AT_BUF2_LOAD 0x0255
  4052. +#define BCMA_CC_FLASHCTL_AT_BUF1_COMPARE 0x0260
  4053. +#define BCMA_CC_FLASHCTL_AT_BUF2_COMPARE 0x0261
  4054. +#define BCMA_CC_FLASHCTL_AT_BUF1_REPROGRAM 0x0258
  4055. +#define BCMA_CC_FLASHCTL_AT_BUF2_REPROGRAM 0x0259
  4056. #define BCMA_CC_FLASHADDR 0x0044
  4057. #define BCMA_CC_FLASHDATA 0x0048
  4058. +/* Status register bits for ST flashes */
  4059. +#define BCMA_CC_FLASHDATA_ST_WIP 0x01 /* Write In Progress */
  4060. +#define BCMA_CC_FLASHDATA_ST_WEL 0x02 /* Write Enable Latch */
  4061. +#define BCMA_CC_FLASHDATA_ST_BP_MASK 0x1c /* Block Protect */
  4062. +#define BCMA_CC_FLASHDATA_ST_BP_SHIFT 2
  4063. +#define BCMA_CC_FLASHDATA_ST_SRWD 0x80 /* Status Register Write Disable */
  4064. +/* Status register bits for Atmel flashes */
  4065. +#define BCMA_CC_FLASHDATA_AT_READY 0x80
  4066. +#define BCMA_CC_FLASHDATA_AT_MISMATCH 0x40
  4067. +#define BCMA_CC_FLASHDATA_AT_ID_MASK 0x38
  4068. +#define BCMA_CC_FLASHDATA_AT_ID_SHIFT 3
  4069. #define BCMA_CC_BCAST_ADDR 0x0050
  4070. #define BCMA_CC_BCAST_DATA 0x0054
  4071. #define BCMA_CC_GPIOPULLUP 0x0058 /* Rev >= 20 only */
  4072. @@ -181,6 +255,45 @@
  4073. #define BCMA_CC_FLASH_CFG 0x0128
  4074. #define BCMA_CC_FLASH_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */
  4075. #define BCMA_CC_FLASH_WAITCNT 0x012C
  4076. +#define BCMA_CC_SROM_CONTROL 0x0190
  4077. +#define BCMA_CC_SROM_CONTROL_START 0x80000000
  4078. +#define BCMA_CC_SROM_CONTROL_BUSY 0x80000000
  4079. +#define BCMA_CC_SROM_CONTROL_OPCODE 0x60000000
  4080. +#define BCMA_CC_SROM_CONTROL_OP_READ 0x00000000
  4081. +#define BCMA_CC_SROM_CONTROL_OP_WRITE 0x20000000
  4082. +#define BCMA_CC_SROM_CONTROL_OP_WRDIS 0x40000000
  4083. +#define BCMA_CC_SROM_CONTROL_OP_WREN 0x60000000
  4084. +#define BCMA_CC_SROM_CONTROL_OTPSEL 0x00000010
  4085. +#define BCMA_CC_SROM_CONTROL_LOCK 0x00000008
  4086. +#define BCMA_CC_SROM_CONTROL_SIZE_MASK 0x00000006
  4087. +#define BCMA_CC_SROM_CONTROL_SIZE_1K 0x00000000
  4088. +#define BCMA_CC_SROM_CONTROL_SIZE_4K 0x00000002
  4089. +#define BCMA_CC_SROM_CONTROL_SIZE_16K 0x00000004
  4090. +#define BCMA_CC_SROM_CONTROL_SIZE_SHIFT 1
  4091. +#define BCMA_CC_SROM_CONTROL_PRESENT 0x00000001
  4092. +/* Block 0x140 - 0x190 registers are chipset specific */
  4093. +#define BCMA_CC_4706_FLASHSCFG 0x18C /* Flash struct configuration */
  4094. +#define BCMA_CC_4706_FLASHSCFG_MASK 0x000000ff
  4095. +#define BCMA_CC_4706_FLASHSCFG_SF1 0x00000001 /* 2nd serial flash present */
  4096. +#define BCMA_CC_4706_FLASHSCFG_PF1 0x00000002 /* 2nd parallel flash present */
  4097. +#define BCMA_CC_4706_FLASHSCFG_SF1_TYPE 0x00000004 /* 2nd serial flash type : 0 : ST, 1 : Atmel */
  4098. +#define BCMA_CC_4706_FLASHSCFG_NF1 0x00000008 /* 2nd NAND flash present */
  4099. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_MASK 0x000000f0
  4100. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_4MB 0x00000010 /* 4MB */
  4101. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_8MB 0x00000020 /* 8MB */
  4102. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_16MB 0x00000030 /* 16MB */
  4103. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_32MB 0x00000040 /* 32MB */
  4104. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_64MB 0x00000050 /* 64MB */
  4105. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_128MB 0x00000060 /* 128MB */
  4106. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_256MB 0x00000070 /* 256MB */
  4107. +/* NAND flash registers for BCM4706 (corerev = 31) */
  4108. +#define BCMA_CC_NFLASH_CTL 0x01A0
  4109. +#define BCMA_CC_NFLASH_CTL_ERR 0x08000000
  4110. +#define BCMA_CC_NFLASH_CONF 0x01A4
  4111. +#define BCMA_CC_NFLASH_COL_ADDR 0x01A8
  4112. +#define BCMA_CC_NFLASH_ROW_ADDR 0x01AC
  4113. +#define BCMA_CC_NFLASH_DATA 0x01B0
  4114. +#define BCMA_CC_NFLASH_WAITCNT0 0x01B4
  4115. /* 0x1E0 is defined as shared BCMA_CLKCTLST */
  4116. #define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
  4117. #define BCMA_CC_UART0_DATA 0x0300
  4118. @@ -240,7 +353,60 @@
  4119. #define BCMA_CC_PLLCTL_ADDR 0x0660
  4120. #define BCMA_CC_PLLCTL_DATA 0x0664
  4121. #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
  4122. -#define BCMA_CC_SPROM_PCIE6 0x0830 /* SPROM beginning on PCIe rev >= 6 */
  4123. +/* NAND flash MLC controller registers (corerev >= 38) */
  4124. +#define BCMA_CC_NAND_REVISION 0x0C00
  4125. +#define BCMA_CC_NAND_CMD_START 0x0C04
  4126. +#define BCMA_CC_NAND_CMD_ADDR_X 0x0C08
  4127. +#define BCMA_CC_NAND_CMD_ADDR 0x0C0C
  4128. +#define BCMA_CC_NAND_CMD_END_ADDR 0x0C10
  4129. +#define BCMA_CC_NAND_CS_NAND_SELECT 0x0C14
  4130. +#define BCMA_CC_NAND_CS_NAND_XOR 0x0C18
  4131. +#define BCMA_CC_NAND_SPARE_RD0 0x0C20
  4132. +#define BCMA_CC_NAND_SPARE_RD4 0x0C24
  4133. +#define BCMA_CC_NAND_SPARE_RD8 0x0C28
  4134. +#define BCMA_CC_NAND_SPARE_RD12 0x0C2C
  4135. +#define BCMA_CC_NAND_SPARE_WR0 0x0C30
  4136. +#define BCMA_CC_NAND_SPARE_WR4 0x0C34
  4137. +#define BCMA_CC_NAND_SPARE_WR8 0x0C38
  4138. +#define BCMA_CC_NAND_SPARE_WR12 0x0C3C
  4139. +#define BCMA_CC_NAND_ACC_CONTROL 0x0C40
  4140. +#define BCMA_CC_NAND_CONFIG 0x0C48
  4141. +#define BCMA_CC_NAND_TIMING_1 0x0C50
  4142. +#define BCMA_CC_NAND_TIMING_2 0x0C54
  4143. +#define BCMA_CC_NAND_SEMAPHORE 0x0C58
  4144. +#define BCMA_CC_NAND_DEVID 0x0C60
  4145. +#define BCMA_CC_NAND_DEVID_X 0x0C64
  4146. +#define BCMA_CC_NAND_BLOCK_LOCK_STATUS 0x0C68
  4147. +#define BCMA_CC_NAND_INTFC_STATUS 0x0C6C
  4148. +#define BCMA_CC_NAND_ECC_CORR_ADDR_X 0x0C70
  4149. +#define BCMA_CC_NAND_ECC_CORR_ADDR 0x0C74
  4150. +#define BCMA_CC_NAND_ECC_UNC_ADDR_X 0x0C78
  4151. +#define BCMA_CC_NAND_ECC_UNC_ADDR 0x0C7C
  4152. +#define BCMA_CC_NAND_READ_ERROR_COUNT 0x0C80
  4153. +#define BCMA_CC_NAND_CORR_STAT_THRESHOLD 0x0C84
  4154. +#define BCMA_CC_NAND_READ_ADDR_X 0x0C90
  4155. +#define BCMA_CC_NAND_READ_ADDR 0x0C94
  4156. +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR_X 0x0C98
  4157. +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR 0x0C9C
  4158. +#define BCMA_CC_NAND_COPY_BACK_ADDR_X 0x0CA0
  4159. +#define BCMA_CC_NAND_COPY_BACK_ADDR 0x0CA4
  4160. +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR_X 0x0CA8
  4161. +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR 0x0CAC
  4162. +#define BCMA_CC_NAND_INV_READ_ADDR_X 0x0CB0
  4163. +#define BCMA_CC_NAND_INV_READ_ADDR 0x0CB4
  4164. +#define BCMA_CC_NAND_BLK_WR_PROTECT 0x0CC0
  4165. +#define BCMA_CC_NAND_ACC_CONTROL_CS1 0x0CD0
  4166. +#define BCMA_CC_NAND_CONFIG_CS1 0x0CD4
  4167. +#define BCMA_CC_NAND_TIMING_1_CS1 0x0CD8
  4168. +#define BCMA_CC_NAND_TIMING_2_CS1 0x0CDC
  4169. +#define BCMA_CC_NAND_SPARE_RD16 0x0D30
  4170. +#define BCMA_CC_NAND_SPARE_RD20 0x0D34
  4171. +#define BCMA_CC_NAND_SPARE_RD24 0x0D38
  4172. +#define BCMA_CC_NAND_SPARE_RD28 0x0D3C
  4173. +#define BCMA_CC_NAND_CACHE_ADDR 0x0D40
  4174. +#define BCMA_CC_NAND_CACHE_DATA 0x0D44
  4175. +#define BCMA_CC_NAND_CTRL_CONFIG 0x0D48
  4176. +#define BCMA_CC_NAND_CTRL_STATUS 0x0D4C
  4177. /* Divider allocation in 4716/47162/5356 */
  4178. #define BCMA_CC_PMU5_MAINPLL_CPU 1
  4179. @@ -256,6 +422,15 @@
  4180. /* 4706 PMU */
  4181. #define BCMA_CC_PMU4706_MAINPLL_PLL0 0
  4182. +#define BCMA_CC_PMU6_4706_PROCPLL_OFF 4 /* The CPU PLL */
  4183. +#define BCMA_CC_PMU6_4706_PROC_P2DIV_MASK 0x000f0000
  4184. +#define BCMA_CC_PMU6_4706_PROC_P2DIV_SHIFT 16
  4185. +#define BCMA_CC_PMU6_4706_PROC_P1DIV_MASK 0x0000f000
  4186. +#define BCMA_CC_PMU6_4706_PROC_P1DIV_SHIFT 12
  4187. +#define BCMA_CC_PMU6_4706_PROC_NDIV_INT_MASK 0x00000ff8
  4188. +#define BCMA_CC_PMU6_4706_PROC_NDIV_INT_SHIFT 3
  4189. +#define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_MASK 0x00000007
  4190. +#define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_SHIFT 0
  4191. /* ALP clock on pre-PMU chips */
  4192. #define BCMA_CC_PMU_ALP_CLOCK 20000000
  4193. @@ -284,6 +459,19 @@
  4194. #define BCMA_CC_PPL_PCHI_OFF 5
  4195. #define BCMA_CC_PPL_PCHI_MASK 0x0000003f
  4196. +#define BCMA_CC_PMU_PLL_CTL0 0
  4197. +#define BCMA_CC_PMU_PLL_CTL1 1
  4198. +#define BCMA_CC_PMU_PLL_CTL2 2
  4199. +#define BCMA_CC_PMU_PLL_CTL3 3
  4200. +#define BCMA_CC_PMU_PLL_CTL4 4
  4201. +#define BCMA_CC_PMU_PLL_CTL5 5
  4202. +
  4203. +#define BCMA_CC_PMU1_PLL0_PC0_P1DIV_MASK 0x00f00000
  4204. +#define BCMA_CC_PMU1_PLL0_PC0_P1DIV_SHIFT 20
  4205. +
  4206. +#define BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_MASK 0x1ff00000
  4207. +#define BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT 20
  4208. +
  4209. /* BCM4331 ChipControl numbers. */
  4210. #define BCMA_CHIPCTL_4331_BT_COEXIST BIT(0) /* 0 disable */
  4211. #define BCMA_CHIPCTL_4331_SECI BIT(1) /* 0 SECI is disabled (JATG functional) */
  4212. @@ -297,9 +485,25 @@
  4213. #define BCMA_CHIPCTL_4331_OVR_PIPEAUXPWRDOWN BIT(9) /* override core control on pipe_AuxPowerDown */
  4214. #define BCMA_CHIPCTL_4331_PCIE_AUXCLKEN BIT(10) /* pcie_auxclkenable */
  4215. #define BCMA_CHIPCTL_4331_PCIE_PIPE_PLLDOWN BIT(11) /* pcie_pipe_pllpowerdown */
  4216. +#define BCMA_CHIPCTL_4331_EXTPA_EN2 BIT(12) /* 0 ext pa disable, 1 ext pa enabled */
  4217. #define BCMA_CHIPCTL_4331_BT_SHD0_ON_GPIO4 BIT(16) /* enable bt_shd0 at gpio4 */
  4218. #define BCMA_CHIPCTL_4331_BT_SHD1_ON_GPIO5 BIT(17) /* enable bt_shd1 at gpio5 */
  4219. +/* 43224 chip-specific ChipControl register bits */
  4220. +#define BCMA_CCTRL_43224_GPIO_TOGGLE 0x8000 /* gpio[3:0] pins as btcoex or s/w gpio */
  4221. +#define BCMA_CCTRL_43224A0_12MA_LED_DRIVE 0x00F000F0 /* 12 mA drive strength */
  4222. +#define BCMA_CCTRL_43224B0_12MA_LED_DRIVE 0xF0 /* 12 mA drive strength for later 43224s */
  4223. +
  4224. +/* 4313 Chip specific ChipControl register bits */
  4225. +#define BCMA_CCTRL_4313_12MA_LED_DRIVE 0x00000007 /* 12 mA drive strengh for later 4313 */
  4226. +
  4227. +/* BCM5357 ChipControl register bits */
  4228. +#define BCMA_CHIPCTL_5357_EXTPA BIT(14)
  4229. +#define BCMA_CHIPCTL_5357_ANT_MUX_2O3 BIT(15)
  4230. +#define BCMA_CHIPCTL_5357_NFLASH BIT(16)
  4231. +#define BCMA_CHIPCTL_5357_I2S_PINS_ENABLE BIT(18)
  4232. +#define BCMA_CHIPCTL_5357_I2CSPI_PINS_ENABLE BIT(19)
  4233. +
  4234. /* Data for the PMU, if available.
  4235. * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
  4236. */
  4237. @@ -310,11 +514,35 @@ struct bcma_chipcommon_pmu {
  4238. #ifdef CONFIG_BCMA_DRIVER_MIPS
  4239. struct bcma_pflash {
  4240. + bool present;
  4241. u8 buswidth;
  4242. u32 window;
  4243. u32 window_size;
  4244. };
  4245. +#ifdef CONFIG_BCMA_SFLASH
  4246. +struct bcma_sflash {
  4247. + bool present;
  4248. + u32 window;
  4249. + u32 blocksize;
  4250. + u16 numblocks;
  4251. + u32 size;
  4252. +
  4253. + struct mtd_info *mtd;
  4254. +};
  4255. +#endif
  4256. +
  4257. +#ifdef CONFIG_BCMA_NFLASH
  4258. +struct mtd_info;
  4259. +
  4260. +struct bcma_nflash {
  4261. + bool present;
  4262. + bool boot; /* This is the flash the SoC boots from */
  4263. +
  4264. + struct mtd_info *mtd;
  4265. +};
  4266. +#endif
  4267. +
  4268. struct bcma_serial_port {
  4269. void *regs;
  4270. unsigned long clockspeed;
  4271. @@ -330,15 +558,30 @@ struct bcma_drv_cc {
  4272. u32 capabilities;
  4273. u32 capabilities_ext;
  4274. u8 setup_done:1;
  4275. + u8 early_setup_done:1;
  4276. /* Fast Powerup Delay constant */
  4277. u16 fast_pwrup_delay;
  4278. struct bcma_chipcommon_pmu pmu;
  4279. #ifdef CONFIG_BCMA_DRIVER_MIPS
  4280. struct bcma_pflash pflash;
  4281. +#ifdef CONFIG_BCMA_SFLASH
  4282. + struct bcma_sflash sflash;
  4283. +#endif
  4284. +#ifdef CONFIG_BCMA_NFLASH
  4285. + struct bcma_nflash nflash;
  4286. +#endif
  4287. int nr_serial_ports;
  4288. struct bcma_serial_port serial_ports[4];
  4289. #endif /* CONFIG_BCMA_DRIVER_MIPS */
  4290. + u32 ticks_per_ms;
  4291. + struct platform_device *watchdog;
  4292. +
  4293. + /* Lock for GPIO register access. */
  4294. + spinlock_t gpio_lock;
  4295. +#ifdef CONFIG_BCMA_DRIVER_GPIO
  4296. + struct gpio_chip gpio;
  4297. +#endif
  4298. };
  4299. /* Register access */
  4300. @@ -355,14 +598,16 @@ struct bcma_drv_cc {
  4301. bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
  4302. extern void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
  4303. +extern void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
  4304. extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
  4305. extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
  4306. void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
  4307. -extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
  4308. - u32 ticks);
  4309. +extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
  4310. +
  4311. +extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
  4312. void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
  4313. @@ -375,9 +620,12 @@ u32 bcma_chipco_gpio_outen(struct bcma_d
  4314. u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value);
  4315. u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value);
  4316. u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value);
  4317. +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value);
  4318. +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value);
  4319. /* PMU support */
  4320. extern void bcma_pmu_init(struct bcma_drv_cc *cc);
  4321. +extern void bcma_pmu_early_init(struct bcma_drv_cc *cc);
  4322. extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
  4323. u32 value);
  4324. @@ -387,5 +635,6 @@ extern void bcma_chipco_chipctl_maskset(
  4325. u32 offset, u32 mask, u32 set);
  4326. extern void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc,
  4327. u32 offset, u32 mask, u32 set);
  4328. +extern void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid);
  4329. #endif /* LINUX_BCMA_DRIVER_CC_H_ */
  4330. --- /dev/null
  4331. +++ b/include/linux/bcma/bcma_driver_gmac_cmn.h
  4332. @@ -0,0 +1,100 @@
  4333. +#ifndef LINUX_BCMA_DRIVER_GMAC_CMN_H_
  4334. +#define LINUX_BCMA_DRIVER_GMAC_CMN_H_
  4335. +
  4336. +#include <linux/types.h>
  4337. +
  4338. +#define BCMA_GMAC_CMN_STAG0 0x000
  4339. +#define BCMA_GMAC_CMN_STAG1 0x004
  4340. +#define BCMA_GMAC_CMN_STAG2 0x008
  4341. +#define BCMA_GMAC_CMN_STAG3 0x00C
  4342. +#define BCMA_GMAC_CMN_PARSER_CTL 0x020
  4343. +#define BCMA_GMAC_CMN_MIB_MAX_LEN 0x024
  4344. +#define BCMA_GMAC_CMN_PHY_ACCESS 0x100
  4345. +#define BCMA_GMAC_CMN_PA_DATA_MASK 0x0000ffff
  4346. +#define BCMA_GMAC_CMN_PA_ADDR_MASK 0x001f0000
  4347. +#define BCMA_GMAC_CMN_PA_ADDR_SHIFT 16
  4348. +#define BCMA_GMAC_CMN_PA_REG_MASK 0x1f000000
  4349. +#define BCMA_GMAC_CMN_PA_REG_SHIFT 24
  4350. +#define BCMA_GMAC_CMN_PA_WRITE 0x20000000
  4351. +#define BCMA_GMAC_CMN_PA_START 0x40000000
  4352. +#define BCMA_GMAC_CMN_PHY_CTL 0x104
  4353. +#define BCMA_GMAC_CMN_PC_EPA_MASK 0x0000001f
  4354. +#define BCMA_GMAC_CMN_PC_MCT_MASK 0x007f0000
  4355. +#define BCMA_GMAC_CMN_PC_MCT_SHIFT 16
  4356. +#define BCMA_GMAC_CMN_PC_MTE 0x00800000
  4357. +#define BCMA_GMAC_CMN_GMAC0_RGMII_CTL 0x110
  4358. +#define BCMA_GMAC_CMN_CFP_ACCESS 0x200
  4359. +#define BCMA_GMAC_CMN_CFP_TCAM_DATA0 0x210
  4360. +#define BCMA_GMAC_CMN_CFP_TCAM_DATA1 0x214
  4361. +#define BCMA_GMAC_CMN_CFP_TCAM_DATA2 0x218
  4362. +#define BCMA_GMAC_CMN_CFP_TCAM_DATA3 0x21C
  4363. +#define BCMA_GMAC_CMN_CFP_TCAM_DATA4 0x220
  4364. +#define BCMA_GMAC_CMN_CFP_TCAM_DATA5 0x224
  4365. +#define BCMA_GMAC_CMN_CFP_TCAM_DATA6 0x228
  4366. +#define BCMA_GMAC_CMN_CFP_TCAM_DATA7 0x22C
  4367. +#define BCMA_GMAC_CMN_CFP_TCAM_MASK0 0x230
  4368. +#define BCMA_GMAC_CMN_CFP_TCAM_MASK1 0x234
  4369. +#define BCMA_GMAC_CMN_CFP_TCAM_MASK2 0x238
  4370. +#define BCMA_GMAC_CMN_CFP_TCAM_MASK3 0x23C
  4371. +#define BCMA_GMAC_CMN_CFP_TCAM_MASK4 0x240
  4372. +#define BCMA_GMAC_CMN_CFP_TCAM_MASK5 0x244
  4373. +#define BCMA_GMAC_CMN_CFP_TCAM_MASK6 0x248
  4374. +#define BCMA_GMAC_CMN_CFP_TCAM_MASK7 0x24C
  4375. +#define BCMA_GMAC_CMN_CFP_ACTION_DATA 0x250
  4376. +#define BCMA_GMAC_CMN_TCAM_BIST_CTL 0x2A0
  4377. +#define BCMA_GMAC_CMN_TCAM_BIST_STATUS 0x2A4
  4378. +#define BCMA_GMAC_CMN_TCAM_CMP_STATUS 0x2A8
  4379. +#define BCMA_GMAC_CMN_TCAM_DISABLE 0x2AC
  4380. +#define BCMA_GMAC_CMN_TCAM_TEST_CTL 0x2F0
  4381. +#define BCMA_GMAC_CMN_UDF_0_A3_A0 0x300
  4382. +#define BCMA_GMAC_CMN_UDF_0_A7_A4 0x304
  4383. +#define BCMA_GMAC_CMN_UDF_0_A8 0x308
  4384. +#define BCMA_GMAC_CMN_UDF_1_A3_A0 0x310
  4385. +#define BCMA_GMAC_CMN_UDF_1_A7_A4 0x314
  4386. +#define BCMA_GMAC_CMN_UDF_1_A8 0x318
  4387. +#define BCMA_GMAC_CMN_UDF_2_A3_A0 0x320
  4388. +#define BCMA_GMAC_CMN_UDF_2_A7_A4 0x324
  4389. +#define BCMA_GMAC_CMN_UDF_2_A8 0x328
  4390. +#define BCMA_GMAC_CMN_UDF_0_B3_B0 0x330
  4391. +#define BCMA_GMAC_CMN_UDF_0_B7_B4 0x334
  4392. +#define BCMA_GMAC_CMN_UDF_0_B8 0x338
  4393. +#define BCMA_GMAC_CMN_UDF_1_B3_B0 0x340
  4394. +#define BCMA_GMAC_CMN_UDF_1_B7_B4 0x344
  4395. +#define BCMA_GMAC_CMN_UDF_1_B8 0x348
  4396. +#define BCMA_GMAC_CMN_UDF_2_B3_B0 0x350
  4397. +#define BCMA_GMAC_CMN_UDF_2_B7_B4 0x354
  4398. +#define BCMA_GMAC_CMN_UDF_2_B8 0x358
  4399. +#define BCMA_GMAC_CMN_UDF_0_C3_C0 0x360
  4400. +#define BCMA_GMAC_CMN_UDF_0_C7_C4 0x364
  4401. +#define BCMA_GMAC_CMN_UDF_0_C8 0x368
  4402. +#define BCMA_GMAC_CMN_UDF_1_C3_C0 0x370
  4403. +#define BCMA_GMAC_CMN_UDF_1_C7_C4 0x374
  4404. +#define BCMA_GMAC_CMN_UDF_1_C8 0x378
  4405. +#define BCMA_GMAC_CMN_UDF_2_C3_C0 0x380
  4406. +#define BCMA_GMAC_CMN_UDF_2_C7_C4 0x384
  4407. +#define BCMA_GMAC_CMN_UDF_2_C8 0x388
  4408. +#define BCMA_GMAC_CMN_UDF_0_D3_D0 0x390
  4409. +#define BCMA_GMAC_CMN_UDF_0_D7_D4 0x394
  4410. +#define BCMA_GMAC_CMN_UDF_0_D11_D8 0x394
  4411. +
  4412. +struct bcma_drv_gmac_cmn {
  4413. + struct bcma_device *core;
  4414. +
  4415. + /* Drivers accessing BCMA_GMAC_CMN_PHY_ACCESS and
  4416. + * BCMA_GMAC_CMN_PHY_CTL need to take that mutex first. */
  4417. + struct mutex phy_mutex;
  4418. +};
  4419. +
  4420. +/* Register access */
  4421. +#define gmac_cmn_read16(gc, offset) bcma_read16((gc)->core, offset)
  4422. +#define gmac_cmn_read32(gc, offset) bcma_read32((gc)->core, offset)
  4423. +#define gmac_cmn_write16(gc, offset, val) bcma_write16((gc)->core, offset, val)
  4424. +#define gmac_cmn_write32(gc, offset, val) bcma_write32((gc)->core, offset, val)
  4425. +
  4426. +#ifdef CONFIG_BCMA_DRIVER_GMAC_CMN
  4427. +extern void __devinit bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc);
  4428. +#else
  4429. +static inline void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc) { }
  4430. +#endif
  4431. +
  4432. +#endif /* LINUX_BCMA_DRIVER_GMAC_CMN_H_ */
  4433. --- a/include/linux/bcma/bcma_driver_mips.h
  4434. +++ b/include/linux/bcma/bcma_driver_mips.h
  4435. @@ -35,13 +35,15 @@ struct bcma_device;
  4436. struct bcma_drv_mips {
  4437. struct bcma_device *core;
  4438. u8 setup_done:1;
  4439. - unsigned int assigned_irqs;
  4440. + u8 early_setup_done:1;
  4441. };
  4442. #ifdef CONFIG_BCMA_DRIVER_MIPS
  4443. extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
  4444. +extern void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
  4445. #else
  4446. static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
  4447. +static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) { }
  4448. #endif
  4449. extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
  4450. --- a/include/linux/bcma/bcma_driver_pci.h
  4451. +++ b/include/linux/bcma/bcma_driver_pci.h
  4452. @@ -53,11 +53,47 @@ struct pci_dev;
  4453. #define BCMA_CORE_PCI_SBTOPCI1_MASK 0xFC000000
  4454. #define BCMA_CORE_PCI_SBTOPCI2 0x0108 /* Backplane to PCI translation 2 (sbtopci2) */
  4455. #define BCMA_CORE_PCI_SBTOPCI2_MASK 0xC0000000
  4456. +#define BCMA_CORE_PCI_CONFIG_ADDR 0x0120 /* pcie config space access */
  4457. +#define BCMA_CORE_PCI_CONFIG_DATA 0x0124 /* pcie config space access */
  4458. +#define BCMA_CORE_PCI_MDIO_CONTROL 0x0128 /* controls the mdio access */
  4459. +#define BCMA_CORE_PCI_MDIOCTL_DIVISOR_MASK 0x7f /* clock to be used on MDIO */
  4460. +#define BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL 0x2
  4461. +#define BCMA_CORE_PCI_MDIOCTL_PREAM_EN 0x80 /* Enable preamble sequnce */
  4462. +#define BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE 0x100 /* Tranaction complete */
  4463. +#define BCMA_CORE_PCI_MDIO_DATA 0x012c /* Data to the mdio access */
  4464. +#define BCMA_CORE_PCI_MDIODATA_MASK 0x0000ffff /* data 2 bytes */
  4465. +#define BCMA_CORE_PCI_MDIODATA_TA 0x00020000 /* Turnaround */
  4466. +#define BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD 18 /* Regaddr shift (rev < 10) */
  4467. +#define BCMA_CORE_PCI_MDIODATA_REGADDR_MASK_OLD 0x003c0000 /* Regaddr Mask (rev < 10) */
  4468. +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD 22 /* Physmedia devaddr shift (rev < 10) */
  4469. +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_MASK_OLD 0x0fc00000 /* Physmedia devaddr Mask (rev < 10) */
  4470. +#define BCMA_CORE_PCI_MDIODATA_REGADDR_SHF 18 /* Regaddr shift */
  4471. +#define BCMA_CORE_PCI_MDIODATA_REGADDR_MASK 0x007c0000 /* Regaddr Mask */
  4472. +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF 23 /* Physmedia devaddr shift */
  4473. +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_MASK 0x0f800000 /* Physmedia devaddr Mask */
  4474. +#define BCMA_CORE_PCI_MDIODATA_WRITE 0x10000000 /* write Transaction */
  4475. +#define BCMA_CORE_PCI_MDIODATA_READ 0x20000000 /* Read Transaction */
  4476. +#define BCMA_CORE_PCI_MDIODATA_START 0x40000000 /* start of Transaction */
  4477. +#define BCMA_CORE_PCI_MDIODATA_DEV_ADDR 0x0 /* dev address for serdes */
  4478. +#define BCMA_CORE_PCI_MDIODATA_BLK_ADDR 0x1F /* blk address for serdes */
  4479. +#define BCMA_CORE_PCI_MDIODATA_DEV_PLL 0x1d /* SERDES PLL Dev */
  4480. +#define BCMA_CORE_PCI_MDIODATA_DEV_TX 0x1e /* SERDES TX Dev */
  4481. +#define BCMA_CORE_PCI_MDIODATA_DEV_RX 0x1f /* SERDES RX Dev */
  4482. +#define BCMA_CORE_PCI_PCIEIND_ADDR 0x0130 /* indirect access to the internal register */
  4483. +#define BCMA_CORE_PCI_PCIEIND_DATA 0x0134 /* Data to/from the internal regsiter */
  4484. +#define BCMA_CORE_PCI_CLKREQENCTRL 0x0138 /* >= rev 6, Clkreq rdma control */
  4485. #define BCMA_CORE_PCI_PCICFG0 0x0400 /* PCI config space 0 (rev >= 8) */
  4486. #define BCMA_CORE_PCI_PCICFG1 0x0500 /* PCI config space 1 (rev >= 8) */
  4487. #define BCMA_CORE_PCI_PCICFG2 0x0600 /* PCI config space 2 (rev >= 8) */
  4488. #define BCMA_CORE_PCI_PCICFG3 0x0700 /* PCI config space 3 (rev >= 8) */
  4489. #define BCMA_CORE_PCI_SPROM(wordoffset) (0x0800 + ((wordoffset) * 2)) /* SPROM shadow area (72 bytes) */
  4490. +#define BCMA_CORE_PCI_SPROM_PI_OFFSET 0 /* first word */
  4491. +#define BCMA_CORE_PCI_SPROM_PI_MASK 0xf000 /* bit 15:12 */
  4492. +#define BCMA_CORE_PCI_SPROM_PI_SHIFT 12 /* bit 15:12 */
  4493. +#define BCMA_CORE_PCI_SPROM_MISC_CONFIG 5 /* word 5 */
  4494. +#define BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST 0x8000 /* bit 15 */
  4495. +#define BCMA_CORE_PCI_SPROM_CLKREQ_OFFSET_REV5 20 /* word 20 for srom rev <= 5 */
  4496. +#define BCMA_CORE_PCI_SPROM_CLKREQ_ENB 0x0800 /* bit 11 */
  4497. /* SBtoPCIx */
  4498. #define BCMA_CORE_PCI_SBTOPCI_MEM 0x00000000
  4499. @@ -72,20 +108,118 @@ struct pci_dev;
  4500. #define BCMA_CORE_PCI_SBTOPCI_RC_READL 0x00000010 /* Memory read line */
  4501. #define BCMA_CORE_PCI_SBTOPCI_RC_READM 0x00000020 /* Memory read multiple */
  4502. +/* PCIE protocol PHY diagnostic registers */
  4503. +#define BCMA_CORE_PCI_PLP_MODEREG 0x200 /* Mode */
  4504. +#define BCMA_CORE_PCI_PLP_STATUSREG 0x204 /* Status */
  4505. +#define BCMA_CORE_PCI_PLP_POLARITYINV_STAT 0x10 /* Status reg PCIE_PLP_STATUSREG */
  4506. +#define BCMA_CORE_PCI_PLP_LTSSMCTRLREG 0x208 /* LTSSM control */
  4507. +#define BCMA_CORE_PCI_PLP_LTLINKNUMREG 0x20c /* Link Training Link number */
  4508. +#define BCMA_CORE_PCI_PLP_LTLANENUMREG 0x210 /* Link Training Lane number */
  4509. +#define BCMA_CORE_PCI_PLP_LTNFTSREG 0x214 /* Link Training N_FTS */
  4510. +#define BCMA_CORE_PCI_PLP_ATTNREG 0x218 /* Attention */
  4511. +#define BCMA_CORE_PCI_PLP_ATTNMASKREG 0x21C /* Attention Mask */
  4512. +#define BCMA_CORE_PCI_PLP_RXERRCTR 0x220 /* Rx Error */
  4513. +#define BCMA_CORE_PCI_PLP_RXFRMERRCTR 0x224 /* Rx Framing Error */
  4514. +#define BCMA_CORE_PCI_PLP_RXERRTHRESHREG 0x228 /* Rx Error threshold */
  4515. +#define BCMA_CORE_PCI_PLP_TESTCTRLREG 0x22C /* Test Control reg */
  4516. +#define BCMA_CORE_PCI_PLP_SERDESCTRLOVRDREG 0x230 /* SERDES Control Override */
  4517. +#define BCMA_CORE_PCI_PLP_TIMINGOVRDREG 0x234 /* Timing param override */
  4518. +#define BCMA_CORE_PCI_PLP_RXTXSMDIAGREG 0x238 /* RXTX State Machine Diag */
  4519. +#define BCMA_CORE_PCI_PLP_LTSSMDIAGREG 0x23C /* LTSSM State Machine Diag */
  4520. +
  4521. +/* PCIE protocol DLLP diagnostic registers */
  4522. +#define BCMA_CORE_PCI_DLLP_LCREG 0x100 /* Link Control */
  4523. +#define BCMA_CORE_PCI_DLLP_LSREG 0x104 /* Link Status */
  4524. +#define BCMA_CORE_PCI_DLLP_LAREG 0x108 /* Link Attention */
  4525. +#define BCMA_CORE_PCI_DLLP_LSREG_LINKUP (1 << 16)
  4526. +#define BCMA_CORE_PCI_DLLP_LAMASKREG 0x10C /* Link Attention Mask */
  4527. +#define BCMA_CORE_PCI_DLLP_NEXTTXSEQNUMREG 0x110 /* Next Tx Seq Num */
  4528. +#define BCMA_CORE_PCI_DLLP_ACKEDTXSEQNUMREG 0x114 /* Acked Tx Seq Num */
  4529. +#define BCMA_CORE_PCI_DLLP_PURGEDTXSEQNUMREG 0x118 /* Purged Tx Seq Num */
  4530. +#define BCMA_CORE_PCI_DLLP_RXSEQNUMREG 0x11C /* Rx Sequence Number */
  4531. +#define BCMA_CORE_PCI_DLLP_LRREG 0x120 /* Link Replay */
  4532. +#define BCMA_CORE_PCI_DLLP_LACKTOREG 0x124 /* Link Ack Timeout */
  4533. +#define BCMA_CORE_PCI_DLLP_PMTHRESHREG 0x128 /* Power Management Threshold */
  4534. +#define BCMA_CORE_PCI_ASPMTIMER_EXTEND 0x01000000 /* > rev7: enable extend ASPM timer */
  4535. +#define BCMA_CORE_PCI_DLLP_RTRYWPREG 0x12C /* Retry buffer write ptr */
  4536. +#define BCMA_CORE_PCI_DLLP_RTRYRPREG 0x130 /* Retry buffer Read ptr */
  4537. +#define BCMA_CORE_PCI_DLLP_RTRYPPREG 0x134 /* Retry buffer Purged ptr */
  4538. +#define BCMA_CORE_PCI_DLLP_RTRRWREG 0x138 /* Retry buffer Read/Write */
  4539. +#define BCMA_CORE_PCI_DLLP_ECTHRESHREG 0x13C /* Error Count Threshold */
  4540. +#define BCMA_CORE_PCI_DLLP_TLPERRCTRREG 0x140 /* TLP Error Counter */
  4541. +#define BCMA_CORE_PCI_DLLP_ERRCTRREG 0x144 /* Error Counter */
  4542. +#define BCMA_CORE_PCI_DLLP_NAKRXCTRREG 0x148 /* NAK Received Counter */
  4543. +#define BCMA_CORE_PCI_DLLP_TESTREG 0x14C /* Test */
  4544. +#define BCMA_CORE_PCI_DLLP_PKTBIST 0x150 /* Packet BIST */
  4545. +#define BCMA_CORE_PCI_DLLP_PCIE11 0x154 /* DLLP PCIE 1.1 reg */
  4546. +
  4547. +/* SERDES RX registers */
  4548. +#define BCMA_CORE_PCI_SERDES_RX_CTRL 1 /* Rx cntrl */
  4549. +#define BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE 0x80 /* rxpolarity_force */
  4550. +#define BCMA_CORE_PCI_SERDES_RX_CTRL_POLARITY 0x40 /* rxpolarity_value */
  4551. +#define BCMA_CORE_PCI_SERDES_RX_TIMER1 2 /* Rx Timer1 */
  4552. +#define BCMA_CORE_PCI_SERDES_RX_CDR 6 /* CDR */
  4553. +#define BCMA_CORE_PCI_SERDES_RX_CDRBW 7 /* CDR BW */
  4554. +
  4555. +/* SERDES PLL registers */
  4556. +#define BCMA_CORE_PCI_SERDES_PLL_CTRL 1 /* PLL control reg */
  4557. +#define BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN 0x4000 /* bit 14 is FREQDET on */
  4558. +
  4559. /* PCIcore specific boardflags */
  4560. #define BCMA_CORE_PCI_BFL_NOPCI 0x00000400 /* Board leaves PCI floating */
  4561. +/* PCIE Config space accessing MACROS */
  4562. +#define BCMA_CORE_PCI_CFG_BUS_SHIFT 24 /* Bus shift */
  4563. +#define BCMA_CORE_PCI_CFG_SLOT_SHIFT 19 /* Slot/Device shift */
  4564. +#define BCMA_CORE_PCI_CFG_FUN_SHIFT 16 /* Function shift */
  4565. +#define BCMA_CORE_PCI_CFG_OFF_SHIFT 0 /* Register shift */
  4566. +
  4567. +#define BCMA_CORE_PCI_CFG_BUS_MASK 0xff /* Bus mask */
  4568. +#define BCMA_CORE_PCI_CFG_SLOT_MASK 0x1f /* Slot/Device mask */
  4569. +#define BCMA_CORE_PCI_CFG_FUN_MASK 7 /* Function mask */
  4570. +#define BCMA_CORE_PCI_CFG_OFF_MASK 0xfff /* Register mask */
  4571. +
  4572. +/* PCIE Root Capability Register bits (Host mode only) */
  4573. +#define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001
  4574. +
  4575. +struct bcma_drv_pci;
  4576. +
  4577. +#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
  4578. +struct bcma_drv_pci_host {
  4579. + struct bcma_drv_pci *pdev;
  4580. +
  4581. + u32 host_cfg_addr;
  4582. + spinlock_t cfgspace_lock;
  4583. +
  4584. + struct pci_controller pci_controller;
  4585. + struct pci_ops pci_ops;
  4586. + struct resource mem_resource;
  4587. + struct resource io_resource;
  4588. +};
  4589. +#endif
  4590. +
  4591. struct bcma_drv_pci {
  4592. struct bcma_device *core;
  4593. u8 setup_done:1;
  4594. + u8 hostmode:1;
  4595. +
  4596. +#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
  4597. + struct bcma_drv_pci_host *host_controller;
  4598. +#endif
  4599. };
  4600. /* Register access */
  4601. +#define pcicore_read16(pc, offset) bcma_read16((pc)->core, offset)
  4602. #define pcicore_read32(pc, offset) bcma_read32((pc)->core, offset)
  4603. +#define pcicore_write16(pc, offset, val) bcma_write16((pc)->core, offset, val)
  4604. #define pcicore_write32(pc, offset, val) bcma_write32((pc)->core, offset, val)
  4605. -extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
  4606. +extern void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc);
  4607. extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
  4608. struct bcma_device *core, bool enable);
  4609. +extern void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend);
  4610. +
  4611. +extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
  4612. +extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
  4613. #endif /* LINUX_BCMA_DRIVER_PCI_H_ */
  4614. --- a/include/linux/bcma/bcma_regs.h
  4615. +++ b/include/linux/bcma/bcma_regs.h
  4616. @@ -11,11 +11,13 @@
  4617. #define BCMA_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
  4618. #define BCMA_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
  4619. #define BCMA_CLKCTLST_EXTRESREQ 0x00000700 /* Mask of external resource requests */
  4620. +#define BCMA_CLKCTLST_EXTRESREQ_SHIFT 8
  4621. #define BCMA_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
  4622. #define BCMA_CLKCTLST_HAVEHT 0x00020000 /* HT available */
  4623. #define BCMA_CLKCTLST_BP_ON_ALP 0x00040000 /* RO: running on ALP clock */
  4624. #define BCMA_CLKCTLST_BP_ON_HT 0x00080000 /* RO: running on HT clock */
  4625. #define BCMA_CLKCTLST_EXTRESST 0x07000000 /* Mask of external resource status */
  4626. +#define BCMA_CLKCTLST_EXTRESST_SHIFT 24
  4627. /* Is there any BCM4328 on BCMA bus? */
  4628. #define BCMA_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
  4629. #define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
  4630. @@ -56,4 +58,36 @@
  4631. #define BCMA_PCI_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
  4632. #define BCMA_PCI_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
  4633. +/* SiliconBackplane Address Map.
  4634. + * All regions may not exist on all chips.
  4635. + */
  4636. +#define BCMA_SOC_SDRAM_BASE 0x00000000U /* Physical SDRAM */
  4637. +#define BCMA_SOC_PCI_MEM 0x08000000U /* Host Mode sb2pcitranslation0 (64 MB) */
  4638. +#define BCMA_SOC_PCI_MEM_SZ (64 * 1024 * 1024)
  4639. +#define BCMA_SOC_PCI_CFG 0x0c000000U /* Host Mode sb2pcitranslation1 (64 MB) */
  4640. +#define BCMA_SOC_SDRAM_SWAPPED 0x10000000U /* Byteswapped Physical SDRAM */
  4641. +#define BCMA_SOC_SDRAM_R2 0x80000000U /* Region 2 for sdram (512 MB) */
  4642. +
  4643. +
  4644. +#define BCMA_SOC_PCI_DMA 0x40000000U /* Client Mode sb2pcitranslation2 (1 GB) */
  4645. +#define BCMA_SOC_PCI_DMA2 0x80000000U /* Client Mode sb2pcitranslation2 (1 GB) */
  4646. +#define BCMA_SOC_PCI_DMA_SZ 0x40000000U /* Client Mode sb2pcitranslation2 size in bytes */
  4647. +#define BCMA_SOC_PCIE_DMA_L32 0x00000000U /* PCIE Client Mode sb2pcitranslation2
  4648. + * (2 ZettaBytes), low 32 bits
  4649. + */
  4650. +#define BCMA_SOC_PCIE_DMA_H32 0x80000000U /* PCIE Client Mode sb2pcitranslation2
  4651. + * (2 ZettaBytes), high 32 bits
  4652. + */
  4653. +
  4654. +#define BCMA_SOC_PCI1_MEM 0x40000000U /* Host Mode sb2pcitranslation0 (64 MB) */
  4655. +#define BCMA_SOC_PCI1_CFG 0x44000000U /* Host Mode sb2pcitranslation1 (64 MB) */
  4656. +#define BCMA_SOC_PCIE1_DMA_H32 0xc0000000U /* PCIE Client Mode sb2pcitranslation2
  4657. + * (2 ZettaBytes), high 32 bits
  4658. + */
  4659. +
  4660. +#define BCMA_SOC_FLASH1 0x1fc00000 /* MIPS Flash Region 1 */
  4661. +#define BCMA_SOC_FLASH1_SZ 0x00400000 /* MIPS Size of Flash Region 1 */
  4662. +#define BCMA_SOC_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
  4663. +#define BCMA_SOC_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
  4664. +
  4665. #endif /* LINUX_BCMA_REGS_H_ */
  4666. --- a/drivers/net/wireless/b43/main.c
  4667. +++ b/drivers/net/wireless/b43/main.c
  4668. @@ -4618,7 +4618,7 @@ static int b43_wireless_core_init(struct
  4669. switch (dev->dev->bus_type) {
  4670. #ifdef CONFIG_B43_BCMA
  4671. case B43_BUS_BCMA:
  4672. - bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci,
  4673. + bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0],
  4674. dev->dev->bdev, true);
  4675. break;
  4676. #endif
  4677. --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
  4678. +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
  4679. @@ -533,7 +533,7 @@ ai_buscore_setup(struct si_info *sii, st
  4680. /* fixup necessary chip/core configurations */
  4681. if (!sii->pch) {
  4682. - sii->pch = pcicore_init(&sii->pub, sii->icbus->drv_pci.core);
  4683. + sii->pch = pcicore_init(&sii->pub, sii->icbus->drv_pci[0].core);
  4684. if (sii->pch == NULL)
  4685. return false;
  4686. }