0062-mt7621-add-ECHI-OCHI-XCHI-support.patch 212 KB

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