0214-usb-add-mt7621-xhci-support.patch 215 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768
  1. From b823088d8782e02cc39c7eb4d834396b83dabe49 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  3. Date: Mon, 27 Jan 2014 13:11:01 +0000
  4. Subject: [PATCH 214/215] usb: add mt7621 xhci support
  5. Signed-off-by: John Crispin <[email protected]>
  6. ---
  7. drivers/usb/core/hub.c | 2 +-
  8. drivers/usb/core/port.c | 3 +-
  9. drivers/usb/host/Kconfig | 6 +-
  10. drivers/usb/host/Makefile | 10 +-
  11. drivers/usb/host/mtk-phy-7621.c | 445 +++++
  12. drivers/usb/host/mtk-phy-7621.h | 2871 +++++++++++++++++++++++++++++++++
  13. drivers/usb/host/mtk-phy-ahb.c | 58 +
  14. drivers/usb/host/mtk-phy.c | 102 ++
  15. drivers/usb/host/mtk-phy.h | 179 ++
  16. drivers/usb/host/pci-quirks.h | 2 +-
  17. drivers/usb/host/xhci-dbg.c | 3 +
  18. drivers/usb/host/xhci-mem.c | 11 +
  19. drivers/usb/host/xhci-mtk-power.c | 115 ++
  20. drivers/usb/host/xhci-mtk-power.h | 13 +
  21. drivers/usb/host/xhci-mtk-scheduler.c | 608 +++++++
  22. drivers/usb/host/xhci-mtk-scheduler.h | 77 +
  23. drivers/usb/host/xhci-mtk.c | 265 +++
  24. drivers/usb/host/xhci-mtk.h | 120 ++
  25. drivers/usb/host/xhci-plat.c | 19 +
  26. drivers/usb/host/xhci-ring.c | 109 +-
  27. drivers/usb/host/xhci.c | 201 ++-
  28. drivers/usb/host/xhci.h | 23 +-
  29. 22 files changed, 5229 insertions(+), 13 deletions(-)
  30. create mode 100644 drivers/usb/host/mtk-phy-7621.c
  31. create mode 100644 drivers/usb/host/mtk-phy-7621.h
  32. create mode 100644 drivers/usb/host/mtk-phy-ahb.c
  33. create mode 100644 drivers/usb/host/mtk-phy.c
  34. create mode 100644 drivers/usb/host/mtk-phy.h
  35. create mode 100644 drivers/usb/host/xhci-mtk-power.c
  36. create mode 100644 drivers/usb/host/xhci-mtk-power.h
  37. create mode 100644 drivers/usb/host/xhci-mtk-scheduler.c
  38. create mode 100644 drivers/usb/host/xhci-mtk-scheduler.h
  39. create mode 100644 drivers/usb/host/xhci-mtk.c
  40. create mode 100644 drivers/usb/host/xhci-mtk.h
  41. --- a/drivers/usb/core/hub.c
  42. +++ b/drivers/usb/core/hub.c
  43. @@ -1254,7 +1254,7 @@ static void hub_quiesce(struct usb_hub *
  44. if (type != HUB_SUSPEND) {
  45. /* Disconnect all the children */
  46. for (i = 0; i < hdev->maxchild; ++i) {
  47. - if (hub->ports[i]->child)
  48. + if (hub->ports[i] && hub->ports[i]->child)
  49. usb_disconnect(&hub->ports[i]->child);
  50. }
  51. }
  52. --- a/drivers/usb/core/port.c
  53. +++ b/drivers/usb/core/port.c
  54. @@ -193,6 +193,7 @@ exit:
  55. void usb_hub_remove_port_device(struct usb_hub *hub,
  56. int port1)
  57. {
  58. - device_unregister(&hub->ports[port1 - 1]->dev);
  59. + if (hub->ports[port1 - 1])
  60. + device_unregister(&hub->ports[port1 - 1]->dev);
  61. }
  62. --- a/drivers/usb/host/Kconfig
  63. +++ b/drivers/usb/host/Kconfig
  64. @@ -28,7 +28,11 @@ config USB_XHCI_HCD
  65. if USB_XHCI_HCD
  66. config USB_XHCI_PLATFORM
  67. - tristate
  68. + bool "xHCI platform"
  69. +
  70. +config USB_MT7621_XHCI_PLATFORM
  71. + bool "MTK MT7621 xHCI"
  72. + depends on USB_XHCI_PLATFORM
  73. config USB_XHCI_HCD_DEBUGGING
  74. bool "Debugging for the xHCI host controller"
  75. --- a/drivers/usb/host/Makefile
  76. +++ b/drivers/usb/host/Makefile
  77. @@ -13,15 +13,23 @@ fhci-$(CONFIG_FHCI_DEBUG) += fhci-dbg.o
  78. xhci-hcd-y := xhci.o xhci-mem.o
  79. xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o
  80. +ifndef CONFIG_USB_MT7621_XHCI_PLATFORM
  81. xhci-hcd-$(CONFIG_PCI) += xhci-pci.o
  82. +endif
  83. +
  84. +ifdef CONFIG_USB_MT7621_XHCI_PLATFORM
  85. +xhci-hcd-y += mtk-phy.o xhci-mtk-scheduler.o xhci-mtk-power.o xhci-mtk.o mtk-phy-7621.o mtk-phy-ahb.o
  86. +endif
  87. ifneq ($(CONFIG_USB_XHCI_PLATFORM), )
  88. - xhci-hcd-y += xhci-plat.o
  89. +xhci-hcd-y += xhci-plat.o
  90. endif
  91. obj-$(CONFIG_USB_WHCI_HCD) += whci/
  92. +ifndef CONFIG_USB_MT7621_XHCI_PLATFORM
  93. obj-$(CONFIG_PCI) += pci-quirks.o
  94. +endif
  95. obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
  96. obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
  97. --- /dev/null
  98. +++ b/drivers/usb/host/mtk-phy-7621.c
  99. @@ -0,0 +1,445 @@
  100. +#include "mtk-phy.h"
  101. +
  102. +#ifdef CONFIG_PROJECT_7621
  103. +#include "mtk-phy-7621.h"
  104. +
  105. +//not used on SoC
  106. +PHY_INT32 phy_init(struct u3phy_info *info){
  107. + return PHY_TRUE;
  108. +}
  109. +
  110. +//not used on SoC
  111. +PHY_INT32 phy_change_pipe_phase(struct u3phy_info *info, PHY_INT32 phy_drv, PHY_INT32 pipe_phase){
  112. + return PHY_TRUE;
  113. +}
  114. +
  115. +//--------------------------------------------------------
  116. +// Function : fgEyeScanHelper_CheckPtInRegion()
  117. +// Description : Check if the test point is in a rectangle region.
  118. +// If it is in the rectangle, also check if this point
  119. +// is on the multiple of deltaX and deltaY.
  120. +// Parameter : strucScanRegion * prEye - the region
  121. +// BYTE bX
  122. +// BYTE bY
  123. +// Return : BYTE - TRUE : This point needs to be tested
  124. +// FALSE: This point will be omitted
  125. +// Note : First check within the rectangle.
  126. +// Secondly, use modulous to check if the point will be tested.
  127. +//--------------------------------------------------------
  128. +static PHY_INT8 fgEyeScanHelper_CheckPtInRegion(struct strucScanRegion * prEye, PHY_INT8 bX, PHY_INT8 bY)
  129. +{
  130. + PHY_INT8 fgValid = true;
  131. +
  132. +
  133. + /// Be careful, the axis origin is on the TOP-LEFT corner.
  134. + /// Therefore the top-left point has the minimum X and Y
  135. + /// Botton-right point is the maximum X and Y
  136. + if ( (prEye->bX_tl <= bX) && (bX <= prEye->bX_br)
  137. + && (prEye->bY_tl <= bY) && (bY <= prEye->bX_br))
  138. + {
  139. + // With the region, now check whether or not the input test point is
  140. + // on the multiples of X and Y
  141. + // Do not have to worry about negative value, because we have already
  142. + // check the input bX, and bY is within the region.
  143. + if ( ((bX - prEye->bX_tl) % (prEye->bDeltaX))
  144. + || ((bY - prEye->bY_tl) % (prEye->bDeltaY)) )
  145. + {
  146. + // if the division will have remainder, that means
  147. + // the input test point is on the multiples of X and Y
  148. + fgValid = false;
  149. + }
  150. + else
  151. + {
  152. + }
  153. + }
  154. + else
  155. + {
  156. +
  157. + fgValid = false;
  158. + }
  159. + return fgValid;
  160. +}
  161. +
  162. +//--------------------------------------------------------
  163. +// Function : EyeScanHelper_RunTest()
  164. +// Description : Enable the test, and wait til it is completed
  165. +// Parameter : None
  166. +// Return : None
  167. +// Note : None
  168. +//--------------------------------------------------------
  169. +static void EyeScanHelper_RunTest(struct u3phy_info *info)
  170. +{
  171. + DRV_UDELAY(100);
  172. + // Disable the test
  173. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  174. + , RG_SSUSB_EQ_EYE_CNT_EN_OFST, RG_SSUSB_EQ_EYE_CNT_EN, 0); //RG_SSUSB_RX_EYE_CNT_EN = 0
  175. + DRV_UDELAY(100);
  176. + // Run the test
  177. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  178. + , RG_SSUSB_EQ_EYE_CNT_EN_OFST, RG_SSUSB_EQ_EYE_CNT_EN, 1); //RG_SSUSB_RX_EYE_CNT_EN = 1
  179. + DRV_UDELAY(100);
  180. + // Wait til it's done
  181. + //RGS_SSUSB_RX_EYE_CNT_RDY
  182. + while(!U3PhyReadField32(((PHY_UINT32)&info->u3phyd_regs->phya_rx_mon5)
  183. + , RGS_SSUSB_EQ_EYE_CNT_RDY_OFST, RGS_SSUSB_EQ_EYE_CNT_RDY));
  184. +}
  185. +
  186. +//--------------------------------------------------------
  187. +// Function : fgEyeScanHelper_CalNextPoint()
  188. +// Description : Calcualte the test point for the measurement
  189. +// Parameter : None
  190. +// Return : BOOL - TRUE : the next point is within the
  191. +// boundaryof HW limit
  192. +// FALSE: the next point is out of the HW limit
  193. +// Note : The next point is obtained by calculating
  194. +// from the bottom left of the region rectangle
  195. +// and then scanning up until it reaches the upper
  196. +// limit. At this time, the x will increment, and
  197. +// start scanning downwards until the y hits the
  198. +// zero.
  199. +//--------------------------------------------------------
  200. +static PHY_INT8 fgEyeScanHelper_CalNextPoint(void)
  201. +{
  202. + if ( ((_bYcurr == MAX_Y) && (_eScanDir == SCAN_DN))
  203. + || ((_bYcurr == MIN_Y) && (_eScanDir == SCAN_UP))
  204. + )
  205. + {
  206. + /// Reaches the limit of Y axis
  207. + /// Increment X
  208. + _bXcurr++;
  209. + _fgXChged = true;
  210. + _eScanDir = (_eScanDir == SCAN_UP) ? SCAN_DN : SCAN_UP;
  211. +
  212. + if (_bXcurr > MAX_X)
  213. + {
  214. + return false;
  215. + }
  216. + }
  217. + else
  218. + {
  219. + _bYcurr = (_eScanDir == SCAN_DN) ? _bYcurr + 1 : _bYcurr - 1;
  220. + _fgXChged = false;
  221. + }
  222. + return PHY_TRUE;
  223. +}
  224. +
  225. +PHY_INT32 eyescan_init(struct u3phy_info *info){
  226. + //initial PHY setting
  227. + U3PhyWriteField32(((PHY_UINT32)&info->u3phya_regs->rega)
  228. + , RG_SSUSB_CDR_EPEN_OFST, RG_SSUSB_CDR_EPEN, 1);
  229. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->phyd_mix3)
  230. + , RG_SSUSB_FORCE_CDR_PI_PWD_OFST, RG_SSUSB_FORCE_CDR_PI_PWD, 1);
  231. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_bank2_regs->b2_phyd_misc0)
  232. + , RG_SSUSB_RX_PI_CAL_EN_SEL_OFST, RG_SSUSB_RX_PI_CAL_EN_SEL, 1); //RG_SSUSB_RX_PI_CAL_MANUAL_SEL = 1
  233. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_bank2_regs->b2_phyd_misc0)
  234. + , RG_SSUSB_RX_PI_CAL_EN_OFST, RG_SSUSB_RX_PI_CAL_EN, 1); //RG_SSUSB_RX_PI_CAL_MANUAL_EN = 1
  235. + return PHY_TRUE;
  236. +}
  237. +
  238. +PHY_INT32 phy_eyescan(struct u3phy_info *info, PHY_INT32 x_t1, PHY_INT32 y_t1, PHY_INT32 x_br, PHY_INT32 y_br, PHY_INT32 delta_x, PHY_INT32 delta_y
  239. + , PHY_INT32 eye_cnt, PHY_INT32 num_cnt, PHY_INT32 PI_cal_en, PHY_INT32 num_ignore_cnt){
  240. + PHY_INT32 cOfst = 0;
  241. + PHY_UINT8 bIdxX = 0;
  242. + PHY_UINT8 bIdxY = 0;
  243. + //PHY_INT8 bCnt = 0;
  244. + PHY_UINT8 bIdxCycCnt = 0;
  245. + PHY_INT8 fgValid;
  246. + PHY_INT8 cX;
  247. + PHY_INT8 cY;
  248. + PHY_UINT8 bExtendCnt;
  249. + PHY_INT8 isContinue;
  250. + //PHY_INT8 isBreak;
  251. + PHY_UINT32 wErr0 = 0, wErr1 = 0;
  252. + //PHY_UINT32 temp;
  253. +
  254. + PHY_UINT32 pwErrCnt0[CYCLE_COUNT_MAX][ERRCNT_MAX][ERRCNT_MAX];
  255. + PHY_UINT32 pwErrCnt1[CYCLE_COUNT_MAX][ERRCNT_MAX][ERRCNT_MAX];
  256. +
  257. + _rEye1.bX_tl = x_t1;
  258. + _rEye1.bY_tl = y_t1;
  259. + _rEye1.bX_br = x_br;
  260. + _rEye1.bY_br = y_br;
  261. + _rEye1.bDeltaX = delta_x;
  262. + _rEye1.bDeltaY = delta_y;
  263. +
  264. + _rEye2.bX_tl = x_t1;
  265. + _rEye2.bY_tl = y_t1;
  266. + _rEye2.bX_br = x_br;
  267. + _rEye2.bY_br = y_br;
  268. + _rEye2.bDeltaX = delta_x;
  269. + _rEye2.bDeltaY = delta_y;
  270. +
  271. + _rTestCycle.wEyeCnt = eye_cnt;
  272. + _rTestCycle.bNumOfEyeCnt = num_cnt;
  273. + _rTestCycle.bNumOfIgnoreCnt = num_ignore_cnt;
  274. + _rTestCycle.bPICalEn = PI_cal_en;
  275. +
  276. + _bXcurr = 0;
  277. + _bYcurr = 0;
  278. + _eScanDir = SCAN_DN;
  279. + _fgXChged = false;
  280. +
  281. + printk("x_t1: %x, y_t1: %x, x_br: %x, y_br: %x, delta_x: %x, delta_y: %x, \
  282. + eye_cnt: %x, num_cnt: %x, PI_cal_en: %x, num_ignore_cnt: %x\n", \
  283. + x_t1, y_t1, x_br, y_br, delta_x, delta_y, eye_cnt, num_cnt, PI_cal_en, num_ignore_cnt);
  284. +
  285. + //force SIGDET to OFF
  286. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_bank2_regs->b2_phyd_misc0)
  287. + , RG_SSUSB_RX_SIGDET_EN_SEL_OFST, RG_SSUSB_RX_SIGDET_EN_SEL, 1); //RG_SSUSB_RX_SIGDET_SEL = 1
  288. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_bank2_regs->b2_phyd_misc0)
  289. + , RG_SSUSB_RX_SIGDET_EN_OFST, RG_SSUSB_RX_SIGDET_EN, 0); //RG_SSUSB_RX_SIGDET_EN = 0
  290. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye1)
  291. + , RG_SSUSB_EQ_SIGDET_OFST, RG_SSUSB_EQ_SIGDET, 0); //RG_SSUSB_RX_SIGDET = 0
  292. +
  293. + // RX_TRI_DET_EN to Disable
  294. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq3)
  295. + , RG_SSUSB_EQ_TRI_DET_EN_OFST, RG_SSUSB_EQ_TRI_DET_EN, 0); //RG_SSUSB_RX_TRI_DET_EN = 0
  296. +
  297. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  298. + , RG_SSUSB_EQ_EYE_MON_EN_OFST, RG_SSUSB_EQ_EYE_MON_EN, 1); //RG_SSUSB_EYE_MON_EN = 1
  299. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  300. + , RG_SSUSB_EQ_EYE_XOFFSET_OFST, RG_SSUSB_EQ_EYE_XOFFSET, 0); //RG_SSUSB_RX_EYE_XOFFSET = 0
  301. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  302. + , RG_SSUSB_EQ_EYE0_Y_OFST, RG_SSUSB_EQ_EYE0_Y, 0); //RG_SSUSB_RX_EYE0_Y = 0
  303. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  304. + , RG_SSUSB_EQ_EYE1_Y_OFST, RG_SSUSB_EQ_EYE1_Y, 0); //RG_SSUSB_RX_EYE1_Y = 0
  305. +
  306. +
  307. + if (PI_cal_en){
  308. + // PI Calibration
  309. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_bank2_regs->b2_phyd_misc0)
  310. + , RG_SSUSB_RX_PI_CAL_EN_SEL_OFST, RG_SSUSB_RX_PI_CAL_EN_SEL, 1); //RG_SSUSB_RX_PI_CAL_MANUAL_SEL = 1
  311. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_bank2_regs->b2_phyd_misc0)
  312. + , RG_SSUSB_RX_PI_CAL_EN_OFST, RG_SSUSB_RX_PI_CAL_EN, 0); //RG_SSUSB_RX_PI_CAL_MANUAL_EN = 0
  313. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_bank2_regs->b2_phyd_misc0)
  314. + , RG_SSUSB_RX_PI_CAL_EN_OFST, RG_SSUSB_RX_PI_CAL_EN, 1); //RG_SSUSB_RX_PI_CAL_MANUAL_EN = 1
  315. +
  316. + DRV_UDELAY(20);
  317. +
  318. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_bank2_regs->b2_phyd_misc0)
  319. + , RG_SSUSB_RX_PI_CAL_EN_OFST, RG_SSUSB_RX_PI_CAL_EN, 0); //RG_SSUSB_RX_PI_CAL_MANUAL_EN = 0
  320. + _bPIResult = U3PhyReadField32(((PHY_UINT32)&info->u3phyd_regs->phya_rx_mon5)
  321. + , RGS_SSUSB_EQ_PILPO_OFST, RGS_SSUSB_EQ_PILPO); //read RGS_SSUSB_RX_PILPO
  322. +
  323. + printk(KERN_ERR "PI result: %d\n", _bPIResult);
  324. + }
  325. + // Read Initial DAC
  326. + // Set CYCLE
  327. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye3)
  328. + ,RG_SSUSB_EQ_EYE_CNT_OFST, RG_SSUSB_EQ_EYE_CNT, eye_cnt); //RG_SSUSB_RX_EYE_CNT
  329. +
  330. + // Eye Monitor Feature
  331. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye1)
  332. + , RG_SSUSB_EQ_EYE_MASK_OFST, RG_SSUSB_EQ_EYE_MASK, 0x3ff); //RG_SSUSB_RX_EYE_MASK = 0x3ff
  333. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  334. + , RG_SSUSB_EQ_EYE_MON_EN_OFST, RG_SSUSB_EQ_EYE_MON_EN, 1); //RG_SSUSB_EYE_MON_EN = 1
  335. +
  336. + // Move X,Y to the top-left corner
  337. + for (cOfst = 0; cOfst >= -64; cOfst--)
  338. + {
  339. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  340. + ,RG_SSUSB_EQ_EYE_XOFFSET_OFST, RG_SSUSB_EQ_EYE_XOFFSET, cOfst); //RG_SSUSB_RX_EYE_XOFFSET
  341. + }
  342. + for (cOfst = 0; cOfst < 64; cOfst++)
  343. + {
  344. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  345. + , RG_SSUSB_EQ_EYE0_Y_OFST, RG_SSUSB_EQ_EYE0_Y, cOfst); //RG_SSUSB_RX_EYE0_Y
  346. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  347. + , RG_SSUSB_EQ_EYE1_Y_OFST, RG_SSUSB_EQ_EYE1_Y, cOfst); //RG_SSUSB_RX_EYE1_Y
  348. + }
  349. + //ClearErrorResult
  350. + for(bIdxCycCnt = 0; bIdxCycCnt < CYCLE_COUNT_MAX; bIdxCycCnt++){
  351. + for(bIdxX = 0; bIdxX < ERRCNT_MAX; bIdxX++)
  352. + {
  353. + for(bIdxY = 0; bIdxY < ERRCNT_MAX; bIdxY++){
  354. + pwErrCnt0[bIdxCycCnt][bIdxX][bIdxY] = 0;
  355. + pwErrCnt1[bIdxCycCnt][bIdxX][bIdxY] = 0;
  356. + }
  357. + }
  358. + }
  359. + isContinue = true;
  360. + while(isContinue){
  361. + //printk(KERN_ERR "_bXcurr: %d, _bYcurr: %d\n", _bXcurr, _bYcurr);
  362. + // The point is within the boundary, then let's check if it is within
  363. + // the testing region.
  364. + // The point is only test-able if one of the eye region
  365. + // includes this point.
  366. + fgValid = fgEyeScanHelper_CheckPtInRegion(&_rEye1, _bXcurr, _bYcurr)
  367. + || fgEyeScanHelper_CheckPtInRegion(&_rEye2, _bXcurr, _bYcurr);
  368. + // Translate bX and bY to 2's complement from where the origin was on the
  369. + // top left corner.
  370. + // 0x40 and 0x3F needs a bit of thinking!!!! >"<
  371. + cX = (_bXcurr ^ 0x40);
  372. + cY = (_bYcurr ^ 0x3F);
  373. +
  374. + // Set X if necessary
  375. + if (_fgXChged == true)
  376. + {
  377. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  378. + , RG_SSUSB_EQ_EYE_XOFFSET_OFST, RG_SSUSB_EQ_EYE_XOFFSET, cX); //RG_SSUSB_RX_EYE_XOFFSET
  379. + }
  380. + // Set Y
  381. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  382. + , RG_SSUSB_EQ_EYE0_Y_OFST, RG_SSUSB_EQ_EYE0_Y, cY); //RG_SSUSB_RX_EYE0_Y
  383. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  384. + , RG_SSUSB_EQ_EYE1_Y_OFST, RG_SSUSB_EQ_EYE1_Y, cY); //RG_SSUSB_RX_EYE1_Y
  385. +
  386. + /// Test this point!
  387. + if (fgValid){
  388. + for (bExtendCnt = 0; bExtendCnt < num_ignore_cnt; bExtendCnt++)
  389. + {
  390. + //run test
  391. + EyeScanHelper_RunTest(info);
  392. + }
  393. + for (bExtendCnt = 0; bExtendCnt < num_cnt; bExtendCnt++)
  394. + {
  395. + EyeScanHelper_RunTest(info);
  396. + wErr0 = U3PhyReadField32(((PHY_UINT32)&info->u3phyd_regs->phya_rx_mon3)
  397. + , RGS_SSUSB_EQ_EYE_MONITOR_ERRCNT_0_OFST, RGS_SSUSB_EQ_EYE_MONITOR_ERRCNT_0);
  398. + wErr1 = U3PhyReadField32(((PHY_UINT32)&info->u3phyd_regs->phya_rx_mon4)
  399. + , RGS_SSUSB_EQ_EYE_MONITOR_ERRCNT_1_OFST, RGS_SSUSB_EQ_EYE_MONITOR_ERRCNT_1);
  400. +
  401. + pwErrCnt0[bExtendCnt][_bXcurr][_bYcurr] = wErr0;
  402. + pwErrCnt1[bExtendCnt][_bXcurr][_bYcurr] = wErr1;
  403. +
  404. + //EyeScanHelper_GetResult(&_rRes.pwErrCnt0[bCnt], &_rRes.pwErrCnt1[bCnt]);
  405. +// printk(KERN_ERR "cnt[%d] cur_x,y [0x%x][0x%x], cX,cY [0x%x][0x%x], ErrCnt[%d][%d]\n"
  406. +// , bExtendCnt, _bXcurr, _bYcurr, cX, cY, pwErrCnt0[bExtendCnt][_bXcurr][_bYcurr], pwErrCnt1[bExtendCnt][_bXcurr][_bYcurr]);
  407. + }
  408. + //printk(KERN_ERR "cur_x,y [0x%x][0x%x], cX,cY [0x%x][0x%x], ErrCnt[%d][%d]\n", _bXcurr, _bYcurr, cX, cY, pwErrCnt0[0][_bXcurr][_bYcurr], pwErrCnt1[0][_bXcurr][_bYcurr]);
  409. + }
  410. + else{
  411. +
  412. + }
  413. + if (fgEyeScanHelper_CalNextPoint() == false){
  414. +#if 0
  415. + printk(KERN_ERR "Xcurr [0x%x] Ycurr [0x%x]\n", _bXcurr, _bYcurr);
  416. + printk(KERN_ERR "XcurrREG [0x%x] YcurrREG [0x%x]\n", cX, cY);
  417. +#endif
  418. + printk(KERN_ERR "end of eye scan\n");
  419. + isContinue = false;
  420. + }
  421. + }
  422. + printk(KERN_ERR "CurX [0x%x] CurY [0x%x]\n"
  423. + , U3PhyReadField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0), RG_SSUSB_EQ_EYE_XOFFSET_OFST, RG_SSUSB_EQ_EYE_XOFFSET)
  424. + , U3PhyReadField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0), RG_SSUSB_EQ_EYE0_Y_OFST, RG_SSUSB_EQ_EYE0_Y));
  425. +
  426. + // Move X,Y to the top-left corner
  427. + for (cOfst = 63; cOfst >= 0; cOfst--)
  428. + {
  429. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  430. + , RG_SSUSB_EQ_EYE_XOFFSET_OFST, RG_SSUSB_EQ_EYE_XOFFSET, cOfst); //RG_SSUSB_RX_EYE_XOFFSET
  431. + }
  432. + for (cOfst = 63; cOfst >= 0; cOfst--)
  433. + {
  434. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  435. + , RG_SSUSB_EQ_EYE0_Y_OFST, RG_SSUSB_EQ_EYE0_Y, cOfst);
  436. + U3PhyWriteField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0)
  437. + , RG_SSUSB_EQ_EYE1_Y_OFST, RG_SSUSB_EQ_EYE1_Y, cOfst);
  438. +
  439. + }
  440. + printk(KERN_ERR "CurX [0x%x] CurY [0x%x]\n"
  441. + , U3PhyReadField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0), RG_SSUSB_EQ_EYE_XOFFSET_OFST, RG_SSUSB_EQ_EYE_XOFFSET)
  442. + , U3PhyReadField32(((PHY_UINT32)&info->u3phyd_regs->eq_eye0), RG_SSUSB_EQ_EYE0_Y_OFST, RG_SSUSB_EQ_EYE0_Y));
  443. +
  444. + printk(KERN_ERR "PI result: %d\n", _bPIResult);
  445. + printk(KERN_ERR "pwErrCnt0 addr: 0x%x\n", (PHY_UINT32)pwErrCnt0);
  446. + printk(KERN_ERR "pwErrCnt1 addr: 0x%x\n", (PHY_UINT32)pwErrCnt1);
  447. +
  448. + return PHY_TRUE;
  449. +}
  450. +
  451. +//not used on SoC
  452. +PHY_INT32 u2_save_cur_en(struct u3phy_info *info){
  453. + return PHY_TRUE;
  454. +}
  455. +
  456. +//not used on SoC
  457. +PHY_INT32 u2_save_cur_re(struct u3phy_info *info){
  458. + return PHY_TRUE;
  459. +}
  460. +
  461. +PHY_INT32 u2_slew_rate_calibration(struct u3phy_info *info){
  462. + PHY_INT32 i=0;
  463. + //PHY_INT32 j=0;
  464. + //PHY_INT8 u1SrCalVal = 0;
  465. + //PHY_INT8 u1Reg_addr_HSTX_SRCAL_EN;
  466. + PHY_INT32 fgRet = 0;
  467. + PHY_INT32 u4FmOut = 0;
  468. + PHY_INT32 u4Tmp = 0;
  469. + //PHY_INT32 temp;
  470. +
  471. + // => RG_USB20_HSTX_SRCAL_EN = 1
  472. + // enable HS TX SR calibration
  473. + U3PhyWriteField32(((PHY_UINT32)&info->u2phy_regs->u2phyacr0)
  474. + , RG_USB20_HSTX_SRCAL_EN_OFST, RG_USB20_HSTX_SRCAL_EN, 0x1);
  475. + DRV_MSLEEP(1);
  476. +
  477. + // => RG_FRCK_EN = 1
  478. + // Enable free run clock
  479. + U3PhyWriteField32(((PHY_UINT32)&info->sifslv_fm_regs->fmmonr1)
  480. + , RG_FRCK_EN_OFST, RG_FRCK_EN, 1);
  481. +
  482. + // MT6290 HS signal quality patch
  483. + // => RG_CYCLECNT = 400
  484. + // Setting cyclecnt =400
  485. + U3PhyWriteField32(((PHY_UINT32)&info->sifslv_fm_regs->fmcr0)
  486. + , RG_CYCLECNT_OFST, RG_CYCLECNT, 0x400);
  487. +
  488. + // => RG_FREQDET_EN = 1
  489. + // Enable frequency meter
  490. + U3PhyWriteField32(((PHY_UINT32)&info->sifslv_fm_regs->fmcr0)
  491. + , RG_FREQDET_EN_OFST, RG_FREQDET_EN, 0x1);
  492. +
  493. + // wait for FM detection done, set 10ms timeout
  494. + for(i=0; i<10; i++){
  495. + // => u4FmOut = USB_FM_OUT
  496. + // read FM_OUT
  497. + u4FmOut = U3PhyReadReg32(((PHY_UINT32)&info->sifslv_fm_regs->fmmonr0));
  498. + printk("FM_OUT value: u4FmOut = %d(0x%08X)\n", u4FmOut, u4FmOut);
  499. +
  500. + // check if FM detection done
  501. + if (u4FmOut != 0)
  502. + {
  503. + fgRet = 0;
  504. + printk("FM detection done! loop = %d\n", i);
  505. +
  506. + break;
  507. + }
  508. +
  509. + fgRet = 1;
  510. + DRV_MSLEEP(1);
  511. + }
  512. + // => RG_FREQDET_EN = 0
  513. + // disable frequency meter
  514. + U3PhyWriteField32(((PHY_UINT32)&info->sifslv_fm_regs->fmcr0)
  515. + , RG_FREQDET_EN_OFST, RG_FREQDET_EN, 0);
  516. +
  517. + // => RG_FRCK_EN = 0
  518. + // disable free run clock
  519. + U3PhyWriteField32(((PHY_UINT32)&info->sifslv_fm_regs->fmmonr1)
  520. + , RG_FRCK_EN_OFST, RG_FRCK_EN, 0);
  521. +
  522. + // => RG_USB20_HSTX_SRCAL_EN = 0
  523. + // disable HS TX SR calibration
  524. + U3PhyWriteField32(((PHY_UINT32)&info->u2phy_regs->u2phyacr0)
  525. + , RG_USB20_HSTX_SRCAL_EN_OFST, RG_USB20_HSTX_SRCAL_EN, 0);
  526. + DRV_MSLEEP(1);
  527. +
  528. + if(u4FmOut == 0){
  529. + U3PhyWriteField32(((PHY_UINT32)&info->u2phy_regs->u2phyacr0)
  530. + , RG_USB20_HSTX_SRCTRL_OFST, RG_USB20_HSTX_SRCTRL, 0x4);
  531. +
  532. + fgRet = 1;
  533. + }
  534. + else{
  535. + // set reg = (1024/FM_OUT) * 25 * 0.028 (round to the nearest digits)
  536. + u4Tmp = (((1024 * 25 * U2_SR_COEF_7621) / u4FmOut) + 500) / 1000;
  537. + printk("SR calibration value u1SrCalVal = %d\n", (PHY_UINT8)u4Tmp);
  538. + U3PhyWriteField32(((PHY_UINT32)&info->u2phy_regs->u2phyacr0)
  539. + , RG_USB20_HSTX_SRCTRL_OFST, RG_USB20_HSTX_SRCTRL, u4Tmp);
  540. + }
  541. + return fgRet;
  542. +}
  543. +
  544. +#endif
  545. --- /dev/null
  546. +++ b/drivers/usb/host/mtk-phy-7621.h
  547. @@ -0,0 +1,2871 @@
  548. +#ifdef CONFIG_PROJECT_7621
  549. +#ifndef __MTK_PHY_7621_H
  550. +#define __MTK_PHY_7621_H
  551. +
  552. +#define U2_SR_COEF_7621 28
  553. +
  554. +///////////////////////////////////////////////////////////////////////////////
  555. +
  556. +struct u2phy_reg {
  557. + //0x0
  558. + PHY_LE32 u2phyac0;
  559. + PHY_LE32 u2phyac1;
  560. + PHY_LE32 u2phyac2;
  561. + PHY_LE32 reserve0;
  562. + //0x10
  563. + PHY_LE32 u2phyacr0;
  564. + PHY_LE32 u2phyacr1;
  565. + PHY_LE32 u2phyacr2;
  566. + PHY_LE32 u2phyacr3;
  567. + //0x20
  568. + PHY_LE32 u2phyacr4;
  569. + PHY_LE32 u2phyamon0;
  570. + PHY_LE32 reserve1[2];
  571. + //0x30~0x50
  572. + PHY_LE32 reserve2[12];
  573. + //0x60
  574. + PHY_LE32 u2phydcr0;
  575. + PHY_LE32 u2phydcr1;
  576. + PHY_LE32 u2phydtm0;
  577. + PHY_LE32 u2phydtm1;
  578. + //0x70
  579. + PHY_LE32 u2phydmon0;
  580. + PHY_LE32 u2phydmon1;
  581. + PHY_LE32 u2phydmon2;
  582. + PHY_LE32 u2phydmon3;
  583. + //0x80
  584. + PHY_LE32 u2phybc12c;
  585. + PHY_LE32 u2phybc12c1;
  586. + PHY_LE32 reserve3[2];
  587. + //0x90~0xe0
  588. + PHY_LE32 reserve4[24];
  589. + //0xf0
  590. + PHY_LE32 reserve6[3];
  591. + PHY_LE32 regfcom;
  592. +};
  593. +
  594. +//U3D_U2PHYAC0
  595. +#define RG_USB20_USBPLL_DIVEN (0x7<<28) //30:28
  596. +#define RG_USB20_USBPLL_CKCTRL (0x3<<26) //27:26
  597. +#define RG_USB20_USBPLL_PREDIV (0x3<<24) //25:24
  598. +#define RG_USB20_USBPLL_FORCE_ON (0x1<<23) //23:23
  599. +#define RG_USB20_USBPLL_FBDIV (0x7f<<16) //22:16
  600. +#define RG_USB20_REF_EN (0x1<<15) //15:15
  601. +#define RG_USB20_INTR_EN (0x1<<14) //14:14
  602. +#define RG_USB20_BG_TRIM (0xf<<8) //11:8
  603. +#define RG_USB20_BG_RBSEL (0x3<<6) //7:6
  604. +#define RG_USB20_BG_RASEL (0x3<<4) //5:4
  605. +#define RG_USB20_BGR_DIV (0x3<<2) //3:2
  606. +#define RG_SIFSLV_CHP_EN (0x1<<1) //1:1
  607. +#define RG_SIFSLV_BGR_EN (0x1<<0) //0:0
  608. +
  609. +//U3D_U2PHYAC1
  610. +#define RG_USB20_VRT_VREF_SEL (0x7<<28) //30:28
  611. +#define RG_USB20_TERM_VREF_SEL (0x7<<24) //26:24
  612. +#define RG_USB20_MPX_SEL (0xff<<16) //23:16
  613. +#define RG_USB20_MPX_OUT_SEL (0x3<<12) //13:12
  614. +#define RG_USB20_TX_PH_ROT_SEL (0x7<<8) //10:8
  615. +#define RG_USB20_USBPLL_ACCEN (0x1<<3) //3:3
  616. +#define RG_USB20_USBPLL_LF (0x1<<2) //2:2
  617. +#define RG_USB20_USBPLL_BR (0x1<<1) //1:1
  618. +#define RG_USB20_USBPLL_BP (0x1<<0) //0:0
  619. +
  620. +//U3D_U2PHYAC2
  621. +#define RG_SIFSLV_MAC_BANDGAP_EN (0x1<<17) //17:17
  622. +#define RG_SIFSLV_MAC_CHOPPER_EN (0x1<<16) //16:16
  623. +#define RG_USB20_CLKREF_REV (0xff<<0) //7:0
  624. +
  625. +//U3D_U2PHYACR0
  626. +#define RG_USB20_ICUSB_EN (0x1<<24) //24:24
  627. +#define RG_USB20_HSTX_SRCAL_EN (0x1<<23) //23:23
  628. +#define RG_USB20_HSTX_SRCTRL (0x7<<16) //18:16
  629. +#define RG_USB20_LS_CR (0x7<<12) //14:12
  630. +#define RG_USB20_FS_CR (0x7<<8) //10:8
  631. +#define RG_USB20_LS_SR (0x7<<4) //6:4
  632. +#define RG_USB20_FS_SR (0x7<<0) //2:0
  633. +
  634. +//U3D_U2PHYACR1
  635. +#define RG_USB20_INIT_SQ_EN_DG (0x3<<28) //29:28
  636. +#define RG_USB20_SQD (0x3<<24) //25:24
  637. +#define RG_USB20_HSTX_TMODE_SEL (0x3<<20) //21:20
  638. +#define RG_USB20_HSTX_TMODE_EN (0x1<<19) //19:19
  639. +#define RG_USB20_PHYD_MONEN (0x1<<18) //18:18
  640. +#define RG_USB20_INLPBK_EN (0x1<<17) //17:17
  641. +#define RG_USB20_CHIRP_EN (0x1<<16) //16:16
  642. +#define RG_USB20_DM_ABIST_SOURCE_EN (0x1<<15) //15:15
  643. +#define RG_USB20_DM_ABIST_SELE (0xf<<8) //11:8
  644. +#define RG_USB20_DP_ABIST_SOURCE_EN (0x1<<7) //7:7
  645. +#define RG_USB20_DP_ABIST_SELE (0xf<<0) //3:0
  646. +
  647. +//U3D_U2PHYACR2
  648. +#define RG_USB20_OTG_ABIST_SELE (0x7<<29) //31:29
  649. +#define RG_USB20_OTG_ABIST_EN (0x1<<28) //28:28
  650. +#define RG_USB20_OTG_VBUSCMP_EN (0x1<<27) //27:27
  651. +#define RG_USB20_OTG_VBUSTH (0x7<<24) //26:24
  652. +#define RG_USB20_DISC_FIT_EN (0x1<<22) //22:22
  653. +#define RG_USB20_DISCD (0x3<<20) //21:20
  654. +#define RG_USB20_DISCTH (0xf<<16) //19:16
  655. +#define RG_USB20_SQCAL_EN (0x1<<15) //15:15
  656. +#define RG_USB20_SQCAL (0xf<<8) //11:8
  657. +#define RG_USB20_SQTH (0xf<<0) //3:0
  658. +
  659. +//U3D_U2PHYACR3
  660. +#define RG_USB20_HSTX_DBIST (0xf<<28) //31:28
  661. +#define RG_USB20_HSTX_BIST_EN (0x1<<26) //26:26
  662. +#define RG_USB20_HSTX_I_EN_MODE (0x3<<24) //25:24
  663. +#define RG_USB20_HSRX_TMODE_EN (0x1<<23) //23:23
  664. +#define RG_USB20_HSRX_BIAS_EN_SEL (0x3<<20) //21:20
  665. +#define RG_USB20_USB11_TMODE_EN (0x1<<19) //19:19
  666. +#define RG_USB20_TMODE_FS_LS_TX_EN (0x1<<18) //18:18
  667. +#define RG_USB20_TMODE_FS_LS_RCV_EN (0x1<<17) //17:17
  668. +#define RG_USB20_TMODE_FS_LS_MODE (0x1<<16) //16:16
  669. +#define RG_USB20_HS_TERM_EN_MODE (0x3<<13) //14:13
  670. +#define RG_USB20_PUPD_BIST_EN (0x1<<12) //12:12
  671. +#define RG_USB20_EN_PU_DM (0x1<<11) //11:11
  672. +#define RG_USB20_EN_PD_DM (0x1<<10) //10:10
  673. +#define RG_USB20_EN_PU_DP (0x1<<9) //9:9
  674. +#define RG_USB20_EN_PD_DP (0x1<<8) //8:8
  675. +#define RG_USB20_PHY_REV (0xff<<0) //7:0
  676. +
  677. +//U3D_U2PHYACR4
  678. +#define RG_USB20_DP_100K_MODE (0x1<<18) //18:18
  679. +#define RG_USB20_DM_100K_EN (0x1<<17) //17:17
  680. +#define USB20_DP_100K_EN (0x1<<16) //16:16
  681. +#define USB20_GPIO_DM_I (0x1<<15) //15:15
  682. +#define USB20_GPIO_DP_I (0x1<<14) //14:14
  683. +#define USB20_GPIO_DM_OE (0x1<<13) //13:13
  684. +#define USB20_GPIO_DP_OE (0x1<<12) //12:12
  685. +#define RG_USB20_GPIO_CTL (0x1<<9) //9:9
  686. +#define USB20_GPIO_MODE (0x1<<8) //8:8
  687. +#define RG_USB20_TX_BIAS_EN (0x1<<5) //5:5
  688. +#define RG_USB20_TX_VCMPDN_EN (0x1<<4) //4:4
  689. +#define RG_USB20_HS_SQ_EN_MODE (0x3<<2) //3:2
  690. +#define RG_USB20_HS_RCV_EN_MODE (0x3<<0) //1:0
  691. +
  692. +//U3D_U2PHYAMON0
  693. +#define RGO_USB20_GPIO_DM_O (0x1<<1) //1:1
  694. +#define RGO_USB20_GPIO_DP_O (0x1<<0) //0:0
  695. +
  696. +//U3D_U2PHYDCR0
  697. +#define RG_USB20_CDR_TST (0x3<<30) //31:30
  698. +#define RG_USB20_GATED_ENB (0x1<<29) //29:29
  699. +#define RG_USB20_TESTMODE (0x3<<26) //27:26
  700. +#define RG_USB20_PLL_STABLE (0x1<<25) //25:25
  701. +#define RG_USB20_PLL_FORCE_ON (0x1<<24) //24:24
  702. +#define RG_USB20_PHYD_RESERVE (0xffff<<8) //23:8
  703. +#define RG_USB20_EBTHRLD (0x1<<7) //7:7
  704. +#define RG_USB20_EARLY_HSTX_I (0x1<<6) //6:6
  705. +#define RG_USB20_TX_TST (0x1<<5) //5:5
  706. +#define RG_USB20_NEGEDGE_ENB (0x1<<4) //4:4
  707. +#define RG_USB20_CDR_FILT (0xf<<0) //3:0
  708. +
  709. +//U3D_U2PHYDCR1
  710. +#define RG_USB20_PROBE_SEL (0xff<<24) //31:24
  711. +#define RG_USB20_DRVVBUS (0x1<<23) //23:23
  712. +#define RG_DEBUG_EN (0x1<<22) //22:22
  713. +#define RG_USB20_OTG_PROBE (0x3<<20) //21:20
  714. +#define RG_USB20_SW_PLLMODE (0x3<<18) //19:18
  715. +#define RG_USB20_BERTH (0x3<<16) //17:16
  716. +#define RG_USB20_LBMODE (0x3<<13) //14:13
  717. +#define RG_USB20_FORCE_TAP (0x1<<12) //12:12
  718. +#define RG_USB20_TAPSEL (0xfff<<0) //11:0
  719. +
  720. +//U3D_U2PHYDTM0
  721. +#define RG_UART_MODE (0x3<<30) //31:30
  722. +#define FORCE_UART_I (0x1<<29) //29:29
  723. +#define FORCE_UART_BIAS_EN (0x1<<28) //28:28
  724. +#define FORCE_UART_TX_OE (0x1<<27) //27:27
  725. +#define FORCE_UART_EN (0x1<<26) //26:26
  726. +#define FORCE_USB_CLKEN (0x1<<25) //25:25
  727. +#define FORCE_DRVVBUS (0x1<<24) //24:24
  728. +#define FORCE_DATAIN (0x1<<23) //23:23
  729. +#define FORCE_TXVALID (0x1<<22) //22:22
  730. +#define FORCE_DM_PULLDOWN (0x1<<21) //21:21
  731. +#define FORCE_DP_PULLDOWN (0x1<<20) //20:20
  732. +#define FORCE_XCVRSEL (0x1<<19) //19:19
  733. +#define FORCE_SUSPENDM (0x1<<18) //18:18
  734. +#define FORCE_TERMSEL (0x1<<17) //17:17
  735. +#define FORCE_OPMODE (0x1<<16) //16:16
  736. +#define UTMI_MUXSEL (0x1<<15) //15:15
  737. +#define RG_RESET (0x1<<14) //14:14
  738. +#define RG_DATAIN (0xf<<10) //13:10
  739. +#define RG_TXVALIDH (0x1<<9) //9:9
  740. +#define RG_TXVALID (0x1<<8) //8:8
  741. +#define RG_DMPULLDOWN (0x1<<7) //7:7
  742. +#define RG_DPPULLDOWN (0x1<<6) //6:6
  743. +#define RG_XCVRSEL (0x3<<4) //5:4
  744. +#define RG_SUSPENDM (0x1<<3) //3:3
  745. +#define RG_TERMSEL (0x1<<2) //2:2
  746. +#define RG_OPMODE (0x3<<0) //1:0
  747. +
  748. +//U3D_U2PHYDTM1
  749. +#define RG_USB20_PRBS7_EN (0x1<<31) //31:31
  750. +#define RG_USB20_PRBS7_BITCNT (0x3f<<24) //29:24
  751. +#define RG_USB20_CLK48M_EN (0x1<<23) //23:23
  752. +#define RG_USB20_CLK60M_EN (0x1<<22) //22:22
  753. +#define RG_UART_I (0x1<<19) //19:19
  754. +#define RG_UART_BIAS_EN (0x1<<18) //18:18
  755. +#define RG_UART_TX_OE (0x1<<17) //17:17
  756. +#define RG_UART_EN (0x1<<16) //16:16
  757. +#define FORCE_VBUSVALID (0x1<<13) //13:13
  758. +#define FORCE_SESSEND (0x1<<12) //12:12
  759. +#define FORCE_BVALID (0x1<<11) //11:11
  760. +#define FORCE_AVALID (0x1<<10) //10:10
  761. +#define FORCE_IDDIG (0x1<<9) //9:9
  762. +#define FORCE_IDPULLUP (0x1<<8) //8:8
  763. +#define RG_VBUSVALID (0x1<<5) //5:5
  764. +#define RG_SESSEND (0x1<<4) //4:4
  765. +#define RG_BVALID (0x1<<3) //3:3
  766. +#define RG_AVALID (0x1<<2) //2:2
  767. +#define RG_IDDIG (0x1<<1) //1:1
  768. +#define RG_IDPULLUP (0x1<<0) //0:0
  769. +
  770. +//U3D_U2PHYDMON0
  771. +#define RG_USB20_PRBS7_BERTH (0xff<<0) //7:0
  772. +
  773. +//U3D_U2PHYDMON1
  774. +#define USB20_UART_O (0x1<<31) //31:31
  775. +#define RGO_USB20_LB_PASS (0x1<<30) //30:30
  776. +#define RGO_USB20_LB_DONE (0x1<<29) //29:29
  777. +#define AD_USB20_BVALID (0x1<<28) //28:28
  778. +#define USB20_IDDIG (0x1<<27) //27:27
  779. +#define AD_USB20_VBUSVALID (0x1<<26) //26:26
  780. +#define AD_USB20_SESSEND (0x1<<25) //25:25
  781. +#define AD_USB20_AVALID (0x1<<24) //24:24
  782. +#define USB20_LINE_STATE (0x3<<22) //23:22
  783. +#define USB20_HST_DISCON (0x1<<21) //21:21
  784. +#define USB20_TX_READY (0x1<<20) //20:20
  785. +#define USB20_RX_ERROR (0x1<<19) //19:19
  786. +#define USB20_RX_ACTIVE (0x1<<18) //18:18
  787. +#define USB20_RX_VALIDH (0x1<<17) //17:17
  788. +#define USB20_RX_VALID (0x1<<16) //16:16
  789. +#define USB20_DATA_OUT (0xffff<<0) //15:0
  790. +
  791. +//U3D_U2PHYDMON2
  792. +#define RGO_TXVALID_CNT (0xff<<24) //31:24
  793. +#define RGO_RXACTIVE_CNT (0xff<<16) //23:16
  794. +#define RGO_USB20_LB_BERCNT (0xff<<8) //15:8
  795. +#define USB20_PROBE_OUT (0xff<<0) //7:0
  796. +
  797. +//U3D_U2PHYDMON3
  798. +#define RGO_USB20_PRBS7_ERRCNT (0xffff<<16) //31:16
  799. +#define RGO_USB20_PRBS7_DONE (0x1<<3) //3:3
  800. +#define RGO_USB20_PRBS7_LOCK (0x1<<2) //2:2
  801. +#define RGO_USB20_PRBS7_PASS (0x1<<1) //1:1
  802. +#define RGO_USB20_PRBS7_PASSTH (0x1<<0) //0:0
  803. +
  804. +//U3D_U2PHYBC12C
  805. +#define RG_SIFSLV_CHGDT_DEGLCH_CNT (0xf<<28) //31:28
  806. +#define RG_SIFSLV_CHGDT_CTRL_CNT (0xf<<24) //27:24
  807. +#define RG_SIFSLV_CHGDT_FORCE_MODE (0x1<<16) //16:16
  808. +#define RG_CHGDT_ISRC_LEV (0x3<<14) //15:14
  809. +#define RG_CHGDT_VDATSRC (0x1<<13) //13:13
  810. +#define RG_CHGDT_BGVREF_SEL (0x7<<10) //12:10
  811. +#define RG_CHGDT_RDVREF_SEL (0x3<<8) //9:8
  812. +#define RG_CHGDT_ISRC_DP (0x1<<7) //7:7
  813. +#define RG_SIFSLV_CHGDT_OPOUT_DM (0x1<<6) //6:6
  814. +#define RG_CHGDT_VDAT_DM (0x1<<5) //5:5
  815. +#define RG_CHGDT_OPOUT_DP (0x1<<4) //4:4
  816. +#define RG_SIFSLV_CHGDT_VDAT_DP (0x1<<3) //3:3
  817. +#define RG_SIFSLV_CHGDT_COMP_EN (0x1<<2) //2:2
  818. +#define RG_SIFSLV_CHGDT_OPDRV_EN (0x1<<1) //1:1
  819. +#define RG_CHGDT_EN (0x1<<0) //0:0
  820. +
  821. +//U3D_U2PHYBC12C1
  822. +#define RG_CHGDT_REV (0xff<<0) //7:0
  823. +
  824. +//U3D_REGFCOM
  825. +#define RG_PAGE (0xff<<24) //31:24
  826. +#define I2C_MODE (0x1<<16) //16:16
  827. +
  828. +
  829. +/* OFFSET */
  830. +
  831. +//U3D_U2PHYAC0
  832. +#define RG_USB20_USBPLL_DIVEN_OFST (28)
  833. +#define RG_USB20_USBPLL_CKCTRL_OFST (26)
  834. +#define RG_USB20_USBPLL_PREDIV_OFST (24)
  835. +#define RG_USB20_USBPLL_FORCE_ON_OFST (23)
  836. +#define RG_USB20_USBPLL_FBDIV_OFST (16)
  837. +#define RG_USB20_REF_EN_OFST (15)
  838. +#define RG_USB20_INTR_EN_OFST (14)
  839. +#define RG_USB20_BG_TRIM_OFST (8)
  840. +#define RG_USB20_BG_RBSEL_OFST (6)
  841. +#define RG_USB20_BG_RASEL_OFST (4)
  842. +#define RG_USB20_BGR_DIV_OFST (2)
  843. +#define RG_SIFSLV_CHP_EN_OFST (1)
  844. +#define RG_SIFSLV_BGR_EN_OFST (0)
  845. +
  846. +//U3D_U2PHYAC1
  847. +#define RG_USB20_VRT_VREF_SEL_OFST (28)
  848. +#define RG_USB20_TERM_VREF_SEL_OFST (24)
  849. +#define RG_USB20_MPX_SEL_OFST (16)
  850. +#define RG_USB20_MPX_OUT_SEL_OFST (12)
  851. +#define RG_USB20_TX_PH_ROT_SEL_OFST (8)
  852. +#define RG_USB20_USBPLL_ACCEN_OFST (3)
  853. +#define RG_USB20_USBPLL_LF_OFST (2)
  854. +#define RG_USB20_USBPLL_BR_OFST (1)
  855. +#define RG_USB20_USBPLL_BP_OFST (0)
  856. +
  857. +//U3D_U2PHYAC2
  858. +#define RG_SIFSLV_MAC_BANDGAP_EN_OFST (17)
  859. +#define RG_SIFSLV_MAC_CHOPPER_EN_OFST (16)
  860. +#define RG_USB20_CLKREF_REV_OFST (0)
  861. +
  862. +//U3D_U2PHYACR0
  863. +#define RG_USB20_ICUSB_EN_OFST (24)
  864. +#define RG_USB20_HSTX_SRCAL_EN_OFST (23)
  865. +#define RG_USB20_HSTX_SRCTRL_OFST (16)
  866. +#define RG_USB20_LS_CR_OFST (12)
  867. +#define RG_USB20_FS_CR_OFST (8)
  868. +#define RG_USB20_LS_SR_OFST (4)
  869. +#define RG_USB20_FS_SR_OFST (0)
  870. +
  871. +//U3D_U2PHYACR1
  872. +#define RG_USB20_INIT_SQ_EN_DG_OFST (28)
  873. +#define RG_USB20_SQD_OFST (24)
  874. +#define RG_USB20_HSTX_TMODE_SEL_OFST (20)
  875. +#define RG_USB20_HSTX_TMODE_EN_OFST (19)
  876. +#define RG_USB20_PHYD_MONEN_OFST (18)
  877. +#define RG_USB20_INLPBK_EN_OFST (17)
  878. +#define RG_USB20_CHIRP_EN_OFST (16)
  879. +#define RG_USB20_DM_ABIST_SOURCE_EN_OFST (15)
  880. +#define RG_USB20_DM_ABIST_SELE_OFST (8)
  881. +#define RG_USB20_DP_ABIST_SOURCE_EN_OFST (7)
  882. +#define RG_USB20_DP_ABIST_SELE_OFST (0)
  883. +
  884. +//U3D_U2PHYACR2
  885. +#define RG_USB20_OTG_ABIST_SELE_OFST (29)
  886. +#define RG_USB20_OTG_ABIST_EN_OFST (28)
  887. +#define RG_USB20_OTG_VBUSCMP_EN_OFST (27)
  888. +#define RG_USB20_OTG_VBUSTH_OFST (24)
  889. +#define RG_USB20_DISC_FIT_EN_OFST (22)
  890. +#define RG_USB20_DISCD_OFST (20)
  891. +#define RG_USB20_DISCTH_OFST (16)
  892. +#define RG_USB20_SQCAL_EN_OFST (15)
  893. +#define RG_USB20_SQCAL_OFST (8)
  894. +#define RG_USB20_SQTH_OFST (0)
  895. +
  896. +//U3D_U2PHYACR3
  897. +#define RG_USB20_HSTX_DBIST_OFST (28)
  898. +#define RG_USB20_HSTX_BIST_EN_OFST (26)
  899. +#define RG_USB20_HSTX_I_EN_MODE_OFST (24)
  900. +#define RG_USB20_HSRX_TMODE_EN_OFST (23)
  901. +#define RG_USB20_HSRX_BIAS_EN_SEL_OFST (20)
  902. +#define RG_USB20_USB11_TMODE_EN_OFST (19)
  903. +#define RG_USB20_TMODE_FS_LS_TX_EN_OFST (18)
  904. +#define RG_USB20_TMODE_FS_LS_RCV_EN_OFST (17)
  905. +#define RG_USB20_TMODE_FS_LS_MODE_OFST (16)
  906. +#define RG_USB20_HS_TERM_EN_MODE_OFST (13)
  907. +#define RG_USB20_PUPD_BIST_EN_OFST (12)
  908. +#define RG_USB20_EN_PU_DM_OFST (11)
  909. +#define RG_USB20_EN_PD_DM_OFST (10)
  910. +#define RG_USB20_EN_PU_DP_OFST (9)
  911. +#define RG_USB20_EN_PD_DP_OFST (8)
  912. +#define RG_USB20_PHY_REV_OFST (0)
  913. +
  914. +//U3D_U2PHYACR4
  915. +#define RG_USB20_DP_100K_MODE_OFST (18)
  916. +#define RG_USB20_DM_100K_EN_OFST (17)
  917. +#define USB20_DP_100K_EN_OFST (16)
  918. +#define USB20_GPIO_DM_I_OFST (15)
  919. +#define USB20_GPIO_DP_I_OFST (14)
  920. +#define USB20_GPIO_DM_OE_OFST (13)
  921. +#define USB20_GPIO_DP_OE_OFST (12)
  922. +#define RG_USB20_GPIO_CTL_OFST (9)
  923. +#define USB20_GPIO_MODE_OFST (8)
  924. +#define RG_USB20_TX_BIAS_EN_OFST (5)
  925. +#define RG_USB20_TX_VCMPDN_EN_OFST (4)
  926. +#define RG_USB20_HS_SQ_EN_MODE_OFST (2)
  927. +#define RG_USB20_HS_RCV_EN_MODE_OFST (0)
  928. +
  929. +//U3D_U2PHYAMON0
  930. +#define RGO_USB20_GPIO_DM_O_OFST (1)
  931. +#define RGO_USB20_GPIO_DP_O_OFST (0)
  932. +
  933. +//U3D_U2PHYDCR0
  934. +#define RG_USB20_CDR_TST_OFST (30)
  935. +#define RG_USB20_GATED_ENB_OFST (29)
  936. +#define RG_USB20_TESTMODE_OFST (26)
  937. +#define RG_USB20_PLL_STABLE_OFST (25)
  938. +#define RG_USB20_PLL_FORCE_ON_OFST (24)
  939. +#define RG_USB20_PHYD_RESERVE_OFST (8)
  940. +#define RG_USB20_EBTHRLD_OFST (7)
  941. +#define RG_USB20_EARLY_HSTX_I_OFST (6)
  942. +#define RG_USB20_TX_TST_OFST (5)
  943. +#define RG_USB20_NEGEDGE_ENB_OFST (4)
  944. +#define RG_USB20_CDR_FILT_OFST (0)
  945. +
  946. +//U3D_U2PHYDCR1
  947. +#define RG_USB20_PROBE_SEL_OFST (24)
  948. +#define RG_USB20_DRVVBUS_OFST (23)
  949. +#define RG_DEBUG_EN_OFST (22)
  950. +#define RG_USB20_OTG_PROBE_OFST (20)
  951. +#define RG_USB20_SW_PLLMODE_OFST (18)
  952. +#define RG_USB20_BERTH_OFST (16)
  953. +#define RG_USB20_LBMODE_OFST (13)
  954. +#define RG_USB20_FORCE_TAP_OFST (12)
  955. +#define RG_USB20_TAPSEL_OFST (0)
  956. +
  957. +//U3D_U2PHYDTM0
  958. +#define RG_UART_MODE_OFST (30)
  959. +#define FORCE_UART_I_OFST (29)
  960. +#define FORCE_UART_BIAS_EN_OFST (28)
  961. +#define FORCE_UART_TX_OE_OFST (27)
  962. +#define FORCE_UART_EN_OFST (26)
  963. +#define FORCE_USB_CLKEN_OFST (25)
  964. +#define FORCE_DRVVBUS_OFST (24)
  965. +#define FORCE_DATAIN_OFST (23)
  966. +#define FORCE_TXVALID_OFST (22)
  967. +#define FORCE_DM_PULLDOWN_OFST (21)
  968. +#define FORCE_DP_PULLDOWN_OFST (20)
  969. +#define FORCE_XCVRSEL_OFST (19)
  970. +#define FORCE_SUSPENDM_OFST (18)
  971. +#define FORCE_TERMSEL_OFST (17)
  972. +#define FORCE_OPMODE_OFST (16)
  973. +#define UTMI_MUXSEL_OFST (15)
  974. +#define RG_RESET_OFST (14)
  975. +#define RG_DATAIN_OFST (10)
  976. +#define RG_TXVALIDH_OFST (9)
  977. +#define RG_TXVALID_OFST (8)
  978. +#define RG_DMPULLDOWN_OFST (7)
  979. +#define RG_DPPULLDOWN_OFST (6)
  980. +#define RG_XCVRSEL_OFST (4)
  981. +#define RG_SUSPENDM_OFST (3)
  982. +#define RG_TERMSEL_OFST (2)
  983. +#define RG_OPMODE_OFST (0)
  984. +
  985. +//U3D_U2PHYDTM1
  986. +#define RG_USB20_PRBS7_EN_OFST (31)
  987. +#define RG_USB20_PRBS7_BITCNT_OFST (24)
  988. +#define RG_USB20_CLK48M_EN_OFST (23)
  989. +#define RG_USB20_CLK60M_EN_OFST (22)
  990. +#define RG_UART_I_OFST (19)
  991. +#define RG_UART_BIAS_EN_OFST (18)
  992. +#define RG_UART_TX_OE_OFST (17)
  993. +#define RG_UART_EN_OFST (16)
  994. +#define FORCE_VBUSVALID_OFST (13)
  995. +#define FORCE_SESSEND_OFST (12)
  996. +#define FORCE_BVALID_OFST (11)
  997. +#define FORCE_AVALID_OFST (10)
  998. +#define FORCE_IDDIG_OFST (9)
  999. +#define FORCE_IDPULLUP_OFST (8)
  1000. +#define RG_VBUSVALID_OFST (5)
  1001. +#define RG_SESSEND_OFST (4)
  1002. +#define RG_BVALID_OFST (3)
  1003. +#define RG_AVALID_OFST (2)
  1004. +#define RG_IDDIG_OFST (1)
  1005. +#define RG_IDPULLUP_OFST (0)
  1006. +
  1007. +//U3D_U2PHYDMON0
  1008. +#define RG_USB20_PRBS7_BERTH_OFST (0)
  1009. +
  1010. +//U3D_U2PHYDMON1
  1011. +#define USB20_UART_O_OFST (31)
  1012. +#define RGO_USB20_LB_PASS_OFST (30)
  1013. +#define RGO_USB20_LB_DONE_OFST (29)
  1014. +#define AD_USB20_BVALID_OFST (28)
  1015. +#define USB20_IDDIG_OFST (27)
  1016. +#define AD_USB20_VBUSVALID_OFST (26)
  1017. +#define AD_USB20_SESSEND_OFST (25)
  1018. +#define AD_USB20_AVALID_OFST (24)
  1019. +#define USB20_LINE_STATE_OFST (22)
  1020. +#define USB20_HST_DISCON_OFST (21)
  1021. +#define USB20_TX_READY_OFST (20)
  1022. +#define USB20_RX_ERROR_OFST (19)
  1023. +#define USB20_RX_ACTIVE_OFST (18)
  1024. +#define USB20_RX_VALIDH_OFST (17)
  1025. +#define USB20_RX_VALID_OFST (16)
  1026. +#define USB20_DATA_OUT_OFST (0)
  1027. +
  1028. +//U3D_U2PHYDMON2
  1029. +#define RGO_TXVALID_CNT_OFST (24)
  1030. +#define RGO_RXACTIVE_CNT_OFST (16)
  1031. +#define RGO_USB20_LB_BERCNT_OFST (8)
  1032. +#define USB20_PROBE_OUT_OFST (0)
  1033. +
  1034. +//U3D_U2PHYDMON3
  1035. +#define RGO_USB20_PRBS7_ERRCNT_OFST (16)
  1036. +#define RGO_USB20_PRBS7_DONE_OFST (3)
  1037. +#define RGO_USB20_PRBS7_LOCK_OFST (2)
  1038. +#define RGO_USB20_PRBS7_PASS_OFST (1)
  1039. +#define RGO_USB20_PRBS7_PASSTH_OFST (0)
  1040. +
  1041. +//U3D_U2PHYBC12C
  1042. +#define RG_SIFSLV_CHGDT_DEGLCH_CNT_OFST (28)
  1043. +#define RG_SIFSLV_CHGDT_CTRL_CNT_OFST (24)
  1044. +#define RG_SIFSLV_CHGDT_FORCE_MODE_OFST (16)
  1045. +#define RG_CHGDT_ISRC_LEV_OFST (14)
  1046. +#define RG_CHGDT_VDATSRC_OFST (13)
  1047. +#define RG_CHGDT_BGVREF_SEL_OFST (10)
  1048. +#define RG_CHGDT_RDVREF_SEL_OFST (8)
  1049. +#define RG_CHGDT_ISRC_DP_OFST (7)
  1050. +#define RG_SIFSLV_CHGDT_OPOUT_DM_OFST (6)
  1051. +#define RG_CHGDT_VDAT_DM_OFST (5)
  1052. +#define RG_CHGDT_OPOUT_DP_OFST (4)
  1053. +#define RG_SIFSLV_CHGDT_VDAT_DP_OFST (3)
  1054. +#define RG_SIFSLV_CHGDT_COMP_EN_OFST (2)
  1055. +#define RG_SIFSLV_CHGDT_OPDRV_EN_OFST (1)
  1056. +#define RG_CHGDT_EN_OFST (0)
  1057. +
  1058. +//U3D_U2PHYBC12C1
  1059. +#define RG_CHGDT_REV_OFST (0)
  1060. +
  1061. +//U3D_REGFCOM
  1062. +#define RG_PAGE_OFST (24)
  1063. +#define I2C_MODE_OFST (16)
  1064. +
  1065. +
  1066. +///////////////////////////////////////////////////////////////////////////////
  1067. +
  1068. +struct u3phya_reg {
  1069. + //0x0
  1070. + PHY_LE32 reg0;
  1071. + PHY_LE32 reg1;
  1072. + PHY_LE32 reg2;
  1073. + PHY_LE32 reg3;
  1074. + //0x10
  1075. + PHY_LE32 reg4;
  1076. + PHY_LE32 reg5;
  1077. + PHY_LE32 reg6;
  1078. + PHY_LE32 reg7;
  1079. + //0x20
  1080. + PHY_LE32 reg8;
  1081. + PHY_LE32 reg9;
  1082. + PHY_LE32 rega;
  1083. + PHY_LE32 regb;
  1084. + //0x30
  1085. + PHY_LE32 regc;
  1086. + PHY_LE32 regd;
  1087. + PHY_LE32 rege;
  1088. +};
  1089. +
  1090. +//U3D_reg0
  1091. +#define RG_SSUSB_BGR_EN (0x1<<31) //31:31
  1092. +#define RG_SSUSB_CHPEN (0x1<<30) //30:30
  1093. +#define RG_SSUSB_BG_DIV (0x3<<28) //29:28
  1094. +#define RG_SSUSB_INTR_EN (0x1<<26) //26:26
  1095. +#define RG_SSUSB_MPX_OUT_SEL (0x3<<24) //25:24
  1096. +#define RG_SSUSB_MPX_SEL (0xff<<16) //23:16
  1097. +#define RG_SSUSB_REF_EN (0x1<<15) //15:15
  1098. +#define RG_SSUSB_VRT_VREF_SEL (0xf<<11) //14:11
  1099. +#define RG_SSUSB_BG_RASEL (0x3<<9) //10:9
  1100. +#define RG_SSUSB_BG_RBSEL (0x3<<7) //8:7
  1101. +#define RG_SSUSB_BG_MONEN (0x1<<6) //6:6
  1102. +#define RG_PCIE_CLKDRV_OFFSET (0x3<<0) //1:0
  1103. +
  1104. +//U3D_reg1
  1105. +#define RG_PCIE_CLKDRV_SLEW (0x3<<30) //31:30
  1106. +#define RG_PCIE_CLKDRV_AMP (0x7<<27) //29:27
  1107. +#define RG_SSUSB_XTAL_TST_A2DCK_EN (0x1<<26) //26:26
  1108. +#define RG_SSUSB_XTAL_MON_EN (0x1<<25) //25:25
  1109. +#define RG_SSUSB_XTAL_HYS (0x1<<24) //24:24
  1110. +#define RG_SSUSB_XTAL_TOP_RESERVE (0xffff<<8) //23:8
  1111. +#define RG_SSUSB_SYSPLL_RESERVE (0xf<<4) //7:4
  1112. +#define RG_SSUSB_SYSPLL_FBSEL (0x3<<2) //3:2
  1113. +#define RG_SSUSB_SYSPLL_PREDIV (0x3<<0) //1:0
  1114. +
  1115. +//U3D_reg2
  1116. +#define RG_SSUSB_SYSPLL_LF (0x1<<31) //31:31
  1117. +#define RG_SSUSB_SYSPLL_FBDIV (0x7f<<24) //30:24
  1118. +#define RG_SSUSB_SYSPLL_POSDIV (0x3<<22) //23:22
  1119. +#define RG_SSUSB_SYSPLL_VCO_DIV_SEL (0x1<<21) //21:21
  1120. +#define RG_SSUSB_SYSPLL_BLP (0x1<<20) //20:20
  1121. +#define RG_SSUSB_SYSPLL_BP (0x1<<19) //19:19
  1122. +#define RG_SSUSB_SYSPLL_BR (0x1<<18) //18:18
  1123. +#define RG_SSUSB_SYSPLL_BC (0x1<<17) //17:17
  1124. +#define RG_SSUSB_SYSPLL_DIVEN (0x7<<14) //16:14
  1125. +#define RG_SSUSB_SYSPLL_FPEN (0x1<<13) //13:13
  1126. +#define RG_SSUSB_SYSPLL_MONCK_EN (0x1<<12) //12:12
  1127. +#define RG_SSUSB_SYSPLL_MONVC_EN (0x1<<11) //11:11
  1128. +#define RG_SSUSB_SYSPLL_MONREF_EN (0x1<<10) //10:10
  1129. +#define RG_SSUSB_SYSPLL_VOD_EN (0x1<<9) //9:9
  1130. +#define RG_SSUSB_SYSPLL_CK_SEL (0x1<<8) //8:8
  1131. +
  1132. +//U3D_reg3
  1133. +#define RG_SSUSB_SYSPLL_TOP_RESERVE (0xffff<<16) //31:16
  1134. +
  1135. +//U3D_reg4
  1136. +#define RG_SSUSB_SYSPLL_PCW_NCPO (0x7fffffff<<1) //31:1
  1137. +
  1138. +//U3D_reg5
  1139. +#define RG_SSUSB_SYSPLL_DDS_PI_C (0x7<<29) //31:29
  1140. +#define RG_SSUSB_SYSPLL_DDS_HF_EN (0x1<<28) //28:28
  1141. +#define RG_SSUSB_SYSPLL_DDS_PREDIV2 (0x1<<27) //27:27
  1142. +#define RG_SSUSB_SYSPLL_DDS_POSTDIV2 (0x1<<26) //26:26
  1143. +#define RG_SSUSB_SYSPLL_DDS_PI_PL_EN (0x1<<25) //25:25
  1144. +#define RG_SSUSB_SYSPLL_DDS_PI_RST_SEL (0x1<<24) //24:24
  1145. +#define RG_SSUSB_SYSPLL_DDS_MONEN (0x1<<23) //23:23
  1146. +#define RG_SSUSB_SYSPLL_DDS_LPF_EN (0x1<<22) //22:22
  1147. +#define RG_SSUSB_SYSPLL_CLK_PH_INV (0x1<<21) //21:21
  1148. +#define RG_SSUSB_SYSPLL_DDS_SEL_EXT (0x1<<20) //20:20
  1149. +#define RG_SSUSB_SYSPLL_DDS_DMY (0xffff<<0) //15:0
  1150. +
  1151. +//U3D_reg6
  1152. +#define RG_SSUSB_TX250MCK_INVB (0x1<<31) //31:31
  1153. +#define RG_SSUSB_IDRV_ITAILOP_EN (0x1<<30) //30:30
  1154. +#define RG_SSUSB_IDRV_CALIB (0x3f<<24) //29:24
  1155. +#define RG_SSUSB_TX_R50_FON (0x1<<23) //23:23
  1156. +#define RG_SSUSB_TX_SR (0x7<<20) //22:20
  1157. +#define RG_SSUSB_TX_EIDLE_CM (0xf<<16) //19:16
  1158. +#define RG_SSUSB_RXDET_RSEL (0x3<<14) //15:14
  1159. +#define RG_SSUSB_RXDET_VTHSEL (0x3<<12) //13:12
  1160. +#define RG_SSUSB_CKMON_EN (0x1<<11) //11:11
  1161. +#define RG_SSUSB_CKMON_SEL (0x7<<8) //10:8
  1162. +#define RG_SSUSB_TX_VLMON_EN (0x1<<7) //7:7
  1163. +#define RG_SSUSB_TX_VLMON_SEL (0x1<<6) //6:6
  1164. +#define RG_SSUSB_RXLBTX_EN (0x1<<5) //5:5
  1165. +#define RG_SSUSB_TXLBRX_EN (0x1<<4) //4:4
  1166. +
  1167. +//U3D_reg7
  1168. +#define RG_SSUSB_RESERVE (0xfffff<<12) //31:12
  1169. +#define RG_SSUSB_PLL_CKCTRL (0x3<<10) //11:10
  1170. +#define RG_SSUSB_PLL_POSDIV (0x3<<8) //9:8
  1171. +#define RG_SSUSB_PLL_AUTOK_LOAD (0x1<<7) //7:7
  1172. +#define RG_SSUSB_PLL_LOAD_RSTB (0x1<<6) //6:6
  1173. +#define RG_SSUSB_PLL_EP_EN (0x1<<5) //5:5
  1174. +#define RG_SSUSB_PLL_VOD_EN (0x1<<4) //4:4
  1175. +#define RG_SSUSB_PLL_V11_EN (0x1<<3) //3:3
  1176. +#define RG_SSUSB_PLL_MONREF_EN (0x1<<2) //2:2
  1177. +#define RG_SSUSB_PLL_MONCK_EN (0x1<<1) //1:1
  1178. +#define RG_SSUSB_PLL_MONVC_EN (0x1<<0) //0:0
  1179. +
  1180. +//U3D_reg8
  1181. +#define RG_SSUSB_PLL_RESERVE (0xffff<<0) //15:0
  1182. +
  1183. +//U3D_reg9
  1184. +#define RG_SSUSB_PLL_DDS_DMY (0xffff<<16) //31:16
  1185. +#define RG_SSUSB_PLL_SSC_PRD (0xffff<<0) //15:0
  1186. +
  1187. +//U3D_regA
  1188. +#define RG_SSUSB_PLL_SSC_PHASE_INI (0x1<<31) //31:31
  1189. +#define RG_SSUSB_PLL_SSC_TRI_EN (0x1<<30) //30:30
  1190. +#define RG_SSUSB_PLL_CLK_PH_INV (0x1<<29) //29:29
  1191. +#define RG_SSUSB_PLL_DDS_LPF_EN (0x1<<28) //28:28
  1192. +#define RG_SSUSB_PLL_DDS_VADJ (0x7<<21) //23:21
  1193. +#define RG_SSUSB_PLL_DDS_MONEN (0x1<<20) //20:20
  1194. +#define RG_SSUSB_PLL_DDS_PS_VADJ (0x7<<17) //19:17
  1195. +#define RG_SSUSB_PLL_DDS_SEL_EXT (0x1<<16) //16:16
  1196. +#define RG_SSUSB_CDR_PD_DIV_BYPASS (0x1<<15) //15:15
  1197. +#define RG_SSUSB_CDR_PD_DIV_SEL (0x1<<14) //14:14
  1198. +#define RG_SSUSB_CDR_CPBIAS_SEL (0x1<<13) //13:13
  1199. +#define RG_SSUSB_CDR_OSCDET_EN (0x1<<12) //12:12
  1200. +#define RG_SSUSB_CDR_MONMUX (0x1<<11) //11:11
  1201. +#define RG_SSUSB_CDR_CKCTRL (0x3<<9) //10:9
  1202. +#define RG_SSUSB_CDR_ACCEN (0x1<<8) //8:8
  1203. +#define RG_SSUSB_CDR_BYPASS (0x3<<6) //7:6
  1204. +#define RG_SSUSB_CDR_PI_SLEW (0x3<<4) //5:4
  1205. +#define RG_SSUSB_CDR_EPEN (0x1<<3) //3:3
  1206. +#define RG_SSUSB_CDR_AUTOK_LOAD (0x1<<2) //2:2
  1207. +#define RG_SSUSB_CDR_LOAD_RSTB (0x1<<1) //1:1
  1208. +#define RG_SSUSB_CDR_MONEN (0x1<<0) //0:0
  1209. +
  1210. +//U3D_regB
  1211. +#define RG_SSUSB_CDR_MONEN_DIG (0x1<<31) //31:31
  1212. +#define RG_SSUSB_CDR_REGOD (0x3<<29) //30:29
  1213. +#define RG_SSUSB_RX_DAC_EN (0x1<<26) //26:26
  1214. +#define RG_SSUSB_RX_DAC_PWD (0x1<<25) //25:25
  1215. +#define RG_SSUSB_EQ_CURSEL (0x1<<24) //24:24
  1216. +#define RG_SSUSB_RX_DAC_MUX (0x1f<<19) //23:19
  1217. +#define RG_SSUSB_RX_R2T_EN (0x1<<18) //18:18
  1218. +#define RG_SSUSB_RX_T2R_EN (0x1<<17) //17:17
  1219. +#define RG_SSUSB_RX_50_LOWER (0x7<<14) //16:14
  1220. +#define RG_SSUSB_RX_50_TAR (0x3<<12) //13:12
  1221. +#define RG_SSUSB_RX_SW_CTRL (0xf<<7) //10:7
  1222. +#define RG_PCIE_SIGDET_VTH (0x3<<5) //6:5
  1223. +#define RG_PCIE_SIGDET_LPF (0x3<<3) //4:3
  1224. +#define RG_SSUSB_LFPS_MON_EN (0x1<<2) //2:2
  1225. +
  1226. +//U3D_regC
  1227. +#define RG_SSUSB_RXAFE_DCMON_SEL (0xf<<28) //31:28
  1228. +#define RG_SSUSB_CDR_RESERVE (0xff<<16) //23:16
  1229. +#define RG_SSUSB_RXAFE_RESERVE (0xff<<8) //15:8
  1230. +#define RG_PCIE_RX_RESERVE (0xff<<0) //7:0
  1231. +
  1232. +//U3D_redD
  1233. +#define RGS_SSUSB_CDR_NO_OSC (0x1<<8) //8:8
  1234. +#define RGS_SSUSB_RX_DEBUG_RESERVE (0xff<<0) //7:0
  1235. +
  1236. +//U3D_regE
  1237. +#define RG_SSUSB_INT_BIAS_SEL (0x1<<4) //4:4
  1238. +#define RG_SSUSB_EXT_BIAS_SEL (0x1<<3) //3:3
  1239. +#define RG_SSUSB_RX_P1_ENTRY_PASS (0x1<<2) //2:2
  1240. +#define RG_SSUSB_RX_PD_RST (0x1<<1) //1:1
  1241. +#define RG_SSUSB_RX_PD_RST_PASS (0x1<<0) //0:0
  1242. +
  1243. +
  1244. +/* OFFSET */
  1245. +
  1246. +//U3D_reg0
  1247. +#define RG_SSUSB_BGR_EN_OFST (31)
  1248. +#define RG_SSUSB_CHPEN_OFST (30)
  1249. +#define RG_SSUSB_BG_DIV_OFST (28)
  1250. +#define RG_SSUSB_INTR_EN_OFST (26)
  1251. +#define RG_SSUSB_MPX_OUT_SEL_OFST (24)
  1252. +#define RG_SSUSB_MPX_SEL_OFST (16)
  1253. +#define RG_SSUSB_REF_EN_OFST (15)
  1254. +#define RG_SSUSB_VRT_VREF_SEL_OFST (11)
  1255. +#define RG_SSUSB_BG_RASEL_OFST (9)
  1256. +#define RG_SSUSB_BG_RBSEL_OFST (7)
  1257. +#define RG_SSUSB_BG_MONEN_OFST (6)
  1258. +#define RG_PCIE_CLKDRV_OFFSET_OFST (0)
  1259. +
  1260. +//U3D_reg1
  1261. +#define RG_PCIE_CLKDRV_SLEW_OFST (30)
  1262. +#define RG_PCIE_CLKDRV_AMP_OFST (27)
  1263. +#define RG_SSUSB_XTAL_TST_A2DCK_EN_OFST (26)
  1264. +#define RG_SSUSB_XTAL_MON_EN_OFST (25)
  1265. +#define RG_SSUSB_XTAL_HYS_OFST (24)
  1266. +#define RG_SSUSB_XTAL_TOP_RESERVE_OFST (8)
  1267. +#define RG_SSUSB_SYSPLL_RESERVE_OFST (4)
  1268. +#define RG_SSUSB_SYSPLL_FBSEL_OFST (2)
  1269. +#define RG_SSUSB_SYSPLL_PREDIV_OFST (0)
  1270. +
  1271. +//U3D_reg2
  1272. +#define RG_SSUSB_SYSPLL_LF_OFST (31)
  1273. +#define RG_SSUSB_SYSPLL_FBDIV_OFST (24)
  1274. +#define RG_SSUSB_SYSPLL_POSDIV_OFST (22)
  1275. +#define RG_SSUSB_SYSPLL_VCO_DIV_SEL_OFST (21)
  1276. +#define RG_SSUSB_SYSPLL_BLP_OFST (20)
  1277. +#define RG_SSUSB_SYSPLL_BP_OFST (19)
  1278. +#define RG_SSUSB_SYSPLL_BR_OFST (18)
  1279. +#define RG_SSUSB_SYSPLL_BC_OFST (17)
  1280. +#define RG_SSUSB_SYSPLL_DIVEN_OFST (14)
  1281. +#define RG_SSUSB_SYSPLL_FPEN_OFST (13)
  1282. +#define RG_SSUSB_SYSPLL_MONCK_EN_OFST (12)
  1283. +#define RG_SSUSB_SYSPLL_MONVC_EN_OFST (11)
  1284. +#define RG_SSUSB_SYSPLL_MONREF_EN_OFST (10)
  1285. +#define RG_SSUSB_SYSPLL_VOD_EN_OFST (9)
  1286. +#define RG_SSUSB_SYSPLL_CK_SEL_OFST (8)
  1287. +
  1288. +//U3D_reg3
  1289. +#define RG_SSUSB_SYSPLL_TOP_RESERVE_OFST (16)
  1290. +
  1291. +//U3D_reg4
  1292. +#define RG_SSUSB_SYSPLL_PCW_NCPO_OFST (1)
  1293. +
  1294. +//U3D_reg5
  1295. +#define RG_SSUSB_SYSPLL_DDS_PI_C_OFST (29)
  1296. +#define RG_SSUSB_SYSPLL_DDS_HF_EN_OFST (28)
  1297. +#define RG_SSUSB_SYSPLL_DDS_PREDIV2_OFST (27)
  1298. +#define RG_SSUSB_SYSPLL_DDS_POSTDIV2_OFST (26)
  1299. +#define RG_SSUSB_SYSPLL_DDS_PI_PL_EN_OFST (25)
  1300. +#define RG_SSUSB_SYSPLL_DDS_PI_RST_SEL_OFST (24)
  1301. +#define RG_SSUSB_SYSPLL_DDS_MONEN_OFST (23)
  1302. +#define RG_SSUSB_SYSPLL_DDS_LPF_EN_OFST (22)
  1303. +#define RG_SSUSB_SYSPLL_CLK_PH_INV_OFST (21)
  1304. +#define RG_SSUSB_SYSPLL_DDS_SEL_EXT_OFST (20)
  1305. +#define RG_SSUSB_SYSPLL_DDS_DMY_OFST (0)
  1306. +
  1307. +//U3D_reg6
  1308. +#define RG_SSUSB_TX250MCK_INVB_OFST (31)
  1309. +#define RG_SSUSB_IDRV_ITAILOP_EN_OFST (30)
  1310. +#define RG_SSUSB_IDRV_CALIB_OFST (24)
  1311. +#define RG_SSUSB_TX_R50_FON_OFST (23)
  1312. +#define RG_SSUSB_TX_SR_OFST (20)
  1313. +#define RG_SSUSB_TX_EIDLE_CM_OFST (16)
  1314. +#define RG_SSUSB_RXDET_RSEL_OFST (14)
  1315. +#define RG_SSUSB_RXDET_VTHSEL_OFST (12)
  1316. +#define RG_SSUSB_CKMON_EN_OFST (11)
  1317. +#define RG_SSUSB_CKMON_SEL_OFST (8)
  1318. +#define RG_SSUSB_TX_VLMON_EN_OFST (7)
  1319. +#define RG_SSUSB_TX_VLMON_SEL_OFST (6)
  1320. +#define RG_SSUSB_RXLBTX_EN_OFST (5)
  1321. +#define RG_SSUSB_TXLBRX_EN_OFST (4)
  1322. +
  1323. +//U3D_reg7
  1324. +#define RG_SSUSB_RESERVE_OFST (12)
  1325. +#define RG_SSUSB_PLL_CKCTRL_OFST (10)
  1326. +#define RG_SSUSB_PLL_POSDIV_OFST (8)
  1327. +#define RG_SSUSB_PLL_AUTOK_LOAD_OFST (7)
  1328. +#define RG_SSUSB_PLL_LOAD_RSTB_OFST (6)
  1329. +#define RG_SSUSB_PLL_EP_EN_OFST (5)
  1330. +#define RG_SSUSB_PLL_VOD_EN_OFST (4)
  1331. +#define RG_SSUSB_PLL_V11_EN_OFST (3)
  1332. +#define RG_SSUSB_PLL_MONREF_EN_OFST (2)
  1333. +#define RG_SSUSB_PLL_MONCK_EN_OFST (1)
  1334. +#define RG_SSUSB_PLL_MONVC_EN_OFST (0)
  1335. +
  1336. +//U3D_reg8
  1337. +#define RG_SSUSB_PLL_RESERVE_OFST (0)
  1338. +
  1339. +//U3D_reg9
  1340. +#define RG_SSUSB_PLL_DDS_DMY_OFST (16)
  1341. +#define RG_SSUSB_PLL_SSC_PRD_OFST (0)
  1342. +
  1343. +//U3D_regA
  1344. +#define RG_SSUSB_PLL_SSC_PHASE_INI_OFST (31)
  1345. +#define RG_SSUSB_PLL_SSC_TRI_EN_OFST (30)
  1346. +#define RG_SSUSB_PLL_CLK_PH_INV_OFST (29)
  1347. +#define RG_SSUSB_PLL_DDS_LPF_EN_OFST (28)
  1348. +#define RG_SSUSB_PLL_DDS_VADJ_OFST (21)
  1349. +#define RG_SSUSB_PLL_DDS_MONEN_OFST (20)
  1350. +#define RG_SSUSB_PLL_DDS_PS_VADJ_OFST (17)
  1351. +#define RG_SSUSB_PLL_DDS_SEL_EXT_OFST (16)
  1352. +#define RG_SSUSB_CDR_PD_DIV_BYPASS_OFST (15)
  1353. +#define RG_SSUSB_CDR_PD_DIV_SEL_OFST (14)
  1354. +#define RG_SSUSB_CDR_CPBIAS_SEL_OFST (13)
  1355. +#define RG_SSUSB_CDR_OSCDET_EN_OFST (12)
  1356. +#define RG_SSUSB_CDR_MONMUX_OFST (11)
  1357. +#define RG_SSUSB_CDR_CKCTRL_OFST (9)
  1358. +#define RG_SSUSB_CDR_ACCEN_OFST (8)
  1359. +#define RG_SSUSB_CDR_BYPASS_OFST (6)
  1360. +#define RG_SSUSB_CDR_PI_SLEW_OFST (4)
  1361. +#define RG_SSUSB_CDR_EPEN_OFST (3)
  1362. +#define RG_SSUSB_CDR_AUTOK_LOAD_OFST (2)
  1363. +#define RG_SSUSB_CDR_LOAD_RSTB_OFST (1)
  1364. +#define RG_SSUSB_CDR_MONEN_OFST (0)
  1365. +
  1366. +//U3D_regB
  1367. +#define RG_SSUSB_CDR_MONEN_DIG_OFST (31)
  1368. +#define RG_SSUSB_CDR_REGOD_OFST (29)
  1369. +#define RG_SSUSB_RX_DAC_EN_OFST (26)
  1370. +#define RG_SSUSB_RX_DAC_PWD_OFST (25)
  1371. +#define RG_SSUSB_EQ_CURSEL_OFST (24)
  1372. +#define RG_SSUSB_RX_DAC_MUX_OFST (19)
  1373. +#define RG_SSUSB_RX_R2T_EN_OFST (18)
  1374. +#define RG_SSUSB_RX_T2R_EN_OFST (17)
  1375. +#define RG_SSUSB_RX_50_LOWER_OFST (14)
  1376. +#define RG_SSUSB_RX_50_TAR_OFST (12)
  1377. +#define RG_SSUSB_RX_SW_CTRL_OFST (7)
  1378. +#define RG_PCIE_SIGDET_VTH_OFST (5)
  1379. +#define RG_PCIE_SIGDET_LPF_OFST (3)
  1380. +#define RG_SSUSB_LFPS_MON_EN_OFST (2)
  1381. +
  1382. +//U3D_regC
  1383. +#define RG_SSUSB_RXAFE_DCMON_SEL_OFST (28)
  1384. +#define RG_SSUSB_CDR_RESERVE_OFST (16)
  1385. +#define RG_SSUSB_RXAFE_RESERVE_OFST (8)
  1386. +#define RG_PCIE_RX_RESERVE_OFST (0)
  1387. +
  1388. +//U3D_redD
  1389. +#define RGS_SSUSB_CDR_NO_OSC_OFST (8)
  1390. +#define RGS_SSUSB_RX_DEBUG_RESERVE_OFST (0)
  1391. +
  1392. +//U3D_regE
  1393. +#define RG_SSUSB_INT_BIAS_SEL_OFST (4)
  1394. +#define RG_SSUSB_EXT_BIAS_SEL_OFST (3)
  1395. +#define RG_SSUSB_RX_P1_ENTRY_PASS_OFST (2)
  1396. +#define RG_SSUSB_RX_PD_RST_OFST (1)
  1397. +#define RG_SSUSB_RX_PD_RST_PASS_OFST (0)
  1398. +
  1399. +///////////////////////////////////////////////////////////////////////////////
  1400. +
  1401. +struct u3phya_da_reg {
  1402. + //0x0
  1403. + PHY_LE32 reg0;
  1404. + PHY_LE32 reg1;
  1405. + PHY_LE32 reg4;
  1406. + PHY_LE32 reg5;
  1407. + //0x10
  1408. + PHY_LE32 reg6;
  1409. + PHY_LE32 reg7;
  1410. + PHY_LE32 reg8;
  1411. + PHY_LE32 reg9;
  1412. + //0x20
  1413. + PHY_LE32 reg10;
  1414. + PHY_LE32 reg12;
  1415. + PHY_LE32 reg13;
  1416. + PHY_LE32 reg14;
  1417. + //0x30
  1418. + PHY_LE32 reg15;
  1419. + PHY_LE32 reg16;
  1420. + PHY_LE32 reg19;
  1421. + PHY_LE32 reg20;
  1422. + //0x40
  1423. + PHY_LE32 reg21;
  1424. + PHY_LE32 reg23;
  1425. + PHY_LE32 reg25;
  1426. + PHY_LE32 reg26;
  1427. + //0x50
  1428. + PHY_LE32 reg28;
  1429. + PHY_LE32 reg29;
  1430. + PHY_LE32 reg30;
  1431. + PHY_LE32 reg31;
  1432. + //0x60
  1433. + PHY_LE32 reg32;
  1434. + PHY_LE32 reg33;
  1435. +};
  1436. +
  1437. +//U3D_reg0
  1438. +#define RG_PCIE_SPEED_PE2D (0x1<<24) //24:24
  1439. +#define RG_PCIE_SPEED_PE2H (0x1<<23) //23:23
  1440. +#define RG_PCIE_SPEED_PE1D (0x1<<22) //22:22
  1441. +#define RG_PCIE_SPEED_PE1H (0x1<<21) //21:21
  1442. +#define RG_PCIE_SPEED_U3 (0x1<<20) //20:20
  1443. +#define RG_SSUSB_XTAL_EXT_EN_PE2D (0x3<<18) //19:18
  1444. +#define RG_SSUSB_XTAL_EXT_EN_PE2H (0x3<<16) //17:16
  1445. +#define RG_SSUSB_XTAL_EXT_EN_PE1D (0x3<<14) //15:14
  1446. +#define RG_SSUSB_XTAL_EXT_EN_PE1H (0x3<<12) //13:12
  1447. +#define RG_SSUSB_XTAL_EXT_EN_U3 (0x3<<10) //11:10
  1448. +#define RG_SSUSB_CDR_REFCK_SEL_PE2D (0x3<<8) //9:8
  1449. +#define RG_SSUSB_CDR_REFCK_SEL_PE2H (0x3<<6) //7:6
  1450. +#define RG_SSUSB_CDR_REFCK_SEL_PE1D (0x3<<4) //5:4
  1451. +#define RG_SSUSB_CDR_REFCK_SEL_PE1H (0x3<<2) //3:2
  1452. +#define RG_SSUSB_CDR_REFCK_SEL_U3 (0x3<<0) //1:0
  1453. +
  1454. +//U3D_reg1
  1455. +#define RG_USB20_REFCK_SEL_PE2D (0x1<<30) //30:30
  1456. +#define RG_USB20_REFCK_SEL_PE2H (0x1<<29) //29:29
  1457. +#define RG_USB20_REFCK_SEL_PE1D (0x1<<28) //28:28
  1458. +#define RG_USB20_REFCK_SEL_PE1H (0x1<<27) //27:27
  1459. +#define RG_USB20_REFCK_SEL_U3 (0x1<<26) //26:26
  1460. +#define RG_PCIE_REFCK_DIV4_PE2D (0x1<<25) //25:25
  1461. +#define RG_PCIE_REFCK_DIV4_PE2H (0x1<<24) //24:24
  1462. +#define RG_PCIE_REFCK_DIV4_PE1D (0x1<<18) //18:18
  1463. +#define RG_PCIE_REFCK_DIV4_PE1H (0x1<<17) //17:17
  1464. +#define RG_PCIE_REFCK_DIV4_U3 (0x1<<16) //16:16
  1465. +#define RG_PCIE_MODE_PE2D (0x1<<8) //8:8
  1466. +#define RG_PCIE_MODE_PE2H (0x1<<3) //3:3
  1467. +#define RG_PCIE_MODE_PE1D (0x1<<2) //2:2
  1468. +#define RG_PCIE_MODE_PE1H (0x1<<1) //1:1
  1469. +#define RG_PCIE_MODE_U3 (0x1<<0) //0:0
  1470. +
  1471. +//U3D_reg4
  1472. +#define RG_SSUSB_PLL_DIVEN_PE2D (0x7<<22) //24:22
  1473. +#define RG_SSUSB_PLL_DIVEN_PE2H (0x7<<19) //21:19
  1474. +#define RG_SSUSB_PLL_DIVEN_PE1D (0x7<<16) //18:16
  1475. +#define RG_SSUSB_PLL_DIVEN_PE1H (0x7<<13) //15:13
  1476. +#define RG_SSUSB_PLL_DIVEN_U3 (0x7<<10) //12:10
  1477. +#define RG_SSUSB_PLL_BC_PE2D (0x3<<8) //9:8
  1478. +#define RG_SSUSB_PLL_BC_PE2H (0x3<<6) //7:6
  1479. +#define RG_SSUSB_PLL_BC_PE1D (0x3<<4) //5:4
  1480. +#define RG_SSUSB_PLL_BC_PE1H (0x3<<2) //3:2
  1481. +#define RG_SSUSB_PLL_BC_U3 (0x3<<0) //1:0
  1482. +
  1483. +//U3D_reg5
  1484. +#define RG_SSUSB_PLL_BR_PE2D (0x7<<27) //29:27
  1485. +#define RG_SSUSB_PLL_BR_PE2H (0x7<<24) //26:24
  1486. +#define RG_SSUSB_PLL_BR_PE1D (0x7<<21) //23:21
  1487. +#define RG_SSUSB_PLL_BR_PE1H (0x7<<18) //20:18
  1488. +#define RG_SSUSB_PLL_BR_U3 (0x7<<15) //17:15
  1489. +#define RG_SSUSB_PLL_IC_PE2D (0x7<<12) //14:12
  1490. +#define RG_SSUSB_PLL_IC_PE2H (0x7<<9) //11:9
  1491. +#define RG_SSUSB_PLL_IC_PE1D (0x7<<6) //8:6
  1492. +#define RG_SSUSB_PLL_IC_PE1H (0x7<<3) //5:3
  1493. +#define RG_SSUSB_PLL_IC_U3 (0x7<<0) //2:0
  1494. +
  1495. +//U3D_reg6
  1496. +#define RG_SSUSB_PLL_IR_PE2D (0xf<<24) //27:24
  1497. +#define RG_SSUSB_PLL_IR_PE2H (0xf<<16) //19:16
  1498. +#define RG_SSUSB_PLL_IR_PE1D (0xf<<8) //11:8
  1499. +#define RG_SSUSB_PLL_IR_PE1H (0xf<<4) //7:4
  1500. +#define RG_SSUSB_PLL_IR_U3 (0xf<<0) //3:0
  1501. +
  1502. +//U3D_reg7
  1503. +#define RG_SSUSB_PLL_BP_PE2D (0xf<<24) //27:24
  1504. +#define RG_SSUSB_PLL_BP_PE2H (0xf<<16) //19:16
  1505. +#define RG_SSUSB_PLL_BP_PE1D (0xf<<8) //11:8
  1506. +#define RG_SSUSB_PLL_BP_PE1H (0xf<<4) //7:4
  1507. +#define RG_SSUSB_PLL_BP_U3 (0xf<<0) //3:0
  1508. +
  1509. +//U3D_reg8
  1510. +#define RG_SSUSB_PLL_FBKSEL_PE2D (0x3<<24) //25:24
  1511. +#define RG_SSUSB_PLL_FBKSEL_PE2H (0x3<<16) //17:16
  1512. +#define RG_SSUSB_PLL_FBKSEL_PE1D (0x3<<8) //9:8
  1513. +#define RG_SSUSB_PLL_FBKSEL_PE1H (0x3<<2) //3:2
  1514. +#define RG_SSUSB_PLL_FBKSEL_U3 (0x3<<0) //1:0
  1515. +
  1516. +//U3D_reg9
  1517. +#define RG_SSUSB_PLL_FBKDIV_PE2H (0x7f<<24) //30:24
  1518. +#define RG_SSUSB_PLL_FBKDIV_PE1D (0x7f<<16) //22:16
  1519. +#define RG_SSUSB_PLL_FBKDIV_PE1H (0x7f<<8) //14:8
  1520. +#define RG_SSUSB_PLL_FBKDIV_U3 (0x7f<<0) //6:0
  1521. +
  1522. +//U3D_reg10
  1523. +#define RG_SSUSB_PLL_PREDIV_PE2D (0x3<<26) //27:26
  1524. +#define RG_SSUSB_PLL_PREDIV_PE2H (0x3<<24) //25:24
  1525. +#define RG_SSUSB_PLL_PREDIV_PE1D (0x3<<18) //19:18
  1526. +#define RG_SSUSB_PLL_PREDIV_PE1H (0x3<<16) //17:16
  1527. +#define RG_SSUSB_PLL_PREDIV_U3 (0x3<<8) //9:8
  1528. +#define RG_SSUSB_PLL_FBKDIV_PE2D (0x7f<<0) //6:0
  1529. +
  1530. +//U3D_reg12
  1531. +#define RG_SSUSB_PLL_PCW_NCPO_U3 (0x7fffffff<<0) //30:0
  1532. +
  1533. +//U3D_reg13
  1534. +#define RG_SSUSB_PLL_PCW_NCPO_PE1H (0x7fffffff<<0) //30:0
  1535. +
  1536. +//U3D_reg14
  1537. +#define RG_SSUSB_PLL_PCW_NCPO_PE1D (0x7fffffff<<0) //30:0
  1538. +
  1539. +//U3D_reg15
  1540. +#define RG_SSUSB_PLL_PCW_NCPO_PE2H (0x7fffffff<<0) //30:0
  1541. +
  1542. +//U3D_reg16
  1543. +#define RG_SSUSB_PLL_PCW_NCPO_PE2D (0x7fffffff<<0) //30:0
  1544. +
  1545. +//U3D_reg19
  1546. +#define RG_SSUSB_PLL_SSC_DELTA1_PE1H (0xffff<<16) //31:16
  1547. +#define RG_SSUSB_PLL_SSC_DELTA1_U3 (0xffff<<0) //15:0
  1548. +
  1549. +//U3D_reg20
  1550. +#define RG_SSUSB_PLL_SSC_DELTA1_PE2H (0xffff<<16) //31:16
  1551. +#define RG_SSUSB_PLL_SSC_DELTA1_PE1D (0xffff<<0) //15:0
  1552. +
  1553. +//U3D_reg21
  1554. +#define RG_SSUSB_PLL_SSC_DELTA_U3 (0xffff<<16) //31:16
  1555. +#define RG_SSUSB_PLL_SSC_DELTA1_PE2D (0xffff<<0) //15:0
  1556. +
  1557. +//U3D_reg23
  1558. +#define RG_SSUSB_PLL_SSC_DELTA_PE1D (0xffff<<16) //31:16
  1559. +#define RG_SSUSB_PLL_SSC_DELTA_PE1H (0xffff<<0) //15:0
  1560. +
  1561. +//U3D_reg25
  1562. +#define RG_SSUSB_PLL_SSC_DELTA_PE2D (0xffff<<16) //31:16
  1563. +#define RG_SSUSB_PLL_SSC_DELTA_PE2H (0xffff<<0) //15:0
  1564. +
  1565. +//U3D_reg26
  1566. +#define RG_SSUSB_PLL_REFCKDIV_PE2D (0x1<<25) //25:25
  1567. +#define RG_SSUSB_PLL_REFCKDIV_PE2H (0x1<<24) //24:24
  1568. +#define RG_SSUSB_PLL_REFCKDIV_PE1D (0x1<<16) //16:16
  1569. +#define RG_SSUSB_PLL_REFCKDIV_PE1H (0x1<<8) //8:8
  1570. +#define RG_SSUSB_PLL_REFCKDIV_U3 (0x1<<0) //0:0
  1571. +
  1572. +//U3D_reg28
  1573. +#define RG_SSUSB_CDR_BPA_PE2D (0x3<<24) //25:24
  1574. +#define RG_SSUSB_CDR_BPA_PE2H (0x3<<16) //17:16
  1575. +#define RG_SSUSB_CDR_BPA_PE1D (0x3<<10) //11:10
  1576. +#define RG_SSUSB_CDR_BPA_PE1H (0x3<<8) //9:8
  1577. +#define RG_SSUSB_CDR_BPA_U3 (0x3<<0) //1:0
  1578. +
  1579. +//U3D_reg29
  1580. +#define RG_SSUSB_CDR_BPB_PE2D (0x7<<24) //26:24
  1581. +#define RG_SSUSB_CDR_BPB_PE2H (0x7<<16) //18:16
  1582. +#define RG_SSUSB_CDR_BPB_PE1D (0x7<<6) //8:6
  1583. +#define RG_SSUSB_CDR_BPB_PE1H (0x7<<3) //5:3
  1584. +#define RG_SSUSB_CDR_BPB_U3 (0x7<<0) //2:0
  1585. +
  1586. +//U3D_reg30
  1587. +#define RG_SSUSB_CDR_BR_PE2D (0x7<<24) //26:24
  1588. +#define RG_SSUSB_CDR_BR_PE2H (0x7<<16) //18:16
  1589. +#define RG_SSUSB_CDR_BR_PE1D (0x7<<6) //8:6
  1590. +#define RG_SSUSB_CDR_BR_PE1H (0x7<<3) //5:3
  1591. +#define RG_SSUSB_CDR_BR_U3 (0x7<<0) //2:0
  1592. +
  1593. +//U3D_reg31
  1594. +#define RG_SSUSB_CDR_FBDIV_PE2H (0x7f<<24) //30:24
  1595. +#define RG_SSUSB_CDR_FBDIV_PE1D (0x7f<<16) //22:16
  1596. +#define RG_SSUSB_CDR_FBDIV_PE1H (0x7f<<8) //14:8
  1597. +#define RG_SSUSB_CDR_FBDIV_U3 (0x7f<<0) //6:0
  1598. +
  1599. +//U3D_reg32
  1600. +#define RG_SSUSB_EQ_RSTEP1_PE2D (0x3<<30) //31:30
  1601. +#define RG_SSUSB_EQ_RSTEP1_PE2H (0x3<<28) //29:28
  1602. +#define RG_SSUSB_EQ_RSTEP1_PE1D (0x3<<26) //27:26
  1603. +#define RG_SSUSB_EQ_RSTEP1_PE1H (0x3<<24) //25:24
  1604. +#define RG_SSUSB_EQ_RSTEP1_U3 (0x3<<22) //23:22
  1605. +#define RG_SSUSB_LFPS_DEGLITCH_PE2D (0x3<<20) //21:20
  1606. +#define RG_SSUSB_LFPS_DEGLITCH_PE2H (0x3<<18) //19:18
  1607. +#define RG_SSUSB_LFPS_DEGLITCH_PE1D (0x3<<16) //17:16
  1608. +#define RG_SSUSB_LFPS_DEGLITCH_PE1H (0x3<<14) //15:14
  1609. +#define RG_SSUSB_LFPS_DEGLITCH_U3 (0x3<<12) //13:12
  1610. +#define RG_SSUSB_CDR_KVSEL_PE2D (0x1<<11) //11:11
  1611. +#define RG_SSUSB_CDR_KVSEL_PE2H (0x1<<10) //10:10
  1612. +#define RG_SSUSB_CDR_KVSEL_PE1D (0x1<<9) //9:9
  1613. +#define RG_SSUSB_CDR_KVSEL_PE1H (0x1<<8) //8:8
  1614. +#define RG_SSUSB_CDR_KVSEL_U3 (0x1<<7) //7:7
  1615. +#define RG_SSUSB_CDR_FBDIV_PE2D (0x7f<<0) //6:0
  1616. +
  1617. +//U3D_reg33
  1618. +#define RG_SSUSB_RX_CMPWD_PE2D (0x1<<26) //26:26
  1619. +#define RG_SSUSB_RX_CMPWD_PE2H (0x1<<25) //25:25
  1620. +#define RG_SSUSB_RX_CMPWD_PE1D (0x1<<24) //24:24
  1621. +#define RG_SSUSB_RX_CMPWD_PE1H (0x1<<23) //23:23
  1622. +#define RG_SSUSB_RX_CMPWD_U3 (0x1<<16) //16:16
  1623. +#define RG_SSUSB_EQ_RSTEP2_PE2D (0x3<<8) //9:8
  1624. +#define RG_SSUSB_EQ_RSTEP2_PE2H (0x3<<6) //7:6
  1625. +#define RG_SSUSB_EQ_RSTEP2_PE1D (0x3<<4) //5:4
  1626. +#define RG_SSUSB_EQ_RSTEP2_PE1H (0x3<<2) //3:2
  1627. +#define RG_SSUSB_EQ_RSTEP2_U3 (0x3<<0) //1:0
  1628. +
  1629. +
  1630. +/* OFFSET */
  1631. +
  1632. +//U3D_reg0
  1633. +#define RG_PCIE_SPEED_PE2D_OFST (24)
  1634. +#define RG_PCIE_SPEED_PE2H_OFST (23)
  1635. +#define RG_PCIE_SPEED_PE1D_OFST (22)
  1636. +#define RG_PCIE_SPEED_PE1H_OFST (21)
  1637. +#define RG_PCIE_SPEED_U3_OFST (20)
  1638. +#define RG_SSUSB_XTAL_EXT_EN_PE2D_OFST (18)
  1639. +#define RG_SSUSB_XTAL_EXT_EN_PE2H_OFST (16)
  1640. +#define RG_SSUSB_XTAL_EXT_EN_PE1D_OFST (14)
  1641. +#define RG_SSUSB_XTAL_EXT_EN_PE1H_OFST (12)
  1642. +#define RG_SSUSB_XTAL_EXT_EN_U3_OFST (10)
  1643. +#define RG_SSUSB_CDR_REFCK_SEL_PE2D_OFST (8)
  1644. +#define RG_SSUSB_CDR_REFCK_SEL_PE2H_OFST (6)
  1645. +#define RG_SSUSB_CDR_REFCK_SEL_PE1D_OFST (4)
  1646. +#define RG_SSUSB_CDR_REFCK_SEL_PE1H_OFST (2)
  1647. +#define RG_SSUSB_CDR_REFCK_SEL_U3_OFST (0)
  1648. +
  1649. +//U3D_reg1
  1650. +#define RG_USB20_REFCK_SEL_PE2D_OFST (30)
  1651. +#define RG_USB20_REFCK_SEL_PE2H_OFST (29)
  1652. +#define RG_USB20_REFCK_SEL_PE1D_OFST (28)
  1653. +#define RG_USB20_REFCK_SEL_PE1H_OFST (27)
  1654. +#define RG_USB20_REFCK_SEL_U3_OFST (26)
  1655. +#define RG_PCIE_REFCK_DIV4_PE2D_OFST (25)
  1656. +#define RG_PCIE_REFCK_DIV4_PE2H_OFST (24)
  1657. +#define RG_PCIE_REFCK_DIV4_PE1D_OFST (18)
  1658. +#define RG_PCIE_REFCK_DIV4_PE1H_OFST (17)
  1659. +#define RG_PCIE_REFCK_DIV4_U3_OFST (16)
  1660. +#define RG_PCIE_MODE_PE2D_OFST (8)
  1661. +#define RG_PCIE_MODE_PE2H_OFST (3)
  1662. +#define RG_PCIE_MODE_PE1D_OFST (2)
  1663. +#define RG_PCIE_MODE_PE1H_OFST (1)
  1664. +#define RG_PCIE_MODE_U3_OFST (0)
  1665. +
  1666. +//U3D_reg4
  1667. +#define RG_SSUSB_PLL_DIVEN_PE2D_OFST (22)
  1668. +#define RG_SSUSB_PLL_DIVEN_PE2H_OFST (19)
  1669. +#define RG_SSUSB_PLL_DIVEN_PE1D_OFST (16)
  1670. +#define RG_SSUSB_PLL_DIVEN_PE1H_OFST (13)
  1671. +#define RG_SSUSB_PLL_DIVEN_U3_OFST (10)
  1672. +#define RG_SSUSB_PLL_BC_PE2D_OFST (8)
  1673. +#define RG_SSUSB_PLL_BC_PE2H_OFST (6)
  1674. +#define RG_SSUSB_PLL_BC_PE1D_OFST (4)
  1675. +#define RG_SSUSB_PLL_BC_PE1H_OFST (2)
  1676. +#define RG_SSUSB_PLL_BC_U3_OFST (0)
  1677. +
  1678. +//U3D_reg5
  1679. +#define RG_SSUSB_PLL_BR_PE2D_OFST (27)
  1680. +#define RG_SSUSB_PLL_BR_PE2H_OFST (24)
  1681. +#define RG_SSUSB_PLL_BR_PE1D_OFST (21)
  1682. +#define RG_SSUSB_PLL_BR_PE1H_OFST (18)
  1683. +#define RG_SSUSB_PLL_BR_U3_OFST (15)
  1684. +#define RG_SSUSB_PLL_IC_PE2D_OFST (12)
  1685. +#define RG_SSUSB_PLL_IC_PE2H_OFST (9)
  1686. +#define RG_SSUSB_PLL_IC_PE1D_OFST (6)
  1687. +#define RG_SSUSB_PLL_IC_PE1H_OFST (3)
  1688. +#define RG_SSUSB_PLL_IC_U3_OFST (0)
  1689. +
  1690. +//U3D_reg6
  1691. +#define RG_SSUSB_PLL_IR_PE2D_OFST (24)
  1692. +#define RG_SSUSB_PLL_IR_PE2H_OFST (16)
  1693. +#define RG_SSUSB_PLL_IR_PE1D_OFST (8)
  1694. +#define RG_SSUSB_PLL_IR_PE1H_OFST (4)
  1695. +#define RG_SSUSB_PLL_IR_U3_OFST (0)
  1696. +
  1697. +//U3D_reg7
  1698. +#define RG_SSUSB_PLL_BP_PE2D_OFST (24)
  1699. +#define RG_SSUSB_PLL_BP_PE2H_OFST (16)
  1700. +#define RG_SSUSB_PLL_BP_PE1D_OFST (8)
  1701. +#define RG_SSUSB_PLL_BP_PE1H_OFST (4)
  1702. +#define RG_SSUSB_PLL_BP_U3_OFST (0)
  1703. +
  1704. +//U3D_reg8
  1705. +#define RG_SSUSB_PLL_FBKSEL_PE2D_OFST (24)
  1706. +#define RG_SSUSB_PLL_FBKSEL_PE2H_OFST (16)
  1707. +#define RG_SSUSB_PLL_FBKSEL_PE1D_OFST (8)
  1708. +#define RG_SSUSB_PLL_FBKSEL_PE1H_OFST (2)
  1709. +#define RG_SSUSB_PLL_FBKSEL_U3_OFST (0)
  1710. +
  1711. +//U3D_reg9
  1712. +#define RG_SSUSB_PLL_FBKDIV_PE2H_OFST (24)
  1713. +#define RG_SSUSB_PLL_FBKDIV_PE1D_OFST (16)
  1714. +#define RG_SSUSB_PLL_FBKDIV_PE1H_OFST (8)
  1715. +#define RG_SSUSB_PLL_FBKDIV_U3_OFST (0)
  1716. +
  1717. +//U3D_reg10
  1718. +#define RG_SSUSB_PLL_PREDIV_PE2D_OFST (26)
  1719. +#define RG_SSUSB_PLL_PREDIV_PE2H_OFST (24)
  1720. +#define RG_SSUSB_PLL_PREDIV_PE1D_OFST (18)
  1721. +#define RG_SSUSB_PLL_PREDIV_PE1H_OFST (16)
  1722. +#define RG_SSUSB_PLL_PREDIV_U3_OFST (8)
  1723. +#define RG_SSUSB_PLL_FBKDIV_PE2D_OFST (0)
  1724. +
  1725. +//U3D_reg12
  1726. +#define RG_SSUSB_PLL_PCW_NCPO_U3_OFST (0)
  1727. +
  1728. +//U3D_reg13
  1729. +#define RG_SSUSB_PLL_PCW_NCPO_PE1H_OFST (0)
  1730. +
  1731. +//U3D_reg14
  1732. +#define RG_SSUSB_PLL_PCW_NCPO_PE1D_OFST (0)
  1733. +
  1734. +//U3D_reg15
  1735. +#define RG_SSUSB_PLL_PCW_NCPO_PE2H_OFST (0)
  1736. +
  1737. +//U3D_reg16
  1738. +#define RG_SSUSB_PLL_PCW_NCPO_PE2D_OFST (0)
  1739. +
  1740. +//U3D_reg19
  1741. +#define RG_SSUSB_PLL_SSC_DELTA1_PE1H_OFST (16)
  1742. +#define RG_SSUSB_PLL_SSC_DELTA1_U3_OFST (0)
  1743. +
  1744. +//U3D_reg20
  1745. +#define RG_SSUSB_PLL_SSC_DELTA1_PE2H_OFST (16)
  1746. +#define RG_SSUSB_PLL_SSC_DELTA1_PE1D_OFST (0)
  1747. +
  1748. +//U3D_reg21
  1749. +#define RG_SSUSB_PLL_SSC_DELTA_U3_OFST (16)
  1750. +#define RG_SSUSB_PLL_SSC_DELTA1_PE2D_OFST (0)
  1751. +
  1752. +//U3D_reg23
  1753. +#define RG_SSUSB_PLL_SSC_DELTA_PE1D_OFST (16)
  1754. +#define RG_SSUSB_PLL_SSC_DELTA_PE1H_OFST (0)
  1755. +
  1756. +//U3D_reg25
  1757. +#define RG_SSUSB_PLL_SSC_DELTA_PE2D_OFST (16)
  1758. +#define RG_SSUSB_PLL_SSC_DELTA_PE2H_OFST (0)
  1759. +
  1760. +//U3D_reg26
  1761. +#define RG_SSUSB_PLL_REFCKDIV_PE2D_OFST (25)
  1762. +#define RG_SSUSB_PLL_REFCKDIV_PE2H_OFST (24)
  1763. +#define RG_SSUSB_PLL_REFCKDIV_PE1D_OFST (16)
  1764. +#define RG_SSUSB_PLL_REFCKDIV_PE1H_OFST (8)
  1765. +#define RG_SSUSB_PLL_REFCKDIV_U3_OFST (0)
  1766. +
  1767. +//U3D_reg28
  1768. +#define RG_SSUSB_CDR_BPA_PE2D_OFST (24)
  1769. +#define RG_SSUSB_CDR_BPA_PE2H_OFST (16)
  1770. +#define RG_SSUSB_CDR_BPA_PE1D_OFST (10)
  1771. +#define RG_SSUSB_CDR_BPA_PE1H_OFST (8)
  1772. +#define RG_SSUSB_CDR_BPA_U3_OFST (0)
  1773. +
  1774. +//U3D_reg29
  1775. +#define RG_SSUSB_CDR_BPB_PE2D_OFST (24)
  1776. +#define RG_SSUSB_CDR_BPB_PE2H_OFST (16)
  1777. +#define RG_SSUSB_CDR_BPB_PE1D_OFST (6)
  1778. +#define RG_SSUSB_CDR_BPB_PE1H_OFST (3)
  1779. +#define RG_SSUSB_CDR_BPB_U3_OFST (0)
  1780. +
  1781. +//U3D_reg30
  1782. +#define RG_SSUSB_CDR_BR_PE2D_OFST (24)
  1783. +#define RG_SSUSB_CDR_BR_PE2H_OFST (16)
  1784. +#define RG_SSUSB_CDR_BR_PE1D_OFST (6)
  1785. +#define RG_SSUSB_CDR_BR_PE1H_OFST (3)
  1786. +#define RG_SSUSB_CDR_BR_U3_OFST (0)
  1787. +
  1788. +//U3D_reg31
  1789. +#define RG_SSUSB_CDR_FBDIV_PE2H_OFST (24)
  1790. +#define RG_SSUSB_CDR_FBDIV_PE1D_OFST (16)
  1791. +#define RG_SSUSB_CDR_FBDIV_PE1H_OFST (8)
  1792. +#define RG_SSUSB_CDR_FBDIV_U3_OFST (0)
  1793. +
  1794. +//U3D_reg32
  1795. +#define RG_SSUSB_EQ_RSTEP1_PE2D_OFST (30)
  1796. +#define RG_SSUSB_EQ_RSTEP1_PE2H_OFST (28)
  1797. +#define RG_SSUSB_EQ_RSTEP1_PE1D_OFST (26)
  1798. +#define RG_SSUSB_EQ_RSTEP1_PE1H_OFST (24)
  1799. +#define RG_SSUSB_EQ_RSTEP1_U3_OFST (22)
  1800. +#define RG_SSUSB_LFPS_DEGLITCH_PE2D_OFST (20)
  1801. +#define RG_SSUSB_LFPS_DEGLITCH_PE2H_OFST (18)
  1802. +#define RG_SSUSB_LFPS_DEGLITCH_PE1D_OFST (16)
  1803. +#define RG_SSUSB_LFPS_DEGLITCH_PE1H_OFST (14)
  1804. +#define RG_SSUSB_LFPS_DEGLITCH_U3_OFST (12)
  1805. +#define RG_SSUSB_CDR_KVSEL_PE2D_OFST (11)
  1806. +#define RG_SSUSB_CDR_KVSEL_PE2H_OFST (10)
  1807. +#define RG_SSUSB_CDR_KVSEL_PE1D_OFST (9)
  1808. +#define RG_SSUSB_CDR_KVSEL_PE1H_OFST (8)
  1809. +#define RG_SSUSB_CDR_KVSEL_U3_OFST (7)
  1810. +#define RG_SSUSB_CDR_FBDIV_PE2D_OFST (0)
  1811. +
  1812. +//U3D_reg33
  1813. +#define RG_SSUSB_RX_CMPWD_PE2D_OFST (26)
  1814. +#define RG_SSUSB_RX_CMPWD_PE2H_OFST (25)
  1815. +#define RG_SSUSB_RX_CMPWD_PE1D_OFST (24)
  1816. +#define RG_SSUSB_RX_CMPWD_PE1H_OFST (23)
  1817. +#define RG_SSUSB_RX_CMPWD_U3_OFST (16)
  1818. +#define RG_SSUSB_EQ_RSTEP2_PE2D_OFST (8)
  1819. +#define RG_SSUSB_EQ_RSTEP2_PE2H_OFST (6)
  1820. +#define RG_SSUSB_EQ_RSTEP2_PE1D_OFST (4)
  1821. +#define RG_SSUSB_EQ_RSTEP2_PE1H_OFST (2)
  1822. +#define RG_SSUSB_EQ_RSTEP2_U3_OFST (0)
  1823. +
  1824. +
  1825. +///////////////////////////////////////////////////////////////////////////////
  1826. +
  1827. +struct u3phyd_reg {
  1828. + //0x0
  1829. + PHY_LE32 phyd_mix0;
  1830. + PHY_LE32 phyd_mix1;
  1831. + PHY_LE32 phyd_lfps0;
  1832. + PHY_LE32 phyd_lfps1;
  1833. + //0x10
  1834. + PHY_LE32 phyd_impcal0;
  1835. + PHY_LE32 phyd_impcal1;
  1836. + PHY_LE32 phyd_txpll0;
  1837. + PHY_LE32 phyd_txpll1;
  1838. + //0x20
  1839. + PHY_LE32 phyd_txpll2;
  1840. + PHY_LE32 phyd_fl0;
  1841. + PHY_LE32 phyd_mix2;
  1842. + PHY_LE32 phyd_rx0;
  1843. + //0x30
  1844. + PHY_LE32 phyd_t2rlb;
  1845. + PHY_LE32 phyd_cppat;
  1846. + PHY_LE32 phyd_mix3;
  1847. + PHY_LE32 phyd_ebufctl;
  1848. + //0x40
  1849. + PHY_LE32 phyd_pipe0;
  1850. + PHY_LE32 phyd_pipe1;
  1851. + PHY_LE32 phyd_mix4;
  1852. + PHY_LE32 phyd_ckgen0;
  1853. + //0x50
  1854. + PHY_LE32 phyd_mix5;
  1855. + PHY_LE32 phyd_reserved;
  1856. + PHY_LE32 phyd_cdr0;
  1857. + PHY_LE32 phyd_cdr1;
  1858. + //0x60
  1859. + PHY_LE32 phyd_pll_0;
  1860. + PHY_LE32 phyd_pll_1;
  1861. + PHY_LE32 phyd_bcn_det_1;
  1862. + PHY_LE32 phyd_bcn_det_2;
  1863. + //0x70
  1864. + PHY_LE32 eq0;
  1865. + PHY_LE32 eq1;
  1866. + PHY_LE32 eq2;
  1867. + PHY_LE32 eq3;
  1868. + //0x80
  1869. + PHY_LE32 eq_eye0;
  1870. + PHY_LE32 eq_eye1;
  1871. + PHY_LE32 eq_eye2;
  1872. + PHY_LE32 eq_dfe0;
  1873. + //0x90
  1874. + PHY_LE32 eq_dfe1;
  1875. + PHY_LE32 eq_dfe2;
  1876. + PHY_LE32 eq_dfe3;
  1877. + PHY_LE32 reserve0;
  1878. + //0xa0
  1879. + PHY_LE32 phyd_mon0;
  1880. + PHY_LE32 phyd_mon1;
  1881. + PHY_LE32 phyd_mon2;
  1882. + PHY_LE32 phyd_mon3;
  1883. + //0xb0
  1884. + PHY_LE32 phyd_mon4;
  1885. + PHY_LE32 phyd_mon5;
  1886. + PHY_LE32 phyd_mon6;
  1887. + PHY_LE32 phyd_mon7;
  1888. + //0xc0
  1889. + PHY_LE32 phya_rx_mon0;
  1890. + PHY_LE32 phya_rx_mon1;
  1891. + PHY_LE32 phya_rx_mon2;
  1892. + PHY_LE32 phya_rx_mon3;
  1893. + //0xd0
  1894. + PHY_LE32 phya_rx_mon4;
  1895. + PHY_LE32 phya_rx_mon5;
  1896. + PHY_LE32 phyd_cppat2;
  1897. + PHY_LE32 eq_eye3;
  1898. + //0xe0
  1899. + PHY_LE32 kband_out;
  1900. + PHY_LE32 kband_out1;
  1901. +};
  1902. +
  1903. +//U3D_PHYD_MIX0
  1904. +#define RG_SSUSB_P_P3_TX_NG (0x1<<31) //31:31
  1905. +#define RG_SSUSB_TSEQ_EN (0x1<<30) //30:30
  1906. +#define RG_SSUSB_TSEQ_POLEN (0x1<<29) //29:29
  1907. +#define RG_SSUSB_TSEQ_POL (0x1<<28) //28:28
  1908. +#define RG_SSUSB_P_P3_PCLK_NG (0x1<<27) //27:27
  1909. +#define RG_SSUSB_TSEQ_TH (0x7<<24) //26:24
  1910. +#define RG_SSUSB_PRBS_BERTH (0xff<<16) //23:16
  1911. +#define RG_SSUSB_DISABLE_PHY_U2_ON (0x1<<15) //15:15
  1912. +#define RG_SSUSB_DISABLE_PHY_U2_OFF (0x1<<14) //14:14
  1913. +#define RG_SSUSB_PRBS_EN (0x1<<13) //13:13
  1914. +#define RG_SSUSB_BPSLOCK (0x1<<12) //12:12
  1915. +#define RG_SSUSB_RTCOMCNT (0xf<<8) //11:8
  1916. +#define RG_SSUSB_COMCNT (0xf<<4) //7:4
  1917. +#define RG_SSUSB_PRBSEL_CALIB (0xf<<0) //3:0
  1918. +
  1919. +//U3D_PHYD_MIX1
  1920. +#define RG_SSUSB_SLEEP_EN (0x1<<31) //31:31
  1921. +#define RG_SSUSB_PRBSEL_PCS (0x7<<28) //30:28
  1922. +#define RG_SSUSB_TXLFPS_PRD (0xf<<24) //27:24
  1923. +#define RG_SSUSB_P_RX_P0S_CK (0x1<<23) //23:23
  1924. +#define RG_SSUSB_P_TX_P0S_CK (0x1<<22) //22:22
  1925. +#define RG_SSUSB_PDNCTL (0x3f<<16) //21:16
  1926. +#define RG_SSUSB_TX_DRV_EN (0x1<<15) //15:15
  1927. +#define RG_SSUSB_TX_DRV_SEL (0x1<<14) //14:14
  1928. +#define RG_SSUSB_TX_DRV_DLY (0x3f<<8) //13:8
  1929. +#define RG_SSUSB_BERT_EN (0x1<<7) //7:7
  1930. +#define RG_SSUSB_SCP_TH (0x7<<4) //6:4
  1931. +#define RG_SSUSB_SCP_EN (0x1<<3) //3:3
  1932. +#define RG_SSUSB_RXANSIDEC_TEST (0x7<<0) //2:0
  1933. +
  1934. +//U3D_PHYD_LFPS0
  1935. +#define RG_SSUSB_LFPS_PWD (0x1<<30) //30:30
  1936. +#define RG_SSUSB_FORCE_LFPS_PWD (0x1<<29) //29:29
  1937. +#define RG_SSUSB_RXLFPS_OVF (0x1f<<24) //28:24
  1938. +#define RG_SSUSB_P3_ENTRY_SEL (0x1<<23) //23:23
  1939. +#define RG_SSUSB_P3_ENTRY (0x1<<22) //22:22
  1940. +#define RG_SSUSB_RXLFPS_CDRSEL (0x3<<20) //21:20
  1941. +#define RG_SSUSB_RXLFPS_CDRTH (0xf<<16) //19:16
  1942. +#define RG_SSUSB_LOCK5G_BLOCK (0x1<<15) //15:15
  1943. +#define RG_SSUSB_TFIFO_EXT_D_SEL (0x1<<14) //14:14
  1944. +#define RG_SSUSB_TFIFO_NO_EXTEND (0x1<<13) //13:13
  1945. +#define RG_SSUSB_RXLFPS_LOB (0x1f<<8) //12:8
  1946. +#define RG_SSUSB_TXLFPS_EN (0x1<<7) //7:7
  1947. +#define RG_SSUSB_TXLFPS_SEL (0x1<<6) //6:6
  1948. +#define RG_SSUSB_RXLFPS_CDRLOCK (0x1<<5) //5:5
  1949. +#define RG_SSUSB_RXLFPS_UPB (0x1f<<0) //4:0
  1950. +
  1951. +//U3D_PHYD_LFPS1
  1952. +#define RG_SSUSB_RX_IMP_BIAS (0xf<<28) //31:28
  1953. +#define RG_SSUSB_TX_IMP_BIAS (0xf<<24) //27:24
  1954. +#define RG_SSUSB_FWAKE_TH (0x3f<<16) //21:16
  1955. +#define RG_SSUSB_RXLFPS_UDF (0x1f<<8) //12:8
  1956. +#define RG_SSUSB_RXLFPS_P0IDLETH (0xff<<0) //7:0
  1957. +
  1958. +//U3D_PHYD_IMPCAL0
  1959. +#define RG_SSUSB_FORCE_TX_IMPSEL (0x1<<31) //31:31
  1960. +#define RG_SSUSB_TX_IMPCAL_EN (0x1<<30) //30:30
  1961. +#define RG_SSUSB_FORCE_TX_IMPCAL_EN (0x1<<29) //29:29
  1962. +#define RG_SSUSB_TX_IMPSEL (0x1f<<24) //28:24
  1963. +#define RG_SSUSB_TX_IMPCAL_CALCYC (0x3f<<16) //21:16
  1964. +#define RG_SSUSB_TX_IMPCAL_STBCYC (0x1f<<10) //14:10
  1965. +#define RG_SSUSB_TX_IMPCAL_CYCCNT (0x3ff<<0) //9:0
  1966. +
  1967. +//U3D_PHYD_IMPCAL1
  1968. +#define RG_SSUSB_FORCE_RX_IMPSEL (0x1<<31) //31:31
  1969. +#define RG_SSUSB_RX_IMPCAL_EN (0x1<<30) //30:30
  1970. +#define RG_SSUSB_FORCE_RX_IMPCAL_EN (0x1<<29) //29:29
  1971. +#define RG_SSUSB_RX_IMPSEL (0x1f<<24) //28:24
  1972. +#define RG_SSUSB_RX_IMPCAL_CALCYC (0x3f<<16) //21:16
  1973. +#define RG_SSUSB_RX_IMPCAL_STBCYC (0x1f<<10) //14:10
  1974. +#define RG_SSUSB_RX_IMPCAL_CYCCNT (0x3ff<<0) //9:0
  1975. +
  1976. +//U3D_PHYD_TXPLL0
  1977. +#define RG_SSUSB_TXPLL_DDSEN_CYC (0x1f<<27) //31:27
  1978. +#define RG_SSUSB_TXPLL_ON (0x1<<26) //26:26
  1979. +#define RG_SSUSB_FORCE_TXPLLON (0x1<<25) //25:25
  1980. +#define RG_SSUSB_TXPLL_STBCYC (0x1ff<<16) //24:16
  1981. +#define RG_SSUSB_TXPLL_NCPOCHG_CYC (0xf<<12) //15:12
  1982. +#define RG_SSUSB_TXPLL_NCPOEN_CYC (0x3<<10) //11:10
  1983. +#define RG_SSUSB_TXPLL_DDSRSTB_CYC (0x7<<0) //2:0
  1984. +
  1985. +//U3D_PHYD_TXPLL1
  1986. +#define RG_SSUSB_PLL_NCPO_EN (0x1<<31) //31:31
  1987. +#define RG_SSUSB_PLL_FIFO_START_MAN (0x1<<30) //30:30
  1988. +#define RG_SSUSB_PLL_NCPO_CHG (0x1<<28) //28:28
  1989. +#define RG_SSUSB_PLL_DDS_RSTB (0x1<<27) //27:27
  1990. +#define RG_SSUSB_PLL_DDS_PWDB (0x1<<26) //26:26
  1991. +#define RG_SSUSB_PLL_DDSEN (0x1<<25) //25:25
  1992. +#define RG_SSUSB_PLL_AUTOK_VCO (0x1<<24) //24:24
  1993. +#define RG_SSUSB_PLL_PWD (0x1<<23) //23:23
  1994. +#define RG_SSUSB_RX_AFE_PWD (0x1<<22) //22:22
  1995. +#define RG_SSUSB_PLL_TCADJ (0x3f<<16) //21:16
  1996. +#define RG_SSUSB_FORCE_CDR_TCADJ (0x1<<15) //15:15
  1997. +#define RG_SSUSB_FORCE_CDR_AUTOK_VCO (0x1<<14) //14:14
  1998. +#define RG_SSUSB_FORCE_CDR_PWD (0x1<<13) //13:13
  1999. +#define RG_SSUSB_FORCE_PLL_NCPO_EN (0x1<<12) //12:12
  2000. +#define RG_SSUSB_FORCE_PLL_FIFO_START_MAN (0x1<<11) //11:11
  2001. +#define RG_SSUSB_FORCE_PLL_NCPO_CHG (0x1<<9) //9:9
  2002. +#define RG_SSUSB_FORCE_PLL_DDS_RSTB (0x1<<8) //8:8
  2003. +#define RG_SSUSB_FORCE_PLL_DDS_PWDB (0x1<<7) //7:7
  2004. +#define RG_SSUSB_FORCE_PLL_DDSEN (0x1<<6) //6:6
  2005. +#define RG_SSUSB_FORCE_PLL_TCADJ (0x1<<5) //5:5
  2006. +#define RG_SSUSB_FORCE_PLL_AUTOK_VCO (0x1<<4) //4:4
  2007. +#define RG_SSUSB_FORCE_PLL_PWD (0x1<<3) //3:3
  2008. +#define RG_SSUSB_FLT_1_DISPERR_B (0x1<<2) //2:2
  2009. +
  2010. +//U3D_PHYD_TXPLL2
  2011. +#define RG_SSUSB_TX_LFPS_EN (0x1<<31) //31:31
  2012. +#define RG_SSUSB_FORCE_TX_LFPS_EN (0x1<<30) //30:30
  2013. +#define RG_SSUSB_TX_LFPS (0x1<<29) //29:29
  2014. +#define RG_SSUSB_FORCE_TX_LFPS (0x1<<28) //28:28
  2015. +#define RG_SSUSB_RXPLL_STB (0x1<<27) //27:27
  2016. +#define RG_SSUSB_TXPLL_STB (0x1<<26) //26:26
  2017. +#define RG_SSUSB_FORCE_RXPLL_STB (0x1<<25) //25:25
  2018. +#define RG_SSUSB_FORCE_TXPLL_STB (0x1<<24) //24:24
  2019. +#define RG_SSUSB_RXPLL_REFCKSEL (0x1<<16) //16:16
  2020. +#define RG_SSUSB_RXPLL_STBMODE (0x1<<11) //11:11
  2021. +#define RG_SSUSB_RXPLL_ON (0x1<<10) //10:10
  2022. +#define RG_SSUSB_FORCE_RXPLLON (0x1<<9) //9:9
  2023. +#define RG_SSUSB_FORCE_RX_AFE_PWD (0x1<<8) //8:8
  2024. +#define RG_SSUSB_CDR_AUTOK_VCO (0x1<<7) //7:7
  2025. +#define RG_SSUSB_CDR_PWD (0x1<<6) //6:6
  2026. +#define RG_SSUSB_CDR_TCADJ (0x3f<<0) //5:0
  2027. +
  2028. +//U3D_PHYD_FL0
  2029. +#define RG_SSUSB_RX_FL_TARGET (0xffff<<16) //31:16
  2030. +#define RG_SSUSB_RX_FL_CYCLECNT (0xffff<<0) //15:0
  2031. +
  2032. +//U3D_PHYD_MIX2
  2033. +#define RG_SSUSB_RX_EQ_RST (0x1<<31) //31:31
  2034. +#define RG_SSUSB_RX_EQ_RST_SEL (0x1<<30) //30:30
  2035. +#define RG_SSUSB_RXVAL_RST (0x1<<29) //29:29
  2036. +#define RG_SSUSB_RXVAL_CNT (0x1f<<24) //28:24
  2037. +#define RG_SSUSB_CDROS_EN (0x1<<18) //18:18
  2038. +#define RG_SSUSB_CDR_LCKOP (0x3<<16) //17:16
  2039. +#define RG_SSUSB_RX_FL_LOCKTH (0xf<<8) //11:8
  2040. +#define RG_SSUSB_RX_FL_OFFSET (0xff<<0) //7:0
  2041. +
  2042. +//U3D_PHYD_RX0
  2043. +#define RG_SSUSB_T2RLB_BERTH (0xff<<24) //31:24
  2044. +#define RG_SSUSB_T2RLB_PAT (0xff<<16) //23:16
  2045. +#define RG_SSUSB_T2RLB_EN (0x1<<15) //15:15
  2046. +#define RG_SSUSB_T2RLB_BPSCRAMB (0x1<<14) //14:14
  2047. +#define RG_SSUSB_T2RLB_SERIAL (0x1<<13) //13:13
  2048. +#define RG_SSUSB_T2RLB_MODE (0x3<<11) //12:11
  2049. +#define RG_SSUSB_RX_SAOSC_EN (0x1<<10) //10:10
  2050. +#define RG_SSUSB_RX_SAOSC_EN_SEL (0x1<<9) //9:9
  2051. +#define RG_SSUSB_RX_DFE_OPTION (0x1<<8) //8:8
  2052. +#define RG_SSUSB_RX_DFE_EN (0x1<<7) //7:7
  2053. +#define RG_SSUSB_RX_DFE_EN_SEL (0x1<<6) //6:6
  2054. +#define RG_SSUSB_RX_EQ_EN (0x1<<5) //5:5
  2055. +#define RG_SSUSB_RX_EQ_EN_SEL (0x1<<4) //4:4
  2056. +#define RG_SSUSB_RX_SAOSC_RST (0x1<<3) //3:3
  2057. +#define RG_SSUSB_RX_SAOSC_RST_SEL (0x1<<2) //2:2
  2058. +#define RG_SSUSB_RX_DFE_RST (0x1<<1) //1:1
  2059. +#define RG_SSUSB_RX_DFE_RST_SEL (0x1<<0) //0:0
  2060. +
  2061. +//U3D_PHYD_T2RLB
  2062. +#define RG_SSUSB_EQTRAIN_CH_MODE (0x1<<28) //28:28
  2063. +#define RG_SSUSB_PRB_OUT_CPPAT (0x1<<27) //27:27
  2064. +#define RG_SSUSB_BPANSIENC (0x1<<26) //26:26
  2065. +#define RG_SSUSB_VALID_EN (0x1<<25) //25:25
  2066. +#define RG_SSUSB_EBUF_SRST (0x1<<24) //24:24
  2067. +#define RG_SSUSB_K_EMP (0xf<<20) //23:20
  2068. +#define RG_SSUSB_K_FUL (0xf<<16) //19:16
  2069. +#define RG_SSUSB_T2RLB_BDATRST (0xf<<12) //15:12
  2070. +#define RG_SSUSB_P_T2RLB_SKP_EN (0x1<<10) //10:10
  2071. +#define RG_SSUSB_T2RLB_PATMODE (0x3<<8) //9:8
  2072. +#define RG_SSUSB_T2RLB_TSEQCNT (0xff<<0) //7:0
  2073. +
  2074. +//U3D_PHYD_CPPAT
  2075. +#define RG_SSUSB_CPPAT_PROGRAM_EN (0x1<<24) //24:24
  2076. +#define RG_SSUSB_CPPAT_TOZ (0x3<<21) //22:21
  2077. +#define RG_SSUSB_CPPAT_PRBS_EN (0x1<<20) //20:20
  2078. +#define RG_SSUSB_CPPAT_OUT_TMP2 (0xf<<16) //19:16
  2079. +#define RG_SSUSB_CPPAT_OUT_TMP1 (0xff<<8) //15:8
  2080. +#define RG_SSUSB_CPPAT_OUT_TMP0 (0xff<<0) //7:0
  2081. +
  2082. +//U3D_PHYD_MIX3
  2083. +#define RG_SSUSB_CDR_TCADJ_MINUS (0x1<<31) //31:31
  2084. +#define RG_SSUSB_P_CDROS_EN (0x1<<30) //30:30
  2085. +#define RG_SSUSB_P_P2_TX_DRV_DIS (0x1<<28) //28:28
  2086. +#define RG_SSUSB_CDR_TCADJ_OFFSET (0x7<<24) //26:24
  2087. +#define RG_SSUSB_PLL_TCADJ_MINUS (0x1<<23) //23:23
  2088. +#define RG_SSUSB_FORCE_PLL_BIAS_LPF_EN (0x1<<20) //20:20
  2089. +#define RG_SSUSB_PLL_BIAS_LPF_EN (0x1<<19) //19:19
  2090. +#define RG_SSUSB_PLL_TCADJ_OFFSET (0x7<<16) //18:16
  2091. +#define RG_SSUSB_FORCE_PLL_SSCEN (0x1<<15) //15:15
  2092. +#define RG_SSUSB_PLL_SSCEN (0x1<<14) //14:14
  2093. +#define RG_SSUSB_FORCE_CDR_PI_PWD (0x1<<13) //13:13
  2094. +#define RG_SSUSB_CDR_PI_PWD (0x1<<12) //12:12
  2095. +#define RG_SSUSB_CDR_PI_MODE (0x1<<11) //11:11
  2096. +#define RG_SSUSB_TXPLL_SSCEN_CYC (0x3ff<<0) //9:0
  2097. +
  2098. +//U3D_PHYD_EBUFCTL
  2099. +#define RG_SSUSB_EBUFCTL (0xffffffff<<0) //31:0
  2100. +
  2101. +//U3D_PHYD_PIPE0
  2102. +#define RG_SSUSB_RXTERMINATION (0x1<<30) //30:30
  2103. +#define RG_SSUSB_RXEQTRAINING (0x1<<29) //29:29
  2104. +#define RG_SSUSB_RXPOLARITY (0x1<<28) //28:28
  2105. +#define RG_SSUSB_TXDEEMPH (0x3<<26) //27:26
  2106. +#define RG_SSUSB_POWERDOWN (0x3<<24) //25:24
  2107. +#define RG_SSUSB_TXONESZEROS (0x1<<23) //23:23
  2108. +#define RG_SSUSB_TXELECIDLE (0x1<<22) //22:22
  2109. +#define RG_SSUSB_TXDETECTRX (0x1<<21) //21:21
  2110. +#define RG_SSUSB_PIPE_SEL (0x1<<20) //20:20
  2111. +#define RG_SSUSB_TXDATAK (0xf<<16) //19:16
  2112. +#define RG_SSUSB_CDR_STABLE_SEL (0x1<<15) //15:15
  2113. +#define RG_SSUSB_CDR_STABLE (0x1<<14) //14:14
  2114. +#define RG_SSUSB_CDR_RSTB_SEL (0x1<<13) //13:13
  2115. +#define RG_SSUSB_CDR_RSTB (0x1<<12) //12:12
  2116. +#define RG_SSUSB_P_ERROR_SEL (0x3<<4) //5:4
  2117. +#define RG_SSUSB_TXMARGIN (0x7<<1) //3:1
  2118. +#define RG_SSUSB_TXCOMPLIANCE (0x1<<0) //0:0
  2119. +
  2120. +//U3D_PHYD_PIPE1
  2121. +#define RG_SSUSB_TXDATA (0xffffffff<<0) //31:0
  2122. +
  2123. +//U3D_PHYD_MIX4
  2124. +#define RG_SSUSB_CDROS_CNT (0x3f<<24) //29:24
  2125. +#define RG_SSUSB_T2RLB_BER_EN (0x1<<16) //16:16
  2126. +#define RG_SSUSB_T2RLB_BER_RATE (0xffff<<0) //15:0
  2127. +
  2128. +//U3D_PHYD_CKGEN0
  2129. +#define RG_SSUSB_RFIFO_IMPLAT (0x1<<27) //27:27
  2130. +#define RG_SSUSB_TFIFO_PSEL (0x7<<24) //26:24
  2131. +#define RG_SSUSB_CKGEN_PSEL (0x3<<8) //9:8
  2132. +#define RG_SSUSB_RXCK_INV (0x1<<0) //0:0
  2133. +
  2134. +//U3D_PHYD_MIX5
  2135. +#define RG_SSUSB_PRB_SEL (0xffff<<16) //31:16
  2136. +#define RG_SSUSB_RXPLL_STBCYC (0x7ff<<0) //10:0
  2137. +
  2138. +//U3D_PHYD_RESERVED
  2139. +#define RG_SSUSB_PHYD_RESERVE (0xffffffff<<0) //31:0
  2140. +//#define RG_SSUSB_RX_SIGDET_SEL (0x1<<11)
  2141. +//#define RG_SSUSB_RX_SIGDET_EN (0x1<<12)
  2142. +//#define RG_SSUSB_RX_PI_CAL_MANUAL_SEL (0x1<<9)
  2143. +//#define RG_SSUSB_RX_PI_CAL_MANUAL_EN (0x1<<10)
  2144. +
  2145. +//U3D_PHYD_CDR0
  2146. +#define RG_SSUSB_CDR_BIC_LTR (0xf<<28) //31:28
  2147. +#define RG_SSUSB_CDR_BIC_LTD0 (0xf<<24) //27:24
  2148. +#define RG_SSUSB_CDR_BC_LTD1 (0x1f<<16) //20:16
  2149. +#define RG_SSUSB_CDR_BC_LTR (0x1f<<8) //12:8
  2150. +#define RG_SSUSB_CDR_BC_LTD0 (0x1f<<0) //4:0
  2151. +
  2152. +//U3D_PHYD_CDR1
  2153. +#define RG_SSUSB_CDR_BIR_LTD1 (0x1f<<24) //28:24
  2154. +#define RG_SSUSB_CDR_BIR_LTR (0x1f<<16) //20:16
  2155. +#define RG_SSUSB_CDR_BIR_LTD0 (0x1f<<8) //12:8
  2156. +#define RG_SSUSB_CDR_BW_SEL (0x3<<6) //7:6
  2157. +#define RG_SSUSB_CDR_BIC_LTD1 (0xf<<0) //3:0
  2158. +
  2159. +//U3D_PHYD_PLL_0
  2160. +#define RG_SSUSB_FORCE_CDR_BAND_5G (0x1<<28) //28:28
  2161. +#define RG_SSUSB_FORCE_CDR_BAND_2P5G (0x1<<27) //27:27
  2162. +#define RG_SSUSB_FORCE_PLL_BAND_5G (0x1<<26) //26:26
  2163. +#define RG_SSUSB_FORCE_PLL_BAND_2P5G (0x1<<25) //25:25
  2164. +#define RG_SSUSB_P_EQ_T_SEL (0x3ff<<15) //24:15
  2165. +#define RG_SSUSB_PLL_ISO_EN_CYC (0x3ff<<5) //14:5
  2166. +#define RG_SSUSB_PLLBAND_RECAL (0x1<<4) //4:4
  2167. +#define RG_SSUSB_PLL_DDS_ISO_EN (0x1<<3) //3:3
  2168. +#define RG_SSUSB_FORCE_PLL_DDS_ISO_EN (0x1<<2) //2:2
  2169. +#define RG_SSUSB_PLL_DDS_PWR_ON (0x1<<1) //1:1
  2170. +#define RG_SSUSB_FORCE_PLL_DDS_PWR_ON (0x1<<0) //0:0
  2171. +
  2172. +//U3D_PHYD_PLL_1
  2173. +#define RG_SSUSB_CDR_BAND_5G (0xff<<24) //31:24
  2174. +#define RG_SSUSB_CDR_BAND_2P5G (0xff<<16) //23:16
  2175. +#define RG_SSUSB_PLL_BAND_5G (0xff<<8) //15:8
  2176. +#define RG_SSUSB_PLL_BAND_2P5G (0xff<<0) //7:0
  2177. +
  2178. +//U3D_PHYD_BCN_DET_1
  2179. +#define RG_SSUSB_P_BCN_OBS_PRD (0xffff<<16) //31:16
  2180. +#define RG_SSUSB_U_BCN_OBS_PRD (0xffff<<0) //15:0
  2181. +
  2182. +//U3D_PHYD_BCN_DET_2
  2183. +#define RG_SSUSB_P_BCN_OBS_SEL (0xfff<<16) //27:16
  2184. +#define RG_SSUSB_BCN_DET_DIS (0x1<<12) //12:12
  2185. +#define RG_SSUSB_U_BCN_OBS_SEL (0xfff<<0) //11:0
  2186. +
  2187. +//U3D_EQ0
  2188. +#define RG_SSUSB_EQ_DLHL_LFI (0x7f<<24) //30:24
  2189. +#define RG_SSUSB_EQ_DHHL_LFI (0x7f<<16) //22:16
  2190. +#define RG_SSUSB_EQ_DD0HOS_LFI (0x7f<<8) //14:8
  2191. +#define RG_SSUSB_EQ_DD0LOS_LFI (0x7f<<0) //6:0
  2192. +
  2193. +//U3D_EQ1
  2194. +#define RG_SSUSB_EQ_DD1HOS_LFI (0x7f<<24) //30:24
  2195. +#define RG_SSUSB_EQ_DD1LOS_LFI (0x7f<<16) //22:16
  2196. +#define RG_SSUSB_EQ_DE0OS_LFI (0x7f<<8) //14:8
  2197. +#define RG_SSUSB_EQ_DE1OS_LFI (0x7f<<0) //6:0
  2198. +
  2199. +//U3D_EQ2
  2200. +#define RG_SSUSB_EQ_DLHLOS_LFI (0x7f<<24) //30:24
  2201. +#define RG_SSUSB_EQ_DHHLOS_LFI (0x7f<<16) //22:16
  2202. +#define RG_SSUSB_EQ_STOPTIME (0x1<<14) //14:14
  2203. +#define RG_SSUSB_EQ_DHHL_LF_SEL (0x7<<11) //13:11
  2204. +#define RG_SSUSB_EQ_DSAOS_LF_SEL (0x7<<8) //10:8
  2205. +#define RG_SSUSB_EQ_STARTTIME (0x3<<6) //7:6
  2206. +#define RG_SSUSB_EQ_DLEQ_LF_SEL (0x7<<3) //5:3
  2207. +#define RG_SSUSB_EQ_DLHL_LF_SEL (0x7<<0) //2:0
  2208. +
  2209. +//U3D_EQ3
  2210. +#define RG_SSUSB_EQ_DLEQ_LFI_GEN2 (0xf<<28) //31:28
  2211. +#define RG_SSUSB_EQ_DLEQ_LFI_GEN1 (0xf<<24) //27:24
  2212. +#define RG_SSUSB_EQ_DEYE0OS_LFI (0x7f<<16) //22:16
  2213. +#define RG_SSUSB_EQ_DEYE1OS_LFI (0x7f<<8) //14:8
  2214. +#define RG_SSUSB_EQ_TRI_DET_EN (0x1<<7) //7:7
  2215. +#define RG_SSUSB_EQ_TRI_DET_TH (0x7f<<0) //6:0
  2216. +
  2217. +//U3D_EQ_EYE0
  2218. +#define RG_SSUSB_EQ_EYE_XOFFSET (0x7f<<25) //31:25
  2219. +#define RG_SSUSB_EQ_EYE_MON_EN (0x1<<24) //24:24
  2220. +#define RG_SSUSB_EQ_EYE0_Y (0x7f<<16) //22:16
  2221. +#define RG_SSUSB_EQ_EYE1_Y (0x7f<<8) //14:8
  2222. +#define RG_SSUSB_EQ_PILPO_ROUT (0x1<<7) //7:7
  2223. +#define RG_SSUSB_EQ_PI_KPGAIN (0x7<<4) //6:4
  2224. +#define RG_SSUSB_EQ_EYE_CNT_EN (0x1<<3) //3:3
  2225. +
  2226. +//U3D_EQ_EYE1
  2227. +#define RG_SSUSB_EQ_SIGDET (0x7f<<24) //30:24
  2228. +#define RG_SSUSB_EQ_EYE_MASK (0x3ff<<7) //16:7
  2229. +
  2230. +//U3D_EQ_EYE2
  2231. +#define RG_SSUSB_EQ_RX500M_CK_SEL (0x1<<31) //31:31
  2232. +#define RG_SSUSB_EQ_SD_CNT1 (0x3f<<24) //29:24
  2233. +#define RG_SSUSB_EQ_ISIFLAG_SEL (0x3<<22) //23:22
  2234. +#define RG_SSUSB_EQ_SD_CNT0 (0x3f<<16) //21:16
  2235. +
  2236. +//U3D_EQ_DFE0
  2237. +#define RG_SSUSB_EQ_LEQMAX (0xf<<28) //31:28
  2238. +#define RG_SSUSB_EQ_DFEX_EN (0x1<<27) //27:27
  2239. +#define RG_SSUSB_EQ_DFEX_LF_SEL (0x7<<24) //26:24
  2240. +#define RG_SSUSB_EQ_CHK_EYE_H (0x1<<23) //23:23
  2241. +#define RG_SSUSB_EQ_PIEYE_INI (0x7f<<16) //22:16
  2242. +#define RG_SSUSB_EQ_PI90_INI (0x7f<<8) //14:8
  2243. +#define RG_SSUSB_EQ_PI0_INI (0x7f<<0) //6:0
  2244. +
  2245. +//U3D_EQ_DFE1
  2246. +#define RG_SSUSB_EQ_REV (0xffff<<16) //31:16
  2247. +#define RG_SSUSB_EQ_DFEYEN_DUR (0x7<<12) //14:12
  2248. +#define RG_SSUSB_EQ_DFEXEN_DUR (0x7<<8) //10:8
  2249. +#define RG_SSUSB_EQ_DFEX_RST (0x1<<7) //7:7
  2250. +#define RG_SSUSB_EQ_GATED_RXD_B (0x1<<6) //6:6
  2251. +#define RG_SSUSB_EQ_PI90CK_SEL (0x3<<4) //5:4
  2252. +#define RG_SSUSB_EQ_DFEX_DIS (0x1<<2) //2:2
  2253. +#define RG_SSUSB_EQ_DFEYEN_STOP_DIS (0x1<<1) //1:1
  2254. +#define RG_SSUSB_EQ_DFEXEN_SEL (0x1<<0) //0:0
  2255. +
  2256. +//U3D_EQ_DFE2
  2257. +#define RG_SSUSB_EQ_MON_SEL (0x1f<<24) //28:24
  2258. +#define RG_SSUSB_EQ_LEQOSC_DLYCNT (0x7<<16) //18:16
  2259. +#define RG_SSUSB_EQ_DLEQOS_LFI (0x1f<<8) //12:8
  2260. +#define RG_SSUSB_EQ_LEQ_STOP_TO (0x3<<0) //1:0
  2261. +
  2262. +//U3D_EQ_DFE3
  2263. +#define RG_SSUSB_EQ_RESERVED (0xffffffff<<0) //31:0
  2264. +
  2265. +//U3D_PHYD_MON0
  2266. +#define RGS_SSUSB_BERT_BERC (0xffff<<16) //31:16
  2267. +#define RGS_SSUSB_LFPS (0xf<<12) //15:12
  2268. +#define RGS_SSUSB_TRAINDEC (0x7<<8) //10:8
  2269. +#define RGS_SSUSB_SCP_PAT (0xff<<0) //7:0
  2270. +
  2271. +//U3D_PHYD_MON1
  2272. +#define RGS_SSUSB_RX_FL_OUT (0xffff<<0) //15:0
  2273. +
  2274. +//U3D_PHYD_MON2
  2275. +#define RGS_SSUSB_T2RLB_ERRCNT (0xffff<<16) //31:16
  2276. +#define RGS_SSUSB_RETRACK (0xf<<12) //15:12
  2277. +#define RGS_SSUSB_RXPLL_LOCK (0x1<<10) //10:10
  2278. +#define RGS_SSUSB_CDR_VCOCAL_CPLT_D (0x1<<9) //9:9
  2279. +#define RGS_SSUSB_PLL_VCOCAL_CPLT_D (0x1<<8) //8:8
  2280. +#define RGS_SSUSB_PDNCTL (0xff<<0) //7:0
  2281. +
  2282. +//U3D_PHYD_MON3
  2283. +#define RGS_SSUSB_TSEQ_ERRCNT (0xffff<<16) //31:16
  2284. +#define RGS_SSUSB_PRBS_ERRCNT (0xffff<<0) //15:0
  2285. +
  2286. +//U3D_PHYD_MON4
  2287. +#define RGS_SSUSB_RX_LSLOCK_CNT (0xf<<24) //27:24
  2288. +#define RGS_SSUSB_SCP_DETCNT (0xff<<16) //23:16
  2289. +#define RGS_SSUSB_TSEQ_DETCNT (0xffff<<0) //15:0
  2290. +
  2291. +//U3D_PHYD_MON5
  2292. +#define RGS_SSUSB_EBUFMSG (0xffff<<16) //31:16
  2293. +#define RGS_SSUSB_BERT_LOCK (0x1<<15) //15:15
  2294. +#define RGS_SSUSB_SCP_DET (0x1<<14) //14:14
  2295. +#define RGS_SSUSB_TSEQ_DET (0x1<<13) //13:13
  2296. +#define RGS_SSUSB_EBUF_UDF (0x1<<12) //12:12
  2297. +#define RGS_SSUSB_EBUF_OVF (0x1<<11) //11:11
  2298. +#define RGS_SSUSB_PRBS_PASSTH (0x1<<10) //10:10
  2299. +#define RGS_SSUSB_PRBS_PASS (0x1<<9) //9:9
  2300. +#define RGS_SSUSB_PRBS_LOCK (0x1<<8) //8:8
  2301. +#define RGS_SSUSB_T2RLB_ERR (0x1<<6) //6:6
  2302. +#define RGS_SSUSB_T2RLB_PASSTH (0x1<<5) //5:5
  2303. +#define RGS_SSUSB_T2RLB_PASS (0x1<<4) //4:4
  2304. +#define RGS_SSUSB_T2RLB_LOCK (0x1<<3) //3:3
  2305. +#define RGS_SSUSB_RX_IMPCAL_DONE (0x1<<2) //2:2
  2306. +#define RGS_SSUSB_TX_IMPCAL_DONE (0x1<<1) //1:1
  2307. +#define RGS_SSUSB_RXDETECTED (0x1<<0) //0:0
  2308. +
  2309. +//U3D_PHYD_MON6
  2310. +#define RGS_SSUSB_SIGCAL_DONE (0x1<<30) //30:30
  2311. +#define RGS_SSUSB_SIGCAL_CAL_OUT (0x1<<29) //29:29
  2312. +#define RGS_SSUSB_SIGCAL_OFFSET (0x1f<<24) //28:24
  2313. +#define RGS_SSUSB_RX_IMP_SEL (0x1f<<16) //20:16
  2314. +#define RGS_SSUSB_TX_IMP_SEL (0x1f<<8) //12:8
  2315. +#define RGS_SSUSB_TFIFO_MSG (0xf<<4) //7:4
  2316. +#define RGS_SSUSB_RFIFO_MSG (0xf<<0) //3:0
  2317. +
  2318. +//U3D_PHYD_MON7
  2319. +#define RGS_SSUSB_FT_OUT (0xff<<8) //15:8
  2320. +#define RGS_SSUSB_PRB_OUT (0xff<<0) //7:0
  2321. +
  2322. +//U3D_PHYA_RX_MON0
  2323. +#define RGS_SSUSB_EQ_DCLEQ (0xf<<24) //27:24
  2324. +#define RGS_SSUSB_EQ_DCD0H (0x7f<<16) //22:16
  2325. +#define RGS_SSUSB_EQ_DCD0L (0x7f<<8) //14:8
  2326. +#define RGS_SSUSB_EQ_DCD1H (0x7f<<0) //6:0
  2327. +
  2328. +//U3D_PHYA_RX_MON1
  2329. +#define RGS_SSUSB_EQ_DCD1L (0x7f<<24) //30:24
  2330. +#define RGS_SSUSB_EQ_DCE0 (0x7f<<16) //22:16
  2331. +#define RGS_SSUSB_EQ_DCE1 (0x7f<<8) //14:8
  2332. +#define RGS_SSUSB_EQ_DCHHL (0x7f<<0) //6:0
  2333. +
  2334. +//U3D_PHYA_RX_MON2
  2335. +#define RGS_SSUSB_EQ_LEQ_STOP (0x1<<31) //31:31
  2336. +#define RGS_SSUSB_EQ_DCLHL (0x7f<<24) //30:24
  2337. +#define RGS_SSUSB_EQ_STATUS (0xff<<16) //23:16
  2338. +#define RGS_SSUSB_EQ_DCEYE0 (0x7f<<8) //14:8
  2339. +#define RGS_SSUSB_EQ_DCEYE1 (0x7f<<0) //6:0
  2340. +
  2341. +//U3D_PHYA_RX_MON3
  2342. +#define RGS_SSUSB_EQ_EYE_MONITOR_ERRCNT_0 (0xfffff<<0) //19:0
  2343. +
  2344. +//U3D_PHYA_RX_MON4
  2345. +#define RGS_SSUSB_EQ_EYE_MONITOR_ERRCNT_1 (0xfffff<<0) //19:0
  2346. +
  2347. +//U3D_PHYA_RX_MON5
  2348. +#define RGS_SSUSB_EQ_DCLEQOS (0x1f<<8) //12:8
  2349. +#define RGS_SSUSB_EQ_EYE_CNT_RDY (0x1<<7) //7:7
  2350. +#define RGS_SSUSB_EQ_PILPO (0x7f<<0) //6:0
  2351. +
  2352. +//U3D_PHYD_CPPAT2
  2353. +#define RG_SSUSB_CPPAT_OUT_H_TMP2 (0xf<<16) //19:16
  2354. +#define RG_SSUSB_CPPAT_OUT_H_TMP1 (0xff<<8) //15:8
  2355. +#define RG_SSUSB_CPPAT_OUT_H_TMP0 (0xff<<0) //7:0
  2356. +
  2357. +//U3D_EQ_EYE3
  2358. +#define RG_SSUSB_EQ_LEQ_SHIFT (0x7<<24) //26:24
  2359. +#define RG_SSUSB_EQ_EYE_CNT (0xfffff<<0) //19:0
  2360. +
  2361. +//U3D_KBAND_OUT
  2362. +#define RGS_SSUSB_CDR_BAND_5G (0xff<<24) //31:24
  2363. +#define RGS_SSUSB_CDR_BAND_2P5G (0xff<<16) //23:16
  2364. +#define RGS_SSUSB_PLL_BAND_5G (0xff<<8) //15:8
  2365. +#define RGS_SSUSB_PLL_BAND_2P5G (0xff<<0) //7:0
  2366. +
  2367. +//U3D_KBAND_OUT1
  2368. +#define RGS_SSUSB_CDR_VCOCAL_FAIL (0x1<<24) //24:24
  2369. +#define RGS_SSUSB_CDR_VCOCAL_STATE (0xff<<16) //23:16
  2370. +#define RGS_SSUSB_PLL_VCOCAL_FAIL (0x1<<8) //8:8
  2371. +#define RGS_SSUSB_PLL_VCOCAL_STATE (0xff<<0) //7:0
  2372. +
  2373. +
  2374. +/* OFFSET */
  2375. +
  2376. +//U3D_PHYD_MIX0
  2377. +#define RG_SSUSB_P_P3_TX_NG_OFST (31)
  2378. +#define RG_SSUSB_TSEQ_EN_OFST (30)
  2379. +#define RG_SSUSB_TSEQ_POLEN_OFST (29)
  2380. +#define RG_SSUSB_TSEQ_POL_OFST (28)
  2381. +#define RG_SSUSB_P_P3_PCLK_NG_OFST (27)
  2382. +#define RG_SSUSB_TSEQ_TH_OFST (24)
  2383. +#define RG_SSUSB_PRBS_BERTH_OFST (16)
  2384. +#define RG_SSUSB_DISABLE_PHY_U2_ON_OFST (15)
  2385. +#define RG_SSUSB_DISABLE_PHY_U2_OFF_OFST (14)
  2386. +#define RG_SSUSB_PRBS_EN_OFST (13)
  2387. +#define RG_SSUSB_BPSLOCK_OFST (12)
  2388. +#define RG_SSUSB_RTCOMCNT_OFST (8)
  2389. +#define RG_SSUSB_COMCNT_OFST (4)
  2390. +#define RG_SSUSB_PRBSEL_CALIB_OFST (0)
  2391. +
  2392. +//U3D_PHYD_MIX1
  2393. +#define RG_SSUSB_SLEEP_EN_OFST (31)
  2394. +#define RG_SSUSB_PRBSEL_PCS_OFST (28)
  2395. +#define RG_SSUSB_TXLFPS_PRD_OFST (24)
  2396. +#define RG_SSUSB_P_RX_P0S_CK_OFST (23)
  2397. +#define RG_SSUSB_P_TX_P0S_CK_OFST (22)
  2398. +#define RG_SSUSB_PDNCTL_OFST (16)
  2399. +#define RG_SSUSB_TX_DRV_EN_OFST (15)
  2400. +#define RG_SSUSB_TX_DRV_SEL_OFST (14)
  2401. +#define RG_SSUSB_TX_DRV_DLY_OFST (8)
  2402. +#define RG_SSUSB_BERT_EN_OFST (7)
  2403. +#define RG_SSUSB_SCP_TH_OFST (4)
  2404. +#define RG_SSUSB_SCP_EN_OFST (3)
  2405. +#define RG_SSUSB_RXANSIDEC_TEST_OFST (0)
  2406. +
  2407. +//U3D_PHYD_LFPS0
  2408. +#define RG_SSUSB_LFPS_PWD_OFST (30)
  2409. +#define RG_SSUSB_FORCE_LFPS_PWD_OFST (29)
  2410. +#define RG_SSUSB_RXLFPS_OVF_OFST (24)
  2411. +#define RG_SSUSB_P3_ENTRY_SEL_OFST (23)
  2412. +#define RG_SSUSB_P3_ENTRY_OFST (22)
  2413. +#define RG_SSUSB_RXLFPS_CDRSEL_OFST (20)
  2414. +#define RG_SSUSB_RXLFPS_CDRTH_OFST (16)
  2415. +#define RG_SSUSB_LOCK5G_BLOCK_OFST (15)
  2416. +#define RG_SSUSB_TFIFO_EXT_D_SEL_OFST (14)
  2417. +#define RG_SSUSB_TFIFO_NO_EXTEND_OFST (13)
  2418. +#define RG_SSUSB_RXLFPS_LOB_OFST (8)
  2419. +#define RG_SSUSB_TXLFPS_EN_OFST (7)
  2420. +#define RG_SSUSB_TXLFPS_SEL_OFST (6)
  2421. +#define RG_SSUSB_RXLFPS_CDRLOCK_OFST (5)
  2422. +#define RG_SSUSB_RXLFPS_UPB_OFST (0)
  2423. +
  2424. +//U3D_PHYD_LFPS1
  2425. +#define RG_SSUSB_RX_IMP_BIAS_OFST (28)
  2426. +#define RG_SSUSB_TX_IMP_BIAS_OFST (24)
  2427. +#define RG_SSUSB_FWAKE_TH_OFST (16)
  2428. +#define RG_SSUSB_RXLFPS_UDF_OFST (8)
  2429. +#define RG_SSUSB_RXLFPS_P0IDLETH_OFST (0)
  2430. +
  2431. +//U3D_PHYD_IMPCAL0
  2432. +#define RG_SSUSB_FORCE_TX_IMPSEL_OFST (31)
  2433. +#define RG_SSUSB_TX_IMPCAL_EN_OFST (30)
  2434. +#define RG_SSUSB_FORCE_TX_IMPCAL_EN_OFST (29)
  2435. +#define RG_SSUSB_TX_IMPSEL_OFST (24)
  2436. +#define RG_SSUSB_TX_IMPCAL_CALCYC_OFST (16)
  2437. +#define RG_SSUSB_TX_IMPCAL_STBCYC_OFST (10)
  2438. +#define RG_SSUSB_TX_IMPCAL_CYCCNT_OFST (0)
  2439. +
  2440. +//U3D_PHYD_IMPCAL1
  2441. +#define RG_SSUSB_FORCE_RX_IMPSEL_OFST (31)
  2442. +#define RG_SSUSB_RX_IMPCAL_EN_OFST (30)
  2443. +#define RG_SSUSB_FORCE_RX_IMPCAL_EN_OFST (29)
  2444. +#define RG_SSUSB_RX_IMPSEL_OFST (24)
  2445. +#define RG_SSUSB_RX_IMPCAL_CALCYC_OFST (16)
  2446. +#define RG_SSUSB_RX_IMPCAL_STBCYC_OFST (10)
  2447. +#define RG_SSUSB_RX_IMPCAL_CYCCNT_OFST (0)
  2448. +
  2449. +//U3D_PHYD_TXPLL0
  2450. +#define RG_SSUSB_TXPLL_DDSEN_CYC_OFST (27)
  2451. +#define RG_SSUSB_TXPLL_ON_OFST (26)
  2452. +#define RG_SSUSB_FORCE_TXPLLON_OFST (25)
  2453. +#define RG_SSUSB_TXPLL_STBCYC_OFST (16)
  2454. +#define RG_SSUSB_TXPLL_NCPOCHG_CYC_OFST (12)
  2455. +#define RG_SSUSB_TXPLL_NCPOEN_CYC_OFST (10)
  2456. +#define RG_SSUSB_TXPLL_DDSRSTB_CYC_OFST (0)
  2457. +
  2458. +//U3D_PHYD_TXPLL1
  2459. +#define RG_SSUSB_PLL_NCPO_EN_OFST (31)
  2460. +#define RG_SSUSB_PLL_FIFO_START_MAN_OFST (30)
  2461. +#define RG_SSUSB_PLL_NCPO_CHG_OFST (28)
  2462. +#define RG_SSUSB_PLL_DDS_RSTB_OFST (27)
  2463. +#define RG_SSUSB_PLL_DDS_PWDB_OFST (26)
  2464. +#define RG_SSUSB_PLL_DDSEN_OFST (25)
  2465. +#define RG_SSUSB_PLL_AUTOK_VCO_OFST (24)
  2466. +#define RG_SSUSB_PLL_PWD_OFST (23)
  2467. +#define RG_SSUSB_RX_AFE_PWD_OFST (22)
  2468. +#define RG_SSUSB_PLL_TCADJ_OFST (16)
  2469. +#define RG_SSUSB_FORCE_CDR_TCADJ_OFST (15)
  2470. +#define RG_SSUSB_FORCE_CDR_AUTOK_VCO_OFST (14)
  2471. +#define RG_SSUSB_FORCE_CDR_PWD_OFST (13)
  2472. +#define RG_SSUSB_FORCE_PLL_NCPO_EN_OFST (12)
  2473. +#define RG_SSUSB_FORCE_PLL_FIFO_START_MAN_OFST (11)
  2474. +#define RG_SSUSB_FORCE_PLL_NCPO_CHG_OFST (9)
  2475. +#define RG_SSUSB_FORCE_PLL_DDS_RSTB_OFST (8)
  2476. +#define RG_SSUSB_FORCE_PLL_DDS_PWDB_OFST (7)
  2477. +#define RG_SSUSB_FORCE_PLL_DDSEN_OFST (6)
  2478. +#define RG_SSUSB_FORCE_PLL_TCADJ_OFST (5)
  2479. +#define RG_SSUSB_FORCE_PLL_AUTOK_VCO_OFST (4)
  2480. +#define RG_SSUSB_FORCE_PLL_PWD_OFST (3)
  2481. +#define RG_SSUSB_FLT_1_DISPERR_B_OFST (2)
  2482. +
  2483. +//U3D_PHYD_TXPLL2
  2484. +#define RG_SSUSB_TX_LFPS_EN_OFST (31)
  2485. +#define RG_SSUSB_FORCE_TX_LFPS_EN_OFST (30)
  2486. +#define RG_SSUSB_TX_LFPS_OFST (29)
  2487. +#define RG_SSUSB_FORCE_TX_LFPS_OFST (28)
  2488. +#define RG_SSUSB_RXPLL_STB_OFST (27)
  2489. +#define RG_SSUSB_TXPLL_STB_OFST (26)
  2490. +#define RG_SSUSB_FORCE_RXPLL_STB_OFST (25)
  2491. +#define RG_SSUSB_FORCE_TXPLL_STB_OFST (24)
  2492. +#define RG_SSUSB_RXPLL_REFCKSEL_OFST (16)
  2493. +#define RG_SSUSB_RXPLL_STBMODE_OFST (11)
  2494. +#define RG_SSUSB_RXPLL_ON_OFST (10)
  2495. +#define RG_SSUSB_FORCE_RXPLLON_OFST (9)
  2496. +#define RG_SSUSB_FORCE_RX_AFE_PWD_OFST (8)
  2497. +#define RG_SSUSB_CDR_AUTOK_VCO_OFST (7)
  2498. +#define RG_SSUSB_CDR_PWD_OFST (6)
  2499. +#define RG_SSUSB_CDR_TCADJ_OFST (0)
  2500. +
  2501. +//U3D_PHYD_FL0
  2502. +#define RG_SSUSB_RX_FL_TARGET_OFST (16)
  2503. +#define RG_SSUSB_RX_FL_CYCLECNT_OFST (0)
  2504. +
  2505. +//U3D_PHYD_MIX2
  2506. +#define RG_SSUSB_RX_EQ_RST_OFST (31)
  2507. +#define RG_SSUSB_RX_EQ_RST_SEL_OFST (30)
  2508. +#define RG_SSUSB_RXVAL_RST_OFST (29)
  2509. +#define RG_SSUSB_RXVAL_CNT_OFST (24)
  2510. +#define RG_SSUSB_CDROS_EN_OFST (18)
  2511. +#define RG_SSUSB_CDR_LCKOP_OFST (16)
  2512. +#define RG_SSUSB_RX_FL_LOCKTH_OFST (8)
  2513. +#define RG_SSUSB_RX_FL_OFFSET_OFST (0)
  2514. +
  2515. +//U3D_PHYD_RX0
  2516. +#define RG_SSUSB_T2RLB_BERTH_OFST (24)
  2517. +#define RG_SSUSB_T2RLB_PAT_OFST (16)
  2518. +#define RG_SSUSB_T2RLB_EN_OFST (15)
  2519. +#define RG_SSUSB_T2RLB_BPSCRAMB_OFST (14)
  2520. +#define RG_SSUSB_T2RLB_SERIAL_OFST (13)
  2521. +#define RG_SSUSB_T2RLB_MODE_OFST (11)
  2522. +#define RG_SSUSB_RX_SAOSC_EN_OFST (10)
  2523. +#define RG_SSUSB_RX_SAOSC_EN_SEL_OFST (9)
  2524. +#define RG_SSUSB_RX_DFE_OPTION_OFST (8)
  2525. +#define RG_SSUSB_RX_DFE_EN_OFST (7)
  2526. +#define RG_SSUSB_RX_DFE_EN_SEL_OFST (6)
  2527. +#define RG_SSUSB_RX_EQ_EN_OFST (5)
  2528. +#define RG_SSUSB_RX_EQ_EN_SEL_OFST (4)
  2529. +#define RG_SSUSB_RX_SAOSC_RST_OFST (3)
  2530. +#define RG_SSUSB_RX_SAOSC_RST_SEL_OFST (2)
  2531. +#define RG_SSUSB_RX_DFE_RST_OFST (1)
  2532. +#define RG_SSUSB_RX_DFE_RST_SEL_OFST (0)
  2533. +
  2534. +//U3D_PHYD_T2RLB
  2535. +#define RG_SSUSB_EQTRAIN_CH_MODE_OFST (28)
  2536. +#define RG_SSUSB_PRB_OUT_CPPAT_OFST (27)
  2537. +#define RG_SSUSB_BPANSIENC_OFST (26)
  2538. +#define RG_SSUSB_VALID_EN_OFST (25)
  2539. +#define RG_SSUSB_EBUF_SRST_OFST (24)
  2540. +#define RG_SSUSB_K_EMP_OFST (20)
  2541. +#define RG_SSUSB_K_FUL_OFST (16)
  2542. +#define RG_SSUSB_T2RLB_BDATRST_OFST (12)
  2543. +#define RG_SSUSB_P_T2RLB_SKP_EN_OFST (10)
  2544. +#define RG_SSUSB_T2RLB_PATMODE_OFST (8)
  2545. +#define RG_SSUSB_T2RLB_TSEQCNT_OFST (0)
  2546. +
  2547. +//U3D_PHYD_CPPAT
  2548. +#define RG_SSUSB_CPPAT_PROGRAM_EN_OFST (24)
  2549. +#define RG_SSUSB_CPPAT_TOZ_OFST (21)
  2550. +#define RG_SSUSB_CPPAT_PRBS_EN_OFST (20)
  2551. +#define RG_SSUSB_CPPAT_OUT_TMP2_OFST (16)
  2552. +#define RG_SSUSB_CPPAT_OUT_TMP1_OFST (8)
  2553. +#define RG_SSUSB_CPPAT_OUT_TMP0_OFST (0)
  2554. +
  2555. +//U3D_PHYD_MIX3
  2556. +#define RG_SSUSB_CDR_TCADJ_MINUS_OFST (31)
  2557. +#define RG_SSUSB_P_CDROS_EN_OFST (30)
  2558. +#define RG_SSUSB_P_P2_TX_DRV_DIS_OFST (28)
  2559. +#define RG_SSUSB_CDR_TCADJ_OFFSET_OFST (24)
  2560. +#define RG_SSUSB_PLL_TCADJ_MINUS_OFST (23)
  2561. +#define RG_SSUSB_FORCE_PLL_BIAS_LPF_EN_OFST (20)
  2562. +#define RG_SSUSB_PLL_BIAS_LPF_EN_OFST (19)
  2563. +#define RG_SSUSB_PLL_TCADJ_OFFSET_OFST (16)
  2564. +#define RG_SSUSB_FORCE_PLL_SSCEN_OFST (15)
  2565. +#define RG_SSUSB_PLL_SSCEN_OFST (14)
  2566. +#define RG_SSUSB_FORCE_CDR_PI_PWD_OFST (13)
  2567. +#define RG_SSUSB_CDR_PI_PWD_OFST (12)
  2568. +#define RG_SSUSB_CDR_PI_MODE_OFST (11)
  2569. +#define RG_SSUSB_TXPLL_SSCEN_CYC_OFST (0)
  2570. +
  2571. +//U3D_PHYD_EBUFCTL
  2572. +#define RG_SSUSB_EBUFCTL_OFST (0)
  2573. +
  2574. +//U3D_PHYD_PIPE0
  2575. +#define RG_SSUSB_RXTERMINATION_OFST (30)
  2576. +#define RG_SSUSB_RXEQTRAINING_OFST (29)
  2577. +#define RG_SSUSB_RXPOLARITY_OFST (28)
  2578. +#define RG_SSUSB_TXDEEMPH_OFST (26)
  2579. +#define RG_SSUSB_POWERDOWN_OFST (24)
  2580. +#define RG_SSUSB_TXONESZEROS_OFST (23)
  2581. +#define RG_SSUSB_TXELECIDLE_OFST (22)
  2582. +#define RG_SSUSB_TXDETECTRX_OFST (21)
  2583. +#define RG_SSUSB_PIPE_SEL_OFST (20)
  2584. +#define RG_SSUSB_TXDATAK_OFST (16)
  2585. +#define RG_SSUSB_CDR_STABLE_SEL_OFST (15)
  2586. +#define RG_SSUSB_CDR_STABLE_OFST (14)
  2587. +#define RG_SSUSB_CDR_RSTB_SEL_OFST (13)
  2588. +#define RG_SSUSB_CDR_RSTB_OFST (12)
  2589. +#define RG_SSUSB_P_ERROR_SEL_OFST (4)
  2590. +#define RG_SSUSB_TXMARGIN_OFST (1)
  2591. +#define RG_SSUSB_TXCOMPLIANCE_OFST (0)
  2592. +
  2593. +//U3D_PHYD_PIPE1
  2594. +#define RG_SSUSB_TXDATA_OFST (0)
  2595. +
  2596. +//U3D_PHYD_MIX4
  2597. +#define RG_SSUSB_CDROS_CNT_OFST (24)
  2598. +#define RG_SSUSB_T2RLB_BER_EN_OFST (16)
  2599. +#define RG_SSUSB_T2RLB_BER_RATE_OFST (0)
  2600. +
  2601. +//U3D_PHYD_CKGEN0
  2602. +#define RG_SSUSB_RFIFO_IMPLAT_OFST (27)
  2603. +#define RG_SSUSB_TFIFO_PSEL_OFST (24)
  2604. +#define RG_SSUSB_CKGEN_PSEL_OFST (8)
  2605. +#define RG_SSUSB_RXCK_INV_OFST (0)
  2606. +
  2607. +//U3D_PHYD_MIX5
  2608. +#define RG_SSUSB_PRB_SEL_OFST (16)
  2609. +#define RG_SSUSB_RXPLL_STBCYC_OFST (0)
  2610. +
  2611. +//U3D_PHYD_RESERVED
  2612. +#define RG_SSUSB_PHYD_RESERVE_OFST (0)
  2613. +//#define RG_SSUSB_RX_SIGDET_SEL_OFST (11)
  2614. +//#define RG_SSUSB_RX_SIGDET_EN_OFST (12)
  2615. +//#define RG_SSUSB_RX_PI_CAL_MANUAL_SEL_OFST (9)
  2616. +//#define RG_SSUSB_RX_PI_CAL_MANUAL_EN_OFST (10)
  2617. +
  2618. +//U3D_PHYD_CDR0
  2619. +#define RG_SSUSB_CDR_BIC_LTR_OFST (28)
  2620. +#define RG_SSUSB_CDR_BIC_LTD0_OFST (24)
  2621. +#define RG_SSUSB_CDR_BC_LTD1_OFST (16)
  2622. +#define RG_SSUSB_CDR_BC_LTR_OFST (8)
  2623. +#define RG_SSUSB_CDR_BC_LTD0_OFST (0)
  2624. +
  2625. +//U3D_PHYD_CDR1
  2626. +#define RG_SSUSB_CDR_BIR_LTD1_OFST (24)
  2627. +#define RG_SSUSB_CDR_BIR_LTR_OFST (16)
  2628. +#define RG_SSUSB_CDR_BIR_LTD0_OFST (8)
  2629. +#define RG_SSUSB_CDR_BW_SEL_OFST (6)
  2630. +#define RG_SSUSB_CDR_BIC_LTD1_OFST (0)
  2631. +
  2632. +//U3D_PHYD_PLL_0
  2633. +#define RG_SSUSB_FORCE_CDR_BAND_5G_OFST (28)
  2634. +#define RG_SSUSB_FORCE_CDR_BAND_2P5G_OFST (27)
  2635. +#define RG_SSUSB_FORCE_PLL_BAND_5G_OFST (26)
  2636. +#define RG_SSUSB_FORCE_PLL_BAND_2P5G_OFST (25)
  2637. +#define RG_SSUSB_P_EQ_T_SEL_OFST (15)
  2638. +#define RG_SSUSB_PLL_ISO_EN_CYC_OFST (5)
  2639. +#define RG_SSUSB_PLLBAND_RECAL_OFST (4)
  2640. +#define RG_SSUSB_PLL_DDS_ISO_EN_OFST (3)
  2641. +#define RG_SSUSB_FORCE_PLL_DDS_ISO_EN_OFST (2)
  2642. +#define RG_SSUSB_PLL_DDS_PWR_ON_OFST (1)
  2643. +#define RG_SSUSB_FORCE_PLL_DDS_PWR_ON_OFST (0)
  2644. +
  2645. +//U3D_PHYD_PLL_1
  2646. +#define RG_SSUSB_CDR_BAND_5G_OFST (24)
  2647. +#define RG_SSUSB_CDR_BAND_2P5G_OFST (16)
  2648. +#define RG_SSUSB_PLL_BAND_5G_OFST (8)
  2649. +#define RG_SSUSB_PLL_BAND_2P5G_OFST (0)
  2650. +
  2651. +//U3D_PHYD_BCN_DET_1
  2652. +#define RG_SSUSB_P_BCN_OBS_PRD_OFST (16)
  2653. +#define RG_SSUSB_U_BCN_OBS_PRD_OFST (0)
  2654. +
  2655. +//U3D_PHYD_BCN_DET_2
  2656. +#define RG_SSUSB_P_BCN_OBS_SEL_OFST (16)
  2657. +#define RG_SSUSB_BCN_DET_DIS_OFST (12)
  2658. +#define RG_SSUSB_U_BCN_OBS_SEL_OFST (0)
  2659. +
  2660. +//U3D_EQ0
  2661. +#define RG_SSUSB_EQ_DLHL_LFI_OFST (24)
  2662. +#define RG_SSUSB_EQ_DHHL_LFI_OFST (16)
  2663. +#define RG_SSUSB_EQ_DD0HOS_LFI_OFST (8)
  2664. +#define RG_SSUSB_EQ_DD0LOS_LFI_OFST (0)
  2665. +
  2666. +//U3D_EQ1
  2667. +#define RG_SSUSB_EQ_DD1HOS_LFI_OFST (24)
  2668. +#define RG_SSUSB_EQ_DD1LOS_LFI_OFST (16)
  2669. +#define RG_SSUSB_EQ_DE0OS_LFI_OFST (8)
  2670. +#define RG_SSUSB_EQ_DE1OS_LFI_OFST (0)
  2671. +
  2672. +//U3D_EQ2
  2673. +#define RG_SSUSB_EQ_DLHLOS_LFI_OFST (24)
  2674. +#define RG_SSUSB_EQ_DHHLOS_LFI_OFST (16)
  2675. +#define RG_SSUSB_EQ_STOPTIME_OFST (14)
  2676. +#define RG_SSUSB_EQ_DHHL_LF_SEL_OFST (11)
  2677. +#define RG_SSUSB_EQ_DSAOS_LF_SEL_OFST (8)
  2678. +#define RG_SSUSB_EQ_STARTTIME_OFST (6)
  2679. +#define RG_SSUSB_EQ_DLEQ_LF_SEL_OFST (3)
  2680. +#define RG_SSUSB_EQ_DLHL_LF_SEL_OFST (0)
  2681. +
  2682. +//U3D_EQ3
  2683. +#define RG_SSUSB_EQ_DLEQ_LFI_GEN2_OFST (28)
  2684. +#define RG_SSUSB_EQ_DLEQ_LFI_GEN1_OFST (24)
  2685. +#define RG_SSUSB_EQ_DEYE0OS_LFI_OFST (16)
  2686. +#define RG_SSUSB_EQ_DEYE1OS_LFI_OFST (8)
  2687. +#define RG_SSUSB_EQ_TRI_DET_EN_OFST (7)
  2688. +#define RG_SSUSB_EQ_TRI_DET_TH_OFST (0)
  2689. +
  2690. +//U3D_EQ_EYE0
  2691. +#define RG_SSUSB_EQ_EYE_XOFFSET_OFST (25)
  2692. +#define RG_SSUSB_EQ_EYE_MON_EN_OFST (24)
  2693. +#define RG_SSUSB_EQ_EYE0_Y_OFST (16)
  2694. +#define RG_SSUSB_EQ_EYE1_Y_OFST (8)
  2695. +#define RG_SSUSB_EQ_PILPO_ROUT_OFST (7)
  2696. +#define RG_SSUSB_EQ_PI_KPGAIN_OFST (4)
  2697. +#define RG_SSUSB_EQ_EYE_CNT_EN_OFST (3)
  2698. +
  2699. +//U3D_EQ_EYE1
  2700. +#define RG_SSUSB_EQ_SIGDET_OFST (24)
  2701. +#define RG_SSUSB_EQ_EYE_MASK_OFST (7)
  2702. +
  2703. +//U3D_EQ_EYE2
  2704. +#define RG_SSUSB_EQ_RX500M_CK_SEL_OFST (31)
  2705. +#define RG_SSUSB_EQ_SD_CNT1_OFST (24)
  2706. +#define RG_SSUSB_EQ_ISIFLAG_SEL_OFST (22)
  2707. +#define RG_SSUSB_EQ_SD_CNT0_OFST (16)
  2708. +
  2709. +//U3D_EQ_DFE0
  2710. +#define RG_SSUSB_EQ_LEQMAX_OFST (28)
  2711. +#define RG_SSUSB_EQ_DFEX_EN_OFST (27)
  2712. +#define RG_SSUSB_EQ_DFEX_LF_SEL_OFST (24)
  2713. +#define RG_SSUSB_EQ_CHK_EYE_H_OFST (23)
  2714. +#define RG_SSUSB_EQ_PIEYE_INI_OFST (16)
  2715. +#define RG_SSUSB_EQ_PI90_INI_OFST (8)
  2716. +#define RG_SSUSB_EQ_PI0_INI_OFST (0)
  2717. +
  2718. +//U3D_EQ_DFE1
  2719. +#define RG_SSUSB_EQ_REV_OFST (16)
  2720. +#define RG_SSUSB_EQ_DFEYEN_DUR_OFST (12)
  2721. +#define RG_SSUSB_EQ_DFEXEN_DUR_OFST (8)
  2722. +#define RG_SSUSB_EQ_DFEX_RST_OFST (7)
  2723. +#define RG_SSUSB_EQ_GATED_RXD_B_OFST (6)
  2724. +#define RG_SSUSB_EQ_PI90CK_SEL_OFST (4)
  2725. +#define RG_SSUSB_EQ_DFEX_DIS_OFST (2)
  2726. +#define RG_SSUSB_EQ_DFEYEN_STOP_DIS_OFST (1)
  2727. +#define RG_SSUSB_EQ_DFEXEN_SEL_OFST (0)
  2728. +
  2729. +//U3D_EQ_DFE2
  2730. +#define RG_SSUSB_EQ_MON_SEL_OFST (24)
  2731. +#define RG_SSUSB_EQ_LEQOSC_DLYCNT_OFST (16)
  2732. +#define RG_SSUSB_EQ_DLEQOS_LFI_OFST (8)
  2733. +#define RG_SSUSB_EQ_LEQ_STOP_TO_OFST (0)
  2734. +
  2735. +//U3D_EQ_DFE3
  2736. +#define RG_SSUSB_EQ_RESERVED_OFST (0)
  2737. +
  2738. +//U3D_PHYD_MON0
  2739. +#define RGS_SSUSB_BERT_BERC_OFST (16)
  2740. +#define RGS_SSUSB_LFPS_OFST (12)
  2741. +#define RGS_SSUSB_TRAINDEC_OFST (8)
  2742. +#define RGS_SSUSB_SCP_PAT_OFST (0)
  2743. +
  2744. +//U3D_PHYD_MON1
  2745. +#define RGS_SSUSB_RX_FL_OUT_OFST (0)
  2746. +
  2747. +//U3D_PHYD_MON2
  2748. +#define RGS_SSUSB_T2RLB_ERRCNT_OFST (16)
  2749. +#define RGS_SSUSB_RETRACK_OFST (12)
  2750. +#define RGS_SSUSB_RXPLL_LOCK_OFST (10)
  2751. +#define RGS_SSUSB_CDR_VCOCAL_CPLT_D_OFST (9)
  2752. +#define RGS_SSUSB_PLL_VCOCAL_CPLT_D_OFST (8)
  2753. +#define RGS_SSUSB_PDNCTL_OFST (0)
  2754. +
  2755. +//U3D_PHYD_MON3
  2756. +#define RGS_SSUSB_TSEQ_ERRCNT_OFST (16)
  2757. +#define RGS_SSUSB_PRBS_ERRCNT_OFST (0)
  2758. +
  2759. +//U3D_PHYD_MON4
  2760. +#define RGS_SSUSB_RX_LSLOCK_CNT_OFST (24)
  2761. +#define RGS_SSUSB_SCP_DETCNT_OFST (16)
  2762. +#define RGS_SSUSB_TSEQ_DETCNT_OFST (0)
  2763. +
  2764. +//U3D_PHYD_MON5
  2765. +#define RGS_SSUSB_EBUFMSG_OFST (16)
  2766. +#define RGS_SSUSB_BERT_LOCK_OFST (15)
  2767. +#define RGS_SSUSB_SCP_DET_OFST (14)
  2768. +#define RGS_SSUSB_TSEQ_DET_OFST (13)
  2769. +#define RGS_SSUSB_EBUF_UDF_OFST (12)
  2770. +#define RGS_SSUSB_EBUF_OVF_OFST (11)
  2771. +#define RGS_SSUSB_PRBS_PASSTH_OFST (10)
  2772. +#define RGS_SSUSB_PRBS_PASS_OFST (9)
  2773. +#define RGS_SSUSB_PRBS_LOCK_OFST (8)
  2774. +#define RGS_SSUSB_T2RLB_ERR_OFST (6)
  2775. +#define RGS_SSUSB_T2RLB_PASSTH_OFST (5)
  2776. +#define RGS_SSUSB_T2RLB_PASS_OFST (4)
  2777. +#define RGS_SSUSB_T2RLB_LOCK_OFST (3)
  2778. +#define RGS_SSUSB_RX_IMPCAL_DONE_OFST (2)
  2779. +#define RGS_SSUSB_TX_IMPCAL_DONE_OFST (1)
  2780. +#define RGS_SSUSB_RXDETECTED_OFST (0)
  2781. +
  2782. +//U3D_PHYD_MON6
  2783. +#define RGS_SSUSB_SIGCAL_DONE_OFST (30)
  2784. +#define RGS_SSUSB_SIGCAL_CAL_OUT_OFST (29)
  2785. +#define RGS_SSUSB_SIGCAL_OFFSET_OFST (24)
  2786. +#define RGS_SSUSB_RX_IMP_SEL_OFST (16)
  2787. +#define RGS_SSUSB_TX_IMP_SEL_OFST (8)
  2788. +#define RGS_SSUSB_TFIFO_MSG_OFST (4)
  2789. +#define RGS_SSUSB_RFIFO_MSG_OFST (0)
  2790. +
  2791. +//U3D_PHYD_MON7
  2792. +#define RGS_SSUSB_FT_OUT_OFST (8)
  2793. +#define RGS_SSUSB_PRB_OUT_OFST (0)
  2794. +
  2795. +//U3D_PHYA_RX_MON0
  2796. +#define RGS_SSUSB_EQ_DCLEQ_OFST (24)
  2797. +#define RGS_SSUSB_EQ_DCD0H_OFST (16)
  2798. +#define RGS_SSUSB_EQ_DCD0L_OFST (8)
  2799. +#define RGS_SSUSB_EQ_DCD1H_OFST (0)
  2800. +
  2801. +//U3D_PHYA_RX_MON1
  2802. +#define RGS_SSUSB_EQ_DCD1L_OFST (24)
  2803. +#define RGS_SSUSB_EQ_DCE0_OFST (16)
  2804. +#define RGS_SSUSB_EQ_DCE1_OFST (8)
  2805. +#define RGS_SSUSB_EQ_DCHHL_OFST (0)
  2806. +
  2807. +//U3D_PHYA_RX_MON2
  2808. +#define RGS_SSUSB_EQ_LEQ_STOP_OFST (31)
  2809. +#define RGS_SSUSB_EQ_DCLHL_OFST (24)
  2810. +#define RGS_SSUSB_EQ_STATUS_OFST (16)
  2811. +#define RGS_SSUSB_EQ_DCEYE0_OFST (8)
  2812. +#define RGS_SSUSB_EQ_DCEYE1_OFST (0)
  2813. +
  2814. +//U3D_PHYA_RX_MON3
  2815. +#define RGS_SSUSB_EQ_EYE_MONITOR_ERRCNT_0_OFST (0)
  2816. +
  2817. +//U3D_PHYA_RX_MON4
  2818. +#define RGS_SSUSB_EQ_EYE_MONITOR_ERRCNT_1_OFST (0)
  2819. +
  2820. +//U3D_PHYA_RX_MON5
  2821. +#define RGS_SSUSB_EQ_DCLEQOS_OFST (8)
  2822. +#define RGS_SSUSB_EQ_EYE_CNT_RDY_OFST (7)
  2823. +#define RGS_SSUSB_EQ_PILPO_OFST (0)
  2824. +
  2825. +//U3D_PHYD_CPPAT2
  2826. +#define RG_SSUSB_CPPAT_OUT_H_TMP2_OFST (16)
  2827. +#define RG_SSUSB_CPPAT_OUT_H_TMP1_OFST (8)
  2828. +#define RG_SSUSB_CPPAT_OUT_H_TMP0_OFST (0)
  2829. +
  2830. +//U3D_EQ_EYE3
  2831. +#define RG_SSUSB_EQ_LEQ_SHIFT_OFST (24)
  2832. +#define RG_SSUSB_EQ_EYE_CNT_OFST (0)
  2833. +
  2834. +//U3D_KBAND_OUT
  2835. +#define RGS_SSUSB_CDR_BAND_5G_OFST (24)
  2836. +#define RGS_SSUSB_CDR_BAND_2P5G_OFST (16)
  2837. +#define RGS_SSUSB_PLL_BAND_5G_OFST (8)
  2838. +#define RGS_SSUSB_PLL_BAND_2P5G_OFST (0)
  2839. +
  2840. +//U3D_KBAND_OUT1
  2841. +#define RGS_SSUSB_CDR_VCOCAL_FAIL_OFST (24)
  2842. +#define RGS_SSUSB_CDR_VCOCAL_STATE_OFST (16)
  2843. +#define RGS_SSUSB_PLL_VCOCAL_FAIL_OFST (8)
  2844. +#define RGS_SSUSB_PLL_VCOCAL_STATE_OFST (0)
  2845. +
  2846. +
  2847. +///////////////////////////////////////////////////////////////////////////////
  2848. +
  2849. +struct u3phyd_bank2_reg {
  2850. + //0x0
  2851. + PHY_LE32 b2_phyd_top1;
  2852. + PHY_LE32 b2_phyd_top2;
  2853. + PHY_LE32 b2_phyd_top3;
  2854. + PHY_LE32 b2_phyd_top4;
  2855. + //0x10
  2856. + PHY_LE32 b2_phyd_top5;
  2857. + PHY_LE32 b2_phyd_top6;
  2858. + PHY_LE32 b2_phyd_top7;
  2859. + PHY_LE32 b2_phyd_p_sigdet1;
  2860. + //0x20
  2861. + PHY_LE32 b2_phyd_p_sigdet2;
  2862. + PHY_LE32 b2_phyd_p_sigdet_cal1;
  2863. + PHY_LE32 b2_phyd_rxdet1;
  2864. + PHY_LE32 b2_phyd_rxdet2;
  2865. + //0x30
  2866. + PHY_LE32 b2_phyd_misc0;
  2867. + PHY_LE32 b2_phyd_misc2;
  2868. + PHY_LE32 b2_phyd_misc3;
  2869. + PHY_LE32 reserve0;
  2870. + //0x40
  2871. + PHY_LE32 b2_rosc_0;
  2872. + PHY_LE32 b2_rosc_1;
  2873. + PHY_LE32 b2_rosc_2;
  2874. + PHY_LE32 b2_rosc_3;
  2875. + //0x50
  2876. + PHY_LE32 b2_rosc_4;
  2877. + PHY_LE32 b2_rosc_5;
  2878. + PHY_LE32 b2_rosc_6;
  2879. + PHY_LE32 b2_rosc_7;
  2880. + //0x60
  2881. + PHY_LE32 b2_rosc_8;
  2882. + PHY_LE32 b2_rosc_9;
  2883. + PHY_LE32 b2_rosc_a;
  2884. + PHY_LE32 reserve1;
  2885. + //0x70~0xd0
  2886. + PHY_LE32 reserve2[28];
  2887. + //0xe0
  2888. + PHY_LE32 phyd_version;
  2889. + PHY_LE32 phyd_model;
  2890. +};
  2891. +
  2892. +//U3D_B2_PHYD_TOP1
  2893. +#define RG_SSUSB_PCIE2_K_EMP (0xf<<28) //31:28
  2894. +#define RG_SSUSB_PCIE2_K_FUL (0xf<<24) //27:24
  2895. +#define RG_SSUSB_TX_EIDLE_LP_EN (0x1<<17) //17:17
  2896. +#define RG_SSUSB_FORCE_TX_EIDLE_LP_EN (0x1<<16) //16:16
  2897. +#define RG_SSUSB_SIGDET_EN (0x1<<15) //15:15
  2898. +#define RG_SSUSB_FORCE_SIGDET_EN (0x1<<14) //14:14
  2899. +#define RG_SSUSB_CLKRX_EN (0x1<<13) //13:13
  2900. +#define RG_SSUSB_FORCE_CLKRX_EN (0x1<<12) //12:12
  2901. +#define RG_SSUSB_CLKTX_EN (0x1<<11) //11:11
  2902. +#define RG_SSUSB_FORCE_CLKTX_EN (0x1<<10) //10:10
  2903. +#define RG_SSUSB_CLK_REQ_N_I (0x1<<9) //9:9
  2904. +#define RG_SSUSB_FORCE_CLK_REQ_N_I (0x1<<8) //8:8
  2905. +#define RG_SSUSB_RATE (0x1<<6) //6:6
  2906. +#define RG_SSUSB_FORCE_RATE (0x1<<5) //5:5
  2907. +#define RG_SSUSB_PCIE_MODE_SEL (0x1<<4) //4:4
  2908. +#define RG_SSUSB_FORCE_PCIE_MODE_SEL (0x1<<3) //3:3
  2909. +#define RG_SSUSB_PHY_MODE (0x3<<1) //2:1
  2910. +#define RG_SSUSB_FORCE_PHY_MODE (0x1<<0) //0:0
  2911. +
  2912. +//U3D_B2_PHYD_TOP2
  2913. +#define RG_SSUSB_FORCE_IDRV_6DB (0x1<<30) //30:30
  2914. +#define RG_SSUSB_IDRV_6DB (0x3f<<24) //29:24
  2915. +#define RG_SSUSB_FORCE_IDEM_3P5DB (0x1<<22) //22:22
  2916. +#define RG_SSUSB_IDEM_3P5DB (0x3f<<16) //21:16
  2917. +#define RG_SSUSB_FORCE_IDRV_3P5DB (0x1<<14) //14:14
  2918. +#define RG_SSUSB_IDRV_3P5DB (0x3f<<8) //13:8
  2919. +#define RG_SSUSB_FORCE_IDRV_0DB (0x1<<6) //6:6
  2920. +#define RG_SSUSB_IDRV_0DB (0x3f<<0) //5:0
  2921. +
  2922. +//U3D_B2_PHYD_TOP3
  2923. +#define RG_SSUSB_TX_BIASI (0x7<<25) //27:25
  2924. +#define RG_SSUSB_FORCE_TX_BIASI_EN (0x1<<24) //24:24
  2925. +#define RG_SSUSB_TX_BIASI_EN (0x1<<16) //16:16
  2926. +#define RG_SSUSB_FORCE_TX_BIASI (0x1<<13) //13:13
  2927. +#define RG_SSUSB_FORCE_IDEM_6DB (0x1<<8) //8:8
  2928. +#define RG_SSUSB_IDEM_6DB (0x3f<<0) //5:0
  2929. +
  2930. +//U3D_B2_PHYD_TOP4
  2931. +#define RG_SSUSB_G1_CDR_BIC_LTR (0xf<<28) //31:28
  2932. +#define RG_SSUSB_G1_CDR_BIC_LTD0 (0xf<<24) //27:24
  2933. +#define RG_SSUSB_G1_CDR_BC_LTD1 (0x1f<<16) //20:16
  2934. +#define RG_SSUSB_G1_CDR_BC_LTR (0x1f<<8) //12:8
  2935. +#define RG_SSUSB_G1_CDR_BC_LTD0 (0x1f<<0) //4:0
  2936. +
  2937. +//U3D_B2_PHYD_TOP5
  2938. +#define RG_SSUSB_G1_CDR_BIR_LTD1 (0x1f<<24) //28:24
  2939. +#define RG_SSUSB_G1_CDR_BIR_LTR (0x1f<<16) //20:16
  2940. +#define RG_SSUSB_G1_CDR_BIR_LTD0 (0x1f<<8) //12:8
  2941. +#define RG_SSUSB_G1_CDR_BIC_LTD1 (0xf<<0) //3:0
  2942. +
  2943. +//U3D_B2_PHYD_TOP6
  2944. +#define RG_SSUSB_G2_CDR_BIC_LTR (0xf<<28) //31:28
  2945. +#define RG_SSUSB_G2_CDR_BIC_LTD0 (0xf<<24) //27:24
  2946. +#define RG_SSUSB_G2_CDR_BC_LTD1 (0x1f<<16) //20:16
  2947. +#define RG_SSUSB_G2_CDR_BC_LTR (0x1f<<8) //12:8
  2948. +#define RG_SSUSB_G2_CDR_BC_LTD0 (0x1f<<0) //4:0
  2949. +
  2950. +//U3D_B2_PHYD_TOP7
  2951. +#define RG_SSUSB_G2_CDR_BIR_LTD1 (0x1f<<24) //28:24
  2952. +#define RG_SSUSB_G2_CDR_BIR_LTR (0x1f<<16) //20:16
  2953. +#define RG_SSUSB_G2_CDR_BIR_LTD0 (0x1f<<8) //12:8
  2954. +#define RG_SSUSB_G2_CDR_BIC_LTD1 (0xf<<0) //3:0
  2955. +
  2956. +//U3D_B2_PHYD_P_SIGDET1
  2957. +#define RG_SSUSB_P_SIGDET_FLT_DIS (0x1<<31) //31:31
  2958. +#define RG_SSUSB_P_SIGDET_FLT_G2_DEAST_SEL (0x7f<<24) //30:24
  2959. +#define RG_SSUSB_P_SIGDET_FLT_G1_DEAST_SEL (0x7f<<16) //22:16
  2960. +#define RG_SSUSB_P_SIGDET_FLT_P2_AST_SEL (0x7f<<8) //14:8
  2961. +#define RG_SSUSB_P_SIGDET_FLT_PX_AST_SEL (0x7f<<0) //6:0
  2962. +
  2963. +//U3D_B2_PHYD_P_SIGDET2
  2964. +#define RG_SSUSB_P_SIGDET_RX_VAL_S (0x1<<29) //29:29
  2965. +#define RG_SSUSB_P_SIGDET_L0S_DEAS_SEL (0x1<<28) //28:28
  2966. +#define RG_SSUSB_P_SIGDET_L0_EXIT_S (0x1<<27) //27:27
  2967. +#define RG_SSUSB_P_SIGDET_L0S_EXIT_T_S (0x3<<25) //26:25
  2968. +#define RG_SSUSB_P_SIGDET_L0S_EXIT_S (0x1<<24) //24:24
  2969. +#define RG_SSUSB_P_SIGDET_L0S_ENTRY_S (0x1<<16) //16:16
  2970. +#define RG_SSUSB_P_SIGDET_PRB_SEL (0x1<<10) //10:10
  2971. +#define RG_SSUSB_P_SIGDET_BK_SIG_T (0x3<<8) //9:8
  2972. +#define RG_SSUSB_P_SIGDET_P2_RXLFPS (0x1<<6) //6:6
  2973. +#define RG_SSUSB_P_SIGDET_NON_BK_AD (0x1<<5) //5:5
  2974. +#define RG_SSUSB_P_SIGDET_BK_B_RXEQ (0x1<<4) //4:4
  2975. +#define RG_SSUSB_P_SIGDET_G2_KO_SEL (0x3<<2) //3:2
  2976. +#define RG_SSUSB_P_SIGDET_G1_KO_SEL (0x3<<0) //1:0
  2977. +
  2978. +//U3D_B2_PHYD_P_SIGDET_CAL1
  2979. +#define RG_SSUSB_P_SIGDET_CAL_OFFSET (0x1f<<24) //28:24
  2980. +#define RG_SSUSB_P_FORCE_SIGDET_CAL_OFFSET (0x1<<16) //16:16
  2981. +#define RG_SSUSB_P_SIGDET_CAL_EN (0x1<<8) //8:8
  2982. +#define RG_SSUSB_P_FORCE_SIGDET_CAL_EN (0x1<<3) //3:3
  2983. +#define RG_SSUSB_P_SIGDET_FLT_EN (0x1<<2) //2:2
  2984. +#define RG_SSUSB_P_SIGDET_SAMPLE_PRD (0x1<<1) //1:1
  2985. +#define RG_SSUSB_P_SIGDET_REK (0x1<<0) //0:0
  2986. +
  2987. +//U3D_B2_PHYD_RXDET1
  2988. +#define RG_SSUSB_RXDET_PRB_SEL (0x1<<31) //31:31
  2989. +#define RG_SSUSB_FORCE_CMDET (0x1<<30) //30:30
  2990. +#define RG_SSUSB_RXDET_EN (0x1<<29) //29:29
  2991. +#define RG_SSUSB_FORCE_RXDET_EN (0x1<<28) //28:28
  2992. +#define RG_SSUSB_RXDET_K_TWICE (0x1<<27) //27:27
  2993. +#define RG_SSUSB_RXDET_STB3_SET (0x1ff<<18) //26:18
  2994. +#define RG_SSUSB_RXDET_STB2_SET (0x1ff<<9) //17:9
  2995. +#define RG_SSUSB_RXDET_STB1_SET (0x1ff<<0) //8:0
  2996. +
  2997. +//U3D_B2_PHYD_RXDET2
  2998. +#define RG_SSUSB_PHYD_TRAINDEC_FORCE_CGEN (0x1<<31) //31:31
  2999. +#define RG_SSUSB_PHYD_BERTLB_FORCE_CGEN (0x1<<30) //30:30
  3000. +#define RG_SSUSB_PHYD_T2RLB_FORCE_CGEN (0x1<<29) //29:29
  3001. +#define RG_SSUSB_PDN_T_SEL (0x3<<18) //19:18
  3002. +#define RG_SSUSB_RXDET_STB3_SET_P3 (0x1ff<<9) //17:9
  3003. +#define RG_SSUSB_RXDET_STB2_SET_P3 (0x1ff<<0) //8:0
  3004. +
  3005. +//U3D_B2_PHYD_MISC0
  3006. +#define RG_SSUSB_FORCE_PLL_DDS_HF_EN (0x1<<22) //22:22
  3007. +#define RG_SSUSB_PLL_DDS_HF_EN_MAN (0x1<<21) //21:21
  3008. +#define RG_SSUSB_RXLFPS_ENTXDRV (0x1<<20) //20:20
  3009. +#define RG_SSUSB_RX_FL_UNLOCKTH (0xf<<16) //19:16
  3010. +#define RG_SSUSB_LFPS_PSEL (0x1<<15) //15:15
  3011. +#define RG_SSUSB_RX_SIGDET_EN (0x1<<14) //14:14
  3012. +#define RG_SSUSB_RX_SIGDET_EN_SEL (0x1<<13) //13:13
  3013. +#define RG_SSUSB_RX_PI_CAL_EN (0x1<<12) //12:12
  3014. +#define RG_SSUSB_RX_PI_CAL_EN_SEL (0x1<<11) //11:11
  3015. +#define RG_SSUSB_P3_CLS_CK_SEL (0x1<<10) //10:10
  3016. +#define RG_SSUSB_T2RLB_PSEL (0x3<<8) //9:8
  3017. +#define RG_SSUSB_PPCTL_PSEL (0x7<<5) //7:5
  3018. +#define RG_SSUSB_PHYD_TX_DATA_INV (0x1<<4) //4:4
  3019. +#define RG_SSUSB_BERTLB_PSEL (0x3<<2) //3:2
  3020. +#define RG_SSUSB_RETRACK_DIS (0x1<<1) //1:1
  3021. +#define RG_SSUSB_PPERRCNT_CLR (0x1<<0) //0:0
  3022. +
  3023. +//U3D_B2_PHYD_MISC2
  3024. +#define RG_SSUSB_FRC_PLL_DDS_PREDIV2 (0x1<<31) //31:31
  3025. +#define RG_SSUSB_FRC_PLL_DDS_IADJ (0xf<<27) //30:27
  3026. +#define RG_SSUSB_P_SIGDET_125FILTER (0x1<<26) //26:26
  3027. +#define RG_SSUSB_P_SIGDET_RST_FILTER (0x1<<25) //25:25
  3028. +#define RG_SSUSB_P_SIGDET_EID_USE_RAW (0x1<<24) //24:24
  3029. +#define RG_SSUSB_P_SIGDET_LTD_USE_RAW (0x1<<23) //23:23
  3030. +#define RG_SSUSB_EIDLE_BF_RXDET (0x1<<22) //22:22
  3031. +#define RG_SSUSB_EIDLE_LP_STBCYC (0x1ff<<13) //21:13
  3032. +#define RG_SSUSB_TX_EIDLE_LP_POSTDLY (0x3f<<7) //12:7
  3033. +#define RG_SSUSB_TX_EIDLE_LP_PREDLY (0x3f<<1) //6:1
  3034. +#define RG_SSUSB_TX_EIDLE_LP_EN_ADV (0x1<<0) //0:0
  3035. +
  3036. +//U3D_B2_PHYD_MISC3
  3037. +#define RGS_SSUSB_DDS_CALIB_C_STATE (0x7<<16) //18:16
  3038. +#define RGS_SSUSB_PPERRCNT (0xffff<<0) //15:0
  3039. +
  3040. +//U3D_B2_ROSC_0
  3041. +#define RG_SSUSB_RING_OSC_CNTEND (0x1ff<<23) //31:23
  3042. +#define RG_SSUSB_XTAL_OSC_CNTEND (0x7f<<16) //22:16
  3043. +#define RG_SSUSB_RING_OSC_EN (0x1<<3) //3:3
  3044. +#define RG_SSUSB_RING_OSC_FORCE_EN (0x1<<2) //2:2
  3045. +#define RG_SSUSB_FRC_RING_BYPASS_DET (0x1<<1) //1:1
  3046. +#define RG_SSUSB_RING_BYPASS_DET (0x1<<0) //0:0
  3047. +
  3048. +//U3D_B2_ROSC_1
  3049. +#define RG_SSUSB_RING_OSC_FRC_P3 (0x1<<20) //20:20
  3050. +#define RG_SSUSB_RING_OSC_P3 (0x1<<19) //19:19
  3051. +#define RG_SSUSB_RING_OSC_FRC_RECAL (0x3<<17) //18:17
  3052. +#define RG_SSUSB_RING_OSC_RECAL (0x1<<16) //16:16
  3053. +#define RG_SSUSB_RING_OSC_SEL (0xff<<8) //15:8
  3054. +#define RG_SSUSB_RING_OSC_FRC_SEL (0x1<<0) //0:0
  3055. +
  3056. +//U3D_B2_ROSC_2
  3057. +#define RG_SSUSB_RING_DET_STRCYC2 (0xffff<<16) //31:16
  3058. +#define RG_SSUSB_RING_DET_STRCYC1 (0xffff<<0) //15:0
  3059. +
  3060. +//U3D_B2_ROSC_3
  3061. +#define RG_SSUSB_RING_DET_DETWIN1 (0xffff<<16) //31:16
  3062. +#define RG_SSUSB_RING_DET_STRCYC3 (0xffff<<0) //15:0
  3063. +
  3064. +//U3D_B2_ROSC_4
  3065. +#define RG_SSUSB_RING_DET_DETWIN3 (0xffff<<16) //31:16
  3066. +#define RG_SSUSB_RING_DET_DETWIN2 (0xffff<<0) //15:0
  3067. +
  3068. +//U3D_B2_ROSC_5
  3069. +#define RG_SSUSB_RING_DET_LBOND1 (0xffff<<16) //31:16
  3070. +#define RG_SSUSB_RING_DET_UBOND1 (0xffff<<0) //15:0
  3071. +
  3072. +//U3D_B2_ROSC_6
  3073. +#define RG_SSUSB_RING_DET_LBOND2 (0xffff<<16) //31:16
  3074. +#define RG_SSUSB_RING_DET_UBOND2 (0xffff<<0) //15:0
  3075. +
  3076. +//U3D_B2_ROSC_7
  3077. +#define RG_SSUSB_RING_DET_LBOND3 (0xffff<<16) //31:16
  3078. +#define RG_SSUSB_RING_DET_UBOND3 (0xffff<<0) //15:0
  3079. +
  3080. +//U3D_B2_ROSC_8
  3081. +#define RG_SSUSB_RING_RESERVE (0xffff<<16) //31:16
  3082. +#define RG_SSUSB_ROSC_PROB_SEL (0xf<<2) //5:2
  3083. +#define RG_SSUSB_RING_FREQMETER_EN (0x1<<1) //1:1
  3084. +#define RG_SSUSB_RING_DET_BPS_UBOND (0x1<<0) //0:0
  3085. +
  3086. +//U3D_B2_ROSC_9
  3087. +#define RGS_FM_RING_CNT (0xffff<<16) //31:16
  3088. +#define RGS_SSUSB_RING_OSC_STATE (0x3<<10) //11:10
  3089. +#define RGS_SSUSB_RING_OSC_STABLE (0x1<<9) //9:9
  3090. +#define RGS_SSUSB_RING_OSC_CAL_FAIL (0x1<<8) //8:8
  3091. +#define RGS_SSUSB_RING_OSC_CAL (0xff<<0) //7:0
  3092. +
  3093. +//U3D_B2_ROSC_A
  3094. +#define RGS_SSUSB_ROSC_PROB_OUT (0xff<<0) //7:0
  3095. +
  3096. +//U3D_PHYD_VERSION
  3097. +#define RGS_SSUSB_PHYD_VERSION (0xffffffff<<0) //31:0
  3098. +
  3099. +//U3D_PHYD_MODEL
  3100. +#define RGS_SSUSB_PHYD_MODEL (0xffffffff<<0) //31:0
  3101. +
  3102. +
  3103. +/* OFFSET */
  3104. +
  3105. +//U3D_B2_PHYD_TOP1
  3106. +#define RG_SSUSB_PCIE2_K_EMP_OFST (28)
  3107. +#define RG_SSUSB_PCIE2_K_FUL_OFST (24)
  3108. +#define RG_SSUSB_TX_EIDLE_LP_EN_OFST (17)
  3109. +#define RG_SSUSB_FORCE_TX_EIDLE_LP_EN_OFST (16)
  3110. +#define RG_SSUSB_SIGDET_EN_OFST (15)
  3111. +#define RG_SSUSB_FORCE_SIGDET_EN_OFST (14)
  3112. +#define RG_SSUSB_CLKRX_EN_OFST (13)
  3113. +#define RG_SSUSB_FORCE_CLKRX_EN_OFST (12)
  3114. +#define RG_SSUSB_CLKTX_EN_OFST (11)
  3115. +#define RG_SSUSB_FORCE_CLKTX_EN_OFST (10)
  3116. +#define RG_SSUSB_CLK_REQ_N_I_OFST (9)
  3117. +#define RG_SSUSB_FORCE_CLK_REQ_N_I_OFST (8)
  3118. +#define RG_SSUSB_RATE_OFST (6)
  3119. +#define RG_SSUSB_FORCE_RATE_OFST (5)
  3120. +#define RG_SSUSB_PCIE_MODE_SEL_OFST (4)
  3121. +#define RG_SSUSB_FORCE_PCIE_MODE_SEL_OFST (3)
  3122. +#define RG_SSUSB_PHY_MODE_OFST (1)
  3123. +#define RG_SSUSB_FORCE_PHY_MODE_OFST (0)
  3124. +
  3125. +//U3D_B2_PHYD_TOP2
  3126. +#define RG_SSUSB_FORCE_IDRV_6DB_OFST (30)
  3127. +#define RG_SSUSB_IDRV_6DB_OFST (24)
  3128. +#define RG_SSUSB_FORCE_IDEM_3P5DB_OFST (22)
  3129. +#define RG_SSUSB_IDEM_3P5DB_OFST (16)
  3130. +#define RG_SSUSB_FORCE_IDRV_3P5DB_OFST (14)
  3131. +#define RG_SSUSB_IDRV_3P5DB_OFST (8)
  3132. +#define RG_SSUSB_FORCE_IDRV_0DB_OFST (6)
  3133. +#define RG_SSUSB_IDRV_0DB_OFST (0)
  3134. +
  3135. +//U3D_B2_PHYD_TOP3
  3136. +#define RG_SSUSB_TX_BIASI_OFST (25)
  3137. +#define RG_SSUSB_FORCE_TX_BIASI_EN_OFST (24)
  3138. +#define RG_SSUSB_TX_BIASI_EN_OFST (16)
  3139. +#define RG_SSUSB_FORCE_TX_BIASI_OFST (13)
  3140. +#define RG_SSUSB_FORCE_IDEM_6DB_OFST (8)
  3141. +#define RG_SSUSB_IDEM_6DB_OFST (0)
  3142. +
  3143. +//U3D_B2_PHYD_TOP4
  3144. +#define RG_SSUSB_G1_CDR_BIC_LTR_OFST (28)
  3145. +#define RG_SSUSB_G1_CDR_BIC_LTD0_OFST (24)
  3146. +#define RG_SSUSB_G1_CDR_BC_LTD1_OFST (16)
  3147. +#define RG_SSUSB_G1_CDR_BC_LTR_OFST (8)
  3148. +#define RG_SSUSB_G1_CDR_BC_LTD0_OFST (0)
  3149. +
  3150. +//U3D_B2_PHYD_TOP5
  3151. +#define RG_SSUSB_G1_CDR_BIR_LTD1_OFST (24)
  3152. +#define RG_SSUSB_G1_CDR_BIR_LTR_OFST (16)
  3153. +#define RG_SSUSB_G1_CDR_BIR_LTD0_OFST (8)
  3154. +#define RG_SSUSB_G1_CDR_BIC_LTD1_OFST (0)
  3155. +
  3156. +//U3D_B2_PHYD_TOP6
  3157. +#define RG_SSUSB_G2_CDR_BIC_LTR_OFST (28)
  3158. +#define RG_SSUSB_G2_CDR_BIC_LTD0_OFST (24)
  3159. +#define RG_SSUSB_G2_CDR_BC_LTD1_OFST (16)
  3160. +#define RG_SSUSB_G2_CDR_BC_LTR_OFST (8)
  3161. +#define RG_SSUSB_G2_CDR_BC_LTD0_OFST (0)
  3162. +
  3163. +//U3D_B2_PHYD_TOP7
  3164. +#define RG_SSUSB_G2_CDR_BIR_LTD1_OFST (24)
  3165. +#define RG_SSUSB_G2_CDR_BIR_LTR_OFST (16)
  3166. +#define RG_SSUSB_G2_CDR_BIR_LTD0_OFST (8)
  3167. +#define RG_SSUSB_G2_CDR_BIC_LTD1_OFST (0)
  3168. +
  3169. +//U3D_B2_PHYD_P_SIGDET1
  3170. +#define RG_SSUSB_P_SIGDET_FLT_DIS_OFST (31)
  3171. +#define RG_SSUSB_P_SIGDET_FLT_G2_DEAST_SEL_OFST (24)
  3172. +#define RG_SSUSB_P_SIGDET_FLT_G1_DEAST_SEL_OFST (16)
  3173. +#define RG_SSUSB_P_SIGDET_FLT_P2_AST_SEL_OFST (8)
  3174. +#define RG_SSUSB_P_SIGDET_FLT_PX_AST_SEL_OFST (0)
  3175. +
  3176. +//U3D_B2_PHYD_P_SIGDET2
  3177. +#define RG_SSUSB_P_SIGDET_RX_VAL_S_OFST (29)
  3178. +#define RG_SSUSB_P_SIGDET_L0S_DEAS_SEL_OFST (28)
  3179. +#define RG_SSUSB_P_SIGDET_L0_EXIT_S_OFST (27)
  3180. +#define RG_SSUSB_P_SIGDET_L0S_EXIT_T_S_OFST (25)
  3181. +#define RG_SSUSB_P_SIGDET_L0S_EXIT_S_OFST (24)
  3182. +#define RG_SSUSB_P_SIGDET_L0S_ENTRY_S_OFST (16)
  3183. +#define RG_SSUSB_P_SIGDET_PRB_SEL_OFST (10)
  3184. +#define RG_SSUSB_P_SIGDET_BK_SIG_T_OFST (8)
  3185. +#define RG_SSUSB_P_SIGDET_P2_RXLFPS_OFST (6)
  3186. +#define RG_SSUSB_P_SIGDET_NON_BK_AD_OFST (5)
  3187. +#define RG_SSUSB_P_SIGDET_BK_B_RXEQ_OFST (4)
  3188. +#define RG_SSUSB_P_SIGDET_G2_KO_SEL_OFST (2)
  3189. +#define RG_SSUSB_P_SIGDET_G1_KO_SEL_OFST (0)
  3190. +
  3191. +//U3D_B2_PHYD_P_SIGDET_CAL1
  3192. +#define RG_SSUSB_P_SIGDET_CAL_OFFSET_OFST (24)
  3193. +#define RG_SSUSB_P_FORCE_SIGDET_CAL_OFFSET_OFST (16)
  3194. +#define RG_SSUSB_P_SIGDET_CAL_EN_OFST (8)
  3195. +#define RG_SSUSB_P_FORCE_SIGDET_CAL_EN_OFST (3)
  3196. +#define RG_SSUSB_P_SIGDET_FLT_EN_OFST (2)
  3197. +#define RG_SSUSB_P_SIGDET_SAMPLE_PRD_OFST (1)
  3198. +#define RG_SSUSB_P_SIGDET_REK_OFST (0)
  3199. +
  3200. +//U3D_B2_PHYD_RXDET1
  3201. +#define RG_SSUSB_RXDET_PRB_SEL_OFST (31)
  3202. +#define RG_SSUSB_FORCE_CMDET_OFST (30)
  3203. +#define RG_SSUSB_RXDET_EN_OFST (29)
  3204. +#define RG_SSUSB_FORCE_RXDET_EN_OFST (28)
  3205. +#define RG_SSUSB_RXDET_K_TWICE_OFST (27)
  3206. +#define RG_SSUSB_RXDET_STB3_SET_OFST (18)
  3207. +#define RG_SSUSB_RXDET_STB2_SET_OFST (9)
  3208. +#define RG_SSUSB_RXDET_STB1_SET_OFST (0)
  3209. +
  3210. +//U3D_B2_PHYD_RXDET2
  3211. +#define RG_SSUSB_PHYD_TRAINDEC_FORCE_CGEN_OFST (31)
  3212. +#define RG_SSUSB_PHYD_BERTLB_FORCE_CGEN_OFST (30)
  3213. +#define RG_SSUSB_PHYD_T2RLB_FORCE_CGEN_OFST (29)
  3214. +#define RG_SSUSB_PDN_T_SEL_OFST (18)
  3215. +#define RG_SSUSB_RXDET_STB3_SET_P3_OFST (9)
  3216. +#define RG_SSUSB_RXDET_STB2_SET_P3_OFST (0)
  3217. +
  3218. +//U3D_B2_PHYD_MISC0
  3219. +#define RG_SSUSB_FORCE_PLL_DDS_HF_EN_OFST (22)
  3220. +#define RG_SSUSB_PLL_DDS_HF_EN_MAN_OFST (21)
  3221. +#define RG_SSUSB_RXLFPS_ENTXDRV_OFST (20)
  3222. +#define RG_SSUSB_RX_FL_UNLOCKTH_OFST (16)
  3223. +#define RG_SSUSB_LFPS_PSEL_OFST (15)
  3224. +#define RG_SSUSB_RX_SIGDET_EN_OFST (14)
  3225. +#define RG_SSUSB_RX_SIGDET_EN_SEL_OFST (13)
  3226. +#define RG_SSUSB_RX_PI_CAL_EN_OFST (12)
  3227. +#define RG_SSUSB_RX_PI_CAL_EN_SEL_OFST (11)
  3228. +#define RG_SSUSB_P3_CLS_CK_SEL_OFST (10)
  3229. +#define RG_SSUSB_T2RLB_PSEL_OFST (8)
  3230. +#define RG_SSUSB_PPCTL_PSEL_OFST (5)
  3231. +#define RG_SSUSB_PHYD_TX_DATA_INV_OFST (4)
  3232. +#define RG_SSUSB_BERTLB_PSEL_OFST (2)
  3233. +#define RG_SSUSB_RETRACK_DIS_OFST (1)
  3234. +#define RG_SSUSB_PPERRCNT_CLR_OFST (0)
  3235. +
  3236. +//U3D_B2_PHYD_MISC2
  3237. +#define RG_SSUSB_FRC_PLL_DDS_PREDIV2_OFST (31)
  3238. +#define RG_SSUSB_FRC_PLL_DDS_IADJ_OFST (27)
  3239. +#define RG_SSUSB_P_SIGDET_125FILTER_OFST (26)
  3240. +#define RG_SSUSB_P_SIGDET_RST_FILTER_OFST (25)
  3241. +#define RG_SSUSB_P_SIGDET_EID_USE_RAW_OFST (24)
  3242. +#define RG_SSUSB_P_SIGDET_LTD_USE_RAW_OFST (23)
  3243. +#define RG_SSUSB_EIDLE_BF_RXDET_OFST (22)
  3244. +#define RG_SSUSB_EIDLE_LP_STBCYC_OFST (13)
  3245. +#define RG_SSUSB_TX_EIDLE_LP_POSTDLY_OFST (7)
  3246. +#define RG_SSUSB_TX_EIDLE_LP_PREDLY_OFST (1)
  3247. +#define RG_SSUSB_TX_EIDLE_LP_EN_ADV_OFST (0)
  3248. +
  3249. +//U3D_B2_PHYD_MISC3
  3250. +#define RGS_SSUSB_DDS_CALIB_C_STATE_OFST (16)
  3251. +#define RGS_SSUSB_PPERRCNT_OFST (0)
  3252. +
  3253. +//U3D_B2_ROSC_0
  3254. +#define RG_SSUSB_RING_OSC_CNTEND_OFST (23)
  3255. +#define RG_SSUSB_XTAL_OSC_CNTEND_OFST (16)
  3256. +#define RG_SSUSB_RING_OSC_EN_OFST (3)
  3257. +#define RG_SSUSB_RING_OSC_FORCE_EN_OFST (2)
  3258. +#define RG_SSUSB_FRC_RING_BYPASS_DET_OFST (1)
  3259. +#define RG_SSUSB_RING_BYPASS_DET_OFST (0)
  3260. +
  3261. +//U3D_B2_ROSC_1
  3262. +#define RG_SSUSB_RING_OSC_FRC_P3_OFST (20)
  3263. +#define RG_SSUSB_RING_OSC_P3_OFST (19)
  3264. +#define RG_SSUSB_RING_OSC_FRC_RECAL_OFST (17)
  3265. +#define RG_SSUSB_RING_OSC_RECAL_OFST (16)
  3266. +#define RG_SSUSB_RING_OSC_SEL_OFST (8)
  3267. +#define RG_SSUSB_RING_OSC_FRC_SEL_OFST (0)
  3268. +
  3269. +//U3D_B2_ROSC_2
  3270. +#define RG_SSUSB_RING_DET_STRCYC2_OFST (16)
  3271. +#define RG_SSUSB_RING_DET_STRCYC1_OFST (0)
  3272. +
  3273. +//U3D_B2_ROSC_3
  3274. +#define RG_SSUSB_RING_DET_DETWIN1_OFST (16)
  3275. +#define RG_SSUSB_RING_DET_STRCYC3_OFST (0)
  3276. +
  3277. +//U3D_B2_ROSC_4
  3278. +#define RG_SSUSB_RING_DET_DETWIN3_OFST (16)
  3279. +#define RG_SSUSB_RING_DET_DETWIN2_OFST (0)
  3280. +
  3281. +//U3D_B2_ROSC_5
  3282. +#define RG_SSUSB_RING_DET_LBOND1_OFST (16)
  3283. +#define RG_SSUSB_RING_DET_UBOND1_OFST (0)
  3284. +
  3285. +//U3D_B2_ROSC_6
  3286. +#define RG_SSUSB_RING_DET_LBOND2_OFST (16)
  3287. +#define RG_SSUSB_RING_DET_UBOND2_OFST (0)
  3288. +
  3289. +//U3D_B2_ROSC_7
  3290. +#define RG_SSUSB_RING_DET_LBOND3_OFST (16)
  3291. +#define RG_SSUSB_RING_DET_UBOND3_OFST (0)
  3292. +
  3293. +//U3D_B2_ROSC_8
  3294. +#define RG_SSUSB_RING_RESERVE_OFST (16)
  3295. +#define RG_SSUSB_ROSC_PROB_SEL_OFST (2)
  3296. +#define RG_SSUSB_RING_FREQMETER_EN_OFST (1)
  3297. +#define RG_SSUSB_RING_DET_BPS_UBOND_OFST (0)
  3298. +
  3299. +//U3D_B2_ROSC_9
  3300. +#define RGS_FM_RING_CNT_OFST (16)
  3301. +#define RGS_SSUSB_RING_OSC_STATE_OFST (10)
  3302. +#define RGS_SSUSB_RING_OSC_STABLE_OFST (9)
  3303. +#define RGS_SSUSB_RING_OSC_CAL_FAIL_OFST (8)
  3304. +#define RGS_SSUSB_RING_OSC_CAL_OFST (0)
  3305. +
  3306. +//U3D_B2_ROSC_A
  3307. +#define RGS_SSUSB_ROSC_PROB_OUT_OFST (0)
  3308. +
  3309. +//U3D_PHYD_VERSION
  3310. +#define RGS_SSUSB_PHYD_VERSION_OFST (0)
  3311. +
  3312. +//U3D_PHYD_MODEL
  3313. +#define RGS_SSUSB_PHYD_MODEL_OFST (0)
  3314. +
  3315. +
  3316. +///////////////////////////////////////////////////////////////////////////////
  3317. +
  3318. +struct sifslv_chip_reg {
  3319. + PHY_LE32 xtalbias;
  3320. + PHY_LE32 syspll1;
  3321. + PHY_LE32 gpio_ctla;
  3322. + PHY_LE32 gpio_ctlb;
  3323. + PHY_LE32 gpio_ctlc;
  3324. +};
  3325. +
  3326. +//U3D_GPIO_CTLA
  3327. +#define RG_C60802_GPIO_CTLA (0xffffffff<<0) //31:0
  3328. +
  3329. +//U3D_GPIO_CTLB
  3330. +#define RG_C60802_GPIO_CTLB (0xffffffff<<0) //31:0
  3331. +
  3332. +//U3D_GPIO_CTLC
  3333. +#define RG_C60802_GPIO_CTLC (0xffffffff<<0) //31:0
  3334. +
  3335. +/* OFFSET */
  3336. +
  3337. +//U3D_GPIO_CTLA
  3338. +#define RG_C60802_GPIO_CTLA_OFST (0)
  3339. +
  3340. +//U3D_GPIO_CTLB
  3341. +#define RG_C60802_GPIO_CTLB_OFST (0)
  3342. +
  3343. +//U3D_GPIO_CTLC
  3344. +#define RG_C60802_GPIO_CTLC_OFST (0)
  3345. +
  3346. +///////////////////////////////////////////////////////////////////////////////
  3347. +
  3348. +struct sifslv_fm_feg {
  3349. + //0x0
  3350. + PHY_LE32 fmcr0;
  3351. + PHY_LE32 fmcr1;
  3352. + PHY_LE32 fmcr2;
  3353. + PHY_LE32 fmmonr0;
  3354. + //0x10
  3355. + PHY_LE32 fmmonr1;
  3356. +};
  3357. +
  3358. +//U3D_FMCR0
  3359. +#define RG_LOCKTH (0xf<<28) //31:28
  3360. +#define RG_MONCLK_SEL (0x3<<26) //27:26
  3361. +#define RG_FM_MODE (0x1<<25) //25:25
  3362. +#define RG_FREQDET_EN (0x1<<24) //24:24
  3363. +#define RG_CYCLECNT (0xffffff<<0) //23:0
  3364. +
  3365. +//U3D_FMCR1
  3366. +#define RG_TARGET (0xffffffff<<0) //31:0
  3367. +
  3368. +//U3D_FMCR2
  3369. +#define RG_OFFSET (0xffffffff<<0) //31:0
  3370. +
  3371. +//U3D_FMMONR0
  3372. +#define USB_FM_OUT (0xffffffff<<0) //31:0
  3373. +
  3374. +//U3D_FMMONR1
  3375. +#define RG_MONCLK_SEL_3 (0x1<<9) //9:9
  3376. +#define RG_FRCK_EN (0x1<<8) //8:8
  3377. +#define USBPLL_LOCK (0x1<<1) //1:1
  3378. +#define USB_FM_VLD (0x1<<0) //0:0
  3379. +
  3380. +
  3381. +/* OFFSET */
  3382. +
  3383. +//U3D_FMCR0
  3384. +#define RG_LOCKTH_OFST (28)
  3385. +#define RG_MONCLK_SEL_OFST (26)
  3386. +#define RG_FM_MODE_OFST (25)
  3387. +#define RG_FREQDET_EN_OFST (24)
  3388. +#define RG_CYCLECNT_OFST (0)
  3389. +
  3390. +//U3D_FMCR1
  3391. +#define RG_TARGET_OFST (0)
  3392. +
  3393. +//U3D_FMCR2
  3394. +#define RG_OFFSET_OFST (0)
  3395. +
  3396. +//U3D_FMMONR0
  3397. +#define USB_FM_OUT_OFST (0)
  3398. +
  3399. +//U3D_FMMONR1
  3400. +#define RG_MONCLK_SEL_3_OFST (9)
  3401. +#define RG_FRCK_EN_OFST (8)
  3402. +#define USBPLL_LOCK_OFST (1)
  3403. +#define USB_FM_VLD_OFST (0)
  3404. +
  3405. +
  3406. +///////////////////////////////////////////////////////////////////////////////
  3407. +
  3408. +PHY_INT32 phy_init(struct u3phy_info *info);
  3409. +PHY_INT32 phy_change_pipe_phase(struct u3phy_info *info, PHY_INT32 phy_drv, PHY_INT32 pipe_phase);
  3410. +PHY_INT32 eyescan_init(struct u3phy_info *info);
  3411. +PHY_INT32 phy_eyescan(struct u3phy_info *info, PHY_INT32 x_t1, PHY_INT32 y_t1, PHY_INT32 x_br, PHY_INT32 y_br, PHY_INT32 delta_x, PHY_INT32 delta_y
  3412. + , PHY_INT32 eye_cnt, PHY_INT32 num_cnt, PHY_INT32 PI_cal_en, PHY_INT32 num_ignore_cnt);
  3413. +PHY_INT32 u2_save_cur_en(struct u3phy_info *info);
  3414. +PHY_INT32 u2_save_cur_re(struct u3phy_info *info);
  3415. +PHY_INT32 u2_slew_rate_calibration(struct u3phy_info *info);
  3416. +
  3417. +#endif
  3418. +#endif
  3419. --- /dev/null
  3420. +++ b/drivers/usb/host/mtk-phy-ahb.c
  3421. @@ -0,0 +1,58 @@
  3422. +#include "mtk-phy.h"
  3423. +#ifdef CONFIG_U3D_HAL_SUPPORT
  3424. +#include "mu3d_hal_osal.h"
  3425. +#endif
  3426. +
  3427. +#ifdef CONFIG_U3_PHY_AHB_SUPPORT
  3428. +#include <linux/gfp.h>
  3429. +#include <linux/kernel.h>
  3430. +#include <linux/slab.h>
  3431. +
  3432. +#ifndef CONFIG_U3D_HAL_SUPPORT
  3433. +#define os_writel(addr,data) {\
  3434. + (*((volatile PHY_UINT32*)(addr)) = data);\
  3435. + }
  3436. +#define os_readl(addr) *((volatile PHY_UINT32*)(addr))
  3437. +#define os_writelmsk(addr, data, msk) \
  3438. + { os_writel(addr, ((os_readl(addr) & ~(msk)) | ((data) & (msk)))); \
  3439. + }
  3440. +#define os_setmsk(addr, msk) \
  3441. + { os_writel(addr, os_readl(addr) | msk); \
  3442. + }
  3443. +#define os_clrmsk(addr, msk) \
  3444. + { os_writel(addr, os_readl(addr) &~ msk); \
  3445. + }
  3446. +/*msk the data first, then umsk with the umsk.*/
  3447. +#define os_writelmskumsk(addr, data, msk, umsk) \
  3448. +{\
  3449. + os_writel(addr, ((os_readl(addr) & ~(msk)) | ((data) & (msk))) & (umsk));\
  3450. +}
  3451. +
  3452. +#endif
  3453. +
  3454. +PHY_INT32 U3PhyWriteReg32(PHY_UINT32 addr, PHY_UINT32 data)
  3455. +{
  3456. + os_writel(addr, data);
  3457. +
  3458. + return 0;
  3459. +}
  3460. +
  3461. +PHY_INT32 U3PhyReadReg32(PHY_UINT32 addr)
  3462. +{
  3463. + return os_readl(addr);
  3464. +}
  3465. +
  3466. +PHY_INT32 U3PhyWriteReg8(PHY_UINT32 addr, PHY_UINT8 data)
  3467. +{
  3468. + os_writelmsk(addr&0xfffffffc, data<<((addr%4)*8), 0xff<<((addr%4)*8));
  3469. +
  3470. + return 0;
  3471. +}
  3472. +
  3473. +PHY_INT8 U3PhyReadReg8(PHY_UINT32 addr)
  3474. +{
  3475. + return ((os_readl(addr)>>((addr%4)*8))&0xff);
  3476. +}
  3477. +
  3478. +#endif
  3479. +
  3480. --- /dev/null
  3481. +++ b/drivers/usb/host/mtk-phy.c
  3482. @@ -0,0 +1,102 @@
  3483. +#include <linux/gfp.h>
  3484. +#include <linux/kernel.h>
  3485. +#include <linux/slab.h>
  3486. +#define U3_PHY_LIB
  3487. +#include "mtk-phy.h"
  3488. +#ifdef CONFIG_PROJECT_7621
  3489. +#include "mtk-phy-7621.h"
  3490. +#endif
  3491. +#ifdef CONFIG_PROJECT_PHY
  3492. +static struct u3phy_operator project_operators = {
  3493. + .init = phy_init,
  3494. + .change_pipe_phase = phy_change_pipe_phase,
  3495. + .eyescan_init = eyescan_init,
  3496. + .eyescan = phy_eyescan,
  3497. + .u2_slew_rate_calibration = u2_slew_rate_calibration,
  3498. +};
  3499. +#endif
  3500. +
  3501. +
  3502. +PHY_INT32 u3phy_init(){
  3503. +#ifndef CONFIG_PROJECT_PHY
  3504. + PHY_INT32 u3phy_version;
  3505. +#endif
  3506. +
  3507. + if(u3phy != NULL){
  3508. + return PHY_TRUE;
  3509. + }
  3510. +
  3511. + u3phy = kmalloc(sizeof(struct u3phy_info), GFP_NOIO);
  3512. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  3513. + u3phy_p1 = kmalloc(sizeof(struct u3phy_info), GFP_NOIO);
  3514. +#endif
  3515. +#ifdef CONFIG_U3_PHY_GPIO_SUPPORT
  3516. + u3phy->phyd_version_addr = 0x2000e4;
  3517. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  3518. + u3phy_p1->phyd_version_addr = 0x2000e4;
  3519. +#endif
  3520. +#else
  3521. + u3phy->phyd_version_addr = U3_PHYD_B2_BASE + 0xe4;
  3522. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  3523. + u3phy_p1->phyd_version_addr = U3_PHYD_B2_BASE_P1 + 0xe4;
  3524. +#endif
  3525. +#endif
  3526. +
  3527. +#ifdef CONFIG_PROJECT_PHY
  3528. +
  3529. + u3phy->u2phy_regs = (struct u2phy_reg *)U2_PHY_BASE;
  3530. + u3phy->u3phyd_regs = (struct u3phyd_reg *)U3_PHYD_BASE;
  3531. + u3phy->u3phyd_bank2_regs = (struct u3phyd_bank2_reg *)U3_PHYD_B2_BASE;
  3532. + u3phy->u3phya_regs = (struct u3phya_reg *)U3_PHYA_BASE;
  3533. + u3phy->u3phya_da_regs = (struct u3phya_da_reg *)U3_PHYA_DA_BASE;
  3534. + u3phy->sifslv_chip_regs = (struct sifslv_chip_reg *)SIFSLV_CHIP_BASE;
  3535. + u3phy->sifslv_fm_regs = (struct sifslv_fm_feg *)SIFSLV_FM_FEG_BASE;
  3536. + u3phy_ops = &project_operators;
  3537. +
  3538. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  3539. + u3phy_p1->u2phy_regs = (struct u2phy_reg *)U2_PHY_BASE_P1;
  3540. + u3phy_p1->u3phyd_regs = (struct u3phyd_reg *)U3_PHYD_BASE_P1;
  3541. + u3phy_p1->u3phyd_bank2_regs = (struct u3phyd_bank2_reg *)U3_PHYD_B2_BASE_P1;
  3542. + u3phy_p1->u3phya_regs = (struct u3phya_reg *)U3_PHYA_BASE_P1;
  3543. + u3phy_p1->u3phya_da_regs = (struct u3phya_da_reg *)U3_PHYA_DA_BASE_P1;
  3544. + u3phy_p1->sifslv_chip_regs = (struct sifslv_chip_reg *)SIFSLV_CHIP_BASE;
  3545. + u3phy_p1->sifslv_fm_regs = (struct sifslv_fm_feg *)SIFSLV_FM_FEG_BASE;
  3546. +#endif
  3547. +#endif
  3548. +
  3549. + return PHY_TRUE;
  3550. +}
  3551. +
  3552. +PHY_INT32 U3PhyWriteField8(PHY_INT32 addr, PHY_INT32 offset, PHY_INT32 mask, PHY_INT32 value){
  3553. + PHY_INT8 cur_value;
  3554. + PHY_INT8 new_value;
  3555. +
  3556. + cur_value = U3PhyReadReg8(addr);
  3557. + new_value = (cur_value & (~mask)) | (value << offset);
  3558. + //udelay(i2cdelayus);
  3559. + U3PhyWriteReg8(addr, new_value);
  3560. + return PHY_TRUE;
  3561. +}
  3562. +
  3563. +PHY_INT32 U3PhyWriteField32(PHY_INT32 addr, PHY_INT32 offset, PHY_INT32 mask, PHY_INT32 value){
  3564. + PHY_INT32 cur_value;
  3565. + PHY_INT32 new_value;
  3566. +
  3567. + cur_value = U3PhyReadReg32(addr);
  3568. + new_value = (cur_value & (~mask)) | ((value << offset) & mask);
  3569. + U3PhyWriteReg32(addr, new_value);
  3570. + //DRV_MDELAY(100);
  3571. +
  3572. + return PHY_TRUE;
  3573. +}
  3574. +
  3575. +PHY_INT32 U3PhyReadField8(PHY_INT32 addr,PHY_INT32 offset,PHY_INT32 mask){
  3576. +
  3577. + return ((U3PhyReadReg8(addr) & mask) >> offset);
  3578. +}
  3579. +
  3580. +PHY_INT32 U3PhyReadField32(PHY_INT32 addr, PHY_INT32 offset, PHY_INT32 mask){
  3581. +
  3582. + return ((U3PhyReadReg32(addr) & mask) >> offset);
  3583. +}
  3584. +
  3585. --- /dev/null
  3586. +++ b/drivers/usb/host/mtk-phy.h
  3587. @@ -0,0 +1,179 @@
  3588. +#ifndef __MTK_PHY_NEW_H
  3589. +#define __MTK_PHY_NEW_H
  3590. +
  3591. +//#define CONFIG_U3D_HAL_SUPPORT
  3592. +
  3593. +/* include system library */
  3594. +#include <linux/gfp.h>
  3595. +#include <linux/kernel.h>
  3596. +#include <linux/slab.h>
  3597. +#include <linux/delay.h>
  3598. +
  3599. +/* Choose PHY R/W implementation */
  3600. +//#define CONFIG_U3_PHY_GPIO_SUPPORT //SW I2C implemented by GPIO
  3601. +#define CONFIG_U3_PHY_AHB_SUPPORT //AHB, only on SoC
  3602. +
  3603. +/* Choose PHY version */
  3604. +//Select your project by defining one of the followings
  3605. +#define CONFIG_PROJECT_7621 //7621
  3606. +#define CONFIG_PROJECT_PHY
  3607. +
  3608. +/* BASE ADDRESS DEFINE, should define this on ASIC */
  3609. +#define PHY_BASE 0xBE1D0000
  3610. +#define SIFSLV_FM_FEG_BASE (PHY_BASE+0x100)
  3611. +#define SIFSLV_CHIP_BASE (PHY_BASE+0x700)
  3612. +#define U2_PHY_BASE (PHY_BASE+0x800)
  3613. +#define U3_PHYD_BASE (PHY_BASE+0x900)
  3614. +#define U3_PHYD_B2_BASE (PHY_BASE+0xa00)
  3615. +#define U3_PHYA_BASE (PHY_BASE+0xb00)
  3616. +#define U3_PHYA_DA_BASE (PHY_BASE+0xc00)
  3617. +
  3618. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  3619. +#define SIFSLV_FM_FEG_BASE_P1 (PHY_BASE+0x100)
  3620. +#define SIFSLV_CHIP_BASE_P1 (PHY_BASE+0x700)
  3621. +#define U2_PHY_BASE_P1 (PHY_BASE+0x1000)
  3622. +#define U3_PHYD_BASE_P1 (PHY_BASE+0x1100)
  3623. +#define U3_PHYD_B2_BASE_P1 (PHY_BASE+0x1200)
  3624. +#define U3_PHYA_BASE_P1 (PHY_BASE+0x1300)
  3625. +#define U3_PHYA_DA_BASE_P1 (PHY_BASE+0x1400)
  3626. +#endif
  3627. +
  3628. +/*
  3629. +
  3630. +0x00000100 MODULE ssusb_sifslv_fmreg ssusb_sifslv_fmreg
  3631. +0x00000700 MODULE ssusb_sifslv_ippc ssusb_sifslv_ippc
  3632. +0x00000800 MODULE ssusb_sifslv_u2phy_com ssusb_sifslv_u2_phy_com_T28
  3633. +0x00000900 MODULE ssusb_sifslv_u3phyd ssusb_sifslv_u3phyd_T28
  3634. +0x00000a00 MODULE ssusb_sifslv_u3phyd_bank2 ssusb_sifslv_u3phyd_bank2_T28
  3635. +0x00000b00 MODULE ssusb_sifslv_u3phya ssusb_sifslv_u3phya_T28
  3636. +0x00000c00 MODULE ssusb_sifslv_u3phya_da ssusb_sifslv_u3phya_da_T28
  3637. +*/
  3638. +
  3639. +
  3640. +/* TYPE DEFINE */
  3641. +typedef unsigned int PHY_UINT32;
  3642. +typedef int PHY_INT32;
  3643. +typedef unsigned short PHY_UINT16;
  3644. +typedef short PHY_INT16;
  3645. +typedef unsigned char PHY_UINT8;
  3646. +typedef char PHY_INT8;
  3647. +
  3648. +typedef PHY_UINT32 __bitwise PHY_LE32;
  3649. +
  3650. +/* CONSTANT DEFINE */
  3651. +#define PHY_FALSE 0
  3652. +#define PHY_TRUE 1
  3653. +
  3654. +/* MACRO DEFINE */
  3655. +#define DRV_WriteReg32(addr,data) ((*(volatile PHY_UINT32 *)(addr)) = (unsigned long)(data))
  3656. +#define DRV_Reg32(addr) (*(volatile PHY_UINT32 *)(addr))
  3657. +
  3658. +#define DRV_MDELAY mdelay
  3659. +#define DRV_MSLEEP msleep
  3660. +#define DRV_UDELAY udelay
  3661. +#define DRV_USLEEP usleep
  3662. +
  3663. +/* PHY FUNCTION DEFINE, implemented in platform files, ex. ahb, gpio */
  3664. +PHY_INT32 U3PhyWriteReg32(PHY_UINT32 addr, PHY_UINT32 data);
  3665. +PHY_INT32 U3PhyReadReg32(PHY_UINT32 addr);
  3666. +PHY_INT32 U3PhyWriteReg8(PHY_UINT32 addr, PHY_UINT8 data);
  3667. +PHY_INT8 U3PhyReadReg8(PHY_UINT32 addr);
  3668. +
  3669. +/* PHY GENERAL USAGE FUNC, implemented in mtk-phy.c */
  3670. +PHY_INT32 U3PhyWriteField8(PHY_INT32 addr, PHY_INT32 offset, PHY_INT32 mask, PHY_INT32 value);
  3671. +PHY_INT32 U3PhyWriteField32(PHY_INT32 addr, PHY_INT32 offset, PHY_INT32 mask, PHY_INT32 value);
  3672. +PHY_INT32 U3PhyReadField8(PHY_INT32 addr, PHY_INT32 offset, PHY_INT32 mask);
  3673. +PHY_INT32 U3PhyReadField32(PHY_INT32 addr, PHY_INT32 offset, PHY_INT32 mask);
  3674. +
  3675. +struct u3phy_info {
  3676. + PHY_INT32 phy_version;
  3677. + PHY_INT32 phyd_version_addr;
  3678. +
  3679. +#ifdef CONFIG_PROJECT_PHY
  3680. + struct u2phy_reg *u2phy_regs;
  3681. + struct u3phya_reg *u3phya_regs;
  3682. + struct u3phya_da_reg *u3phya_da_regs;
  3683. + struct u3phyd_reg *u3phyd_regs;
  3684. + struct u3phyd_bank2_reg *u3phyd_bank2_regs;
  3685. + struct sifslv_chip_reg *sifslv_chip_regs;
  3686. + struct sifslv_fm_feg *sifslv_fm_regs;
  3687. +#endif
  3688. +};
  3689. +
  3690. +struct u3phy_operator {
  3691. + PHY_INT32 (*init) (struct u3phy_info *info);
  3692. + PHY_INT32 (*change_pipe_phase) (struct u3phy_info *info, PHY_INT32 phy_drv, PHY_INT32 pipe_phase);
  3693. + PHY_INT32 (*eyescan_init) (struct u3phy_info *info);
  3694. + PHY_INT32 (*eyescan) (struct u3phy_info *info, PHY_INT32 x_t1, PHY_INT32 y_t1, PHY_INT32 x_br, PHY_INT32 y_br, PHY_INT32 delta_x, PHY_INT32 delta_y, PHY_INT32 eye_cnt, PHY_INT32 num_cnt, PHY_INT32 PI_cal_en, PHY_INT32 num_ignore_cnt);
  3695. + PHY_INT32 (*u2_save_current_entry) (struct u3phy_info *info);
  3696. + PHY_INT32 (*u2_save_current_recovery) (struct u3phy_info *info);
  3697. + PHY_INT32 (*u2_slew_rate_calibration) (struct u3phy_info *info);
  3698. +};
  3699. +
  3700. +#ifdef U3_PHY_LIB
  3701. +#define AUTOEXT
  3702. +#else
  3703. +#define AUTOEXT extern
  3704. +#endif
  3705. +
  3706. +AUTOEXT struct u3phy_info *u3phy;
  3707. +AUTOEXT struct u3phy_info *u3phy_p1;
  3708. +AUTOEXT struct u3phy_operator *u3phy_ops;
  3709. +
  3710. +/*********eye scan required*********/
  3711. +
  3712. +#define LO_BYTE(x) ((PHY_UINT8)((x) & 0xFF))
  3713. +#define HI_BYTE(x) ((PHY_UINT8)(((x) & 0xFF00) >> 8))
  3714. +
  3715. +typedef enum
  3716. +{
  3717. + SCAN_UP,
  3718. + SCAN_DN
  3719. +} enumScanDir;
  3720. +
  3721. +struct strucScanRegion
  3722. +{
  3723. + PHY_INT8 bX_tl;
  3724. + PHY_INT8 bY_tl;
  3725. + PHY_INT8 bX_br;
  3726. + PHY_INT8 bY_br;
  3727. + PHY_INT8 bDeltaX;
  3728. + PHY_INT8 bDeltaY;
  3729. +};
  3730. +
  3731. +struct strucTestCycle
  3732. +{
  3733. + PHY_UINT16 wEyeCnt;
  3734. + PHY_INT8 bNumOfEyeCnt;
  3735. + PHY_INT8 bPICalEn;
  3736. + PHY_INT8 bNumOfIgnoreCnt;
  3737. +};
  3738. +
  3739. +#define ERRCNT_MAX 128
  3740. +#define CYCLE_COUNT_MAX 15
  3741. +
  3742. +/// the map resolution is 128 x 128 pts
  3743. +#define MAX_X 127
  3744. +#define MAX_Y 127
  3745. +#define MIN_X 0
  3746. +#define MIN_Y 0
  3747. +
  3748. +PHY_INT32 u3phy_init(void);
  3749. +
  3750. +AUTOEXT struct strucScanRegion _rEye1;
  3751. +AUTOEXT struct strucScanRegion _rEye2;
  3752. +AUTOEXT struct strucTestCycle _rTestCycle;
  3753. +AUTOEXT PHY_UINT8 _bXcurr;
  3754. +AUTOEXT PHY_UINT8 _bYcurr;
  3755. +AUTOEXT enumScanDir _eScanDir;
  3756. +AUTOEXT PHY_INT8 _fgXChged;
  3757. +AUTOEXT PHY_INT8 _bPIResult;
  3758. +/* use local variable instead to save memory use */
  3759. +#if 0
  3760. +AUTOEXT PHY_UINT32 pwErrCnt0[CYCLE_COUNT_MAX][ERRCNT_MAX][ERRCNT_MAX];
  3761. +AUTOEXT PHY_UINT32 pwErrCnt1[CYCLE_COUNT_MAX][ERRCNT_MAX][ERRCNT_MAX];
  3762. +#endif
  3763. +
  3764. +/***********************************/
  3765. +#endif
  3766. +
  3767. --- a/drivers/usb/host/pci-quirks.h
  3768. +++ b/drivers/usb/host/pci-quirks.h
  3769. @@ -1,7 +1,7 @@
  3770. #ifndef __LINUX_USB_PCI_QUIRKS_H
  3771. #define __LINUX_USB_PCI_QUIRKS_H
  3772. -#ifdef CONFIG_PCI
  3773. +#if defined (CONFIG_PCI) && !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  3774. void uhci_reset_hc(struct pci_dev *pdev, unsigned long base);
  3775. int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base);
  3776. #endif /* CONFIG_PCI */
  3777. --- a/drivers/usb/host/xhci-dbg.c
  3778. +++ b/drivers/usb/host/xhci-dbg.c
  3779. @@ -21,6 +21,9 @@
  3780. */
  3781. #include "xhci.h"
  3782. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  3783. +#include "xhci-mtk.h"
  3784. +#endif
  3785. #define XHCI_INIT_VALUE 0x0
  3786. --- a/drivers/usb/host/xhci-mem.c
  3787. +++ b/drivers/usb/host/xhci-mem.c
  3788. @@ -65,6 +65,9 @@ static struct xhci_segment *xhci_segment
  3789. static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg)
  3790. {
  3791. + if (!seg)
  3792. + return;
  3793. +
  3794. if (seg->trbs) {
  3795. dma_pool_free(xhci->segment_pool, seg->trbs, seg->dma);
  3796. seg->trbs = NULL;
  3797. @@ -1446,9 +1449,17 @@ int xhci_endpoint_init(struct xhci_hcd *
  3798. max_burst = (usb_endpoint_maxp(&ep->desc)
  3799. & 0x1800) >> 11;
  3800. }
  3801. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  3802. + if ((max_packet % 4 == 2) && (max_packet % 16 != 14) && (max_burst == 0) && usb_endpoint_dir_in(&ep->desc))
  3803. + max_packet += 2;
  3804. +#endif
  3805. break;
  3806. case USB_SPEED_FULL:
  3807. case USB_SPEED_LOW:
  3808. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  3809. + if ((max_packet % 4 == 2) && (max_packet % 16 != 14) && (max_burst == 0) && usb_endpoint_dir_in(&ep->desc))
  3810. + max_packet += 2;
  3811. +#endif
  3812. break;
  3813. default:
  3814. BUG();
  3815. --- /dev/null
  3816. +++ b/drivers/usb/host/xhci-mtk-power.c
  3817. @@ -0,0 +1,115 @@
  3818. +#include "xhci-mtk.h"
  3819. +#include "xhci-mtk-power.h"
  3820. +#include "xhci.h"
  3821. +#include <linux/kernel.h> /* printk() */
  3822. +#include <linux/slab.h>
  3823. +#include <linux/delay.h>
  3824. +
  3825. +static int g_num_u3_port;
  3826. +static int g_num_u2_port;
  3827. +
  3828. +
  3829. +void enableXhciAllPortPower(struct xhci_hcd *xhci){
  3830. + int i;
  3831. + u32 port_id, temp;
  3832. + u32 __iomem *addr;
  3833. +
  3834. + g_num_u3_port = SSUSB_U3_PORT_NUM(readl(SSUSB_IP_CAP));
  3835. + g_num_u2_port = SSUSB_U2_PORT_NUM(readl(SSUSB_IP_CAP));
  3836. +
  3837. + for(i=1; i<=g_num_u3_port; i++){
  3838. + port_id=i;
  3839. + addr = &xhci->op_regs->port_status_base + NUM_PORT_REGS*(port_id-1 & 0xff);
  3840. + temp = xhci_readl(xhci, addr);
  3841. + temp = xhci_port_state_to_neutral(temp);
  3842. + temp |= PORT_POWER;
  3843. + xhci_writel(xhci, temp, addr);
  3844. + }
  3845. + for(i=1; i<=g_num_u2_port; i++){
  3846. + port_id=i+g_num_u3_port;
  3847. + addr = &xhci->op_regs->port_status_base + NUM_PORT_REGS*(port_id-1 & 0xff);
  3848. + temp = xhci_readl(xhci, addr);
  3849. + temp = xhci_port_state_to_neutral(temp);
  3850. + temp |= PORT_POWER;
  3851. + xhci_writel(xhci, temp, addr);
  3852. + }
  3853. +}
  3854. +
  3855. +void enableAllClockPower(){
  3856. +
  3857. + int i;
  3858. + u32 temp;
  3859. +
  3860. + g_num_u3_port = SSUSB_U3_PORT_NUM(readl(SSUSB_IP_CAP));
  3861. + g_num_u2_port = SSUSB_U2_PORT_NUM(readl(SSUSB_IP_CAP));
  3862. +
  3863. + //2. Enable xHC
  3864. + writel(readl(SSUSB_IP_PW_CTRL) | (SSUSB_IP_SW_RST), SSUSB_IP_PW_CTRL);
  3865. + writel(readl(SSUSB_IP_PW_CTRL) & (~SSUSB_IP_SW_RST), SSUSB_IP_PW_CTRL);
  3866. + writel(readl(SSUSB_IP_PW_CTRL_1) & (~SSUSB_IP_PDN), SSUSB_IP_PW_CTRL_1);
  3867. +
  3868. + //1. Enable target ports
  3869. + for(i=0; i<g_num_u3_port; i++){
  3870. + temp = readl(SSUSB_U3_CTRL(i));
  3871. + temp = temp & (~SSUSB_U3_PORT_PDN) & (~SSUSB_U3_PORT_DIS);
  3872. + writel(temp, SSUSB_U3_CTRL(i));
  3873. + }
  3874. + for(i=0; i<g_num_u2_port; i++){
  3875. + temp = readl(SSUSB_U2_CTRL(i));
  3876. + temp = temp & (~SSUSB_U2_PORT_PDN) & (~SSUSB_U2_PORT_DIS);
  3877. + writel(temp, SSUSB_U2_CTRL(i));
  3878. + }
  3879. + msleep(100);
  3880. +}
  3881. +
  3882. +
  3883. +//(X)disable clock/power of a port
  3884. +//(X)if all ports are disabled, disable IP ctrl power
  3885. +//disable all ports and IP clock/power, this is just mention HW that the power/clock of port
  3886. +//and IP could be disable if suspended.
  3887. +//If doesn't not disable all ports at first, the IP clock/power will never be disabled
  3888. +//(some U2 and U3 ports are binded to the same connection, that is, they will never enter suspend at the same time
  3889. +//port_index: port number
  3890. +//port_rev: 0x2 - USB2.0, 0x3 - USB3.0 (SuperSpeed)
  3891. +void disablePortClockPower(void){
  3892. + int i;
  3893. + u32 temp;
  3894. +
  3895. + g_num_u3_port = SSUSB_U3_PORT_NUM(readl(SSUSB_IP_CAP));
  3896. + g_num_u2_port = SSUSB_U2_PORT_NUM(readl(SSUSB_IP_CAP));
  3897. +
  3898. + for(i=0; i<g_num_u3_port; i++){
  3899. + temp = readl(SSUSB_U3_CTRL(i));
  3900. + temp = temp | (SSUSB_U3_PORT_PDN);
  3901. + writel(temp, SSUSB_U3_CTRL(i));
  3902. + }
  3903. + for(i=0; i<g_num_u2_port; i++){
  3904. + temp = readl(SSUSB_U2_CTRL(i));
  3905. + temp = temp | (SSUSB_U2_PORT_PDN);
  3906. + writel(temp, SSUSB_U2_CTRL(i));
  3907. + }
  3908. + writel(readl(SSUSB_IP_PW_CTRL_1) | (SSUSB_IP_PDN), SSUSB_IP_PW_CTRL_1);
  3909. +}
  3910. +
  3911. +//if IP ctrl power is disabled, enable it
  3912. +//enable clock/power of a port
  3913. +//port_index: port number
  3914. +//port_rev: 0x2 - USB2.0, 0x3 - USB3.0 (SuperSpeed)
  3915. +void enablePortClockPower(int port_index, int port_rev){
  3916. + int i;
  3917. + u32 temp;
  3918. +
  3919. + writel(readl(SSUSB_IP_PW_CTRL_1) & (~SSUSB_IP_PDN), SSUSB_IP_PW_CTRL_1);
  3920. +
  3921. + if(port_rev == 0x3){
  3922. + temp = readl(SSUSB_U3_CTRL(port_index));
  3923. + temp = temp & (~SSUSB_U3_PORT_PDN);
  3924. + writel(temp, SSUSB_U3_CTRL(port_index));
  3925. + }
  3926. + else if(port_rev == 0x2){
  3927. + temp = readl(SSUSB_U2_CTRL(port_index));
  3928. + temp = temp & (~SSUSB_U2_PORT_PDN);
  3929. + writel(temp, SSUSB_U2_CTRL(port_index));
  3930. + }
  3931. +}
  3932. +
  3933. --- /dev/null
  3934. +++ b/drivers/usb/host/xhci-mtk-power.h
  3935. @@ -0,0 +1,13 @@
  3936. +#ifndef _XHCI_MTK_POWER_H
  3937. +#define _XHCI_MTK_POWER_H
  3938. +
  3939. +#include <linux/usb.h>
  3940. +#include "xhci.h"
  3941. +#include "xhci-mtk.h"
  3942. +
  3943. +void enableXhciAllPortPower(struct xhci_hcd *xhci);
  3944. +void enableAllClockPower(void);
  3945. +void disablePortClockPower(void);
  3946. +void enablePortClockPower(int port_index, int port_rev);
  3947. +
  3948. +#endif
  3949. --- /dev/null
  3950. +++ b/drivers/usb/host/xhci-mtk-scheduler.c
  3951. @@ -0,0 +1,608 @@
  3952. +#include "xhci-mtk-scheduler.h"
  3953. +#include <linux/kernel.h> /* printk() */
  3954. +
  3955. +static struct sch_ep **ss_out_eps[MAX_EP_NUM];
  3956. +static struct sch_ep **ss_in_eps[MAX_EP_NUM];
  3957. +static struct sch_ep **hs_eps[MAX_EP_NUM]; //including tt isoc
  3958. +static struct sch_ep **tt_intr_eps[MAX_EP_NUM];
  3959. +
  3960. +
  3961. +int mtk_xhci_scheduler_init(void){
  3962. + int i;
  3963. +
  3964. + for(i=0; i<MAX_EP_NUM; i++){
  3965. + ss_out_eps[i] = NULL;
  3966. + }
  3967. + for(i=0; i<MAX_EP_NUM; i++){
  3968. + ss_in_eps[i] = NULL;
  3969. + }
  3970. + for(i=0; i<MAX_EP_NUM; i++){
  3971. + hs_eps[i] = NULL;
  3972. + }
  3973. + for(i=0; i<MAX_EP_NUM; i++){
  3974. + tt_intr_eps[i] = NULL;
  3975. + }
  3976. + return 0;
  3977. +}
  3978. +
  3979. +int add_sch_ep(int dev_speed, int is_in, int isTT, int ep_type, int maxp, int interval, int burst
  3980. + , int mult, int offset, int repeat, int pkts, int cs_count, int burst_mode
  3981. + , int bw_cost, mtk_u32 *ep, struct sch_ep *tmp_ep){
  3982. +
  3983. + struct sch_ep **ep_array;
  3984. + int i;
  3985. +
  3986. + if(is_in && dev_speed == USB_SPEED_SUPER ){
  3987. + ep_array = (struct sch_ep **)ss_in_eps;
  3988. + }
  3989. + else if(dev_speed == USB_SPEED_SUPER){
  3990. + ep_array = (struct sch_ep **)ss_out_eps;
  3991. + }
  3992. + else if(dev_speed == USB_SPEED_HIGH || (isTT && ep_type == USB_EP_ISOC)){
  3993. + ep_array = (struct sch_ep **)hs_eps;
  3994. + }
  3995. + else{
  3996. + ep_array = (struct sch_ep **)tt_intr_eps;
  3997. + }
  3998. + for(i=0; i<MAX_EP_NUM; i++){
  3999. + if(ep_array[i] == NULL){
  4000. + tmp_ep->dev_speed = dev_speed;
  4001. + tmp_ep->isTT = isTT;
  4002. + tmp_ep->is_in = is_in;
  4003. + tmp_ep->ep_type = ep_type;
  4004. + tmp_ep->maxp = maxp;
  4005. + tmp_ep->interval = interval;
  4006. + tmp_ep->burst = burst;
  4007. + tmp_ep->mult = mult;
  4008. + tmp_ep->offset = offset;
  4009. + tmp_ep->repeat = repeat;
  4010. + tmp_ep->pkts = pkts;
  4011. + tmp_ep->cs_count = cs_count;
  4012. + tmp_ep->burst_mode = burst_mode;
  4013. + tmp_ep->bw_cost = bw_cost;
  4014. + tmp_ep->ep = ep;
  4015. + ep_array[i] = tmp_ep;
  4016. + return SCH_SUCCESS;
  4017. + }
  4018. + }
  4019. + return SCH_FAIL;
  4020. +}
  4021. +
  4022. +int count_ss_bw(int is_in, int ep_type, int maxp, int interval, int burst, int mult, int offset, int repeat
  4023. + , int td_size){
  4024. + int i, j, k;
  4025. + int bw_required[3];
  4026. + int final_bw_required;
  4027. + int bw_required_per_repeat;
  4028. + int tmp_bw_required;
  4029. + struct sch_ep *cur_sch_ep;
  4030. + struct sch_ep **ep_array;
  4031. + int cur_offset;
  4032. + int cur_ep_offset;
  4033. + int tmp_offset;
  4034. + int tmp_interval;
  4035. + int ep_offset;
  4036. + int ep_interval;
  4037. + int ep_repeat;
  4038. + int ep_mult;
  4039. +
  4040. + if(is_in){
  4041. + ep_array = (struct sch_ep **)ss_in_eps;
  4042. + }
  4043. + else{
  4044. + ep_array = (struct sch_ep **)ss_out_eps;
  4045. + }
  4046. +
  4047. + bw_required[0] = 0;
  4048. + bw_required[1] = 0;
  4049. + bw_required[2] = 0;
  4050. +
  4051. + if(repeat == 0){
  4052. + final_bw_required = 0;
  4053. + for(i=0; i<MAX_EP_NUM; i++){
  4054. + cur_sch_ep = ep_array[i];
  4055. + if(cur_sch_ep == NULL){
  4056. + continue;
  4057. + }
  4058. + ep_interval = cur_sch_ep->interval;
  4059. + ep_offset = cur_sch_ep->offset;
  4060. + if(cur_sch_ep->repeat == 0){
  4061. + if(ep_interval >= interval){
  4062. + tmp_offset = ep_offset + ep_interval - offset;
  4063. + tmp_interval = interval;
  4064. + }
  4065. + else{
  4066. + tmp_offset = offset + interval - ep_offset;
  4067. + tmp_interval = ep_interval;
  4068. + }
  4069. + if(tmp_offset % tmp_interval == 0){
  4070. + final_bw_required += cur_sch_ep->bw_cost;
  4071. + }
  4072. + }
  4073. + else{
  4074. + ep_repeat = cur_sch_ep->repeat;
  4075. + ep_mult = cur_sch_ep->mult;
  4076. + for(k=0; k<=ep_mult; k++){
  4077. + cur_ep_offset = ep_offset+(k*ep_mult);
  4078. + if(ep_interval >= interval){
  4079. + tmp_offset = cur_ep_offset + ep_interval - offset;
  4080. + tmp_interval = interval;
  4081. + }
  4082. + else{
  4083. + tmp_offset = offset + interval - cur_ep_offset;
  4084. + tmp_interval = ep_interval;
  4085. + }
  4086. + if(tmp_offset % tmp_interval == 0){
  4087. + final_bw_required += cur_sch_ep->bw_cost;
  4088. + break;
  4089. + }
  4090. + }
  4091. + }
  4092. + }
  4093. + final_bw_required += td_size;
  4094. + }
  4095. + else{
  4096. + bw_required_per_repeat = maxp * (burst+1);
  4097. + for(j=0; j<=mult; j++){
  4098. + tmp_bw_required = 0;
  4099. + cur_offset = offset+(j*repeat);
  4100. + for(i=0; i<MAX_EP_NUM; i++){
  4101. + cur_sch_ep = ep_array[i];
  4102. + if(cur_sch_ep == NULL){
  4103. + continue;
  4104. + }
  4105. + ep_interval = cur_sch_ep->interval;
  4106. + ep_offset = cur_sch_ep->offset;
  4107. + if(cur_sch_ep->repeat == 0){
  4108. + if(ep_interval >= interval){
  4109. + tmp_offset = ep_offset + ep_interval - cur_offset;
  4110. + tmp_interval = interval;
  4111. + }
  4112. + else{
  4113. + tmp_offset = cur_offset + interval - ep_offset;
  4114. + tmp_interval = ep_interval;
  4115. + }
  4116. + if(tmp_offset % tmp_interval == 0){
  4117. + tmp_bw_required += cur_sch_ep->bw_cost;
  4118. + }
  4119. + }
  4120. + else{
  4121. + ep_repeat = cur_sch_ep->repeat;
  4122. + ep_mult = cur_sch_ep->mult;
  4123. + for(k=0; k<=ep_mult; k++){
  4124. + cur_ep_offset = ep_offset+(k*ep_repeat);
  4125. + if(ep_interval >= interval){
  4126. + tmp_offset = cur_ep_offset + ep_interval - cur_offset;
  4127. + tmp_interval = interval;
  4128. + }
  4129. + else{
  4130. + tmp_offset = cur_offset + interval - cur_ep_offset;
  4131. + tmp_interval = ep_interval;
  4132. + }
  4133. + if(tmp_offset % tmp_interval == 0){
  4134. + tmp_bw_required += cur_sch_ep->bw_cost;
  4135. + break;
  4136. + }
  4137. + }
  4138. + }
  4139. + }
  4140. + bw_required[j] = tmp_bw_required;
  4141. + }
  4142. + final_bw_required = SS_BW_BOUND;
  4143. + for(j=0; j<=mult; j++){
  4144. + if(bw_required[j] < final_bw_required){
  4145. + final_bw_required = bw_required[j];
  4146. + }
  4147. + }
  4148. + final_bw_required += bw_required_per_repeat;
  4149. + }
  4150. + return final_bw_required;
  4151. +}
  4152. +
  4153. +int count_hs_bw(int ep_type, int maxp, int interval, int offset, int td_size){
  4154. + int i;
  4155. + int bw_required;
  4156. + struct sch_ep *cur_sch_ep;
  4157. + int tmp_offset;
  4158. + int tmp_interval;
  4159. + int ep_offset;
  4160. + int ep_interval;
  4161. + int cur_tt_isoc_interval; //for isoc tt check
  4162. +
  4163. + bw_required = 0;
  4164. + for(i=0; i<MAX_EP_NUM; i++){
  4165. +
  4166. + cur_sch_ep = (struct sch_ep *)hs_eps[i];
  4167. + if(cur_sch_ep == NULL){
  4168. + continue;
  4169. + }
  4170. + ep_offset = cur_sch_ep->offset;
  4171. + ep_interval = cur_sch_ep->interval;
  4172. +
  4173. + if(cur_sch_ep->isTT && cur_sch_ep->ep_type == USB_EP_ISOC){
  4174. + cur_tt_isoc_interval = ep_interval<<3;
  4175. + if(ep_interval >= interval){
  4176. + tmp_offset = ep_offset + cur_tt_isoc_interval - offset;
  4177. + tmp_interval = interval;
  4178. + }
  4179. + else{
  4180. + tmp_offset = offset + interval - ep_offset;
  4181. + tmp_interval = cur_tt_isoc_interval;
  4182. + }
  4183. + if(cur_sch_ep->is_in){
  4184. + if((tmp_offset%tmp_interval >=2) && (tmp_offset%tmp_interval <= cur_sch_ep->cs_count)){
  4185. + bw_required += 188;
  4186. + }
  4187. + }
  4188. + else{
  4189. + if(tmp_offset%tmp_interval <= cur_sch_ep->cs_count){
  4190. + bw_required += 188;
  4191. + }
  4192. + }
  4193. + }
  4194. + else{
  4195. + if(ep_interval >= interval){
  4196. + tmp_offset = ep_offset + ep_interval - offset;
  4197. + tmp_interval = interval;
  4198. + }
  4199. + else{
  4200. + tmp_offset = offset + interval - ep_offset;
  4201. + tmp_interval = ep_interval;
  4202. + }
  4203. + if(tmp_offset%tmp_interval == 0){
  4204. + bw_required += cur_sch_ep->bw_cost;
  4205. + }
  4206. + }
  4207. + }
  4208. + bw_required += td_size;
  4209. + return bw_required;
  4210. +}
  4211. +
  4212. +int count_tt_isoc_bw(int is_in, int maxp, int interval, int offset, int td_size){
  4213. + char is_cs;
  4214. + int mframe_idx, frame_idx, s_frame, s_mframe, cur_mframe;
  4215. + int bw_required, max_bw;
  4216. + int ss_cs_count;
  4217. + int cs_mframe;
  4218. + int max_frame;
  4219. + int i,j;
  4220. + struct sch_ep *cur_sch_ep;
  4221. + int ep_offset;
  4222. + int ep_interval;
  4223. + int ep_cs_count;
  4224. + int tt_isoc_interval; //for isoc tt check
  4225. + int cur_tt_isoc_interval; //for isoc tt check
  4226. + int tmp_offset;
  4227. + int tmp_interval;
  4228. +
  4229. + is_cs = 0;
  4230. +
  4231. + tt_isoc_interval = interval<<3; //frame to mframe
  4232. + if(is_in){
  4233. + is_cs = 1;
  4234. + }
  4235. + s_frame = offset/8;
  4236. + s_mframe = offset%8;
  4237. + ss_cs_count = (maxp + (188 - 1))/188;
  4238. + if(is_cs){
  4239. + cs_mframe = offset%8 + 2 + ss_cs_count;
  4240. + if (cs_mframe <= 6)
  4241. + ss_cs_count += 2;
  4242. + else if (cs_mframe == 7)
  4243. + ss_cs_count++;
  4244. + else if (cs_mframe > 8)
  4245. + return -1;
  4246. + }
  4247. + max_bw = 0;
  4248. + if(is_in){
  4249. + i=2;
  4250. + }
  4251. + for(cur_mframe = offset+i; i<ss_cs_count; cur_mframe++, i++){
  4252. + bw_required = 0;
  4253. + for(j=0; j<MAX_EP_NUM; j++){
  4254. + cur_sch_ep = (struct sch_ep *)hs_eps[j];
  4255. + if(cur_sch_ep == NULL){
  4256. + continue;
  4257. + }
  4258. + ep_offset = cur_sch_ep->offset;
  4259. + ep_interval = cur_sch_ep->interval;
  4260. + if(cur_sch_ep->isTT && cur_sch_ep->ep_type == USB_EP_ISOC){
  4261. + //isoc tt
  4262. + //check if mframe offset overlap
  4263. + //if overlap, add 188 to the bw
  4264. + cur_tt_isoc_interval = ep_interval<<3;
  4265. + if(cur_tt_isoc_interval >= tt_isoc_interval){
  4266. + tmp_offset = (ep_offset+cur_tt_isoc_interval) - cur_mframe;
  4267. + tmp_interval = tt_isoc_interval;
  4268. + }
  4269. + else{
  4270. + tmp_offset = (cur_mframe+tt_isoc_interval) - ep_offset;
  4271. + tmp_interval = cur_tt_isoc_interval;
  4272. + }
  4273. + if(cur_sch_ep->is_in){
  4274. + if((tmp_offset%tmp_interval >=2) && (tmp_offset%tmp_interval <= cur_sch_ep->cs_count)){
  4275. + bw_required += 188;
  4276. + }
  4277. + }
  4278. + else{
  4279. + if(tmp_offset%tmp_interval <= cur_sch_ep->cs_count){
  4280. + bw_required += 188;
  4281. + }
  4282. + }
  4283. +
  4284. + }
  4285. + else if(cur_sch_ep->ep_type == USB_EP_INT || cur_sch_ep->ep_type == USB_EP_ISOC){
  4286. + //check if mframe
  4287. + if(ep_interval >= tt_isoc_interval){
  4288. + tmp_offset = (ep_offset+ep_interval) - cur_mframe;
  4289. + tmp_interval = tt_isoc_interval;
  4290. + }
  4291. + else{
  4292. + tmp_offset = (cur_mframe+tt_isoc_interval) - ep_offset;
  4293. + tmp_interval = ep_interval;
  4294. + }
  4295. + if(tmp_offset%tmp_interval == 0){
  4296. + bw_required += cur_sch_ep->bw_cost;
  4297. + }
  4298. + }
  4299. + }
  4300. + bw_required += 188;
  4301. + if(bw_required > max_bw){
  4302. + max_bw = bw_required;
  4303. + }
  4304. + }
  4305. + return max_bw;
  4306. +}
  4307. +
  4308. +int count_tt_intr_bw(int interval, int frame_offset){
  4309. + //check all eps in tt_intr_eps
  4310. + int ret;
  4311. + int i,j;
  4312. + int ep_offset;
  4313. + int ep_interval;
  4314. + int tmp_offset;
  4315. + int tmp_interval;
  4316. + ret = SCH_SUCCESS;
  4317. + struct sch_ep *cur_sch_ep;
  4318. +
  4319. + for(i=0; i<MAX_EP_NUM; i++){
  4320. + cur_sch_ep = (struct sch_ep *)tt_intr_eps[i];
  4321. + if(cur_sch_ep == NULL){
  4322. + continue;
  4323. + }
  4324. + ep_offset = cur_sch_ep->offset;
  4325. + ep_interval = cur_sch_ep->interval;
  4326. + if(ep_interval >= interval){
  4327. + tmp_offset = ep_offset + ep_interval - frame_offset;
  4328. + tmp_interval = interval;
  4329. + }
  4330. + else{
  4331. + tmp_offset = frame_offset + interval - ep_offset;
  4332. + tmp_interval = ep_interval;
  4333. + }
  4334. +
  4335. + if(tmp_offset%tmp_interval==0){
  4336. + return SCH_FAIL;
  4337. + }
  4338. + }
  4339. + return SCH_SUCCESS;
  4340. +}
  4341. +
  4342. +struct sch_ep * mtk_xhci_scheduler_remove_ep(int dev_speed, int is_in, int isTT, int ep_type, mtk_u32 *ep){
  4343. + int i;
  4344. + struct sch_ep **ep_array;
  4345. + struct sch_ep *cur_ep;
  4346. +
  4347. + if (is_in && dev_speed == USB_SPEED_SUPER) {
  4348. + ep_array = (struct sch_ep **)ss_in_eps;
  4349. + }
  4350. + else if (dev_speed == USB_SPEED_SUPER) {
  4351. + ep_array = (struct sch_ep **)ss_out_eps;
  4352. + }
  4353. + else if (dev_speed == USB_SPEED_HIGH || (isTT && ep_type == USB_EP_ISOC)) {
  4354. + ep_array = (struct sch_ep **)hs_eps;
  4355. + }
  4356. + else {
  4357. + ep_array = (struct sch_ep **)tt_intr_eps;
  4358. + }
  4359. + for (i = 0; i < MAX_EP_NUM; i++) {
  4360. + cur_ep = (struct sch_ep *)ep_array[i];
  4361. + if(cur_ep != NULL && cur_ep->ep == ep){
  4362. + ep_array[i] = NULL;
  4363. + return cur_ep;
  4364. + }
  4365. + }
  4366. + return NULL;
  4367. +}
  4368. +
  4369. +int mtk_xhci_scheduler_add_ep(int dev_speed, int is_in, int isTT, int ep_type, int maxp, int interval, int burst
  4370. + , int mult, mtk_u32 *ep, mtk_u32 *ep_ctx, struct sch_ep *sch_ep){
  4371. + mtk_u32 bPkts = 0;
  4372. + mtk_u32 bCsCount = 0;
  4373. + mtk_u32 bBm = 1;
  4374. + mtk_u32 bOffset = 0;
  4375. + mtk_u32 bRepeat = 0;
  4376. + int ret;
  4377. + struct mtk_xhci_ep_ctx *temp_ep_ctx;
  4378. + int td_size;
  4379. + int mframe_idx, frame_idx;
  4380. + int bw_cost;
  4381. + int cur_bw, best_bw, best_bw_idx,repeat, max_repeat, best_bw_repeat;
  4382. + int cur_offset, cs_mframe;
  4383. + int break_out;
  4384. + int frame_interval;
  4385. +
  4386. + printk(KERN_ERR "add_ep parameters, dev_speed %d, is_in %d, isTT %d, ep_type %d, maxp %d, interval %d, burst %d, mult %d, ep 0x%x, ep_ctx 0x%x, sch_ep 0x%x\n", dev_speed, is_in, isTT, ep_type, maxp
  4387. + , interval, burst, mult, ep, ep_ctx, sch_ep);
  4388. + if(isTT && ep_type == USB_EP_INT && ((dev_speed == USB_SPEED_LOW) || (dev_speed == USB_SPEED_FULL))){
  4389. + frame_interval = interval >> 3;
  4390. + for(frame_idx=0; frame_idx<frame_interval; frame_idx++){
  4391. + printk(KERN_ERR "check tt_intr_bw interval %d, frame_idx %d\n", frame_interval, frame_idx);
  4392. + if(count_tt_intr_bw(frame_interval, frame_idx) == SCH_SUCCESS){
  4393. + printk(KERN_ERR "check OK............\n");
  4394. + bOffset = frame_idx<<3;
  4395. + bPkts = 1;
  4396. + bCsCount = 3;
  4397. + bw_cost = maxp;
  4398. + bRepeat = 0;
  4399. + if(add_sch_ep(dev_speed, is_in, isTT, ep_type, maxp, frame_interval, burst, mult
  4400. + , bOffset, bRepeat, bPkts, bCsCount, bBm, maxp, ep, sch_ep) == SCH_FAIL){
  4401. + return SCH_FAIL;
  4402. + }
  4403. + ret = SCH_SUCCESS;
  4404. + break;
  4405. + }
  4406. + }
  4407. + }
  4408. + else if(isTT && ep_type == USB_EP_ISOC){
  4409. + best_bw = HS_BW_BOUND;
  4410. + best_bw_idx = -1;
  4411. + cur_bw = 0;
  4412. + td_size = maxp;
  4413. + break_out = 0;
  4414. + frame_interval = interval>>3;
  4415. + for(frame_idx=0; frame_idx<frame_interval && !break_out; frame_idx++){
  4416. + for(mframe_idx=0; mframe_idx<8; mframe_idx++){
  4417. + cur_offset = (frame_idx*8) + mframe_idx;
  4418. + cur_bw = count_tt_isoc_bw(is_in, maxp, frame_interval, cur_offset, td_size);
  4419. + if(cur_bw > 0 && cur_bw < best_bw){
  4420. + best_bw_idx = cur_offset;
  4421. + best_bw = cur_bw;
  4422. + if(cur_bw == td_size || cur_bw < (HS_BW_BOUND>>1)){
  4423. + break_out = 1;
  4424. + break;
  4425. + }
  4426. + }
  4427. + }
  4428. + }
  4429. + if(best_bw_idx == -1){
  4430. + return SCH_FAIL;
  4431. + }
  4432. + else{
  4433. + bOffset = best_bw_idx;
  4434. + bPkts = 1;
  4435. + bCsCount = (maxp + (188 - 1)) / 188;
  4436. + if(is_in){
  4437. + cs_mframe = bOffset%8 + 2 + bCsCount;
  4438. + if (cs_mframe <= 6)
  4439. + bCsCount += 2;
  4440. + else if (cs_mframe == 7)
  4441. + bCsCount++;
  4442. + }
  4443. + bw_cost = 188;
  4444. + bRepeat = 0;
  4445. + if(add_sch_ep( dev_speed, is_in, isTT, ep_type, maxp, interval, burst, mult
  4446. + , bOffset, bRepeat, bPkts, bCsCount, bBm, bw_cost, ep, sch_ep) == SCH_FAIL){
  4447. + return SCH_FAIL;
  4448. + }
  4449. + ret = SCH_SUCCESS;
  4450. + }
  4451. + }
  4452. + else if((dev_speed == USB_SPEED_FULL || dev_speed == USB_SPEED_LOW) && ep_type == USB_EP_INT){
  4453. + bPkts = 1;
  4454. + ret = SCH_SUCCESS;
  4455. + }
  4456. + else if(dev_speed == USB_SPEED_FULL && ep_type == USB_EP_ISOC){
  4457. + bPkts = 1;
  4458. + ret = SCH_SUCCESS;
  4459. + }
  4460. + else if(dev_speed == USB_SPEED_HIGH && (ep_type == USB_EP_INT || ep_type == USB_EP_ISOC)){
  4461. + best_bw = HS_BW_BOUND;
  4462. + best_bw_idx = -1;
  4463. + cur_bw = 0;
  4464. + td_size = maxp*(burst+1);
  4465. + for(cur_offset = 0; cur_offset<interval; cur_offset++){
  4466. + cur_bw = count_hs_bw(ep_type, maxp, interval, cur_offset, td_size);
  4467. + if(cur_bw > 0 && cur_bw < best_bw){
  4468. + best_bw_idx = cur_offset;
  4469. + best_bw = cur_bw;
  4470. + if(cur_bw == td_size || cur_bw < (HS_BW_BOUND>>1)){
  4471. + break;
  4472. + }
  4473. + }
  4474. + }
  4475. + if(best_bw_idx == -1){
  4476. + return SCH_FAIL;
  4477. + }
  4478. + else{
  4479. + bOffset = best_bw_idx;
  4480. + bPkts = burst + 1;
  4481. + bCsCount = 0;
  4482. + bw_cost = td_size;
  4483. + bRepeat = 0;
  4484. + if(add_sch_ep(dev_speed, is_in, isTT, ep_type, maxp, interval, burst, mult
  4485. + , bOffset, bRepeat, bPkts, bCsCount, bBm, bw_cost, ep, sch_ep) == SCH_FAIL){
  4486. + return SCH_FAIL;
  4487. + }
  4488. + ret = SCH_SUCCESS;
  4489. + }
  4490. + }
  4491. + else if(dev_speed == USB_SPEED_SUPER && (ep_type == USB_EP_INT || ep_type == USB_EP_ISOC)){
  4492. + best_bw = SS_BW_BOUND;
  4493. + best_bw_idx = -1;
  4494. + cur_bw = 0;
  4495. + td_size = maxp * (mult+1) * (burst+1);
  4496. + if(mult == 0){
  4497. + max_repeat = 0;
  4498. + }
  4499. + else{
  4500. + max_repeat = (interval-1)/(mult+1);
  4501. + }
  4502. + break_out = 0;
  4503. + for(frame_idx = 0; (frame_idx < interval) && !break_out; frame_idx++){
  4504. + for(repeat = max_repeat; repeat >= 0; repeat--){
  4505. + cur_bw = count_ss_bw(is_in, ep_type, maxp, interval, burst, mult, frame_idx
  4506. + , repeat, td_size);
  4507. + printk(KERN_ERR "count_ss_bw, frame_idx %d, repeat %d, td_size %d, result bw %d\n"
  4508. + , frame_idx, repeat, td_size, cur_bw);
  4509. + if(cur_bw > 0 && cur_bw < best_bw){
  4510. + best_bw_idx = frame_idx;
  4511. + best_bw_repeat = repeat;
  4512. + best_bw = cur_bw;
  4513. + if(cur_bw <= td_size || cur_bw < (HS_BW_BOUND>>1)){
  4514. + break_out = 1;
  4515. + break;
  4516. + }
  4517. + }
  4518. + }
  4519. + }
  4520. + printk(KERN_ERR "final best idx %d, best repeat %d\n", best_bw_idx, best_bw_repeat);
  4521. + if(best_bw_idx == -1){
  4522. + return SCH_FAIL;
  4523. + }
  4524. + else{
  4525. + bOffset = best_bw_idx;
  4526. + bCsCount = 0;
  4527. + bRepeat = best_bw_repeat;
  4528. + if(bRepeat == 0){
  4529. + bw_cost = (burst+1)*(mult+1)*maxp;
  4530. + bPkts = (burst+1)*(mult+1);
  4531. + }
  4532. + else{
  4533. + bw_cost = (burst+1)*maxp;
  4534. + bPkts = (burst+1);
  4535. + }
  4536. + if(add_sch_ep(dev_speed, is_in, isTT, ep_type, maxp, interval, burst, mult
  4537. + , bOffset, bRepeat, bPkts, bCsCount, bBm, bw_cost, ep, sch_ep) == SCH_FAIL){
  4538. + return SCH_FAIL;
  4539. + }
  4540. + ret = SCH_SUCCESS;
  4541. + }
  4542. + }
  4543. + else{
  4544. + bPkts = 1;
  4545. + ret = SCH_SUCCESS;
  4546. + }
  4547. + if(ret == SCH_SUCCESS){
  4548. + temp_ep_ctx = (struct mtk_xhci_ep_ctx *)ep_ctx;
  4549. + temp_ep_ctx->reserved[0] |= (BPKTS(bPkts) | BCSCOUNT(bCsCount) | BBM(bBm));
  4550. + temp_ep_ctx->reserved[1] |= (BOFFSET(bOffset) | BREPEAT(bRepeat));
  4551. +
  4552. + printk(KERN_DEBUG "[DBG] BPKTS: %x, BCSCOUNT: %x, BBM: %x\n", bPkts, bCsCount, bBm);
  4553. + printk(KERN_DEBUG "[DBG] BOFFSET: %x, BREPEAT: %x\n", bOffset, bRepeat);
  4554. + return SCH_SUCCESS;
  4555. + }
  4556. + else{
  4557. + return SCH_FAIL;
  4558. + }
  4559. +}
  4560. --- /dev/null
  4561. +++ b/drivers/usb/host/xhci-mtk-scheduler.h
  4562. @@ -0,0 +1,77 @@
  4563. +#ifndef _XHCI_MTK_SCHEDULER_H
  4564. +#define _XHCI_MTK_SCHEDULER_H
  4565. +
  4566. +#define MTK_SCH_NEW 1
  4567. +
  4568. +#define SCH_SUCCESS 1
  4569. +#define SCH_FAIL 0
  4570. +
  4571. +#define MAX_EP_NUM 64
  4572. +#define SS_BW_BOUND 51000
  4573. +#define HS_BW_BOUND 6144
  4574. +
  4575. +#define USB_EP_CONTROL 0
  4576. +#define USB_EP_ISOC 1
  4577. +#define USB_EP_BULK 2
  4578. +#define USB_EP_INT 3
  4579. +
  4580. +#define USB_SPEED_LOW 1
  4581. +#define USB_SPEED_FULL 2
  4582. +#define USB_SPEED_HIGH 3
  4583. +#define USB_SPEED_SUPER 5
  4584. +
  4585. +/* mtk scheduler bitmasks */
  4586. +#define BPKTS(p) ((p) & 0x3f)
  4587. +#define BCSCOUNT(p) (((p) & 0x7) << 8)
  4588. +#define BBM(p) ((p) << 11)
  4589. +#define BOFFSET(p) ((p) & 0x3fff)
  4590. +#define BREPEAT(p) (((p) & 0x7fff) << 16)
  4591. +
  4592. +
  4593. +#if 1
  4594. +typedef unsigned int mtk_u32;
  4595. +typedef unsigned long long mtk_u64;
  4596. +#endif
  4597. +
  4598. +#define NULL ((void *)0)
  4599. +
  4600. +struct mtk_xhci_ep_ctx {
  4601. + mtk_u32 ep_info;
  4602. + mtk_u32 ep_info2;
  4603. + mtk_u64 deq;
  4604. + mtk_u32 tx_info;
  4605. + /* offset 0x14 - 0x1f reserved for HC internal use */
  4606. + mtk_u32 reserved[3];
  4607. +};
  4608. +
  4609. +
  4610. +struct sch_ep
  4611. +{
  4612. + //device info
  4613. + int dev_speed;
  4614. + int isTT;
  4615. + //ep info
  4616. + int is_in;
  4617. + int ep_type;
  4618. + int maxp;
  4619. + int interval;
  4620. + int burst;
  4621. + int mult;
  4622. + //scheduling info
  4623. + int offset;
  4624. + int repeat;
  4625. + int pkts;
  4626. + int cs_count;
  4627. + int burst_mode;
  4628. + //other
  4629. + int bw_cost; //bandwidth cost in each repeat; including overhead
  4630. + mtk_u32 *ep; //address of usb_endpoint pointer
  4631. +};
  4632. +
  4633. +int mtk_xhci_scheduler_init(void);
  4634. +int mtk_xhci_scheduler_add_ep(int dev_speed, int is_in, int isTT, int ep_type, int maxp, int interval, int burst
  4635. + , int mult, mtk_u32 *ep, mtk_u32 *ep_ctx, struct sch_ep *sch_ep);
  4636. +struct sch_ep * mtk_xhci_scheduler_remove_ep(int dev_speed, int is_in, int isTT, int ep_type, mtk_u32 *ep);
  4637. +
  4638. +
  4639. +#endif
  4640. --- /dev/null
  4641. +++ b/drivers/usb/host/xhci-mtk.c
  4642. @@ -0,0 +1,265 @@
  4643. +#include "xhci-mtk.h"
  4644. +#include "xhci-mtk-power.h"
  4645. +#include "xhci.h"
  4646. +#include "mtk-phy.h"
  4647. +#ifdef CONFIG_C60802_SUPPORT
  4648. +#include "mtk-phy-c60802.h"
  4649. +#endif
  4650. +#include "xhci-mtk-scheduler.h"
  4651. +#include <linux/kernel.h> /* printk() */
  4652. +#include <linux/slab.h>
  4653. +#include <linux/delay.h>
  4654. +#include <asm/uaccess.h>
  4655. +#include <linux/dma-mapping.h>
  4656. +#include <linux/platform_device.h>
  4657. +
  4658. +void setInitialReg(void )
  4659. +{
  4660. + __u32 __iomem *addr;
  4661. + u32 temp;
  4662. +
  4663. + /* set SSUSB DMA burst size to 128B */
  4664. + addr = SSUSB_U3_XHCI_BASE + SSUSB_HDMA_CFG;
  4665. + temp = SSUSB_HDMA_CFG_MT7621_VALUE;
  4666. + writel(temp, addr);
  4667. +
  4668. + /* extend U3 LTSSM Polling.LFPS timeout value */
  4669. + addr = SSUSB_U3_XHCI_BASE + U3_LTSSM_TIMING_PARAMETER3;
  4670. + temp = U3_LTSSM_TIMING_PARAMETER3_VALUE;
  4671. + writel(temp, addr);
  4672. +
  4673. + /* EOF */
  4674. + addr = SSUSB_U3_XHCI_BASE + SYNC_HS_EOF;
  4675. + temp = SYNC_HS_EOF_VALUE;
  4676. + writel(temp, addr);
  4677. +
  4678. +#if defined (CONFIG_PERIODIC_ENP)
  4679. + /* HSCH_CFG1: SCH2_FIFO_DEPTH */
  4680. + addr = SSUSB_U3_XHCI_BASE + HSCH_CFG1;
  4681. + temp = readl(addr);
  4682. + temp &= ~(0x3 << SCH2_FIFO_DEPTH_OFFSET);
  4683. + writel(temp, addr);
  4684. +#endif
  4685. +
  4686. + /* Doorbell handling */
  4687. + addr = SIFSLV_IPPC + SSUSB_IP_SPAR0;
  4688. + temp = 0x1;
  4689. + writel(temp, addr);
  4690. +
  4691. + /* Set SW PLL Stable mode to 1 for U2 LPM device remote wakeup */
  4692. + /* Port 0 */
  4693. + addr = U2_PHY_BASE + U2_PHYD_CR1;
  4694. + temp = readl(addr);
  4695. + temp &= ~(0x3 << 18);
  4696. + temp |= (1 << 18);
  4697. + writel(temp, addr);
  4698. +
  4699. + /* Port 1 */
  4700. + addr = U2_PHY_BASE_P1 + U2_PHYD_CR1;
  4701. + temp = readl(addr);
  4702. + temp &= ~(0x3 << 18);
  4703. + temp |= (1 << 18);
  4704. + writel(temp, addr);
  4705. +}
  4706. +
  4707. +
  4708. +void setLatchSel(void){
  4709. + __u32 __iomem *latch_sel_addr;
  4710. + u32 latch_sel_value;
  4711. + latch_sel_addr = U3_PIPE_LATCH_SEL_ADD;
  4712. + latch_sel_value = ((U3_PIPE_LATCH_TX)<<2) | (U3_PIPE_LATCH_RX);
  4713. + writel(latch_sel_value, latch_sel_addr);
  4714. +}
  4715. +
  4716. +void reinitIP(void){
  4717. + __u32 __iomem *ip_reset_addr;
  4718. + u32 ip_reset_value;
  4719. +
  4720. + enableAllClockPower();
  4721. + mtk_xhci_scheduler_init();
  4722. +}
  4723. +
  4724. +void dbg_prb_out(void){
  4725. + mtk_probe_init(0x0f0f0f0f);
  4726. + mtk_probe_out(0xffffffff);
  4727. + mtk_probe_out(0x01010101);
  4728. + mtk_probe_out(0x02020202);
  4729. + mtk_probe_out(0x04040404);
  4730. + mtk_probe_out(0x08080808);
  4731. + mtk_probe_out(0x10101010);
  4732. + mtk_probe_out(0x20202020);
  4733. + mtk_probe_out(0x40404040);
  4734. + mtk_probe_out(0x80808080);
  4735. + mtk_probe_out(0x55555555);
  4736. + mtk_probe_out(0xaaaaaaaa);
  4737. +}
  4738. +
  4739. +
  4740. +
  4741. +///////////////////////////////////////////////////////////////////////////////
  4742. +
  4743. +#define RET_SUCCESS 0
  4744. +#define RET_FAIL 1
  4745. +
  4746. +static int dbg_u3w(int argc, char**argv)
  4747. +{
  4748. + int u4TimingValue;
  4749. + char u1TimingValue;
  4750. + int u4TimingAddress;
  4751. +
  4752. + if (argc<3)
  4753. + {
  4754. + printk(KERN_ERR "Arg: address value\n");
  4755. + return RET_FAIL;
  4756. + }
  4757. + u3phy_init();
  4758. +
  4759. + u4TimingAddress = (int)simple_strtol(argv[1], &argv[1], 16);
  4760. + u4TimingValue = (int)simple_strtol(argv[2], &argv[2], 16);
  4761. + u1TimingValue = u4TimingValue & 0xff;
  4762. + /* access MMIO directly */
  4763. + writel(u1TimingValue, u4TimingAddress);
  4764. + printk(KERN_ERR "Write done\n");
  4765. + return RET_SUCCESS;
  4766. +
  4767. +}
  4768. +
  4769. +static int dbg_u3r(int argc, char**argv)
  4770. +{
  4771. + char u1ReadTimingValue;
  4772. + int u4TimingAddress;
  4773. + if (argc<2)
  4774. + {
  4775. + printk(KERN_ERR "Arg: address\n");
  4776. + return 0;
  4777. + }
  4778. + u3phy_init();
  4779. + mdelay(500);
  4780. + u4TimingAddress = (int)simple_strtol(argv[1], &argv[1], 16);
  4781. + /* access MMIO directly */
  4782. + u1ReadTimingValue = readl(u4TimingAddress);
  4783. + printk(KERN_ERR "Value = 0x%x\n", u1ReadTimingValue);
  4784. + return 0;
  4785. +}
  4786. +
  4787. +static int dbg_u3init(int argc, char**argv)
  4788. +{
  4789. + int ret;
  4790. + ret = u3phy_init();
  4791. + printk(KERN_ERR "phy registers and operations initial done\n");
  4792. + if(u3phy_ops->u2_slew_rate_calibration){
  4793. + u3phy_ops->u2_slew_rate_calibration(u3phy);
  4794. + }
  4795. + else{
  4796. + printk(KERN_ERR "WARN: PHY doesn't implement u2 slew rate calibration function\n");
  4797. + }
  4798. + if(u3phy_ops->init(u3phy) == PHY_TRUE)
  4799. + return RET_SUCCESS;
  4800. + return RET_FAIL;
  4801. +}
  4802. +
  4803. +void dbg_setU1U2(int argc, char**argv){
  4804. + struct xhci_hcd *xhci;
  4805. + int u1_value;
  4806. + int u2_value;
  4807. + u32 port_id, temp;
  4808. + u32 __iomem *addr;
  4809. +
  4810. + if (argc<3)
  4811. + {
  4812. + printk(KERN_ERR "Arg: u1value u2value\n");
  4813. + return RET_FAIL;
  4814. + }
  4815. +
  4816. + u1_value = (int)simple_strtol(argv[1], &argv[1], 10);
  4817. + u2_value = (int)simple_strtol(argv[2], &argv[2], 10);
  4818. + addr = (SSUSB_U3_XHCI_BASE + 0x424);
  4819. + temp = readl(addr);
  4820. + temp = temp & (~(0x0000ffff));
  4821. + temp = temp | u1_value | (u2_value<<8);
  4822. + writel(temp, addr);
  4823. +}
  4824. +///////////////////////////////////////////////////////////////////////////////
  4825. +
  4826. +int call_function(char *buf)
  4827. +{
  4828. + int i;
  4829. + int argc;
  4830. + char *argv[80];
  4831. +
  4832. + argc = 0;
  4833. + do
  4834. + {
  4835. + argv[argc] = strsep(&buf, " ");
  4836. + printk(KERN_DEBUG "[%d] %s\r\n", argc, argv[argc]);
  4837. + argc++;
  4838. + } while (buf);
  4839. + if (!strcmp("dbg.r", argv[0]))
  4840. + dbg_prb_out();
  4841. + else if (!strcmp("dbg.u3w", argv[0]))
  4842. + dbg_u3w(argc, argv);
  4843. + else if (!strcmp("dbg.u3r", argv[0]))
  4844. + dbg_u3r(argc, argv);
  4845. + else if (!strcmp("dbg.u3i", argv[0]))
  4846. + dbg_u3init(argc, argv);
  4847. + else if (!strcmp("pw.u1u2", argv[0]))
  4848. + dbg_setU1U2(argc, argv);
  4849. + return 0;
  4850. +}
  4851. +
  4852. +long xhci_mtk_test_unlock_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  4853. +{
  4854. + char w_buf[200];
  4855. + char r_buf[200] = "this is a test";
  4856. + int len = 200;
  4857. +
  4858. + switch (cmd) {
  4859. + case IOCTL_READ:
  4860. + copy_to_user((char *) arg, r_buf, len);
  4861. + printk(KERN_DEBUG "IOCTL_READ: %s\r\n", r_buf);
  4862. + break;
  4863. + case IOCTL_WRITE:
  4864. + copy_from_user(w_buf, (char *) arg, len);
  4865. + printk(KERN_DEBUG "IOCTL_WRITE: %s\r\n", w_buf);
  4866. +
  4867. + //invoke function
  4868. + return call_function(w_buf);
  4869. + break;
  4870. + default:
  4871. + return -ENOTTY;
  4872. + }
  4873. +
  4874. + return len;
  4875. +}
  4876. +
  4877. +int xhci_mtk_test_open(struct inode *inode, struct file *file)
  4878. +{
  4879. +
  4880. + printk(KERN_DEBUG "xhci_mtk_test open: successful\n");
  4881. + return 0;
  4882. +}
  4883. +
  4884. +int xhci_mtk_test_release(struct inode *inode, struct file *file)
  4885. +{
  4886. +
  4887. + printk(KERN_DEBUG "xhci_mtk_test release: successful\n");
  4888. + return 0;
  4889. +}
  4890. +
  4891. +ssize_t xhci_mtk_test_read(struct file *file, char *buf, size_t count, loff_t *ptr)
  4892. +{
  4893. +
  4894. + printk(KERN_DEBUG "xhci_mtk_test read: returning zero bytes\n");
  4895. + return 0;
  4896. +}
  4897. +
  4898. +ssize_t xhci_mtk_test_write(struct file *file, const char *buf, size_t count, loff_t * ppos)
  4899. +{
  4900. +
  4901. + printk(KERN_DEBUG "xhci_mtk_test write: accepting zero bytes\n");
  4902. + return 0;
  4903. +}
  4904. +
  4905. +
  4906. +
  4907. +
  4908. --- /dev/null
  4909. +++ b/drivers/usb/host/xhci-mtk.h
  4910. @@ -0,0 +1,120 @@
  4911. +#ifndef _XHCI_MTK_H
  4912. +#define _XHCI_MTK_H
  4913. +
  4914. +#include <linux/usb.h>
  4915. +#include "xhci.h"
  4916. +
  4917. +#define SSUSB_U3_XHCI_BASE 0xBE1C0000
  4918. +#define SSUSB_U3_MAC_BASE 0xBE1C2400
  4919. +#define SSUSB_U3_SYS_BASE 0xBE1C2600
  4920. +#define SSUSB_U2_SYS_BASE 0xBE1C3400
  4921. +#define SSUB_SIF_SLV_TOP 0xBE1D0000
  4922. +#define SIFSLV_IPPC (SSUB_SIF_SLV_TOP + 0x700)
  4923. +
  4924. +#define U3_PIPE_LATCH_SEL_ADD SSUSB_U3_MAC_BASE + 0x130
  4925. +#define U3_PIPE_LATCH_TX 0
  4926. +#define U3_PIPE_LATCH_RX 0
  4927. +
  4928. +#define U3_UX_EXIT_LFPS_TIMING_PAR 0xa0
  4929. +#define U3_REF_CK_PAR 0xb0
  4930. +#define U3_RX_UX_EXIT_LFPS_REF_OFFSET 8
  4931. +#define U3_RX_UX_EXIT_LFPS_REF 3
  4932. +#define U3_REF_CK_VAL 10
  4933. +
  4934. +#define U3_TIMING_PULSE_CTRL 0xb4
  4935. +#define CNT_1US_VALUE 63 //62.5MHz:63, 70MHz:70, 80MHz:80, 100MHz:100, 125MHz:125
  4936. +
  4937. +#define USB20_TIMING_PARAMETER 0x40
  4938. +#define TIME_VALUE_1US 63 //62.5MHz:63, 80MHz:80, 100MHz:100, 125MHz:125
  4939. +
  4940. +#define LINK_PM_TIMER 0x8
  4941. +#define PM_LC_TIMEOUT_VALUE 3
  4942. +
  4943. +#define XHCI_IMOD 0x624
  4944. +#define XHCI_IMOD_MT7621_VALUE 0x10
  4945. +
  4946. +#define SSUSB_HDMA_CFG 0x950
  4947. +#define SSUSB_HDMA_CFG_MT7621_VALUE 0x10E0E0C
  4948. +
  4949. +#define U3_LTSSM_TIMING_PARAMETER3 0x2514
  4950. +#define U3_LTSSM_TIMING_PARAMETER3_VALUE 0x3E8012C
  4951. +
  4952. +#define U2_PHYD_CR1 0x64
  4953. +
  4954. +#define SSUSB_IP_SPAR0 0xC8
  4955. +
  4956. +#define SYNC_HS_EOF 0x938
  4957. +#define SYNC_HS_EOF_VALUE 0x201F3
  4958. +
  4959. +#define HSCH_CFG1 0x960
  4960. +#define SCH2_FIFO_DEPTH_OFFSET 16
  4961. +
  4962. +
  4963. +#define SSUSB_IP_PW_CTRL (SIFSLV_IPPC+0x0)
  4964. +#define SSUSB_IP_SW_RST (1<<0)
  4965. +#define SSUSB_IP_PW_CTRL_1 (SIFSLV_IPPC+0x4)
  4966. +#define SSUSB_IP_PDN (1<<0)
  4967. +#define SSUSB_U3_CTRL(p) (SIFSLV_IPPC+0x30+(p*0x08))
  4968. +#define SSUSB_U3_PORT_DIS (1<<0)
  4969. +#define SSUSB_U3_PORT_PDN (1<<1)
  4970. +#define SSUSB_U3_PORT_HOST_SEL (1<<2)
  4971. +#define SSUSB_U3_PORT_CKBG_EN (1<<3)
  4972. +#define SSUSB_U3_PORT_MAC_RST (1<<4)
  4973. +#define SSUSB_U3_PORT_PHYD_RST (1<<5)
  4974. +#define SSUSB_U2_CTRL(p) (SIFSLV_IPPC+(0x50)+(p*0x08))
  4975. +#define SSUSB_U2_PORT_DIS (1<<0)
  4976. +#define SSUSB_U2_PORT_PDN (1<<1)
  4977. +#define SSUSB_U2_PORT_HOST_SEL (1<<2)
  4978. +#define SSUSB_U2_PORT_CKBG_EN (1<<3)
  4979. +#define SSUSB_U2_PORT_MAC_RST (1<<4)
  4980. +#define SSUSB_U2_PORT_PHYD_RST (1<<5)
  4981. +#define SSUSB_IP_CAP (SIFSLV_IPPC+0x024)
  4982. +
  4983. +#define SSUSB_U3_PORT_NUM(p) (p & 0xff)
  4984. +#define SSUSB_U2_PORT_NUM(p) ((p>>8) & 0xff)
  4985. +
  4986. +
  4987. +#define XHCI_MTK_TEST_MAJOR 234
  4988. +#define DEVICE_NAME "xhci_mtk_test"
  4989. +
  4990. +#define CLI_MAGIC 'CLI'
  4991. +#define IOCTL_READ _IOR(CLI_MAGIC, 0, int)
  4992. +#define IOCTL_WRITE _IOW(CLI_MAGIC, 1, int)
  4993. +
  4994. +void reinitIP(void);
  4995. +void setInitialReg(void);
  4996. +void dbg_prb_out(void);
  4997. +int call_function(char *buf);
  4998. +
  4999. +long xhci_mtk_test_unlock_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
  5000. +int xhci_mtk_test_open(struct inode *inode, struct file *file);
  5001. +int xhci_mtk_test_release(struct inode *inode, struct file *file);
  5002. +ssize_t xhci_mtk_test_read(struct file *file, char *buf, size_t count, loff_t *ptr);
  5003. +ssize_t xhci_mtk_test_write(struct file *file, const char *buf, size_t count, loff_t * ppos);
  5004. +
  5005. +/*
  5006. + mediatek probe out
  5007. +*/
  5008. +/************************************************************************************/
  5009. +
  5010. +#define SW_PRB_OUT_ADDR (SIFSLV_IPPC+0xc0)
  5011. +#define PRB_MODULE_SEL_ADDR (SIFSLV_IPPC+0xbc)
  5012. +
  5013. +static inline void mtk_probe_init(const u32 byte){
  5014. + __u32 __iomem *ptr = (__u32 __iomem *) PRB_MODULE_SEL_ADDR;
  5015. + writel(byte, ptr);
  5016. +}
  5017. +
  5018. +static inline void mtk_probe_out(const u32 value){
  5019. + __u32 __iomem *ptr = (__u32 __iomem *) SW_PRB_OUT_ADDR;
  5020. + writel(value, ptr);
  5021. +}
  5022. +
  5023. +static inline u32 mtk_probe_value(void){
  5024. + __u32 __iomem *ptr = (__u32 __iomem *) SW_PRB_OUT_ADDR;
  5025. +
  5026. + return readl(ptr);
  5027. +}
  5028. +
  5029. +
  5030. +#endif
  5031. --- a/drivers/usb/host/xhci-plat.c
  5032. +++ b/drivers/usb/host/xhci-plat.c
  5033. @@ -25,6 +25,13 @@ static void xhci_plat_quirks(struct devi
  5034. * dev struct in order to setup MSI
  5035. */
  5036. xhci->quirks |= XHCI_PLAT;
  5037. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5038. + /* MTK host controller gives a spurious successful event after a
  5039. + * short transfer. Ignore it.
  5040. + */
  5041. + xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
  5042. + xhci->quirks |= XHCI_LPM_SUPPORT;
  5043. +#endif
  5044. }
  5045. /* called during probe() after chip reset completes */
  5046. @@ -96,20 +103,32 @@ static int xhci_plat_probe(struct platfo
  5047. driver = &xhci_plat_xhci_driver;
  5048. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5049. + irq = XHC_IRQ;
  5050. +#else
  5051. irq = platform_get_irq(pdev, 0);
  5052. +#endif
  5053. +
  5054. if (irq < 0)
  5055. return -ENODEV;
  5056. +#if !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5057. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  5058. if (!res)
  5059. return -ENODEV;
  5060. +#endif
  5061. hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
  5062. if (!hcd)
  5063. return -ENOMEM;
  5064. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5065. + hcd->rsrc_start = (uint32_t)XHC_IO_START;
  5066. + hcd->rsrc_len = XHC_IO_LENGTH;
  5067. +#else
  5068. hcd->rsrc_start = res->start;
  5069. hcd->rsrc_len = resource_size(res);
  5070. +#endif
  5071. if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
  5072. driver->description)) {
  5073. --- a/drivers/usb/host/xhci-ring.c
  5074. +++ b/drivers/usb/host/xhci-ring.c
  5075. @@ -236,7 +236,6 @@ static void inc_enq(struct xhci_hcd *xhc
  5076. */
  5077. if (!chain && !more_trbs_coming)
  5078. break;
  5079. -
  5080. /* If we're not dealing with 0.95 hardware or
  5081. * isoc rings on AMD 0.96 host,
  5082. * carry over the chain bit of the previous TRB
  5083. @@ -273,16 +272,20 @@ static void inc_enq(struct xhci_hcd *xhc
  5084. static inline int room_on_ring(struct xhci_hcd *xhci, struct xhci_ring *ring,
  5085. unsigned int num_trbs)
  5086. {
  5087. +#if !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5088. int num_trbs_in_deq_seg;
  5089. +#endif
  5090. if (ring->num_trbs_free < num_trbs)
  5091. return 0;
  5092. +#if !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5093. if (ring->type != TYPE_COMMAND && ring->type != TYPE_EVENT) {
  5094. num_trbs_in_deq_seg = ring->dequeue - ring->deq_seg->trbs;
  5095. if (ring->num_trbs_free < num_trbs + num_trbs_in_deq_seg)
  5096. return 0;
  5097. }
  5098. +#endif
  5099. return 1;
  5100. }
  5101. @@ -2910,6 +2913,7 @@ static int prepare_ring(struct xhci_hcd
  5102. next = ring->enqueue;
  5103. while (last_trb(xhci, ring, ring->enq_seg, next)) {
  5104. +#if !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5105. /* If we're not dealing with 0.95 hardware or isoc rings
  5106. * on AMD 0.96 host, clear the chain bit.
  5107. */
  5108. @@ -2919,7 +2923,9 @@ static int prepare_ring(struct xhci_hcd
  5109. next->link.control &= cpu_to_le32(~TRB_CHAIN);
  5110. else
  5111. next->link.control |= cpu_to_le32(TRB_CHAIN);
  5112. -
  5113. +#else
  5114. + next->link.control &= cpu_to_le32(~TRB_CHAIN);
  5115. +#endif
  5116. wmb();
  5117. next->link.control ^= cpu_to_le32(TRB_CYCLE);
  5118. @@ -3049,6 +3055,9 @@ static void giveback_first_trb(struct xh
  5119. start_trb->field[3] |= cpu_to_le32(start_cycle);
  5120. else
  5121. start_trb->field[3] &= cpu_to_le32(~TRB_CYCLE);
  5122. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5123. + wmb();
  5124. +#endif
  5125. xhci_ring_ep_doorbell(xhci, slot_id, ep_index, stream_id);
  5126. }
  5127. @@ -3108,6 +3117,29 @@ static u32 xhci_td_remainder(unsigned in
  5128. return (remainder >> 10) << 17;
  5129. }
  5130. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5131. +static u32 mtk_xhci_td_remainder(unsigned int td_transfer_size, unsigned int td_running_total, unsigned int maxp, unsigned trb_buffer_length)
  5132. +{
  5133. + u32 max = 31;
  5134. + int remainder, td_packet_count, packet_transferred;
  5135. +
  5136. + //0 for the last TRB
  5137. + //FIXME: need to workaround if there is ZLP in this TD
  5138. + if (td_running_total + trb_buffer_length == td_transfer_size)
  5139. + return 0;
  5140. +
  5141. + //FIXME: need to take care of high-bandwidth (MAX_ESIT)
  5142. + packet_transferred = (td_running_total /*+ trb_buffer_length*/) / maxp;
  5143. + td_packet_count = DIV_ROUND_UP(td_transfer_size, maxp);
  5144. + remainder = td_packet_count - packet_transferred;
  5145. +
  5146. + if (remainder > max)
  5147. + return max << 17;
  5148. + else
  5149. + return remainder << 17;
  5150. +}
  5151. +#endif
  5152. +
  5153. /*
  5154. * For xHCI 1.0 host controllers, TD size is the number of max packet sized
  5155. * packets remaining in the TD (*not* including this TRB).
  5156. @@ -3245,6 +3277,7 @@ static int queue_bulk_sg_tx(struct xhci_
  5157. }
  5158. /* Set the TRB length, TD size, and interrupter fields. */
  5159. +#if !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5160. if (xhci->hci_version < 0x100) {
  5161. remainder = xhci_td_remainder(
  5162. urb->transfer_buffer_length -
  5163. @@ -3254,6 +3287,13 @@ static int queue_bulk_sg_tx(struct xhci_
  5164. trb_buff_len, total_packet_count, urb,
  5165. num_trbs - 1);
  5166. }
  5167. +#else
  5168. + if (num_trbs > 1)
  5169. + remainder = mtk_xhci_td_remainder(urb->transfer_buffer_length,
  5170. + running_total, urb->ep->desc.wMaxPacketSize, trb_buff_len);
  5171. +#endif
  5172. +
  5173. +
  5174. length_field = TRB_LEN(trb_buff_len) |
  5175. remainder |
  5176. TRB_INTR_TARGET(0);
  5177. @@ -3316,6 +3356,9 @@ int xhci_queue_bulk_tx(struct xhci_hcd *
  5178. int running_total, trb_buff_len, ret;
  5179. unsigned int total_packet_count;
  5180. u64 addr;
  5181. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5182. + int max_packet;
  5183. +#endif
  5184. if (urb->num_sgs)
  5185. return queue_bulk_sg_tx(xhci, mem_flags, urb, slot_id, ep_index);
  5186. @@ -3341,6 +3384,25 @@ int xhci_queue_bulk_tx(struct xhci_hcd *
  5187. running_total += TRB_MAX_BUFF_SIZE;
  5188. }
  5189. /* FIXME: this doesn't deal with URB_ZERO_PACKET - need one more */
  5190. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5191. + switch(urb->dev->speed){
  5192. + case USB_SPEED_SUPER:
  5193. + max_packet = urb->ep->desc.wMaxPacketSize;
  5194. + break;
  5195. + case USB_SPEED_HIGH:
  5196. + case USB_SPEED_FULL:
  5197. + case USB_SPEED_LOW:
  5198. + case USB_SPEED_WIRELESS:
  5199. + case USB_SPEED_UNKNOWN:
  5200. + default:
  5201. + max_packet = urb->ep->desc.wMaxPacketSize & 0x7ff;
  5202. + break;
  5203. + }
  5204. + if((urb->transfer_flags & URB_ZERO_PACKET)
  5205. + && ((urb->transfer_buffer_length % max_packet) == 0)){
  5206. + num_trbs++;
  5207. + }
  5208. +#endif
  5209. ret = prepare_transfer(xhci, xhci->devs[slot_id],
  5210. ep_index, urb->stream_id,
  5211. @@ -3400,6 +3462,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *
  5212. field |= TRB_ISP;
  5213. /* Set the TRB length, TD size, and interrupter fields. */
  5214. +#if !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5215. if (xhci->hci_version < 0x100) {
  5216. remainder = xhci_td_remainder(
  5217. urb->transfer_buffer_length -
  5218. @@ -3409,6 +3472,10 @@ int xhci_queue_bulk_tx(struct xhci_hcd *
  5219. trb_buff_len, total_packet_count, urb,
  5220. num_trbs - 1);
  5221. }
  5222. +#else
  5223. + remainder = mtk_xhci_td_remainder(urb->transfer_buffer_length, running_total, max_packet, trb_buff_len);
  5224. +#endif
  5225. +
  5226. length_field = TRB_LEN(trb_buff_len) |
  5227. remainder |
  5228. TRB_INTR_TARGET(0);
  5229. @@ -3498,7 +3565,11 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *
  5230. field |= 0x1;
  5231. /* xHCI 1.0 6.4.1.2.1: Transfer Type field */
  5232. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5233. + if (1) {
  5234. +#else
  5235. if (xhci->hci_version == 0x100) {
  5236. +#endif
  5237. if (urb->transfer_buffer_length > 0) {
  5238. if (setup->bRequestType & USB_DIR_IN)
  5239. field |= TRB_TX_TYPE(TRB_DATA_IN);
  5240. @@ -3522,7 +3593,12 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *
  5241. field = TRB_TYPE(TRB_DATA);
  5242. length_field = TRB_LEN(urb->transfer_buffer_length) |
  5243. +#if !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5244. xhci_td_remainder(urb->transfer_buffer_length) |
  5245. +#else
  5246. + //CC: MTK style, no scatter-gather for control transfer
  5247. + 0 |
  5248. +#endif
  5249. TRB_INTR_TARGET(0);
  5250. if (urb->transfer_buffer_length > 0) {
  5251. if (setup->bRequestType & USB_DIR_IN)
  5252. @@ -3533,7 +3609,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *
  5253. length_field,
  5254. field | ep_ring->cycle_state);
  5255. }
  5256. -
  5257. +
  5258. /* Save the DMA address of the last TRB in the TD */
  5259. td->last_trb = ep_ring->enqueue;
  5260. @@ -3645,6 +3721,9 @@ static int xhci_queue_isoc_tx(struct xhc
  5261. u64 start_addr, addr;
  5262. int i, j;
  5263. bool more_trbs_coming;
  5264. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5265. + int max_packet;
  5266. +#endif
  5267. ep_ring = xhci->devs[slot_id]->eps[ep_index].ring;
  5268. @@ -3658,6 +3737,21 @@ static int xhci_queue_isoc_tx(struct xhc
  5269. start_trb = &ep_ring->enqueue->generic;
  5270. start_cycle = ep_ring->cycle_state;
  5271. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5272. + switch(urb->dev->speed){
  5273. + case USB_SPEED_SUPER:
  5274. + max_packet = urb->ep->desc.wMaxPacketSize;
  5275. + break;
  5276. + case USB_SPEED_HIGH:
  5277. + case USB_SPEED_FULL:
  5278. + case USB_SPEED_LOW:
  5279. + case USB_SPEED_WIRELESS:
  5280. + case USB_SPEED_UNKNOWN:
  5281. + max_packet = urb->ep->desc.wMaxPacketSize & 0x7ff;
  5282. + break;
  5283. + }
  5284. +#endif
  5285. +
  5286. urb_priv = urb->hcpriv;
  5287. /* Queue the first TRB, even if it's zero-length */
  5288. for (i = 0; i < num_tds; i++) {
  5289. @@ -3729,9 +3823,13 @@ static int xhci_queue_isoc_tx(struct xhc
  5290. } else {
  5291. td->last_trb = ep_ring->enqueue;
  5292. field |= TRB_IOC;
  5293. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5294. + if (!(xhci->quirks & XHCI_AVOID_BEI)) {
  5295. +#else
  5296. if (xhci->hci_version == 0x100 &&
  5297. !(xhci->quirks &
  5298. XHCI_AVOID_BEI)) {
  5299. +#endif
  5300. /* Set BEI bit except for the last td */
  5301. if (i < num_tds - 1)
  5302. field |= TRB_BEI;
  5303. @@ -3746,6 +3844,7 @@ static int xhci_queue_isoc_tx(struct xhc
  5304. trb_buff_len = td_remain_len;
  5305. /* Set the TRB length, TD size, & interrupter fields. */
  5306. +#if !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5307. if (xhci->hci_version < 0x100) {
  5308. remainder = xhci_td_remainder(
  5309. td_len - running_total);
  5310. @@ -3755,6 +3854,10 @@ static int xhci_queue_isoc_tx(struct xhc
  5311. total_packet_count, urb,
  5312. (trbs_per_td - j - 1));
  5313. }
  5314. +#else
  5315. + remainder = mtk_xhci_td_remainder(urb->transfer_buffer_length, running_total, max_packet, trb_buff_len);
  5316. +#endif
  5317. +
  5318. length_field = TRB_LEN(trb_buff_len) |
  5319. remainder |
  5320. TRB_INTR_TARGET(0);
  5321. --- a/drivers/usb/host/xhci.c
  5322. +++ b/drivers/usb/host/xhci.c
  5323. @@ -30,6 +30,16 @@
  5324. #include "xhci.h"
  5325. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5326. +#include <asm/uaccess.h>
  5327. +#include <linux/dma-mapping.h>
  5328. +#include <linux/platform_device.h>
  5329. +#include "mtk-phy.h"
  5330. +#include "xhci-mtk-scheduler.h"
  5331. +#include "xhci-mtk-power.h"
  5332. +#include "xhci-mtk.h"
  5333. +#endif
  5334. +
  5335. #define DRIVER_AUTHOR "Sarah Sharp"
  5336. #define DRIVER_DESC "'eXtensible' Host Controller (xHC) Driver"
  5337. @@ -38,6 +48,18 @@ static int link_quirk;
  5338. module_param(link_quirk, int, S_IRUGO | S_IWUSR);
  5339. MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB");
  5340. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5341. +long xhci_mtk_test_unlock_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
  5342. +static struct file_operations xhci_mtk_test_fops = {
  5343. + .owner = THIS_MODULE,
  5344. + .read = xhci_mtk_test_read,
  5345. + .write = xhci_mtk_test_write,
  5346. + .unlocked_ioctl = xhci_mtk_test_unlock_ioctl,
  5347. + .open = xhci_mtk_test_open,
  5348. + .release = xhci_mtk_test_release,
  5349. +};
  5350. +#endif
  5351. +
  5352. /* TODO: copied from ehci-hcd.c - can this be refactored? */
  5353. /*
  5354. * xhci_handshake - spin reading hc until handshake completes or fails
  5355. @@ -189,7 +211,7 @@ int xhci_reset(struct xhci_hcd *xhci)
  5356. return ret;
  5357. }
  5358. -#ifdef CONFIG_PCI
  5359. +#if defined (CONFIG_PCI) && !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5360. static int xhci_free_msi(struct xhci_hcd *xhci)
  5361. {
  5362. int i;
  5363. @@ -389,6 +411,7 @@ static int xhci_try_enable_msi(struct us
  5364. return ret;
  5365. }
  5366. hcd->irq = pdev->irq;
  5367. +
  5368. return 0;
  5369. }
  5370. @@ -430,6 +453,11 @@ static void compliance_mode_recovery(uns
  5371. xhci_dbg(xhci, "Attempting compliance mode recovery\n");
  5372. hcd = xhci->shared_hcd;
  5373. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5374. + temp |= (1 << 31);
  5375. + xhci_writel(xhci, temp, xhci->usb3_ports[i]);
  5376. +#endif
  5377. +
  5378. if (hcd->state == HC_STATE_SUSPENDED)
  5379. usb_hcd_resume_root_hub(hcd);
  5380. @@ -478,6 +506,9 @@ bool xhci_compliance_mode_recovery_timer
  5381. {
  5382. const char *dmi_product_name, *dmi_sys_vendor;
  5383. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5384. + return true;
  5385. +#endif
  5386. dmi_product_name = dmi_get_system_info(DMI_PRODUCT_NAME);
  5387. dmi_sys_vendor = dmi_get_system_info(DMI_SYS_VENDOR);
  5388. if (!dmi_product_name || !dmi_sys_vendor)
  5389. @@ -521,6 +552,10 @@ int xhci_init(struct usb_hcd *hcd)
  5390. } else {
  5391. xhci_dbg(xhci, "xHCI doesn't need link TRB QUIRK\n");
  5392. }
  5393. +
  5394. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5395. + mtk_xhci_scheduler_init();
  5396. +#endif
  5397. retval = xhci_mem_init(xhci, GFP_KERNEL);
  5398. xhci_dbg(xhci, "Finished xhci_init\n");
  5399. @@ -664,7 +699,11 @@ int xhci_run(struct usb_hcd *hcd)
  5400. xhci_dbg(xhci, "// Set the interrupt modulation register\n");
  5401. temp = xhci_readl(xhci, &xhci->ir_set->irq_control);
  5402. temp &= ~ER_IRQ_INTERVAL_MASK;
  5403. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5404. + temp |= (u32) 16;
  5405. +#else
  5406. temp |= (u32) 160;
  5407. +#endif
  5408. xhci_writel(xhci, temp, &xhci->ir_set->irq_control);
  5409. /* Set the HCD state before we enable the irqs */
  5410. @@ -685,6 +724,9 @@ int xhci_run(struct usb_hcd *hcd)
  5411. xhci_queue_vendor_command(xhci, 0, 0, 0,
  5412. TRB_TYPE(TRB_NEC_GET_FW));
  5413. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5414. + enableXhciAllPortPower(xhci);
  5415. +#endif
  5416. xhci_dbg(xhci, "Finished xhci_run for USB2 roothub\n");
  5417. return 0;
  5418. }
  5419. @@ -1002,7 +1044,6 @@ int xhci_resume(struct xhci_hcd *xhci, b
  5420. /* If restore operation fails, re-initialize the HC during resume */
  5421. if ((temp & STS_SRE) || hibernated) {
  5422. -
  5423. if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
  5424. !(xhci_all_ports_seen_u0(xhci))) {
  5425. del_timer_sync(&xhci->comp_mode_recovery_timer);
  5426. @@ -1586,6 +1627,13 @@ int xhci_drop_endpoint(struct usb_hcd *h
  5427. u32 drop_flag;
  5428. u32 new_add_flags, new_drop_flags, new_slot_info;
  5429. int ret;
  5430. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5431. +#if MTK_SCH_NEW
  5432. + struct sch_ep *sch_ep = NULL;
  5433. + int isTT;
  5434. + int ep_type;
  5435. +#endif
  5436. +#endif
  5437. ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
  5438. if (ret <= 0)
  5439. @@ -1637,6 +1685,40 @@ int xhci_drop_endpoint(struct usb_hcd *h
  5440. xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep);
  5441. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5442. +#if MTK_SCH_NEW
  5443. + slot_ctx = xhci_get_slot_ctx(xhci, xhci->devs[udev->slot_id]->out_ctx);
  5444. + if ((slot_ctx->tt_info & 0xff) > 0) {
  5445. + isTT = 1;
  5446. + }
  5447. + else {
  5448. + isTT = 0;
  5449. + }
  5450. + if (usb_endpoint_xfer_int(&ep->desc)) {
  5451. + ep_type = USB_EP_INT;
  5452. + }
  5453. + else if (usb_endpoint_xfer_isoc(&ep->desc)) {
  5454. + ep_type = USB_EP_ISOC;
  5455. + }
  5456. + else if (usb_endpoint_xfer_bulk(&ep->desc)) {
  5457. + ep_type = USB_EP_BULK;
  5458. + }
  5459. + else
  5460. + ep_type = USB_EP_CONTROL;
  5461. +
  5462. + sch_ep = mtk_xhci_scheduler_remove_ep(udev->speed, usb_endpoint_dir_in(&ep->desc)
  5463. + , isTT, ep_type, (mtk_u32 *)ep);
  5464. + if (sch_ep != NULL) {
  5465. + kfree(sch_ep);
  5466. + }
  5467. + else {
  5468. + xhci_dbg(xhci, "[MTK]Doesn't find ep_sch instance when removing endpoint\n");
  5469. + }
  5470. +#else
  5471. + mtk_xhci_scheduler_remove_ep(xhci, udev, ep);
  5472. +#endif
  5473. +#endif
  5474. +
  5475. xhci_dbg(xhci, "drop ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x, new slot info = %#x\n",
  5476. (unsigned int) ep->desc.bEndpointAddress,
  5477. udev->slot_id,
  5478. @@ -1672,6 +1754,18 @@ int xhci_add_endpoint(struct usb_hcd *hc
  5479. u32 new_add_flags, new_drop_flags, new_slot_info;
  5480. struct xhci_virt_device *virt_dev;
  5481. int ret = 0;
  5482. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5483. + struct xhci_ep_ctx *in_ep_ctx;
  5484. +#if MTK_SCH_NEW
  5485. + struct sch_ep *sch_ep;
  5486. + int isTT;
  5487. + int ep_type;
  5488. + int maxp = 0;
  5489. + int burst = 0;
  5490. + int mult = 0;
  5491. + int interval;
  5492. +#endif
  5493. +#endif
  5494. ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
  5495. if (ret <= 0) {
  5496. @@ -1734,6 +1828,56 @@ int xhci_add_endpoint(struct usb_hcd *hc
  5497. return -ENOMEM;
  5498. }
  5499. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5500. + in_ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index);
  5501. +#if MTK_SCH_NEW
  5502. + slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx);
  5503. + if ((slot_ctx->tt_info & 0xff) > 0) {
  5504. + isTT = 1;
  5505. + }
  5506. + else {
  5507. + isTT = 0;
  5508. + }
  5509. + if (usb_endpoint_xfer_int(&ep->desc)) {
  5510. + ep_type = USB_EP_INT;
  5511. + }
  5512. + else if (usb_endpoint_xfer_isoc(&ep->desc)) {
  5513. + ep_type = USB_EP_ISOC;
  5514. + }
  5515. + else if (usb_endpoint_xfer_bulk(&ep->desc)) {
  5516. + ep_type = USB_EP_BULK;
  5517. + }
  5518. + else
  5519. + ep_type = USB_EP_CONTROL;
  5520. +
  5521. + if (udev->speed == USB_SPEED_FULL || udev->speed == USB_SPEED_HIGH
  5522. + || udev->speed == USB_SPEED_LOW) {
  5523. + maxp = ep->desc.wMaxPacketSize & 0x7FF;
  5524. + burst = ep->desc.wMaxPacketSize >> 11;
  5525. + mult = 0;
  5526. + }
  5527. + else if (udev->speed == USB_SPEED_SUPER) {
  5528. + maxp = ep->desc.wMaxPacketSize & 0x7FF;
  5529. + burst = ep->ss_ep_comp.bMaxBurst;
  5530. + mult = ep->ss_ep_comp.bmAttributes & 0x3;
  5531. + }
  5532. + interval = (1 << ((in_ep_ctx->ep_info >> 16) & 0xff));
  5533. + sch_ep = kmalloc(sizeof(struct sch_ep), GFP_KERNEL);
  5534. + if (mtk_xhci_scheduler_add_ep(udev->speed, usb_endpoint_dir_in(&ep->desc),
  5535. + isTT, ep_type, maxp, interval, burst, mult, (mtk_u32 *)ep
  5536. + , (mtk_u32 *)in_ep_ctx, sch_ep) != SCH_SUCCESS) {
  5537. + xhci_err(xhci, "[MTK] not enough bandwidth\n");
  5538. +
  5539. + return -ENOSPC;
  5540. + }
  5541. +#else
  5542. + if (mtk_xhci_scheduler_add_ep(xhci, udev, ep, in_ep_ctx) != SCH_SUCCESS) {
  5543. + xhci_err(xhci, "[MTK] not enough bandwidth\n");
  5544. +
  5545. + return -ENOSPC;
  5546. + }
  5547. +#endif
  5548. +#endif
  5549. ctrl_ctx->add_flags |= cpu_to_le32(added_ctxs);
  5550. new_add_flags = le32_to_cpu(ctrl_ctx->add_flags);
  5551. @@ -2697,7 +2841,7 @@ int xhci_check_bandwidth(struct usb_hcd
  5552. if (ctrl_ctx->add_flags == cpu_to_le32(SLOT_FLAG) &&
  5553. ctrl_ctx->drop_flags == 0)
  5554. return 0;
  5555. -
  5556. +
  5557. xhci_dbg(xhci, "New Input Control Context:\n");
  5558. slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
  5559. xhci_dbg_ctx(xhci, virt_dev->in_ctx,
  5560. @@ -4233,10 +4377,14 @@ static u16 xhci_call_host_update_timeout
  5561. u16 *timeout)
  5562. {
  5563. if (state == USB3_LPM_U1) {
  5564. +#if !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5565. if (xhci->quirks & XHCI_INTEL_HOST)
  5566. +#endif
  5567. return xhci_calculate_intel_u1_timeout(udev, desc);
  5568. } else {
  5569. +#if !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5570. if (xhci->quirks & XHCI_INTEL_HOST)
  5571. +#endif
  5572. return xhci_calculate_intel_u2_timeout(udev, desc);
  5573. }
  5574. @@ -4662,7 +4810,9 @@ int xhci_gen_setup(struct usb_hcd *hcd,
  5575. /* Accept arbitrarily long scatter-gather lists */
  5576. hcd->self.sg_tablesize = ~0;
  5577. /* XHCI controllers don't stop the ep queue on short packets :| */
  5578. +#if !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5579. hcd->self.no_stop_on_short = 1;
  5580. +#endif
  5581. if (usb_hcd_is_primary_hcd(hcd)) {
  5582. xhci = kzalloc(sizeof(struct xhci_hcd), GFP_KERNEL);
  5583. @@ -4731,6 +4881,10 @@ int xhci_gen_setup(struct usb_hcd *hcd,
  5584. goto error;
  5585. xhci_dbg(xhci, "Reset complete\n");
  5586. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5587. + setInitialReg();
  5588. +#endif
  5589. +
  5590. temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
  5591. if (HCC_64BIT_ADDR(temp)) {
  5592. xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
  5593. @@ -4755,8 +4909,21 @@ MODULE_DESCRIPTION(DRIVER_DESC);
  5594. MODULE_AUTHOR(DRIVER_AUTHOR);
  5595. MODULE_LICENSE("GPL");
  5596. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5597. +static struct platform_device xhci_platform_dev = {
  5598. + .name = "xhci-hcd",
  5599. + .id = -1,
  5600. + .dev = {
  5601. + .coherent_dma_mask = 0xffffffff,
  5602. + },
  5603. +};
  5604. +#endif
  5605. +
  5606. static int __init xhci_hcd_init(void)
  5607. {
  5608. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5609. + struct platform_device *pPlatformDev;
  5610. +#endif
  5611. int retval;
  5612. retval = xhci_register_pci();
  5613. @@ -4769,6 +4936,33 @@ static int __init xhci_hcd_init(void)
  5614. printk(KERN_DEBUG "Problem registering platform driver.");
  5615. goto unreg_pci;
  5616. }
  5617. +
  5618. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5619. + retval = register_chrdev(XHCI_MTK_TEST_MAJOR, DEVICE_NAME, &xhci_mtk_test_fops);
  5620. +
  5621. + u3phy_init();
  5622. + if (u3phy_ops->u2_slew_rate_calibration) {
  5623. + u3phy_ops->u2_slew_rate_calibration(u3phy);
  5624. + u3phy_ops->u2_slew_rate_calibration(u3phy_p1);
  5625. + }
  5626. + else{
  5627. + printk(KERN_ERR "WARN: PHY doesn't implement u2 slew rate calibration function\n");
  5628. + }
  5629. + u3phy_ops->init(u3phy);
  5630. + reinitIP();
  5631. +
  5632. + pPlatformDev = &xhci_platform_dev;
  5633. + memset(pPlatformDev, 0, sizeof(struct platform_device));
  5634. + pPlatformDev->name = "xhci-hcd";
  5635. + pPlatformDev->id = -1;
  5636. + pPlatformDev->dev.coherent_dma_mask = 0xffffffff;
  5637. + pPlatformDev->dev.dma_mask = &pPlatformDev->dev.coherent_dma_mask;
  5638. +
  5639. + retval = platform_device_register(&xhci_platform_dev);
  5640. + if (retval < 0)
  5641. + xhci_unregister_plat();
  5642. +#endif
  5643. +
  5644. /*
  5645. * Check the compiler generated sizes of structures that must be laid
  5646. * out in specific ways for hardware access.
  5647. @@ -4786,6 +4980,7 @@ static int __init xhci_hcd_init(void)
  5648. BUILD_BUG_ON(sizeof(struct xhci_intr_reg) != 8*32/8);
  5649. /* xhci_run_regs has eight fields and embeds 128 xhci_intr_regs */
  5650. BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8);
  5651. +
  5652. return 0;
  5653. unreg_pci:
  5654. xhci_unregister_pci();
  5655. --- a/drivers/usb/host/xhci.h
  5656. +++ b/drivers/usb/host/xhci.h
  5657. @@ -29,9 +29,24 @@
  5658. #include <linux/usb/hcd.h>
  5659. /* Code sharing between pci-quirks and xhci hcd */
  5660. -#include "xhci-ext-caps.h"
  5661. +#include "xhci-ext-caps.h"
  5662. #include "pci-quirks.h"
  5663. +#if defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5664. +#define XHC_IRQ (22 + 8)
  5665. +#define XHC_IO_START 0x1E1C0000
  5666. +#define XHC_IO_LENGTH 0x10000
  5667. +/* mtk scheduler bitmasks */
  5668. +#define BPKTS(p) ((p) & 0x3f)
  5669. +#define BCSCOUNT(p) (((p) & 0x7) << 8)
  5670. +#define BBM(p) ((p) << 11)
  5671. +#define BOFFSET(p) ((p) & 0x3fff)
  5672. +#define BREPEAT(p) (((p) & 0x7fff) << 16)
  5673. +#endif
  5674. +
  5675. +
  5676. +
  5677. +
  5678. /* xHCI PCI Configuration Registers */
  5679. #define XHCI_SBRN_OFFSET (0x60)
  5680. @@ -1536,8 +1551,12 @@ struct xhci_hcd {
  5681. /* Compliance Mode Recovery Data */
  5682. struct timer_list comp_mode_recovery_timer;
  5683. u32 port_status_u0;
  5684. +#ifdef CONFIG_USB_MT7621_XHCI_PLATFORM
  5685. +#define COMP_MODE_RCVRY_MSECS 5000
  5686. +#else
  5687. /* Compliance Mode Timer Triggered every 2 seconds */
  5688. #define COMP_MODE_RCVRY_MSECS 2000
  5689. +#endif
  5690. };
  5691. /* convert between an HCD pointer and the corresponding EHCI_HCD */
  5692. @@ -1703,7 +1722,7 @@ void xhci_urb_free_priv(struct xhci_hcd
  5693. void xhci_free_command(struct xhci_hcd *xhci,
  5694. struct xhci_command *command);
  5695. -#ifdef CONFIG_PCI
  5696. +#if defined (CONFIG_PCI) && !defined (CONFIG_USB_MT7621_XHCI_PLATFORM)
  5697. /* xHCI PCI glue */
  5698. int xhci_register_pci(void);
  5699. void xhci_unregister_pci(void);