001-git_sync.patch 151 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157
  1. --- a/arch/arm/boot/compressed/head.S
  2. +++ b/arch/arm/boot/compressed/head.S
  3. @@ -9,6 +9,7 @@
  4. * published by the Free Software Foundation.
  5. */
  6. #include <linux/linkage.h>
  7. +#include <asm/cache.h>
  8. /*
  9. * Debugging stuff
  10. @@ -337,7 +338,7 @@ params: ldr r0, =params_phys
  11. * This routine must preserve:
  12. * r4, r5, r6, r7, r8
  13. */
  14. - .align 5
  15. + .align L1_CACHE_SHIFT
  16. cache_on: mov r3, #8 @ cache_on function
  17. b call_cache_fn
  18. @@ -519,7 +520,7 @@ __common_mmu_cache_on:
  19. mcr p15, 0, r3, c2, c0, 0 @ load page table pointer
  20. mcr p15, 0, r1, c3, c0, 0 @ load domain access control
  21. b 1f
  22. - .align 5 @ cache line aligned
  23. + .align L1_CACHE_SHIFT @ cache line aligned
  24. 1: mcr p15, 0, r0, c1, c0, 0 @ load control register
  25. mrc p15, 0, r0, c1, c0, 0 @ and read it back to
  26. sub pc, lr, r0, lsr #32 @ properly flush pipeline
  27. @@ -539,7 +540,7 @@ __common_mmu_cache_on:
  28. * r8 = atags pointer
  29. * r9-r12,r14 = corrupted
  30. */
  31. - .align 5
  32. + .align L1_CACHE_SHIFT
  33. reloc_start: add r9, r5, r0
  34. sub r9, r9, #128 @ do not copy the stack
  35. debug_reloc_start
  36. @@ -768,7 +769,7 @@ proc_types:
  37. * On exit, r0, r1, r2, r3, r12 corrupted
  38. * This routine must preserve: r4, r6, r7
  39. */
  40. - .align 5
  41. + .align L1_CACHE_SHIFT
  42. cache_off: mov r3, #12 @ cache_off function
  43. b call_cache_fn
  44. @@ -845,7 +846,7 @@ __armv3_mmu_cache_off:
  45. * This routine must preserve:
  46. * r0, r4, r5, r6, r7
  47. */
  48. - .align 5
  49. + .align L1_CACHE_SHIFT
  50. cache_clean_flush:
  51. mov r3, #16
  52. b call_cache_fn
  53. --- a/arch/arm/include/asm/dma-mapping.h
  54. +++ b/arch/arm/include/asm/dma-mapping.h
  55. @@ -98,7 +98,7 @@ static inline int dma_set_mask(struct de
  56. static inline int dma_get_cache_alignment(void)
  57. {
  58. - return 32;
  59. + return L1_CACHE_BYTES;
  60. }
  61. static inline int dma_is_consistent(struct device *dev, dma_addr_t handle)
  62. --- a/arch/arm/Kconfig
  63. +++ b/arch/arm/Kconfig
  64. @@ -923,7 +923,7 @@ config ISA_DMA_API
  65. bool
  66. config PCI
  67. - bool "PCI support" if ARCH_INTEGRATOR_AP || ARCH_VERSATILE_PB || ARCH_IXP4XX || ARCH_KS8695 || MACH_ARMCORE
  68. + bool "PCI support" if ARCH_INTEGRATOR_AP || ARCH_VERSATILE_PB || ARCH_IXP4XX || ARCH_KS8695 || MACH_ARMCORE || ARCH_GEMINI
  69. help
  70. Find out whether you have a PCI motherboard. PCI is the name of a
  71. bus system, i.e. the way the CPU talks to the other stuff inside
  72. --- a/arch/arm/kernel/entry-armv.S
  73. +++ b/arch/arm/kernel/entry-armv.S
  74. @@ -22,6 +22,7 @@
  75. #include <asm/thread_notify.h>
  76. #include <asm/unwind.h>
  77. #include <asm/unistd.h>
  78. +#include <asm/cache.h>
  79. #include "entry-header.S"
  80. @@ -166,7 +167,7 @@ ENDPROC(__und_invalid)
  81. asm_trace_hardirqs_off
  82. .endm
  83. - .align 5
  84. + .align L1_CACHE_SHIFT
  85. __dabt_svc:
  86. svc_entry
  87. @@ -214,7 +215,7 @@ __dabt_svc:
  88. UNWIND(.fnend )
  89. ENDPROC(__dabt_svc)
  90. - .align 5
  91. + .align L1_CACHE_SHIFT
  92. __irq_svc:
  93. svc_entry
  94. @@ -255,7 +256,7 @@ svc_preempt:
  95. b 1b
  96. #endif
  97. - .align 5
  98. + .align L1_CACHE_SHIFT
  99. __und_svc:
  100. #ifdef CONFIG_KPROBES
  101. @ If a kprobe is about to simulate a "stmdb sp..." instruction,
  102. @@ -301,7 +302,7 @@ __und_svc:
  103. UNWIND(.fnend )
  104. ENDPROC(__und_svc)
  105. - .align 5
  106. + .align L1_CACHE_SHIFT
  107. __pabt_svc:
  108. svc_entry
  109. @@ -337,7 +338,7 @@ __pabt_svc:
  110. UNWIND(.fnend )
  111. ENDPROC(__pabt_svc)
  112. - .align 5
  113. + .align L1_CACHE_SHIFT
  114. .LCcralign:
  115. .word cr_alignment
  116. #ifdef MULTI_DABORT
  117. @@ -412,7 +413,7 @@ ENDPROC(__pabt_svc)
  118. #endif
  119. .endm
  120. - .align 5
  121. + .align L1_CACHE_SHIFT
  122. __dabt_usr:
  123. usr_entry
  124. kuser_cmpxchg_check
  125. @@ -444,7 +445,7 @@ __dabt_usr:
  126. UNWIND(.fnend )
  127. ENDPROC(__dabt_usr)
  128. - .align 5
  129. + .align L1_CACHE_SHIFT
  130. __irq_usr:
  131. usr_entry
  132. kuser_cmpxchg_check
  133. @@ -476,7 +477,7 @@ ENDPROC(__irq_usr)
  134. .ltorg
  135. - .align 5
  136. + .align L1_CACHE_SHIFT
  137. __und_usr:
  138. usr_entry
  139. @@ -692,7 +693,7 @@ __und_usr_unknown:
  140. b do_undefinstr
  141. ENDPROC(__und_usr_unknown)
  142. - .align 5
  143. + .align L1_CACHE_SHIFT
  144. __pabt_usr:
  145. usr_entry
  146. @@ -803,7 +804,7 @@ ENDPROC(__switch_to)
  147. #endif
  148. .endm
  149. - .align 5
  150. + .align L1_CACHE_SHIFT
  151. .globl __kuser_helper_start
  152. __kuser_helper_start:
  153. @@ -843,7 +844,7 @@ __kuser_memory_barrier: @ 0xffff0fa0
  154. smp_dmb
  155. usr_ret lr
  156. - .align 5
  157. + .align L1_CACHE_SHIFT
  158. /*
  159. * Reference prototype:
  160. @@ -975,7 +976,7 @@ kuser_cmpxchg_fixup:
  161. #endif
  162. - .align 5
  163. + .align L1_CACHE_SHIFT
  164. /*
  165. * Reference prototype:
  166. @@ -1058,7 +1059,7 @@ __kuser_helper_end:
  167. * of which is copied into r0 for the mode specific abort handler.
  168. */
  169. .macro vector_stub, name, mode, correction=0
  170. - .align 5
  171. + .align L1_CACHE_SHIFT
  172. vector_\name:
  173. .if \correction
  174. @@ -1189,7 +1190,7 @@ __stubs_start:
  175. .long __und_invalid @ e
  176. .long __und_invalid @ f
  177. - .align 5
  178. + .align L1_CACHE_SHIFT
  179. /*=============================================================================
  180. * Undefined FIQs
  181. @@ -1219,7 +1220,7 @@ vector_addrexcptn:
  182. * We group all the following data together to optimise
  183. * for CPUs with separate I & D caches.
  184. */
  185. - .align 5
  186. + .align L1_CACHE_SHIFT
  187. .LCvswi:
  188. .word vector_swi
  189. --- a/arch/arm/kernel/entry-common.S
  190. +++ b/arch/arm/kernel/entry-common.S
  191. @@ -10,13 +10,14 @@
  192. #include <asm/unistd.h>
  193. #include <asm/ftrace.h>
  194. +#include <asm/cache.h>
  195. #include <mach/entry-macro.S>
  196. #include <asm/unwind.h>
  197. #include "entry-header.S"
  198. - .align 5
  199. + .align L1_CACHE_SHIFT
  200. /*
  201. * This is the fast syscall return path. We do as little as
  202. * possible here, and this includes saving r0 back into the SVC
  203. @@ -183,7 +184,7 @@ ftrace_stub:
  204. #define A710(code...)
  205. #endif
  206. - .align 5
  207. + .align L1_CACHE_SHIFT
  208. ENTRY(vector_swi)
  209. sub sp, sp, #S_FRAME_SIZE
  210. stmia sp, {r0 - r12} @ Calling r0 - r12
  211. @@ -316,7 +317,7 @@ __sys_trace_return:
  212. bl syscall_trace
  213. b ret_slow_syscall
  214. - .align 5
  215. + .align L1_CACHE_SHIFT
  216. #ifdef CONFIG_ALIGNMENT_TRAP
  217. .type __cr_alignment, #object
  218. __cr_alignment:
  219. --- a/arch/arm/kernel/head.S
  220. +++ b/arch/arm/kernel/head.S
  221. @@ -21,6 +21,7 @@
  222. #include <asm/memory.h>
  223. #include <asm/thread_info.h>
  224. #include <asm/system.h>
  225. +#include <asm/cache.h>
  226. #if (PHYS_OFFSET & 0x001fffff)
  227. #error "PHYS_OFFSET must be at an even 2MiB boundary!"
  228. @@ -192,7 +193,7 @@ ENDPROC(__enable_mmu)
  229. *
  230. * other registers depend on the function called upon completion
  231. */
  232. - .align 5
  233. + .align L1_CACHE_SHIFT
  234. __turn_mmu_on:
  235. mov r0, r0
  236. mcr p15, 0, r0, c1, c0, 0 @ write control reg
  237. --- a/arch/arm/kernel/vmlinux.lds.S
  238. +++ b/arch/arm/kernel/vmlinux.lds.S
  239. @@ -7,6 +7,7 @@
  240. #include <asm/thread_info.h>
  241. #include <asm/memory.h>
  242. #include <asm/page.h>
  243. +#include <asm/cache.h>
  244. OUTPUT_ARCH(arm)
  245. ENTRY(stext)
  246. @@ -59,7 +60,7 @@ SECTIONS
  247. *(.security_initcall.init)
  248. __security_initcall_end = .;
  249. #ifdef CONFIG_BLK_DEV_INITRD
  250. - . = ALIGN(32);
  251. + . = ALIGN(L1_CACHE_BYTES);
  252. __initramfs_start = .;
  253. usr/built-in.o(.init.ramfs)
  254. __initramfs_end = .;
  255. @@ -176,13 +177,13 @@ SECTIONS
  256. /*
  257. * then the cacheline aligned data
  258. */
  259. - . = ALIGN(32);
  260. + . = ALIGN(L1_CACHE_BYTES);
  261. *(.data.cacheline_aligned)
  262. /*
  263. * The exception fixup table (might need resorting at runtime)
  264. */
  265. - . = ALIGN(32);
  266. + . = ALIGN(L1_CACHE_BYTES);
  267. __start___ex_table = .;
  268. #ifdef CONFIG_MMU
  269. *(__ex_table)
  270. --- a/arch/arm/lib/memchr.S
  271. +++ b/arch/arm/lib/memchr.S
  272. @@ -11,9 +11,10 @@
  273. */
  274. #include <linux/linkage.h>
  275. #include <asm/assembler.h>
  276. +#include <asm/cache.h>
  277. .text
  278. - .align 5
  279. + .align L1_CACHE_SHIFT
  280. ENTRY(memchr)
  281. 1: subs r2, r2, #1
  282. bmi 2f
  283. --- a/arch/arm/lib/memset.S
  284. +++ b/arch/arm/lib/memset.S
  285. @@ -11,9 +11,10 @@
  286. */
  287. #include <linux/linkage.h>
  288. #include <asm/assembler.h>
  289. +#include <asm/cache.h>
  290. .text
  291. - .align 5
  292. + .align L1_CACHE_SHIFT
  293. .word 0
  294. 1: subs r2, r2, #4 @ 1 do we have enough
  295. --- a/arch/arm/lib/memzero.S
  296. +++ b/arch/arm/lib/memzero.S
  297. @@ -9,9 +9,10 @@
  298. */
  299. #include <linux/linkage.h>
  300. #include <asm/assembler.h>
  301. +#include <asm/cache.h>
  302. .text
  303. - .align 5
  304. + .align L1_CACHE_SHIFT
  305. .word 0
  306. /*
  307. * Align the pointer in r0. r3 contains the number of bytes that we are
  308. --- a/arch/arm/lib/strchr.S
  309. +++ b/arch/arm/lib/strchr.S
  310. @@ -11,9 +11,10 @@
  311. */
  312. #include <linux/linkage.h>
  313. #include <asm/assembler.h>
  314. +#include <asm/cache.h>
  315. .text
  316. - .align 5
  317. + .align L1_CACHE_SHIFT
  318. ENTRY(strchr)
  319. and r1, r1, #0xff
  320. 1: ldrb r2, [r0], #1
  321. --- a/arch/arm/lib/strncpy_from_user.S
  322. +++ b/arch/arm/lib/strncpy_from_user.S
  323. @@ -10,9 +10,10 @@
  324. #include <linux/linkage.h>
  325. #include <asm/assembler.h>
  326. #include <asm/errno.h>
  327. +#include <asm/cache.h>
  328. .text
  329. - .align 5
  330. + .align L1_CACHE_SHIFT
  331. /*
  332. * Copy a string from user space to kernel space.
  333. --- a/arch/arm/lib/strnlen_user.S
  334. +++ b/arch/arm/lib/strnlen_user.S
  335. @@ -10,9 +10,10 @@
  336. #include <linux/linkage.h>
  337. #include <asm/assembler.h>
  338. #include <asm/errno.h>
  339. +#include <asm/cache.h>
  340. .text
  341. - .align 5
  342. + .align L1_CACHE_SHIFT
  343. /* Prototype: unsigned long __strnlen_user(const char *str, long n)
  344. * Purpose : get length of a string in user memory
  345. --- a/arch/arm/lib/strrchr.S
  346. +++ b/arch/arm/lib/strrchr.S
  347. @@ -11,9 +11,10 @@
  348. */
  349. #include <linux/linkage.h>
  350. #include <asm/assembler.h>
  351. +#include <asm/cache.h>
  352. .text
  353. - .align 5
  354. + .align L1_CACHE_SHIFT
  355. ENTRY(strrchr)
  356. mov r3, #0
  357. 1: ldrb r2, [r0], #1
  358. --- /dev/null
  359. +++ b/arch/arm/mach-gemini/board-nas4220b.c
  360. @@ -0,0 +1,160 @@
  361. +/*
  362. + * Support for Raidsonic NAS-4220-B
  363. + *
  364. + * Copyright (C) 2009 Janos Laube <[email protected]>
  365. + *
  366. + * based on rut1xx.c
  367. + * Copyright (C) 2008 Paulius Zaleckas <[email protected]>
  368. + *
  369. + * This program is free software; you can redistribute it and/or modify
  370. + * it under the terms of the GNU General Public License as published by
  371. + * the Free Software Foundation; either version 2 of the License, or
  372. + * (at your option) any later version.
  373. + */
  374. +
  375. +#include <linux/kernel.h>
  376. +#include <linux/init.h>
  377. +#include <linux/platform_device.h>
  378. +#include <linux/leds.h>
  379. +#include <linux/input.h>
  380. +#include <linux/gpio_keys.h>
  381. +#include <linux/mdio-gpio.h>
  382. +#include <linux/io.h>
  383. +
  384. +#include <asm/setup.h>
  385. +#include <asm/mach-types.h>
  386. +#include <asm/mach/arch.h>
  387. +#include <asm/mach/time.h>
  388. +
  389. +#include <mach/gmac.h>
  390. +#include <mach/hardware.h>
  391. +#include <mach/global_reg.h>
  392. +
  393. +#include "common.h"
  394. +
  395. +static struct sys_timer ib4220b_timer = {
  396. + .init = gemini_timer_init,
  397. +};
  398. +
  399. +static struct gpio_led ib4220b_leds[] = {
  400. + {
  401. + .name = "nas4220b:orange:hdd",
  402. + .default_trigger = "ide-disk",
  403. + .gpio = 60,
  404. + },
  405. + {
  406. + .name = "nas4220b:green:os",
  407. + .default_trigger = "heartbeat",
  408. + .gpio = 62,
  409. + },
  410. +};
  411. +
  412. +static struct gpio_led_platform_data ib4220b_leds_data = {
  413. + .num_leds = ARRAY_SIZE(ib4220b_leds),
  414. + .leds = ib4220b_leds,
  415. +};
  416. +
  417. +static struct platform_device ib4220b_led_device = {
  418. + .name = "leds-gpio",
  419. + .id = -1,
  420. + .dev = {
  421. + .platform_data = &ib4220b_leds_data,
  422. + },
  423. +};
  424. +
  425. +static struct gpio_keys_button ib4220b_keys[] = {
  426. + {
  427. + .code = KEY_SETUP,
  428. + .gpio = 61,
  429. + .active_low = 1,
  430. + .desc = "Backup Button",
  431. + .type = EV_KEY,
  432. + },
  433. + {
  434. + .code = KEY_RESTART,
  435. + .gpio = 63,
  436. + .active_low = 1,
  437. + .desc = "Softreset Button",
  438. + .type = EV_KEY,
  439. + },
  440. +};
  441. +
  442. +static struct gpio_keys_platform_data ib4220b_keys_data = {
  443. + .buttons = ib4220b_keys,
  444. + .nbuttons = ARRAY_SIZE(ib4220b_keys),
  445. +};
  446. +
  447. +static struct platform_device ib4220b_key_device = {
  448. + .name = "gpio-keys",
  449. + .id = -1,
  450. + .dev = {
  451. + .platform_data = &ib4220b_keys_data,
  452. + },
  453. +};
  454. +
  455. +static struct mdio_gpio_platform_data ib4220b_mdio = {
  456. + .mdc = 22,
  457. + .mdio = 21,
  458. + .phy_mask = ~(1 << 1),
  459. +};
  460. +
  461. +static struct platform_device ib4220b_phy_device = {
  462. + .name = "mdio-gpio",
  463. + .id = 0,
  464. + .dev = {
  465. + .platform_data = &ib4220b_mdio,
  466. + },
  467. +};
  468. +
  469. +static struct gemini_gmac_platform_data ib4220b_gmac_data = {
  470. + .bus_id[0] = "0:01",
  471. + .interface[0] = PHY_INTERFACE_MODE_RGMII,
  472. +};
  473. +
  474. +static void __init gmac_ib4220b_init(void)
  475. +{
  476. + unsigned int val;
  477. +
  478. + val = __raw_readl(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
  479. + GLOBAL_IO_DRIVING_CTRL);
  480. + val |= (0x3 << GMAC0_PADS_SHIFT) | (0x3 << GMAC1_PADS_SHIFT);
  481. + __raw_writel(val, IO_ADDRESS(GEMINI_GLOBAL_BASE) +
  482. + GLOBAL_IO_DRIVING_CTRL);
  483. +
  484. + val = (0x0 << GMAC0_RXDV_SKEW_SHIFT) | (0xf << GMAC0_RXC_SKEW_SHIFT) |
  485. + (0x7 << GMAC0_TXEN_SKEW_SHIFT) | (0xa << GMAC0_TXC_SKEW_SHIFT) |
  486. + (0x0 << GMAC1_RXDV_SKEW_SHIFT) | (0xf << GMAC1_RXC_SKEW_SHIFT) |
  487. + (0x7 << GMAC1_TXEN_SKEW_SHIFT) | (0xa << GMAC1_TXC_SKEW_SHIFT);
  488. + __raw_writel(val, IO_ADDRESS(GEMINI_GLOBAL_BASE) +
  489. + GLOBAL_GMAC_CTRL_SKEW_CTRL);
  490. +
  491. + val = __raw_readl(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
  492. + GLOBAL_ARBITRATION1_CTRL);
  493. + val |= (0x20 << BURST_LENGTH_SHIFT);
  494. + __raw_writel(val, IO_ADDRESS(GEMINI_GLOBAL_BASE) +
  495. + GLOBAL_ARBITRATION1_CTRL);
  496. +}
  497. +
  498. +static void __init ib4220b_init(void)
  499. +{
  500. + gemini_gpio_init();
  501. + gmac_ib4220b_init();
  502. + platform_register_uart();
  503. + platform_register_usb(0);
  504. + platform_register_usb(1);
  505. + platform_register_pflash(SZ_16M, NULL, 0);
  506. + platform_device_register(&ib4220b_led_device);
  507. + platform_device_register(&ib4220b_key_device);
  508. + platform_device_register(&ib4220b_phy_device);
  509. + platform_register_ethernet(&ib4220b_gmac_data);
  510. +}
  511. +
  512. +MACHINE_START(NAS4220B, "Raidsonic NAS IB-4220-B")
  513. + .phys_io = 0x7fffc000,
  514. + .io_pg_offst = ((0xffffc000) >> 18) & 0xfffc,
  515. + .boot_params = 0x100,
  516. + .map_io = gemini_map_io,
  517. + .init_irq = gemini_init_irq,
  518. + .timer = &ib4220b_timer,
  519. + .init_machine = ib4220b_init,
  520. +MACHINE_END
  521. --- a/arch/arm/mach-gemini/board-rut1xx.c
  522. +++ b/arch/arm/mach-gemini/board-rut1xx.c
  523. @@ -14,13 +14,35 @@
  524. #include <linux/leds.h>
  525. #include <linux/input.h>
  526. #include <linux/gpio_keys.h>
  527. +#include <linux/mdio-gpio.h>
  528. #include <asm/mach-types.h>
  529. #include <asm/mach/arch.h>
  530. #include <asm/mach/time.h>
  531. +#include <mach/gmac.h>
  532. +
  533. #include "common.h"
  534. +static struct mdio_gpio_platform_data rut1xx_mdio = {
  535. + .mdc = 22,
  536. + .mdio = 21,
  537. + .phy_mask = ~(1 << 1),
  538. +};
  539. +
  540. +static struct platform_device rut1xx_phy_device = {
  541. + .name = "mdio-gpio",
  542. + .id = 0,
  543. + .dev = {
  544. + .platform_data = &rut1xx_mdio,
  545. + },
  546. +};
  547. +
  548. +static struct gemini_gmac_platform_data gmac_data = {
  549. + .bus_id[0] = "0:01",
  550. + .interface[0] = PHY_INTERFACE_MODE_MII,
  551. +};
  552. +
  553. static struct gpio_keys_button rut1xx_keys[] = {
  554. {
  555. .code = KEY_SETUP,
  556. @@ -79,9 +101,13 @@ static void __init rut1xx_init(void)
  557. {
  558. gemini_gpio_init();
  559. platform_register_uart();
  560. + platform_register_watchdog();
  561. + platform_register_usb(0);
  562. platform_register_pflash(SZ_8M, NULL, 0);
  563. platform_device_register(&rut1xx_leds);
  564. platform_device_register(&rut1xx_keys_device);
  565. + platform_device_register(&rut1xx_phy_device);
  566. + platform_register_ethernet(&gmac_data);
  567. }
  568. MACHINE_START(RUT100, "Teltonika RUT100")
  569. --- a/arch/arm/mach-gemini/common.h
  570. +++ b/arch/arm/mach-gemini/common.h
  571. @@ -13,6 +13,7 @@
  572. #define __GEMINI_COMMON_H__
  573. struct mtd_partition;
  574. +struct gemini_gmac_platform_data;
  575. extern void gemini_map_io(void);
  576. extern void gemini_init_irq(void);
  577. @@ -21,8 +22,11 @@ extern void gemini_gpio_init(void);
  578. /* Common platform devices registration functions */
  579. extern int platform_register_uart(void);
  580. +extern int platform_register_ethernet(struct gemini_gmac_platform_data *pdata);
  581. extern int platform_register_pflash(unsigned int size,
  582. struct mtd_partition *parts,
  583. unsigned int nr_parts);
  584. +extern int platform_register_usb(unsigned int i);
  585. +extern int platform_register_watchdog(void);
  586. #endif /* __GEMINI_COMMON_H__ */
  587. --- a/arch/arm/mach-gemini/devices.c
  588. +++ b/arch/arm/mach-gemini/devices.c
  589. @@ -17,6 +17,7 @@
  590. #include <mach/irqs.h>
  591. #include <mach/hardware.h>
  592. #include <mach/global_reg.h>
  593. +#include <mach/gmac.h>
  594. static struct plat_serial8250_port serial_platform_data[] = {
  595. {
  596. @@ -45,6 +46,116 @@ int platform_register_uart(void)
  597. return platform_device_register(&serial_device);
  598. }
  599. +static struct resource usb0_resources[] = {
  600. + {
  601. + .start = 0x68000000,
  602. + .end = 0x68000fff,
  603. + .flags = IORESOURCE_MEM,
  604. + },
  605. + {
  606. + .start = IRQ_USB0,
  607. + .end = IRQ_USB0,
  608. + .flags = IORESOURCE_IRQ,
  609. + },
  610. +};
  611. +
  612. +static struct resource usb1_resources[] = {
  613. + {
  614. + .start = 0x69000000,
  615. + .end = 0x69000fff,
  616. + .flags = IORESOURCE_MEM,
  617. + },
  618. + {
  619. + .start = IRQ_USB1,
  620. + .end = IRQ_USB1,
  621. + .flags = IORESOURCE_IRQ,
  622. + },
  623. +};
  624. +
  625. +static u64 usb0_dmamask = 0xffffffffUL;
  626. +
  627. +static u64 usb1_dmamask = 0xffffffffUL;
  628. +
  629. +static struct platform_device usb_device[] = {
  630. + {
  631. + .name = "ehci-fotg2xx",
  632. + .id = 0,
  633. + .dev = {
  634. + .dma_mask = &usb0_dmamask,
  635. + .coherent_dma_mask = 0xffffffff,
  636. + },
  637. + .num_resources = ARRAY_SIZE(usb0_resources),
  638. + .resource = usb0_resources,
  639. + },
  640. + {
  641. + .name = "ehci-fotg2xx",
  642. + .id = 1,
  643. + .dev = {
  644. + .dma_mask = &usb1_dmamask,
  645. + .coherent_dma_mask = 0xffffffff,
  646. + },
  647. + .num_resources = ARRAY_SIZE(usb1_resources),
  648. + .resource = usb1_resources,
  649. + },
  650. +};
  651. +
  652. +int platform_register_usb(unsigned int i)
  653. +{
  654. + if (i > 1)
  655. + return -EINVAL;
  656. +
  657. + return platform_device_register(&usb_device[i]);
  658. +}
  659. +
  660. +static struct resource gmac_resources[] = {
  661. + {
  662. + .start = 0x60000000,
  663. + .end = 0x6000ffff,
  664. + .flags = IORESOURCE_MEM,
  665. + },
  666. + {
  667. + .start = IRQ_GMAC0,
  668. + .end = IRQ_GMAC0,
  669. + .flags = IORESOURCE_IRQ,
  670. + },
  671. + {
  672. + .start = IRQ_GMAC1,
  673. + .end = IRQ_GMAC1,
  674. + .flags = IORESOURCE_IRQ,
  675. + },
  676. +};
  677. +
  678. +static u64 gmac_dmamask = 0xffffffffUL;
  679. +
  680. +static struct platform_device ethernet_device = {
  681. + .name = "gemini-gmac",
  682. + .id = 0,
  683. + .dev = {
  684. + .dma_mask = &gmac_dmamask,
  685. + .coherent_dma_mask = 0xffffffff,
  686. + },
  687. + .num_resources = ARRAY_SIZE(gmac_resources),
  688. + .resource = gmac_resources,
  689. +};
  690. +
  691. +int platform_register_ethernet(struct gemini_gmac_platform_data *pdata)
  692. +{
  693. + unsigned int reg = __raw_readl(IO_ADDRESS(GEMINI_GLOBAL_BASE) + GLOBAL_MISC_CTRL);
  694. +
  695. + reg &= ~(GMAC_GMII | GMAC_1_ENABLE);
  696. +
  697. + if (pdata->bus_id[1])
  698. + reg |= GMAC_1_ENABLE;
  699. + else if (pdata->interface[0] == PHY_INTERFACE_MODE_GMII)
  700. + reg |= GMAC_GMII;
  701. +
  702. + __raw_writel(reg, IO_ADDRESS(GEMINI_GLOBAL_BASE) + GLOBAL_MISC_CTRL);
  703. +
  704. + ethernet_device.dev.platform_data = pdata;
  705. +
  706. + return platform_device_register(&ethernet_device);
  707. +}
  708. +
  709. static struct resource flash_resource = {
  710. .start = GEMINI_FLASH_BASE,
  711. .flags = IORESOURCE_MEM,
  712. @@ -90,3 +201,21 @@ int platform_register_pflash(unsigned in
  713. return platform_device_register(&pflash_device);
  714. }
  715. +
  716. +static struct resource wdt_resource = {
  717. + .start = GEMINI_WAQTCHDOG_BASE,
  718. + .end = GEMINI_WAQTCHDOG_BASE + 0x18,
  719. + .flags = IORESOURCE_MEM,
  720. +};
  721. +
  722. +static struct platform_device wdt_device = {
  723. + .name = "gemini-wdt",
  724. + .id = 0,
  725. + .resource = &wdt_resource,
  726. + .num_resources = 1,
  727. +};
  728. +
  729. +int platform_register_watchdog(void)
  730. +{
  731. + return platform_device_register(&wdt_device);
  732. +}
  733. --- /dev/null
  734. +++ b/arch/arm/mach-gemini/include/mach/gmac.h
  735. @@ -0,0 +1,21 @@
  736. +/*
  737. + * Gemini GMAC specific defines
  738. + *
  739. + * Copyright (C) 2008, Paulius Zaleckas <[email protected]>
  740. + *
  741. + * This program is free software; you can redistribute it and/or modify
  742. + * it under the terms of the GNU General Public License as published by
  743. + * the Free Software Foundation; either version 2 of the License, or
  744. + * (at your option) any later version.
  745. + */
  746. +#ifndef __MACH_GMAC_H__
  747. +#define __MACH_GMAC_H__
  748. +
  749. +#include <linux/phy.h>
  750. +
  751. +struct gemini_gmac_platform_data {
  752. + char *bus_id[2]; /* NULL means that this port is not used */
  753. + phy_interface_t interface[2];
  754. +};
  755. +
  756. +#endif /* __MACH_GMAC_H__ */
  757. --- a/arch/arm/mach-gemini/include/mach/hardware.h
  758. +++ b/arch/arm/mach-gemini/include/mach/hardware.h
  759. @@ -71,4 +71,12 @@
  760. */
  761. #define IO_ADDRESS(x) ((((x) & 0xFFF00000) >> 4) | ((x) & 0x000FFFFF) | 0xF0000000)
  762. +/*
  763. + * PCI subsystem macros
  764. + */
  765. +#define PCIBIOS_MIN_IO 0x00000100
  766. +#define PCIBIOS_MIN_MEM 0x00000000
  767. +
  768. +#define pcibios_assign_all_busses() 1
  769. +
  770. #endif
  771. --- a/arch/arm/mach-gemini/include/mach/irqs.h
  772. +++ b/arch/arm/mach-gemini/include/mach/irqs.h
  773. @@ -43,11 +43,14 @@
  774. #define NORMAL_IRQ_NUM 32
  775. -#define GPIO_IRQ_BASE NORMAL_IRQ_NUM
  776. +#define PCI_IRQ_BASE NORMAL_IRQ_NUM
  777. +#define PCI_IRQ_NUM 4
  778. +
  779. +#define GPIO_IRQ_BASE (NORMAL_IRQ_NUM + PCI_IRQ_NUM)
  780. #define GPIO_IRQ_NUM (3 * 32)
  781. #define ARCH_TIMER_IRQ IRQ_TIMER2
  782. -#define NR_IRQS (NORMAL_IRQ_NUM + GPIO_IRQ_NUM)
  783. +#define NR_IRQS (NORMAL_IRQ_NUM + PCI_IRQ_NUM + GPIO_IRQ_NUM)
  784. #endif /* __MACH_IRQS_H__ */
  785. --- a/arch/arm/mach-gemini/Kconfig
  786. +++ b/arch/arm/mach-gemini/Kconfig
  787. @@ -2,6 +2,13 @@ if ARCH_GEMINI
  788. menu "Cortina Systems Gemini Implementations"
  789. +config MACH_NAS4220B
  790. + bool "Raidsonic NAS-4220-B"
  791. + select GEMINI_MEM_SWAP
  792. + help
  793. + Say Y here if you intend to run this kernel on a
  794. + Raidsonic NAS-4220-B.
  795. +
  796. config MACH_RUT100
  797. bool "Teltonika RUT100"
  798. select GEMINI_MEM_SWAP
  799. --- a/arch/arm/mach-gemini/Makefile
  800. +++ b/arch/arm/mach-gemini/Makefile
  801. @@ -6,5 +6,8 @@
  802. obj-y := irq.o mm.o time.o devices.o gpio.o
  803. +obj-$(CONFIG_PCI) += pci.o
  804. +
  805. # Board-specific support
  806. +obj-$(CONFIG_MACH_NAS4220B) += board-nas4220b.o
  807. obj-$(CONFIG_MACH_RUT100) += board-rut1xx.o
  808. --- a/arch/arm/mach-gemini/mm.c
  809. +++ b/arch/arm/mach-gemini/mm.c
  810. @@ -59,6 +59,11 @@ static struct map_desc gemini_io_desc[]
  811. .length = SZ_512K,
  812. .type = MT_DEVICE,
  813. }, {
  814. + .virtual = IO_ADDRESS(GEMINI_PCI_IO_BASE),
  815. + .pfn = __phys_to_pfn(GEMINI_PCI_IO_BASE),
  816. + .length = SZ_512K,
  817. + .type = MT_DEVICE,
  818. + }, {
  819. .virtual = IO_ADDRESS(GEMINI_FLASH_CTRL_BASE),
  820. .pfn = __phys_to_pfn(GEMINI_FLASH_CTRL_BASE),
  821. .length = SZ_512K,
  822. --- /dev/null
  823. +++ b/arch/arm/mach-gemini/pci.c
  824. @@ -0,0 +1,315 @@
  825. +/*
  826. + * Support for Gemini PCI Controller
  827. + *
  828. + * Copyright (C) 2009 Janos Laube <[email protected]>
  829. + * Copyright (C) 2009 Paulius Zaleckas <[email protected]>
  830. + *
  831. + * based on SL2312 PCI controller code
  832. + * Storlink (C) 2003
  833. + *
  834. + * This program is free software; you can redistribute it and/or modify
  835. + * it under the terms of the GNU General Public License as published by
  836. + * the Free Software Foundation; either version 2 of the License, or
  837. + * (at your option) any later version.
  838. + */
  839. +
  840. +#include <linux/kernel.h>
  841. +#include <linux/pci.h>
  842. +#include <linux/irq.h>
  843. +
  844. +#include <asm/mach/pci.h>
  845. +#include <asm/gpio.h>
  846. +
  847. +#include <mach/irqs.h>
  848. +
  849. +#define GEMINI_PCI_IOSIZE_1M 0x0000
  850. +
  851. +#define GEMINI_PCI_PMC 0x40
  852. +#define GEMINI_PCI_PMCSR 0x44
  853. +#define GEMINI_PCI_CTRL1 0x48
  854. +#define GEMINI_PCI_CTRL2 0x4C
  855. +#define GEMINI_PCI_MEM1_BASE_SIZE 0x50
  856. +#define GEMINI_PCI_MEM2_BASE_SIZE 0x54
  857. +#define GEMINI_PCI_MEM3_BASE_SIZE 0x58
  858. +
  859. +#define PCI_CTRL2_INTSTS_OFFSET 28
  860. +#define PCI_CTRL2_INTMASK_OFFSET 22
  861. +
  862. +#define GEMINI_PCI_DMA_MASK 0xFFF00000
  863. +#define GEMINI_PCI_DMA_MEM1_BASE 0x00000000
  864. +#define GEMINI_PCI_DMA_MEM2_BASE 0x00000000
  865. +#define GEMINI_PCI_DMA_MEM3_BASE 0x00000000
  866. +#define GEMINI_PCI_DMA_MEM1_SIZE 7
  867. +#define GEMINI_PCI_DMA_MEM2_SIZE 6
  868. +#define GEMINI_PCI_DMA_MEM3_SIZE 6
  869. +
  870. +#define PCI_CONF_ENABLE (1 << 31)
  871. +#define PCI_CONF_WHERE(r) ((r) & 0xFC)
  872. +#define PCI_CONF_BUS(b) (((b) & 0xFF) << 16)
  873. +#define PCI_CONF_DEVICE(d) (((d) & 0x1F) << 11)
  874. +#define PCI_CONF_FUNCTION(f) (((f) & 0x07) << 8)
  875. +
  876. +#define PCI_IOSIZE_REG (IO_ADDRESS(GEMINI_PCI_IO_BASE))
  877. +#define PCI_PROT_REG (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x04)
  878. +#define PCI_CTRL_REG (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x08)
  879. +#define PCI_SOFTRST_REG (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x10)
  880. +#define PCI_CONFIG_REG (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x28)
  881. +#define PCI_DATA_REG (IO_ADDRESS(GEMINI_PCI_IO_BASE) + 0x2C)
  882. +
  883. +
  884. +static DEFINE_SPINLOCK(gemini_pci_lock);
  885. +
  886. +static struct resource gemini_pci_resource_io = {
  887. + .name = "PCI I/O Space",
  888. + .start = IO_ADDRESS(GEMINI_PCI_IO_BASE),
  889. + .end = IO_ADDRESS(GEMINI_PCI_IO_BASE) + SZ_1M - 1,
  890. + .flags = IORESOURCE_IO,
  891. +};
  892. +
  893. +static struct resource gemini_pci_resource_mem = {
  894. + .name = "PCI Memory Space",
  895. + .start = GEMINI_PCI_MEM_BASE,
  896. + .end = GEMINI_PCI_MEM_BASE + SZ_128M - 1,
  897. + .flags = IORESOURCE_MEM,
  898. +};
  899. +
  900. +static int gemini_pci_read_config(struct pci_bus* bus, unsigned int fn,
  901. + int config, int size, u32* value)
  902. +{
  903. + unsigned long irq_flags;
  904. +
  905. + spin_lock_irqsave(&gemini_pci_lock, irq_flags);
  906. +
  907. + __raw_writel(PCI_CONF_BUS(bus->number) |
  908. + PCI_CONF_DEVICE(PCI_SLOT(fn)) |
  909. + PCI_CONF_FUNCTION(PCI_FUNC(fn)) |
  910. + PCI_CONF_WHERE(config) |
  911. + PCI_CONF_ENABLE,
  912. + PCI_CONFIG_REG);
  913. +
  914. + *value = __raw_readl(PCI_DATA_REG);
  915. +
  916. + if (size == 1)
  917. + *value = (*value >> (8 * (config & 3))) & 0xFF;
  918. + else if (size == 2)
  919. + *value = (*value >> (8 * (config & 3))) & 0xFFFF;
  920. +
  921. + spin_unlock_irqrestore(&gemini_pci_lock, irq_flags);
  922. +
  923. + dev_dbg(&bus->dev,
  924. + "[read] slt: %.2d, fnc: %d, cnf: 0x%.2X, val (%d bytes): 0x%.8X\n",
  925. + PCI_SLOT(fn), PCI_FUNC(fn), config, size, *value);
  926. +
  927. + return PCIBIOS_SUCCESSFUL;
  928. +}
  929. +
  930. +static int gemini_pci_write_config(struct pci_bus* bus, unsigned int fn,
  931. + int config, int size, u32 value)
  932. +{
  933. + unsigned long irq_flags = 0;
  934. + int ret = PCIBIOS_SUCCESSFUL;
  935. +
  936. + dev_dbg(&bus->dev,
  937. + "[write] slt: %.2d, fnc: %d, cnf: 0x%.2X, val (%d bytes): 0x%.8X\n",
  938. + PCI_SLOT(fn), PCI_FUNC(fn), config, size, value);
  939. +
  940. + spin_lock_irqsave(&gemini_pci_lock, irq_flags);
  941. +
  942. + __raw_writel(PCI_CONF_BUS(bus->number) |
  943. + PCI_CONF_DEVICE(PCI_SLOT(fn)) |
  944. + PCI_CONF_FUNCTION(PCI_FUNC(fn)) |
  945. + PCI_CONF_WHERE(config) |
  946. + PCI_CONF_ENABLE,
  947. + PCI_CONFIG_REG);
  948. +
  949. + switch(size) {
  950. + case 4:
  951. + __raw_writel(value, PCI_DATA_REG);
  952. + break;
  953. + case 2:
  954. + __raw_writew(value, PCI_DATA_REG + (config & 3));
  955. + break;
  956. + case 1:
  957. + __raw_writeb(value, PCI_DATA_REG + (config & 3));
  958. + break;
  959. + default:
  960. + ret = PCIBIOS_BAD_REGISTER_NUMBER;
  961. + }
  962. +
  963. + spin_unlock_irqrestore(&gemini_pci_lock, irq_flags);
  964. +
  965. + return ret;
  966. +}
  967. +
  968. +static struct pci_ops gemini_pci_ops = {
  969. + .read = gemini_pci_read_config,
  970. + .write = gemini_pci_write_config,
  971. +};
  972. +
  973. +static int __init gemini_pci_request_resources(struct pci_sys_data *sys)
  974. +{
  975. + if (request_resource(&ioport_resource, &gemini_pci_resource_io))
  976. + goto bad_resources;
  977. + if (request_resource(&iomem_resource, &gemini_pci_resource_mem))
  978. + goto bad_resources;
  979. +
  980. + sys->resource[0] = &gemini_pci_resource_io;
  981. + sys->resource[1] = &gemini_pci_resource_mem;
  982. + sys->resource[2] = 0;
  983. +
  984. + return 0;
  985. +
  986. +bad_resources:
  987. + pr_err("Gemini PCI: request_resource() failed. "
  988. + "Abort PCI bus enumeration.\n");
  989. + return -1;
  990. +}
  991. +
  992. +static int __init gemini_pci_setup(int nr, struct pci_sys_data *sys)
  993. +{
  994. + unsigned int cmd;
  995. +
  996. + if ((nr > 0) || gemini_pci_request_resources(sys))
  997. + return 0;
  998. +
  999. + /* setup I/O space to 1MB size */
  1000. + __raw_writel(GEMINI_PCI_IOSIZE_1M, PCI_IOSIZE_REG);
  1001. +
  1002. + /* setup hostbridge */
  1003. + cmd = __raw_readl(PCI_CTRL_REG);
  1004. + cmd |= PCI_COMMAND_IO;
  1005. + cmd |= PCI_COMMAND_MEMORY;
  1006. + cmd |= PCI_COMMAND_MASTER;
  1007. + __raw_writel(cmd, PCI_CTRL_REG);
  1008. +
  1009. + return 1;
  1010. +}
  1011. +
  1012. +static struct pci_bus* __init gemini_pci_scan_bus(int nr, struct pci_sys_data* sys)
  1013. +{
  1014. + unsigned int reg = 0;
  1015. + struct pci_bus* bus = 0;
  1016. +
  1017. + bus = pci_scan_bus(nr, &gemini_pci_ops, sys);
  1018. + if (bus) {
  1019. + dev_dbg(&bus->dev, "setting up PCI DMA\n");
  1020. + reg = (GEMINI_PCI_DMA_MEM1_BASE & GEMINI_PCI_DMA_MASK)
  1021. + | (GEMINI_PCI_DMA_MEM1_SIZE << 16);
  1022. + gemini_pci_write_config(bus, 0, GEMINI_PCI_MEM1_BASE_SIZE, 4, reg);
  1023. + reg = (GEMINI_PCI_DMA_MEM2_BASE & GEMINI_PCI_DMA_MASK)
  1024. + | (GEMINI_PCI_DMA_MEM2_SIZE << 16);
  1025. + gemini_pci_write_config(bus, 0, GEMINI_PCI_MEM2_BASE_SIZE, 4, reg);
  1026. + reg = (GEMINI_PCI_DMA_MEM3_BASE & GEMINI_PCI_DMA_MASK)
  1027. + | (GEMINI_PCI_DMA_MEM3_SIZE << 16);
  1028. + gemini_pci_write_config(bus, 0, GEMINI_PCI_MEM3_BASE_SIZE, 4, reg);
  1029. + }
  1030. +
  1031. + return bus;
  1032. +}
  1033. +
  1034. +/* Should work with all boards based on original Storlink EVB */
  1035. +static int __init gemini_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  1036. +{
  1037. + if (slot < 9 || slot > 12)
  1038. + return -1;
  1039. +
  1040. + return PCI_IRQ_BASE + (((slot - 9) + (pin - 1)) & 0x3);
  1041. +}
  1042. +
  1043. +static struct hw_pci gemini_hw_pci __initdata = {
  1044. + .nr_controllers = 1,
  1045. + .setup = gemini_pci_setup,
  1046. + .scan = gemini_pci_scan_bus,
  1047. + .swizzle = pci_std_swizzle,
  1048. + .map_irq = gemini_pci_map_irq,
  1049. +};
  1050. +
  1051. +/* we need this for muxed PCI interrupts handling */
  1052. +static struct pci_bus bogus_pci_bus;
  1053. +
  1054. +static void gemini_pci_ack_irq(unsigned int irq)
  1055. +{
  1056. + unsigned int reg;
  1057. +
  1058. + gemini_pci_read_config(&bogus_pci_bus, 0, GEMINI_PCI_CTRL2, 4, &reg);
  1059. + reg &= ~(0xF << PCI_CTRL2_INTSTS_OFFSET);
  1060. + reg |= 1 << (irq - PCI_IRQ_BASE + PCI_CTRL2_INTSTS_OFFSET);
  1061. + gemini_pci_write_config(&bogus_pci_bus, 0, GEMINI_PCI_CTRL2, 4, reg);
  1062. +}
  1063. +
  1064. +static void gemini_pci_mask_irq(unsigned int irq)
  1065. +{
  1066. + unsigned int reg;
  1067. +
  1068. + gemini_pci_read_config(&bogus_pci_bus, 0, GEMINI_PCI_CTRL2, 4, &reg);
  1069. + reg &= ~((0xF << PCI_CTRL2_INTSTS_OFFSET)
  1070. + | (1 << (irq - PCI_IRQ_BASE + PCI_CTRL2_INTMASK_OFFSET)));
  1071. + gemini_pci_write_config(&bogus_pci_bus, 0, GEMINI_PCI_CTRL2, 4, reg);
  1072. +}
  1073. +
  1074. +static void gemini_pci_unmask_irq(unsigned int irq)
  1075. +{
  1076. + unsigned int reg;
  1077. +
  1078. + gemini_pci_read_config(&bogus_pci_bus, 0, GEMINI_PCI_CTRL2, 4, &reg);
  1079. + reg &= ~(0xF << PCI_CTRL2_INTSTS_OFFSET);
  1080. + reg |= 1 << (irq - PCI_IRQ_BASE + PCI_CTRL2_INTMASK_OFFSET);
  1081. + gemini_pci_write_config(&bogus_pci_bus, 0, GEMINI_PCI_CTRL2, 4, reg);
  1082. +}
  1083. +
  1084. +static void gemini_pci_irq_handler(unsigned int irq, struct irq_desc *desc)
  1085. +{
  1086. + unsigned int pci_irq_no, irq_stat, reg, i;
  1087. +
  1088. + gemini_pci_read_config(&bogus_pci_bus, 0, GEMINI_PCI_CTRL2, 4, &reg);
  1089. + irq_stat = reg >> PCI_CTRL2_INTSTS_OFFSET;
  1090. +
  1091. + for (i = 0; i < 4; i++) {
  1092. +
  1093. + if ((irq_stat & (1 << i)) == 0)
  1094. + continue;
  1095. +
  1096. + pci_irq_no = PCI_IRQ_BASE + i;
  1097. +
  1098. + BUG_ON(!(irq_desc[pci_irq_no].handle_irq));
  1099. + irq_desc[pci_irq_no].handle_irq(pci_irq_no,
  1100. + &irq_desc[pci_irq_no]);
  1101. + }
  1102. +}
  1103. +
  1104. +static struct irq_chip gemini_pci_irq_chip = {
  1105. + .name = "PCI",
  1106. + .ack = gemini_pci_ack_irq,
  1107. + .mask = gemini_pci_mask_irq,
  1108. + .unmask = gemini_pci_unmask_irq,
  1109. +};
  1110. +
  1111. +static int __init gemini_pci_init(void)
  1112. +{
  1113. + int i;
  1114. +
  1115. + for (i = 72; i <= 95; i++)
  1116. + gpio_request(i, "PCI");
  1117. +
  1118. + /* initialize our bogus bus */
  1119. + dev_set_name(&bogus_pci_bus.dev, "PCI IRQ handler");
  1120. + bogus_pci_bus.number = 0;
  1121. +
  1122. + /* mask and clear all interrupts */
  1123. + gemini_pci_write_config(&bogus_pci_bus, 0, GEMINI_PCI_CTRL2 + 2, 2,
  1124. + 0xF000);
  1125. +
  1126. + for (i = PCI_IRQ_BASE; i < PCI_IRQ_BASE + 4; i++) {
  1127. + set_irq_chip(i, &gemini_pci_irq_chip);
  1128. + set_irq_handler(i, handle_level_irq);
  1129. + set_irq_flags(i, IRQF_VALID);
  1130. + }
  1131. +
  1132. + set_irq_chained_handler(IRQ_PCI, gemini_pci_irq_handler);
  1133. +
  1134. + pci_common_init(&gemini_hw_pci);
  1135. +
  1136. + return 0;
  1137. +}
  1138. +
  1139. +subsys_initcall(gemini_pci_init);
  1140. --- a/arch/arm/mm/abort-ev4.S
  1141. +++ b/arch/arm/mm/abort-ev4.S
  1142. @@ -1,5 +1,6 @@
  1143. #include <linux/linkage.h>
  1144. #include <asm/assembler.h>
  1145. +#include <asm/cache.h>
  1146. /*
  1147. * Function: v4_early_abort
  1148. *
  1149. @@ -17,7 +18,7 @@
  1150. * abort here if the I-TLB and D-TLB aren't seeing the same
  1151. * picture. Unfortunately, this does happen. We live with it.
  1152. */
  1153. - .align 5
  1154. + .align L1_CACHE_SHIFT
  1155. ENTRY(v4_early_abort)
  1156. mrc p15, 0, r1, c5, c0, 0 @ get FSR
  1157. mrc p15, 0, r0, c6, c0, 0 @ get FAR
  1158. --- a/arch/arm/mm/abort-nommu.S
  1159. +++ b/arch/arm/mm/abort-nommu.S
  1160. @@ -1,5 +1,6 @@
  1161. #include <linux/linkage.h>
  1162. #include <asm/assembler.h>
  1163. +#include <asm/cache.h>
  1164. /*
  1165. * Function: nommu_early_abort
  1166. *
  1167. @@ -12,7 +13,7 @@
  1168. * Note: There is no FSR/FAR on !CPU_CP15_MMU cores.
  1169. * Just fill zero into the registers.
  1170. */
  1171. - .align 5
  1172. + .align L1_CACHE_SHIFT
  1173. ENTRY(nommu_early_abort)
  1174. mov r0, #0 @ clear r0, r1 (no FSR/FAR)
  1175. mov r1, #0
  1176. --- /dev/null
  1177. +++ b/drivers/net/gemini_negmac/gm_gmac.c
  1178. @@ -0,0 +1,1350 @@
  1179. +/*
  1180. + * Ethernet device driver for Gemini SoC.
  1181. + *
  1182. + * Copyright (C) 2006, Storlink, Corp.
  1183. + * Copyright (C) 2008-2009, Paulius Zaleckas <[email protected]>
  1184. + *
  1185. + * This program is free software; you can redistribute it and/or modify
  1186. + * it under the terms of the GNU General Public License as published by
  1187. + * the Free Software Foundation; either version 2 of the License, or
  1188. + * (at your option) any later version.
  1189. + */
  1190. +#include <linux/module.h>
  1191. +#include <linux/kernel.h>
  1192. +#include <linux/platform_device.h>
  1193. +#include <linux/slab.h>
  1194. +#include <linux/mm.h>
  1195. +#include <linux/compiler.h>
  1196. +#include <linux/dma-mapping.h>
  1197. +#include <linux/init.h>
  1198. +#include <linux/ioport.h>
  1199. +#include <linux/netdevice.h>
  1200. +#include <linux/etherdevice.h>
  1201. +#include <linux/rtnetlink.h>
  1202. +#include <linux/delay.h>
  1203. +#include <linux/ethtool.h>
  1204. +#include <linux/mii.h>
  1205. +#include <linux/phy.h>
  1206. +#include <linux/completion.h>
  1207. +#include <linux/kthread.h>
  1208. +#include <linux/io.h>
  1209. +#include <mach/hardware.h>
  1210. +#include <asm/irq.h>
  1211. +#include <linux/semaphore.h>
  1212. +#include <mach/irqs.h>
  1213. +#include <linux/skbuff.h>
  1214. +#include <linux/in.h>
  1215. +#include <linux/ip.h>
  1216. +#include <linux/tcp.h>
  1217. +#include <linux/udp.h>
  1218. +#include <mach/gmac.h>
  1219. +
  1220. +#include "gm_gmac.h"
  1221. +
  1222. +/* #define GMAX_TX_INTR_DISABLED */
  1223. +#define DO_HW_CHKSUM
  1224. +/* #define ENABLE_TSO */
  1225. +#define GMAC_USE_TXQ0
  1226. +/* #define GMAC_LEN_1_2_ISSUE */
  1227. +
  1228. +#define DEFAULT_RXQ_MAX_CNT 256
  1229. +
  1230. +/* define chip information */
  1231. +#define DRV_VERSION "0.2"
  1232. +#define SL351x_DRIVER_NAME "Gemini Ethernet driver " DRV_VERSION
  1233. +
  1234. +#ifdef GMAC_LEN_1_2_ISSUE
  1235. + #define _DEBUG_PREFETCH_NUM 256
  1236. +static int _debug_prefetch_cnt;
  1237. +static char _debug_prefetch_buf[_DEBUG_PREFETCH_NUM][4] __attribute__((aligned(4)));
  1238. +#endif
  1239. +
  1240. +static inline void gmac_write_reg(unsigned int base, unsigned int offset, unsigned int data, unsigned int bit_mask)
  1241. +{
  1242. + unsigned int reg_val;
  1243. +
  1244. + reg_val = (__raw_readl(base + offset) & (~bit_mask)) | (data & bit_mask);
  1245. + __raw_writel(reg_val, base + offset);
  1246. +}
  1247. +
  1248. +/*----------------------------------------------------------------------
  1249. +* toe_init_free_queue
  1250. +* (1) Initialize the Free Queue Descriptor Base Address & size
  1251. +* Register: TOE_GLOBAL_BASE + 0x0004
  1252. +* (2) Initialize DMA Read/Write pointer for
  1253. +* SW Free Queue and HW Free Queue
  1254. +* (3) Initialize DMA Descriptors for
  1255. +* SW Free Queue and HW Free Queue,
  1256. +*----------------------------------------------------------------------*/
  1257. +static void toe_init_free_queue(struct toe_private *toe)
  1258. +{
  1259. + int i;
  1260. + DMA_RWPTR_T rwptr_reg;
  1261. + void *desc_buf;
  1262. + GMAC_RXDESC_T *sw_desc_ptr;
  1263. + struct sk_buff *skb;
  1264. +
  1265. + desc_buf = dma_alloc_coherent(toe->dev, TOE_SW_FREEQ_DESC_NUM * sizeof(GMAC_RXDESC_T),
  1266. + &toe->sw_freeq_desc_base_dma, GFP_KERNEL);
  1267. + sw_desc_ptr = (GMAC_RXDESC_T *)desc_buf;
  1268. + if (!desc_buf) {
  1269. + dev_err(toe->dev, "%s::DMA ALLOC fail\n", __func__);
  1270. + return;
  1271. + }
  1272. + memset(desc_buf, 0, TOE_SW_FREEQ_DESC_NUM * sizeof(GMAC_RXDESC_T));
  1273. +
  1274. + /* DMA Queue Base & Size */
  1275. + __raw_writel((toe->sw_freeq_desc_base_dma & DMA_Q_BASE_MASK) | TOE_SW_FREEQ_DESC_POWER,
  1276. + toe->global_base + GLOBAL_SW_FREEQ_BASE_SIZE_REG);
  1277. +
  1278. + /* init descriptor base */
  1279. + toe->swfq_desc_base = (unsigned int)desc_buf;
  1280. +
  1281. + /* SW Free Queue Descriptors */
  1282. + for (i = 0; i < TOE_SW_FREEQ_DESC_NUM; i++) {
  1283. + sw_desc_ptr->word0.bits.buffer_size = SW_RX_BUF_SIZE;
  1284. + skb = dev_alloc_skb(SW_RX_BUF_SIZE); /* allocate socket buffer */
  1285. + if (!skb) {
  1286. + dev_err(toe->dev, "%s::skb buffer allocation fail\n", __func__);
  1287. + return;
  1288. + }
  1289. + REG32(skb->data) = (unsigned int)skb;
  1290. + skb_reserve(skb, SKB_RESERVE_BYTES);
  1291. + sw_desc_ptr->word2.buf_adr = dma_map_single(toe->dev, skb->data,
  1292. + SW_RX_BUF_SIZE - SKB_RESERVE_BYTES,
  1293. + DMA_FROM_DEVICE);
  1294. + sw_desc_ptr++;
  1295. + }
  1296. +
  1297. + dma_sync_single_for_device(toe->dev, toe->sw_freeq_desc_base_dma,
  1298. + TOE_SW_FREEQ_DESC_NUM * sizeof(GMAC_RXDESC_T),
  1299. + DMA_TO_DEVICE);
  1300. +
  1301. + /* SW Free Queue Read/Write Pointer */
  1302. + rwptr_reg.bits.wptr = TOE_SW_FREEQ_DESC_NUM - 1;
  1303. + rwptr_reg.bits.rptr = 0;
  1304. + __raw_writel(rwptr_reg.bits32, toe->global_base + GLOBAL_SWFQ_RWPTR_REG);
  1305. +
  1306. + /* DMA Queue Base & Size */
  1307. + __raw_writel(TOE_HW_FREEQ_DESC_POWER,
  1308. + toe->global_base + GLOBAL_HW_FREEQ_BASE_SIZE_REG);
  1309. + rwptr_reg.bits.wptr = TOE_HW_FREEQ_DESC_NUM - 1;
  1310. + rwptr_reg.bits.rptr = 0;
  1311. + __raw_writel(rwptr_reg.bits32, toe->global_base + GLOBAL_HWFQ_RWPTR_REG);
  1312. +}
  1313. +
  1314. +/*----------------------------------------------------------------------
  1315. +* toe_init_swtx_queue
  1316. +* (2) Initialize the GMAC 0/1 SW TXQ Queue Descriptor Base Address & sizeup
  1317. +* GMAC_SW_TX_QUEUE_BASE_REG(0x0050)
  1318. +* (2) Initialize DMA Read/Write pointer for
  1319. +* GMAC 0/1 SW TX Q0-5
  1320. +*----------------------------------------------------------------------*/
  1321. +static void toe_init_swtx_queue(struct net_device *dev)
  1322. +{
  1323. + int i;
  1324. + struct gmac_private *gmac = netdev_priv(dev);
  1325. + struct toe_private *toe = dev->ml_priv;
  1326. + DMA_RWPTR_T rwptr_reg;
  1327. + unsigned int rwptr_addr;
  1328. + void *desc_buf;
  1329. + unsigned int offset;
  1330. +
  1331. + desc_buf = dma_alloc_coherent(toe->dev, TOE_GMAC_SWTXQ_DESC_NUM * TOE_SW_TXQ_NUM * sizeof(GMAC_TXDESC_T),
  1332. + &gmac->swtxq_desc_base_dma, GFP_KERNEL);
  1333. + gmac->swtxq_desc_base = (unsigned int)desc_buf;
  1334. + if (!desc_buf) {
  1335. + dev_err(toe->dev, "%s::DMA ALLOC fail\n", __func__);
  1336. + return;
  1337. + }
  1338. + memset(desc_buf, 0, TOE_GMAC_SWTXQ_DESC_NUM * TOE_SW_TXQ_NUM * sizeof(GMAC_TXDESC_T));
  1339. + dma_sync_single_for_device(toe->dev, gmac->swtxq_desc_base_dma,
  1340. + TOE_GMAC_SWTXQ_DESC_NUM * TOE_SW_TXQ_NUM * sizeof(GMAC_TXDESC_T),
  1341. + DMA_TO_DEVICE);
  1342. + __raw_writel((gmac->swtxq_desc_base_dma & DMA_Q_BASE_MASK) | TOE_GMAC_SWTXQ_DESC_POWER,
  1343. + gmac->dma_base_addr + GMAC_SW_TX_QUEUE_BASE_REG);
  1344. +
  1345. + /* GMAC0 SW TX Q0-Q5 */
  1346. + offset = 0;
  1347. + rwptr_reg.bits.wptr = 0;
  1348. + rwptr_reg.bits.rptr = 0;
  1349. + rwptr_addr = gmac->dma_base_addr + GMAC_SW_TX_QUEUE0_PTR_REG;
  1350. + for (i = 0; i < TOE_SW_TXQ_NUM; i++) {
  1351. + gmac->swtxq[i].rwptr_reg = rwptr_addr;
  1352. + gmac->swtxq[i].desc_base_dma = (unsigned int)gmac->swtxq_desc_base_dma + offset;
  1353. + gmac->swtxq[i].desc_base = (unsigned int)desc_buf + offset;
  1354. + offset += TOE_GMAC_SWTXQ_DESC_NUM * sizeof(GMAC_TXDESC_T);
  1355. + __raw_writel(rwptr_reg.bits32, rwptr_addr);
  1356. + rwptr_addr += 4;
  1357. + }
  1358. +}
  1359. +
  1360. +/*----------------------------------------------------------------------
  1361. +* toe_init_default_queue
  1362. +* (1) Initialize the default 0/1 Queue Header
  1363. +* Register: TOE_DEFAULT_Q0_HDR_BASE (0x60002000)
  1364. +* TOE_DEFAULT_Q1_HDR_BASE (0x60002008)
  1365. +* (2) Initialize Descriptors of Default Queue 0/1
  1366. +*----------------------------------------------------------------------*/
  1367. +static void toe_init_default_queue(struct net_device *dev)
  1368. +{
  1369. + struct gmac_private *gmac = netdev_priv(dev);
  1370. + struct toe_private *toe = dev->ml_priv;
  1371. + volatile NONTOE_QHDR_T *qhdr;
  1372. + GMAC_RXDESC_T *desc_ptr;
  1373. +
  1374. + desc_ptr = dma_alloc_coherent(toe->dev, TOE_DEFAULT_Q_DESC_NUM * sizeof(GMAC_RXDESC_T),
  1375. + &gmac->default_desc_base_dma, GFP_KERNEL);
  1376. + if (!desc_ptr) {
  1377. + dev_err(toe->dev, "%s::DMA ALLOC fail\n", __func__);
  1378. + return;
  1379. + }
  1380. + memset(desc_ptr, 0, TOE_DEFAULT_Q_DESC_NUM * sizeof(GMAC_RXDESC_T));
  1381. + dma_sync_single_for_device(toe->dev, gmac->default_desc_base_dma,
  1382. + TOE_DEFAULT_Q_DESC_NUM * sizeof(GMAC_RXDESC_T),
  1383. + DMA_TO_DEVICE);
  1384. + gmac->default_desc_base = (unsigned int)desc_ptr;
  1385. + qhdr = (volatile NONTOE_QHDR_T *)(toe->global_base + TOE_DEFAULT_Q_HDR_BASE(gmac->port_id));
  1386. + qhdr->word0.base_size = ((unsigned int)gmac->default_desc_base_dma & NONTOE_QHDR0_BASE_MASK) | TOE_DEFAULT_Q_DESC_POWER;
  1387. + qhdr->word1.bits32 = 0;
  1388. + gmac->default_qhdr = (NONTOE_QHDR_T *)qhdr;
  1389. +}
  1390. +
  1391. +/*----------------------------------------------------------------------
  1392. +* toe_init_interrupt_config
  1393. +* Interrupt Select Registers are used to map interrupt to int0 or int1
  1394. +* Int0 and int1 are wired to CPU 0/1 GMAC 0/1
  1395. +* Interrupt Device Inteface data are used to pass device info to
  1396. +* upper device driver or store status/statistics
  1397. +* ISR handler
  1398. +* (1) If status bit ON but masked, the prinf error message (bug issue)
  1399. +* (2) If select bits are for me, handle it, else skip to let
  1400. +* the other ISR handles it.
  1401. +* Notes:
  1402. +* GMACx init routine (for eCOS) or open routine (for Linux)
  1403. +* enable the interrupt bits only which are selected for it.
  1404. +*
  1405. +* Default Setting:
  1406. +* GMAC0 intr bits ------> int0 ----> eth0
  1407. +* GMAC1 intr bits ------> int1 ----> eth1
  1408. +* TOE intr -------------> int0 ----> eth0
  1409. +* Classification Intr --> int0 ----> eth0
  1410. +* Default Q0 -----------> int0 ----> eth0
  1411. +* Default Q1 -----------> int1 ----> eth1
  1412. +*----------------------------------------------------------------------*/
  1413. +static void toe_init_interrupt_config(struct toe_private *toe)
  1414. +{
  1415. + /* clear all status bits */
  1416. + __raw_writel(0xffffffff, toe->global_base + GLOBAL_INTERRUPT_STATUS_0_REG);
  1417. + __raw_writel(0xffffffff, toe->global_base + GLOBAL_INTERRUPT_STATUS_1_REG);
  1418. + __raw_writel(0xffffffff, toe->global_base + GLOBAL_INTERRUPT_STATUS_2_REG);
  1419. + __raw_writel(0xffffffff, toe->global_base + GLOBAL_INTERRUPT_STATUS_3_REG);
  1420. + __raw_writel(0xffffffff, toe->global_base + GLOBAL_INTERRUPT_STATUS_4_REG);
  1421. +
  1422. + /* Init select registers */
  1423. + __raw_writel(0, toe->global_base + GLOBAL_INTERRUPT_SELECT_0_REG);
  1424. + __raw_writel(0, toe->global_base + GLOBAL_INTERRUPT_SELECT_1_REG);
  1425. + __raw_writel(0, toe->global_base + GLOBAL_INTERRUPT_SELECT_2_REG);
  1426. + __raw_writel(0, toe->global_base + GLOBAL_INTERRUPT_SELECT_3_REG);
  1427. + __raw_writel(0, toe->global_base + GLOBAL_INTERRUPT_SELECT_4_REG);
  1428. +
  1429. + /* disable all interrupt */
  1430. + __raw_writel(0, toe->global_base + GLOBAL_INTERRUPT_ENABLE_0_REG);
  1431. + __raw_writel(0, toe->global_base + GLOBAL_INTERRUPT_ENABLE_1_REG);
  1432. + __raw_writel(0, toe->global_base + GLOBAL_INTERRUPT_ENABLE_2_REG);
  1433. + __raw_writel(0, toe->global_base + GLOBAL_INTERRUPT_ENABLE_3_REG);
  1434. + __raw_writel(0, toe->global_base + GLOBAL_INTERRUPT_ENABLE_4_REG);
  1435. +}
  1436. +
  1437. +static void toe_gmac_hw_start(struct gmac_private *gmac)
  1438. +{
  1439. + GMAC_DMA_CTRL_T dma_ctrl;
  1440. +
  1441. + /* program dma control register */
  1442. + dma_ctrl.bits32 = __raw_readl(gmac->dma_base_addr + GMAC_DMA_CTRL_REG);
  1443. + dma_ctrl.bits.rd_enable = 1;
  1444. + dma_ctrl.bits.td_enable = 1;
  1445. + dma_ctrl.bits.loopback = 0;
  1446. + dma_ctrl.bits.drop_small_ack = 0;
  1447. + dma_ctrl.bits.rd_prot = 0;
  1448. + dma_ctrl.bits.rd_burst_size = 3;
  1449. + dma_ctrl.bits.rd_insert_bytes = RX_INSERT_BYTES;
  1450. + dma_ctrl.bits.rd_bus = 3;
  1451. + dma_ctrl.bits.td_prot = 0;
  1452. + dma_ctrl.bits.td_burst_size = 3;
  1453. + dma_ctrl.bits.td_bus = 3;
  1454. +
  1455. + __raw_writel(dma_ctrl.bits32, gmac->dma_base_addr + GMAC_DMA_CTRL_REG);
  1456. +}
  1457. +
  1458. +static void toe_gmac_hw_stop(struct gmac_private *gmac)
  1459. +{
  1460. + GMAC_DMA_CTRL_T dma_ctrl;
  1461. +
  1462. + /* program dma control register */
  1463. + dma_ctrl.bits32 = __raw_readl(gmac->dma_base_addr + GMAC_DMA_CTRL_REG);
  1464. + dma_ctrl.bits.rd_enable = 0;
  1465. + dma_ctrl.bits.td_enable = 0;
  1466. + __raw_writel(dma_ctrl.bits32, gmac->dma_base_addr + GMAC_DMA_CTRL_REG);
  1467. +}
  1468. +
  1469. +static void toe_gmac_init_chip(struct net_device *dev)
  1470. +{
  1471. + struct gmac_private *gmac = netdev_priv(dev);
  1472. + GMAC_CONFIG2_T config2_val;
  1473. + GMAC_CONFIG0_T config0;
  1474. + GMAC_CONFIG1_T config1;
  1475. + GMAC_STATUS_T status;
  1476. + GMAC_TX_WCR0_T hw_weigh;
  1477. + GMAC_TX_WCR1_T sw_weigh;
  1478. + GMAC_RX_FLTR_T rx_filter;
  1479. +
  1480. + /* set RX_FLTR register to receive all multicast packet */
  1481. + rx_filter.bits32 = __raw_readl(dev->base_addr + GMAC_RX_FLTR);
  1482. + rx_filter.bits.unicast = 1;
  1483. + rx_filter.bits.multicast = 1;
  1484. + rx_filter.bits.broadcast = 1;
  1485. + __raw_writel(rx_filter.bits32, dev->base_addr + GMAC_RX_FLTR);
  1486. +
  1487. + /* set flow control threshold */
  1488. + config1.bits32 = 0;
  1489. + config1.bits.set_threshold = 32 / 2;
  1490. + config1.bits.rel_threshold = 32 / 4 * 3;
  1491. + __raw_writel(config1.bits32, dev->base_addr + GMAC_CONFIG1);
  1492. +
  1493. + /* set flow control threshold */
  1494. + config2_val.bits32 = 0;
  1495. + config2_val.bits.set_threshold = TOE_SW_FREEQ_DESC_NUM / 4;
  1496. + config2_val.bits.rel_threshold = TOE_SW_FREEQ_DESC_NUM / 2;
  1497. + __raw_writel(config2_val.bits32, dev->base_addr + GMAC_CONFIG2);
  1498. +
  1499. + /* disable TX/RX and disable internal loop back */
  1500. + config0.bits32 = __raw_readl(dev->base_addr + GMAC_CONFIG0);
  1501. +
  1502. + config0.bits.max_len = 2;
  1503. +
  1504. + gmac->flow_control_enable = 0;
  1505. +
  1506. + config0.bits.tx_fc_en = 0; /* disable tx flow control */
  1507. + config0.bits.rx_fc_en = 0; /* disable rx flow control */
  1508. + config0.bits.dis_rx = 1; /* disable rx */
  1509. + config0.bits.dis_tx = 1; /* disable tx */
  1510. + config0.bits.loop_back = 0; /* enable/disable GMAC loopback */
  1511. + config0.bits.rx_err_detect = 1;
  1512. + config0.bits.rgmii_en = 0;
  1513. + config0.bits.rgmm_edge = 1;
  1514. + config0.bits.rxc_inv = 0;
  1515. + config0.bits.ipv4_rx_chksum = 1; /* enable H/W to check ip checksum */
  1516. + config0.bits.ipv6_rx_chksum = 1; /* enable H/W to check ip checksum */
  1517. + config0.bits.port0_chk_hwq = 1;
  1518. + config0.bits.port1_chk_hwq = 1;
  1519. + config0.bits.port0_chk_toeq = 1;
  1520. + config0.bits.port1_chk_toeq = 1;
  1521. + config0.bits.port0_chk_classq = 1;
  1522. + config0.bits.port1_chk_classq = 1;
  1523. +
  1524. + __raw_writel(config0.bits32, dev->base_addr + GMAC_CONFIG0);
  1525. +
  1526. + hw_weigh.bits32 = 0;
  1527. + hw_weigh.bits.hw_tq3 = 1;
  1528. + hw_weigh.bits.hw_tq2 = 1;
  1529. + hw_weigh.bits.hw_tq1 = 1;
  1530. + hw_weigh.bits.hw_tq0 = 1;
  1531. + __raw_writel(hw_weigh.bits32, gmac->dma_base_addr + GMAC_TX_WEIGHTING_CTRL_0_REG);
  1532. +
  1533. + sw_weigh.bits32 = 0;
  1534. + sw_weigh.bits.sw_tq5 = 1;
  1535. + sw_weigh.bits.sw_tq4 = 1;
  1536. + sw_weigh.bits.sw_tq3 = 1;
  1537. + sw_weigh.bits.sw_tq2 = 1;
  1538. + sw_weigh.bits.sw_tq1 = 1;
  1539. + sw_weigh.bits.sw_tq0 = 1;
  1540. + __raw_writel(sw_weigh.bits32, gmac->dma_base_addr + GMAC_TX_WEIGHTING_CTRL_1_REG);
  1541. +
  1542. + /* set interface type */
  1543. + status.bits32 = __raw_readl(dev->base_addr + GMAC_STATUS);
  1544. +
  1545. + switch (gmac->phydev->interface) {
  1546. + case PHY_INTERFACE_MODE_MII:
  1547. + status.bits.mii_rmii = GMAC_PHY_MII;
  1548. + break;
  1549. + case PHY_INTERFACE_MODE_GMII:
  1550. + status.bits.mii_rmii = GMAC_PHY_GMII;
  1551. + break;
  1552. + case PHY_INTERFACE_MODE_RGMII:
  1553. + status.bits.mii_rmii = GMAC_PHY_RGMII_100_10;
  1554. + break;
  1555. + default:
  1556. + dev_err(&dev->dev, "Unsupported MII interface\n");
  1557. + return;
  1558. + }
  1559. +
  1560. + __raw_writel(status.bits32, dev->base_addr + GMAC_STATUS);
  1561. +}
  1562. +
  1563. +static void toe_init_gmac(struct net_device *dev)
  1564. +{
  1565. + struct gmac_private *gmac = netdev_priv(dev);
  1566. + struct toe_private *toe = dev->ml_priv;
  1567. + u32 data;
  1568. +
  1569. + /* GMAC initialization */
  1570. + toe_gmac_init_chip(dev);
  1571. +
  1572. + /* -----------------------------------------------------------
  1573. + Enable GMAC interrupt & disable loopback
  1574. + Notes:
  1575. + GMACx init routine (for eCOS) or open routine (for Linux)
  1576. + enable the interrupt bits only which are selected for him.
  1577. + --------------------------------------------------------------*/
  1578. +
  1579. + /* Enable Interrupt Bits */
  1580. + if (gmac->port_id == 0) {
  1581. + gmac->intr0_selected = GMAC0_TXDERR_INT_BIT | GMAC0_TXPERR_INT_BIT |
  1582. + GMAC0_RXDERR_INT_BIT | GMAC0_RXPERR_INT_BIT |
  1583. + GMAC0_SWTQ05_FIN_INT_BIT | GMAC0_SWTQ05_EOF_INT_BIT |
  1584. + GMAC0_SWTQ04_FIN_INT_BIT | GMAC0_SWTQ04_EOF_INT_BIT |
  1585. + GMAC0_SWTQ03_FIN_INT_BIT | GMAC0_SWTQ03_EOF_INT_BIT |
  1586. + GMAC0_SWTQ02_FIN_INT_BIT | GMAC0_SWTQ02_EOF_INT_BIT |
  1587. + GMAC0_SWTQ01_FIN_INT_BIT | GMAC0_SWTQ01_EOF_INT_BIT |
  1588. + GMAC0_SWTQ00_FIN_INT_BIT | GMAC0_SWTQ00_EOF_INT_BIT;
  1589. +
  1590. +#ifdef GMAX_TX_INTR_DISABLED
  1591. + gmac->intr0_enabled = 0;
  1592. +#else
  1593. + gmac->intr0_enabled = GMAC0_SWTQ00_FIN_INT_BIT | GMAC0_SWTQ00_EOF_INT_BIT;
  1594. +#endif
  1595. +
  1596. + gmac->intr1_selected = TOE_IQ_ALL_BITS | TOE_CLASS_RX_INT_BITS |
  1597. + GMAC0_HWTQ03_EOF_INT_BIT | GMAC0_HWTQ02_EOF_INT_BIT |
  1598. + GMAC0_HWTQ01_EOF_INT_BIT | GMAC0_HWTQ00_EOF_INT_BIT |
  1599. + DEFAULT_Q0_INT_BIT;
  1600. + gmac->intr1_enabled = DEFAULT_Q0_INT_BIT | TOE_IQ_ALL_BITS;
  1601. + gmac->intr2_selected = 0xffffffff; /* TOE Queue 32-63 FUUL Intr */
  1602. + gmac->intr2_enabled = 0xffffffff;
  1603. + gmac->intr3_selected = 0xffffffff; /* TOE Queue 0-31 FUUL Intr */
  1604. + gmac->intr3_enabled = 0xffffffff;
  1605. + gmac->intr4_selected = GMAC0_INT_BITS | CLASS_RX_FULL_INT_BITS |
  1606. + HWFQ_EMPTY_INT_BIT | SWFQ_EMPTY_INT_BIT;
  1607. + gmac->intr4_enabled = GMAC0_INT_BITS | SWFQ_EMPTY_INT_BIT;
  1608. +
  1609. + data = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_SELECT_0_REG) & ~gmac->intr0_selected;
  1610. + __raw_writel(data, toe->global_base + GLOBAL_INTERRUPT_SELECT_0_REG);
  1611. + data = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_SELECT_1_REG) & ~gmac->intr1_selected;
  1612. + __raw_writel(data, toe->global_base + GLOBAL_INTERRUPT_SELECT_1_REG);
  1613. + data = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_SELECT_2_REG) & ~gmac->intr2_selected;
  1614. + __raw_writel(data, toe->global_base + GLOBAL_INTERRUPT_SELECT_2_REG);
  1615. + data = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_SELECT_3_REG) & ~gmac->intr3_selected;
  1616. + __raw_writel(data, toe->global_base + GLOBAL_INTERRUPT_SELECT_3_REG);
  1617. + data = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_SELECT_4_REG) & ~gmac->intr4_selected;
  1618. + __raw_writel(data, toe->global_base + GLOBAL_INTERRUPT_SELECT_4_REG);
  1619. + } else {
  1620. + gmac->intr0_selected = GMAC1_TXDERR_INT_BIT | GMAC1_TXPERR_INT_BIT |
  1621. + GMAC1_RXDERR_INT_BIT | GMAC1_RXPERR_INT_BIT |
  1622. + GMAC1_SWTQ15_FIN_INT_BIT | GMAC1_SWTQ15_EOF_INT_BIT |
  1623. + GMAC1_SWTQ14_FIN_INT_BIT | GMAC1_SWTQ14_EOF_INT_BIT |
  1624. + GMAC1_SWTQ13_FIN_INT_BIT | GMAC1_SWTQ13_EOF_INT_BIT |
  1625. + GMAC1_SWTQ12_FIN_INT_BIT | GMAC1_SWTQ12_EOF_INT_BIT |
  1626. + GMAC1_SWTQ11_FIN_INT_BIT | GMAC1_SWTQ11_EOF_INT_BIT |
  1627. + GMAC1_SWTQ10_FIN_INT_BIT | GMAC1_SWTQ10_EOF_INT_BIT;
  1628. +#ifdef GMAX_TX_INTR_DISABLED
  1629. + gmac->intr0_enabled = 0;
  1630. +#else
  1631. + gmac->intr0_enabled = GMAC1_SWTQ10_FIN_INT_BIT | GMAC1_SWTQ10_EOF_INT_BIT;
  1632. +#endif
  1633. +
  1634. + gmac->intr1_selected = DEFAULT_Q1_INT_BIT;
  1635. + gmac->intr1_enabled = DEFAULT_Q1_INT_BIT | TOE_IQ_ALL_BITS;
  1636. + gmac->intr2_selected = 0; /* TOE Queue 32-63 FUUL Intr */
  1637. + gmac->intr2_enabled = 0;
  1638. + gmac->intr3_selected = 0; /* TOE Queue 0-31 FUUL Intr */
  1639. + gmac->intr3_enabled = 0;
  1640. + gmac->intr4_selected = GMAC1_INT_BITS;
  1641. + gmac->intr4_enabled = GMAC1_INT_BITS;
  1642. +
  1643. + data = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_SELECT_0_REG) | gmac->intr0_selected;
  1644. + __raw_writel(data, toe->global_base + GLOBAL_INTERRUPT_SELECT_0_REG);
  1645. + data = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_SELECT_1_REG) | gmac->intr1_selected;
  1646. + __raw_writel(data, toe->global_base + GLOBAL_INTERRUPT_SELECT_1_REG);
  1647. + data = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_SELECT_2_REG) | gmac->intr2_selected;
  1648. + __raw_writel(data, toe->global_base + GLOBAL_INTERRUPT_SELECT_2_REG);
  1649. + data = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_SELECT_3_REG) | gmac->intr3_selected;
  1650. + __raw_writel(data, toe->global_base + GLOBAL_INTERRUPT_SELECT_3_REG);
  1651. + data = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_SELECT_4_REG) | gmac->intr4_selected;
  1652. + __raw_writel(data, toe->global_base + GLOBAL_INTERRUPT_SELECT_4_REG);
  1653. + }
  1654. +
  1655. + /* enable only selected bits */
  1656. + gmac_write_reg(toe->global_base, GLOBAL_INTERRUPT_ENABLE_0_REG,
  1657. + gmac->intr0_enabled, gmac->intr0_selected);
  1658. + gmac_write_reg(toe->global_base, GLOBAL_INTERRUPT_ENABLE_1_REG,
  1659. + gmac->intr1_enabled, gmac->intr1_selected);
  1660. + gmac_write_reg(toe->global_base, GLOBAL_INTERRUPT_ENABLE_2_REG,
  1661. + gmac->intr2_enabled, gmac->intr2_selected);
  1662. + gmac_write_reg(toe->global_base, GLOBAL_INTERRUPT_ENABLE_3_REG,
  1663. + gmac->intr3_enabled, gmac->intr3_selected);
  1664. + gmac_write_reg(toe->global_base, GLOBAL_INTERRUPT_ENABLE_4_REG,
  1665. + gmac->intr4_enabled, gmac->intr4_selected);
  1666. +
  1667. + /* start DMA process */
  1668. + toe_gmac_hw_start(gmac);
  1669. +}
  1670. +
  1671. +static void toe_gmac_enable_tx_rx(struct net_device *dev)
  1672. +{
  1673. + GMAC_CONFIG0_T config0;
  1674. +
  1675. + /* enable TX/RX */
  1676. + config0.bits32 = __raw_readl(dev->base_addr + GMAC_CONFIG0);
  1677. + config0.bits.dis_rx = 0; /* enable rx */
  1678. + config0.bits.dis_tx = 0; /* enable tx */
  1679. + __raw_writel(config0.bits32, dev->base_addr + GMAC_CONFIG0);
  1680. +}
  1681. +
  1682. +static void toe_gmac_disable_tx_rx(struct net_device *dev)
  1683. +{
  1684. + GMAC_CONFIG0_T config0;
  1685. +
  1686. + /* enable TX/RX */
  1687. + config0.bits32 = __raw_readl(dev->base_addr + GMAC_CONFIG0);
  1688. + config0.bits.dis_rx = 1; /* disable rx */
  1689. + config0.bits.dis_tx = 1; /* disable tx */
  1690. + __raw_writel(config0.bits32, dev->base_addr + GMAC_CONFIG0);
  1691. +}
  1692. +
  1693. +static void toe_gmac_tx_complete(struct net_device *dev, unsigned int tx_qid)
  1694. +{
  1695. + struct gmac_private *gmac = netdev_priv(dev);
  1696. + struct toe_private *toe = dev->ml_priv;
  1697. + GMAC_TXDESC_T *curr_desc;
  1698. + GMAC_TXDESC_0_T word0;
  1699. + GMAC_TXDESC_1_T word1;
  1700. + unsigned int desc_count;
  1701. + GMAC_SWTXQ_T *swtxq;
  1702. + DMA_RWPTR_T rwptr;
  1703. +
  1704. + /* get tx H/W completed descriptor virtual address */
  1705. + /* check tx status and accumulate tx statistics */
  1706. + swtxq = &gmac->swtxq[tx_qid];
  1707. + for (;;) {
  1708. + rwptr.bits32 = __raw_readl(swtxq->rwptr_reg);
  1709. + if (rwptr.bits.rptr == swtxq->finished_idx)
  1710. + break;
  1711. + curr_desc = (GMAC_TXDESC_T *)swtxq->desc_base + swtxq->finished_idx;
  1712. + dma_sync_single_range_for_device(toe->dev, swtxq->desc_base_dma,
  1713. + swtxq->finished_idx * sizeof(GMAC_TXDESC_T),
  1714. + sizeof(GMAC_TXDESC_T),
  1715. + DMA_FROM_DEVICE);
  1716. + word0.bits32 = curr_desc->word0.bits32;
  1717. + word1.bits32 = curr_desc->word1.bits32;
  1718. +
  1719. + if (word0.bits.status_tx_ok) {
  1720. + dev->stats.tx_bytes += word1.bits.byte_count;
  1721. + desc_count = word0.bits.desc_count;
  1722. + if (desc_count == 0) {
  1723. + dev_err(&dev->dev, "%s::Desc 0x%x = 0x%x, desc_count=%d\n", __func__, (u32)curr_desc, word0.bits32, desc_count);
  1724. + BUG();
  1725. + }
  1726. + while (--desc_count) {
  1727. + word0.bits.status_tx_ok = 0;
  1728. + curr_desc->word0.bits32 = word0.bits32;
  1729. + dma_sync_single_range_for_device(toe->dev, swtxq->desc_base_dma,
  1730. + swtxq->finished_idx * sizeof(GMAC_TXDESC_T),
  1731. + sizeof(GMAC_TXDESC_T),
  1732. + DMA_TO_DEVICE);
  1733. + swtxq->finished_idx = RWPTR_ADVANCE_ONE(swtxq->finished_idx, TOE_GMAC_SWTXQ_DESC_NUM);
  1734. + curr_desc = (GMAC_TXDESC_T *)swtxq->desc_base + swtxq->finished_idx;
  1735. + dma_sync_single_range_for_device(toe->dev, swtxq->desc_base_dma,
  1736. + swtxq->finished_idx * sizeof(GMAC_TXDESC_T),
  1737. + sizeof(GMAC_TXDESC_T),
  1738. + DMA_FROM_DEVICE);
  1739. + word0.bits32 = curr_desc->word0.bits32;
  1740. + }
  1741. +
  1742. + word0.bits.status_tx_ok = 0;
  1743. + dev_kfree_skb_any(swtxq->tx_skb[swtxq->finished_idx]);
  1744. + swtxq->tx_skb[swtxq->finished_idx] = NULL;
  1745. +
  1746. + curr_desc->word0.bits32 = word0.bits32;
  1747. + dma_sync_single_range_for_device(toe->dev, swtxq->desc_base_dma,
  1748. + swtxq->finished_idx * sizeof(GMAC_TXDESC_T),
  1749. + sizeof(GMAC_TXDESC_T),
  1750. + DMA_TO_DEVICE);
  1751. + dev->stats.tx_packets++;
  1752. + swtxq->finished_idx = RWPTR_ADVANCE_ONE(swtxq->finished_idx, TOE_GMAC_SWTXQ_DESC_NUM);
  1753. + } else {
  1754. + break;
  1755. + }
  1756. + }
  1757. +
  1758. + if (netif_queue_stopped(dev))
  1759. + netif_wake_queue(dev);
  1760. +}
  1761. +
  1762. +static int gmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
  1763. +{
  1764. + struct gmac_private *gmac = netdev_priv(dev);
  1765. + struct toe_private *toe = dev->ml_priv;
  1766. + DMA_RWPTR_T rwptr;
  1767. + GMAC_TXDESC_T *curr_desc;
  1768. + int snd_pages = skb_shinfo(skb)->nr_frags + 1; /* get number of descriptor */
  1769. + int frag_id = 0;
  1770. + int len, total_len = skb->len;
  1771. + struct net_device_stats *isPtr = &dev->stats;
  1772. + unsigned int free_desc;
  1773. + GMAC_SWTXQ_T *swtxq;
  1774. + register unsigned long word0, word1, word2, word3;
  1775. + unsigned short wptr, rptr;
  1776. +
  1777. +#ifdef GMAC_LEN_1_2_ISSUE
  1778. + int total_pages;
  1779. + total_pages = snd_pages;
  1780. +#endif
  1781. +
  1782. + if (skb->len >= 0x10000) {
  1783. + isPtr->tx_dropped++;
  1784. + dev_err(&dev->dev, "%s::skb->len %d >= 64K\n", __func__, skb->len);
  1785. + netif_stop_queue(dev);
  1786. + return 1;
  1787. + }
  1788. +
  1789. +#ifdef GMAC_USE_TXQ0
  1790. + #define tx_qid 0
  1791. +#endif
  1792. +
  1793. + swtxq = &gmac->swtxq[tx_qid];
  1794. +
  1795. + rwptr.bits32 = __raw_readl(swtxq->rwptr_reg);
  1796. + wptr = rwptr.bits.wptr;
  1797. + rptr = rwptr.bits.rptr;
  1798. +
  1799. + /*
  1800. + * check finished desc or empty BD
  1801. + * cannot check by read ptr of RW PTR register,
  1802. + * because the HW complete to send but the SW may NOT handle it
  1803. + */
  1804. +#ifdef GMAX_TX_INTR_DISABLED
  1805. + toe_gmac_tx_complete(dev, tx_qid);
  1806. +#endif
  1807. + if (wptr >= swtxq->finished_idx)
  1808. + free_desc = TOE_GMAC_SWTXQ_DESC_NUM - wptr + swtxq->finished_idx;
  1809. + else
  1810. + free_desc = swtxq->finished_idx - wptr;
  1811. +
  1812. + if (free_desc < snd_pages) {
  1813. + isPtr->tx_dropped++;
  1814. + netif_stop_queue(dev);
  1815. + return 1;
  1816. + }
  1817. +
  1818. + while (snd_pages) {
  1819. + char *pkt_datap;
  1820. +
  1821. + curr_desc = (GMAC_TXDESC_T *)swtxq->desc_base + wptr;
  1822. + if (frag_id == 0) {
  1823. + len = skb_headlen(skb);
  1824. + pkt_datap = dma_map_single(toe->dev, skb->data, len, DMA_TO_DEVICE);
  1825. + } else {
  1826. + skb_frag_t *frag = &skb_shinfo(skb)->frags[frag_id - 1];
  1827. + len = frag->size;
  1828. + pkt_datap = dma_map_page(toe->dev, frag->page, frag->page_offset, len, DMA_TO_DEVICE);
  1829. + }
  1830. +
  1831. + /* set TX descriptor */
  1832. + word0 = len;
  1833. + word3 = (dev->mtu + 14) | EOFIE_BIT;
  1834. +
  1835. +#ifdef DO_HW_CHKSUM
  1836. + if (total_len <= 1514 && ip_hdr(skb) && (ip_hdr(skb)->frag_off & __constant_htons(0x3fff)))
  1837. + word1 = total_len |
  1838. + TSS_IP_CHKSUM_BIT |
  1839. + TSS_IPV6_ENABLE_BIT |
  1840. + TSS_MTU_ENABLE_BIT;
  1841. + else
  1842. + word1 = total_len |
  1843. + TSS_UDP_CHKSUM_BIT |
  1844. + TSS_TCP_CHKSUM_BIT |
  1845. + TSS_IP_CHKSUM_BIT |
  1846. + TSS_IPV6_ENABLE_BIT |
  1847. + TSS_MTU_ENABLE_BIT;
  1848. +#else
  1849. + word1 = total_len | TSS_MTU_ENABLE_BIT;
  1850. +#endif
  1851. + word2 = pkt_datap;
  1852. +
  1853. + if (frag_id == 0)
  1854. + word3 |= SOF_BIT;
  1855. +
  1856. + if (snd_pages == 1) {
  1857. + word3 |= EOF_BIT;
  1858. + swtxq->tx_skb[wptr] = skb;
  1859. + } else
  1860. + swtxq->tx_skb[wptr] = NULL;
  1861. +
  1862. +#ifdef GMAC_LEN_1_2_ISSUE
  1863. + if ((total_pages != snd_pages) && (len == 1 || len == 2) && ((u32)pkt_datap & 0x03)) {
  1864. + memcpy((void *)&_debug_prefetch_buf[_debug_prefetch_cnt][0], pkt_datap, len);
  1865. + pkt_datap = (char *)&_debug_prefetch_buf[_debug_prefetch_cnt][0];
  1866. + word2 = (unsigned long)__pa(pkt_datap);
  1867. + _debug_prefetch_cnt++;
  1868. + if (_debug_prefetch_cnt >= _DEBUG_PREFETCH_NUM)
  1869. + _debug_prefetch_cnt = 0;
  1870. + }
  1871. +#endif
  1872. + curr_desc->word0.bits32 = word0;
  1873. + curr_desc->word1.bits32 = word1;
  1874. + curr_desc->word2.bits32 = word2;
  1875. + curr_desc->word3.bits32 = word3;
  1876. + free_desc--;
  1877. + dma_sync_single_range_for_device(toe->dev, swtxq->desc_base_dma,
  1878. + wptr * sizeof(GMAC_TXDESC_T),
  1879. + sizeof(GMAC_TXDESC_T),
  1880. + DMA_TO_DEVICE);
  1881. + wptr = RWPTR_ADVANCE_ONE(wptr, TOE_GMAC_SWTXQ_DESC_NUM);
  1882. + frag_id++;
  1883. + snd_pages--;
  1884. + }
  1885. +
  1886. + SET_WPTR(swtxq->rwptr_reg, wptr);
  1887. + dev->trans_start = jiffies;
  1888. +
  1889. + return 0;
  1890. +}
  1891. +
  1892. +static void __gmac_set_mac_address(struct net_device *dev)
  1893. +{
  1894. + unsigned int reg_val;
  1895. +
  1896. + reg_val = dev->dev_addr[0] + (dev->dev_addr[1] << 8) +
  1897. + (dev->dev_addr[2] << 16) + (dev->dev_addr[3] << 24);
  1898. + __raw_writel(reg_val, dev->base_addr + GMAC_STA_ADD0);
  1899. + reg_val = (__raw_readl(dev->base_addr + GMAC_STA_ADD1) & 0xFFFF0000) +
  1900. + dev->dev_addr[4] + (dev->dev_addr[5] << 8);
  1901. + __raw_writel(reg_val, dev->base_addr + GMAC_STA_ADD1);
  1902. +}
  1903. +
  1904. +static int gmac_set_mac_address(struct net_device *dev, void *addr)
  1905. +{
  1906. + struct sockaddr *sa = addr;
  1907. +
  1908. + memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);
  1909. +
  1910. + __gmac_set_mac_address(dev);
  1911. +
  1912. + return 0;
  1913. +}
  1914. +
  1915. +static void gmac_get_mac_address(struct net_device *dev)
  1916. +{
  1917. + unsigned int reg_val;
  1918. +
  1919. + reg_val = __raw_readl(dev->base_addr + GMAC_STA_ADD0);
  1920. + dev->dev_addr[0] = reg_val & 0xFF;
  1921. + dev->dev_addr[1] = (reg_val >> 8) & 0xFF;
  1922. + dev->dev_addr[2] = (reg_val >> 16) & 0xFF;
  1923. + dev->dev_addr[3] = (reg_val >> 24) & 0xFF;
  1924. + reg_val = __raw_readl(dev->base_addr + GMAC_STA_ADD1);
  1925. + dev->dev_addr[4] = reg_val & 0xFF;
  1926. + dev->dev_addr[5] = (reg_val >> 8) & 0xFF;
  1927. +
  1928. + if (!is_valid_ether_addr(dev->dev_addr)) {
  1929. + random_ether_addr(dev->dev_addr);
  1930. + __gmac_set_mac_address(dev);
  1931. + }
  1932. +}
  1933. +
  1934. +struct net_device_stats *gmac_get_stats(struct net_device *dev)
  1935. +{
  1936. + if (netif_running(dev)) {
  1937. + unsigned short multicast;
  1938. +
  1939. + multicast = __raw_readw(dev->base_addr + GMAC_IN_MCAST) +
  1940. + __raw_readw(dev->base_addr + GMAC_IN_BCAST);
  1941. +
  1942. + dev->stats.rx_dropped += __raw_readw(dev->base_addr + GMAC_IN_DISCARDS);
  1943. + dev->stats.rx_errors += __raw_readw(dev->base_addr + GMAC_IN_ERRORS);
  1944. + dev->stats.rx_packets += __raw_readl(dev->base_addr + GMAC_IN_MAC1) + multicast;
  1945. + dev->stats.multicast += multicast;
  1946. + }
  1947. +
  1948. + return &dev->stats;
  1949. +}
  1950. +
  1951. +/* TODO: If possible use crc32 from kernel lib */
  1952. +static unsigned const ethernet_polynomial = 0x04c11db7U;
  1953. +static unsigned int ether_crc(int length, unsigned char *data)
  1954. +{
  1955. + int crc = -1;
  1956. + unsigned int i;
  1957. + unsigned int crc_val = 0;
  1958. +
  1959. + while (--length >= 0) {
  1960. + unsigned char current_octet = *data++;
  1961. + int bit;
  1962. + for (bit = 0; bit < 8; bit++, current_octet >>= 1)
  1963. + crc = (crc << 1) ^ ((crc < 0) ^ (current_octet & 1) ?
  1964. + ethernet_polynomial : 0);
  1965. + }
  1966. + crc = ~crc;
  1967. + for (i = 0; i < 32; i++)
  1968. + crc_val = crc_val + (((crc << i) & 0x80000000) >> (31 - i));
  1969. +
  1970. + return crc_val;
  1971. +}
  1972. +
  1973. +/*----------------------------------------------------------------------
  1974. +* toe_gmac_fill_free_q
  1975. +* allocate buffers for free queue.
  1976. +*----------------------------------------------------------------------*/
  1977. +static void toe_gmac_fill_free_q(struct toe_private *toe)
  1978. +{
  1979. + struct sk_buff *skb;
  1980. + DMA_RWPTR_T fq_rwptr;
  1981. + GMAC_RXDESC_T *fq_desc;
  1982. + unsigned long flags;
  1983. +
  1984. + spin_lock_irqsave(&toe->freeq_lock, flags);
  1985. + fq_rwptr.bits32 = __raw_readl(toe->global_base + GLOBAL_SWFQ_RWPTR_REG);
  1986. + while ((unsigned short)RWPTR_ADVANCE_ONE(fq_rwptr.bits.wptr,
  1987. + TOE_SW_FREEQ_DESC_NUM) != fq_rwptr.bits.rptr) {
  1988. + skb = dev_alloc_skb(SW_RX_BUF_SIZE);
  1989. + if (skb == NULL) {
  1990. + dev_err(toe->dev, "%s::skb allocation fail\n", __func__);
  1991. + break;
  1992. + }
  1993. + REG32(skb->data) = (unsigned int)skb;
  1994. + skb_reserve(skb, SKB_RESERVE_BYTES);
  1995. + fq_rwptr.bits.wptr = RWPTR_ADVANCE_ONE(fq_rwptr.bits.wptr,
  1996. + TOE_SW_FREEQ_DESC_NUM);
  1997. + fq_desc = (GMAC_RXDESC_T *)toe->swfq_desc_base + fq_rwptr.bits.wptr;
  1998. + fq_desc->word2.buf_adr = dma_map_single(toe->dev, skb->data,
  1999. + SW_RX_BUF_SIZE - SKB_RESERVE_BYTES,
  2000. + DMA_FROM_DEVICE);
  2001. + dma_sync_single_range_for_device(toe->dev,
  2002. + toe->sw_freeq_desc_base_dma,
  2003. + fq_rwptr.bits.wptr * sizeof(GMAC_RXDESC_T),
  2004. + sizeof(GMAC_RXDESC_T),
  2005. + DMA_TO_DEVICE);
  2006. + SET_WPTR(toe->global_base + GLOBAL_SWFQ_RWPTR_REG, fq_rwptr.bits.wptr);
  2007. + }
  2008. + spin_unlock_irqrestore(&toe->freeq_lock, flags);
  2009. +}
  2010. +
  2011. +static void fill_free_q_worker(struct work_struct *work)
  2012. +{
  2013. + struct toe_private *toe = container_of(work, struct toe_private, freq_work);
  2014. +
  2015. + toe_gmac_fill_free_q(toe);
  2016. +}
  2017. +
  2018. +/*----------------------------------------------------------------------
  2019. +* toe_gmac_handle_default_rxq
  2020. +* (1) Get rx Buffer for default Rx queue
  2021. +* (2) notify or call upper-routine to handle it
  2022. +* (3) get a new buffer and insert it into SW free queue
  2023. +* (4) Note: The SW free queue Read-Write Pointer should be locked when accessing
  2024. +*----------------------------------------------------------------------*/
  2025. +static void toe_gmac_handle_default_rxq(struct net_device *dev)
  2026. +{
  2027. + struct gmac_private *gmac = netdev_priv(dev);
  2028. + struct toe_private *toe = dev->ml_priv;
  2029. + GMAC_RXDESC_T *curr_desc;
  2030. + struct sk_buff *skb;
  2031. + DMA_RWPTR_T rwptr;
  2032. + unsigned int pkt_size;
  2033. + int max_cnt;
  2034. + unsigned int desc_count;
  2035. + unsigned int chksum_status, rx_status;
  2036. + struct net_device_stats *isPtr = &dev->stats;
  2037. +
  2038. + rwptr.bits32 = __raw_readl(&gmac->default_qhdr->word1);
  2039. + max_cnt = DEFAULT_RXQ_MAX_CNT;
  2040. + while ((--max_cnt) && rwptr.bits.rptr != rwptr.bits.wptr) {
  2041. + curr_desc = (GMAC_RXDESC_T *)gmac->default_desc_base + rwptr.bits.rptr;
  2042. + dma_sync_single_range_for_device(toe->dev,
  2043. + gmac->default_desc_base_dma,
  2044. + rwptr.bits.rptr * sizeof(GMAC_RXDESC_T),
  2045. + sizeof(GMAC_RXDESC_T),
  2046. + DMA_FROM_DEVICE);
  2047. + rx_status = curr_desc->word0.bits.status;
  2048. + chksum_status = curr_desc->word0.bits.chksum_status;
  2049. + pkt_size = curr_desc->word1.bits.byte_count; /* total byte count in a frame */
  2050. + desc_count = curr_desc->word0.bits.desc_count; /* get descriptor count per frame */
  2051. + skb = (struct sk_buff *)(REG32(__va(curr_desc->word2.buf_adr) - SKB_RESERVE_BYTES));
  2052. +
  2053. + if ((curr_desc->word0.bits32 & (GMAC_RXDESC_0_T_derr | GMAC_RXDESC_0_T_perr))
  2054. + || (pkt_size < 60) || (chksum_status & 0x4) || rx_status) {
  2055. + if (curr_desc->word0.bits32 & GMAC_RXDESC_0_T_derr)
  2056. + dev_err(&dev->dev, "%s::derr\n", __func__);
  2057. + if (curr_desc->word0.bits32 & GMAC_RXDESC_0_T_perr)
  2058. + dev_err(&dev->dev, "%s::perr\n", __func__);
  2059. + if (rx_status && (rx_status == 4 || rx_status == 7))
  2060. + isPtr->rx_crc_errors++;
  2061. +
  2062. + dev_kfree_skb_irq(skb);
  2063. + goto bad_frame;
  2064. + }
  2065. +
  2066. + if (curr_desc->word0.bits.drop)
  2067. + dev_warn(&dev->dev, "%s::Drop\n", __func__);
  2068. +
  2069. + /* get frame information from the first descriptor of the frame */
  2070. + skb_reserve(skb, RX_INSERT_BYTES); /* 16 byte align the IP fields. */
  2071. + skb_put(skb, pkt_size);
  2072. + skb->dev = dev;
  2073. + skb->protocol = eth_type_trans(skb, dev);
  2074. + if (chksum_status == RX_CHKSUM_IP_UDP_TCP_OK || chksum_status == RX_CHKSUM_IP_OK_ONLY)
  2075. + skb->ip_summed = CHECKSUM_UNNECESSARY;
  2076. +
  2077. + netif_rx(skb); /* socket rx */
  2078. + dev->last_rx = jiffies;
  2079. +
  2080. + isPtr->rx_bytes += pkt_size;
  2081. +
  2082. +bad_frame:
  2083. + /* advance one for Rx default Q 0/1 */
  2084. + rwptr.bits.rptr = RWPTR_ADVANCE_ONE(rwptr.bits.rptr, TOE_DEFAULT_Q_DESC_NUM);
  2085. + SET_RPTR(&gmac->default_qhdr->word1, rwptr.bits.rptr);
  2086. + }
  2087. +
  2088. + schedule_work(&toe->freq_work);
  2089. +}
  2090. +
  2091. +static irqreturn_t toe_gmac_interrupt(int irq, void *dev_instance)
  2092. +{
  2093. + struct net_device *dev = dev_instance;
  2094. + struct gmac_private *gmac = netdev_priv(dev);
  2095. + struct toe_private *toe = dev->ml_priv;
  2096. + unsigned int status0;
  2097. + unsigned int status1;
  2098. + unsigned int status2;
  2099. + unsigned int status3;
  2100. + unsigned int status4;
  2101. + int handled = 0;
  2102. +
  2103. + /* read Interrupt status */
  2104. + status0 = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_STATUS_0_REG);
  2105. + status1 = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_STATUS_1_REG);
  2106. + status2 = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_STATUS_2_REG);
  2107. + status3 = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_STATUS_3_REG);
  2108. + status4 = __raw_readl(toe->global_base + GLOBAL_INTERRUPT_STATUS_4_REG);
  2109. +
  2110. + /* clear interrupts */
  2111. + if (status0)
  2112. + __raw_writel(status0, toe->global_base + GLOBAL_INTERRUPT_STATUS_0_REG);
  2113. + if (status1)
  2114. + __raw_writel(status1, toe->global_base + GLOBAL_INTERRUPT_STATUS_1_REG);
  2115. + if (status2)
  2116. + __raw_writel(status2, toe->global_base + GLOBAL_INTERRUPT_STATUS_2_REG);
  2117. + if (status3)
  2118. + __raw_writel(status3, toe->global_base + GLOBAL_INTERRUPT_STATUS_3_REG);
  2119. + if (status4)
  2120. + __raw_writel(status4, toe->global_base + GLOBAL_INTERRUPT_STATUS_4_REG);
  2121. +
  2122. + /* handle freeq interrupt first */
  2123. + if (status4 & gmac->intr4_enabled) {
  2124. + if ((status4 & SWFQ_EMPTY_INT_BIT) && (gmac->intr4_enabled & SWFQ_EMPTY_INT_BIT)) {
  2125. + toe_gmac_fill_free_q(toe);
  2126. + handled = 1;
  2127. + }
  2128. + }
  2129. +
  2130. + /* Interrupt Status 1 */
  2131. + if (status1 & gmac->intr1_enabled) {
  2132. + /*
  2133. + * Handle GMAC 0/1 HW Tx queue 0-3 EOF events
  2134. + * Only count
  2135. + * TOE, Classification, and default queues interrupts are handled by ISR
  2136. + * because they should pass packets to upper layer
  2137. + */
  2138. + if (gmac->port_id == 0) {
  2139. + if (netif_running(dev) && (status1 & DEFAULT_Q0_INT_BIT) && (gmac->intr1_enabled & DEFAULT_Q0_INT_BIT)) {
  2140. + toe_gmac_handle_default_rxq(dev);
  2141. + handled = 1;
  2142. + }
  2143. + } else if (gmac->port_id == 1) {
  2144. + if (netif_running(dev) && (status1 & DEFAULT_Q1_INT_BIT) && (gmac->intr1_enabled & DEFAULT_Q1_INT_BIT)) {
  2145. + toe_gmac_handle_default_rxq(dev);
  2146. + handled = 1;
  2147. + }
  2148. + }
  2149. + }
  2150. +
  2151. + /* Interrupt Status 0 */
  2152. + if (status0 & gmac->intr0_enabled) {
  2153. +#ifndef GMAX_TX_INTR_DISABLED
  2154. + if (gmac->port_id == 1 && netif_running(dev) &&
  2155. + (((status0 & GMAC1_SWTQ10_FIN_INT_BIT) && (gmac->intr0_enabled & GMAC1_SWTQ10_FIN_INT_BIT))
  2156. + ||
  2157. + ((status0 & GMAC1_SWTQ10_EOF_INT_BIT) && (gmac->intr0_enabled & GMAC1_SWTQ10_EOF_INT_BIT)))) {
  2158. + toe_gmac_tx_complete(dev, 0);
  2159. + handled = 1;
  2160. + }
  2161. +
  2162. + if (gmac->port_id == 0 && netif_running(dev) &&
  2163. + (((status0 & GMAC0_SWTQ00_FIN_INT_BIT) && (gmac->intr0_enabled & GMAC0_SWTQ00_FIN_INT_BIT))
  2164. + ||
  2165. + ((status0 & GMAC0_SWTQ00_EOF_INT_BIT) && (gmac->intr0_enabled & GMAC0_SWTQ00_EOF_INT_BIT)))) {
  2166. + toe_gmac_tx_complete(dev, 0);
  2167. + handled = 1;
  2168. + }
  2169. +#endif
  2170. + }
  2171. +
  2172. + return IRQ_RETVAL(handled);
  2173. +}
  2174. +
  2175. +static int gmac_open(struct net_device *dev)
  2176. +{
  2177. + struct gmac_private *gmac = netdev_priv(dev);
  2178. + int retval;
  2179. +
  2180. + /* hook ISR */
  2181. + retval = request_irq(dev->irq, toe_gmac_interrupt, 0, dev->name, dev);
  2182. + if (retval)
  2183. + return retval;
  2184. +
  2185. + toe_init_gmac(dev);
  2186. +
  2187. + netif_carrier_off(dev);
  2188. + phy_start(gmac->phydev);
  2189. +
  2190. + netif_start_queue(dev);
  2191. +
  2192. + return 0;
  2193. +}
  2194. +
  2195. +static int gmac_close(struct net_device *dev)
  2196. +{
  2197. + struct gmac_private *gmac = netdev_priv(dev);
  2198. +
  2199. + netif_stop_queue(dev);
  2200. + mdelay(20);
  2201. +
  2202. + if (gmac->phydev)
  2203. + phy_stop(gmac->phydev);
  2204. +
  2205. + /* stop tx/rx packet */
  2206. + toe_gmac_disable_tx_rx(dev);
  2207. + mdelay(20);
  2208. +
  2209. + /* stop the chip's Tx and Rx DMA processes */
  2210. + toe_gmac_hw_stop(gmac);
  2211. +
  2212. + disable_irq(dev->irq);
  2213. + free_irq(dev->irq, dev);
  2214. +
  2215. + return 0;
  2216. +}
  2217. +
  2218. +static void gmac_get_phy_status(struct net_device *dev)
  2219. +{
  2220. + struct gmac_private *gmac = netdev_priv(dev);
  2221. + GMAC_CONFIG0_T config0;
  2222. + GMAC_STATUS_T status, old_status;
  2223. + struct phy_device *phydev = gmac->phydev;
  2224. +
  2225. + old_status.bits32 = status.bits32 = __raw_readl(dev->base_addr + GMAC_STATUS);
  2226. +
  2227. + status.bits.link = phydev->link;
  2228. + status.bits.duplex = phydev->duplex;
  2229. +
  2230. + switch (phydev->speed) {
  2231. + case 1000:
  2232. + status.bits.speed = GMAC_SPEED_1000;
  2233. + if (phydev->interface == PHY_INTERFACE_MODE_RGMII)
  2234. + status.bits.mii_rmii = GMAC_PHY_RGMII_1000;
  2235. + break;
  2236. + case 100:
  2237. + status.bits.speed = GMAC_SPEED_100;
  2238. + if (phydev->interface == PHY_INTERFACE_MODE_RGMII)
  2239. + status.bits.mii_rmii = GMAC_PHY_RGMII_100_10;
  2240. + break;
  2241. + case 10:
  2242. + status.bits.speed = GMAC_SPEED_10;
  2243. + if (phydev->interface == PHY_INTERFACE_MODE_RGMII)
  2244. + status.bits.mii_rmii = GMAC_PHY_RGMII_100_10;
  2245. + break;
  2246. + default:
  2247. + dev_warn(&dev->dev, "Not supported PHY speed (%d)\n", phydev->speed);
  2248. + }
  2249. +
  2250. + if (phydev->pause) {
  2251. + if (gmac->flow_control_enable == 0) {
  2252. + config0.bits32 = __raw_readl(dev->base_addr + GMAC_CONFIG0);
  2253. + config0.bits.tx_fc_en = 1; /* enable tx flow control */
  2254. + config0.bits.rx_fc_en = 1; /* enable rx flow control */
  2255. + __raw_writel(config0.bits32, dev->base_addr + GMAC_CONFIG0);
  2256. + dev_info(&dev->dev, "MII flow control enabled\n");
  2257. + }
  2258. + gmac->flow_control_enable = 1;
  2259. + } else {
  2260. + if (gmac->flow_control_enable == 1) {
  2261. + config0.bits32 = __raw_readl(dev->base_addr + GMAC_CONFIG0);
  2262. + config0.bits.tx_fc_en = 0; /* disable tx flow control */
  2263. + config0.bits.rx_fc_en = 0; /* disable rx flow control */
  2264. + __raw_writel(config0.bits32, dev->base_addr + GMAC_CONFIG0);
  2265. + dev_info(&dev->dev, "MII flow control disabled\n");
  2266. + }
  2267. + gmac->flow_control_enable = 0;
  2268. + }
  2269. +
  2270. + if (old_status.bits32 != status.bits32) {
  2271. + toe_gmac_disable_tx_rx(dev);
  2272. + phy_print_status(phydev);
  2273. + mdelay(10); /* let GMAC consume packet */
  2274. + __raw_writel(status.bits32, dev->base_addr + GMAC_STATUS);
  2275. + if (status.bits.link)
  2276. + toe_gmac_enable_tx_rx(dev);
  2277. + }
  2278. +}
  2279. +
  2280. +static void gmac_set_rx_mode(struct net_device *dev)
  2281. +{
  2282. + GMAC_RX_FLTR_T filter;
  2283. + unsigned int mc_filter[2]; /* Multicast hash filter */
  2284. + int bit_nr;
  2285. + unsigned int i;
  2286. +
  2287. + filter.bits32 = 0;
  2288. + filter.bits.error = 0;
  2289. + if (dev->flags & IFF_PROMISC) {
  2290. + filter.bits.error = 1;
  2291. + filter.bits.promiscuous = 1;
  2292. + filter.bits.broadcast = 1;
  2293. + filter.bits.multicast = 1;
  2294. + filter.bits.unicast = 1;
  2295. + mc_filter[1] = mc_filter[0] = 0xffffffff;
  2296. + } else if (dev->flags & IFF_ALLMULTI) {
  2297. + filter.bits.broadcast = 1;
  2298. + filter.bits.multicast = 1;
  2299. + filter.bits.unicast = 1;
  2300. + mc_filter[1] = mc_filter[0] = 0xffffffff;
  2301. + } else {
  2302. + struct dev_mc_list *mclist;
  2303. +
  2304. + filter.bits.broadcast = 1;
  2305. + filter.bits.multicast = 1;
  2306. + filter.bits.unicast = 1;
  2307. + mc_filter[1] = mc_filter[0] = 0;
  2308. + for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count; i++, mclist = mclist->next) {
  2309. + bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3f;
  2310. + if (bit_nr <= 32)
  2311. + mc_filter[0] = mc_filter[0] | (1 << bit_nr);
  2312. + else
  2313. + mc_filter[1] = mc_filter[1] | (1 << (bit_nr - 32));
  2314. + }
  2315. + }
  2316. + __raw_writel(filter.bits32, dev->base_addr + GMAC_RX_FLTR);
  2317. + __raw_writel(mc_filter[0], dev->base_addr + GMAC_MCAST_FIL0);
  2318. + __raw_writel(mc_filter[1], dev->base_addr + GMAC_MCAST_FIL1);
  2319. +}
  2320. +
  2321. +static void gmac_tx_timeout(struct net_device *dev)
  2322. +{
  2323. + if (!netif_queue_stopped(dev))
  2324. + netif_wake_queue(dev);
  2325. +
  2326. + dev_warn(&dev->dev, "TX timeout\n");
  2327. +}
  2328. +
  2329. +const static struct net_device_ops gemini_gmac_ops = {
  2330. + .ndo_open = gmac_open,
  2331. + .ndo_stop = gmac_close,
  2332. + .ndo_start_xmit = gmac_start_xmit,
  2333. + .ndo_get_stats = gmac_get_stats,
  2334. + .ndo_set_multicast_list = gmac_set_rx_mode,
  2335. + .ndo_set_mac_address = gmac_set_mac_address,
  2336. + .ndo_tx_timeout = gmac_tx_timeout,
  2337. +};
  2338. +
  2339. +static void __init mac_init_drv(struct toe_private *toe)
  2340. +{
  2341. + QUEUE_THRESHOLD_T threshold;
  2342. + DMA_SKB_SIZE_T skb_size;
  2343. +
  2344. + /* clear non TOE Queue Header Area */
  2345. + memset(toe->global_base + TOE_NONTOE_QUE_HDR_BASE, 0,
  2346. + NONTOE_Q_HDR_AREA_END - TOE_NONTOE_QUE_HDR_BASE);
  2347. +
  2348. + /* clear TOE Queue Header Area */
  2349. + memset(toe->global_base + TOE_TOE_QUE_HDR_BASE, 0,
  2350. + TOE_Q_HDR_AREA_END - TOE_TOE_QUE_HDR_BASE);
  2351. +
  2352. + /* Write GLOBAL_QUEUE_THRESHOLD_REG */
  2353. + threshold.bits32 = 0;
  2354. + threshold.bits.swfq_empty = (TOE_SW_FREEQ_DESC_NUM > 256) ? 255 :
  2355. + TOE_SW_FREEQ_DESC_NUM / 2;
  2356. + threshold.bits.hwfq_empty = (TOE_HW_FREEQ_DESC_NUM > 256) ? 256 / 4 :
  2357. + TOE_HW_FREEQ_DESC_NUM / 4;
  2358. + threshold.bits.toe_class = (TOE_TOE_DESC_NUM > 256) ? 256 / 4 :
  2359. + TOE_TOE_DESC_NUM / 4;
  2360. + threshold.bits.intrq = (TOE_INTR_DESC_NUM > 256) ? 256 / 4 :
  2361. + TOE_INTR_DESC_NUM / 4;
  2362. + __raw_writel(threshold.bits32, toe->global_base + GLOBAL_QUEUE_THRESHOLD_REG);
  2363. +
  2364. + /* Init skb size */
  2365. + skb_size.bits.hw_skb_size = HW_RX_BUF_SIZE;
  2366. + skb_size.bits.sw_skb_size = SW_RX_BUF_SIZE;
  2367. + __raw_writel(skb_size.bits32, toe->global_base + GLOBAL_DMA_SKB_SIZE_REG);
  2368. +
  2369. + toe_init_free_queue(toe);
  2370. + toe_init_interrupt_config(toe);
  2371. +}
  2372. +
  2373. +static int __init gmac_init_eth(struct platform_device *pdev, unsigned int num)
  2374. +{
  2375. + struct gmac_private *gmac;
  2376. + struct net_device *dev;
  2377. + struct toe_private *toe = platform_get_drvdata(pdev);
  2378. + struct gemini_gmac_platform_data *pdata = pdev->dev.platform_data;
  2379. +
  2380. + if (!pdata->bus_id[num])
  2381. + return 0;
  2382. +
  2383. + dev = alloc_etherdev(sizeof(*gmac));
  2384. + if (dev == NULL) {
  2385. + dev_err(&pdev->dev, "Can't allocate ethernet device #%d\n", num);
  2386. + return -ENOMEM;
  2387. + }
  2388. +
  2389. + gmac = netdev_priv(dev);
  2390. + dev->ml_priv = toe;
  2391. + toe->net_dev[num] = dev;
  2392. +
  2393. + gmac->dma_base_addr = toe->global_base + TOE_GMAC_DMA_BASE(num);
  2394. + gmac->port_id = num;
  2395. +
  2396. + dev->base_addr = toe->global_base + TOE_GMAC_BASE(num);
  2397. + dev->irq = platform_get_irq(pdev, num);
  2398. + dev->netdev_ops = &gemini_gmac_ops;
  2399. + dev->watchdog_timeo = GMAC_DEV_TX_TIMEOUT;
  2400. + dev->tx_queue_len = TOE_GMAC_SWTXQ_DESC_NUM;
  2401. +
  2402. +#ifdef DO_HW_CHKSUM
  2403. + dev->features = NETIF_F_SG | NETIF_F_HW_CSUM;
  2404. +#ifdef ENABLE_TSO
  2405. + dev->features |= NETIF_F_TSO;
  2406. +#endif
  2407. +#endif
  2408. +
  2409. + toe_init_swtx_queue(dev);
  2410. + toe_init_default_queue(dev);
  2411. +
  2412. + gmac_get_mac_address(dev);
  2413. +
  2414. + /* TODO: Do we need this? */
  2415. + __raw_writel(0x55aa55aa, dev->base_addr + GMAC_STA_ADD2);
  2416. +
  2417. + if (register_netdev(dev))
  2418. + return -1;
  2419. +
  2420. + gmac->phydev = phy_connect(dev, pdata->bus_id[num], &gmac_get_phy_status, 0,
  2421. + pdata->interface[num]);
  2422. + if (IS_ERR(gmac->phydev))
  2423. + return PTR_ERR(gmac->phydev);
  2424. +
  2425. + gmac->phydev->supported &= PHY_GBIT_FEATURES | SUPPORTED_Pause;
  2426. + gmac->phydev->advertising = gmac->phydev->supported;
  2427. +
  2428. + return 0;
  2429. +}
  2430. +
  2431. +static int __init gmac_probe(struct platform_device *pdev)
  2432. +{
  2433. + struct resource *res;
  2434. + struct toe_private *toe;
  2435. + int retval;
  2436. +
  2437. + if (!pdev->dev.platform_data)
  2438. + return -EINVAL;
  2439. +
  2440. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  2441. + if (!res) {
  2442. + dev_err(&pdev->dev, "can't get device resources\n");
  2443. + return -ENODEV;
  2444. + }
  2445. +
  2446. + toe = kzalloc(sizeof(struct toe_private), GFP_KERNEL);
  2447. + if (!toe)
  2448. + return -ENOMEM;
  2449. +
  2450. + toe->dev = &pdev->dev;
  2451. +
  2452. + toe->global_base = ioremap(res->start, resource_size(res));
  2453. + if (!toe->global_base) {
  2454. + dev_err(toe->dev, "ioremap failed\n");
  2455. + retval = -EIO;
  2456. + goto err_data;
  2457. + }
  2458. +
  2459. + platform_set_drvdata(pdev, toe);
  2460. +
  2461. + mac_init_drv(toe);
  2462. +
  2463. + INIT_WORK(&toe->freq_work, fill_free_q_worker);
  2464. + spin_lock_init(&toe->freeq_lock);
  2465. +
  2466. + retval = gmac_init_eth(pdev, GMAC_PORT0);
  2467. + if (retval)
  2468. + goto err_unmap;
  2469. + retval = gmac_init_eth(pdev, GMAC_PORT1);
  2470. + if (retval)
  2471. + goto err_unmap;
  2472. +
  2473. + dev_info(&pdev->dev, SL351x_DRIVER_NAME "\n");
  2474. +
  2475. + return 0;
  2476. +
  2477. +err_unmap:
  2478. + iounmap(toe->global_base);
  2479. +err_data:
  2480. + kfree(toe);
  2481. + return retval;
  2482. +}
  2483. +
  2484. +static int __exit gmac_remove(struct platform_device *pdev)
  2485. +{
  2486. + struct toe_private *toe = platform_get_drvdata(pdev);
  2487. + int i;
  2488. +
  2489. + for (i = 0; i < 2; i++)
  2490. + if (toe->net_dev[i]) {
  2491. + unregister_netdev(toe->net_dev[i]);
  2492. + kfree(toe->net_dev[i]);
  2493. + }
  2494. +
  2495. + iounmap(toe->global_base);
  2496. +
  2497. + kfree(toe);
  2498. +
  2499. + return 0;
  2500. +}
  2501. +
  2502. +static struct platform_driver gemini_gmac_driver = {
  2503. + .probe = gmac_probe,
  2504. + .remove = __exit_p(gmac_remove),
  2505. +
  2506. + .driver = {
  2507. + .name = "gemini-gmac",
  2508. + .owner = THIS_MODULE,
  2509. + },
  2510. +};
  2511. +
  2512. +static int __init gemini_gmac_init(void)
  2513. +{
  2514. + return platform_driver_register(&gemini_gmac_driver);
  2515. +}
  2516. +
  2517. +static void __exit gemini_gmac_exit(void)
  2518. +{
  2519. + platform_driver_unregister(&gemini_gmac_driver);
  2520. +}
  2521. +
  2522. +module_init(gemini_gmac_init);
  2523. +module_exit(gemini_gmac_exit);
  2524. +
  2525. +MODULE_AUTHOR("Paulius Zaleckas");
  2526. +MODULE_DESCRIPTION("Ethernet device driver for Gemini SoC");
  2527. +MODULE_LICENSE("GPL");
  2528. +MODULE_ALIAS("platform:gemini-gmac");
  2529. --- /dev/null
  2530. +++ b/drivers/net/gemini_negmac/gm_gmac.h
  2531. @@ -0,0 +1,1488 @@
  2532. +/*
  2533. + * Register definitions for Gemini Ethernet device driver.
  2534. + *
  2535. + * Copyright (C) 2006, Storlink, Corp.
  2536. + * Copyright (C) 2008-2009, Paulius Zaleckas <[email protected]>
  2537. + *
  2538. + * This program is free software; you can redistribute it and/or modify
  2539. + * it under the terms of the GNU General Public License as published by
  2540. + * the Free Software Foundation; either version 2 of the License, or
  2541. + * (at your option) any later version.
  2542. + */
  2543. +#ifndef _GMAC_SL351x_H
  2544. +#define _GMAC_SL351x_H
  2545. +#include <linux/skbuff.h>
  2546. +
  2547. +#define _PACKED_ __attribute__ ((aligned(1), packed))
  2548. +
  2549. +#ifndef BIT
  2550. +#define BIT(x) (1 << (x))
  2551. +#endif
  2552. +
  2553. +#define REG32(addr) (*(volatile unsigned long * const)(addr))
  2554. +
  2555. +/* Define frame size */
  2556. +#define GMAC_MAX_ETH_FRAME_SIZE 1514
  2557. +#define GMAC_TX_BUF_SIZE ((GMAC_MAX_ETH_FRAME_SIZE + 31) & (~31))
  2558. +
  2559. +#define SW_RX_BUF_SIZE 1536
  2560. +#define HW_RX_BUF_SIZE 1536
  2561. +
  2562. +#define GMAC_DEV_TX_TIMEOUT (10*HZ)
  2563. +#define SKB_RESERVE_BYTES 16
  2564. +
  2565. +/*
  2566. + * Base Registers
  2567. + */
  2568. +#define TOE_NONTOE_QUE_HDR_BASE 0x2000
  2569. +#define TOE_TOE_QUE_HDR_BASE 0x3000
  2570. +#define TOE_V_BIT_BASE 0x4000
  2571. +#define TOE_A_BIT_BASE 0x6000
  2572. +#define TOE_GMAC_DMA_BASE(x) (0x8000 + 0x4000 * (x))
  2573. +#define TOE_GMAC_BASE(x) (0xA000 + 0x4000 * (x))
  2574. +
  2575. +/*
  2576. + * Queue ID
  2577. + */
  2578. +#define TOE_SW_FREE_QID 0x00
  2579. +#define TOE_HW_FREE_QID 0x01
  2580. +#define TOE_GMAC0_SW_TXQ0_QID 0x02
  2581. +#define TOE_GMAC0_SW_TXQ1_QID 0x03
  2582. +#define TOE_GMAC0_SW_TXQ2_QID 0x04
  2583. +#define TOE_GMAC0_SW_TXQ3_QID 0x05
  2584. +#define TOE_GMAC0_SW_TXQ4_QID 0x06
  2585. +#define TOE_GMAC0_SW_TXQ5_QID 0x07
  2586. +#define TOE_GMAC0_HW_TXQ0_QID 0x08
  2587. +#define TOE_GMAC0_HW_TXQ1_QID 0x09
  2588. +#define TOE_GMAC0_HW_TXQ2_QID 0x0A
  2589. +#define TOE_GMAC0_HW_TXQ3_QID 0x0B
  2590. +#define TOE_GMAC1_SW_TXQ0_QID 0x12
  2591. +#define TOE_GMAC1_SW_TXQ1_QID 0x13
  2592. +#define TOE_GMAC1_SW_TXQ2_QID 0x14
  2593. +#define TOE_GMAC1_SW_TXQ3_QID 0x15
  2594. +#define TOE_GMAC1_SW_TXQ4_QID 0x16
  2595. +#define TOE_GMAC1_SW_TXQ5_QID 0x17
  2596. +#define TOE_GMAC1_HW_TXQ0_QID 0x18
  2597. +#define TOE_GMAC1_HW_TXQ1_QID 0x19
  2598. +#define TOE_GMAC1_HW_TXQ2_QID 0x1A
  2599. +#define TOE_GMAC1_HW_TXQ3_QID 0x1B
  2600. +#define TOE_GMAC0_DEFAULT_QID 0x20
  2601. +#define TOE_GMAC1_DEFAULT_QID 0x21
  2602. +#define TOE_CLASSIFICATION_QID(x) (0x22 + x) // 0x22 ~ 0x2F
  2603. +#define TOE_TOE_QID(x) (0x40 + x) // 0x40 ~ 0x7F
  2604. +
  2605. +/*
  2606. + * TOE DMA Queue Number should be 2^n, n = 6...12
  2607. + * TOE DMA Queues are the following queue types:
  2608. + * SW Free Queue, HW Free Queue,
  2609. + * GMAC 0/1 SW TX Q0-5, and GMAC 0/1 HW TX Q0-5
  2610. + * They have same descriptor numbers.
  2611. + * The base address and descriptor number are configured at
  2612. + * DMA Queues Descriptor Ring Base Address/Size Register (offset 0x0004)
  2613. + */
  2614. +#define TOE_SW_FREEQ_DESC_POWER 8
  2615. +#define TOE_SW_FREEQ_DESC_NUM (1<<TOE_SW_FREEQ_DESC_POWER)
  2616. +#define TOE_HW_FREEQ_DESC_POWER 8
  2617. +#define TOE_HW_FREEQ_DESC_NUM (1<<TOE_HW_FREEQ_DESC_POWER)
  2618. +#define TOE_GMAC_SWTXQ_DESC_POWER 8
  2619. +#define TOE_GMAC_SWTXQ_DESC_NUM (1<<TOE_GMAC_SWTXQ_DESC_POWER)
  2620. +#define TOE_GMAC_HWTXQ_DESC_POWER 8
  2621. +#define TOE_GMAC_HWTXQ_DESC_NUM (1<<TOE_GMAC_HWTXQ_DESC_POWER)
  2622. +#define TOE_DEFAULT_Q_DESC_POWER 8
  2623. +#define TOE_DEFAULT_Q_DESC_NUM (1<<TOE_DEFAULT_Q_DESC_POWER)
  2624. +#define TOE_TOE_DESC_POWER 8
  2625. +#define TOE_TOE_DESC_NUM (1<<TOE_TOE_DESC_POWER)
  2626. +#define TOE_CLASS_DESC_POWER 8
  2627. +#define TOE_CLASS_DESC_NUM (1<<TOE_CLASS_DESC_POWER)
  2628. +#define TOE_INTR_DESC_POWER 8
  2629. +#define TOE_INTR_DESC_NUM (1<<TOE_INTR_DESC_POWER)
  2630. +
  2631. +#define TOE_TOE_QUEUE_MAX 64
  2632. +#define TOE_TOE_QUEUE_NUM 64
  2633. +#define TOE_CLASS_QUEUE_MAX 14
  2634. +#define TOE_CLASS_QUEUE_NUM 14
  2635. +#define TOE_INTR_QUEUE_MAX 4
  2636. +#define TOE_INTR_QUEUE_NUM 4
  2637. +#define TOE_SW_TXQ_MAX 6
  2638. +#define TOE_SW_TXQ_NUM 1
  2639. +#define TOE_HW_TXQ_MAX 4
  2640. +#define TOE_HW_TXQ_NUM 4
  2641. +
  2642. +#define RWPTR_ADVANCE_ONE(x, max) ((x == (max -1)) ? 0 : x+1)
  2643. +#define RWPTR_RECEDE_ONE(x, max) ((x == 0) ? (max -1) : x-1)
  2644. +#define SET_WPTR(addr, data) (*(volatile u16 * const)((u32)(addr) + 2) = (u16)data)
  2645. +#define SET_RPTR(addr, data) (*(volatile u16 * const)((u32)(addr)) = (u16)data)
  2646. +
  2647. +/*
  2648. + * Global registers
  2649. + * #define TOE_GLOBAL_BASE (TOE_BASE + 0x0000)
  2650. + * Base 0x60000000
  2651. + */
  2652. +#define GLOBAL_TOE_VERSION_REG 0x0000
  2653. +#define GLOBAL_SW_FREEQ_BASE_SIZE_REG 0x0004
  2654. +#define GLOBAL_HW_FREEQ_BASE_SIZE_REG 0x0008
  2655. +#define GLOBAL_DMA_SKB_SIZE_REG 0x0010
  2656. +#define GLOBAL_SWFQ_RWPTR_REG 0x0014
  2657. +#define GLOBAL_HWFQ_RWPTR_REG 0x0018
  2658. +#define GLOBAL_INTERRUPT_STATUS_0_REG 0x0020
  2659. +#define GLOBAL_INTERRUPT_ENABLE_0_REG 0x0024
  2660. +#define GLOBAL_INTERRUPT_SELECT_0_REG 0x0028
  2661. +#define GLOBAL_INTERRUPT_STATUS_1_REG 0x0030
  2662. +#define GLOBAL_INTERRUPT_ENABLE_1_REG 0x0034
  2663. +#define GLOBAL_INTERRUPT_SELECT_1_REG 0x0038
  2664. +#define GLOBAL_INTERRUPT_STATUS_2_REG 0x0040
  2665. +#define GLOBAL_INTERRUPT_ENABLE_2_REG 0x0044
  2666. +#define GLOBAL_INTERRUPT_SELECT_2_REG 0x0048
  2667. +#define GLOBAL_INTERRUPT_STATUS_3_REG 0x0050
  2668. +#define GLOBAL_INTERRUPT_ENABLE_3_REG 0x0054
  2669. +#define GLOBAL_INTERRUPT_SELECT_3_REG 0x0058
  2670. +#define GLOBAL_INTERRUPT_STATUS_4_REG 0x0060
  2671. +#define GLOBAL_INTERRUPT_ENABLE_4_REG 0x0064
  2672. +#define GLOBAL_INTERRUPT_SELECT_4_REG 0x0068
  2673. +#define GLOBAL_HASH_TABLE_BASE_REG 0x006C
  2674. +#define GLOBAL_QUEUE_THRESHOLD_REG 0x0070
  2675. +
  2676. +/*
  2677. + * GMAC 0/1 DMA/TOE register
  2678. + * #define TOE_GMAC0_DMA_BASE (TOE_BASE + 0x8000)
  2679. + * #define TOE_GMAC1_DMA_BASE (TOE_BASE + 0xC000)
  2680. + * Base 0x60008000 or 0x6000C000
  2681. + */
  2682. +#define GMAC_DMA_CTRL_REG 0x0000
  2683. +#define GMAC_TX_WEIGHTING_CTRL_0_REG 0x0004
  2684. +#define GMAC_TX_WEIGHTING_CTRL_1_REG 0x0008
  2685. +#define GMAC_SW_TX_QUEUE0_PTR_REG 0x000C
  2686. +#define GMAC_SW_TX_QUEUE1_PTR_REG 0x0010
  2687. +#define GMAC_SW_TX_QUEUE2_PTR_REG 0x0014
  2688. +#define GMAC_SW_TX_QUEUE3_PTR_REG 0x0018
  2689. +#define GMAC_SW_TX_QUEUE4_PTR_REG 0x001C
  2690. +#define GMAC_SW_TX_QUEUE5_PTR_REG 0x0020
  2691. +#define GMAC_HW_TX_QUEUE0_PTR_REG 0x0024
  2692. +#define GMAC_HW_TX_QUEUE1_PTR_REG 0x0028
  2693. +#define GMAC_HW_TX_QUEUE2_PTR_REG 0x002C
  2694. +#define GMAC_HW_TX_QUEUE3_PTR_REG 0x0030
  2695. +#define GMAC_DMA_TX_FIRST_DESC_REG 0x0038
  2696. +#define GMAC_DMA_TX_CURR_DESC_REG 0x003C
  2697. +#define GMAC_DMA_TX_DESC_WORD0_REG 0x0040
  2698. +#define GMAC_DMA_TX_DESC_WORD1_REG 0x0044
  2699. +#define GMAC_DMA_TX_DESC_WORD2_REG 0x0048
  2700. +#define GMAC_DMA_TX_DESC_WORD3_REG 0x004C
  2701. +#define GMAC_SW_TX_QUEUE_BASE_REG 0x0050
  2702. +#define GMAC_HW_TX_QUEUE_BASE_REG 0x0054
  2703. +#define GMAC_DMA_RX_FIRST_DESC_REG 0x0058
  2704. +#define GMAC_DMA_RX_CURR_DESC_REG 0x005C
  2705. +#define GMAC_DMA_RX_DESC_WORD0_REG 0x0060
  2706. +#define GMAC_DMA_RX_DESC_WORD1_REG 0x0064
  2707. +#define GMAC_DMA_RX_DESC_WORD2_REG 0x0068
  2708. +#define GMAC_DMA_RX_DESC_WORD3_REG 0x006C
  2709. +#define GMAC_HASH_ENGINE_REG0 0x0070
  2710. +#define GMAC_HASH_ENGINE_REG1 0x0074
  2711. +/* matching rule 0 Control register 0 */
  2712. +#define GMAC_MR0CR0 0x0078
  2713. +#define GMAC_MR0CR1 0x007C
  2714. +#define GMAC_MR0CR2 0x0080
  2715. +#define GMAC_MR1CR0 0x0084
  2716. +#define GMAC_MR1CR1 0x0088
  2717. +#define GMAC_MR1CR2 0x008C
  2718. +#define GMAC_MR2CR0 0x0090
  2719. +#define GMAC_MR2CR1 0x0094
  2720. +#define GMAC_MR2CR2 0x0098
  2721. +#define GMAC_MR3CR0 0x009C
  2722. +#define GMAC_MR3CR1 0x00A0
  2723. +#define GMAC_MR3CR2 0x00A4
  2724. +/* Support Protocol Regsister 0 */
  2725. +#define GMAC_SPR0 0x00A8
  2726. +#define GMAC_SPR1 0x00AC
  2727. +#define GMAC_SPR2 0x00B0
  2728. +#define GMAC_SPR3 0x00B4
  2729. +#define GMAC_SPR4 0x00B8
  2730. +#define GMAC_SPR5 0x00BC
  2731. +#define GMAC_SPR6 0x00C0
  2732. +#define GMAC_SPR7 0x00C4
  2733. +/* GMAC Hash/Rx/Tx AHB Weighting register */
  2734. +#define GMAC_AHB_WEIGHT_REG 0x00C8
  2735. +
  2736. +/*
  2737. + * TOE GMAC 0/1 register
  2738. + * #define TOE_GMAC0_BASE (TOE_BASE + 0xA000)
  2739. + * #define TOE_GMAC1_BASE (TOE_BASE + 0xE000)
  2740. + * Base 0x6000A000 or 0x6000E000
  2741. + */
  2742. +enum GMAC_REGISTER {
  2743. + GMAC_STA_ADD0 = 0x0000,
  2744. + GMAC_STA_ADD1 = 0x0004,
  2745. + GMAC_STA_ADD2 = 0x0008,
  2746. + GMAC_RX_FLTR = 0x000c,
  2747. + GMAC_MCAST_FIL0 = 0x0010,
  2748. + GMAC_MCAST_FIL1 = 0x0014,
  2749. + GMAC_CONFIG0 = 0x0018,
  2750. + GMAC_CONFIG1 = 0x001c,
  2751. + GMAC_CONFIG2 = 0x0020,
  2752. + GMAC_CONFIG3 = 0x0024,
  2753. + GMAC_RESERVED = 0x0028,
  2754. + GMAC_STATUS = 0x002c,
  2755. + GMAC_IN_DISCARDS= 0x0030,
  2756. + GMAC_IN_ERRORS = 0x0034,
  2757. + GMAC_IN_MCAST = 0x0038,
  2758. + GMAC_IN_BCAST = 0x003c,
  2759. + GMAC_IN_MAC1 = 0x0040, /* for STA 1 MAC Address */
  2760. + GMAC_IN_MAC2 = 0x0044 /* for STA 2 MAC Address */
  2761. +};
  2762. +
  2763. +/*
  2764. + * DMA Queues description Ring Base Address/Size Register (offset 0x0004)
  2765. + */
  2766. +typedef union {
  2767. + unsigned int bits32;
  2768. + unsigned int base_size;
  2769. +} DMA_Q_BASE_SIZE_T;
  2770. +#define DMA_Q_BASE_MASK (~0x0f)
  2771. +
  2772. +/*
  2773. + * DMA SKB Buffer register (offset 0x0008)
  2774. + */
  2775. +typedef union {
  2776. + unsigned int bits32;
  2777. + struct bit_0008 {
  2778. + unsigned int sw_skb_size : 16; /* SW Free poll SKB Size */
  2779. + unsigned int hw_skb_size : 16; /* HW Free poll SKB Size */
  2780. + } bits;
  2781. +} DMA_SKB_SIZE_T;
  2782. +
  2783. +/*
  2784. + * DMA SW Free Queue Read/Write Pointer Register (offset 0x000C)
  2785. + */
  2786. +typedef union {
  2787. + unsigned int bits32;
  2788. + struct bit_000c {
  2789. + unsigned int rptr : 16; /* Read Ptr, RO */
  2790. + unsigned int wptr : 16; /* Write Ptr, RW */
  2791. + } bits;
  2792. +} DMA_RWPTR_T;
  2793. +
  2794. +/*
  2795. + * DMA HW Free Queue Read/Write Pointer Register (offset 0x0010)
  2796. + * see DMA_RWPTR_T structure
  2797. + */
  2798. +
  2799. +/*
  2800. + * Interrupt Status Register 0 (offset 0x0020)
  2801. + * Interrupt Mask Register 0 (offset 0x0024)
  2802. + * Interrupt Select Register 0 (offset 0x0028)
  2803. + */
  2804. +typedef union {
  2805. + unsigned int bits32;
  2806. + struct bit_0020 {
  2807. + /* GMAC0 SW Tx Queue 0 EOF Interrupt */
  2808. + unsigned int swtq00_eof : 1;
  2809. + unsigned int swtq01_eof : 1;
  2810. + unsigned int swtq02_eof : 1;
  2811. + unsigned int swtq03_eof : 1;
  2812. + unsigned int swtq04_eof : 1;
  2813. + unsigned int swtq05_eof : 1;
  2814. + /* GMAC1 SW Tx Queue 0 EOF Interrupt */
  2815. + unsigned int swtq10_eof : 1;
  2816. + unsigned int swtq11_eof : 1;
  2817. + unsigned int swtq12_eof : 1;
  2818. + unsigned int swtq13_eof : 1;
  2819. + unsigned int swtq14_eof : 1;
  2820. + unsigned int swtq15_eof : 1;
  2821. + /* GMAC0 SW Tx Queue 0 Finish Interrupt */
  2822. + unsigned int swtq00_fin : 1;
  2823. + unsigned int swtq01_fin : 1;
  2824. + unsigned int swtq02_fin : 1;
  2825. + unsigned int swtq03_fin : 1;
  2826. + unsigned int swtq04_fin : 1;
  2827. + unsigned int swtq05_fin : 1;
  2828. + /* GMAC1 SW Tx Queue 0 Finish Interrupt */
  2829. + unsigned int swtq10_fin : 1;
  2830. + unsigned int swtq11_fin : 1;
  2831. + unsigned int swtq12_fin : 1;
  2832. + unsigned int swtq13_fin : 1;
  2833. + unsigned int swtq14_fin : 1;
  2834. + unsigned int swtq15_fin : 1;
  2835. + /* GMAC0 Rx Descriptor Protocol Error */
  2836. + unsigned int rxPerr0 : 1;
  2837. + /* GMAC0 AHB Bus Error while Rx */
  2838. + unsigned int rxDerr0 : 1;
  2839. + /* GMAC1 Rx Descriptor Protocol Error */
  2840. + unsigned int rxPerr1 : 1;
  2841. + /* GMAC1 AHB Bus Error while Rx */
  2842. + unsigned int rxDerr1 : 1;
  2843. + /* GMAC0 Tx Descriptor Protocol Error */
  2844. + unsigned int txPerr0 : 1;
  2845. + /* GMAC0 AHB Bus Error while Tx */
  2846. + unsigned int txDerr0 : 1;
  2847. + /* GMAC1 Tx Descriptor Protocol Error */
  2848. + unsigned int txPerr1 : 1;
  2849. + /* GMAC1 AHB Bus Error while Tx */
  2850. + unsigned int txDerr1 : 1;
  2851. + } bits;
  2852. +} INTR_REG0_T;
  2853. +
  2854. +#define GMAC1_TXDERR_INT_BIT BIT(31)
  2855. +#define GMAC1_TXPERR_INT_BIT BIT(30)
  2856. +#define GMAC0_TXDERR_INT_BIT BIT(29)
  2857. +#define GMAC0_TXPERR_INT_BIT BIT(28)
  2858. +#define GMAC1_RXDERR_INT_BIT BIT(27)
  2859. +#define GMAC1_RXPERR_INT_BIT BIT(26)
  2860. +#define GMAC0_RXDERR_INT_BIT BIT(25)
  2861. +#define GMAC0_RXPERR_INT_BIT BIT(24)
  2862. +#define GMAC1_SWTQ15_FIN_INT_BIT BIT(23)
  2863. +#define GMAC1_SWTQ14_FIN_INT_BIT BIT(22)
  2864. +#define GMAC1_SWTQ13_FIN_INT_BIT BIT(21)
  2865. +#define GMAC1_SWTQ12_FIN_INT_BIT BIT(20)
  2866. +#define GMAC1_SWTQ11_FIN_INT_BIT BIT(19)
  2867. +#define GMAC1_SWTQ10_FIN_INT_BIT BIT(18)
  2868. +#define GMAC0_SWTQ05_FIN_INT_BIT BIT(17)
  2869. +#define GMAC0_SWTQ04_FIN_INT_BIT BIT(16)
  2870. +#define GMAC0_SWTQ03_FIN_INT_BIT BIT(15)
  2871. +#define GMAC0_SWTQ02_FIN_INT_BIT BIT(14)
  2872. +#define GMAC0_SWTQ01_FIN_INT_BIT BIT(13)
  2873. +#define GMAC0_SWTQ00_FIN_INT_BIT BIT(12)
  2874. +#define GMAC1_SWTQ15_EOF_INT_BIT BIT(11)
  2875. +#define GMAC1_SWTQ14_EOF_INT_BIT BIT(10)
  2876. +#define GMAC1_SWTQ13_EOF_INT_BIT BIT(9)
  2877. +#define GMAC1_SWTQ12_EOF_INT_BIT BIT(8)
  2878. +#define GMAC1_SWTQ11_EOF_INT_BIT BIT(7)
  2879. +#define GMAC1_SWTQ10_EOF_INT_BIT BIT(6)
  2880. +#define GMAC0_SWTQ05_EOF_INT_BIT BIT(5)
  2881. +#define GMAC0_SWTQ04_EOF_INT_BIT BIT(4)
  2882. +#define GMAC0_SWTQ03_EOF_INT_BIT BIT(3)
  2883. +#define GMAC0_SWTQ02_EOF_INT_BIT BIT(2)
  2884. +#define GMAC0_SWTQ01_EOF_INT_BIT BIT(1)
  2885. +#define GMAC0_SWTQ00_EOF_INT_BIT BIT(0)
  2886. +
  2887. +/*
  2888. + * Interrupt Status Register 1 (offset 0x0030)
  2889. + * Interrupt Mask Register 1 (offset 0x0034)
  2890. + * Interrupt Select Register 1 (offset 0x0038)
  2891. + */
  2892. +typedef union {
  2893. + unsigned int bits32;
  2894. + struct bit_0030 {
  2895. + unsigned int default_q0_eof : 1; /* Default Queue 0 EOF Interrupt */
  2896. + unsigned int default_q1_eof : 1; /* Default Queue 1 EOF Interrupt */
  2897. + unsigned int class_rx : 14; /* Classification Queue Rx Interrupt */
  2898. + unsigned int hwtq00_eof : 1; /* GMAC0 HW Tx Queue0 EOF Interrupt */
  2899. + unsigned int hwtq01_eof : 1; /* GMAC0 HW Tx Queue1 EOF Interrupt */
  2900. + unsigned int hwtq02_eof : 1; /* GMAC0 HW Tx Queue2 EOF Interrupt */
  2901. + unsigned int hwtq03_eof : 1; /* GMAC0 HW Tx Queue3 EOF Interrupt */
  2902. + unsigned int hwtq10_eof : 1; /* GMAC1 HW Tx Queue0 EOF Interrupt */
  2903. + unsigned int hwtq11_eof : 1; /* GMAC1 HW Tx Queue1 EOF Interrupt */
  2904. + unsigned int hwtq12_eof : 1; /* GMAC1 HW Tx Queue2 EOF Interrupt */
  2905. + unsigned int hwtq13_eof : 1; /* GMAC1 HW Tx Queue3 EOF Interrupt */
  2906. + unsigned int toe_iq0_intr : 1; /* TOE Interrupt Queue 0 with Interrupts */
  2907. + unsigned int toe_iq1_intr : 1; /* TOE Interrupt Queue 1 with Interrupts */
  2908. + unsigned int toe_iq2_intr : 1; /* TOE Interrupt Queue 2 with Interrupts */
  2909. + unsigned int toe_iq3_intr : 1; /* TOE Interrupt Queue 3 with Interrupts */
  2910. + unsigned int toe_iq0_full : 1; /* TOE Interrupt Queue 0 Full Interrupt */
  2911. + unsigned int toe_iq1_full : 1; /* TOE Interrupt Queue 1 Full Interrupt */
  2912. + unsigned int toe_iq2_full : 1; /* TOE Interrupt Queue 2 Full Interrupt */
  2913. + unsigned int toe_iq3_full : 1; /* TOE Interrupt Queue 3 Full Interrupt */
  2914. + } bits;
  2915. +} INTR_REG1_T;
  2916. +
  2917. +#define TOE_IQ3_FULL_INT_BIT BIT(31)
  2918. +#define TOE_IQ2_FULL_INT_BIT BIT(30)
  2919. +#define TOE_IQ1_FULL_INT_BIT BIT(29)
  2920. +#define TOE_IQ0_FULL_INT_BIT BIT(28)
  2921. +#define TOE_IQ3_INT_BIT BIT(27)
  2922. +#define TOE_IQ2_INT_BIT BIT(26)
  2923. +#define TOE_IQ1_INT_BIT BIT(25)
  2924. +#define TOE_IQ0_INT_BIT BIT(24)
  2925. +#define GMAC1_HWTQ13_EOF_INT_BIT BIT(23)
  2926. +#define GMAC1_HWTQ12_EOF_INT_BIT BIT(22)
  2927. +#define GMAC1_HWTQ11_EOF_INT_BIT BIT(21)
  2928. +#define GMAC1_HWTQ10_EOF_INT_BIT BIT(20)
  2929. +#define GMAC0_HWTQ03_EOF_INT_BIT BIT(19)
  2930. +#define GMAC0_HWTQ02_EOF_INT_BIT BIT(18)
  2931. +#define GMAC0_HWTQ01_EOF_INT_BIT BIT(17)
  2932. +#define GMAC0_HWTQ00_EOF_INT_BIT BIT(16)
  2933. +#define CLASS_RX_INT_BIT(x) BIT((x + 2))
  2934. +#define DEFAULT_Q1_INT_BIT BIT(1)
  2935. +#define DEFAULT_Q0_INT_BIT BIT(0)
  2936. +
  2937. +#define TOE_IQ_INT_BITS (TOE_IQ0_INT_BIT | TOE_IQ1_INT_BIT | \
  2938. + TOE_IQ2_INT_BIT | TOE_IQ3_INT_BIT)
  2939. +#define TOE_IQ_FULL_BITS (TOE_IQ0_FULL_INT_BIT | TOE_IQ1_FULL_INT_BIT | \
  2940. + TOE_IQ2_FULL_INT_BIT | TOE_IQ3_FULL_INT_BIT)
  2941. +#define TOE_IQ_ALL_BITS (TOE_IQ_INT_BITS | TOE_IQ_FULL_BITS)
  2942. +#define TOE_CLASS_RX_INT_BITS 0xfffc
  2943. +
  2944. +/*
  2945. + * Interrupt Status Register 2 (offset 0x0040)
  2946. + * Interrupt Mask Register 2 (offset 0x0044)
  2947. + * Interrupt Select Register 2 (offset 0x0048)
  2948. + */
  2949. +typedef union {
  2950. + unsigned int bits32;
  2951. + struct bit_0040 {
  2952. + unsigned int toe_q0_full : 1; // bit 0 TOE Queue 0 Full Interrupt
  2953. + unsigned int toe_q1_full : 1; // bit 1 TOE Queue 1 Full Interrupt
  2954. + unsigned int toe_q2_full : 1; // bit 2 TOE Queue 2 Full Interrupt
  2955. + unsigned int toe_q3_full : 1; // bit 3 TOE Queue 3 Full Interrupt
  2956. + unsigned int toe_q4_full : 1; // bit 4 TOE Queue 4 Full Interrupt
  2957. + unsigned int toe_q5_full : 1; // bit 5 TOE Queue 5 Full Interrupt
  2958. + unsigned int toe_q6_full : 1; // bit 6 TOE Queue 6 Full Interrupt
  2959. + unsigned int toe_q7_full : 1; // bit 7 TOE Queue 7 Full Interrupt
  2960. + unsigned int toe_q8_full : 1; // bit 8 TOE Queue 8 Full Interrupt
  2961. + unsigned int toe_q9_full : 1; // bit 9 TOE Queue 9 Full Interrupt
  2962. + unsigned int toe_q10_full : 1; // bit 10 TOE Queue 10 Full Interrupt
  2963. + unsigned int toe_q11_full : 1; // bit 11 TOE Queue 11 Full Interrupt
  2964. + unsigned int toe_q12_full : 1; // bit 12 TOE Queue 12 Full Interrupt
  2965. + unsigned int toe_q13_full : 1; // bit 13 TOE Queue 13 Full Interrupt
  2966. + unsigned int toe_q14_full : 1; // bit 14 TOE Queue 14 Full Interrupt
  2967. + unsigned int toe_q15_full : 1; // bit 15 TOE Queue 15 Full Interrupt
  2968. + unsigned int toe_q16_full : 1; // bit 16 TOE Queue 16 Full Interrupt
  2969. + unsigned int toe_q17_full : 1; // bit 17 TOE Queue 17 Full Interrupt
  2970. + unsigned int toe_q18_full : 1; // bit 18 TOE Queue 18 Full Interrupt
  2971. + unsigned int toe_q19_full : 1; // bit 19 TOE Queue 19 Full Interrupt
  2972. + unsigned int toe_q20_full : 1; // bit 20 TOE Queue 20 Full Interrupt
  2973. + unsigned int toe_q21_full : 1; // bit 21 TOE Queue 21 Full Interrupt
  2974. + unsigned int toe_q22_full : 1; // bit 22 TOE Queue 22 Full Interrupt
  2975. + unsigned int toe_q23_full : 1; // bit 23 TOE Queue 23 Full Interrupt
  2976. + unsigned int toe_q24_full : 1; // bit 24 TOE Queue 24 Full Interrupt
  2977. + unsigned int toe_q25_full : 1; // bit 25 TOE Queue 25 Full Interrupt
  2978. + unsigned int toe_q26_full : 1; // bit 26 TOE Queue 26 Full Interrupt
  2979. + unsigned int toe_q27_full : 1; // bit 27 TOE Queue 27 Full Interrupt
  2980. + unsigned int toe_q28_full : 1; // bit 28 TOE Queue 28 Full Interrupt
  2981. + unsigned int toe_q29_full : 1; // bit 29 TOE Queue 29 Full Interrupt
  2982. + unsigned int toe_q30_full : 1; // bit 30 TOE Queue 30 Full Interrupt
  2983. + unsigned int toe_q31_full : 1; // bit 31 TOE Queue 31 Full Interrupt
  2984. + } bits;
  2985. +} INTR_REG2_T;
  2986. +
  2987. +#define TOE_QL_FULL_INT_BIT(x) BIT(x)
  2988. +
  2989. +/*
  2990. + * Interrupt Status Register 3 (offset 0x0050)
  2991. + * Interrupt Mask Register 3 (offset 0x0054)
  2992. + * Interrupt Select Register 3 (offset 0x0058)
  2993. + */
  2994. +typedef union {
  2995. + unsigned int bits32;
  2996. + struct bit_0050 {
  2997. + unsigned int toe_q32_full : 1; // bit 32 TOE Queue 32 Full Interrupt
  2998. + unsigned int toe_q33_full : 1; // bit 33 TOE Queue 33 Full Interrupt
  2999. + unsigned int toe_q34_full : 1; // bit 34 TOE Queue 34 Full Interrupt
  3000. + unsigned int toe_q35_full : 1; // bit 35 TOE Queue 35 Full Interrupt
  3001. + unsigned int toe_q36_full : 1; // bit 36 TOE Queue 36 Full Interrupt
  3002. + unsigned int toe_q37_full : 1; // bit 37 TOE Queue 37 Full Interrupt
  3003. + unsigned int toe_q38_full : 1; // bit 38 TOE Queue 38 Full Interrupt
  3004. + unsigned int toe_q39_full : 1; // bit 39 TOE Queue 39 Full Interrupt
  3005. + unsigned int toe_q40_full : 1; // bit 40 TOE Queue 40 Full Interrupt
  3006. + unsigned int toe_q41_full : 1; // bit 41 TOE Queue 41 Full Interrupt
  3007. + unsigned int toe_q42_full : 1; // bit 42 TOE Queue 42 Full Interrupt
  3008. + unsigned int toe_q43_full : 1; // bit 43 TOE Queue 43 Full Interrupt
  3009. + unsigned int toe_q44_full : 1; // bit 44 TOE Queue 44 Full Interrupt
  3010. + unsigned int toe_q45_full : 1; // bit 45 TOE Queue 45 Full Interrupt
  3011. + unsigned int toe_q46_full : 1; // bit 46 TOE Queue 46 Full Interrupt
  3012. + unsigned int toe_q47_full : 1; // bit 47 TOE Queue 47 Full Interrupt
  3013. + unsigned int toe_q48_full : 1; // bit 48 TOE Queue 48 Full Interrupt
  3014. + unsigned int toe_q49_full : 1; // bit 49 TOE Queue 49 Full Interrupt
  3015. + unsigned int toe_q50_full : 1; // bit 50 TOE Queue 50 Full Interrupt
  3016. + unsigned int toe_q51_full : 1; // bit 51 TOE Queue 51 Full Interrupt
  3017. + unsigned int toe_q52_full : 1; // bit 52 TOE Queue 52 Full Interrupt
  3018. + unsigned int toe_q53_full : 1; // bit 53 TOE Queue 53 Full Interrupt
  3019. + unsigned int toe_q54_full : 1; // bit 54 TOE Queue 54 Full Interrupt
  3020. + unsigned int toe_q55_full : 1; // bit 55 TOE Queue 55 Full Interrupt
  3021. + unsigned int toe_q56_full : 1; // bit 56 TOE Queue 56 Full Interrupt
  3022. + unsigned int toe_q57_full : 1; // bit 57 TOE Queue 57 Full Interrupt
  3023. + unsigned int toe_q58_full : 1; // bit 58 TOE Queue 58 Full Interrupt
  3024. + unsigned int toe_q59_full : 1; // bit 59 TOE Queue 59 Full Interrupt
  3025. + unsigned int toe_q60_full : 1; // bit 60 TOE Queue 60 Full Interrupt
  3026. + unsigned int toe_q61_full : 1; // bit 61 TOE Queue 61 Full Interrupt
  3027. + unsigned int toe_q62_full : 1; // bit 62 TOE Queue 62 Full Interrupt
  3028. + unsigned int toe_q63_full : 1; // bit 63 TOE Queue 63 Full Interrupt
  3029. + } bits;
  3030. +} INTR_REG3_T;
  3031. +
  3032. +#define TOE_QH_FULL_INT_BIT(x) BIT(x-32)
  3033. +
  3034. +/*
  3035. + * Interrupt Status Register 4 (offset 0x0060)
  3036. + * Interrupt Mask Register 4 (offset 0x0064)
  3037. + * Interrupt Select Register 4 (offset 0x0068)
  3038. + */
  3039. +typedef union {
  3040. + unsigned char byte;
  3041. + struct bit_0060 {
  3042. + unsigned char status_changed : 1; // Status Changed Intr for RGMII Mode
  3043. + unsigned char rx_overrun : 1; // GMAC Rx FIFO overrun interrupt
  3044. + unsigned char tx_pause_off : 1; // received pause off frame interrupt
  3045. + unsigned char rx_pause_off : 1; // received pause off frame interrupt
  3046. + unsigned char tx_pause_on : 1; // transmit pause on frame interrupt
  3047. + unsigned char rx_pause_on : 1; // received pause on frame interrupt
  3048. + unsigned char cnt_full : 1; // MIB counters half full interrupt
  3049. + unsigned char reserved : 1; //
  3050. + } _PACKED_ bits;
  3051. +} _PACKED_ GMAC_INTR_T;
  3052. +
  3053. +typedef union {
  3054. + unsigned int bits32;
  3055. + struct bit_0060_2 {
  3056. + unsigned int swfq_empty : 1; // bit 0 Software Free Queue Empty Intr.
  3057. + unsigned int hwfq_empty : 1; // bit 1 Hardware Free Queue Empty Intr.
  3058. + unsigned int class_qf_int : 14; // bit 15:2 Classification Rx Queue13-0 Full Intr.
  3059. + GMAC_INTR_T gmac0;
  3060. + GMAC_INTR_T gmac1;
  3061. + } bits;
  3062. +} INTR_REG4_T;
  3063. +
  3064. +#define GMAC1_RESERVED_INT_BIT BIT(31)
  3065. +#define GMAC1_MIB_INT_BIT BIT(30)
  3066. +#define GMAC1_RX_PAUSE_ON_INT_BIT BIT(29)
  3067. +#define GMAC1_TX_PAUSE_ON_INT_BIT BIT(28)
  3068. +#define GMAC1_RX_PAUSE_OFF_INT_BIT BIT(27)
  3069. +#define GMAC1_TX_PAUSE_OFF_INT_BIT BIT(26)
  3070. +#define GMAC1_RX_OVERRUN_INT_BIT BIT(25)
  3071. +#define GMAC1_STATUS_CHANGE_INT_BIT BIT(24)
  3072. +#define GMAC0_RESERVED_INT_BIT BIT(23)
  3073. +#define GMAC0_MIB_INT_BIT BIT(22)
  3074. +#define GMAC0_RX_PAUSE_ON_INT_BIT BIT(21)
  3075. +#define GMAC0_TX_PAUSE_ON_INT_BIT BIT(20)
  3076. +#define GMAC0_RX_PAUSE_OFF_INT_BIT BIT(19)
  3077. +#define GMAC0_TX_PAUSE_OFF_INT_BIT BIT(18)
  3078. +#define GMAC0_RX_OVERRUN_INT_BIT BIT(17)
  3079. +#define GMAC0_STATUS_CHANGE_INT_BIT BIT(16)
  3080. +#define CLASS_RX_FULL_INT_BIT(x) BIT((x+2))
  3081. +#define HWFQ_EMPTY_INT_BIT BIT(1)
  3082. +#define SWFQ_EMPTY_INT_BIT BIT(0)
  3083. +
  3084. +#if 1
  3085. +#define GMAC0_INT_BITS (GMAC0_MIB_INT_BIT)
  3086. +#define GMAC1_INT_BITS (GMAC1_MIB_INT_BIT)
  3087. +#else
  3088. +#define GMAC0_INT_BITS (GMAC0_RESERVED_INT_BIT | GMAC0_MIB_INT_BIT | \
  3089. + GMAC0_RX_PAUSE_ON_INT_BIT | GMAC0_TX_PAUSE_ON_INT_BIT | \
  3090. + GMAC0_RX_PAUSE_OFF_INT_BIT | GMAC0_TX_PAUSE_OFF_INT_BIT | \
  3091. + GMAC0_RX_OVERRUN_INT_BIT | GMAC0_STATUS_CHANGE_INT_BIT)
  3092. +#define GMAC1_INT_BITS (GMAC1_RESERVED_INT_BIT | GMAC1_MIB_INT_BIT | \
  3093. + GMAC1_RX_PAUSE_ON_INT_BIT | GMAC1_TX_PAUSE_ON_INT_BIT | \
  3094. + GMAC1_RX_PAUSE_OFF_INT_BIT | GMAC1_TX_PAUSE_OFF_INT_BIT | \
  3095. + GMAC1_RX_OVERRUN_INT_BIT | GMAC1_STATUS_CHANGE_INT_BIT)
  3096. +#endif
  3097. +
  3098. +#define CLASS_RX_FULL_INT_BITS 0xfffc
  3099. +
  3100. +/*
  3101. + * GLOBAL_QUEUE_THRESHOLD_REG (offset 0x0070)
  3102. + */
  3103. +typedef union {
  3104. + unsigned int bits32;
  3105. + struct bit_0070_2 {
  3106. + unsigned int swfq_empty : 8; // 7:0 Software Free Queue Empty Threshold
  3107. + unsigned int hwfq_empty : 8; // 15:8 Hardware Free Queue Empty Threshold
  3108. + unsigned int intrq : 8; // 23:16
  3109. + unsigned int toe_class : 8; // 31:24
  3110. + } bits;
  3111. +} QUEUE_THRESHOLD_T;
  3112. +
  3113. +
  3114. +/*
  3115. + * GMAC DMA Control Register
  3116. + * GMAC0 offset 0x8000
  3117. + * GMAC1 offset 0xC000
  3118. + */
  3119. +typedef union {
  3120. + unsigned int bits32;
  3121. + struct bit_8000 {
  3122. + unsigned int td_bus : 2; // bit 1:0 Peripheral Bus Width
  3123. + unsigned int td_burst_size : 2; // bit 3:2 TxDMA max burst size for every AHB request
  3124. + unsigned int td_prot : 4; // bit 7:4 TxDMA protection control
  3125. + unsigned int rd_bus : 2; // bit 9:8 Peripheral Bus Width
  3126. + unsigned int rd_burst_size : 2; // bit 11:10 DMA max burst size for every AHB request
  3127. + unsigned int rd_prot : 4; // bit 15:12 DMA Protection Control
  3128. + unsigned int rd_insert_bytes : 2; // bit 17:16
  3129. + unsigned int reserved : 10; // bit 27:18
  3130. + unsigned int drop_small_ack : 1; // bit 28 1: Drop, 0: Accept
  3131. + unsigned int loopback : 1; // bit 29 Loopback TxDMA to RxDMA
  3132. + unsigned int td_enable : 1; // bit 30 Tx DMA Enable
  3133. + unsigned int rd_enable : 1; // bit 31 Rx DMA Enable
  3134. + } bits;
  3135. +} GMAC_DMA_CTRL_T;
  3136. +
  3137. +/*
  3138. + * GMAC Tx Weighting Control Register 0
  3139. + * GMAC0 offset 0x8004
  3140. + * GMAC1 offset 0xC004
  3141. + */
  3142. +typedef union {
  3143. + unsigned int bits32;
  3144. + struct bit_8004 {
  3145. + unsigned int hw_tq0 : 6; // bit 5:0 HW TX Queue 3
  3146. + unsigned int hw_tq1 : 6; // bit 11:6 HW TX Queue 2
  3147. + unsigned int hw_tq2 : 6; // bit 17:12 HW TX Queue 1
  3148. + unsigned int hw_tq3 : 6; // bit 23:18 HW TX Queue 0
  3149. + unsigned int reserved : 8; // bit 31:24
  3150. + } bits;
  3151. +} GMAC_TX_WCR0_T; /* Weighting Control Register 0 */
  3152. +
  3153. +/*
  3154. + * GMAC Tx Weighting Control Register 1
  3155. + * GMAC0 offset 0x8008
  3156. + * GMAC1 offset 0xC008
  3157. + */
  3158. +typedef union {
  3159. + unsigned int bits32;
  3160. + struct bit_8008 {
  3161. + unsigned int sw_tq0 : 5; // bit 4:0 SW TX Queue 0
  3162. + unsigned int sw_tq1 : 5; // bit 9:5 SW TX Queue 1
  3163. + unsigned int sw_tq2 : 5; // bit 14:10 SW TX Queue 2
  3164. + unsigned int sw_tq3 : 5; // bit 19:15 SW TX Queue 3
  3165. + unsigned int sw_tq4 : 5; // bit 24:20 SW TX Queue 4
  3166. + unsigned int sw_tq5 : 5; // bit 29:25 SW TX Queue 5
  3167. + unsigned int reserved : 2; // bit 31:30
  3168. + } bits;
  3169. +} GMAC_TX_WCR1_T; /* Weighting Control Register 1 */
  3170. +
  3171. +/*
  3172. + * Queue Read/Write Pointer
  3173. + * GMAC SW TX Queue 0~5 Read/Write Pointer register
  3174. + * GMAC0 offset 0x800C ~ 0x8020
  3175. + * GMAC1 offset 0xC00C ~ 0xC020
  3176. + * GMAC HW TX Queue 0~3 Read/Write Pointer register
  3177. + * GMAC0 offset 0x8024 ~ 0x8030
  3178. + * GMAC1 offset 0xC024 ~ 0xC030
  3179. + *
  3180. + * see DMA_RWPTR_T structure
  3181. + */
  3182. +
  3183. +/*
  3184. + * GMAC DMA Tx First Description Address Register
  3185. + * GMAC0 offset 0x8038
  3186. + * GMAC1 offset 0xC038
  3187. + */
  3188. +typedef union {
  3189. + unsigned int bits32;
  3190. + struct bit_8038 {
  3191. + unsigned int reserved : 3;
  3192. + unsigned int td_busy : 1; // bit 3 1: TxDMA busy; 0: TxDMA idle
  3193. + unsigned int td_first_des_ptr : 28; // bit 31:4 first descriptor address
  3194. + } bits;
  3195. +} GMAC_TXDMA_FIRST_DESC_T;
  3196. +
  3197. +/*
  3198. + * GMAC DMA Tx Current Description Address Register
  3199. + * GMAC0 offset 0x803C
  3200. + * GMAC1 offset 0xC03C
  3201. + */
  3202. +typedef union {
  3203. + unsigned int bits32;
  3204. + struct bit_803C {
  3205. + unsigned int reserved : 4;
  3206. + unsigned int td_curr_desc_ptr : 28; // bit 31:4 current descriptor address
  3207. + } bits;
  3208. +} GMAC_TXDMA_CURR_DESC_T;
  3209. +
  3210. +/*
  3211. + * GMAC DMA Tx Description Word 0 Register
  3212. + * GMAC0 offset 0x8040
  3213. + * GMAC1 offset 0xC040
  3214. + */
  3215. +typedef union {
  3216. + unsigned int bits32;
  3217. + struct bit_8040 {
  3218. + unsigned int buffer_size : 16; // bit 15:0 Transfer size
  3219. + unsigned int desc_count : 6; // bit 21:16 number of descriptors used for the current frame
  3220. + unsigned int status_tx_ok : 1; // bit 22 Tx Status, 1: Successful 0: Failed
  3221. + unsigned int status_rvd : 6; // bit 28:23 Tx Status, Reserved bits
  3222. + unsigned int perr : 1; // bit 29 protocol error during processing this descriptor
  3223. + unsigned int derr : 1; // bit 30 data error during processing this descriptor
  3224. + unsigned int reserved : 1; // bit 31
  3225. + } bits;
  3226. +} GMAC_TXDESC_0_T;
  3227. +
  3228. +/*
  3229. + * GMAC DMA Tx Description Word 1 Register
  3230. + * GMAC0 offset 0x8044
  3231. + * GMAC1 offset 0xC044
  3232. + */
  3233. +typedef union {
  3234. + unsigned int bits32;
  3235. + struct txdesc_word1 {
  3236. + unsigned int byte_count : 16; // bit 15: 0 Tx Frame Byte Count
  3237. + unsigned int mtu_enable : 1; // bit 16 TSS segmentation use MTU setting
  3238. + unsigned int ip_chksum : 1; // bit 17 IPV4 Header Checksum Enable
  3239. + unsigned int ipv6_enable : 1; // bit 18 IPV6 Tx Enable
  3240. + unsigned int tcp_chksum : 1; // bit 19 TCP Checksum Enable
  3241. + unsigned int udp_chksum : 1; // bit 20 UDP Checksum Enable
  3242. + unsigned int bypass_tss : 1; // bit 21
  3243. + unsigned int ip_fixed_len : 1; // bit 22
  3244. + unsigned int reserved : 9; // bit 31:23 Tx Flag, Reserved
  3245. + } bits;
  3246. +} GMAC_TXDESC_1_T;
  3247. +
  3248. +#define TSS_IP_FIXED_LEN_BIT BIT(22)
  3249. +#define TSS_UDP_CHKSUM_BIT BIT(20)
  3250. +#define TSS_TCP_CHKSUM_BIT BIT(19)
  3251. +#define TSS_IPV6_ENABLE_BIT BIT(18)
  3252. +#define TSS_IP_CHKSUM_BIT BIT(17)
  3253. +#define TSS_MTU_ENABLE_BIT BIT(16)
  3254. +
  3255. +/*
  3256. + * GMAC DMA Tx Description Word 2 Register
  3257. + * GMAC0 offset 0x8048
  3258. + * GMAC1 offset 0xC048
  3259. + */
  3260. +typedef union {
  3261. + unsigned int bits32;
  3262. + unsigned int buf_adr;
  3263. +} GMAC_TXDESC_2_T;
  3264. +
  3265. +/*
  3266. + * GMAC DMA Tx Description Word 3 Register
  3267. + * GMAC0 offset 0x804C
  3268. + * GMAC1 offset 0xC04C
  3269. + */
  3270. +typedef union {
  3271. + unsigned int bits32;
  3272. + struct txdesc_word3 {
  3273. + unsigned int mtu_size : 11; // bit 10: 0 Tx Frame Byte Count
  3274. + unsigned int reserved : 18; // bit 28:11
  3275. + unsigned int eofie : 1; // bit 29 End of frame interrupt enable
  3276. + unsigned int sof_eof : 2; // bit 31:30 11: only one, 10: first, 01: last, 00: linking
  3277. + } bits;
  3278. +} GMAC_TXDESC_3_T;
  3279. +#define SOF_EOF_BIT_MASK 0x3fffffff
  3280. +#define SOF_BIT 0x80000000
  3281. +#define EOF_BIT 0x40000000
  3282. +#define EOFIE_BIT BIT(29)
  3283. +#define MTU_SIZE_BIT_MASK 0x7ff
  3284. +
  3285. +/*
  3286. + * GMAC Tx Descriptor
  3287. + */
  3288. +typedef struct {
  3289. + GMAC_TXDESC_0_T word0;
  3290. + GMAC_TXDESC_1_T word1;
  3291. + GMAC_TXDESC_2_T word2;
  3292. + GMAC_TXDESC_3_T word3;
  3293. +} GMAC_TXDESC_T;
  3294. +
  3295. +/*
  3296. + * GMAC DMA Rx First Description Address Register
  3297. + * GMAC0 offset 0x8058
  3298. + * GMAC1 offset 0xC058
  3299. + */
  3300. +typedef union {
  3301. + unsigned int bits32;
  3302. + struct bit_8058 {
  3303. + unsigned int reserved : 3; // bit 2:0
  3304. + unsigned int rd_busy : 1; // bit 3 1-RxDMA busy; 0-RxDMA idle
  3305. + unsigned int rd_first_des_ptr : 28; // bit 31:4 first descriptor address
  3306. + } bits;
  3307. +} GMAC_RXDMA_FIRST_DESC_T;
  3308. +
  3309. +/*
  3310. + * GMAC DMA Rx Current Description Address Register
  3311. + * GMAC0 offset 0x805C
  3312. + * GMAC1 offset 0xC05C
  3313. + */
  3314. +typedef union {
  3315. + unsigned int bits32;
  3316. + struct bit_805C {
  3317. + unsigned int reserved : 4; // bit 3:0
  3318. + unsigned int rd_curr_des_ptr : 28; // bit 31:4 current descriptor address
  3319. + } bits;
  3320. +} GMAC_RXDMA_CURR_DESC_T;
  3321. +
  3322. +/*
  3323. + * GMAC DMA Rx Description Word 0 Register
  3324. + * GMAC0 offset 0x8060
  3325. + * GMAC1 offset 0xC060
  3326. + */
  3327. +typedef union {
  3328. + unsigned int bits32;
  3329. + struct bit_8060 {
  3330. + unsigned int buffer_size : 16; // bit 15:0 number of descriptors used for the current frame
  3331. + unsigned int desc_count : 6; // bit 21:16 number of descriptors used for the current frame
  3332. + unsigned int status : 4; // bit 24:22 Status of rx frame
  3333. + unsigned int chksum_status : 3; // bit 28:26 Check Sum Status
  3334. + unsigned int perr : 1; // bit 29 protocol error during processing this descriptor
  3335. + unsigned int derr : 1; // bit 30 data error during processing this descriptor
  3336. + unsigned int drop : 1; // bit 31 TOE/CIS Queue Full dropped packet to default queue
  3337. + } bits;
  3338. +} GMAC_RXDESC_0_T;
  3339. +
  3340. +#define GMAC_RXDESC_0_T_derr BIT(30)
  3341. +#define GMAC_RXDESC_0_T_perr BIT(29)
  3342. +#define GMAC_RXDESC_0_T_chksum_status(x) BIT((x+26))
  3343. +#define GMAC_RXDESC_0_T_status(x) BIT((x+22))
  3344. +#define GMAC_RXDESC_0_T_desc_count(x) BIT((x+16))
  3345. +
  3346. +#define RX_CHKSUM_IP_UDP_TCP_OK 0
  3347. +#define RX_CHKSUM_IP_OK_ONLY 1
  3348. +#define RX_CHKSUM_NONE 2
  3349. +#define RX_CHKSUM_IP_ERR_UNKNOWN 4
  3350. +#define RX_CHKSUM_IP_ERR 5
  3351. +#define RX_CHKSUM_TCP_UDP_ERR 6
  3352. +#define RX_CHKSUM_NUM 8
  3353. +
  3354. +#define RX_STATUS_GOOD_FRAME 0
  3355. +#define RX_STATUS_TOO_LONG_GOOD_CRC 1
  3356. +#define RX_STATUS_RUNT_FRAME 2
  3357. +#define RX_STATUS_SFD_NOT_FOUND 3
  3358. +#define RX_STATUS_CRC_ERROR 4
  3359. +#define RX_STATUS_TOO_LONG_BAD_CRC 5
  3360. +#define RX_STATUS_ALIGNMENT_ERROR 6
  3361. +#define RX_STATUS_TOO_LONG_BAD_ALIGN 7
  3362. +#define RX_STATUS_RX_ERR 8
  3363. +#define RX_STATUS_DA_FILTERED 9
  3364. +#define RX_STATUS_BUFFER_FULL 10
  3365. +#define RX_STATUS_NUM 16
  3366. +
  3367. +
  3368. +/*
  3369. + * GMAC DMA Rx Description Word 1 Register
  3370. + * GMAC0 offset 0x8064
  3371. + * GMAC1 offset 0xC064
  3372. + */
  3373. +typedef union {
  3374. + unsigned int bits32;
  3375. + struct rxdesc_word1 {
  3376. + unsigned int byte_count : 16; // bit 15: 0 Rx Frame Byte Count
  3377. + unsigned int sw_id : 16; // bit 31:16 Software ID
  3378. + } bits;
  3379. +} GMAC_RXDESC_1_T;
  3380. +
  3381. +/*
  3382. + * GMAC DMA Rx Description Word 2 Register
  3383. + * GMAC0 offset 0x8068
  3384. + * GMAC1 offset 0xC068
  3385. + */
  3386. +typedef union {
  3387. + unsigned int bits32;
  3388. + unsigned int buf_adr;
  3389. +} GMAC_RXDESC_2_T;
  3390. +
  3391. +#define RX_INSERT_NONE 0
  3392. +#define RX_INSERT_1_BYTE 1
  3393. +#define RX_INSERT_2_BYTE 2
  3394. +#define RX_INSERT_3_BYTE 3
  3395. +
  3396. +#define RX_INSERT_BYTES RX_INSERT_2_BYTE
  3397. +/*
  3398. + * GMAC DMA Rx Description Word 3 Register
  3399. + * GMAC0 offset 0x806C
  3400. + * GMAC1 offset 0xC06C
  3401. + */
  3402. +typedef union {
  3403. + unsigned int bits32;
  3404. + struct rxdesc_word3 {
  3405. + unsigned int l3_offset : 8; // bit 7: 0 L3 data offset
  3406. + unsigned int l4_offset : 8; // bit 15: 8 L4 data offset
  3407. + unsigned int l7_offset : 8; // bit 23: 16 L7 data offset
  3408. + unsigned int dup_ack : 1; // bit 24 Duplicated ACK detected
  3409. + unsigned int abnormal : 1; // bit 25 abnormal case found
  3410. + unsigned int option : 1; // bit 26 IPV4 option or IPV6 extension header
  3411. + unsigned int out_of_seq : 1; // bit 27 Out of Sequence packet
  3412. + unsigned int ctrl_flag : 1; // bit 28 Control Flag is present
  3413. + unsigned int eofie : 1; // bit 29 End of frame interrupt enable
  3414. + unsigned int sof_eof : 2; // bit 31:30 11: only one, 10: first, 01: last, 00: linking
  3415. + } bits;
  3416. +} GMAC_RXDESC_3_T;
  3417. +
  3418. +/*
  3419. + * GMAC Rx Descriptor
  3420. + */
  3421. +typedef struct {
  3422. + GMAC_RXDESC_0_T word0;
  3423. + GMAC_RXDESC_1_T word1;
  3424. + GMAC_RXDESC_2_T word2;
  3425. + GMAC_RXDESC_3_T word3;
  3426. +} GMAC_RXDESC_T;
  3427. +
  3428. +/*
  3429. + * GMAC Hash Engine Enable/Action Register 0 Offset Register
  3430. + * GMAC0 offset 0x8070
  3431. + * GMAC1 offset 0xC070
  3432. + */
  3433. +typedef union {
  3434. + unsigned int bits32;
  3435. + struct bit_8070 {
  3436. + unsigned int mr0hel : 6; // bit 5:0 match rule 0 hash entry size
  3437. + unsigned int mr0_action : 5; // bit 10:6 Matching Rule 0 action offset
  3438. + unsigned int reserved0 : 4; // bit 14:11
  3439. + unsigned int mr0en : 1; // bit 15 Enable Matching Rule 0
  3440. + unsigned int mr1hel : 6; // bit 21:16 match rule 1 hash entry size
  3441. + unsigned int mr1_action : 5; // bit 26:22 Matching Rule 1 action offset
  3442. + unsigned int timing : 3; // bit 29:27
  3443. + unsigned int reserved1 : 1; // bit 30
  3444. + unsigned int mr1en : 1; // bit 31 Enable Matching Rule 1
  3445. + } bits;
  3446. +} GMAC_HASH_ENABLE_REG0_T;
  3447. +
  3448. +/*
  3449. + * GMAC Hash Engine Enable/Action Register 1 Offset Register
  3450. + * GMAC0 offset 0x8074
  3451. + * GMAC1 offset 0xC074
  3452. + */
  3453. +typedef union {
  3454. + unsigned int bits32;
  3455. + struct bit_8074 {
  3456. + unsigned int mr2hel : 6; // bit 5:0 match rule 2 hash entry size
  3457. + unsigned int mr2_action : 5; // bit 10:6 Matching Rule 2 action offset
  3458. + unsigned int reserved2 : 4; // bit 14:11
  3459. + unsigned int mr2en : 1; // bit 15 Enable Matching Rule 2
  3460. + unsigned int mr3hel : 6; // bit 21:16 match rule 3 hash entry size
  3461. + unsigned int mr3_action : 5; // bit 26:22 Matching Rule 3 action offset
  3462. + unsigned int reserved1 : 4; // bit 30:27
  3463. + unsigned int mr3en : 1; // bit 31 Enable Matching Rule 3
  3464. + } bits;
  3465. +} GMAC_HASH_ENABLE_REG1_T;
  3466. +
  3467. +/*
  3468. + * GMAC Matching Rule Control Register 0
  3469. + * GMAC0 offset 0x8078
  3470. + * GMAC1 offset 0xC078
  3471. + */
  3472. +typedef union {
  3473. + unsigned int bits32;
  3474. + struct bit_8078 {
  3475. + unsigned int sprx : 8; // bit 7:0 Support Protocol Register 7:0
  3476. + unsigned int reserved2 : 4; // bit 11:8
  3477. + unsigned int tos_traffic : 1; // bit 12 IPV4 TOS or IPV6 Traffice Class
  3478. + unsigned int flow_lable : 1; // bit 13 IPV6 Flow label
  3479. + unsigned int ip_hdr_len : 1; // bit 14 IPV4 Header length
  3480. + unsigned int ip_version : 1; // bit 15 0: IPV4, 1: IPV6
  3481. + unsigned int reserved1 : 3; // bit 18:16
  3482. + unsigned int pppoe : 1; // bit 19 PPPoE Session ID enable
  3483. + unsigned int vlan : 1; // bit 20 VLAN ID enable
  3484. + unsigned int ether_type : 1; // bit 21 Ethernet type enable
  3485. + unsigned int sa : 1; // bit 22 MAC SA enable
  3486. + unsigned int da : 1; // bit 23 MAC DA enable
  3487. + unsigned int priority : 3; // bit 26:24 priority if multi-rules matched
  3488. + unsigned int port : 1; // bit 27 PORT ID matching enable
  3489. + unsigned int l7 : 1; // bit 28 L7 matching enable
  3490. + unsigned int l4 : 1; // bit 29 L4 matching enable
  3491. + unsigned int l3 : 1; // bit 30 L3 matching enable
  3492. + unsigned int l2 : 1; // bit 31 L2 matching enable
  3493. + } bits;
  3494. +} GMAC_MRxCR0_T;
  3495. +
  3496. +#define MR_L2_BIT BIT(31)
  3497. +#define MR_L3_BIT BIT(30)
  3498. +#define MR_L4_BIT BIT(29)
  3499. +#define MR_L7_BIT BIT(28)
  3500. +#define MR_PORT_BIT BIT(27)
  3501. +#define MR_PRIORITY_BIT BIT(26)
  3502. +#define MR_DA_BIT BIT(23)
  3503. +#define MR_SA_BIT BIT(22)
  3504. +#define MR_ETHER_TYPE_BIT BIT(21)
  3505. +#define MR_VLAN_BIT BIT(20)
  3506. +#define MR_PPPOE_BIT BIT(19)
  3507. +#define MR_IP_VER_BIT BIT(15)
  3508. +#define MR_IP_HDR_LEN_BIT BIT(14)
  3509. +#define MR_FLOW_LABLE_BIT BIT(13)
  3510. +#define MR_TOS_TRAFFIC_BIT BIT(12)
  3511. +#define MR_SPR_BIT(x) BIT(x)
  3512. +#define MR_SPR_BITS 0xff
  3513. +
  3514. +/*
  3515. + * GMAC Matching Rule Control Register 1
  3516. + * GMAC0 offset 0x807C
  3517. + * GMAC1 offset 0xC07C
  3518. + */
  3519. +typedef union {
  3520. + unsigned int bits32;
  3521. + struct bit_807C {
  3522. + unsigned int l4_byte0_15 : 16; // bit 15: 0
  3523. + unsigned int dip_netmask : 7; // bit 22:16 Dest IP net mask, number of mask bits
  3524. + unsigned int dip : 1; // bit 23 Dest IP
  3525. + unsigned int sip_netmask : 7; // bit 30:24 Srce IP net mask, number of mask bits
  3526. + unsigned int sip : 1; // bit 31 Srce IP
  3527. + } bits;
  3528. +} GMAC_MRxCR1_T;
  3529. +
  3530. +/*
  3531. + * GMAC Matching Rule Control Register 2
  3532. + * GMAC0 offset 0x8080
  3533. + * GMAC1 offset 0xC080
  3534. + */
  3535. +typedef union {
  3536. + unsigned int bits32;
  3537. + struct bit_8080 {
  3538. + unsigned int l7_byte0_23 : 24; // bit 23:0
  3539. + unsigned int l4_byte16_24 : 8; // bit 31: 24
  3540. + } bits;
  3541. +} GMAC_MRxCR2_T;
  3542. +
  3543. +/*
  3544. + * GMAC Support registers
  3545. + * GMAC0 offset 0x80A8
  3546. + * GMAC1 offset 0xC0A8
  3547. + */
  3548. +typedef union {
  3549. + unsigned int bits32;
  3550. + struct bit_80A8 {
  3551. + unsigned int protocol : 8; // bit 7:0 Supported protocol
  3552. + unsigned int swap : 3; // bit 10:8 Swap
  3553. + unsigned int reserved : 21; // bit 31:11
  3554. + } bits;
  3555. +} GMAC_SPR_T;
  3556. +
  3557. +/*
  3558. + * GMAC_AHB_WEIGHT registers
  3559. + * GMAC0 offset 0x80C8
  3560. + * GMAC1 offset 0xC0C8
  3561. + */
  3562. +typedef union {
  3563. + unsigned int bits32;
  3564. + struct bit_80C8 {
  3565. + unsigned int hash_weight : 5; // 4:0
  3566. + unsigned int rx_weight : 5; // 9:5
  3567. + unsigned int tx_weight : 5; // 14:10
  3568. + unsigned int pre_req : 5; // 19:15 Rx Data Pre Request FIFO Threshold
  3569. + unsigned int tqDV_threshold : 5; // 24:20 DMA TqCtrl to Start tqDV FIFO Threshold
  3570. + unsigned int reserved : 7; // 31:25
  3571. + } bits;
  3572. +} GMAC_AHB_WEIGHT_T;
  3573. +
  3574. +/*
  3575. + * the register structure of GMAC
  3576. + */
  3577. +
  3578. +/*
  3579. + * GMAC RX FLTR
  3580. + * GMAC0 Offset 0xA00C
  3581. + * GMAC1 Offset 0xE00C
  3582. + */
  3583. +typedef union {
  3584. + unsigned int bits32;
  3585. + struct bit1_000c {
  3586. + unsigned int unicast : 1; /* enable receive of unicast frames that are sent to STA address */
  3587. + unsigned int multicast : 1; /* enable receive of multicast frames that pass multicast filter */
  3588. + unsigned int broadcast : 1; /* enable receive of broadcast frames */
  3589. + unsigned int promiscuous : 1; /* enable receive of all frames */
  3590. + unsigned int error : 1; /* enable receive of all error frames */
  3591. + unsigned int : 27;
  3592. + } bits;
  3593. +} GMAC_RX_FLTR_T;
  3594. +
  3595. +/*
  3596. + * GMAC Configuration 0
  3597. + * GMAC0 Offset 0xA018
  3598. + * GMAC1 Offset 0xE018
  3599. + */
  3600. +typedef union {
  3601. + unsigned int bits32;
  3602. + struct bit1_0018 {
  3603. + unsigned int dis_tx : 1; /* 0: disable transmit */
  3604. + unsigned int dis_rx : 1; /* 1: disable receive */
  3605. + unsigned int loop_back : 1; /* 2: transmit data loopback enable */
  3606. + unsigned int flow_ctrl : 1; /* 3: flow control also trigged by Rx queues */
  3607. + unsigned int adj_ifg : 4; /* 4-7: adjust IFG from 96+/-56 */
  3608. + unsigned int max_len : 3; /* 8-10 maximum receive frame length allowed */
  3609. + unsigned int dis_bkoff : 1; /* 11: disable back-off function */
  3610. + unsigned int dis_col : 1; /* 12: disable 16 collisions abort function */
  3611. + unsigned int sim_test : 1; /* 13: speed up timers in simulation */
  3612. + unsigned int rx_fc_en : 1; /* 14: RX flow control enable */
  3613. + unsigned int tx_fc_en : 1; /* 15: TX flow control enable */
  3614. + unsigned int rgmii_en : 1; /* 16: RGMII in-band status enable */
  3615. + unsigned int ipv4_rx_chksum : 1; /* 17: IPv4 RX Checksum enable */
  3616. + unsigned int ipv6_rx_chksum : 1; /* 18: IPv6 RX Checksum enable */
  3617. + unsigned int rx_tag_remove : 1; /* 19: Remove Rx VLAN tag */
  3618. + unsigned int rgmm_edge : 1; // 20
  3619. + unsigned int rxc_inv : 1; // 21
  3620. + unsigned int ipv6_exthdr_order : 1; // 22
  3621. + unsigned int rx_err_detect : 1; // 23
  3622. + unsigned int port0_chk_hwq : 1; // 24
  3623. + unsigned int port1_chk_hwq : 1; // 25
  3624. + unsigned int port0_chk_toeq : 1; // 26
  3625. + unsigned int port1_chk_toeq : 1; // 27
  3626. + unsigned int port0_chk_classq : 1; // 28
  3627. + unsigned int port1_chk_classq : 1; // 29
  3628. + unsigned int reserved : 2; // 31
  3629. + } bits;
  3630. +} GMAC_CONFIG0_T;
  3631. +
  3632. +/*
  3633. + * GMAC Configuration 1
  3634. + * GMAC0 Offset 0xA01C
  3635. + * GMAC1 Offset 0xE01C
  3636. + */
  3637. +typedef union {
  3638. + unsigned int bits32;
  3639. + struct bit1_001c {
  3640. + unsigned int set_threshold : 8; /* flow control set threshold */
  3641. + unsigned int rel_threshold : 8; /* flow control release threshold */
  3642. + unsigned int reserved : 16;
  3643. + } bits;
  3644. +} GMAC_CONFIG1_T;
  3645. +
  3646. +#define GMAC_FLOWCTRL_SET_MAX 32
  3647. +#define GMAC_FLOWCTRL_SET_MIN 0
  3648. +#define GMAC_FLOWCTRL_RELEASE_MAX 32
  3649. +#define GMAC_FLOWCTRL_RELEASE_MIN 0
  3650. +
  3651. +/*
  3652. + * GMAC Configuration 2
  3653. + * GMAC0 Offset 0xA020
  3654. + * GMAC1 Offset 0xE020
  3655. + */
  3656. +typedef union {
  3657. + unsigned int bits32;
  3658. + struct bit1_0020 {
  3659. + unsigned int set_threshold : 16; /* flow control set threshold */
  3660. + unsigned int rel_threshold : 16; /* flow control release threshold */
  3661. + } bits;
  3662. +} GMAC_CONFIG2_T;
  3663. +
  3664. +/*
  3665. + * GMAC Configuration 3
  3666. + * GMAC0 Offset 0xA024
  3667. + * GMAC1 Offset 0xE024
  3668. + */
  3669. +typedef union {
  3670. + unsigned int bits32;
  3671. + struct bit1_0024 {
  3672. + unsigned int set_threshold : 16; /* flow control set threshold */
  3673. + unsigned int rel_threshold : 16; /* flow control release threshold */
  3674. + } bits;
  3675. +} GMAC_CONFIG3_T;
  3676. +
  3677. +
  3678. +/*
  3679. + * GMAC STATUS
  3680. + * GMAC0 Offset 0xA02C
  3681. + * GMAC1 Offset 0xE02C
  3682. + */
  3683. +typedef union {
  3684. + unsigned int bits32;
  3685. + struct bit1_002c {
  3686. + unsigned int link : 1; /* link status */
  3687. + unsigned int speed : 2; /* link speed(00->2.5M 01->25M 10->125M) */
  3688. + unsigned int duplex : 1; /* duplex mode */
  3689. + unsigned int reserved : 1;
  3690. + unsigned int mii_rmii : 2; /* PHY interface type */
  3691. + unsigned int : 25;
  3692. + } bits;
  3693. +} GMAC_STATUS_T;
  3694. +
  3695. +#define GMAC_SPEED_10 0
  3696. +#define GMAC_SPEED_100 1
  3697. +#define GMAC_SPEED_1000 2
  3698. +
  3699. +#define GMAC_PHY_MII 0
  3700. +#define GMAC_PHY_GMII 1
  3701. +#define GMAC_PHY_RGMII_100_10 2
  3702. +#define GMAC_PHY_RGMII_1000 3
  3703. +
  3704. +/*
  3705. + * Queue Header
  3706. + * (1) TOE Queue Header
  3707. + * (2) Non-TOE Queue Header
  3708. + * (3) Interrupt Queue Header
  3709. + *
  3710. + * memory Layout
  3711. + * TOE Queue Header
  3712. + * 0x60003000 +---------------------------+ 0x0000
  3713. + * | TOE Queue 0 Header |
  3714. + * | 8 * 4 Bytes |
  3715. + * +---------------------------+ 0x0020
  3716. + * | TOE Queue 1 Header |
  3717. + * | 8 * 4 Bytes |
  3718. + * +---------------------------+ 0x0040
  3719. + * | ...... |
  3720. + * | |
  3721. + * +---------------------------+
  3722. + *
  3723. + * Non TOE Queue Header
  3724. + * 0x60002000 +---------------------------+ 0x0000
  3725. + * | Default Queue 0 Header |
  3726. + * | 2 * 4 Bytes |
  3727. + * +---------------------------+ 0x0008
  3728. + * | Default Queue 1 Header |
  3729. + * | 2 * 4 Bytes |
  3730. + * +---------------------------+ 0x0010
  3731. + * | Classification Queue 0 |
  3732. + * | 2 * 4 Bytes |
  3733. + * +---------------------------+
  3734. + * | Classification Queue 1 |
  3735. + * | 2 * 4 Bytes |
  3736. + * +---------------------------+ (n * 8 + 0x10)
  3737. + * | ... |
  3738. + * | 2 * 4 Bytes |
  3739. + * +---------------------------+ (13 * 8 + 0x10)
  3740. + * | Classification Queue 13 |
  3741. + * | 2 * 4 Bytes |
  3742. + * +---------------------------+ 0x80
  3743. + * | Interrupt Queue 0 |
  3744. + * | 2 * 4 Bytes |
  3745. + * +---------------------------+
  3746. + * | Interrupt Queue 1 |
  3747. + * | 2 * 4 Bytes |
  3748. + * +---------------------------+
  3749. + * | Interrupt Queue 2 |
  3750. + * | 2 * 4 Bytes |
  3751. + * +---------------------------+
  3752. + * | Interrupt Queue 3 |
  3753. + * | 2 * 4 Bytes |
  3754. + * +---------------------------+
  3755. + *
  3756. + */
  3757. +#define TOE_QUEUE_HDR_ADDR(n) (TOE_TOE_QUE_HDR_BASE + n * 32)
  3758. +#define TOE_Q_HDR_AREA_END (TOE_QUEUE_HDR_ADDR(TOE_TOE_QUEUE_MAX + 1))
  3759. +#define TOE_DEFAULT_Q_HDR_BASE(x) (TOE_NONTOE_QUE_HDR_BASE + 0x08 * (x))
  3760. +#define TOE_CLASS_Q_HDR_BASE (TOE_NONTOE_QUE_HDR_BASE + 0x10)
  3761. +#define TOE_INTR_Q_HDR_BASE (TOE_NONTOE_QUE_HDR_BASE + 0x80)
  3762. +#define INTERRUPT_QUEUE_HDR_ADDR(n) (TOE_INTR_Q_HDR_BASE + n * 8)
  3763. +#define NONTOE_Q_HDR_AREA_END (INTERRUPT_QUEUE_HDR_ADDR(TOE_INTR_QUEUE_MAX + 1))
  3764. +/*
  3765. + * TOE Queue Header Word 0
  3766. + */
  3767. +typedef union {
  3768. + unsigned int bits32;
  3769. + unsigned int base_size;
  3770. +} TOE_QHDR0_T;
  3771. +
  3772. +#define TOE_QHDR0_BASE_MASK (~0x0f)
  3773. +
  3774. +/*
  3775. + * TOE Queue Header Word 1
  3776. + */
  3777. +typedef union {
  3778. + unsigned int bits32;
  3779. + struct bit_qhdr1 {
  3780. + unsigned int rptr : 16; // bit 15:0
  3781. + unsigned int wptr : 16; // bit 31:16
  3782. + } bits;
  3783. +} TOE_QHDR1_T;
  3784. +
  3785. +/*
  3786. + * TOE Queue Header Word 2
  3787. + */
  3788. +typedef union {
  3789. + unsigned int bits32;
  3790. + struct bit_qhdr2 {
  3791. + unsigned int TotalPktSize : 17; // bit 16: 0 Total packet size
  3792. + unsigned int reserved : 7; // bit 23:17
  3793. + unsigned int dack : 1; // bit 24 1: Duplicated ACK
  3794. + unsigned int abn : 1; // bit 25 1: Abnormal case Found
  3795. + unsigned int tcp_opt : 1; // bit 26 1: Have TCP option
  3796. + unsigned int ip_opt : 1; // bit 27 1: have IPV4 option or IPV6 Extension header
  3797. + unsigned int sat : 1; // bit 28 1: SeqCnt > SeqThreshold, or AckCnt > AckThreshold
  3798. + unsigned int osq : 1; // bit 29 1: out of sequence
  3799. + unsigned int ctl : 1; // bit 30 1: have control flag bits (except ack)
  3800. + unsigned int usd : 1; // bit 31 0: if no data assembled yet
  3801. + } bits;
  3802. +} TOE_QHDR2_T;
  3803. +
  3804. +/*
  3805. + * TOE Queue Header Word 3
  3806. + */
  3807. +typedef union {
  3808. + unsigned int bits32;
  3809. + unsigned int seq_num;
  3810. +} TOE_QHDR3_T;
  3811. +
  3812. +/*
  3813. + * TOE Queue Header Word 4
  3814. + */
  3815. +typedef union {
  3816. + unsigned int bits32;
  3817. + unsigned int ack_num;
  3818. +} TOE_QHDR4_T;
  3819. +
  3820. +/*
  3821. + * TOE Queue Header Word 5
  3822. + */
  3823. +typedef union {
  3824. + unsigned int bits32;
  3825. + struct bit_qhdr5 {
  3826. + unsigned int AckCnt : 16; // bit 15:0
  3827. + unsigned int SeqCnt : 16; // bit 31:16
  3828. + } bits;
  3829. +} TOE_QHDR5_T;
  3830. +
  3831. +/*
  3832. + * TOE Queue Header Word 6
  3833. + */
  3834. +typedef union {
  3835. + unsigned int bits32;
  3836. + struct bit_qhdr6 {
  3837. + unsigned int WinSize : 16; // bit 15:0
  3838. + unsigned int iq_num : 2; // bit 17:16
  3839. + unsigned int MaxPktSize : 14; // bit 31:18
  3840. + } bits;
  3841. +} TOE_QHDR6_T;
  3842. +
  3843. +/*
  3844. + * TOE Queue Header Word 7
  3845. + */
  3846. +typedef union {
  3847. + unsigned int bits32;
  3848. + struct bit_qhdr7 {
  3849. + unsigned int AckThreshold : 16; // bit 15:0
  3850. + unsigned int SeqThreshold : 16; // bit 31:16
  3851. + } bits;
  3852. +} TOE_QHDR7_T;
  3853. +
  3854. +/*
  3855. + * TOE Queue Header
  3856. + */
  3857. +typedef struct {
  3858. + TOE_QHDR0_T word0;
  3859. + TOE_QHDR1_T word1;
  3860. + TOE_QHDR2_T word2;
  3861. + TOE_QHDR3_T word3;
  3862. + TOE_QHDR4_T word4;
  3863. + TOE_QHDR5_T word5;
  3864. + TOE_QHDR6_T word6;
  3865. + TOE_QHDR7_T word7;
  3866. +} TOE_QHDR_T;
  3867. +
  3868. +/*
  3869. + * NONTOE Queue Header Word 0
  3870. + */
  3871. +typedef union {
  3872. + unsigned int bits32;
  3873. + unsigned int base_size;
  3874. +} NONTOE_QHDR0_T;
  3875. +
  3876. +#define NONTOE_QHDR0_BASE_MASK (~0x0f)
  3877. +
  3878. +/*
  3879. + * NONTOE Queue Header Word 1
  3880. + */
  3881. +typedef union {
  3882. + unsigned int bits32;
  3883. + struct bit_nonqhdr1 {
  3884. + unsigned int rptr : 16; // bit 15:0
  3885. + unsigned int wptr : 16; // bit 31:16
  3886. + } bits;
  3887. +} NONTOE_QHDR1_T;
  3888. +
  3889. +/*
  3890. + * Non-TOE Queue Header
  3891. + */
  3892. +typedef struct {
  3893. + NONTOE_QHDR0_T word0;
  3894. + NONTOE_QHDR1_T word1;
  3895. +} NONTOE_QHDR_T;
  3896. +
  3897. +/*
  3898. + * Interrupt Queue Header Word 0
  3899. + */
  3900. +typedef union {
  3901. + unsigned int bits32;
  3902. + struct bit_intrqhdr0 {
  3903. + unsigned int win_size : 16; // bit 15:0 Descriptor Ring Size
  3904. + unsigned int wptr : 16; // bit 31:16 Write Pointer where hw stopped
  3905. + } bits;
  3906. +} INTR_QHDR0_T;
  3907. +
  3908. +/*
  3909. + * Interrupt Queue Header Word 1
  3910. + */
  3911. +typedef union {
  3912. + unsigned int bits32;
  3913. + struct bit_intrqhdr1 {
  3914. + unsigned int TotalPktSize : 17; // bit 16: 0 Total packet size
  3915. + unsigned int tcp_qid : 8; // bit 24:17 TCP Queue ID
  3916. + unsigned int dack : 1; // bit 25 1: Duplicated ACK
  3917. + unsigned int abn : 1; // bit 26 1: Abnormal case Found
  3918. + unsigned int tcp_opt : 1; // bit 27 1: Have TCP option
  3919. + unsigned int ip_opt : 1; // bit 28 1: have IPV4 option or IPV6 Extension header
  3920. + unsigned int sat : 1; // bit 29 1: SeqCnt > SeqThreshold, or AckCnt > AckThreshold
  3921. + unsigned int osq : 1; // bit 30 1: out of sequence
  3922. + unsigned int ctl : 1; // bit 31 1: have control flag bits (except ack)
  3923. + } bits;
  3924. +} INTR_QHDR1_T;
  3925. +
  3926. +/*
  3927. + * Interrupt Queue Header Word 2
  3928. + */
  3929. +typedef union {
  3930. + unsigned int bits32;
  3931. + unsigned int seq_num;
  3932. +} INTR_QHDR2_T;
  3933. +
  3934. +/*
  3935. + * Interrupt Queue Header Word 3
  3936. + */
  3937. +typedef union {
  3938. + unsigned int bits32;
  3939. + unsigned int ack_num;
  3940. +} INTR_QHDR3_T;
  3941. +
  3942. +/*
  3943. + * Interrupt Queue Header Word 4
  3944. + */
  3945. +typedef union {
  3946. + unsigned int bits32;
  3947. + struct bit_intrqhdr4 {
  3948. + unsigned int AckCnt : 16; // bit 15:0 Ack# change since last ack# intr.
  3949. + unsigned int SeqCnt : 16; // bit 31:16 Seq# change since last seq# intr.
  3950. + } bits;
  3951. +} INTR_QHDR4_T;
  3952. +
  3953. +/*
  3954. + * Interrupt Queue Header
  3955. + */
  3956. +typedef struct {
  3957. + INTR_QHDR0_T word0;
  3958. + INTR_QHDR1_T word1;
  3959. + INTR_QHDR2_T word2;
  3960. + INTR_QHDR3_T word3;
  3961. + INTR_QHDR4_T word4;
  3962. + unsigned int word5;
  3963. + unsigned int word6;
  3964. + unsigned int word7;
  3965. +} INTR_QHDR_T;
  3966. +
  3967. +/*
  3968. + * GMAC private data
  3969. + */
  3970. +typedef struct {
  3971. + unsigned int rwptr_reg;
  3972. + unsigned int desc_base;
  3973. + unsigned int desc_base_dma;
  3974. + unsigned short finished_idx;
  3975. + struct sk_buff *tx_skb[TOE_GMAC_SWTXQ_DESC_NUM];
  3976. +} GMAC_SWTXQ_T;
  3977. +
  3978. +struct gmac_private {
  3979. + struct phy_device *phydev;
  3980. + unsigned int port_id;
  3981. + unsigned int dma_base_addr;
  3982. + unsigned int swtxq_desc_base;
  3983. + GMAC_SWTXQ_T swtxq[TOE_SW_TXQ_NUM];
  3984. + NONTOE_QHDR_T *default_qhdr;
  3985. + unsigned int default_desc_base;
  3986. + dma_addr_t default_desc_base_dma;
  3987. + dma_addr_t swtxq_desc_base_dma;
  3988. + unsigned int flow_control_enable;
  3989. + unsigned int intr0_enabled;
  3990. + unsigned int intr1_enabled;
  3991. + unsigned int intr2_enabled;
  3992. + unsigned int intr3_enabled;
  3993. + unsigned int intr4_enabled;
  3994. + unsigned int intr0_selected;
  3995. + unsigned int intr1_selected;
  3996. + unsigned int intr2_selected;
  3997. + unsigned int intr3_selected;
  3998. + unsigned int intr4_selected;
  3999. +};
  4000. +
  4001. +struct toe_private {
  4002. + void __iomem *global_base;
  4003. + struct net_device *net_dev[2];
  4004. + struct device *dev;
  4005. + struct work_struct freq_work;
  4006. + spinlock_t freeq_lock;
  4007. + unsigned int swfq_desc_base;
  4008. + unsigned int hwfq_desc_base;
  4009. + unsigned int hwfq_buf_base;
  4010. + dma_addr_t sw_freeq_desc_base_dma;
  4011. + dma_addr_t hw_freeq_desc_base_dma;
  4012. + dma_addr_t hwfq_buf_base_dma;
  4013. + dma_addr_t hwfq_buf_end_dma;
  4014. +};
  4015. +
  4016. +#define GMAC_PORT0 0
  4017. +#define GMAC_PORT1 1
  4018. +
  4019. +#endif /* _GMAC_SL351x_H */
  4020. --- /dev/null
  4021. +++ b/drivers/net/gemini_negmac/Makefile
  4022. @@ -0,0 +1,3 @@
  4023. +obj-$(CONFIG_GEMINI_NET_ENGINE_GMAC)+= gemini_negmac.o
  4024. +
  4025. +gemini_negmac-objs := gm_gmac.o
  4026. --- a/drivers/net/Kconfig
  4027. +++ b/drivers/net/Kconfig
  4028. @@ -2126,6 +2126,13 @@ config ACENIC_OMIT_TIGON_I
  4029. The safe and default value for this is N.
  4030. +config GEMINI_NET_ENGINE_GMAC
  4031. + tristate "Gemini Gigabit Ethernet support"
  4032. + depends on ARCH_GEMINI
  4033. + select PHYLIB
  4034. + help
  4035. + This driver supports Gemini TOE and NAT dual Gigabit Ethernet.
  4036. +
  4037. config DL2K
  4038. tristate "DL2000/TC902x-based Gigabit Ethernet support"
  4039. depends on PCI
  4040. --- a/drivers/net/Makefile
  4041. +++ b/drivers/net/Makefile
  4042. @@ -247,6 +247,7 @@ pasemi_mac_driver-objs := pasemi_mac.o p
  4043. obj-$(CONFIG_MLX4_CORE) += mlx4/
  4044. obj-$(CONFIG_ENC28J60) += enc28j60.o
  4045. obj-$(CONFIG_ETHOC) += ethoc.o
  4046. +obj-$(CONFIG_GEMINI_NET_ENGINE_GMAC) += gemini_negmac/
  4047. obj-$(CONFIG_XTENSA_XT2000_SONIC) += xtsonic.o
  4048. --- /dev/null
  4049. +++ b/drivers/usb/host/ehci-fotg2xx.c
  4050. @@ -0,0 +1,459 @@
  4051. +/*
  4052. + * EHCI Host Controller driver
  4053. + *
  4054. + * Copyright (C) 2006 Sony Computer Entertainment Inc.
  4055. + * Copyright 2006 Sony Corp.
  4056. + *
  4057. + * This program is free software; you can redistribute it and/or modify
  4058. + * it under the terms of the GNU General Public License as published by
  4059. + * the Free Software Foundation; version 2 of the License.
  4060. + */
  4061. +
  4062. +#include <linux/platform_device.h>
  4063. +#include <mach/hardware.h>
  4064. +
  4065. +#define otg_set(port, bits) writel(readl(hcd->regs + port) | bits, hcd->regs + port)
  4066. +
  4067. +#define otg_clear(port, bits) writel(readl(hcd->regs + port) & ~bits, hcd->regs + port)
  4068. +
  4069. +#define GLOBAL_ISR 0xC0
  4070. +#define GLOBAL_ICR 0xC4
  4071. +
  4072. +#define HCD_MISC 0x40
  4073. +
  4074. +#define OTGC_SCR 0x80
  4075. +#define OTGC_INT_EN 0x88
  4076. +
  4077. +#define GLOBAL_INT_POLARITY (1 << 3)
  4078. +#define GLOBAL_INT_MASK_HC (1 << 2)
  4079. +#define GLOBAL_INT_MASK_OTG (1 << 1)
  4080. +#define GLOBAL_INT_MASK_DEV (1 << 0)
  4081. +
  4082. +#define OTGC_SCR_ID (1 << 21)
  4083. +#define OTGC_SCR_CROLE (1 << 20)
  4084. +#define OTGC_SCR_VBUS_VLD (1 << 19)
  4085. +#define OTGC_SCR_A_SRP_RESP_TYPE (1 << 8)
  4086. +#define OTGC_SCR_A_SRP_DET_EN (1 << 7)
  4087. +#define OTGC_SCR_A_SET_B_HNP_EN (1 << 6)
  4088. +#define OTGC_SCR_A_BUS_DROP (1 << 5)
  4089. +#define OTGC_SCR_A_BUS_REQ (1 << 4)
  4090. +
  4091. +#define OTGC_INT_APLGRMV (1 << 12)
  4092. +#define OTGC_INT_BPLGRMV (1 << 11)
  4093. +#define OTGC_INT_OVC (1 << 10)
  4094. +#define OTGC_INT_IDCHG (1 << 9)
  4095. +#define OTGC_INT_RLCHG (1 << 8)
  4096. +#define OTGC_INT_AVBUSERR (1 << 5)
  4097. +#define OTGC_INT_ASRPDET (1 << 4)
  4098. +#define OTGC_INT_BSRPDN (1 << 0)
  4099. +
  4100. +#define OTGC_INT_A_TYPE (OTGC_INT_ASRPDET|OTGC_INT_AVBUSERR|OTGC_INT_OVC|OTGC_INT_RLCHG|OTGC_INT_IDCHG|OTGC_INT_APLGRMV)
  4101. +#define OTGC_INT_B_TYPE (OTGC_INT_AVBUSERR|OTGC_INT_OVC|OTGC_INT_RLCHG|OTGC_INT_IDCHG)
  4102. +
  4103. +static void fotg2xx_otgc_role_change(struct usb_hcd *hcd);
  4104. +
  4105. +static void fotg2xx_otgc_init(struct usb_hcd *hcd)
  4106. +{
  4107. + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
  4108. + unsigned int reg;
  4109. +
  4110. + reg = __raw_readl(hcd->regs + OTGC_SCR);
  4111. + ehci_info(ehci, "role detected: %s, ",
  4112. + (reg & OTGC_SCR_CROLE) ? "Peripheral" : "Host");
  4113. +
  4114. + if (reg & OTGC_SCR_ID)
  4115. + ehci_info(ehci, "B-Device (may be unsupported!)\n");
  4116. + else
  4117. + ehci_info(ehci, "A-Device\n");
  4118. +
  4119. + /* Enable the SRP detect */
  4120. + reg &= ~OTGC_SCR_A_SRP_RESP_TYPE;
  4121. + __raw_writel(reg, hcd->regs + OTGC_SCR);
  4122. +
  4123. + reg = __raw_readl(hcd->regs + OTGC_INT_EN);
  4124. + /* clear INT B: bits AVBUSERR | OVC | RLCHG | IDCHG */
  4125. + reg &= ~OTGC_INT_B_TYPE;
  4126. + /* set INT A: bits ASRPDET | AVBUSERR | OVC | RLCHG | IDCHG | APLGRMV */
  4127. + reg |= OTGC_INT_A_TYPE;
  4128. + __raw_writel(reg, hcd->regs + OTGC_INT_EN);
  4129. +
  4130. + reg = __raw_readl(hcd->regs + GLOBAL_ICR);
  4131. + reg &= ~GLOBAL_INT_MASK_OTG;
  4132. + __raw_writel(reg, hcd->regs + GLOBAL_ICR);
  4133. +
  4134. + /* setup MISC register, fixes timing problems */
  4135. + reg = __raw_readl(hcd->regs + HCD_MISC);
  4136. + reg |= 0xD;
  4137. + __raw_writel(reg, hcd->regs + HCD_MISC);
  4138. +
  4139. + fotg2xx_otgc_role_change(hcd);
  4140. +}
  4141. +
  4142. +static void fotg2xx_otgh_close(struct usb_hcd *hcd)
  4143. +{
  4144. + unsigned int reg;
  4145. +
  4146. + /* <1>.Enable Interrupt Mask */
  4147. + reg = __raw_readl(hcd->regs + GLOBAL_ICR);
  4148. + reg |= GLOBAL_INT_MASK_HC;
  4149. + __raw_writel(reg, hcd->regs + GLOBAL_ICR);
  4150. +
  4151. + /* <2>.Clear the Interrupt status */
  4152. + reg = __raw_readl(hcd->regs + 0x18);
  4153. + reg &= 0x0000003F;
  4154. + __raw_writel(reg, hcd->regs + 0x14);
  4155. +}
  4156. +
  4157. +static void fotg2xx_otgh_open(struct usb_hcd *hcd)
  4158. +{
  4159. + unsigned int reg;
  4160. +
  4161. + reg = __raw_readl(hcd->regs + OTGC_SCR);
  4162. + reg &= ~OTGC_SCR_A_SRP_DET_EN;
  4163. + __raw_writel(reg, hcd->regs + OTGC_SCR);
  4164. +
  4165. + reg = __raw_readl(hcd->regs + GLOBAL_ICR);
  4166. + reg &= ~GLOBAL_INT_MASK_HC;
  4167. + __raw_writel(reg, hcd->regs + GLOBAL_ICR);
  4168. +}
  4169. +
  4170. +/* change to host role */
  4171. +static void fotg2xx_otgc_role_change(struct usb_hcd *hcd)
  4172. +{
  4173. +
  4174. + /* clear A_SET_B_HNP_EN */
  4175. + otg_clear(0x80, BIT(6));
  4176. +
  4177. + /*** Enable VBUS driving */
  4178. + if (readl(hcd->regs + 0x80) & BIT(19))
  4179. + printk(KERN_INFO "VBUS already enabled\n");
  4180. + else {
  4181. + int cnt = 0;
  4182. +
  4183. + /* clear A_BUS_DROP */
  4184. + otg_clear(0x80, BIT(5));
  4185. +
  4186. + /* set A_BUS_REQ */
  4187. + otg_set(0x80, BIT(4));
  4188. +
  4189. + /* set global bus reg to VBUS on */
  4190. + writel(readl(IO_ADDRESS(0x40000000) + 0x30) | ((BIT(21)|BIT(22))),
  4191. + IO_ADDRESS(0x40000000) + 0x30);
  4192. +
  4193. + if (readl(hcd->regs + 0x80) & (1<<19)) {
  4194. + printk(KERN_INFO "Waiting for VBus");
  4195. + while (!(readl(hcd->regs + 0x80) & (1<<19)) && (cnt < 80)) {
  4196. + printk(KERN_CONT ".");
  4197. + cnt++;
  4198. + }
  4199. + printk(KERN_CONT "\n");
  4200. + } else
  4201. + printk(KERN_INFO "VBUS enabled.\n");
  4202. +
  4203. + mdelay(1);
  4204. + }
  4205. + fotg2xx_otgh_open(hcd);
  4206. +}
  4207. +
  4208. +static int fotg2xx_ehci_hc_reset(struct usb_hcd *hcd)
  4209. +{
  4210. + int result;
  4211. + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
  4212. +
  4213. + ehci->caps = hcd->regs;
  4214. + ehci->regs = hcd->regs + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
  4215. +
  4216. + dbg_hcs_params(ehci, "reset");
  4217. + dbg_hcc_params(ehci, "reset");
  4218. +
  4219. + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
  4220. + hcd->has_tt = 1;
  4221. +
  4222. + result = ehci_halt(ehci);
  4223. + if (result)
  4224. + return result;
  4225. +
  4226. + result = ehci_init(hcd);
  4227. + if (result)
  4228. + return result;
  4229. +
  4230. + ehci_port_power(ehci, 0);
  4231. +
  4232. + return result;
  4233. +}
  4234. +
  4235. +/*
  4236. + * Name: OTGC_INT_ISR
  4237. + * Description:This interrupt service routine belongs to the OTG-Controller
  4238. + * <1>.Check for ID_Change
  4239. + * <2>.Check for RL_Change
  4240. + * <3>.Error Detect
  4241. + * Input: wINTStatus
  4242. + * Output:void
  4243. + */
  4244. +void fotg2xx_int_isr(struct usb_hcd *hcd, u32 wINTStatus)
  4245. +{
  4246. + /* <1>.Check for ID_Change */
  4247. + if (wINTStatus&OTGC_INT_IDCHG) {
  4248. + if ((readl(hcd->regs + 0x80) & BIT(21)) != 0)
  4249. + fotg2xx_otgc_init(hcd); /* Change to B Type */
  4250. + else
  4251. + fotg2xx_otgc_init(hcd); /* Change to A Type */
  4252. +
  4253. + return;
  4254. + }
  4255. +
  4256. + /* <2>.Check for RL_Change */
  4257. + if (wINTStatus&OTGC_INT_RLCHG)
  4258. + fotg2xx_otgc_role_change(hcd);
  4259. +
  4260. + /* <3>.Error Detect */
  4261. + if (wINTStatus&OTGC_INT_AVBUSERR)
  4262. + printk(KERN_ERR "VBus error!\n");
  4263. +
  4264. + if (wINTStatus&OTGC_INT_OVC)
  4265. + printk(KERN_WARNING "Overcurrent detected!\n");
  4266. +
  4267. + /* <3>.Check for Type-A/Type-B Interrupt */
  4268. + if ((readl(hcd->regs + 0x80) & BIT(21)) == 0) { /*For Type-A Interrupt*/
  4269. + if (wINTStatus & (OTGC_INT_A_TYPE | OTGC_INT_ASRPDET)) {
  4270. + /* <1>.SRP detected => then set global variable */
  4271. + printk(KERN_WARNING "SRP detected, but not implemented!\n");
  4272. +
  4273. +#if 0
  4274. + u32 wTempCounter;
  4275. + /* <2>.Turn on the V Bus */
  4276. + pFTC_OTG->otg.state = OTG_STATE_A_WAIT_VRISE;
  4277. + OTGC_enable_vbus_draw_storlink(1);
  4278. + pFTC_OTG->otg.state = OTG_STATE_A_HOST;
  4279. + /* <3>.Should waiting for Device-Connect Wait 300ms */
  4280. + INFO(pFTC_OTG, ">>> OTG-A Waiting for OTG-B Connect,\n");
  4281. + wTempCounter = 0;
  4282. + while (mwHost20_PORTSC_ConnectStatus_Rd() == 0) {
  4283. + mdelay(1);
  4284. + wTempCounter++;
  4285. + /* Waiting for 300 ms */
  4286. + if (wTempCounter > 300) {
  4287. + mdwOTGC_Control_A_SRP_DET_EN_Clr();
  4288. + INFO(pFTC_OTG, ">>> OTG-B do not connect under 300 ms...\n");
  4289. + break;
  4290. + }
  4291. + }
  4292. + /* <4>.If Connect => issue quick Reset */
  4293. + if (mwHost20_PORTSC_ConnectStatus_Rd() > 0) {
  4294. + mdelay(300); /* For OPT-A Test */
  4295. + OTGH_host_quick_Reset();
  4296. + OTGH_Open();
  4297. + pFTC_OTG->otg.host->A_Disable_Set_Feature_HNP = 0;
  4298. + }
  4299. +#endif
  4300. + }
  4301. + } else { /* For Type-B Interrupt */
  4302. + BUG();
  4303. + }
  4304. +}
  4305. +
  4306. +static irqreturn_t fotg2xx_ehci_irq(int irq, void *devid)
  4307. +{
  4308. + struct usb_hcd *hcd = devid;
  4309. + u32 val;
  4310. +
  4311. + /* OTG Interrupt Status Register */
  4312. + val = readl(hcd->regs + 0x84);
  4313. +
  4314. + /* OTG stuff */
  4315. + if (val) {
  4316. + /* supposed to do "INT STS Clr" - XXX */
  4317. + writel(readl(hcd->regs + 0x84) | val, hcd->regs + 0x84);
  4318. +
  4319. + fotg2xx_int_isr(hcd, val);
  4320. +
  4321. + /* supposed to do "INT STS Clr" - XXX */
  4322. + writel(readl(hcd->regs + 0x84) | val, hcd->regs + 0x84);
  4323. +
  4324. + return IRQ_HANDLED;
  4325. + }
  4326. +
  4327. + if ((readl(hcd->regs + 0x80) & BIT(20)) == 0) { /* Role is HOST */
  4328. + if (readl(hcd->regs + 0xC0) & BIT(2)) { /* INT STS HOST */
  4329. + /* leave this for ehci irq handler */
  4330. + return IRQ_NONE;
  4331. + }
  4332. + } else
  4333. + printk(KERN_WARNING
  4334. + "received irq for peripheral - don't know what to do!\n");
  4335. +
  4336. + /* do not call the ehci irq handler */
  4337. + return IRQ_HANDLED;
  4338. +}
  4339. +
  4340. +static int fotg2xx_ehci_run(struct usb_hcd *hcd)
  4341. +{
  4342. + int retval;
  4343. +
  4344. + retval = ehci_run(hcd);
  4345. +
  4346. + fotg2xx_otgh_close(hcd);
  4347. + fotg2xx_otgc_init(hcd);
  4348. +
  4349. + return retval;
  4350. +}
  4351. +
  4352. +static const struct hc_driver fotg2xx_ehci_hc_driver = {
  4353. + .description = hcd_name,
  4354. + .product_desc = "FOTG2XX EHCI Host Controller",
  4355. + .hcd_priv_size = sizeof(struct ehci_hcd),
  4356. + .irq = ehci_irq,
  4357. + .flags = HCD_MEMORY | HCD_USB2,
  4358. + .reset = fotg2xx_ehci_hc_reset,
  4359. + .start = fotg2xx_ehci_run,
  4360. + .stop = ehci_stop,
  4361. + .shutdown = ehci_shutdown,
  4362. + .urb_enqueue = ehci_urb_enqueue,
  4363. + .urb_dequeue = ehci_urb_dequeue,
  4364. + .endpoint_disable = ehci_endpoint_disable,
  4365. + .get_frame_number = ehci_get_frame,
  4366. + .hub_status_data = ehci_hub_status_data,
  4367. + .hub_control = ehci_hub_control,
  4368. +#if defined(CONFIG_PM)
  4369. + .bus_suspend = ehci_bus_suspend,
  4370. + .bus_resume = ehci_bus_resume,
  4371. +#endif
  4372. + .relinquish_port = ehci_relinquish_port,
  4373. + .port_handed_over = ehci_port_handed_over,
  4374. +};
  4375. +
  4376. +static int fotg2xx_ehci_probe(struct platform_device *pdev)
  4377. +{
  4378. + const struct hc_driver *driver = &fotg2xx_ehci_hc_driver;
  4379. + struct usb_hcd *hcd;
  4380. + struct resource *res;
  4381. + int irq;
  4382. + int retval;
  4383. +
  4384. + pr_debug("initializing FOTG2XX-SOC USB Controller\n");
  4385. +
  4386. + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  4387. + if (!res) {
  4388. + dev_err(&pdev->dev,
  4389. + "Found HC with no IRQ. Check %s setup!\n",
  4390. + dev_name(&pdev->dev));
  4391. + return -ENODEV;
  4392. + }
  4393. +
  4394. + irq = res->start;
  4395. +
  4396. + hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
  4397. + if (!hcd) {
  4398. + retval = -ENOMEM;
  4399. + goto err1;
  4400. + }
  4401. +
  4402. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  4403. + if (!res) {
  4404. + dev_err(&pdev->dev,
  4405. + "Found HC with no register addr. Check %s setup!\n",
  4406. + dev_name(&pdev->dev));
  4407. + retval = -ENODEV;
  4408. + goto err2;
  4409. + }
  4410. +
  4411. + hcd->rsrc_start = res->start;
  4412. + hcd->rsrc_len = res->end - res->start + 1;
  4413. + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
  4414. + driver->description)) {
  4415. + dev_dbg(&pdev->dev, "controller already in use\n");
  4416. + retval = -EBUSY;
  4417. + goto err2;
  4418. + }
  4419. +
  4420. + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
  4421. + if (hcd->regs == NULL) {
  4422. + dev_dbg(&pdev->dev, "error mapping memory\n");
  4423. + retval = -EFAULT;
  4424. + goto err3;
  4425. + }
  4426. +
  4427. +
  4428. + /* set global reg to mini-A host */
  4429. + writel(readl(IO_ADDRESS(0x40000000) + 0x30) & ~(BIT(30)|BIT(29)),
  4430. + IO_ADDRESS(0x40000000) + 0x30);
  4431. +
  4432. + /* USB0&USB1 - VBUS off */
  4433. + writel(readl(IO_ADDRESS(0x40000000) + 0x30) & ~(BIT(21)|BIT(22)),
  4434. + IO_ADDRESS(0x40000000) + 0x30);
  4435. +
  4436. + if ((readl(hcd->regs) == 0x01000010) &&
  4437. + (readl(hcd->regs + 4) == 0x00000001) &&
  4438. + (readl(hcd->regs + 8) == 0x00000006)) {
  4439. + dev_info(&pdev->dev,
  4440. + "Found Faraday OTG 2XX controller (base = 0x%08lX)\n",
  4441. + (unsigned long) hcd->rsrc_start);
  4442. + } else {
  4443. + dev_err(&pdev->dev, "fotg2xx id mismatch: found %d.%d.%d\n",
  4444. + readl(hcd->regs + 0x00),
  4445. + readl(hcd->regs + 0x04),
  4446. + readl(hcd->regs + 0x08));
  4447. + retval = -ENODEV;
  4448. + goto err4;
  4449. + }
  4450. +
  4451. + platform_set_drvdata(pdev, hcd);
  4452. +
  4453. + /* mask interrupts - peripheral, otg, host, hi-active (bits 0,1,2,3) */
  4454. + otg_set(0xc4, BIT(3)); /* hi active */
  4455. +
  4456. + otg_set(0xc4, BIT(2)); /* host */
  4457. + otg_set(0xc4, BIT(1)); /* otg */
  4458. + otg_set(0xc4, BIT(0)); /* peripheral */
  4459. +
  4460. + /* register additional interrupt - here we check otg status */
  4461. + if ((request_irq(irq, &fotg2xx_ehci_irq, IRQF_SHARED | IRQF_DISABLED,
  4462. + hcd->irq_descr, hcd)) != 0) {
  4463. + dev_dbg(&pdev->dev, "error requesting irq %d\n", irq);
  4464. + retval = -EFAULT;
  4465. + goto err4;
  4466. + }
  4467. +
  4468. + retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
  4469. + if (retval != 0)
  4470. + goto err4;
  4471. + return retval;
  4472. +
  4473. +err4:
  4474. + iounmap(hcd->regs);
  4475. +err3:
  4476. + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  4477. +err2:
  4478. + usb_put_hcd(hcd);
  4479. +err1:
  4480. + dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev), retval);
  4481. + return retval;
  4482. +}
  4483. +
  4484. +/* may be called without controller electrically present */
  4485. +/* may be called with controller, bus, and devices active */
  4486. +
  4487. +int fotg2xx_ehci_remove(struct platform_device *pdev)
  4488. +{
  4489. + struct usb_hcd *hcd =
  4490. + (struct usb_hcd *)platform_get_drvdata(pdev);
  4491. +
  4492. + usb_remove_hcd(hcd);
  4493. + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  4494. + iounmap(hcd->regs);
  4495. + usb_put_hcd(hcd);
  4496. + platform_set_drvdata(pdev, NULL);
  4497. +
  4498. + return 0;
  4499. +}
  4500. +
  4501. +MODULE_ALIAS("platform:ehci-fotg2xx");
  4502. +
  4503. +static struct platform_driver fotg2xx_ehci_driver = {
  4504. + .probe = fotg2xx_ehci_probe,
  4505. + .remove = fotg2xx_ehci_remove,
  4506. + .driver = {
  4507. + .name = "ehci-fotg2xx",
  4508. + },
  4509. +};
  4510. --- a/drivers/usb/host/ehci.h
  4511. +++ b/drivers/usb/host/ehci.h
  4512. @@ -552,7 +552,12 @@ static inline unsigned int
  4513. ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc)
  4514. {
  4515. if (ehci_is_TDI(ehci)) {
  4516. +#ifdef CONFIG_ARCH_GEMINI
  4517. + portsc = readl(ehci_to_hcd(ehci)->regs + 0x80);
  4518. + switch ((portsc>>22)&3) {
  4519. +#else
  4520. switch ((portsc >> (ehci->has_hostpc ? 25 : 26)) & 3) {
  4521. +#endif
  4522. case 0:
  4523. return 0;
  4524. case 1:
  4525. --- a/drivers/usb/host/ehci-hcd.c
  4526. +++ b/drivers/usb/host/ehci-hcd.c
  4527. @@ -194,9 +194,11 @@ static int ehci_halt (struct ehci_hcd *e
  4528. if ((temp & STS_HALT) != 0)
  4529. return 0;
  4530. +#ifndef CONFIG_ARCH_GEMINI
  4531. temp = ehci_readl(ehci, &ehci->regs->command);
  4532. temp &= ~CMD_RUN;
  4533. ehci_writel(ehci, temp, &ehci->regs->command);
  4534. +#endif
  4535. return handshake (ehci, &ehci->regs->status,
  4536. STS_HALT, STS_HALT, 16 * 125);
  4537. }
  4538. @@ -263,8 +265,8 @@ static int ehci_reset (struct ehci_hcd *
  4539. if (retval)
  4540. return retval;
  4541. - if (ehci_is_TDI(ehci))
  4542. - tdi_reset (ehci);
  4543. +// if (ehci_is_TDI(ehci))
  4544. +// tdi_reset (ehci);
  4545. if (ehci->debug)
  4546. dbgp_external_startup();
  4547. @@ -397,12 +399,13 @@ static void ehci_silence_controller(stru
  4548. {
  4549. ehci_halt(ehci);
  4550. ehci_turn_off_all_ports(ehci);
  4551. -
  4552. +#ifndef CONFIG_ARCH_GEMINI
  4553. /* make BIOS/etc use companion controller during reboot */
  4554. ehci_writel(ehci, 0, &ehci->regs->configured_flag);
  4555. /* unblock posted writes */
  4556. ehci_readl(ehci, &ehci->regs->configured_flag);
  4557. +#endif
  4558. }
  4559. /* ehci_shutdown kick in for silicon on any bus (not just pci, etc).
  4560. @@ -653,7 +656,9 @@ static int ehci_run (struct usb_hcd *hcd
  4561. // Philips, Intel, and maybe others need CMD_RUN before the
  4562. // root hub will detect new devices (why?); NEC doesn't
  4563. ehci->command &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET);
  4564. +#ifndef CONFIG_ARCH_GEMINI
  4565. ehci->command |= CMD_RUN;
  4566. +#endif
  4567. ehci_writel(ehci, ehci->command, &ehci->regs->command);
  4568. dbg_cmd (ehci, "init", ehci->command);
  4569. @@ -673,9 +678,11 @@ static int ehci_run (struct usb_hcd *hcd
  4570. */
  4571. down_write(&ehci_cf_port_reset_rwsem);
  4572. hcd->state = HC_STATE_RUNNING;
  4573. +#ifndef CONFIG_ARCH_GEMINI
  4574. ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
  4575. ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
  4576. msleep(5);
  4577. +#endif
  4578. up_write(&ehci_cf_port_reset_rwsem);
  4579. ehci->last_periodic_enable = ktime_get_real();
  4580. @@ -767,9 +774,10 @@ static irqreturn_t ehci_irq (struct usb_
  4581. pcd_status = status;
  4582. /* resume root hub? */
  4583. +#ifndef CONFIG_ARCH_GEMINI
  4584. if (!(cmd & CMD_RUN))
  4585. usb_hcd_resume_root_hub(hcd);
  4586. -
  4587. +#endif
  4588. while (i--) {
  4589. int pstatus = ehci_readl(ehci,
  4590. &ehci->regs->port_status [i]);
  4591. @@ -802,7 +810,9 @@ static irqreturn_t ehci_irq (struct usb_
  4592. ehci_halt(ehci);
  4593. dead:
  4594. ehci_reset(ehci);
  4595. +#ifndef CONFIG_ARCH_GEMINI
  4596. ehci_writel(ehci, 0, &ehci->regs->configured_flag);
  4597. +#endif
  4598. /* generic layer kills/unlinks all urbs, then
  4599. * uses ehci_stop to clean up the rest
  4600. */
  4601. @@ -1101,6 +1111,11 @@ MODULE_LICENSE ("GPL");
  4602. #define PCI_DRIVER ehci_pci_driver
  4603. #endif
  4604. +#ifdef CONFIG_ARCH_GEMINI
  4605. +#include "ehci-fotg2xx.c"
  4606. +#define PLATFORM_DRIVER fotg2xx_ehci_driver
  4607. +#endif
  4608. +
  4609. #ifdef CONFIG_USB_EHCI_FSL
  4610. #include "ehci-fsl.c"
  4611. #define PLATFORM_DRIVER ehci_fsl_driver
  4612. --- a/drivers/usb/host/ehci-hub.c
  4613. +++ b/drivers/usb/host/ehci-hub.c
  4614. @@ -809,6 +809,12 @@ static int ehci_hub_control (
  4615. /* see what we found out */
  4616. temp = check_reset_complete (ehci, wIndex, status_reg,
  4617. ehci_readl(ehci, status_reg));
  4618. +#ifdef CONFIG_ARCH_GEMINI
  4619. + /* restart schedule */
  4620. + ehci_writel(ehci, ehci_readl(ehci, &ehci->regs->command) | CMD_RUN, &ehci->regs->command);
  4621. +
  4622. +// hcd->state = HC_STATE_RUNNING;
  4623. +#endif
  4624. }
  4625. if (!(temp & (PORT_RESUME|PORT_RESET)))
  4626. --- a/drivers/usb/Kconfig
  4627. +++ b/drivers/usb/Kconfig
  4628. @@ -60,6 +60,7 @@ config USB_ARCH_HAS_EHCI
  4629. default y if ARCH_IXP4XX
  4630. default y if ARCH_W90X900
  4631. default y if ARCH_AT91SAM9G45
  4632. + default y if ARCH_GEMINI
  4633. default PCI
  4634. # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
  4635. --- /dev/null
  4636. +++ b/drivers/watchdog/gemini_wdt.c
  4637. @@ -0,0 +1,368 @@
  4638. +/*
  4639. + * Watchdog driver for Cortina Systems Gemini SoC
  4640. + *
  4641. + * Copyright (C) 2009 Paulius Zaleckas <[email protected]>
  4642. + *
  4643. + * This program is free software; you can redistribute it and/or modify
  4644. + * it under the terms of the GNU General Public License version 2 as
  4645. + * published by the Free Software Foundation.
  4646. + */
  4647. +
  4648. +#include <linux/kernel.h>
  4649. +#include <linux/init.h>
  4650. +#include <linux/io.h>
  4651. +#include <linux/fs.h>
  4652. +#include <linux/uaccess.h>
  4653. +#include <linux/miscdevice.h>
  4654. +#include <linux/platform_device.h>
  4655. +#include <linux/watchdog.h>
  4656. +
  4657. +#define GEMINI_WDCOUNTER 0x0
  4658. +#define GEMINI_WDLOAD 0x4
  4659. +#define GEMINI_WDRESTART 0x8
  4660. +
  4661. +#define WDRESTART_MAGIC 0x5AB9
  4662. +
  4663. +#define GEMINI_WDCR 0xC
  4664. +
  4665. +#define WDCR_CLOCK_5MHZ (1 << 4)
  4666. +#define WDCR_SYS_RST (1 << 1)
  4667. +#define WDCR_ENABLE (1 << 0)
  4668. +
  4669. +#define WDT_CLOCK 5000000 /* 5 MHz */
  4670. +#define WDT_DEFAULT_TIMEOUT 13
  4671. +#define WDT_MAX_TIMEOUT (0xFFFFFFFF / WDT_CLOCK)
  4672. +
  4673. +/* status bits */
  4674. +#define WDT_ACTIVE 0
  4675. +#define WDT_OK_TO_CLOSE 1
  4676. +
  4677. +static unsigned int timeout = WDT_DEFAULT_TIMEOUT;
  4678. +static int nowayout = WATCHDOG_NOWAYOUT;
  4679. +
  4680. +static DEFINE_SPINLOCK(gemini_wdt_lock);
  4681. +
  4682. +static struct platform_device *gemini_wdt_dev;
  4683. +
  4684. +struct gemini_wdt_struct {
  4685. + struct resource *res;
  4686. + struct device *dev;
  4687. + void __iomem *base;
  4688. + unsigned long status;
  4689. +};
  4690. +
  4691. +static struct watchdog_info gemini_wdt_info = {
  4692. + .identity = "Gemini watchdog",
  4693. + .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING |
  4694. + WDIOF_SETTIMEOUT,
  4695. +};
  4696. +
  4697. +/* Disable the watchdog. */
  4698. +static void gemini_wdt_stop(struct gemini_wdt_struct *gemini_wdt)
  4699. +{
  4700. + spin_lock(&gemini_wdt_lock);
  4701. +
  4702. + __raw_writel(0, gemini_wdt->base + GEMINI_WDCR);
  4703. +
  4704. + clear_bit(WDT_ACTIVE, &gemini_wdt->status);
  4705. +
  4706. + spin_unlock(&gemini_wdt_lock);
  4707. +}
  4708. +
  4709. +/* Service the watchdog */
  4710. +static void gemini_wdt_service(struct gemini_wdt_struct *gemini_wdt)
  4711. +{
  4712. + __raw_writel(WDRESTART_MAGIC, gemini_wdt->base + GEMINI_WDRESTART);
  4713. +}
  4714. +
  4715. +/* Enable and reset the watchdog. */
  4716. +static void gemini_wdt_start(struct gemini_wdt_struct *gemini_wdt)
  4717. +{
  4718. + spin_lock(&gemini_wdt_lock);
  4719. +
  4720. + __raw_writel(timeout * WDT_CLOCK, gemini_wdt->base + GEMINI_WDLOAD);
  4721. +
  4722. + gemini_wdt_service(gemini_wdt);
  4723. +
  4724. + /* set clock before enabling */
  4725. + __raw_writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST,
  4726. + gemini_wdt->base + GEMINI_WDCR);
  4727. +
  4728. + __raw_writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST | WDCR_ENABLE,
  4729. + gemini_wdt->base + GEMINI_WDCR);
  4730. +
  4731. + set_bit(WDT_ACTIVE, &gemini_wdt->status);
  4732. +
  4733. + spin_unlock(&gemini_wdt_lock);
  4734. +}
  4735. +
  4736. +/* Watchdog device is opened, and watchdog starts running. */
  4737. +static int gemini_wdt_open(struct inode *inode, struct file *file)
  4738. +{
  4739. + struct gemini_wdt_struct *gemini_wdt = platform_get_drvdata(gemini_wdt_dev);
  4740. +
  4741. + if (test_bit(WDT_ACTIVE, &gemini_wdt->status))
  4742. + return -EBUSY;
  4743. +
  4744. + file->private_data = gemini_wdt;
  4745. +
  4746. + gemini_wdt_start(gemini_wdt);
  4747. +
  4748. + return nonseekable_open(inode, file);
  4749. +}
  4750. +
  4751. +/* Close the watchdog device. */
  4752. +static int gemini_wdt_close(struct inode *inode, struct file *file)
  4753. +{
  4754. + struct gemini_wdt_struct *gemini_wdt = file->private_data;
  4755. +
  4756. + /* Disable the watchdog if possible */
  4757. + if (test_bit(WDT_OK_TO_CLOSE, &gemini_wdt->status))
  4758. + gemini_wdt_stop(gemini_wdt);
  4759. + else
  4760. + dev_warn(gemini_wdt->dev, "Device closed unexpectedly - timer will not stop\n");
  4761. +
  4762. + return 0;
  4763. +}
  4764. +
  4765. +/* Handle commands from user-space. */
  4766. +static int gemini_wdt_ioctl(struct inode *inode, struct file *file,
  4767. + unsigned int cmd, unsigned long arg)
  4768. +{
  4769. + struct gemini_wdt_struct *gemini_wdt = file->private_data;
  4770. +
  4771. + int value;
  4772. +
  4773. + switch (cmd) {
  4774. + case WDIOC_KEEPALIVE:
  4775. + gemini_wdt_service(gemini_wdt);
  4776. + return 0;
  4777. +
  4778. + case WDIOC_GETSUPPORT:
  4779. + return copy_to_user((struct watchdog_info *)arg, &gemini_wdt_info,
  4780. + sizeof(gemini_wdt_info)) ? -EFAULT : 0;
  4781. +
  4782. + case WDIOC_SETTIMEOUT:
  4783. + if (get_user(value, (int *)arg))
  4784. + return -EFAULT;
  4785. +
  4786. + if ((value < 1) || (value > WDT_MAX_TIMEOUT))
  4787. + return -EINVAL;
  4788. +
  4789. + timeout = value;
  4790. +
  4791. + /* restart wdt to use new timeout */
  4792. + gemini_wdt_stop(gemini_wdt);
  4793. + gemini_wdt_start(gemini_wdt);
  4794. +
  4795. + /* Fall through */
  4796. + case WDIOC_GETTIMEOUT:
  4797. + return put_user(timeout, (int *)arg);
  4798. +
  4799. + case WDIOC_GETTIMELEFT:
  4800. + value = __raw_readl(gemini_wdt->base + GEMINI_WDCOUNTER);
  4801. + return put_user(value / WDT_CLOCK, (int *)arg);
  4802. +
  4803. + default:
  4804. + return -ENOTTY;
  4805. + }
  4806. +}
  4807. +
  4808. +/* Refresh the watchdog whenever device is written to. */
  4809. +static ssize_t gemini_wdt_write(struct file *file, const char *data,
  4810. + size_t len, loff_t *ppos)
  4811. +{
  4812. + struct gemini_wdt_struct *gemini_wdt = file->private_data;
  4813. +
  4814. + if (len) {
  4815. + if (!nowayout) {
  4816. + size_t i;
  4817. +
  4818. + clear_bit(WDT_OK_TO_CLOSE, &gemini_wdt->status);
  4819. + for (i = 0; i != len; i++) {
  4820. + char c;
  4821. +
  4822. + if (get_user(c, data + i))
  4823. + return -EFAULT;
  4824. + if (c == 'V')
  4825. + set_bit(WDT_OK_TO_CLOSE,
  4826. + &gemini_wdt->status);
  4827. + }
  4828. + }
  4829. + gemini_wdt_service(gemini_wdt);
  4830. + }
  4831. +
  4832. + return len;
  4833. +}
  4834. +
  4835. +static const struct file_operations gemini_wdt_fops = {
  4836. + .owner = THIS_MODULE,
  4837. + .llseek = no_llseek,
  4838. + .ioctl = gemini_wdt_ioctl,
  4839. + .open = gemini_wdt_open,
  4840. + .release = gemini_wdt_close,
  4841. + .write = gemini_wdt_write,
  4842. +};
  4843. +
  4844. +static struct miscdevice gemini_wdt_miscdev = {
  4845. + .minor = WATCHDOG_MINOR,
  4846. + .name = "watchdog",
  4847. + .fops = &gemini_wdt_fops,
  4848. +};
  4849. +
  4850. +static void gemini_wdt_shutdown(struct platform_device *pdev)
  4851. +{
  4852. + struct gemini_wdt_struct *gemini_wdt = platform_get_drvdata(pdev);
  4853. +
  4854. + gemini_wdt_stop(gemini_wdt);
  4855. +}
  4856. +
  4857. +static int __init gemini_wdt_probe(struct platform_device *pdev)
  4858. +{
  4859. + int ret;
  4860. + int res_size;
  4861. + struct resource *res;
  4862. + void __iomem *base;
  4863. + struct gemini_wdt_struct *gemini_wdt;
  4864. +
  4865. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  4866. + if (!res) {
  4867. + dev_err(&pdev->dev, "can't get device resources\n");
  4868. + return -ENODEV;
  4869. + }
  4870. +
  4871. + res_size = resource_size(res);
  4872. + if (!request_mem_region(res->start, res_size, res->name)) {
  4873. + dev_err(&pdev->dev, "can't allocate %d bytes at %d address\n",
  4874. + res_size, res->start);
  4875. + return -ENOMEM;
  4876. + }
  4877. +
  4878. + base = ioremap(res->start, res_size);
  4879. + if (!base) {
  4880. + dev_err(&pdev->dev, "ioremap failed\n");
  4881. + ret = -EIO;
  4882. + goto fail0;
  4883. + }
  4884. +
  4885. + gemini_wdt = kzalloc(sizeof(struct gemini_wdt_struct), GFP_KERNEL);
  4886. + if (!gemini_wdt) {
  4887. + dev_err(&pdev->dev, "can't allocate interface\n");
  4888. + ret = -ENOMEM;
  4889. + goto fail1;
  4890. + }
  4891. +
  4892. + /* Setup gemini_wdt driver structure */
  4893. + gemini_wdt->base = base;
  4894. + gemini_wdt->res = res;
  4895. +
  4896. + /* Set up platform driver data */
  4897. + platform_set_drvdata(pdev, gemini_wdt);
  4898. + gemini_wdt_dev = pdev;
  4899. +
  4900. + if (gemini_wdt_miscdev.parent) {
  4901. + ret = -EBUSY;
  4902. + goto fail2;
  4903. + }
  4904. +
  4905. + gemini_wdt_miscdev.parent = &pdev->dev;
  4906. +
  4907. + ret = misc_register(&gemini_wdt_miscdev);
  4908. + if (ret)
  4909. + goto fail2;
  4910. +
  4911. + return 0;
  4912. +
  4913. +fail2:
  4914. + platform_set_drvdata(pdev, NULL);
  4915. + kfree(gemini_wdt);
  4916. +fail1:
  4917. + iounmap(base);
  4918. +fail0:
  4919. + release_mem_region(res->start, res_size);
  4920. +
  4921. + return ret;
  4922. +}
  4923. +
  4924. +static int __exit gemini_wdt_remove(struct platform_device *pdev)
  4925. +{
  4926. + struct gemini_wdt_struct *gemini_wdt = platform_get_drvdata(pdev);
  4927. +
  4928. + platform_set_drvdata(pdev, NULL);
  4929. + misc_deregister(&gemini_wdt_miscdev);
  4930. + gemini_wdt_dev = NULL;
  4931. + iounmap(gemini_wdt->base);
  4932. + release_mem_region(gemini_wdt->res->start, resource_size(gemini_wdt->res));
  4933. +
  4934. + kfree(gemini_wdt);
  4935. +
  4936. + return 0;
  4937. +}
  4938. +
  4939. +#ifdef CONFIG_PM
  4940. +static int gemini_wdt_suspend(struct platform_device *pdev, pm_message_t message)
  4941. +{
  4942. + struct gemini_wdt_struct *gemini_wdt = platform_get_drvdata(pdev);
  4943. + unsigned int reg;
  4944. +
  4945. + reg = __raw_readw(gemini_wdt->base + GEMINI_WDCR);
  4946. + reg &= ~(WDCR_WDENABLE);
  4947. + __raw_writel(reg, gemini_wdt->base + GEMINI_WDCR);
  4948. +
  4949. + return 0;
  4950. +}
  4951. +
  4952. +static int gemini_wdt_resume(struct platform_device *pdev)
  4953. +{
  4954. + struct gemini_wdt_struct *gemini_wdt = platform_get_drvdata(pdev);
  4955. + unsigned int reg;
  4956. +
  4957. + if (gemini_wdt->status) {
  4958. + reg = __raw_readw(gemini_wdt->base + GEMINI_WDCR);
  4959. + reg |= WDCR_WDENABLE;
  4960. + __raw_writel(reg, gemini_wdt->base + GEMINI_WDCR);
  4961. + }
  4962. +
  4963. + return 0;
  4964. +}
  4965. +#else
  4966. +#define gemini_wdt_suspend NULL
  4967. +#define gemini_wdt_resume NULL
  4968. +#endif
  4969. +
  4970. +static struct platform_driver gemini_wdt_driver = {
  4971. + .probe = gemini_wdt_probe,
  4972. + .remove = __exit_p(gemini_wdt_remove),
  4973. + .shutdown = gemini_wdt_shutdown,
  4974. + .suspend = gemini_wdt_suspend,
  4975. + .resume = gemini_wdt_resume,
  4976. + .driver = {
  4977. + .name = "gemini-wdt",
  4978. + .owner = THIS_MODULE,
  4979. + },
  4980. +};
  4981. +
  4982. +static int __init gemini_wdt_init(void)
  4983. +{
  4984. + return platform_driver_probe(&gemini_wdt_driver, gemini_wdt_probe);
  4985. +}
  4986. +
  4987. +static void __exit gemini_wdt_exit(void)
  4988. +{
  4989. + platform_driver_unregister(&gemini_wdt_driver);
  4990. +}
  4991. +
  4992. +module_init(gemini_wdt_init);
  4993. +module_exit(gemini_wdt_exit);
  4994. +
  4995. +module_param(timeout, uint, 0);
  4996. +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds");
  4997. +
  4998. +module_param(nowayout, int, 0);
  4999. +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
  5000. +
  5001. +MODULE_AUTHOR("Paulius Zaleckas");
  5002. +MODULE_DESCRIPTION("Watchdog driver for Gemini");
  5003. +MODULE_LICENSE("GPL");
  5004. +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
  5005. +MODULE_ALIAS("platform:gemini-wdt");
  5006. --- a/drivers/watchdog/Kconfig
  5007. +++ b/drivers/watchdog/Kconfig
  5008. @@ -111,6 +111,16 @@ config 977_WATCHDOG
  5009. Not sure? It's safe to say N.
  5010. +config GEMINI_WATCHDOG
  5011. + tristate "Gemini watchdog"
  5012. + depends on ARCH_GEMINI
  5013. + help
  5014. + Say Y here if to include support for the watchdog timer
  5015. + embedded in the Cortina Systems Gemini family of devices.
  5016. +
  5017. + To compile this driver as a module, choose M here: the
  5018. + module will be called gemini_wdt.
  5019. +
  5020. config IXP2000_WATCHDOG
  5021. tristate "IXP2000 Watchdog"
  5022. depends on ARCH_IXP2000
  5023. --- a/drivers/watchdog/Makefile
  5024. +++ b/drivers/watchdog/Makefile
  5025. @@ -31,6 +31,7 @@ obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.
  5026. obj-$(CONFIG_TWL4030_WATCHDOG) += twl4030_wdt.o
  5027. obj-$(CONFIG_21285_WATCHDOG) += wdt285.o
  5028. obj-$(CONFIG_977_WATCHDOG) += wdt977.o
  5029. +obj-$(CONFIG_GEMINI_WATCHDOG) += gemini_wdt.o
  5030. obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o
  5031. obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
  5032. obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o
  5033. --- a/include/linux/usb/ehci_def.h
  5034. +++ b/include/linux/usb/ehci_def.h
  5035. @@ -91,9 +91,9 @@ struct ehci_regs {
  5036. u32 frame_list; /* points to periodic list */
  5037. /* ASYNCLISTADDR: offset 0x18 */
  5038. u32 async_next; /* address of next async queue head */
  5039. -
  5040. +#ifndef CONFIG_ARCH_GEMINI
  5041. u32 reserved [9];
  5042. -
  5043. +#endif
  5044. /* CONFIGFLAG: offset 0x40 */
  5045. u32 configured_flag;
  5046. #define FLAG_CF (1<<0) /* true: we'll support "high speed" */
  5047. --- a/arch/arm/mm/Kconfig
  5048. +++ b/arch/arm/mm/Kconfig
  5049. @@ -774,5 +774,6 @@ config CACHE_XSC3L2
  5050. config ARM_L1_CACHE_SHIFT
  5051. int
  5052. + default 4 if CPU_FA526
  5053. default 6 if ARCH_OMAP3
  5054. default 5
  5055. --- a/arch/arm/lib/copy_page.S
  5056. +++ b/arch/arm/lib/copy_page.S
  5057. @@ -17,7 +17,7 @@
  5058. #define COPY_COUNT (PAGE_SZ / (2 * L1_CACHE_BYTES) PLD( -1 ))
  5059. .text
  5060. - .align 5
  5061. + .align L1_CACHE_SHIFT
  5062. /*
  5063. * StrongARM optimised copy_page routine
  5064. * now 1.78bytes/cycle, was 1.60 bytes/cycle (50MHz bus -> 89MB/s)