001-arch.patch 277 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864
  1. --- a/arch/arm/Kconfig
  2. +++ b/arch/arm/Kconfig
  3. @@ -220,6 +220,9 @@ config ARCH_EP93XX
  4. help
  5. This enables support for the Cirrus EP93xx series of CPUs.
  6. +config ARCH_SL2312
  7. + bool "SL2312"
  8. +
  9. config ARCH_FOOTBRIDGE
  10. bool "FootBridge"
  11. select FOOTBRIDGE
  12. @@ -414,6 +417,8 @@ source "arch/arm/mach-ep93xx/Kconfig"
  13. source "arch/arm/mach-footbridge/Kconfig"
  14. +source "arch/arm/mach-sl2312/Kconfig"
  15. +
  16. source "arch/arm/mach-integrator/Kconfig"
  17. source "arch/arm/mach-iop32x/Kconfig"
  18. @@ -549,6 +554,16 @@ config PCI
  19. config PCI_SYSCALL
  20. def_bool PCI
  21. +config SL2312_LPC
  22. + bool "LPC Host Support"
  23. + depends on ARCH_SL2312
  24. + help
  25. +
  26. +config SL2312_LPC_IT8712
  27. + bool "IT8712 Support"
  28. + depends on ARCH_SL2312 && SL2312_LPC
  29. + help
  30. +
  31. # Select the host bridge type
  32. config PCI_HOST_VIA82C505
  33. bool
  34. @@ -988,6 +1003,10 @@ if ALIGNMENT_TRAP || !CPU_CP15_MMU
  35. source "drivers/mtd/Kconfig"
  36. endif
  37. +if ARCH_SL2312
  38. +source "drivers/telephony/Kconfig"
  39. +endif
  40. +
  41. source "drivers/parport/Kconfig"
  42. source "drivers/pnp/Kconfig"
  43. @@ -997,7 +1016,7 @@ source "drivers/block/Kconfig"
  44. if PCMCIA || ARCH_CLPS7500 || ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX \
  45. || ARCH_L7200 || ARCH_LH7A40X || ARCH_PXA || ARCH_RPC \
  46. || ARCH_S3C2410 || ARCH_SA1100 || ARCH_SHARK || FOOTBRIDGE \
  47. - || ARCH_IXP23XX
  48. + || ARCH_IXP23XX || ARCH_SL2312
  49. source "drivers/ide/Kconfig"
  50. endif
  51. --- a/arch/arm/Makefile
  52. +++ b/arch/arm/Makefile
  53. @@ -72,6 +72,7 @@ tune-$(CONFIG_CPU_ARM920T) :=-mtune=arm9
  54. tune-$(CONFIG_CPU_ARM922T) :=-mtune=arm9tdmi
  55. tune-$(CONFIG_CPU_ARM925T) :=-mtune=arm9tdmi
  56. tune-$(CONFIG_CPU_ARM926T) :=-mtune=arm9tdmi
  57. +tune-$(CONFIG_CPU_FA52X) :=-mtune=arm9tdmi
  58. tune-$(CONFIG_CPU_SA110) :=-mtune=strongarm110
  59. tune-$(CONFIG_CPU_SA1100) :=-mtune=strongarm1100
  60. tune-$(CONFIG_CPU_XSCALE) :=$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale
  61. @@ -111,6 +112,7 @@ endif
  62. machine-$(CONFIG_ARCH_PXA) := pxa
  63. machine-$(CONFIG_ARCH_L7200) := l7200
  64. machine-$(CONFIG_ARCH_INTEGRATOR) := integrator
  65. + machine-$(CONFIG_ARCH_SL2312) := sl2312
  66. textofs-$(CONFIG_ARCH_CLPS711X) := 0x00028000
  67. machine-$(CONFIG_ARCH_CLPS711X) := clps711x
  68. machine-$(CONFIG_ARCH_IOP32X) := iop32x
  69. --- a/arch/arm/boot/compressed/Makefile
  70. +++ b/arch/arm/boot/compressed/Makefile
  71. @@ -19,6 +19,10 @@ ifeq ($(CONFIG_ARCH_SHARK),y)
  72. OBJS += head-shark.o ofw-shark.o
  73. endif
  74. +ifeq ($(CONFIG_ARCH_SL2312),y)
  75. +OBJS += head-sl2312.o
  76. +endif
  77. +
  78. ifeq ($(CONFIG_ARCH_L7200),y)
  79. OBJS += head-l7200.o
  80. endif
  81. --- /dev/null
  82. +++ b/arch/arm/boot/compressed/head-sl2312.S
  83. @@ -0,0 +1,6 @@
  84. +#include <asm/mach-types.h>
  85. +#include <asm/arch/sl2312.h>
  86. +
  87. + .section ".start", "ax"
  88. + mov r7, #MACH_TYPE_SL2312
  89. +
  90. --- a/arch/arm/boot/compressed/head.S
  91. +++ b/arch/arm/boot/compressed/head.S
  92. @@ -57,6 +57,17 @@
  93. mov \rb, #0x50000000
  94. add \rb, \rb, #0x4000 * CONFIG_S3C_LOWLEVEL_UART_PORT
  95. .endm
  96. +/*****************************************************
  97. + * for Storlink SoC
  98. + *****************************************************/
  99. +#elif defined(CONFIG_ARCH_SL2312)
  100. + .macro loadsp, rb
  101. + mov \rb, #0x16000000
  102. + .endm
  103. + .macro writeb, rb
  104. + strb \rb, [r3, #0]
  105. + .endm
  106. +/****************************************************/
  107. #else
  108. .macro loadsp, rb
  109. addruart \rb
  110. @@ -116,7 +127,28 @@ start:
  111. .rept 8
  112. mov r0, r0
  113. .endr
  114. -
  115. +/*****************************************************************************
  116. + * for Storlink Soc -- on chip UART
  117. + *****************************************************************************/
  118. +#ifndef CONFIG_SERIAL_IT8712 // Jason test
  119. +@ mov r3, #0x22000000
  120. + mov r3, #0x42000000
  121. + mov r11, #0x80
  122. + strb r11, [r3, #0xc]
  123. + mov r11, #0x0
  124. + strb r11, [r3, #0x4]
  125. +#ifndef CONFIG_SL3516_ASIC
  126. + mov r11, #0x9C /*0x9c->19200 0x4E->38400 0x34->57600 */
  127. +#else
  128. + mov r11, #0x9C /* 0x61 for 30MHz on GeminiA chip*/
  129. +#endif
  130. + strb r11, [r3, #0x0]
  131. + mov r11, #0x03
  132. + strb r11, [r3, #0xc]
  133. + mov r11, #0xFB
  134. + strb r11, [r3, #0x18]
  135. +#endif
  136. +/*****************************************************************************/
  137. b 1f
  138. .word 0x016f2818 @ Magic numbers to help the loader
  139. .word start @ absolute load/run zImage address
  140. @@ -458,6 +490,39 @@ __armv7_mmu_cache_on:
  141. mcr p15, 0, r0, c7, c5, 4 @ ISB
  142. mov pc, r12
  143. +/*****************************************************************************
  144. + * for Storlink Soc -- CPU cache
  145. + *****************************************************************************/
  146. +__fa526_cache_on:
  147. + mov r12, lr
  148. + bl __setup_mmu
  149. + mov r0, #0
  150. + mcr p15, 0, r0, c7, c6, 0 @ Invalidate D cache
  151. + mcr p15, 0, r0, c7, c5, 0 @ Invalidate I cache
  152. + mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  153. + mcr p15, 0, r0, c8, c7, 0 @ flush I,D TLBs
  154. + mcr p15, 0, r3, c2, c0, 0 @ load page table pointer
  155. + mov r0, #-1
  156. + mcr p15, 0, r0, c3, c0, 0 @ load domain access register
  157. + mrc p15, 0, r0, c1, c0, 0
  158. + mov r0, r0
  159. + mov r0, r0
  160. +#ifndef CONFIG_CPU_DCACHE_DISABLE
  161. + orr r0, r0, #0x0004 @ .... .... .... .1..
  162. +#endif
  163. +#ifndef CONFIG_CPU_ICACHE_DISABLE
  164. + orr r0, r0, #0x1000 @ ...1 .... .... ....
  165. +#endif
  166. +
  167. +#ifndef DEBUG
  168. + orr r0, r0, #0x0039 @ Write buffer, mmu
  169. +#endif
  170. + mcr p15, 0, r0, c1, c0
  171. + mov r0, r0
  172. + mov r0, r0
  173. + mov pc, r12
  174. +/********************************************************************************/
  175. +
  176. __arm6_mmu_cache_on:
  177. mov r12, lr
  178. bl __setup_mmu
  179. @@ -625,6 +690,16 @@ proc_types:
  180. @ These match on the architecture ID
  181. +/*****************************************************************************
  182. + * for Storlink Soc -- CPU architecture ID
  183. + *****************************************************************************/
  184. + .word 0x66015261 @ FA526
  185. + .word 0xff01fff1
  186. + b __fa526_cache_on
  187. + b __fa526_cache_off
  188. + b __fa526_cache_flush
  189. +/*****************************************************************************/
  190. +
  191. .word 0x00020000 @ ARMv4T
  192. .word 0x000f0000
  193. b __armv4_mmu_cache_on
  194. @@ -712,6 +787,23 @@ __armv7_mmu_cache_off:
  195. mcr p15, 0, r0, c8, c7, 0 @ invalidate whole TLB
  196. mov pc, r12
  197. +/*****************************************************************************
  198. + * for Storlink Soc -- CPU cache
  199. + *****************************************************************************/
  200. +__fa526_cache_off:
  201. + mrc p15, 0, r0, c1, c0
  202. + bic r0, r0, #0x000d
  203. + mov r1, #0
  204. + mcr p15, 0, r1, c7, c14, 0 @ clean and invalidate D cache
  205. + mcr p15, 0, r1, c7, c10, 4 @ drain WB
  206. + mcr p15, 0, r0, c1, c0 @ turn MMU and cache off
  207. + mov r0, #0
  208. + mcr p15, 0, r0, c7, c5, 0 @ invalidate whole cache v4
  209. + mcr p15, 0, r0, c8, c7, 0 @ invalidate whole TLB v4
  210. + mov pc, lr
  211. +/*****************************************************************************/
  212. +
  213. +
  214. __arm6_mmu_cache_off:
  215. mov r0, #0x00000030 @ ARM6 control reg.
  216. b __armv3_mmu_cache_off
  217. @@ -759,6 +851,17 @@ __armv4_mpu_cache_flush:
  218. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  219. mov pc, lr
  220. +/*****************************************************************************
  221. + * for Storlink Soc -- CPU cache
  222. + *****************************************************************************/
  223. +__fa526_cache_flush:
  224. + mov r1, #0
  225. + mcr p15, 0, r1, c7, c14, 0 @ clean and invalidate D cache
  226. + mcr p15, 0, r1, c7, c5, 0 @ flush I cache
  227. + mcr p15, 0, r1, c7, c10, 4 @ drain WB
  228. + mov pc, lr
  229. +/*****************************************************************************/
  230. +
  231. __armv6_mmu_cache_flush:
  232. mov r1, #0
  233. --- /dev/null
  234. +++ b/arch/arm/boot/compressed/it8712.h
  235. @@ -0,0 +1,25 @@
  236. +
  237. +#ifndef __IT8712_H__
  238. +#define __IT8712_H__
  239. +
  240. +#include "asm/arch/sl2312.h"
  241. +
  242. +#define IT8712_IO_BASE SL2312_LPC_IO_BASE
  243. +//#define IT8712_IO_BASE 0x27000000
  244. +// Device LDN
  245. +#define LDN_SERIAL1 0x01
  246. +#define LDN_SERIAL2 0x02
  247. +#define LDN_PARALLEL 0x03
  248. +#define LDN_KEYBOARD 0x05
  249. +#define LDN_MOUSE 0x06
  250. +#define LDN_GPIO 0x07
  251. +
  252. +#define IT8712_UART1_PORT 0x3F8
  253. +#define IT8712_UART2_PORT 0x2F8
  254. +
  255. +#define IT8712_GPIO_BASE 0x800 // 0x800-0x804 for GPIO set1-set5
  256. +
  257. +void LPCSetConfig(char LdnNumber, char Index, char data);
  258. +char LPCGetConfig(char LdnNumber, char Index);
  259. +
  260. +#endif
  261. --- a/arch/arm/boot/compressed/misc.c
  262. +++ b/arch/arm/boot/compressed/misc.c
  263. @@ -30,7 +30,7 @@ static void putstr(const char *ptr);
  264. #include <asm/arch/uncompress.h>
  265. #ifdef CONFIG_DEBUG_ICEDCC
  266. -
  267. +#include "it8712.h"
  268. #ifdef CONFIG_CPU_V6
  269. static void icedcc_putc(int ch)
  270. @@ -69,6 +69,7 @@ static void icedcc_putc(int ch)
  271. #define flush() do { } while (0)
  272. #endif
  273. +#if 0
  274. static void putstr(const char *ptr)
  275. {
  276. char c;
  277. @@ -81,11 +82,36 @@ static void putstr(const char *ptr)
  278. flush();
  279. }
  280. +#endif
  281. #endif
  282. #define __ptr_t void *
  283. +#ifdef CONFIG_SERIAL_IT8712
  284. +unsigned int it8712_uart_base;
  285. +#define UART_RX 0
  286. +#define UART_TX 0
  287. +#define UART_DLL 0
  288. +#define UART_TRG 0
  289. +#define UART_DLM 1
  290. +#define UART_IER 1
  291. +#define UART_FCTR 1
  292. +#define UART_IIR 2
  293. +#define UART_FCR 2
  294. +#define UART_EFR 2
  295. +#define UART_LCR 3
  296. +#define UART_MCR 4
  297. +#define UART_LSR 5
  298. +#define UART_MSR 6
  299. +#define UART_SCR 7
  300. +#define UART_EMSR 7
  301. +void LPCEnterMBPnP(void);
  302. +void LPCExitMBPnP(void);
  303. +int SearchIT8712(void);
  304. +int InitLPCInterface(void);
  305. +#endif
  306. +
  307. /*
  308. * Optimised C version of memzero for the ARM.
  309. */
  310. @@ -346,6 +372,9 @@ ulg
  311. decompress_kernel(ulg output_start, ulg free_mem_ptr_p, ulg free_mem_ptr_end_p,
  312. int arch_id)
  313. {
  314. +#ifdef CONFIG_SERIAL_IT8712
  315. + unsigned char *addr;
  316. +#endif
  317. output_data = (uch *)output_start; /* Points to kernel start */
  318. free_mem_ptr = free_mem_ptr_p;
  319. free_mem_ptr_end = free_mem_ptr_end_p;
  320. @@ -353,6 +382,33 @@ decompress_kernel(ulg output_start, ulg
  321. arch_decomp_setup();
  322. +#ifdef CONFIG_SERIAL_IT8712
  323. +
  324. + InitLPCInterface();
  325. + LPCSetConfig(0, 0x02, 0x01);
  326. + LPCSetConfig(LDN_SERIAL1, 0x30, 0x1);
  327. + LPCSetConfig(LDN_SERIAL1, 0x23, 0x0);
  328. + it8712_uart_base = IT8712_IO_BASE;
  329. + it8712_uart_base += ((LPCGetConfig(LDN_SERIAL1, 0x60) << 8) + LPCGetConfig(LDN_SERIAL1, 0x61));
  330. +
  331. + do {
  332. + addr = (unsigned char *)(it8712_uart_base + UART_LCR) ;
  333. + *addr = 0x80;
  334. + // Set Baud Rate
  335. + addr = (unsigned char *)(it8712_uart_base+UART_DLL);
  336. + *addr = 0x06 ;
  337. + addr = (unsigned char *)(it8712_uart_base+UART_DLM);
  338. + *addr = 0x00 ;
  339. +
  340. + addr = (unsigned char *)(it8712_uart_base+UART_LCR); // LCR
  341. + *addr = 0x07 ;
  342. + addr = (unsigned char *)(it8712_uart_base+UART_MCR); // MCR
  343. + *addr = 0x08 ;
  344. + addr = (unsigned char *)(it8712_uart_base+UART_FCR); // FCR
  345. + *addr = 0x01 ;
  346. + } while(0);
  347. +#endif
  348. +
  349. makecrc();
  350. putstr("Uncompressing Linux...");
  351. gunzip();
  352. @@ -374,4 +430,119 @@ int main()
  353. return 0;
  354. }
  355. #endif
  356. +
  357. +#ifdef CONFIG_SERIAL_IT8712
  358. +
  359. +#define LPC_KEY_ADDR (unsigned char *)(SL2312_LPC_IO_BASE + 0x2e)
  360. +#define LPC_DATA_ADDR (unsigned char *)(SL2312_LPC_IO_BASE + 0x2f)
  361. +#define LPC_BUS_CTRL *( unsigned char*) (SL2312_LPC_HOST_BASE + 0)
  362. +#define LPC_BUS_STATUS *( unsigned char*) (SL2312_LPC_HOST_BASE + 2)
  363. +#define LPC_SERIAL_IRQ_CTRL *( unsigned char*) (SL2312_LPC_HOST_BASE + 4)
  364. +
  365. +char LPCGetConfig(char LdnNumber, char Index)
  366. +{
  367. + char rtn;
  368. + unsigned char *addr ;
  369. +
  370. + LPCEnterMBPnP(); // Enter IT8712 MB PnP mode
  371. +
  372. + addr = LPC_KEY_ADDR;
  373. + *addr = 0x07 ;
  374. +
  375. + addr = LPC_DATA_ADDR;
  376. + *addr = LdnNumber ;
  377. +
  378. + addr = LPC_KEY_ADDR;
  379. + *addr = Index ;
  380. +
  381. + addr = LPC_DATA_ADDR ;
  382. + rtn = *addr ;
  383. +
  384. + LPCExitMBPnP();
  385. + return rtn;
  386. +
  387. +}
  388. +
  389. +void LPCSetConfig(char LdnNumber, char Index, char data)
  390. +{
  391. + unsigned char *addr;
  392. + LPCEnterMBPnP(); // Enter IT8712 MB PnP mode
  393. + addr = LPC_KEY_ADDR;
  394. + *addr = 0x07;
  395. + addr = LPC_DATA_ADDR;
  396. + *addr = LdnNumber;
  397. + addr = LPC_KEY_ADDR;
  398. + *addr = Index;
  399. + addr = LPC_DATA_ADDR;
  400. + *addr = data;
  401. +
  402. + LPCExitMBPnP();
  403. +}
  404. +
  405. +//unsigned char key[4] ;
  406. +void LPCEnterMBPnP(void)
  407. +{
  408. + unsigned char *addr;
  409. + addr = LPC_KEY_ADDR;
  410. + unsigned char key[4] = {0x87, 0x01, 0x55, 0x55};
  411. +
  412. + do {
  413. + *addr = key[0];
  414. + *addr = key[1];
  415. + *addr = key[2];
  416. + *addr = key[3];
  417. + }while(0);
  418. +}
  419. +
  420. +void LPCExitMBPnP(void)
  421. +{
  422. + unsigned char *addr;
  423. + addr = LPC_KEY_ADDR;
  424. + *addr = 0x02 ;
  425. +
  426. + addr = LPC_DATA_ADDR;
  427. + *addr = 0x02 ;
  428. +}
  429. +
  430. +int InitLPCInterface(void)
  431. +{
  432. + int i;
  433. + LPC_BUS_CTRL = 0xc0;
  434. + LPC_SERIAL_IRQ_CTRL = 0xc0;
  435. +
  436. + for(i=0;i<0x2000;i++) ;
  437. +
  438. + LPC_SERIAL_IRQ_CTRL = 0x80;
  439. + if (!SearchIT8712()) ;
  440. +// while(1);
  441. + return 0;
  442. +}
  443. +
  444. +int SearchIT8712(void)
  445. +{
  446. + unsigned char Id1, Id2;
  447. + unsigned short Id;
  448. + unsigned char *addr;
  449. +
  450. + LPCEnterMBPnP();
  451. + addr = LPC_KEY_ADDR;
  452. + *addr = 0x20 ;
  453. + addr = LPC_DATA_ADDR;
  454. + Id1 = *addr ;
  455. +
  456. + addr = LPC_KEY_ADDR;
  457. + *addr = 0x21 ;
  458. + addr = LPC_DATA_ADDR;
  459. + Id2 = *addr ;
  460. +
  461. + Id = (Id1 << 8) | Id2;
  462. + LPCExitMBPnP();
  463. +
  464. + if (Id == 0x8712)
  465. + return 1;
  466. + else
  467. + return 0;
  468. +}
  469. +
  470. +#endif
  471. --- a/arch/arm/kernel/entry-armv.S
  472. +++ b/arch/arm/kernel/entry-armv.S
  473. @@ -18,6 +18,8 @@
  474. #include <asm/memory.h>
  475. #include <asm/glue.h>
  476. #include <asm/vfpmacros.h>
  477. +#include <asm/arch/irqs.h>
  478. +#include <asm/hardware.h>
  479. #include <asm/arch/entry-macro.S>
  480. #include <asm/thread_notify.h>
  481. --- a/arch/arm/kernel/irq.c
  482. +++ b/arch/arm/kernel/irq.c
  483. @@ -40,6 +40,8 @@
  484. #include <asm/system.h>
  485. #include <asm/mach/time.h>
  486. +extern int fixup_irq(unsigned int irq);
  487. +
  488. /*
  489. * No architecture-specific irq_finish function defined in arm/arch/irqs.h.
  490. */
  491. @@ -111,8 +113,11 @@ static struct irq_desc bad_irq_desc = {
  492. asmlinkage void __exception asm_do_IRQ(unsigned int irq, struct pt_regs *regs)
  493. {
  494. struct pt_regs *old_regs = set_irq_regs(regs);
  495. - struct irq_desc *desc = irq_desc + irq;
  496. +// struct irq_desc *desc = irq_desc + irq;
  497. + struct irq_desc *desc;
  498. + irq = fixup_irq(irq);
  499. + desc = irq_desc + irq;
  500. /*
  501. * Some hardware gives randomly wrong interrupts. Rather
  502. * than crashing, do something sensible.
  503. --- a/arch/arm/kernel/process.c
  504. +++ b/arch/arm/kernel/process.c
  505. @@ -117,7 +117,7 @@ void arm_machine_restart(char mode)
  506. void (*pm_idle)(void);
  507. EXPORT_SYMBOL(pm_idle);
  508. -void (*pm_power_off)(void);
  509. +//void (*pm_power_off)(void);
  510. EXPORT_SYMBOL(pm_power_off);
  511. void (*arm_pm_restart)(char str) = arm_machine_restart;
  512. @@ -188,13 +188,37 @@ __setup("reboot=", reboot_setup);
  513. void machine_halt(void)
  514. {
  515. + unsigned int reg_v;
  516. +
  517. + printk("arch_power_off\n");
  518. +
  519. + reg_v = readl(IO_ADDRESS(SL2312_POWER_CTRL_BASE) + 0x04);
  520. + reg_v &= ~0x00000002;
  521. + reg_v |= 0x1;
  522. + mdelay(5);
  523. + // Power off
  524. + __raw_writel( reg_v, IO_ADDRESS(SL2312_POWER_CTRL_BASE) + 0x04);
  525. +
  526. }
  527. void machine_power_off(void)
  528. {
  529. - if (pm_power_off)
  530. + unsigned int reg_v;
  531. +
  532. +// if (pm_power_off)
  533. + if (&pm_power_off!=NULL)
  534. pm_power_off();
  535. +
  536. + printk("arch_power_off\n");
  537. +
  538. + reg_v = readl(IO_ADDRESS(SL2312_POWER_CTRL_BASE) + 0x04);
  539. + reg_v &= ~0x00000002;
  540. + reg_v |= 0x1;
  541. + mdelay(5);
  542. + // Power off
  543. + __raw_writel( reg_v, IO_ADDRESS(SL2312_POWER_CTRL_BASE) + 0x04);
  544. +
  545. }
  546. void machine_restart(char * __unused)
  547. --- a/arch/arm/kernel/time.c
  548. +++ b/arch/arm/kernel/time.c
  549. @@ -502,8 +502,13 @@ static int __init timer_init_sysfs(void)
  550. device_initcall(timer_init_sysfs);
  551. +extern unsigned int rtc_get_time_second(void);
  552. +
  553. void __init time_init(void)
  554. {
  555. +#ifdef CONFIG_SL2312_RTC
  556. + xtime.tv_sec = rtc_get_time_second() ;
  557. +#endif
  558. #ifndef CONFIG_GENERIC_TIME
  559. if (system_timer->offset == NULL)
  560. system_timer->offset = dummy_gettimeoffset;
  561. --- /dev/null
  562. +++ b/arch/arm/mach-sl2312/Kconfig
  563. @@ -0,0 +1,33 @@
  564. +
  565. +menu "SL2312"
  566. +
  567. +config SL3516_ASIC
  568. + bool "SL3516 ASIC version"
  569. + depends on ARCH_SL2312
  570. + help
  571. + This option to select AISC or FPGA
  572. +config PCI
  573. + bool "SL2312 PCI"
  574. + depends on ARCH_SL2312
  575. + help
  576. + This option to enable Storlink PCI controller
  577. +
  578. +config SL2312_LPC
  579. + bool "SL2312 LPC"
  580. + depends on ARCH_SL2312
  581. + help
  582. + This option to enable Low Pin Count controller
  583. +
  584. +config SL2312_USB
  585. + bool "SL2312 USB"
  586. + depends on ARCH_SL2312
  587. + help
  588. + This option to enable USB OTG host controller
  589. +
  590. +config GEMINI_IPI
  591. + bool "Gemini IPI test"
  592. + depends on ARCH_SL2312
  593. + help
  594. + Enable this option to test dual cpu Inter-Processor-Interrupt
  595. +endmenu
  596. +
  597. --- /dev/null
  598. +++ b/arch/arm/mach-sl2312/Makefile
  599. @@ -0,0 +1,16 @@
  600. +#
  601. +# Makefile for the linux kernel.
  602. +#
  603. +
  604. +# Object file lists.
  605. +
  606. +obj-y := arch.o irq.o mm.o time.o sl3516_device.o
  607. +obj-m :=
  608. +obj-n :=
  609. +
  610. +
  611. +obj-$(CONFIG_PCI) += pci.o
  612. +obj-$(CONFIG_SL2312_LPC) += lpc.o
  613. +obj-$(CONFIG_SL2312_USB) += sl2312-otg.o # sl2312-otg-1.o
  614. +obj-$(CONFIG_GEMINI_XOR_ACCE) += xor.o
  615. +obj-$(CONFIG_GEMINI_IPI) += gemini_ipi.o
  616. --- /dev/null
  617. +++ b/arch/arm/mach-sl2312/Makefile.boot
  618. @@ -0,0 +1,5 @@
  619. + zreladdr-y := 0x00008000
  620. +params_phys-y := 0x00508100
  621. +#params_phys-y := 0x00008100
  622. +initrd_phys-y := 0x00800000
  623. +
  624. --- /dev/null
  625. +++ b/arch/arm/mach-sl2312/arch.c
  626. @@ -0,0 +1,72 @@
  627. +/*
  628. + * linux/arch/arm/mach-epxa10db/arch.c
  629. + *
  630. + * Copyright (C) 2000 Deep Blue Solutions Ltd
  631. + * Copyright (C) 2001 Altera Corporation
  632. + *
  633. + * This program is free software; you can redistribute it and/or modify
  634. + * it under the terms of the GNU General Public License as published by
  635. + * the Free Software Foundation; either version 2 of the License, or
  636. + * (at your option) any later version.
  637. + *
  638. + * This program is distributed in the hope that it will be useful,
  639. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  640. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  641. + * GNU General Public License for more details.
  642. + *
  643. + * You should have received a copy of the GNU General Public License
  644. + * along with this program; if not, write to the Free Software
  645. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  646. + */
  647. +#include <linux/types.h>
  648. +#include <linux/init.h>
  649. +
  650. +#include <asm/hardware.h>
  651. +#include <asm/setup.h>
  652. +#include <asm/mach-types.h>
  653. +#include <asm/mach/time.h>
  654. +#include <asm/mach/arch.h>
  655. +
  656. +extern void sl2312_map_io(void);
  657. +extern void sl2312_init_irq(void);
  658. +extern unsigned long sl2312_gettimeoffset (void);
  659. +extern void __init sl2312_time_init(void);
  660. +
  661. +static struct sys_timer sl2312_timer = {
  662. + .init = sl2312_time_init,
  663. + .offset = sl2312_gettimeoffset,
  664. +};
  665. +
  666. +static void __init
  667. +sl2312_fixup(struct machine_desc *desc, struct tag *tags,
  668. + char **cmdline, struct meminfo *mi)
  669. +{
  670. + mi->nr_banks = 1;
  671. + mi->bank[0].start = 0;
  672. +#ifdef CONFIG_GEMINI_IPI
  673. + mi->bank[0].size = (64*1024*1024); // 128M
  674. +#else
  675. + mi->bank[0].size = (128*1024*1024); // 128M
  676. +#endif
  677. + mi->bank[0].node = 0;
  678. +}
  679. +
  680. +/* MACHINE_START(SL2312, "GeminiA")
  681. + MAINTAINER("Storlink Semi")
  682. + BOOT_MEM(0x00000000, 0x90000000, 0xf0000000)
  683. + FIXUP(sl2312_fixup)
  684. + MAPIO(sl2312_map_io)
  685. + INITIRQ(sl2312_init_irq)
  686. + .timer = &sl2312_timer,
  687. +MACHINE_END */
  688. +
  689. +MACHINE_START(SL2312, "GeminiA")
  690. + /* .phys_ram = 0x00000000, */
  691. + .phys_io = 0x7fffc000,
  692. + .io_pg_offst = ((0xffffc000) >> 18) & 0xfffc,
  693. + .boot_params = 0x100,
  694. + .fixup = sl2312_fixup,
  695. + .map_io = sl2312_map_io,
  696. + .init_irq = sl2312_init_irq,
  697. + .timer = &sl2312_timer,
  698. +MACHINE_END
  699. --- /dev/null
  700. +++ b/arch/arm/mach-sl2312/gemini_ipi.c
  701. @@ -0,0 +1,593 @@
  702. +/*
  703. + * FILE NAME sl_cir.c
  704. + *
  705. + * BRIEF MODULE DESCRIPTION
  706. + * IPI Driver for CPU1.
  707. + *
  708. + * Author: StorLink, Corp.
  709. + * Jason Lee
  710. + *
  711. + * Copyright 2002~2006 StorLink, Corp.
  712. + *
  713. + * This program is free software; you can redistribute it and/or modify it
  714. + * under the terms of the GNU General Public License as published by the
  715. + * Free Software Foundation; either version 2 of the License, or (at your
  716. + * option) any later version.
  717. + *
  718. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  719. + * WARRANTIES, INCLUDING, BUT NOT LIMit8712D TO, THE IMPLIED WARRANTIES OF
  720. + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  721. + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  722. + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  723. + * NOT LIMit8712D TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  724. + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  725. + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  726. + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  727. + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  728. + *
  729. + * You should have received a copy of the GNU General Public License along
  730. + * with this program; if not, writ8712 to the Free Software Foundation, Inc.,
  731. + * 675 Mass Ave, Cambridge, MA 02139, USA.
  732. + */
  733. +
  734. +#include <linux/module.h>
  735. +#include <linux/types.h>
  736. +#include <linux/kernel.h>
  737. +#include <linux/miscdevice.h>
  738. +#include <linux/init.h>
  739. +#include <linux/pagemap.h>
  740. +#include <asm/uaccess.h>
  741. +#include <linux/ioport.h>
  742. +#include <linux/sched.h>
  743. +#include <linux/delay.h>
  744. +#include <linux/fs.h>
  745. +#include <linux/interrupt.h>
  746. +#include <asm/io.h>
  747. +#include <asm/delay.h>
  748. +#include <linux/signal.h>
  749. +#include <asm/arch/sl2312.h>
  750. +#include <asm/arch/int_ctrl.h>
  751. +#include <asm/arch/ipi.h>
  752. +#include <linux/dma-mapping.h>
  753. +
  754. +
  755. +#include <linux/mm.h>
  756. +
  757. +#include <linux/bootmem.h>
  758. +
  759. +#include <asm/hardware.h>
  760. +#include <asm/page.h>
  761. +#include <asm/setup.h>
  762. +#include <asm/pgtable.h>
  763. +#include <asm/pgalloc.h>
  764. +
  765. +#include <asm/mach/map.h>
  766. +
  767. +
  768. +static int sl_ipi_debug = 1 ;
  769. +#define DEB(x) if(sl_ipi_debug>=1) x
  770. +
  771. +#define SRAM_PTR IO_ADDRESS(SL2312_SRAM_BASE)
  772. +volatile JSCALE_REQ_T *req=(JSCALE_REQ_T*)SRAM_PTR;
  773. +volatile JSCALE_RSP_T *rsp=(JSCALE_RSP_T*)(SRAM_PTR+0x20);
  774. +
  775. +unsigned int jscale_status=0;
  776. +
  777. +#define JSCALE_WAIT 0
  778. +#define XXXXXX_WAIT 1
  779. +#define MAX_WAIT_Q 8
  780. +wait_queue_head_t gemini_ipi_wait[MAX_WAIT_Q];
  781. +
  782. +#define DRAMCTL_DMA_CTL 0X20
  783. +#define DRAMCTL_DMA_SA 0X24
  784. +#define DRAMCTL_DMA_DA 0X28
  785. +#define DRAMCTL_DMA_CNT 0X2C
  786. +#define MEMCPY_UNIT 0x40000
  787. +int hw_memcpy(const void *to, const void *from, unsigned int bytes)
  788. +{
  789. + unsigned int reg_a,reg_d;
  790. + int count = bytes,i=0;
  791. +
  792. + consistent_sync((unsigned int *)to, bytes, DMA_BIDIRECTIONAL);
  793. + consistent_sync((unsigned int *)from,bytes, DMA_TO_DEVICE);
  794. +
  795. + DEB(printk("hwmemcpy:count %d\n",count));
  796. + while(count>0){
  797. + // SA
  798. + reg_a = IO_ADDRESS(SL2312_DRAM_CTRL_BASE)+DRAMCTL_DMA_SA;
  799. + reg_d = (unsigned int )__virt_to_phys(from) + i*MEMCPY_UNIT;
  800. + DEB(printk("hwmemcpy:from 0x%08x\n",reg_d));
  801. + writel(reg_d,reg_a);
  802. + // DA
  803. + reg_a = IO_ADDRESS(SL2312_DRAM_CTRL_BASE)+DRAMCTL_DMA_DA;
  804. + reg_d = (unsigned int )__virt_to_phys(to) + i*MEMCPY_UNIT;
  805. + writel(reg_d,reg_a);
  806. + DEB(printk("hwmemcpy:to 0x%08x\n",reg_d));
  807. + // byte count
  808. + reg_a = IO_ADDRESS(SL2312_DRAM_CTRL_BASE)+DRAMCTL_DMA_CNT;
  809. + reg_d = (count>=MEMCPY_UNIT)?MEMCPY_UNIT:count;
  810. + writel(reg_d,reg_a);
  811. + // start DMA
  812. + reg_a = IO_ADDRESS(SL2312_DRAM_CTRL_BASE)+DRAMCTL_DMA_CTL;
  813. + writel(0x80000001,reg_a);
  814. +
  815. + do{
  816. + cond_resched();
  817. +// msleep(4);
  818. + reg_d = readl(IO_ADDRESS(SL2312_DRAM_CTRL_BASE)+DRAMCTL_DMA_CTL);
  819. + }while(reg_d&0x1);
  820. +
  821. + count -= MEMCPY_UNIT;
  822. + i++;
  823. + }
  824. +
  825. + return bytes;
  826. +}
  827. +
  828. +static irqreturn_t ipi_interrupt()
  829. +{
  830. + unsigned int id=getcpuid(),tmp;
  831. +
  832. + //dmac_inv_range(__phys_to_virt(SL2312_SRAM_BASE),__phys_to_virt(SHAREADDR)+0x2000);
  833. +
  834. +
  835. + // Clear Interrupt
  836. + if(id==CPU0) {
  837. + tmp = readl(CPU1_STATUS);
  838. + tmp &= ~CPU_IPI_BIT_MASK;
  839. + writel(tmp,CPU1_STATUS);
  840. + }
  841. + else{
  842. + tmp = readl(CPU0_STATUS);
  843. + tmp &= ~CPU_IPI_BIT_MASK;
  844. + writel(tmp,CPU0_STATUS);
  845. + }
  846. +
  847. + //
  848. + DEB(printk("ipi interrupt:0x%x\n",rsp->status));
  849. + switch(rsp->status){
  850. + case JSCALE_STATUS_OK:
  851. +
  852. + break;
  853. + case JSCALE_UNKNOWN_MSG_TYPE:
  854. +
  855. + break;
  856. + case JSCALE_FAILED_FILE_SIZE:
  857. +
  858. + break;
  859. + case JSCALE_FAILED_MALLOC:
  860. +
  861. + break;
  862. + case JSCALE_FAILED_FORMAT:
  863. +
  864. + break;
  865. + case JSCALE_DECODE_ERROR:
  866. +
  867. + break;
  868. +
  869. + }
  870. + jscale_status = rsp->status;
  871. +// wake_up(&gemini_ipi_wait[JSCALE_WAIT]);
  872. +
  873. + return IRQ_HANDLED;
  874. +}
  875. +
  876. +static int gemini_ipi_open(struct inode *inode, struct file *file)
  877. +{
  878. + DEB(printk("ipi open\n"));
  879. + return 0;
  880. +}
  881. +
  882. +
  883. +static int gemini_ipi_release(struct inode *inode, struct file *file)
  884. +{
  885. + DEB(printk("ipi release\n"));
  886. + return 0;
  887. +}
  888. +
  889. +
  890. +static int gemini_ipi_ioctl(struct inode *inode, struct file *file,
  891. + unsigned int cmd, unsigned long arg)
  892. +{
  893. + JSCALE_RSP_T tmp;
  894. +
  895. + switch(cmd) {
  896. + case GEMINI_IPI_JSCALE_REQ:
  897. + DEB(printk("ipi:ioctl jscale request %dX%d Q:%d\n",req->ScaledImageWidth,req->ScaledImageHeight,req->ScaledImageQuality));
  898. + if (copy_from_user(req, (JSCALE_REQ_T *)arg, sizeof(JSCALE_REQ_T)))
  899. + return -EFAULT;
  900. + req->hdr.type = IPC_JSCALE_REQ_MSG;
  901. + req->hdr.length = sizeof(JSCALE_REQ_T);
  902. + req->input_location = CPU_1_DATA_OFFSET;
  903. + req->output_location = CPU_1_DATA_OFFSET;
  904. + break;
  905. + case GEMINI_IPI_JSCALE_STAT:
  906. + DEB(printk("ipi:ioctl jscale stat \n"));
  907. + if(jscale_status==JSCALE_BUSY){ // not yet
  908. + tmp.status = JSCALE_BUSY;
  909. + if (copy_to_user((JSCALE_RSP_T *)arg,&tmp, sizeof(JSCALE_RSP_T)))
  910. + return -EFAULT;
  911. + }
  912. + else{ // finish or error
  913. + if (copy_to_user((JSCALE_RSP_T *)arg,rsp, sizeof(JSCALE_RSP_T)))
  914. + return -EFAULT;
  915. + }
  916. + break;
  917. + default:
  918. + printk("IPI: Error IOCTL number\n");
  919. + return -ENOIOCTLCMD;
  920. + }
  921. +
  922. + return 0;
  923. +}
  924. +
  925. +#define SRAM_SIZE 0x2000
  926. +static ssize_t gemini_ipi_write(struct file *file_p, const char *buf, size_t count, loff_t * ppos)
  927. +{
  928. + int i=0,tmp=0,j;
  929. + const char *ptr=(unsigned int)__phys_to_virt(CPU_1_MEM_BASE+CPU_1_DATA_OFFSET);
  930. + DEB(printk("ipi:write 0x%x to 0x%x length:%d\n",&buf,ptr,count));
  931. + memcpy(ptr,buf,count);
  932. + consistent_sync(ptr,count, DMA_TO_DEVICE);
  933. + //hw_memcpy(ptr,&buf,count);
  934. +
  935. +/* if(count>SRAM_SIZE){
  936. + for(i=0;i<(count/SRAM_SIZE);i++)
  937. + raid_memcpy(ptr+i*SRAM_SIZE,buf+i*SRAM_SIZE,SRAM_SIZE);
  938. + if(count%SRAM_SIZE)
  939. + raid_memcpy(ptr+i*SRAM_SIZE,buf+i*SRAM_SIZE,count%SRAM_SIZE);
  940. + }
  941. + else
  942. + raid_memcpy(ptr,buf,count);
  943. +*/
  944. +
  945. +/* for(i=0;i<count;i++){
  946. + if(buf[i]!=ptr[i])
  947. + printk("ipi error:offset %d valud %x[should %x]\n",i,ptr[i],buf[i]);
  948. + }
  949. +
  950. + printk("===========input buf===============\n");
  951. + for(i=0;i<64;i+=16){
  952. + for(j=0;j<16;j++)
  953. + printk("%02x ",buf[i+j]);
  954. + printk("\n");
  955. + cond_resched();
  956. + }
  957. + printk("===========output buf==============\n");
  958. + for(i=0;i<64;i+=16){
  959. + for(j=0;j<16;j++)
  960. + printk("%02x ",ptr[i+j]);
  961. + printk("\n");
  962. + cond_resched();
  963. + }
  964. +*/
  965. + // send irq for CPU1
  966. + tmp |= CPU_IPI_BIT_MASK;
  967. + writel(tmp,CPU0_STATUS);
  968. + jscale_status = JSCALE_BUSY;
  969. +
  970. + return count;
  971. +}
  972. +
  973. +static ssize_t gemini_ipi_read(struct file * file_p, char *buf, size_t length, loff_t * ppos)
  974. +{
  975. + int i=0;
  976. + const char *ptr=(unsigned int )__phys_to_virt(CPU_1_MEM_BASE+CPU_1_DATA_OFFSET);
  977. +
  978. + consistent_sync(ptr,length, DMA_FROM_DEVICE);
  979. + memcpy(buf,ptr,length);
  980. + DEB(printk("ipi:read 0x%x to 0x%x length:%d\n",ptr,buf,length));
  981. +
  982. + //consistent_sync((unsigned int *)ptr,0x2000, DMA_FROM_DEVICE); // invalid
  983. + //hw_memcpy(buf,ptr,length);
  984. +
  985. + // need encoded file size ********
  986. +/* if(count>SRAM_SIZE){
  987. + for(i=0;i<(count/SRAM_SIZE);i++)
  988. + raid_memcpy(buf+i*SRAM_SIZE,p_mbox->message+i*SRAM_SIZE,SRAM_SIZE);
  989. + if(count%0xFFFF)
  990. + raid_memcpy(buf+i*SRAM_SIZE,p_mbox->message+i*SRAM_SIZE,length%SRAM_SIZE);
  991. + }
  992. + else
  993. + raid_memcpy(buf,p_mbox->message,length);
  994. +*/
  995. + return length;
  996. +}
  997. +
  998. +void do_mapping_read(struct address_space *mapping,
  999. + struct file_ra_state *_ra,
  1000. + struct file *filp,
  1001. + loff_t *ppos,
  1002. + read_descriptor_t *desc,
  1003. + read_actor_t actor)
  1004. +{
  1005. + struct inode *inode = mapping->host;
  1006. + unsigned long index;
  1007. + unsigned long end_index;
  1008. + unsigned long offset;
  1009. + unsigned long last_index;
  1010. + unsigned long next_index;
  1011. + unsigned long prev_index;
  1012. + loff_t isize;
  1013. + struct page *cached_page;
  1014. + int error;
  1015. + struct file_ra_state ra = *_ra;
  1016. +
  1017. + cached_page = NULL;
  1018. + index = *ppos >> PAGE_CACHE_SHIFT;
  1019. + next_index = index;
  1020. + prev_index = ra.prev_page;
  1021. + last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT;
  1022. + offset = *ppos & ~PAGE_CACHE_MASK;
  1023. +
  1024. + isize = i_size_read(inode);
  1025. + if (!isize)
  1026. + goto out;
  1027. +
  1028. + end_index = (isize - 1) >> PAGE_CACHE_SHIFT;
  1029. + for (;;) {
  1030. + struct page *page;
  1031. + unsigned long nr, ret;
  1032. +
  1033. + /* nr is the maximum number of bytes to copy from this page */
  1034. + nr = PAGE_CACHE_SIZE;
  1035. + if (index >= end_index) {
  1036. + if (index > end_index)
  1037. + goto out;
  1038. + nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1;
  1039. + if (nr <= offset) {
  1040. + goto out;
  1041. + }
  1042. + }
  1043. + nr = nr - offset;
  1044. +
  1045. + cond_resched();
  1046. + if (index == next_index)
  1047. + next_index = page_cache_readahead(mapping, &ra, filp,
  1048. + index, last_index - index);
  1049. +
  1050. +find_page:
  1051. + page = find_get_page(mapping, index);
  1052. + if (unlikely(page == NULL)) {
  1053. + handle_ra_miss(mapping, &ra, index);
  1054. + goto no_cached_page;
  1055. + }
  1056. + if (!PageUptodate(page))
  1057. + goto page_not_up_to_date;
  1058. +page_ok:
  1059. +
  1060. + /* If users can be writing to this page using arbitrary
  1061. + * virtual addresses, take care about potential aliasing
  1062. + * before reading the page on the kernel side.
  1063. + */
  1064. + if (mapping_writably_mapped(mapping))
  1065. + flush_dcache_page(page);
  1066. +
  1067. + /*
  1068. + * When (part of) the same page is read multiple times
  1069. + * in succession, only mark it as accessed the first time.
  1070. + */
  1071. + if (prev_index != index)
  1072. + mark_page_accessed(page);
  1073. + prev_index = index;
  1074. +
  1075. + /*
  1076. + * Ok, we have the page, and it's up-to-date, so
  1077. + * now we can copy it to user space...
  1078. + *
  1079. + * The actor routine returns how many bytes were actually used..
  1080. + * NOTE! This may not be the same as how much of a user buffer
  1081. + * we filled up (we may be padding etc), so we can only update
  1082. + * "pos" here (the actor routine has to update the user buffer
  1083. + * pointers and the remaining count).
  1084. + */
  1085. + ret = actor(desc, page, offset, nr);
  1086. + offset += ret;
  1087. + index += offset >> PAGE_CACHE_SHIFT;
  1088. + offset &= ~PAGE_CACHE_MASK;
  1089. +
  1090. + page_cache_release(page);
  1091. + if (ret == nr && desc->count)
  1092. + continue;
  1093. + goto out;
  1094. +
  1095. +page_not_up_to_date:
  1096. + /* Get exclusive access to the page ... */
  1097. + lock_page(page);
  1098. +
  1099. + /* Did it get unhashed before we got the lock? */
  1100. + if (!page->mapping) {
  1101. + unlock_page(page);
  1102. + page_cache_release(page);
  1103. + continue;
  1104. + }
  1105. +
  1106. + /* Did somebody else fill it already? */
  1107. + if (PageUptodate(page)) {
  1108. + unlock_page(page);
  1109. + goto page_ok;
  1110. + }
  1111. +
  1112. +readpage:
  1113. + /* Start the actual read. The read will unlock the page. */
  1114. + error = mapping->a_ops->readpage(filp, page);
  1115. +
  1116. + if (unlikely(error))
  1117. + goto readpage_error;
  1118. +
  1119. + if (!PageUptodate(page)) {
  1120. + lock_page(page);
  1121. + if (!PageUptodate(page)) {
  1122. + if (page->mapping == NULL) {
  1123. + /*
  1124. + * invalidate_inode_pages got it
  1125. + */
  1126. + unlock_page(page);
  1127. + page_cache_release(page);
  1128. + goto find_page;
  1129. + }
  1130. + unlock_page(page);
  1131. + error = -EIO;
  1132. + goto readpage_error;
  1133. + }
  1134. + unlock_page(page);
  1135. + }
  1136. +
  1137. + /*
  1138. + * i_size must be checked after we have done ->readpage.
  1139. + *
  1140. + * Checking i_size after the readpage allows us to calculate
  1141. + * the correct value for "nr", which means the zero-filled
  1142. + * part of the page is not copied back to userspace (unless
  1143. + * another truncate extends the file - this is desired though).
  1144. + */
  1145. + isize = i_size_read(inode);
  1146. + end_index = (isize - 1) >> PAGE_CACHE_SHIFT;
  1147. + if (unlikely(!isize || index > end_index)) {
  1148. + page_cache_release(page);
  1149. + goto out;
  1150. + }
  1151. +
  1152. + /* nr is the maximum number of bytes to copy from this page */
  1153. + nr = PAGE_CACHE_SIZE;
  1154. + if (index == end_index) {
  1155. + nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1;
  1156. + if (nr <= offset) {
  1157. + page_cache_release(page);
  1158. + goto out;
  1159. + }
  1160. + }
  1161. + nr = nr - offset;
  1162. + goto page_ok;
  1163. +
  1164. +readpage_error:
  1165. + /* UHHUH! A synchronous read error occurred. Report it */
  1166. + desc->error = error;
  1167. + page_cache_release(page);
  1168. + goto out;
  1169. +
  1170. +no_cached_page:
  1171. + /*
  1172. + * Ok, it wasn't cached, so we need to create a new
  1173. + * page..
  1174. + */
  1175. + if (!cached_page) {
  1176. + cached_page = page_cache_alloc_cold(mapping);
  1177. + if (!cached_page) {
  1178. + desc->error = -ENOMEM;
  1179. + goto out;
  1180. + }
  1181. + }
  1182. + error = add_to_page_cache_lru(cached_page, mapping,
  1183. + index, GFP_KERNEL);
  1184. + if (error) {
  1185. + if (error == -EEXIST)
  1186. + goto find_page;
  1187. + desc->error = error;
  1188. + goto out;
  1189. + }
  1190. + page = cached_page;
  1191. + cached_page = NULL;
  1192. + goto readpage;
  1193. + }
  1194. +
  1195. +out:
  1196. + *_ra = ra;
  1197. +
  1198. + *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset;
  1199. + if (cached_page)
  1200. + page_cache_release(cached_page);
  1201. + if (filp)
  1202. + file_accessed(filp);
  1203. +}
  1204. +
  1205. +int ipi_send_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size)
  1206. +{
  1207. + ssize_t written;
  1208. + unsigned long count = desc->count;
  1209. + struct file *file = desc->arg.data;
  1210. + unsigned int *ptr_to=(unsigned int)__phys_to_virt(CPU_1_MEM_BASE+CPU_1_DATA_OFFSET) + desc->written;
  1211. + void *ptr_from;
  1212. +
  1213. + if (size > count)
  1214. + size = count;
  1215. +
  1216. + ptr_from = page_address(page)+offset;
  1217. + written = memcpy(ptr_to,ptr_from,size);
  1218. +
  1219. + if (written < 0) {
  1220. + desc->error = written;
  1221. + written = 0;
  1222. + }
  1223. + desc->count = count - written;
  1224. + desc->written += written;
  1225. + return written;
  1226. +}
  1227. +
  1228. +ssize_t gemini_ipi_sendfile(struct file *in_file, loff_t *ppos,
  1229. + size_t count, read_actor_t actor, void *TARGET)
  1230. +{
  1231. + read_descriptor_t desc;
  1232. +
  1233. + if (!count)
  1234. + return 0;
  1235. +
  1236. + desc.written = 0;
  1237. + desc.count = count;
  1238. + desc.arg.data = TARGET;
  1239. + desc.error = 0;
  1240. +
  1241. + do_mapping_read(in_file->f_mapping,&in_file->f_ra,in_file, ppos, &desc, ipi_send_actor);
  1242. +
  1243. + if (desc.written)
  1244. + return desc.written;
  1245. + return desc.error;
  1246. +}
  1247. +static struct file_operations gemini_ipi_fops = {
  1248. + .owner = THIS_MODULE,
  1249. + .ioctl = gemini_ipi_ioctl,
  1250. + .open = gemini_ipi_open,
  1251. + .release= gemini_ipi_release,
  1252. + .write = gemini_ipi_write,
  1253. + .read = gemini_ipi_read,
  1254. + .sendfile = gemini_ipi_sendfile,
  1255. +};
  1256. +
  1257. +#ifndef STORLINK_IPI
  1258. +#define STORLINK_IPI 242 // Documents/devices.txt suggest to use 240~255 for local driver!!
  1259. +#endif
  1260. +
  1261. +static struct miscdevice gemini_ipi_miscdev =
  1262. +{
  1263. + STORLINK_IPI,
  1264. + "slave_ipc",
  1265. + &gemini_ipi_fops
  1266. +};
  1267. +
  1268. +int __init sl_ipi_init(void)
  1269. +{
  1270. +
  1271. + printk("Gemini IPI Driver Initialization...\n");
  1272. + printk("REQ Head :0x%x(phy:0x%x)\n",(unsigned int)req,(unsigned int)SL2312_SRAM_BASE);
  1273. + printk("RSP Head :0x%x(phy:0x%x)\n",(unsigned int)rsp,(unsigned int)SL2312_SRAM_BASE+0x20);
  1274. + printk("Data buff:0x%x(phy:0x%x)\n",__phys_to_virt(CPU_1_MEM_BASE+CPU_1_DATA_OFFSET),CPU_1_MEM_BASE+CPU_1_DATA_OFFSET);
  1275. +
  1276. + misc_register(&gemini_ipi_miscdev);
  1277. +
  1278. + if (request_irq(IRQ_CPU0_IP_IRQ_OFFSET, ipi_interrupt, SA_INTERRUPT, "ipi", NULL))
  1279. + printk("Error: Register IRQ for Storlink IPI failed\n");
  1280. +
  1281. + return 0;
  1282. +}
  1283. +
  1284. +void __exit sl_ipi_exit(void)
  1285. +{
  1286. +
  1287. +}
  1288. +
  1289. +module_init(sl_ipi_init);
  1290. +module_exit(sl_ipi_exit);
  1291. +
  1292. +MODULE_AUTHOR("Jason Lee <[email protected]>");
  1293. +MODULE_DESCRIPTION("Storlink IPI driver");
  1294. +MODULE_LICENSE("GPL");
  1295. --- /dev/null
  1296. +++ b/arch/arm/mach-sl2312/hw_xor.h
  1297. @@ -0,0 +1,573 @@
  1298. +/*
  1299. +* linux/include/asm-arm/xor.h
  1300. +*
  1301. +* Copyright (C) 2001 Storlink Semi.
  1302. +* Jason Lee <[email protected]>
  1303. +*
  1304. +*/
  1305. +#include <asm/arch/sl2312.h>
  1306. +#include <asm/io.h>
  1307. +//#include <linux/compatmac.h>
  1308. +
  1309. +#undef BIG_ENDIAN
  1310. +#define CPU 0
  1311. +#define DMA 1
  1312. +
  1313. +#define DESC_NO 8
  1314. +#define TX_DESC_NUM DESC_NO
  1315. +#define RX_DESC_NUM DESC_NO
  1316. +
  1317. +#define RAID_BASE_ADDR IO_ADDRESS(SL2312_RAID_BASE)
  1318. +
  1319. +#define SRAM_PAR_0k 0
  1320. +#define SRAM_PAR_4k 1
  1321. +#define SRAM_PAR_8k 2
  1322. +#define SRAM_PAR_16k 3
  1323. +#define SRAM_PAR_SIZE SRAM_PAR_8k
  1324. +
  1325. +#define RUNNING 0x1
  1326. +#define COMPLETE 0x2
  1327. +#define ERROR 0x4
  1328. +
  1329. +#define CMD_XOR 0x0
  1330. +#define CMD_FILL 0x1
  1331. +#define CMD_CPY 0x3
  1332. +#define CMD_CHK 0x4
  1333. +
  1334. +enum RAID_DMA_REGISTER {
  1335. + RAID_DMA_DEVICE_ID = 0xff00,
  1336. + RAID_DMA_STATUS = 0xff04,
  1337. + RAID_FCHDMA_CTRL = 0xff08,
  1338. + RAID_FCHDMA_FIRST_DESC = 0xff0C,
  1339. + RAID_FCHDMA_CURR_DESC = 0xff10,
  1340. + RAID_STRDMA_CTRL = 0xff14,
  1341. + RAID_STRDMA_FIRST_DESC = 0xff18,
  1342. + RAID_STRDMA_CURR_DESC = 0xff1C,
  1343. + RAID_TX_FLG_REG = 0xff24,
  1344. + RAID_RX_FLG_REG = 0xff34,
  1345. + RAID_PCR = 0xff50,
  1346. + SMC_CMD_REG = 0xff60,
  1347. + SMC_STATUS_REG = 0xff64
  1348. + };
  1349. +
  1350. +enum RAID_FUNC_MODE {
  1351. + RAID_XOR = 0,
  1352. + RAID_MIX = 2,
  1353. + RAID_SRAM = 3,
  1354. + RAID_ENDIAN = 4,
  1355. + RAID_MEM_BLK = 5,
  1356. + RAID_MEM2MEM = 7,
  1357. + RAID_BUF_SIZE = 8,
  1358. + RAID_ERR_TEST = 9,
  1359. + RAID_BURST = 10,
  1360. + RAID_BUS = 11
  1361. + };
  1362. +
  1363. +typedef struct reg_info {
  1364. + int mask;
  1365. + char err[32];
  1366. + int offset;
  1367. +} REG_INFO;
  1368. +
  1369. +/********************************************************/
  1370. +/* the definition of RAID DMA Module Register */
  1371. +/********************************************************/
  1372. +typedef union
  1373. +{
  1374. + unsigned int bit32;
  1375. + struct bits_ff00
  1376. + {
  1377. + #ifdef BIG_ENDIAN
  1378. + unsigned int : 8;
  1379. + unsigned int teytPerr : 4; /* define protocol error under tsPErrI*/
  1380. + unsigned int reytPerr : 14; /* define protocol error under rsPErrI */
  1381. + unsigned int device_id : 12;
  1382. + unsigned int revision_id : 4;
  1383. + #else
  1384. + unsigned int revision_id : 4;
  1385. + unsigned int device_id : 12;
  1386. + unsigned int reytPerr : 14; /* define protocol error under rsPErrI */
  1387. + unsigned int teytPerr : 4; /* define protocol error under tsPErrI*/
  1388. + unsigned int : 8;
  1389. + #endif
  1390. + } bits;
  1391. +} RAID_DMA_DEVICE_ID_T;
  1392. +
  1393. +typedef union
  1394. +{
  1395. + unsigned int bits32;
  1396. + struct bits_ff04
  1397. + {
  1398. + #ifdef BIG_ENDIAN
  1399. + unsigned int tsFinishI : 1; /* owner bit error interrupt */
  1400. + unsigned int tsDErrI : 1; /* AHB bus error interrupt */
  1401. + unsigned int tsPErrI : 1; /* RAID XOR fetch descriptor protocol error interrupt */
  1402. + unsigned int tsEODI : 1; /* RAID XOR fetch DMA end of descriptor interrupt */
  1403. + unsigned int tsEOFI : 1; /* RAID XOR fetch DMA end of frame interrupt */
  1404. + unsigned int rsFinishI : 1; /* owner bit error interrupt */
  1405. + unsigned int rsDErrI : 1; /* AHB bus error while RAID XOR store interrupt */
  1406. + unsigned int rsPErrI : 1; /* RAID XOR store descriptor protocol error interrupt */
  1407. + unsigned int rsEODI : 1; /* RAID XOR store DMA end of descriptor interrupt */
  1408. + unsigned int rsEOFI : 1; /* RAID XOR store DMA end of frame interrupt */
  1409. + unsigned int inter : 8; /* pattern check error interrupt */
  1410. + unsigned int : 5;
  1411. + unsigned int Loopback : 1; /* loopback */
  1412. + unsigned int intEnable : 8; /*pattern check error interrupt enable */
  1413. + #else
  1414. + unsigned int intEnable : 8; /*pattern check error interrupt enable */
  1415. + unsigned int Loopback : 1; /* loopback */
  1416. + unsigned int : 5;
  1417. + unsigned int inter : 8; /* pattern check error interrupt */
  1418. + unsigned int rsEOFI : 1; /* RAID XOR store DMA end of frame interrupt */
  1419. + unsigned int rsEODI : 1; /* RAID XOR store DMA end of descriptor interrupt */
  1420. + unsigned int rsPErrI : 1; /* RAID XOR store descriptor protocol error interrupt */
  1421. + unsigned int rsDErrI : 1; /* AHB bus error while RAID XOR store interrupt */
  1422. + unsigned int rsFinishI : 1; /* owner bit error interrupt */
  1423. + unsigned int tsEOFI : 1; /* RAID XOR fetch DMA end of frame interrupt */
  1424. + unsigned int tsEODI : 1; /* RAID XOR fetch DMA end of descriptor interrupt */
  1425. + unsigned int tsPErrI : 1; /* RAID XOR fetch descriptor protocol error interrupt */
  1426. + unsigned int tsDErrI : 1; /* AHB bus error interrupt */
  1427. + unsigned int tsFinishI : 1; /* owner bit error interrupt */
  1428. + #endif
  1429. + } bits;
  1430. +} RAID_DMA_STATUS_T;
  1431. +
  1432. +
  1433. +typedef union
  1434. +{
  1435. + unsigned int bits32;
  1436. + struct bits_ff08
  1437. + {
  1438. + #ifdef BIG_ENDIAN
  1439. + unsigned int td_start : 1; /* Start DMA transfer */
  1440. + unsigned int td_continue : 1; /* Continue DMA operation */
  1441. + unsigned int td_chain_mode : 1; /* Descriptor Chain Mode;1-Descriptor Chain mode, 0-Direct DMA mode*/
  1442. + unsigned int : 1;
  1443. + unsigned int td_prot : 4; /* DMA protection control */
  1444. + unsigned int td_burst_size : 2; /* DMA max burst size for every AHB request */
  1445. + unsigned int td_bus : 2; /* peripheral bus width */
  1446. + unsigned int td_endian : 1; /* AHB Endian. 0-little endian; 1-big endian */
  1447. + unsigned int td_finish_en : 1; /* DMA Finish Event Interrupt Enable;1-enable;0-mask */
  1448. + unsigned int td_fail_en : 1; /* DMA Fail Interrupt Enable;1-enable;0-mask */
  1449. + unsigned int td_perr_en : 1; /* Protocol Failure Interrupt Enable;1-enable;0-mask */
  1450. + unsigned int td_eod_en : 1; /* End of Descriptor interrupt Enable;1-enable;0-mask */
  1451. + unsigned int td_eof_en : 1; /* End of frame interrupt Enable;1-enable;0-mask */
  1452. + unsigned int : 14;
  1453. + #else
  1454. + unsigned int : 14;
  1455. + unsigned int td_eof_en : 1; /* End of frame interrupt Enable;1-enable;0-mask */
  1456. + unsigned int td_eod_en : 1; /* End of Descriptor interrupt Enable;1-enable;0-mask */
  1457. + unsigned int td_perr_en : 1; /* Protocol Failure Interrupt Enable;1-enable;0-mask */
  1458. + unsigned int td_fail_en : 1; /* DMA Fail Interrupt Enable;1-enable;0-mask */
  1459. + unsigned int td_finish_en : 1; /* DMA Finish Event Interrupt Enable;1-enable;0-mask */
  1460. + unsigned int td_endian : 1; /* AHB Endian. 0-little endian; 1-big endian */
  1461. + unsigned int td_bus : 2; /* peripheral bus width;0 - 8 bits;1 - 16 bits */
  1462. + unsigned int td_burst_size : 2; /* TxDMA max burst size for every AHB request */
  1463. + unsigned int td_prot : 4; /* TxDMA protection control */
  1464. + unsigned int : 1;
  1465. + unsigned int td_chain_mode : 1; /* Descriptor Chain Mode;1-Descriptor Chain mode, 0-Direct DMA mode*/
  1466. + unsigned int td_continue : 1; /* Continue DMA operation */
  1467. + unsigned int td_start : 1; /* Start DMA transfer */
  1468. + #endif
  1469. + } bits;
  1470. +} RAID_TXDMA_CTRL_T;
  1471. +
  1472. +typedef union
  1473. +{
  1474. + unsigned int bits32;
  1475. + struct bits_ff0c
  1476. + {
  1477. + #ifdef BIG_ENDIAN
  1478. + unsigned int td_first_des_ptr : 28;/* first descriptor address */
  1479. + unsigned int td_busy : 1;/* 1-TxDMA busy; 0-TxDMA idle */
  1480. + unsigned int : 3;
  1481. + #else
  1482. + unsigned int : 3;
  1483. + unsigned int td_busy : 1;/* 1-TxDMA busy; 0-TxDMA idle */
  1484. + unsigned int td_first_des_ptr : 28;/* first descriptor address */
  1485. + #endif
  1486. + } bits;
  1487. +} RAID_TXDMA_FIRST_DESC_T;
  1488. +
  1489. +typedef union
  1490. +{
  1491. + unsigned int bits32;
  1492. + struct bits_ff10
  1493. + {
  1494. + #ifdef BIG_ENDIAN
  1495. + unsigned int ndar : 28; /* next descriptor address */
  1496. + unsigned int eofie : 1; /* end of frame interrupt enable */
  1497. + unsigned int : 1;
  1498. + unsigned int sof_eof : 2;
  1499. + #else
  1500. + unsigned int sof_eof : 2;
  1501. + unsigned int : 1;
  1502. + unsigned int eofie : 1; /* end of frame interrupt enable */
  1503. + unsigned int ndar : 28; /* next descriptor address */
  1504. + #endif
  1505. + } bits;
  1506. +} RAID_TXDMA_CURR_DESC_T;
  1507. +
  1508. +typedef union
  1509. +{
  1510. + unsigned int bits32;
  1511. + struct bits_ff14
  1512. + {
  1513. + #ifdef BIG_ENDIAN
  1514. + unsigned int rd_start : 1; /* Start DMA transfer */
  1515. + unsigned int rd_continue : 1; /* Continue DMA operation */
  1516. + unsigned int rd_chain_mode : 1; /* Descriptor Chain Mode;1-Descriptor Chain mode, 0-Direct DMA mode*/
  1517. + unsigned int : 1;
  1518. + unsigned int rd_prot : 4; /* DMA protection control */
  1519. + unsigned int rd_burst_size : 2; /* DMA max burst size for every AHB request */
  1520. + unsigned int rd_bus : 2; /* peripheral bus width;0 - 8 bits;1 - 16 bits */
  1521. + unsigned int rd_endian : 1; /* AHB Endian. 0-little endian; 1-big endian */
  1522. + unsigned int rd_finish_en : 1; /* DMA Finish Event Interrupt Enable;1-enable;0-mask */
  1523. + unsigned int rd_fail_en : 1; /* DMA Fail Interrupt Enable;1-enable;0-mask */
  1524. + unsigned int rd_perr_en : 1; /* Protocol Failure Interrupt Enable;1-enable;0-mask */
  1525. + unsigned int rd_eod_en : 1; /* End of Descriptor interrupt Enable;1-enable;0-mask */
  1526. + unsigned int rd_eof_en : 1; /* End of frame interrupt Enable;1-enable;0-mask */
  1527. + unsigned int : 14;
  1528. + #else
  1529. + unsigned int : 14;
  1530. + unsigned int rd_eof_en : 1; /* End of frame interrupt Enable;1-enable;0-mask */
  1531. + unsigned int rd_eod_en : 1; /* End of Descriptor interrupt Enable;1-enable;0-mask */
  1532. + unsigned int rd_perr_en : 1; /* Protocol Failure Interrupt Enable;1-enable;0-mask */
  1533. + unsigned int rd_fail_en : 1; /* DMA Fail Interrupt Enable;1-enable;0-mask */
  1534. + unsigned int rd_finish_en : 1; /* DMA Finish Event Interrupt Enable;1-enable;0-mask */
  1535. + unsigned int rd_endian : 1; /* AHB Endian. 0-little endian; 1-big endian */
  1536. + unsigned int rd_bus : 2; /* peripheral bus width;0 - 8 bits;1 - 16 bits */
  1537. + unsigned int rd_burst_size : 2; /* DMA max burst size for every AHB request */
  1538. + unsigned int rd_prot : 4; /* DMA protection control */
  1539. + unsigned int : 1;
  1540. + unsigned int rd_chain_mode : 1; /* Descriptor Chain Mode;1-Descriptor Chain mode, 0-Direct DMA mode*/
  1541. + unsigned int rd_continue : 1; /* Continue DMA operation */
  1542. + unsigned int rd_start : 1; /* Start DMA transfer */
  1543. + #endif
  1544. + } bits;
  1545. +} RAID_RXDMA_CTRL_T;
  1546. +
  1547. +typedef union
  1548. +{
  1549. + unsigned int bits32;
  1550. + struct bits_ff18
  1551. + {
  1552. + #ifdef BIG_ENDIAN
  1553. + unsigned int rd_first_des_ptr : 28;/* first descriptor address */
  1554. + unsigned int rd_busy : 1;/* 1-RxDMA busy; 0-RxDMA idle */
  1555. + unsigned int : 3;
  1556. + #else
  1557. + unsigned int : 3;
  1558. + unsigned int rd_busy : 1;/* 1-RxDMA busy; 0-RxDMA idle */
  1559. + unsigned int rd_first_des_ptr : 28;/* first descriptor address */
  1560. + #endif
  1561. + } bits;
  1562. +} RAID_RXDMA_FIRST_DESC_T;
  1563. +
  1564. +typedef union
  1565. +{
  1566. + unsigned int bits32;
  1567. + struct bits_ff1c
  1568. + {
  1569. + #ifdef BIG_ENDIAN
  1570. + unsigned int ndar : 28; /* next descriptor address */
  1571. + unsigned int eofie : 1; /* end of frame interrupt enable */
  1572. + unsigned int dec : 1; /* AHB bus address increment(0)/decrement(1) */
  1573. + unsigned int sof_eof : 2;
  1574. + #else
  1575. + unsigned int sof_eof : 2;
  1576. + unsigned int dec : 1; /* AHB bus address increment(0)/decrement(1) */
  1577. + unsigned int eofie : 1; /* end of frame interrupt enable */
  1578. + unsigned int ndar : 28; /* next descriptor address */
  1579. + #endif
  1580. + } bits;
  1581. +} RAID_RXDMA_CURR_DESC_T;
  1582. +
  1583. +typedef union
  1584. +{
  1585. + unsigned int bit32;
  1586. + struct bits_ff50
  1587. + {
  1588. + unsigned int pat : 32; /* data for pattern check */
  1589. + } bits;
  1590. +} RAID_PACR_T;
  1591. +
  1592. +/******************************************************/
  1593. +/* the definition of DMA Descriptor Register */
  1594. +/******************************************************/
  1595. +typedef struct raid_descriptor_t
  1596. +{
  1597. + union func_ctrl_t
  1598. + {
  1599. + unsigned int bit32;
  1600. + struct bits_0000
  1601. + {
  1602. + #ifdef BIG_ENDIAN
  1603. + unsigned int own : 1; /* owner bit */
  1604. + unsigned int derr : 1; /* data error during processing this descriptor */
  1605. + unsigned int perr : 1; /* protocol error during processing this descriptor */
  1606. + unsigned int raid_ctrl_status : 7; /* pass RAID XOR fetch/store control status to CPU */
  1607. + unsigned int desc_cnt : 6;
  1608. + unsigned int buffer_size : 16; /* transfer buffer size associated with current description*/
  1609. + #else
  1610. + unsigned int buffer_size : 16; /* transfer buffer size associated with current description*/
  1611. + unsigned int desc_cnt : 6;
  1612. + unsigned int raid_ctrl_status : 7; /* pass RAID XOR fetch/store control status to CPU */
  1613. + unsigned int perr : 1; /* protocol error during processing this descriptor */
  1614. + unsigned int derr : 1; /* data error during processing this descriptor */
  1615. + unsigned int own : 1; /* owner bit */
  1616. + #endif
  1617. + } bits;
  1618. + } func_ctrl;
  1619. +
  1620. + union flg_status_t
  1621. + {
  1622. + unsigned int bits32;
  1623. + struct bit_004
  1624. + {
  1625. + #ifdef BIG_ENDIAN
  1626. + unsigned int bcc : 16;
  1627. + unsigned int : 13
  1628. + unsigned int mode : 3;
  1629. + #else
  1630. + unsigned int mode : 3;
  1631. + unsigned int : 13;
  1632. + unsigned int bcc : 16;
  1633. + #endif
  1634. + } bits_cmd_status;
  1635. + } flg_status; //Sanders
  1636. +
  1637. + unsigned int buf_addr;
  1638. +
  1639. + union next_desc_addr_t
  1640. + {
  1641. + unsigned int bits32;
  1642. + struct bits_000c
  1643. + {
  1644. + #ifdef BIG_ENDIAN
  1645. + unsigned int ndar : 28; /* next descriptor address */
  1646. + unsigned int eofie : 1; /* end of frame interrupt enable */
  1647. + unsigned int : 1;
  1648. + unsigned int sof_eof : 2; /* the position of the descriptor in chain */
  1649. + #else
  1650. + unsigned int sof_eof : 2; /* the position of the descriptor in chain */
  1651. + unsigned int : 1;
  1652. + unsigned int eofie : 1; /* end of frame interrupt enable */
  1653. + unsigned int ndar : 28; /* next descriptor address */
  1654. + #endif
  1655. + } bits;
  1656. + } next_desc_addr;
  1657. +} RAID_DESCRIPTOR_T;
  1658. +
  1659. +/******************************************************/
  1660. +/* the offset of RAID SMC register */
  1661. +/******************************************************/
  1662. +enum RAID_SMC_REGISTER {
  1663. + RAID_SMC_CMD_REG = 0xff60,
  1664. + RAID_SMC_STATUS_REG = 0xff64
  1665. + };
  1666. +
  1667. +/******************************************************/
  1668. +/* the definition of RAID SMC module register */
  1669. +/******************************************************/
  1670. +typedef union
  1671. +{
  1672. + unsigned int bits32;
  1673. + struct bits_ff60
  1674. + {
  1675. + #ifdef BIG_ENDIAN
  1676. + unsigned int pat_mode : 2; /* partition mode selection */
  1677. + unsigned int : 14;
  1678. + unsigned int device_id : 12;
  1679. + unsigned int revision_id : 4;
  1680. + #else
  1681. + unsigned int revision_id : 4;
  1682. + unsigned int device_id : 12;
  1683. + unsigned int : 14;
  1684. + unsigned int pat_mode : 2; /* partition mode selection */
  1685. + #endif
  1686. + } bits;
  1687. +} RAID_SMC_CMD;
  1688. +
  1689. +typedef union
  1690. +{
  1691. + unsigned int bits32;
  1692. + struct bits_ff64
  1693. + {
  1694. + #ifdef BIG_ENDIAN
  1695. + unsigned int addr_err1 : 1; /* address is out of range for controller 1 */
  1696. + unsigned int ahb_err1 : 1; /* AHB bus error for controller 1 */
  1697. + unsigned int : 14;
  1698. + unsigned int addr_err2 : 1; /* address is out of range for controller 2 */
  1699. + unsigned int ahb_err2 : 1; /* AHB bus error for controller 2 */
  1700. + unsigned int : 14;
  1701. + #else
  1702. + unsigned int : 14;
  1703. + unsigned int ahb_err2 : 1; /* AHB bus error for controller 2 */
  1704. + unsigned int addr_err2 : 1; /* address is out of range for controller 2 */
  1705. + unsigned int : 14;
  1706. + unsigned int ahb_err1 : 1; /* AHB bus error for controller 1 */
  1707. + unsigned int addr_err1 : 1; /* address is out of range for controller 1 */
  1708. + #endif
  1709. + } bits;
  1710. +} RAID_SMC_STATUS;
  1711. +
  1712. +typedef struct RAID_S
  1713. +{
  1714. + const char *device_name;
  1715. + wait_queue_head_t wait;
  1716. + unsigned int busy;
  1717. + int irq;
  1718. + unsigned int status;
  1719. + RAID_DESCRIPTOR_T *tx_desc; /* point to virtual TX descriptor address */
  1720. + RAID_DESCRIPTOR_T *rx_desc; /* point ot virtual RX descriptor address */
  1721. + RAID_DESCRIPTOR_T *tx_cur_desc; /* current TX descriptor */
  1722. + RAID_DESCRIPTOR_T *rx_cur_desc; /* current RX descriptor */
  1723. + RAID_DESCRIPTOR_T *tx_finished_desc;
  1724. + RAID_DESCRIPTOR_T *rx_finished_desc;
  1725. + RAID_DESCRIPTOR_T *tx_first_desc;
  1726. + RAID_DESCRIPTOR_T *rx_first_desc;
  1727. +
  1728. +// unsigned int *tx_buf[TX_DESC_NUM];
  1729. + unsigned int *rx_desc_dma; // physical address of rx_descript
  1730. + unsigned int *tx_desc_dma; // physical address of tx_descript
  1731. + unsigned int *rx_bufs_dma;
  1732. + unsigned int *tx_bufs_dma;
  1733. +
  1734. +} RAID_T;
  1735. +
  1736. +struct reg_ioctl
  1737. +{
  1738. + unsigned int reg_addr;
  1739. + unsigned int val_in;
  1740. + unsigned int val_out;
  1741. +};
  1742. +
  1743. +typedef struct dma_ctrl {
  1744. + int sram;
  1745. + int prot;
  1746. + int burst;
  1747. + int bus;
  1748. + int endian;
  1749. + int mode;
  1750. +} DMA_CTRL;
  1751. +
  1752. +
  1753. +#ifdef XOR_SW_FILL_IN
  1754. +
  1755. +#define __XOR(a1, a2) a1 ^= a2
  1756. +
  1757. +#define GET_BLOCK_2(dst) \
  1758. + __asm__("ldmia %0, {%1, %2}" \
  1759. + : "=r" (dst), "=r" (a1), "=r" (a2) \
  1760. + : "0" (dst))
  1761. +
  1762. +#define GET_BLOCK_4(dst) \
  1763. + __asm__("ldmia %0, {%1, %2, %3, %4}" \
  1764. + : "=r" (dst), "=r" (a1), "=r" (a2), "=r" (a3), "=r" (a4) \
  1765. + : "0" (dst))
  1766. +
  1767. +#define XOR_BLOCK_2(src) \
  1768. + __asm__("ldmia %0!, {%1, %2}" \
  1769. + : "=r" (src), "=r" (b1), "=r" (b2) \
  1770. + : "0" (src)); \
  1771. + __XOR(a1, b1); __XOR(a2, b2);
  1772. +
  1773. +#define XOR_BLOCK_4(src) \
  1774. + __asm__("ldmia %0!, {%1, %2, %3, %4}" \
  1775. + : "=r" (src), "=r" (b1), "=r" (b2), "=r" (b3), "=r" (b4) \
  1776. + : "0" (src)); \
  1777. + __XOR(a1, b1); __XOR(a2, b2); __XOR(a3, b3); __XOR(a4, b4)
  1778. +
  1779. +#define PUT_BLOCK_2(dst) \
  1780. + __asm__ __volatile__("stmia %0!, {%2, %3}" \
  1781. + : "=r" (dst) \
  1782. + : "0" (dst), "r" (a1), "r" (a2))
  1783. +
  1784. +#define PUT_BLOCK_4(dst) \
  1785. + __asm__ __volatile__("stmia %0!, {%2, %3, %4, %5}" \
  1786. + : "=r" (dst) \
  1787. + : "0" (dst), "r" (a1), "r" (a2), "r" (a3), "r" (a4))
  1788. +
  1789. +static void
  1790. +xor_arm4regs_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
  1791. +{
  1792. + unsigned int lines = bytes / sizeof(unsigned long) / 4;
  1793. + register unsigned int a1 __asm__("r4");
  1794. + register unsigned int a2 __asm__("r5");
  1795. + register unsigned int a3 __asm__("r6");
  1796. + register unsigned int a4 __asm__("r7");
  1797. + register unsigned int b1 __asm__("r8");
  1798. + register unsigned int b2 __asm__("r9");
  1799. + register unsigned int b3 __asm__("ip");
  1800. + register unsigned int b4 __asm__("lr");
  1801. +
  1802. + do {
  1803. + GET_BLOCK_4(p1);
  1804. + XOR_BLOCK_4(p2);
  1805. + PUT_BLOCK_4(p1);
  1806. + } while (--lines);
  1807. +}
  1808. +
  1809. +static void
  1810. +xor_arm4regs_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
  1811. + unsigned long *p3)
  1812. +{
  1813. + unsigned int lines = bytes / sizeof(unsigned long) / 4;
  1814. + register unsigned int a1 __asm__("r4");
  1815. + register unsigned int a2 __asm__("r5");
  1816. + register unsigned int a3 __asm__("r6");
  1817. + register unsigned int a4 __asm__("r7");
  1818. + register unsigned int b1 __asm__("r8");
  1819. + register unsigned int b2 __asm__("r9");
  1820. + register unsigned int b3 __asm__("ip");
  1821. + register unsigned int b4 __asm__("lr");
  1822. +
  1823. + do {
  1824. + GET_BLOCK_4(p1);
  1825. + XOR_BLOCK_4(p2);
  1826. + XOR_BLOCK_4(p3);
  1827. + PUT_BLOCK_4(p1);
  1828. + } while (--lines);
  1829. +}
  1830. +
  1831. +static void
  1832. +xor_arm4regs_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
  1833. + unsigned long *p3, unsigned long *p4)
  1834. +{
  1835. + unsigned int lines = bytes / sizeof(unsigned long) / 2;
  1836. + register unsigned int a1 __asm__("r8");
  1837. + register unsigned int a2 __asm__("r9");
  1838. + register unsigned int b1 __asm__("ip");
  1839. + register unsigned int b2 __asm__("lr");
  1840. +
  1841. + do {
  1842. + GET_BLOCK_2(p1);
  1843. + XOR_BLOCK_2(p2);
  1844. + XOR_BLOCK_2(p3);
  1845. + XOR_BLOCK_2(p4);
  1846. + PUT_BLOCK_2(p1);
  1847. + } while (--lines);
  1848. +}
  1849. +
  1850. +static void
  1851. +xor_arm4regs_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
  1852. + unsigned long *p3, unsigned long *p4, unsigned long *p5)
  1853. +{
  1854. + unsigned int lines = bytes / sizeof(unsigned long) / 2;
  1855. + register unsigned int a1 __asm__("r8");
  1856. + register unsigned int a2 __asm__("r9");
  1857. + register unsigned int b1 __asm__("ip");
  1858. + register unsigned int b2 __asm__("lr");
  1859. +
  1860. + do {
  1861. + GET_BLOCK_2(p1);
  1862. + XOR_BLOCK_2(p2);
  1863. + XOR_BLOCK_2(p3);
  1864. + XOR_BLOCK_2(p4);
  1865. + XOR_BLOCK_2(p5);
  1866. + PUT_BLOCK_2(p1);
  1867. + } while (--lines);
  1868. +}
  1869. +#endif //XOR_SW_FILL_IN
  1870. +
  1871. --- /dev/null
  1872. +++ b/arch/arm/mach-sl2312/irq.c
  1873. @@ -0,0 +1,202 @@
  1874. +/*
  1875. + * linux/arch/arm/mach-epxa10db/irq.c
  1876. + *
  1877. + * Copyright (C) 2001 Altera Corporation
  1878. + *
  1879. + * This program is free software; you can redistribute it and/or modify
  1880. + * it under the terms of the GNU General Public License as published by
  1881. + * the Free Software Foundation; either version 2 of the License, or
  1882. + * (at your option) any later version.
  1883. + *
  1884. + * This program is distributed in the hope that it will be useful,
  1885. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1886. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1887. + * GNU General Public License for more details.
  1888. + *
  1889. + * You should have received a copy of the GNU General Public License
  1890. + * along with this program; if not, write to the Free Software
  1891. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  1892. + */
  1893. +#include <linux/init.h>
  1894. +#include <linux/ioport.h>
  1895. +#include <linux/stddef.h>
  1896. +#include <linux/list.h>
  1897. +#include <linux/sched.h>
  1898. +#include <asm/hardware.h>
  1899. +#include <asm/irq.h>
  1900. +#include <asm/io.h>
  1901. +#include <asm/mach/irq.h>
  1902. +#include <asm/arch/platform.h>
  1903. +#include <asm/arch/int_ctrl.h>
  1904. +
  1905. +#ifdef CONFIG_PCI
  1906. +#include <asm/arch/pci.h>
  1907. +#endif
  1908. +
  1909. +int fixup_irq(unsigned int irq)
  1910. +{
  1911. +#ifdef CONFIG_PCI
  1912. + if (irq == IRQ_PCI) {
  1913. + return sl2312_pci_get_int_src();
  1914. + }
  1915. +#endif
  1916. + return irq;
  1917. +}
  1918. +
  1919. +static void sl2312_ack_irq(unsigned int irq)
  1920. +{
  1921. + __raw_writel(1 << irq, IRQ_CLEAR(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1922. +}
  1923. +
  1924. +static void sl2312_mask_irq(unsigned int irq)
  1925. +{
  1926. + unsigned int mask;
  1927. +
  1928. +#ifdef CONFIG_PCI
  1929. + if (irq >= PCI_IRQ_OFFSET)
  1930. + {
  1931. + mask = __raw_readl(IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1932. + mask &= ~IRQ_PCI_MASK ;
  1933. + __raw_writel(mask, IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1934. + sl2312_pci_mask_irq(irq - PCI_IRQ_OFFSET);
  1935. + }
  1936. + else
  1937. +#endif
  1938. + if(irq >= FIQ_OFFSET)
  1939. + {
  1940. + mask = __raw_readl(FIQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1941. + mask &= ~(1 << (irq - FIQ_OFFSET));
  1942. + __raw_writel(mask, FIQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1943. + }
  1944. + else
  1945. + {
  1946. + mask = __raw_readl(IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1947. + mask &= ~(1 << irq);
  1948. + __raw_writel(mask, IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1949. + }
  1950. +
  1951. +}
  1952. +
  1953. +static void sl2312_unmask_irq(unsigned int irq)
  1954. +{
  1955. + unsigned int mask;
  1956. +
  1957. +#ifdef CONFIG_PCI
  1958. + if (irq >= PCI_IRQ_OFFSET)
  1959. + {
  1960. + mask = __raw_readl(IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1961. + mask |= IRQ_PCI_MASK ;
  1962. + __raw_writel(mask, IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1963. + sl2312_pci_unmask_irq(irq - PCI_IRQ_OFFSET);
  1964. + }
  1965. + else
  1966. +#endif
  1967. + if(irq >= FIQ_OFFSET)
  1968. + {
  1969. + mask = __raw_readl(FIQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1970. + mask |= (1 << (irq - FIQ_OFFSET));
  1971. + __raw_writel(mask, FIQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1972. + }
  1973. + else
  1974. + {
  1975. + mask = __raw_readl(IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1976. + mask |= (1 << irq);
  1977. + __raw_writel(mask, IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  1978. + }
  1979. +}
  1980. +
  1981. +static struct irq_chip sl2312_level_irq = {
  1982. + .ack = sl2312_mask_irq,
  1983. + .mask = sl2312_mask_irq,
  1984. + .unmask = sl2312_unmask_irq,
  1985. +// .set_type = ixp4xx_set_irq_type,
  1986. +};
  1987. +
  1988. +static struct irq_chip sl2312_edge_irq = {
  1989. + .ack = sl2312_ack_irq,
  1990. + .mask = sl2312_mask_irq,
  1991. + .unmask = sl2312_unmask_irq,
  1992. +// .set_type = ixp4xx_set_irq_type,
  1993. +};
  1994. +
  1995. +static struct resource irq_resource = {
  1996. + .name = "irq_handler",
  1997. + .start = IO_ADDRESS(SL2312_INTERRUPT_BASE),
  1998. + .end = IO_ADDRESS(FIQ_STATUS(SL2312_INTERRUPT_BASE))+4,
  1999. +};
  2000. +
  2001. +void __init sl2312_init_irq(void)
  2002. +{
  2003. + unsigned int i, mode, level;
  2004. +
  2005. + request_resource(&iomem_resource, &irq_resource);
  2006. +
  2007. + for (i = 0; i < NR_IRQS; i++)
  2008. + {
  2009. + if((i>=IRQ_TIMER1 && i<=IRQ_TIMER3)||(i>=IRQ_SERIRQ0 && i<=IRQ_SERIRQ_MAX))
  2010. + {
  2011. + set_irq_chip(i, &sl2312_edge_irq);
  2012. + set_irq_handler(i, handle_edge_irq);
  2013. + }
  2014. + else
  2015. + {
  2016. + set_irq_chip(i, &sl2312_level_irq);
  2017. + set_irq_handler(i,handle_level_irq);
  2018. + }
  2019. + set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
  2020. + }
  2021. +
  2022. + /* Disable all interrupt */
  2023. + __raw_writel(0,IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  2024. + __raw_writel(0,FIQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  2025. +
  2026. + /* Set interrupt mode */
  2027. + /* emac & ipsec type is level trigger and high active */
  2028. + mode = __raw_readl(IRQ_TMODE(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  2029. + level = __raw_readl(IRQ_TLEVEL(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  2030. +
  2031. + mode &= ~IRQ_GMAC0_MASK;
  2032. + level &= ~IRQ_GMAC0_MASK;
  2033. +
  2034. + mode &= ~IRQ_GMAC1_MASK;
  2035. + level &= ~IRQ_GMAC1_MASK;
  2036. +
  2037. + mode &= ~IRQ_IPSEC_MASK;
  2038. + level &= ~IRQ_IPSEC_MASK;
  2039. +
  2040. + // for IDE0,1, high active and level trigger
  2041. + mode &= ~IRQ_IDE0_MASK;
  2042. + level &= ~IRQ_IDE0_MASK;
  2043. + mode &= ~IRQ_IDE1_MASK;
  2044. + level &= ~IRQ_IDE1_MASK;
  2045. +
  2046. +
  2047. + // for PCI, high active and level trigger
  2048. + mode &= ~IRQ_PCI_MASK;
  2049. + level &= ~IRQ_PCI_MASK;
  2050. +
  2051. + // for USB, high active and level trigger
  2052. + mode &= ~IRQ_USB0_MASK;
  2053. + level &= ~IRQ_USB0_MASK;
  2054. +
  2055. + mode &= ~IRQ_USB1_MASK;
  2056. + level &= ~IRQ_USB1_MASK;
  2057. +
  2058. + // for LPC, high active and edge trigger
  2059. + mode |= 0xffff0000;
  2060. + level &= 0x0000ffff;
  2061. +
  2062. + // for GPIO, high active and level trigger
  2063. + mode &= ~(IRQ_GPIO_MASK);
  2064. + level &= ~(IRQ_GPIO_MASK);
  2065. +
  2066. + mode &= ~(IRQ_GPIO1_MASK);
  2067. + level &= ~(IRQ_GPIO1_MASK);
  2068. +
  2069. + mode &= ~(IRQ_GPIO2_MASK);
  2070. + level &= ~(IRQ_GPIO2_MASK);
  2071. +
  2072. + __raw_writel(mode,IRQ_TMODE(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  2073. + __raw_writel(level,IRQ_TLEVEL(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
  2074. +
  2075. +}
  2076. --- /dev/null
  2077. +++ b/arch/arm/mach-sl2312/lpc.c
  2078. @@ -0,0 +1,125 @@
  2079. +/*
  2080. + *
  2081. + * BRIEF MODULE DESCRIPTION
  2082. + * ITE Semi IT8712 Super I/O functions.
  2083. + *
  2084. + * Copyright 2001 MontaVista Software Inc.
  2085. + * Author: MontaVista Software, Inc.
  2086. + * [email protected] or [email protected]
  2087. + *
  2088. + * This program is free software; you can redistribute it and/or modify it
  2089. + * under the terms of the GNU General Public License as published by the
  2090. + * Free Software Foundation; either version 2 of the License, or (at your
  2091. + * option) any later version.
  2092. + *
  2093. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  2094. + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  2095. + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  2096. + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  2097. + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  2098. + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  2099. + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  2100. + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2101. + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  2102. + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2103. + *
  2104. + * You should have received a copy of the GNU General Public License along
  2105. + * with this program; if not, write to the Free Software Foundation, Inc.,
  2106. + * 675 Mass Ave, Cambridge, MA 02139, USA.
  2107. + */
  2108. +#include <linux/kernel.h>
  2109. +#include <linux/delay.h>
  2110. +#include <asm/io.h>
  2111. +#include <asm/types.h>
  2112. +#include <asm/arch/it8712.h>
  2113. +#include <linux/init.h>
  2114. +#include <asm/arch/hardware.h>
  2115. +
  2116. +#ifndef TRUE
  2117. +#define TRUE 1
  2118. +#endif
  2119. +
  2120. +#ifndef FALSE
  2121. +#define FALSE 0
  2122. +#endif
  2123. +
  2124. +
  2125. +// MB PnP configuration register
  2126. +#define LPC_KEY_ADDR (IO_ADDRESS(SL2312_LPC_IO_BASE) + 0x2e)
  2127. +#define LPC_DATA_ADDR (IO_ADDRESS(SL2312_LPC_IO_BASE) + 0x2f)
  2128. +
  2129. +#define LPC_BUS_CTRL *(volatile unsigned char*) (IO_ADDRESS(SL2312_LPC_HOST_BASE) + 0)
  2130. +#define LPC_BUS_STATUS *(volatile unsigned char*) (IO_ADDRESS(SL2312_LPC_HOST_BASE) + 2)
  2131. +#define LPC_SERIAL_IRQ_CTRL *(volatile unsigned char*) (IO_ADDRESS(SL2312_LPC_HOST_BASE) + 4)
  2132. +
  2133. +int it8712_exist;
  2134. +
  2135. +static void LPCEnterMBPnP(void)
  2136. +{
  2137. + int i;
  2138. + unsigned char key[4] = {0x87, 0x01, 0x55, 0x55};
  2139. +
  2140. + for (i = 0; i<4; i++)
  2141. + outb(key[i], LPC_KEY_ADDR);
  2142. +
  2143. +}
  2144. +
  2145. +static void LPCExitMBPnP(void)
  2146. +{
  2147. + outb(0x02, LPC_KEY_ADDR);
  2148. + outb(0x02, LPC_DATA_ADDR);
  2149. +}
  2150. +
  2151. +void LPCSetConfig(char LdnNumber, char Index, char data)
  2152. +{
  2153. + LPCEnterMBPnP(); // Enter IT8712 MB PnP mode
  2154. + outb(0x07, LPC_KEY_ADDR);
  2155. + outb(LdnNumber, LPC_DATA_ADDR);
  2156. + outb(Index, LPC_KEY_ADDR);
  2157. + outb(data, LPC_DATA_ADDR);
  2158. + LPCExitMBPnP();
  2159. +}
  2160. +
  2161. +char LPCGetConfig(char LdnNumber, char Index)
  2162. +{
  2163. + char rtn;
  2164. +
  2165. + LPCEnterMBPnP(); // Enter IT8712 MB PnP mode
  2166. + outb(0x07, LPC_KEY_ADDR);
  2167. + outb(LdnNumber, LPC_DATA_ADDR);
  2168. + outb(Index, LPC_KEY_ADDR);
  2169. + rtn = inb(LPC_DATA_ADDR);
  2170. + LPCExitMBPnP();
  2171. + return rtn;
  2172. +}
  2173. +
  2174. +static int SearchIT8712(void)
  2175. +{
  2176. + unsigned char Id1, Id2;
  2177. + unsigned short Id;
  2178. +
  2179. + LPCEnterMBPnP();
  2180. + outb(0x20, LPC_KEY_ADDR); /* chip id byte 1 */
  2181. + Id1 = inb(LPC_DATA_ADDR);
  2182. + outb(0x21, LPC_KEY_ADDR); /* chip id byte 2 */
  2183. + Id2 = inb(LPC_DATA_ADDR);
  2184. + Id = (Id1 << 8) | Id2;
  2185. + LPCExitMBPnP();
  2186. + if (Id == 0x8712)
  2187. + return TRUE;
  2188. + else
  2189. + return FALSE;
  2190. +}
  2191. +
  2192. +int InitLPCInterface(void)
  2193. +{
  2194. + LPC_BUS_CTRL = 0xc0;
  2195. + LPC_SERIAL_IRQ_CTRL = 0xc0;
  2196. + mdelay(1); // wait for 1 serial IRQ cycle
  2197. + LPC_SERIAL_IRQ_CTRL = 0x80;
  2198. + it8712_exist = SearchIT8712();
  2199. + printk("IT8712 %s exist\n", it8712_exist?"":"doesn't");
  2200. + return 0;
  2201. +}
  2202. +
  2203. +//__initcall(InitLPCInterface);
  2204. --- /dev/null
  2205. +++ b/arch/arm/mach-sl2312/mm.c
  2206. @@ -0,0 +1,80 @@
  2207. +/*
  2208. + * linux/arch/arm/mach-epxa10db/mm.c
  2209. + *
  2210. + * MM routines for Altera'a Epxa10db board
  2211. + *
  2212. + * Copyright (C) 2001 Altera Corporation
  2213. + *
  2214. + * This program is free software; you can redistribute it and/or modify
  2215. + * it under the terms of the GNU General Public License as published by
  2216. + * the Free Software Foundation; either version 2 of the License, or
  2217. + * (at your option) any later version.
  2218. + *
  2219. + * This program is distributed in the hope that it will be useful,
  2220. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2221. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2222. + * GNU General Public License for more details.
  2223. + *
  2224. + * You should have received a copy of the GNU General Public License
  2225. + * along with this program; if not, write to the Free Software
  2226. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  2227. + */
  2228. +#include <linux/sched.h>
  2229. +#include <linux/mm.h>
  2230. +#include <linux/init.h>
  2231. +
  2232. +#include <asm/hardware.h>
  2233. +#include <asm/io.h>
  2234. +#include <asm/pgtable.h>
  2235. +#include <asm/page.h>
  2236. +#include <asm/sizes.h>
  2237. +
  2238. +#include <asm/mach/map.h>
  2239. +
  2240. +/* Page table mapping for I/O region */
  2241. +static struct map_desc sl2312_io_desc[] __initdata = {
  2242. +#ifdef CONFIG_GEMINI_IPI
  2243. +{__phys_to_virt(CPU_1_MEM_BASE), __phys_to_pfn(CPU_1_MEM_BASE), SZ_64M, MT_MEMORY},
  2244. +#endif
  2245. +{IO_ADDRESS(SL2312_SRAM_BASE), __phys_to_pfn(SL2312_SRAM_BASE), SZ_512K, MT_DEVICE},
  2246. +{IO_ADDRESS(SL2312_DRAM_CTRL_BASE), __phys_to_pfn(SL2312_DRAM_CTRL_BASE), SZ_512K, MT_DEVICE},
  2247. +{IO_ADDRESS(SL2312_GLOBAL_BASE), __phys_to_pfn(SL2312_GLOBAL_BASE), SZ_512K, MT_DEVICE},
  2248. +{IO_ADDRESS(SL2312_WAQTCHDOG_BASE), __phys_to_pfn(SL2312_WAQTCHDOG_BASE), SZ_512K, MT_DEVICE},
  2249. +{IO_ADDRESS(SL2312_UART_BASE), __phys_to_pfn(SL2312_UART_BASE), SZ_512K, MT_DEVICE},
  2250. +{IO_ADDRESS(SL2312_TIMER_BASE), __phys_to_pfn(SL2312_TIMER_BASE), SZ_512K, MT_DEVICE},
  2251. +{IO_ADDRESS(SL2312_LCD_BASE), __phys_to_pfn(SL2312_LCD_BASE), SZ_512K, MT_DEVICE},
  2252. +{IO_ADDRESS(SL2312_RTC_BASE), __phys_to_pfn(SL2312_RTC_BASE), SZ_512K, MT_DEVICE},
  2253. +{IO_ADDRESS(SL2312_SATA_BASE), __phys_to_pfn(SL2312_SATA_BASE), SZ_512K, MT_DEVICE},
  2254. +{IO_ADDRESS(SL2312_LPC_HOST_BASE), __phys_to_pfn(SL2312_LPC_HOST_BASE), SZ_512K, MT_DEVICE},
  2255. +{IO_ADDRESS(SL2312_LPC_IO_BASE), __phys_to_pfn(SL2312_LPC_IO_BASE), SZ_512K, MT_DEVICE},
  2256. +{IO_ADDRESS(SL2312_INTERRUPT_BASE), __phys_to_pfn(SL2312_INTERRUPT_BASE), SZ_512K, MT_DEVICE},
  2257. +{IO_ADDRESS(SL2312_INTERRUPT1_BASE), __phys_to_pfn(SL2312_INTERRUPT1_BASE), SZ_512K, MT_DEVICE},
  2258. +{IO_ADDRESS(SL2312_SSP_CTRL_BASE), __phys_to_pfn(SL2312_SSP_CTRL_BASE), SZ_512K, MT_DEVICE},
  2259. +{IO_ADDRESS(SL2312_POWER_CTRL_BASE), __phys_to_pfn(SL2312_POWER_CTRL_BASE), SZ_512K, MT_DEVICE},
  2260. +{IO_ADDRESS(SL2312_CIR_BASE), __phys_to_pfn(SL2312_CIR_BASE), SZ_512K, MT_DEVICE},
  2261. +{IO_ADDRESS(SL2312_GPIO_BASE), __phys_to_pfn(SL2312_GPIO_BASE), SZ_512K, MT_DEVICE},
  2262. +{IO_ADDRESS(SL2312_GPIO_BASE1), __phys_to_pfn(SL2312_GPIO_BASE1), SZ_512K, MT_DEVICE},
  2263. +{IO_ADDRESS(SL2312_GPIO_BASE2), __phys_to_pfn(SL2312_GPIO_BASE2), SZ_512K, MT_DEVICE},
  2264. +{IO_ADDRESS(SL2312_PCI_IO_BASE), __phys_to_pfn(SL2312_PCI_IO_BASE), SZ_512K, MT_DEVICE},
  2265. +{IO_ADDRESS(SL2312_PCI_MEM_BASE), __phys_to_pfn(SL2312_PCI_MEM_BASE), SZ_512K, MT_DEVICE},
  2266. +#ifdef CONFIG_NET_SL351X
  2267. +{IO_ADDRESS(SL2312_TOE_BASE), __phys_to_pfn(SL2312_TOE_BASE) , SZ_512K, MT_DEVICE},
  2268. +#endif
  2269. +{IO_ADDRESS(SL2312_GMAC0_BASE), __phys_to_pfn(SL2312_GMAC0_BASE), SZ_512K, MT_DEVICE},
  2270. +{IO_ADDRESS(SL2312_GMAC1_BASE), __phys_to_pfn(SL2312_GMAC1_BASE), SZ_512K, MT_DEVICE},
  2271. +{IO_ADDRESS(SL2312_SECURITY_BASE), __phys_to_pfn(SL2312_SECURITY_BASE), SZ_512K, MT_DEVICE},
  2272. +{IO_ADDRESS(SL2312_IDE0_BASE), __phys_to_pfn(SL2312_IDE0_BASE), SZ_512K, MT_DEVICE},
  2273. +{IO_ADDRESS(SL2312_IDE1_BASE), __phys_to_pfn(SL2312_IDE1_BASE), SZ_512K, MT_DEVICE},
  2274. +{IO_ADDRESS(SL2312_RAID_BASE), __phys_to_pfn(SL2312_RAID_BASE), SZ_512K, MT_DEVICE},
  2275. +{IO_ADDRESS(SL2312_FLASH_CTRL_BASE), __phys_to_pfn(SL2312_FLASH_CTRL_BASE), SZ_512K, MT_DEVICE},
  2276. +{IO_ADDRESS(SL2312_DRAM_CTRL_BASE), __phys_to_pfn(SL2312_DRAM_CTRL_BASE), SZ_512K, MT_DEVICE},
  2277. +{IO_ADDRESS(SL2312_GENERAL_DMA_BASE), __phys_to_pfn(SL2312_GENERAL_DMA_BASE), SZ_512K, MT_DEVICE},
  2278. +{IO_ADDRESS(SL2312_USB0_BASE), __phys_to_pfn(SL2312_USB_BASE), SZ_512K, MT_DEVICE},
  2279. +{IO_ADDRESS(SL2312_USB1_BASE), __phys_to_pfn(SL2312_USB1_BASE), SZ_512K, MT_DEVICE},
  2280. +{FLASH_VADDR(SL2312_FLASH_BASE), __phys_to_pfn(SL2312_FLASH_BASE), SZ_16M, MT_DEVICE},
  2281. +};
  2282. +
  2283. +void __init sl2312_map_io(void)
  2284. +{
  2285. + iotable_init(sl2312_io_desc, ARRAY_SIZE(sl2312_io_desc));
  2286. +}
  2287. --- /dev/null
  2288. +++ b/arch/arm/mach-sl2312/pci.c
  2289. @@ -0,0 +1,359 @@
  2290. +/*
  2291. + * linux/arch/arm/mach-sl2312/pci_sl2312.c
  2292. + *
  2293. + * PCI functions for sl2312 host PCI bridge
  2294. + *
  2295. + * Copyright (C) 2003 StorLink Corp.
  2296. + *
  2297. + * This program is free software; you can redistribute it and/or modify
  2298. + * it under the terms of the GNU General Public License as published by
  2299. + * the Free Software Foundation; either version 2 of the License, or
  2300. + * (at your option) any later version.
  2301. + *
  2302. + * This program is distributed in the hope that it will be useful,
  2303. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2304. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2305. + * GNU General Public License for more details.
  2306. + *
  2307. + * You should have received a copy of the GNU General Public License
  2308. + * along with this program; if not, write to the Free Software
  2309. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  2310. + */
  2311. +#include <linux/sched.h>
  2312. +#include <linux/kernel.h>
  2313. +#include <linux/pci.h>
  2314. +#include <linux/ptrace.h>
  2315. +#include <linux/slab.h>
  2316. +#include <linux/ioport.h>
  2317. +#include <linux/interrupt.h>
  2318. +#include <linux/spinlock.h>
  2319. +#include <linux/init.h>
  2320. +
  2321. +#include <asm/sizes.h>
  2322. +#include <asm/hardware.h>
  2323. +#include <asm/irq.h>
  2324. +#include <asm/system.h>
  2325. +#include <asm/mach/pci.h>
  2326. +#include <asm/mach/irq.h>
  2327. +#include <asm/mach-types.h>
  2328. +
  2329. +#include <asm/arch/pci.h>
  2330. +
  2331. +//#define DEBUG
  2332. +
  2333. +// sl2312 PCI bridge access routines
  2334. +
  2335. +#define PCI_IOSIZE_REG (*(volatile unsigned long *) (IO_ADDRESS(SL2312_PCI_IO_BASE)))
  2336. +#define PCI_PROT_REG (*(volatile unsigned long *) (IO_ADDRESS(SL2312_PCI_IO_BASE) + 0x04))
  2337. +#define PCI_CTRL_REG (*(volatile unsigned long *) (IO_ADDRESS(SL2312_PCI_IO_BASE) + 0x08))
  2338. +#define PCI_SOFTRST_REG (*(volatile unsigned long *) (IO_ADDRESS(SL2312_PCI_IO_BASE) + 0x10))
  2339. +#define PCI_CONFIG_REG (*(volatile unsigned long *) (IO_ADDRESS(SL2312_PCI_IO_BASE) + 0x28))
  2340. +#define PCI_DATA_REG (*(volatile unsigned long *) (IO_ADDRESS(SL2312_PCI_IO_BASE) + 0x2C))
  2341. +
  2342. +static spinlock_t sl2312_pci_lock = SPIN_LOCK_UNLOCKED;
  2343. +// for initialize PCI devices
  2344. +struct resource pci_ioport_resource = {
  2345. + .name = "PCI I/O Space",
  2346. + .start = IO_ADDRESS(SL2312_PCI_IO_BASE) + 0x100,
  2347. + .end = IO_ADDRESS(SL2312_PCI_IO_BASE) + SZ_512K - 1,
  2348. + .flags = IORESOURCE_IO,
  2349. +};
  2350. +struct resource pci_iomem_resource = {
  2351. + .name = "PCI Mem Space",
  2352. + .start = SL2312_PCI_MEM_BASE,
  2353. + .end = SL2312_PCI_MEM_BASE + SZ_128M - 1,
  2354. + .flags = IORESOURCE_MEM,
  2355. +};
  2356. +
  2357. +static int sl2312_read_config(struct pci_bus *bus, unsigned int devfn, int where,int size, u32 *val)
  2358. +{
  2359. + unsigned long addr,data;
  2360. + unsigned long flags;
  2361. +
  2362. + spin_lock_irqsave(&sl2312_pci_lock, flags);
  2363. + addr = 0x80000000 | (PCI_SLOT(devfn) << 11) | (PCI_FUNC(devfn) << 8) | (where & ~3);
  2364. + PCI_CONFIG_REG = addr;
  2365. + data = PCI_DATA_REG;
  2366. +
  2367. + switch (size) {
  2368. + case 1:
  2369. + *val = (u8) (data >> ((where & 0x03) * 8));
  2370. + break;
  2371. + case 2:
  2372. + *val = (u16) (data >> ((where & 0x02) * 8));
  2373. + break;
  2374. + case 4:
  2375. + *val = data;
  2376. + if ((where >= 0x10) && (where <= 0x24)) {
  2377. + if ((*val & 0xfff00000) == SL2312_PCI_IO_BASE) {
  2378. + *val &= 0x000fffff;
  2379. + *val |= IO_ADDRESS(SL2312_PCI_IO_BASE);
  2380. + }
  2381. + }
  2382. + break;
  2383. + }
  2384. + spin_unlock_irqrestore(&sl2312_pci_lock, flags);
  2385. +// printk("READ==>slot=%d fn=%d where=%d value=%x\n",PCI_SLOT(devfn),PCI_FUNC(devfn),where,*val);
  2386. + return PCIBIOS_SUCCESSFUL;
  2387. +}
  2388. +
  2389. +static int sl2312_write_config(struct pci_bus *bus, unsigned int devfn, int where,int size, u32 val)
  2390. +{
  2391. + unsigned long addr,data;
  2392. + unsigned long flags;
  2393. +
  2394. + spin_lock_irqsave(&sl2312_pci_lock, flags);
  2395. + addr = 0x80000000 | (PCI_SLOT(devfn) << 11) | (PCI_FUNC(devfn) << 8) | (where & ~3);
  2396. + PCI_CONFIG_REG = addr;
  2397. + data = PCI_DATA_REG;
  2398. +
  2399. + switch (size) {
  2400. + case 1:
  2401. + data &= ~(0xff << ((where & 0x03) * 8));
  2402. + data |= (val << ((where & 0x03) * 8));
  2403. + PCI_DATA_REG = data;
  2404. + break;
  2405. + case 2:
  2406. + data &= ~(0xffff << ((where & 0x02) * 8));
  2407. + data |= (val << ((where & 0x02) * 8));
  2408. + PCI_DATA_REG = data;
  2409. + break;
  2410. + case 4:
  2411. + if ((where >= 0x10) && (where <= 0x24)) {
  2412. + if ((val & 0xfff00000) == IO_ADDRESS(SL2312_PCI_IO_BASE)) {
  2413. + val &= 0x000fffff;
  2414. + val |= SL2312_PCI_IO_BASE;
  2415. + }
  2416. + }
  2417. + PCI_DATA_REG = val;
  2418. + break;
  2419. + }
  2420. + spin_unlock_irqrestore(&sl2312_pci_lock, flags);
  2421. +
  2422. +// printk("WRITE==> slot=%d fn=%d where=%d value=%x \n",PCI_SLOT(devfn),PCI_FUNC(devfn),where,val);
  2423. + return PCIBIOS_SUCCESSFUL;
  2424. +}
  2425. +
  2426. +static struct pci_ops sl2312_pci_ops = {
  2427. + .read = sl2312_read_config,
  2428. + .write = sl2312_write_config,
  2429. +};
  2430. +
  2431. +
  2432. +int __init sl2312_pci_setup_resources(struct resource **resource)
  2433. +{
  2434. + PCI_IOSIZE_REG = 0; // 1M IO size
  2435. + PCI_CTRL_REG = 0x06;
  2436. +
  2437. + resource[0] = &pci_ioport_resource;
  2438. + resource[1] = &pci_iomem_resource;
  2439. + resource[2] = NULL;
  2440. +
  2441. + return 1;
  2442. +}
  2443. +
  2444. +//static int sl2312_pci_fault(unsigned long addr, struct pt_regs *regs)
  2445. +//{
  2446. +// return 1;
  2447. +//}
  2448. +
  2449. +
  2450. +/**********************************************************************
  2451. + * MASK(disable) PCI interrupt
  2452. + * 0: PCI INTA, 1: PCI INTB, ... // for Linux interrupt routing
  2453. + * 16: PERR // for PCI module internal use
  2454. + * 17: SERR,.. respect to PCI CTRL2 REG
  2455. + **********************************************************************/
  2456. +void sl2312_pci_mask_irq(unsigned int irq)
  2457. +{
  2458. + struct pci_bus bus;
  2459. + unsigned int tmp;
  2460. +
  2461. + bus.number = 0;
  2462. + sl2312_read_config(&bus, 0, SL2312_PCI_CTRL2, 4, &tmp);
  2463. + if (irq < 16) { // for linux int routing
  2464. + tmp &= ~(1 << (irq + 16 + 6));
  2465. + }
  2466. + else {
  2467. + tmp &= ~(1 << irq);
  2468. + }
  2469. + sl2312_write_config(&bus, 0, SL2312_PCI_CTRL2, 4, tmp);
  2470. +}
  2471. +
  2472. +/* UNMASK(enable) PCI interrupt */
  2473. +void sl2312_pci_unmask_irq(unsigned int irq)
  2474. +{
  2475. + struct pci_bus bus;
  2476. + unsigned int tmp;
  2477. +
  2478. + bus.number = 0;
  2479. + sl2312_read_config(&bus, 0, SL2312_PCI_CTRL2, 4, &tmp);
  2480. + if (irq < 16) { // for linux int routing
  2481. + tmp |= (1 << (irq + 16 + 6));
  2482. + }
  2483. + else {
  2484. + tmp |= (1 << irq);
  2485. + }
  2486. + sl2312_write_config(&bus, 0, SL2312_PCI_CTRL2, 4, tmp);
  2487. +}
  2488. +
  2489. +/* Get PCI interrupt source */
  2490. +int sl2312_pci_get_int_src(void)
  2491. +{
  2492. + struct pci_bus bus;
  2493. + unsigned int tmp=0;
  2494. +
  2495. + bus.number = 0;
  2496. + sl2312_read_config(&bus, 0, SL2312_PCI_CTRL2, 4, &tmp);
  2497. + if (tmp & (1 << 28)) { // PCI INTA
  2498. + sl2312_write_config(&bus, 0, SL2312_PCI_CTRL2, 4, tmp);
  2499. + return IRQ_PCI_INTA;
  2500. + }
  2501. + if (tmp & (1 << 29)) { // PCI INTB
  2502. + sl2312_write_config(&bus, 0, SL2312_PCI_CTRL2, 4, tmp);
  2503. + return IRQ_PCI_INTB;
  2504. + }
  2505. + if (tmp & (1 << 30)) { // PCI INTC
  2506. + sl2312_write_config(&bus, 0, SL2312_PCI_CTRL2, 4, tmp);
  2507. + return IRQ_PCI_INTC;
  2508. + }
  2509. + if (tmp & (1 << 31)) { // PCI INTD
  2510. + sl2312_write_config(&bus, 0, SL2312_PCI_CTRL2, 4, tmp);
  2511. + return IRQ_PCI_INTD;
  2512. + }
  2513. + // otherwise, it should be a PCI error
  2514. + return IRQ_PCI;
  2515. +}
  2516. +
  2517. +static irqreturn_t sl2312_pci_irq(int irq, void *devid)
  2518. +{
  2519. + struct irq_desc *desc;
  2520. + struct irqaction *action;
  2521. + int retval = 0;
  2522. +
  2523. + return 1;
  2524. +
  2525. + irq = sl2312_pci_get_int_src();
  2526. + desc = &irq_desc[irq];
  2527. + action = desc->action;
  2528. + do {
  2529. + retval |= action->handler(irq, devid);
  2530. + action = action->next;
  2531. + } while (action);
  2532. +
  2533. + return 1;
  2534. +}
  2535. +
  2536. +//extern int (*external_fault)(unsigned long addr, struct pt_regs *regs);
  2537. +
  2538. +void __init sl2312_pci_preinit(void)
  2539. +{
  2540. + struct pci_bus bus;
  2541. + unsigned long flags;
  2542. + unsigned int temp;
  2543. + int ret;
  2544. +
  2545. + /*
  2546. + * Hook in our fault handler for PCI errors
  2547. + */
  2548. +// external_fault = sl2312_pci_fault;
  2549. +
  2550. + spin_lock_irqsave(&sl2312_pci_lock, flags);
  2551. +
  2552. + /*
  2553. + * Grab the PCI interrupt.
  2554. + */
  2555. + ret = request_irq(IRQ_PCI, sl2312_pci_irq, 0, "sl2312 pci int", NULL);
  2556. + if (ret)
  2557. + printk(KERN_ERR "PCI: unable to grab PCI error "
  2558. + "interrupt: %d\n", ret);
  2559. +
  2560. + spin_unlock_irqrestore(&sl2312_pci_lock, flags);
  2561. +
  2562. + // setup pci bridge
  2563. + bus.number = 0; /* device 0, function 0 */
  2564. + temp = (SL2312_PCI_DMA_MEM1_BASE & 0xfff00000) | (SL2312_PCI_DMA_MEM1_SIZE << 16);
  2565. + sl2312_write_config(&bus, 0, SL2312_PCI_MEM1_BASE_SIZE, 4, temp);
  2566. +}
  2567. +
  2568. +/*
  2569. + * No swizzle on SL2312
  2570. + */
  2571. +static u8 __init sl2312_pci_swizzle(struct pci_dev *dev, u8 *pinp)
  2572. +{
  2573. + return PCI_SLOT(dev->devfn);
  2574. +}
  2575. +
  2576. +/*
  2577. + * map the specified device/slot/pin to an IRQ. This works out such
  2578. + * that slot 9 pin 1 is INT0, pin 2 is INT1, and slot 10 pin 1 is INT1.
  2579. + */
  2580. +static int __init sl2312_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  2581. +{
  2582. + int intnr = ((slot + (pin - 1)) & 3) + 4; /* the IRQ number of PCI bridge */
  2583. +
  2584. + // printk("%s : slot = %d pin = %d \n",__func__,slot,pin);
  2585. + switch (slot)
  2586. + {
  2587. + case 12:
  2588. + if (pin==1)
  2589. + {
  2590. + intnr = 3;
  2591. + }
  2592. + else
  2593. + {
  2594. + intnr = 0;
  2595. + }
  2596. + break;
  2597. + case 11:
  2598. + intnr = (2 + (pin - 1)) & 3;
  2599. + break;
  2600. + case 10:
  2601. + intnr = (1 + (pin - 1)) & 3;
  2602. + break;
  2603. + case 9:
  2604. + intnr = (pin - 1) & 3;
  2605. + break;
  2606. + }
  2607. +// if (slot == 10)
  2608. +// intnr = (1 + (pin - 1)) & 3;
  2609. +// else if (slot == 9)
  2610. +// intnr = (pin - 1) & 3;
  2611. + return (IRQ_PCI_INTA + intnr);
  2612. +}
  2613. +
  2614. +struct pci_bus * __init sl2312_pci_scan_bus(int nr, struct pci_sys_data *sysdata)
  2615. +{
  2616. + return (pci_scan_bus(0, &sl2312_pci_ops, sysdata));
  2617. +
  2618. +}
  2619. +
  2620. +int __init sl2312_pci_setup(int nr, struct pci_sys_data *sys)
  2621. +{
  2622. + int ret = 0;
  2623. +
  2624. + if (nr == 0) {
  2625. + ret = sl2312_pci_setup_resources(sys->resource);
  2626. + }
  2627. +
  2628. + return ret;
  2629. +}
  2630. +
  2631. +
  2632. +struct hw_pci sl2312_pci __initdata = {
  2633. + .setup = sl2312_pci_setup,
  2634. + .preinit = sl2312_pci_preinit,
  2635. + .nr_controllers = 1,
  2636. + .swizzle = sl2312_pci_swizzle,
  2637. + .map_irq = sl2312_pci_map_irq,
  2638. + .scan = sl2312_pci_scan_bus,
  2639. +};
  2640. +
  2641. +static int __init sl2312_pci_init(void)
  2642. +{
  2643. + if (machine_is_sl2312())
  2644. + pci_common_init(&sl2312_pci);
  2645. + return 0;
  2646. +}
  2647. +
  2648. +subsys_initcall(sl2312_pci_init);
  2649. --- /dev/null
  2650. +++ b/arch/arm/mach-sl2312/sl2312-otg-1.c
  2651. @@ -0,0 +1,64 @@
  2652. +/*
  2653. + * linux/arch/arm/mach-pxa/sl2312.c
  2654. + *
  2655. + * Author: Nicolas Pitre
  2656. + * Created: Nov 05, 2002
  2657. + * Copyright: MontaVista Software Inc.
  2658. + *
  2659. + * Code specific to sl2312 aka Bulverde.
  2660. + *
  2661. + * This program is free software; you can redistribute it and/or modify
  2662. + * it under the terms of the GNU General Public License version 2 as
  2663. + * published by the Free Software Foundation.
  2664. + */
  2665. +#include <linux/module.h>
  2666. +#include <linux/kernel.h>
  2667. +#include <linux/init.h>
  2668. +#include <linux/pm.h>
  2669. +#include <linux/device.h>
  2670. +#include "asm/arch/sl2312.h"
  2671. +#include "asm/arch/irqs.h"
  2672. +#include <asm/hardware.h>
  2673. +#include <asm/irq.h>
  2674. +#include <linux/platform_device.h>
  2675. +
  2676. +/*
  2677. + * device registration specific to sl2312.
  2678. + */
  2679. +
  2680. +static u64 sl2312_dmamask_1 = 0xffffffffUL;
  2681. +
  2682. +static struct resource sl2312_otg_resources_1[] = {
  2683. + [0] = {
  2684. + .start = 0x69000000,
  2685. + .end = 0x69000fff,
  2686. + .flags = IORESOURCE_MEM,
  2687. + },
  2688. + [1] = {
  2689. + .start = IRQ_USB1,
  2690. + .end = IRQ_USB1,
  2691. + .flags = IORESOURCE_IRQ,
  2692. + },
  2693. +};
  2694. +
  2695. +static struct platform_device ehci_1_device = {
  2696. + .name = "ehci-hcd-FOTG2XX",
  2697. + .id = -1,
  2698. + .dev = {
  2699. + .dma_mask = &sl2312_dmamask_1,
  2700. + .coherent_dma_mask = 0xffffffff,
  2701. + },
  2702. + .num_resources = ARRAY_SIZE(sl2312_otg_resources_1),
  2703. + .resource = sl2312_otg_resources_1,
  2704. +};
  2705. +
  2706. +static struct platform_device *devices[] __initdata = {
  2707. + &ehci_1_device,
  2708. +};
  2709. +
  2710. +static int __init sl2312_1_init(void)
  2711. +{
  2712. + return platform_add_devices(devices, ARRAY_SIZE(devices));
  2713. +}
  2714. +
  2715. +subsys_initcall(sl2312_1_init);
  2716. --- /dev/null
  2717. +++ b/arch/arm/mach-sl2312/sl2312-otg.c
  2718. @@ -0,0 +1,87 @@
  2719. +/*
  2720. + * linux/arch/arm/mach-pxa/sl2312.c
  2721. + *
  2722. + * Author: Nicolas Pitre
  2723. + * Created: Nov 05, 2002
  2724. + * Copyright: MontaVista Software Inc.
  2725. + *
  2726. + * Code specific to sl2312 aka Bulverde.
  2727. + *
  2728. + * This program is free software; you can redistribute it and/or modify
  2729. + * it under the terms of the GNU General Public License version 2 as
  2730. + * published by the Free Software Foundation.
  2731. + */
  2732. +#include <linux/module.h>
  2733. +#include <linux/kernel.h>
  2734. +#include <linux/init.h>
  2735. +#include <linux/pm.h>
  2736. +#include <linux/device.h>
  2737. +#include "asm/arch/sl2312.h"
  2738. +#include "asm/arch/irqs.h"
  2739. +#include <asm/hardware.h>
  2740. +#include <asm/irq.h>
  2741. +#include <linux/platform_device.h>
  2742. +
  2743. +/*
  2744. + * device registration specific to sl2312.
  2745. + */
  2746. +
  2747. +static u64 sl2312_dmamask = 0xffffffffUL;
  2748. +
  2749. +static struct resource sl2312_otg_resources_1[] = {
  2750. + [0] = {
  2751. + .start = 0x68000000,
  2752. + .end = 0x68000fff,
  2753. + .flags = IORESOURCE_MEM,
  2754. + },
  2755. + [1] = {
  2756. + .start = IRQ_USB0,
  2757. + .end = IRQ_USB0,
  2758. + .flags = IORESOURCE_IRQ,
  2759. + },
  2760. +};
  2761. +static struct resource sl2312_otg_resources_2[] = {
  2762. + [2] = {
  2763. + .start = 0x69000000,
  2764. + .end = 0x69000fff,
  2765. + .flags = IORESOURCE_MEM,
  2766. + },
  2767. + [3] = {
  2768. + .start = IRQ_USB1,
  2769. + .end = IRQ_USB1,
  2770. + .flags = IORESOURCE_IRQ,
  2771. + },
  2772. +};
  2773. +
  2774. +static struct platform_device ehci_device_1 = {
  2775. + .name = "ehci-hcd-FOTG2XX",
  2776. + .id = 1,
  2777. + .dev = {
  2778. + .dma_mask = &sl2312_dmamask,
  2779. + .coherent_dma_mask = 0xffffffff,
  2780. + },
  2781. + .num_resources = ARRAY_SIZE(sl2312_otg_resources_1),
  2782. + .resource = sl2312_otg_resources_1,
  2783. +};
  2784. +
  2785. +static struct platform_device ehci_device_2 = {
  2786. + .name = "ehci-hcd-FOTG2XX",
  2787. + .id = 2,
  2788. + .dev = {
  2789. + .dma_mask = &sl2312_dmamask,
  2790. + .coherent_dma_mask = 0xffffffff,
  2791. + },
  2792. + .num_resources = ARRAY_SIZE(sl2312_otg_resources_2),
  2793. + .resource = sl2312_otg_resources_2,
  2794. +};
  2795. +
  2796. +static struct platform_device *devices[] __initdata = {
  2797. + &ehci_device_1, /* &ehci_device_2, */
  2798. +};
  2799. +
  2800. +static int __init sl2312_init(void)
  2801. +{
  2802. + return platform_add_devices(devices, ARRAY_SIZE(devices));
  2803. +}
  2804. +
  2805. +subsys_initcall(sl2312_init);
  2806. --- /dev/null
  2807. +++ b/arch/arm/mach-sl2312/sl3516_device.c
  2808. @@ -0,0 +1,89 @@
  2809. +/*
  2810. + * linux/arch/arm/mach-2312/sl3516_device.c
  2811. + *
  2812. + * Author: Nicolas Pitre
  2813. + * Created: Nov 05, 2002
  2814. + * Copyright: MontaVista Software Inc.
  2815. + *
  2816. + * Code specific to sl2312 aka Bulverde.
  2817. + *
  2818. + * This program is free software; you can redistribute it and/or modify
  2819. + * it under the terms of the GNU General Public License version 2 as
  2820. + * published by the Free Software Foundation.
  2821. + */
  2822. +#include <linux/module.h>
  2823. +#include <linux/kernel.h>
  2824. +#include <linux/init.h>
  2825. +#include <linux/pm.h>
  2826. +#include <linux/device.h>
  2827. +#include <linux/platform_device.h>
  2828. +#include "asm/arch/sl2312.h"
  2829. +#include "asm/arch/irqs.h"
  2830. +#include <asm/hardware.h>
  2831. +#include <asm/irq.h>
  2832. +
  2833. +/*
  2834. + * device registration specific to sl2312.
  2835. + */
  2836. +
  2837. +static u64 sl3516_dmamask = 0xffffffffUL;
  2838. +
  2839. +static struct resource sl3516_sata_resources[] = {
  2840. + [0] = {
  2841. + .start = 0x63400000,
  2842. + .end = 0x63400040,
  2843. + .flags = IORESOURCE_MEM,
  2844. + },
  2845. + [1] = {
  2846. + .start = IRQ_IDE1,
  2847. + .end = IRQ_IDE1,
  2848. + .flags = IORESOURCE_IRQ,
  2849. + },
  2850. +};
  2851. +
  2852. +static struct platform_device sata_device = {
  2853. + .name = "lepus-sata",
  2854. + .id = -1,
  2855. + .dev = {
  2856. + .dma_mask = &sl3516_dmamask,
  2857. + .coherent_dma_mask = 0xffffffff,
  2858. + },
  2859. + .num_resources = ARRAY_SIZE(sl3516_sata_resources),
  2860. + .resource = sl3516_sata_resources,
  2861. +};
  2862. +
  2863. +static struct resource sl3516_sata0_resources[] = {
  2864. + [0] = {
  2865. + .start = 0x63000000,
  2866. + .end = 0x63000040,
  2867. + .flags = IORESOURCE_MEM,
  2868. + },
  2869. + [1] = {
  2870. + .start = IRQ_IDE0,
  2871. + .end = IRQ_IDE0,
  2872. + .flags = IORESOURCE_IRQ,
  2873. + },
  2874. +};
  2875. +
  2876. +static struct platform_device sata0_device = {
  2877. + .name = "lepus-sata0",
  2878. + .id = -1,
  2879. + .dev = {
  2880. + .dma_mask = &sl3516_dmamask,
  2881. + .coherent_dma_mask = 0xffffffff,
  2882. + },
  2883. + .num_resources = ARRAY_SIZE(sl3516_sata0_resources),
  2884. + .resource = sl3516_sata0_resources,
  2885. +};
  2886. +
  2887. +static struct platform_device *sata_devices[] __initdata = {
  2888. + &sata_device,
  2889. + &sata0_device,
  2890. +};
  2891. +
  2892. +static int __init sl3516_init(void)
  2893. +{
  2894. + return platform_add_devices(sata_devices, ARRAY_SIZE(sata_devices));
  2895. +}
  2896. +
  2897. +subsys_initcall(sl3516_init);
  2898. --- /dev/null
  2899. +++ b/arch/arm/mach-sl2312/time.c
  2900. @@ -0,0 +1,134 @@
  2901. +/*
  2902. + * linux/include/asm-arm/arch-epxa10db/time.h
  2903. + *
  2904. + * Copyright (C) 2001 Altera Corporation
  2905. + *
  2906. + * This program is free software; you can redistribute it and/or modify
  2907. + * it under the terms of the GNU General Public License as published by
  2908. + * the Free Software Foundation; either version 2 of the License, or
  2909. + * (at your option) any later version.
  2910. + *
  2911. + * This program is distributed in the hope that it will be useful,
  2912. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2913. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2914. + * GNU General Public License for more details.
  2915. + *
  2916. + * You should have received a copy of the GNU General Public License
  2917. + * along with this program; if not, write to the Free Software
  2918. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  2919. + */
  2920. +#include <linux/interrupt.h>
  2921. +#include <linux/irq.h>
  2922. +#include <asm/io.h>
  2923. +#include <asm/system.h>
  2924. +#include <asm/leds.h>
  2925. +#include <asm/arch/hardware.h>
  2926. +#include <asm/mach/time.h>
  2927. +#define TIMER_TYPE (volatile unsigned int*)
  2928. +#include <asm/arch/timer.h>
  2929. +// #define FIQ_PLUS 1
  2930. +
  2931. +
  2932. +/*
  2933. + * IRQ handler for the timer
  2934. + */
  2935. +static irqreturn_t sl2312_timer_interrupt(int irq, void *dev_id)
  2936. +{
  2937. +// unsigned int led;
  2938. + // ...clear the interrupt
  2939. +#ifdef FIQ_PLUS
  2940. + *((volatile unsigned int *)FIQ_CLEAR(IO_ADDRESS(SL2312_INTERRUPT_BASE))) |= (unsigned int)(IRQ_TIMER1_MASK);
  2941. +#else
  2942. + *((volatile unsigned int *)IRQ_CLEAR(IO_ADDRESS(SL2312_INTERRUPT_BASE))) |= (unsigned int)(IRQ_TIMER2_MASK);
  2943. +#endif
  2944. +
  2945. +#if 0
  2946. + if(!(jiffies % HZ))
  2947. + {
  2948. + led = jiffies / HZ;
  2949. +// printk("ticks %x \n", led);
  2950. + }
  2951. + do_leds();
  2952. + do_timer(regs);
  2953. + do_profile(regs);
  2954. +#endif
  2955. + timer_tick();
  2956. + return IRQ_HANDLED;
  2957. +}
  2958. +
  2959. +static struct irqaction sl2312_timer_irq = {
  2960. + .name = "SL2312 Timer Tick",
  2961. + .flags = IRQF_DISABLED | IRQF_TIMER,
  2962. + .handler = sl2312_timer_interrupt,
  2963. +};
  2964. +
  2965. +unsigned long sl2312_gettimeoffset (void)
  2966. +{
  2967. + return 0L;
  2968. +}
  2969. +
  2970. +/*
  2971. + * Set up timer interrupt, and return the current time in seconds.
  2972. + */
  2973. +void __init sl2312_time_init(void)
  2974. +{
  2975. + // For clock rate adjusting
  2976. + unsigned int tick_rate=0;
  2977. +
  2978. +#ifdef CONFIG_SL3516_ASIC
  2979. + unsigned int clock_rate_base = 130000000;
  2980. + unsigned int reg_v=0;
  2981. +
  2982. + //--> Add by jason for clock adjust
  2983. + reg_v = readl(IO_ADDRESS((SL2312_GLOBAL_BASE+GLOBAL_STATUS)));
  2984. + reg_v >>= 15;
  2985. + tick_rate = (clock_rate_base + (reg_v & 0x07)*10000000);
  2986. +
  2987. + // FPGA use AHB bus tick rate
  2988. + printk("Bus: %dMHz",tick_rate/1000000);
  2989. +
  2990. + tick_rate /= 6; // APB bus run AHB*(1/6)
  2991. +
  2992. + switch((reg_v>>3)&3){
  2993. + case 0: printk("(1/1)\n") ;
  2994. + break;
  2995. + case 1: printk("(3/2)\n") ;
  2996. + break;
  2997. + case 2: printk("(24/13)\n") ;
  2998. + break;
  2999. + case 3: printk("(2/1)\n") ;
  3000. + break;
  3001. + }
  3002. + //<--
  3003. +#else
  3004. + printk("Bus: %dMHz(1/1)\n",CLOCK_TICK_RATE/1000000); // FPGA use 20MHz
  3005. + tick_rate = CLOCK_TICK_RATE;
  3006. +#endif
  3007. +
  3008. +
  3009. + /*
  3010. + * Make irqs happen for the system timer
  3011. + */
  3012. + // initialize timer interrupt
  3013. + // low active and edge trigger
  3014. +#ifdef FIQ_PLUS
  3015. + *((volatile unsigned int *)FIQ_TMODE(IO_ADDRESS(SL2312_INTERRUPT_BASE))) |= (unsigned int)(IRQ_TIMER1_MASK);
  3016. + *((volatile unsigned int *)FIQ_LEVEL(IO_ADDRESS(SL2312_INTERRUPT_BASE))) |= (unsigned int)(IRQ_TIMER1_MASK);
  3017. + setup_irq(IRQ_TIMER1, &sl2312_timer_irq);
  3018. + /* Start the timer */
  3019. + *TIMER_COUNT(IO_ADDRESS(SL2312_TIMER1_BASE))=(unsigned int)(tick_rate/HZ);
  3020. + *TIMER_LOAD(IO_ADDRESS(SL2312_TIMER1_BASE))=(unsigned int)(tick_rate/HZ);
  3021. + *TIMER_CR(IO_ADDRESS(SL2312_TIMER1_BASE))=(unsigned int)(TIMER_1_CR_ENABLE_MSK|TIMER_1_CR_INT_MSK);
  3022. +#else
  3023. + *((volatile unsigned int *)IRQ_TMODE(IO_ADDRESS(SL2312_INTERRUPT_BASE))) |= (unsigned int)(IRQ_TIMER2_MASK);
  3024. + *((volatile unsigned int *)IRQ_TLEVEL(IO_ADDRESS(SL2312_INTERRUPT_BASE))) |= (unsigned int)(IRQ_TIMER2_MASK);
  3025. + setup_irq(IRQ_TIMER2, &sl2312_timer_irq);
  3026. + /* Start the timer */
  3027. + *TIMER_COUNT(IO_ADDRESS(SL2312_TIMER2_BASE))=(unsigned int)(tick_rate/HZ);
  3028. + *TIMER_LOAD(IO_ADDRESS(SL2312_TIMER2_BASE))=(unsigned int)(tick_rate/HZ);
  3029. + *TIMER_CR(IO_ADDRESS(SL2312_TIMER1_BASE))=(unsigned int)(TIMER_2_CR_ENABLE_MSK|TIMER_2_CR_INT_MSK);
  3030. +#endif
  3031. +
  3032. +}
  3033. +
  3034. +
  3035. --- /dev/null
  3036. +++ b/arch/arm/mach-sl2312/xor.c
  3037. @@ -0,0 +1,1200 @@
  3038. +/*
  3039. + * arch/arm/mach-sl2312/xor.c
  3040. + *
  3041. + * Support functions for the Gemini Soc. This is
  3042. + * a HW XOR unit that is specifically designed for use with RAID5
  3043. + * applications. This driver provides an interface that is used by
  3044. + * the Linux RAID stack.
  3045. + *
  3046. + * Original Author: Jason Lee<[email protected]>
  3047. + *
  3048. + * Contributors:Sanders<[email protected]>
  3049. + Jason Lee<[email protected]>
  3050. + *
  3051. + *
  3052. + * Maintainer: Jason Lee<[email protected]>
  3053. + *
  3054. + * Copyright (C) 2005 Storlink Corporation
  3055. + *
  3056. + * This program is free software; you can redistribute it and/or modify
  3057. + * it under the terms of the GNU General Public License version 2 as
  3058. + * published by the Free Software Foundation.
  3059. + *
  3060. + *
  3061. + * History: (06/25/2005, DJ) Initial Creation
  3062. + *
  3063. + * Versing 1.0.0 Initial version
  3064. + */
  3065. +
  3066. +#include <linux/types.h>
  3067. +#include <linux/init.h>
  3068. +#include <linux/sched.h>
  3069. +#include <linux/spinlock.h>
  3070. +#include <linux/slab.h>
  3071. +#include <linux/errno.h>
  3072. +#include <linux/interrupt.h>
  3073. +#include <linux/sched.h>
  3074. +#include <linux/wait.h>
  3075. +#include <linux/list.h>
  3076. +#include <linux/pci.h>
  3077. +#include <linux/delay.h>
  3078. +#include <linux/dma-mapping.h>
  3079. +#include <linux/mm.h>
  3080. +#include <asm/irq.h>
  3081. +#include <asm/delay.h>
  3082. +#include <asm/uaccess.h>
  3083. +#include <asm/cacheflush.h>
  3084. +#include <asm/hardware.h>
  3085. +#include <asm/arch/xor.h>
  3086. +#include <asm/pci.h>
  3087. +#include <linux/version.h>
  3088. +
  3089. +/*
  3090. + * pick up local definitions
  3091. + */
  3092. +#define XOR_SW_FILL_IN
  3093. +#include "hw_xor.h"
  3094. +
  3095. +
  3096. +//#define XOR_DEBUG
  3097. +//#define XOR_TEST 1
  3098. +#ifdef XOR_TEST
  3099. +#define TEST_ITERATION 1000
  3100. +#define SPIN_WAIT 1
  3101. +#endif
  3102. +#ifdef XOR_DEBUG
  3103. +#define DPRINTK(s, args...) printk("Gemini XOR: " s "\n", ## args)
  3104. +#define DENTER() DPRINTK("Entered...\n");
  3105. +#define DEXIT() DPRINTK("Exited...\n");
  3106. +#else
  3107. +#define DPRINTK(s, args...)
  3108. +#define DENTER()
  3109. +#define DEXIT()
  3110. +#endif
  3111. +
  3112. +//#define SPIN_WAIT
  3113. +
  3114. +/* globals */
  3115. +static RAID_T tp;
  3116. +static RAID_TXDMA_CTRL_T txdma_ctrl;
  3117. +RAID_RXDMA_CTRL_T rxdma_ctrl;
  3118. +
  3119. +//#ifndef SPIN_WAIT
  3120. +static spinlock_t raid_lock;
  3121. +//#endif
  3122. +
  3123. +static unsigned int tx_desc_virtual_base;
  3124. +static unsigned int rx_desc_virtual_base;
  3125. +RAID_DESCRIPTOR_T *tx_desc_ptr;
  3126. +RAID_DESCRIPTOR_T *rx_desc_ptr;
  3127. +
  3128. +/* static prototypes */
  3129. +#define DMA_MALLOC(size,handle) pci_alloc_consistent(NULL,size,handle)
  3130. +#define DMA_MFREE(mem,size,handle) pci_free_consistent(NULL,size,mem,handle)
  3131. +
  3132. +static int gemini_xor_init_desc(void);
  3133. +
  3134. +static unsigned int raid_read_reg(unsigned int offset)
  3135. +{
  3136. + unsigned int reg_val;
  3137. +
  3138. + reg_val = readl(RAID_BASE_ADDR + offset);
  3139. + return (reg_val);
  3140. +}
  3141. +
  3142. +static void raid_write_reg(unsigned int offset,unsigned int data,unsigned int bit_mask)
  3143. +{
  3144. + unsigned int reg_val;
  3145. + unsigned int *addr;
  3146. +
  3147. + reg_val = ( raid_read_reg(offset) & (~bit_mask) ) | (data & bit_mask);
  3148. + addr = (unsigned int *)(RAID_BASE_ADDR + offset);
  3149. + writel(reg_val,addr);
  3150. + return;
  3151. +}
  3152. +
  3153. +#ifndef SPIN_WAIT
  3154. +__inline__ void xor_queue_descriptor(void)
  3155. +{
  3156. + unsigned int flags,status=1;
  3157. +
  3158. + DPRINTK("Going to sleep");
  3159. +
  3160. + while(status){
  3161. + yield();
  3162. + //schedule();
  3163. + spin_lock_irqsave(&raid_lock,flags);
  3164. + status = tp.busy;
  3165. + spin_unlock_irqrestore(&raid_lock, flags);
  3166. + }
  3167. +// tp.status = COMPLETE;
  3168. + DPRINTK("woken up!");
  3169. +
  3170. +}
  3171. +#endif
  3172. +
  3173. +#ifdef SPIN_WAIT
  3174. +static void gemini_xor_isr(int d_n)
  3175. +#else
  3176. +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,28)
  3177. +static void gemini_xor_isr(int irq, void *dev_id, struct pt_regs *regs)
  3178. +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
  3179. +static irqreturn_t gemini_xor_isr(int irq, void *dev_instance, struct pt_regs *regs)
  3180. +#endif
  3181. +#endif
  3182. +{
  3183. +
  3184. + unsigned int err;
  3185. + RAID_DMA_STATUS_T dma_status;
  3186. +// RAID_DESCRIPTOR_T *rdesc,*tdesc;
  3187. +// unsigned int *paddr;
  3188. +
  3189. + dma_status.bits32 = raid_read_reg(RAID_DMA_STATUS);
  3190. +#ifdef SPIN_WAIT
  3191. + while( (dma_status.bits32& (1<<31) ) ==0 ){
  3192. + udelay(1);
  3193. + dma_status.bits32 = raid_read_reg(RAID_DMA_STATUS);
  3194. + }
  3195. +
  3196. +/* tdesc = tp.tx_first_desc;
  3197. + rdesc = tp.rx_first_desc;
  3198. + for(d_n;d_n>0;d_n--){
  3199. + if( tdesc->func_ctrl.bits.own == DMA ){
  3200. + paddr = tdesc;
  3201. + printk("error tx desc:0x%x\n",*paddr++);
  3202. + printk("error tx desc:0x%x\n",*paddr++);
  3203. + printk("error tx desc:0s%x\n",*paddr++);
  3204. + printk("error tx desc:0x%x\n",*paddr);
  3205. + while(1);
  3206. + }
  3207. + tdesc = (RAID_DESCRIPTOR_T *)((tdesc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3208. + }
  3209. +
  3210. + if( rdesc->func_ctrl.bits.own == DMA ){
  3211. + paddr = rdesc;
  3212. + printk("error rx desc:0x%x\n",*paddr++);
  3213. + printk("error rx desc:0x%x\n",*paddr++);
  3214. + printk("error rx desc:0s%x\n",*paddr++);
  3215. + printk("error rx desc:0x%x\n",*paddr);
  3216. + while(1);
  3217. + }
  3218. +*/
  3219. +#endif
  3220. +
  3221. + if(dma_status.bits32 & ((1<<31)|(1<<26))){
  3222. + // if no bug , we can turn off rx finish interrupt
  3223. + dma_status.bits32 = raid_read_reg(RAID_DMA_STATUS);
  3224. + err = raid_read_reg(RAID_DMA_DEVICE_ID);
  3225. + tp.busy = 0;
  3226. +
  3227. + if(err&0x00FF0000){
  3228. + tp.status = ERROR;
  3229. + printk("XOR:<HW>%s error code %x\n",(err&0x00F00000)?"tx":"rx",err);
  3230. +
  3231. +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,28)
  3232. + return ;
  3233. +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
  3234. +#ifndef SPIN_WAIT
  3235. + return IRQ_RETVAL(IRQ_HANDLED);
  3236. +#endif
  3237. +#endif
  3238. + }
  3239. + // 16~19 rx error code
  3240. + // 20~23 tx error codd
  3241. +
  3242. + dma_status.bits.tsFinishI = 1;
  3243. + dma_status.bits.rsFinishI = 1;
  3244. + raid_write_reg(RAID_DMA_STATUS, dma_status.bits32,0x84000000); // clear INT
  3245. +
  3246. +// printk("xor %d\n",d_n);
  3247. +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,28)
  3248. + return ;
  3249. +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
  3250. +#ifndef SPIN_WAIT
  3251. + return IRQ_RETVAL(IRQ_HANDLED);
  3252. +#endif
  3253. +#endif
  3254. + }
  3255. +
  3256. + #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,28)
  3257. + return ;
  3258. + #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
  3259. + #ifndef SPIN_WAIT
  3260. + printk("XOR: DMA status register(0x%8x)\n",dma_status.bits32);
  3261. + return IRQ_RETVAL(IRQ_HANDLED);
  3262. + #endif
  3263. + #endif
  3264. +}
  3265. +
  3266. +void
  3267. +xor_gemini_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
  3268. +{
  3269. + int status=0;
  3270. + unsigned int flags;
  3271. +
  3272. + if(bytes > (1<<(SRAM_PAR_SIZE+11))){
  3273. + printk("XOR: out of SRAM partition!![0x%x]\n",(unsigned int)bytes);
  3274. + }
  3275. +
  3276. + spin_lock_irqsave(&raid_lock,flags);
  3277. + while(tp.status != COMPLETE){
  3278. + spin_unlock_irqrestore(&raid_lock, flags);
  3279. + //printk("XOR yield2\n");
  3280. +#ifdef XOR_SW_FILL_IN
  3281. + xor_arm4regs_2(bytes,p1,p2);
  3282. + return ;
  3283. +#else
  3284. + yield();
  3285. +#endif
  3286. + }
  3287. + spin_unlock_irqrestore(&raid_lock, flags);
  3288. + tp.status = RUNNING;
  3289. +
  3290. + // flush the cache to memory before H/W XOR touches them
  3291. + consistent_sync(p1, bytes, DMA_BIDIRECTIONAL);
  3292. + consistent_sync(p2, bytes, DMA_TO_DEVICE);
  3293. +
  3294. +
  3295. + tp.tx_desc = tp.tx_first_desc;
  3296. + tp.rx_desc = tp.rx_first_desc;
  3297. + if((tp.tx_desc->func_ctrl.bits.own == CPU)/*&&(tp.rx_desc->func_ctrl.bits.own == DMA)*/){
  3298. + // prepare tx descript
  3299. + raid_write_reg(RAID_FCHDMA_CURR_DESC,(unsigned int)tp.tx_desc-tx_desc_virtual_base,0xffffffff);
  3300. + tp.tx_desc->buf_addr = (unsigned int)__pa(p1); // physical address
  3301. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3302. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 2; // first descript
  3303. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3304. + tp.tx_desc->flg_status.bits32 = 0x00020000;
  3305. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3306. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3307. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3308. + wmb();
  3309. + tp.tx_desc = tp.tx_cur_desc;
  3310. + tp.tx_desc->buf_addr = (unsigned int)__pa(p2); // pysical address
  3311. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3312. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 1; // last descript
  3313. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3314. + tp.tx_desc->flg_status.bits32 = 0x00010000;
  3315. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3316. + tp.tx_desc->next_desc_addr.bits32 = 0x0000000b;// end of descript
  3317. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base); // keep last descript
  3318. +
  3319. + wmb();
  3320. + // prepare rx descript
  3321. + raid_write_reg(RAID_STRDMA_CURR_DESC,(unsigned int)tp.rx_desc-rx_desc_virtual_base,0xFFFFFFFf);
  3322. + tp.rx_desc->buf_addr = (unsigned int)__pa(p1);
  3323. + tp.rx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3324. + tp.rx_desc->flg_status.bits32 = 0; // link data from XOR
  3325. +// tp.rx_cur_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3326. + tp.rx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3327. + tp.rx_desc->next_desc_addr.bits32 = 0x0000000b;// end of descript
  3328. +
  3329. + }
  3330. + else{
  3331. + /* no free tx descriptor */
  3332. + printk("XOR:no free tx descript");
  3333. + return ;
  3334. + }
  3335. +
  3336. + // change status
  3337. +// tp.status = RUNNING;
  3338. + status = tp.busy = 1;
  3339. +
  3340. + // start tx DMA
  3341. + rxdma_ctrl.bits.rd_start = 1;
  3342. + // start rx DMA
  3343. + txdma_ctrl.bits.td_start = 1;
  3344. +
  3345. + raid_write_reg(RAID_FCHDMA_CTRL, txdma_ctrl.bits32,0x80000000);
  3346. + raid_write_reg(RAID_STRDMA_CTRL, rxdma_ctrl.bits32,0x80000000);
  3347. +
  3348. +#ifdef SPIN_WAIT
  3349. + gemini_xor_isr(2);
  3350. +#else
  3351. + xor_queue_descriptor();
  3352. +#endif
  3353. +
  3354. + tp.tx_desc->next_desc_addr.bits32 = ((unsigned long)tp.tx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*2) ;
  3355. + tp.status = COMPLETE;
  3356. +// tp.rx_desc->next_desc_addr.bits32 = ((unsigned long)tp.rx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*1) ;
  3357. +// tp.rx_desc = tp.rx_first_desc ;
  3358. +// tp.rx_desc->func_ctrl.bits.own = DMA;
  3359. +
  3360. +}
  3361. +
  3362. +void
  3363. +xor_gemini_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
  3364. + unsigned long *p3)
  3365. +{
  3366. + int status=0;
  3367. + unsigned int flags;
  3368. +
  3369. + if(bytes > (1<<(SRAM_PAR_SIZE+11))){
  3370. + printk("XOR: out of SRAM partition!![0x%x]\n",(unsigned int)bytes);
  3371. + }
  3372. +
  3373. + spin_lock_irqsave(&raid_lock,flags);
  3374. + if(tp.status != COMPLETE){
  3375. + spin_unlock_irqrestore(&raid_lock, flags);
  3376. + //printk("XOR yield3\n");
  3377. +#ifdef XOR_SW_FILL_IN
  3378. + xor_arm4regs_3(bytes,p1,p2,p3);
  3379. + return;
  3380. +#else
  3381. + yield();
  3382. +#endif
  3383. + }
  3384. + spin_unlock_irqrestore(&raid_lock, flags);
  3385. + tp.status = RUNNING;
  3386. +
  3387. + // flush the cache to memory before H/W XOR touches them
  3388. + consistent_sync(p1, bytes, DMA_BIDIRECTIONAL);
  3389. + consistent_sync(p2, bytes, DMA_TO_DEVICE);
  3390. + consistent_sync(p3, bytes, DMA_TO_DEVICE);
  3391. +
  3392. + tp.tx_desc = tp.tx_first_desc;
  3393. + tp.rx_desc = tp.rx_first_desc;
  3394. + if((tp.tx_desc->func_ctrl.bits.own == CPU)/*&&(tp.rx_desc->func_ctrl.bits.own == DMA)*/){
  3395. + // prepare tx descript
  3396. + raid_write_reg(RAID_FCHDMA_CURR_DESC,(unsigned int)tp.tx_desc-tx_desc_virtual_base,0xffffffff);
  3397. + tp.tx_desc->buf_addr = (unsigned int)__pa(p1); // physical address
  3398. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3399. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 2; // first descript
  3400. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3401. + tp.tx_desc->flg_status.bits32 = 0x00020000;
  3402. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3403. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3404. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3405. +
  3406. + tp.tx_desc = tp.tx_cur_desc;
  3407. + tp.tx_desc->buf_addr = (unsigned int)__pa(p2); // pysical address
  3408. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3409. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 0; // first descript
  3410. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3411. + tp.tx_desc->flg_status.bits32 = 0x0000000;
  3412. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3413. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3414. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3415. +
  3416. + tp.tx_desc = tp.tx_cur_desc;
  3417. + tp.tx_desc->buf_addr = (unsigned int)__pa(p3); // pysical address
  3418. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3419. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 1; // last descript
  3420. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3421. + tp.tx_desc->flg_status.bits32 = 0x00010000;
  3422. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3423. + tp.tx_desc->next_desc_addr.bits32 = 0x0000000b;// end of descript
  3424. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base); // keep last descript
  3425. +
  3426. + // prepare rx descript
  3427. + raid_write_reg(RAID_STRDMA_CURR_DESC,(unsigned int)tp.rx_desc-rx_desc_virtual_base,0xFFFFFFFf);
  3428. + tp.rx_desc->buf_addr = (unsigned int)__pa(p1);
  3429. + tp.rx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3430. + tp.rx_desc->flg_status.bits32 = 0; // link data from XOR
  3431. +// tp.rx_cur_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3432. + tp.rx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3433. + tp.rx_desc->next_desc_addr.bits32 = 0x0000000b;// end of descript
  3434. +
  3435. + }
  3436. + else{
  3437. + /* no free tx descriptor */
  3438. + printk("XOR:no free tx descript \n");
  3439. + return ;
  3440. + }
  3441. +
  3442. + // change status
  3443. +// tp.status = RUNNING;
  3444. + status = tp.busy = 1;
  3445. +
  3446. + // start tx DMA
  3447. + rxdma_ctrl.bits.rd_start = 1;
  3448. + // start rx DMA
  3449. + txdma_ctrl.bits.td_start = 1;
  3450. + wmb();
  3451. + raid_write_reg(RAID_FCHDMA_CTRL, txdma_ctrl.bits32,0x80000000);
  3452. + raid_write_reg(RAID_STRDMA_CTRL, rxdma_ctrl.bits32,0x80000000);
  3453. +
  3454. +#ifdef SPIN_WAIT
  3455. + gemini_xor_isr(3);
  3456. +#else
  3457. + xor_queue_descriptor();
  3458. +#endif
  3459. + tp.tx_desc->next_desc_addr.bits32 = ((unsigned long)tp.tx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*3) | 0x0B;
  3460. + tp.status = COMPLETE;
  3461. +// tp.rx_desc->next_desc_addr.bits32 = ((unsigned long)tp.rx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*1) | 0x0B;
  3462. + //tp.rx_desc = tp.rx_first_desc ;
  3463. +// tp.rx_desc->func_ctrl.bits.own = DMA;
  3464. +
  3465. +}
  3466. +
  3467. +void
  3468. +xor_gemini_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
  3469. + unsigned long *p3, unsigned long *p4)
  3470. +{
  3471. + int status=0;
  3472. + unsigned int flags;
  3473. +
  3474. + if(bytes > (1<<(SRAM_PAR_SIZE+11))){
  3475. + printk("XOR: out of SRAM partition!![0x%x]\n",(unsigned int)bytes);
  3476. + }
  3477. +
  3478. + spin_lock_irqsave(&raid_lock,flags);
  3479. + if(tp.status != COMPLETE){
  3480. + spin_unlock_irqrestore(&raid_lock, flags);
  3481. + //printk("S\n");
  3482. +#ifdef XOR_SW_FILL_IN
  3483. + xor_arm4regs_4(bytes,p1,p2,p3,p4);
  3484. + return;
  3485. +#else
  3486. + msleep(1);
  3487. + yield();
  3488. +#endif
  3489. + }
  3490. + spin_unlock_irqrestore(&raid_lock, flags);
  3491. +
  3492. + tp.status = RUNNING;
  3493. +
  3494. + // flush the cache to memory before H/W XOR touches them
  3495. + consistent_sync(p1, bytes, DMA_BIDIRECTIONAL);
  3496. + consistent_sync(p2, bytes, DMA_TO_DEVICE);
  3497. + consistent_sync(p3, bytes, DMA_TO_DEVICE);
  3498. + consistent_sync(p4, bytes, DMA_TO_DEVICE);
  3499. +
  3500. + tp.tx_desc = tp.tx_first_desc;
  3501. + tp.rx_desc = tp.rx_first_desc;
  3502. + if((tp.tx_desc->func_ctrl.bits.own == CPU)/*&&(tp.rx_desc->func_ctrl.bits.own == DMA)*/){
  3503. + // prepare tx descript
  3504. + raid_write_reg(RAID_FCHDMA_CURR_DESC,(unsigned int)tp.tx_desc-tx_desc_virtual_base,0xffffffff);
  3505. + tp.tx_desc->buf_addr = (unsigned int)__pa(p1); // physical address
  3506. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3507. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 2; // first descript
  3508. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3509. + tp.tx_desc->flg_status.bits32 = 0x00020000;
  3510. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3511. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3512. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3513. +
  3514. + tp.tx_desc = tp.tx_cur_desc;
  3515. + tp.tx_cur_desc->buf_addr = (unsigned int)__pa(p2); // pysical address
  3516. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3517. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 0; // first descript
  3518. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3519. + tp.tx_desc->flg_status.bits32 = 0x00000000;
  3520. + tp.tx_cur_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3521. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3522. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3523. +
  3524. + tp.tx_desc = tp.tx_cur_desc;
  3525. + tp.tx_desc->buf_addr = (unsigned int)__pa(p3); // pysical address
  3526. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3527. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 0; // first descript
  3528. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3529. + tp.tx_desc->flg_status.bits32 = 0x00000000;
  3530. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3531. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3532. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3533. +
  3534. +
  3535. + tp.tx_desc = tp.tx_cur_desc;
  3536. + tp.tx_desc->buf_addr = (unsigned int)__pa(p4); // pysical address
  3537. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3538. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 1; // last descript
  3539. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3540. + tp.tx_desc->flg_status.bits32 = 0x00010000;
  3541. +// tp.tx_cur_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3542. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3543. + tp.tx_desc->next_desc_addr.bits32 = 0x0000000b;// end of descript
  3544. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base); // keep last descript
  3545. +
  3546. + // prepare rx descript
  3547. + raid_write_reg(RAID_STRDMA_CURR_DESC,(unsigned int)tp.rx_desc-rx_desc_virtual_base,0xFFFFFFFF);
  3548. + tp.rx_desc->buf_addr = (unsigned int)__pa(p1);
  3549. + tp.rx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3550. + tp.rx_desc->flg_status.bits32 = 0; // link data from XOR
  3551. +// tp.rx_cur_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3552. + tp.rx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3553. + tp.rx_desc->next_desc_addr.bits32 = 0x0000000b;// end of descript
  3554. +
  3555. + }
  3556. + else{
  3557. + /* no free tx descriptor */
  3558. + printk("XOR:no free tx descript");
  3559. + return ;
  3560. + }
  3561. +
  3562. + // change status
  3563. +// tp.status = RUNNING;
  3564. + status = tp.busy = 1;
  3565. +
  3566. + // start tx DMA
  3567. + rxdma_ctrl.bits.rd_start = 1;
  3568. + // start rx DMA
  3569. + txdma_ctrl.bits.td_start = 1;
  3570. + wmb();
  3571. + raid_write_reg(RAID_FCHDMA_CTRL, txdma_ctrl.bits32,0x80000000);
  3572. + raid_write_reg(RAID_STRDMA_CTRL, rxdma_ctrl.bits32,0x80000000);
  3573. +
  3574. +#ifdef SPIN_WAIT
  3575. + gemini_xor_isr(4);
  3576. +#else
  3577. + xor_queue_descriptor();
  3578. +#endif
  3579. +
  3580. + tp.tx_desc->next_desc_addr.bits32 = ((unsigned long)tp.tx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*4) | 0x0B;
  3581. + tp.status = COMPLETE;
  3582. +// tp.rx_desc->next_desc_addr.bits32 = ((unsigned long)tp.rx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*1) | 0x0B;
  3583. + //tp.rx_desc = tp.rx_first_desc ;
  3584. +// tp.rx_desc->func_ctrl.bits.own = DMA;
  3585. +
  3586. +}
  3587. +
  3588. +void
  3589. +xor_gemini_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
  3590. + unsigned long *p3, unsigned long *p4, unsigned long *p5)
  3591. +{
  3592. +
  3593. + int status=0;
  3594. + unsigned int flags;
  3595. +
  3596. +
  3597. + if(bytes > (1<<(SRAM_PAR_SIZE+11))){
  3598. + printk("XOR: out of SRAM partition!![0x%x]\n",(unsigned int)bytes);
  3599. + }
  3600. +
  3601. + spin_lock_irqsave(&raid_lock,flags);
  3602. + while(tp.status != COMPLETE){
  3603. + spin_unlock_irqrestore(&raid_lock, flags);
  3604. + //printk("XOR yield5\n");
  3605. +#ifdef XOR_SW_FILL_IN
  3606. + xor_arm4regs_5(bytes,p1,p2,p3,p4,p5);
  3607. + return;
  3608. +#else
  3609. + msleep(1);
  3610. + yield();
  3611. +#endif
  3612. + }
  3613. + spin_unlock_irqrestore(&raid_lock, flags);
  3614. + tp.status = RUNNING;
  3615. +
  3616. + // flush the cache to memory before H/W XOR touches them
  3617. + consistent_sync(p1, bytes, DMA_BIDIRECTIONAL);
  3618. + consistent_sync(p2, bytes, DMA_TO_DEVICE);
  3619. + consistent_sync(p3, bytes, DMA_TO_DEVICE);
  3620. + consistent_sync(p4, bytes, DMA_TO_DEVICE);
  3621. + consistent_sync(p5, bytes, DMA_TO_DEVICE);
  3622. +
  3623. + tp.tx_desc = tp.tx_first_desc;
  3624. + tp.rx_desc = tp.rx_first_desc;
  3625. + if((tp.tx_desc->func_ctrl.bits.own == CPU)/*&&(tp.rx_desc->func_ctrl.bits.own == DMA)*/){
  3626. + // prepare tx descript
  3627. + raid_write_reg(RAID_FCHDMA_CURR_DESC,(unsigned int)tp.tx_desc-tx_desc_virtual_base,0xffffffff);
  3628. + tp.tx_desc->buf_addr = (unsigned int)__pa(p1); // physical address
  3629. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3630. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 2; // first descript
  3631. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3632. + tp.tx_desc->flg_status.bits32 = 0x00020000;
  3633. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3634. + wmb();
  3635. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3636. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3637. +
  3638. + tp.tx_desc = tp.tx_cur_desc;
  3639. + tp.tx_desc->buf_addr = (unsigned int)__pa(p2); // pysical address
  3640. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3641. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 0; // first descript
  3642. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3643. + tp.tx_desc->flg_status.bits32 = 0x00000000;
  3644. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3645. + wmb();
  3646. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3647. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3648. +
  3649. + tp.tx_desc = tp.tx_cur_desc;
  3650. + tp.tx_desc->buf_addr = (unsigned int)__pa(p3); // pysical address
  3651. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3652. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 0; // first descript
  3653. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3654. + tp.tx_desc->flg_status.bits32 = 0x00000000;
  3655. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3656. + wmb();
  3657. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3658. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3659. +
  3660. + tp.tx_desc = tp.tx_cur_desc;
  3661. + tp.tx_desc->buf_addr = (unsigned int)__pa(p4); // pysical address
  3662. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3663. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 0; // first descript
  3664. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3665. + tp.tx_desc->flg_status.bits32 = 0x00000000;
  3666. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3667. + wmb();
  3668. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3669. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3670. +
  3671. +
  3672. + tp.tx_desc = tp.tx_cur_desc;
  3673. + tp.tx_desc->buf_addr = (unsigned int)__pa(p5); // pysical address
  3674. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3675. +// tp.tx_desc->flg_status.bits_cmd_status.bcc = 1; // last descript
  3676. +// tp.tx_desc->flg_status.bits_cmd_status.mode = 0; // only support XOR command
  3677. +// tp.tx_cur_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3678. + tp.tx_desc->flg_status.bits32 = 0x00010000;
  3679. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3680. + tp.tx_desc->next_desc_addr.bits32 = 0x0000000b;// end of descript
  3681. + tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xfffffff0)+tx_desc_virtual_base);
  3682. + tp.tx_finished_desc = tp.tx_desc; // keep last descript
  3683. +
  3684. + // prepare rx descript
  3685. + raid_write_reg(RAID_STRDMA_CURR_DESC,(unsigned int)tp.rx_desc-rx_desc_virtual_base,0xFFFFFFFF);
  3686. + tp.rx_desc->buf_addr = (unsigned int)__pa(p1);
  3687. + tp.rx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3688. + tp.rx_desc->flg_status.bits32 = 0; // link data from XOR
  3689. +// tp.rx_cur_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3690. + tp.rx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3691. + tp.rx_desc->next_desc_addr.bits32 = 0x0000000b;// end of descript
  3692. +
  3693. + }
  3694. + else{
  3695. + /* no free tx descriptor */
  3696. + printk("XOR:no free tx descript");
  3697. + return ;
  3698. + }
  3699. +
  3700. + // change status
  3701. +// tp.status = RUNNING;
  3702. + status = tp.busy = 1;
  3703. +
  3704. + // start tx DMA
  3705. + rxdma_ctrl.bits.rd_start = 1;
  3706. + // start rx DMA
  3707. + txdma_ctrl.bits.td_start = 1;
  3708. + wmb();
  3709. + raid_write_reg(RAID_FCHDMA_CTRL, txdma_ctrl.bits32,0x80000000);
  3710. + raid_write_reg(RAID_STRDMA_CTRL, rxdma_ctrl.bits32,0x80000000);
  3711. +
  3712. +#ifdef SPIN_WAIT
  3713. + gemini_xor_isr(5);
  3714. +#else
  3715. + xor_queue_descriptor();
  3716. +#endif
  3717. +
  3718. + tp.tx_desc->next_desc_addr.bits32 = ((unsigned long)tp.tx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*5) | 0x0B;
  3719. + tp.status = COMPLETE;
  3720. +// tp.rx_desc->next_desc_addr.bits32 = ((unsigned long)tp.rx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*1) | 0x0B;
  3721. + //tp.rx_desc = tp.rx_first_desc ;
  3722. +// tp.rx_desc->func_ctrl.bits.own = DMA;
  3723. +
  3724. +}
  3725. +
  3726. +#ifdef XOR_TEST
  3727. +void
  3728. +raid_memset(unsigned int *p1, unsigned int pattern, unsigned int bytes)
  3729. +{
  3730. + int status=0,i;
  3731. +
  3732. + if(bytes > (1<<(SRAM_PAR_SIZE+11))){
  3733. + printk("XOR: out of SRAM partition!![0x%x]\n",(unsigned int)bytes);
  3734. + }
  3735. +
  3736. + *p1 = pattern;
  3737. +
  3738. + // flush the cache to memory before H/W XOR touches them
  3739. + consistent_sync(p1, bytes, DMA_BIDIRECTIONAL);
  3740. +
  3741. + while(tp.status != COMPLETE){
  3742. + DPRINTK("XOR yield\n");
  3743. + //schedule();
  3744. + yield();
  3745. + }
  3746. + tp.status = RUNNING;
  3747. +
  3748. + tp.tx_desc = tp.tx_first_desc;
  3749. + tp.rx_desc = tp.rx_first_desc;
  3750. + if((tp.tx_desc->func_ctrl.bits.own == CPU)/*&&(tp.rx_desc->func_ctrl.bits.own == DMA)*/){
  3751. + // prepare tx descript
  3752. + raid_write_reg(RAID_FCHDMA_CURR_DESC,(unsigned int)tp.tx_desc-tx_desc_virtual_base,0xFFFFFFFF);
  3753. + tp.tx_desc->buf_addr = (unsigned int)__pa(p1); // physical address
  3754. + tp.tx_desc->func_ctrl.bits.buffer_size = 4; /* total frame byte count */
  3755. + tp.tx_desc->flg_status.bits_cmd_status.bcc = bytes; // bytes to fill
  3756. + tp.tx_desc->flg_status.bits_cmd_status.mode = CMD_FILL; // only support memory FILL command
  3757. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3758. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3759. + tp.tx_desc->next_desc_addr.bits32 = 0x0000000b;
  3760. +// tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xFFFFFFF0)+tx_desc_virtual_base);
  3761. +
  3762. + // prepare rx descript
  3763. + raid_write_reg(RAID_STRDMA_CURR_DESC,(unsigned int)tp.rx_desc-rx_desc_virtual_base,0xFFFFFFFF);
  3764. + tp.rx_desc->buf_addr = (unsigned int)__pa(p1);
  3765. + tp.rx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3766. + tp.rx_desc->flg_status.bits32 = 0; // link data from XOR
  3767. + tp.rx_cur_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3768. + tp.rx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3769. +// tp.rx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.rx_cur_desc->next_desc_addr.bits32 & 0xfffffff0)+rx_desc_virtual_base);
  3770. + tp.rx_desc->next_desc_addr.bits32 = 0x0000000b;// end of descript
  3771. + tp.rx_finished_desc = tp.rx_desc;
  3772. +
  3773. + }
  3774. + else{
  3775. + /* no free tx descriptor */
  3776. + printk("XOR:no free tx descript");
  3777. + return ;
  3778. + }
  3779. +
  3780. + // change status
  3781. + //tp.status = RUNNING;
  3782. + status = tp.busy = 1;
  3783. +
  3784. + // start tx DMA
  3785. + rxdma_ctrl.bits.rd_start = 1;
  3786. + // start rx DMA
  3787. + txdma_ctrl.bits.td_start = 1;
  3788. +
  3789. + raid_write_reg(RAID_FCHDMA_CTRL, txdma_ctrl.bits32,0x80000000);
  3790. + raid_write_reg(RAID_STRDMA_CTRL, rxdma_ctrl.bits32,0x80000000);
  3791. +
  3792. +#ifdef SPIN_WAIT
  3793. + gemini_xor_isr(2);
  3794. +#else
  3795. + xor_queue_descriptor();
  3796. +#endif
  3797. +
  3798. + for(i=1; i<(bytes/sizeof(int)); i++) {
  3799. + if(p1[0]!=p1[i]){
  3800. + printk("pattern set error!\n");
  3801. + while(1);
  3802. + }
  3803. + }
  3804. +
  3805. + tp.tx_desc->next_desc_addr.bits32 = ((unsigned long)tp.tx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*1) ;
  3806. + tp.status = COMPLETE;
  3807. +// tp.rx_desc->next_desc_addr.bits32 = ((unsigned long)tp.rx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*1) ;
  3808. + //tp.rx_desc = tp.rx_first_desc ;
  3809. +// tp.rx_desc->func_ctrl.bits.own = DMA;
  3810. +
  3811. +}
  3812. +#endif
  3813. +
  3814. +void
  3815. +raid_memcpy(unsigned int *to, unsigned int *from, unsigned int bytes)
  3816. +{
  3817. + int status=0,i;
  3818. +
  3819. + if(bytes > (1<<(SRAM_PAR_SIZE+11))){
  3820. + printk("XOR: out of SRAM partition!![0x%x]\n",(unsigned int)bytes);
  3821. + }
  3822. +
  3823. + // flush the cache to memory before H/W XOR touches them
  3824. + consistent_sync(to, bytes, DMA_BIDIRECTIONAL);
  3825. + consistent_sync(from,bytes, DMA_TO_DEVICE);
  3826. +
  3827. + while(tp.status != COMPLETE){
  3828. + DPRINTK("XOR yield\n");
  3829. + //schedule();
  3830. + yield();
  3831. + }
  3832. + tp.status = RUNNING;
  3833. +
  3834. + tp.tx_desc = tp.tx_first_desc;
  3835. + tp.rx_desc = tp.rx_first_desc;
  3836. + if((tp.tx_desc->func_ctrl.bits.own == CPU)/*&&(tp.rx_desc->func_ctrl.bits.own == DMA)*/){
  3837. + // prepare tx descript
  3838. + raid_write_reg(RAID_FCHDMA_CURR_DESC,(unsigned int)tp.tx_desc-tx_desc_virtual_base,0xFFFFFFFF);
  3839. + tp.tx_desc->buf_addr = (unsigned int)__pa(from); // physical address
  3840. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3841. + tp.tx_desc->flg_status.bits32 = CMD_CPY; // only support memory FILL command
  3842. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3843. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3844. + tp.tx_desc->next_desc_addr.bits32 = 0x0000000b;
  3845. +// tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xFFFFFFF0)+tx_desc_virtual_base);
  3846. +
  3847. + // prepare rx descript
  3848. + raid_write_reg(RAID_STRDMA_CURR_DESC,(unsigned int)tp.rx_desc-rx_desc_virtual_base,0xFFFFFFFF);
  3849. + tp.rx_desc->buf_addr = (unsigned int)__pa(to);
  3850. + tp.rx_desc->func_ctrl.bits.buffer_size = bytes; /* total frame byte count */
  3851. + tp.rx_desc->flg_status.bits32 = 0; // link data from XOR
  3852. + tp.rx_cur_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3853. + tp.rx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3854. +// tp.rx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.rx_cur_desc->next_desc_addr.bits32 & 0xfffffff0)+rx_desc_virtual_base);
  3855. + tp.rx_desc->next_desc_addr.bits32 = 0x0000000b;// end of descript
  3856. +
  3857. + }
  3858. + else{
  3859. + /* no free tx descriptor */
  3860. + printk("XOR:no free tx descript");
  3861. + return ;
  3862. + }
  3863. +
  3864. + // change status
  3865. + //tp.status = RUNNING;
  3866. + status = tp.busy = 1;
  3867. +
  3868. + // start tx DMA
  3869. + rxdma_ctrl.bits.rd_start = 1;
  3870. + // start rx DMA
  3871. + txdma_ctrl.bits.td_start = 1;
  3872. +
  3873. + raid_write_reg(RAID_FCHDMA_CTRL, txdma_ctrl.bits32,0x80000000);
  3874. + raid_write_reg(RAID_STRDMA_CTRL, rxdma_ctrl.bits32,0x80000000);
  3875. +
  3876. +#ifdef SPIN_WAIT
  3877. + gemini_xor_isr(2);
  3878. +#else
  3879. + xor_queue_descriptor();
  3880. +#endif
  3881. +
  3882. +#ifdef XOR_TEST
  3883. + for(i=1; i<(bytes/sizeof(int)); i++) {
  3884. + if(to[i]!=from[i]){
  3885. + printk("pattern check error!\n");
  3886. + printk("offset=0x%x p1=%x p2=%x\n",i*4,to[i],from[i]);
  3887. + while(1);
  3888. + }
  3889. + }
  3890. +#endif
  3891. +
  3892. + tp.tx_desc->next_desc_addr.bits32 = ((unsigned long)tp.tx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*1) ;
  3893. + tp.status = COMPLETE;
  3894. +// tp.rx_desc->next_desc_addr.bits32 = ((unsigned long)tp.rx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*1) ;
  3895. + //tp.rx_desc = tp.rx_first_desc ;
  3896. +// tp.rx_desc->func_ctrl.bits.own = DMA;
  3897. +
  3898. +}
  3899. +EXPORT_SYMBOL(raid_memcpy);
  3900. +
  3901. +#ifdef XOR_TEST
  3902. +int
  3903. +raid_memchk(unsigned int *p1, unsigned int pattern, unsigned int bytes)
  3904. +{
  3905. + int status=0;
  3906. + RAID_DMA_STATUS_T dma_status;
  3907. +
  3908. + if(bytes > (1<<(SRAM_PAR_SIZE+11))){
  3909. + printk("XOR: out of SRAM partition!![0x%x]\n",(unsigned int)bytes);
  3910. + }
  3911. +
  3912. + status = ((pattern&0xFFFF)%bytes )/4;
  3913. + p1[status] = pattern;
  3914. +
  3915. + while(tp.status != COMPLETE){
  3916. + DPRINTK("XOR yield\n");
  3917. + //schedule();
  3918. + yield();
  3919. + }
  3920. + tp.status = RUNNING;
  3921. +
  3922. + // flush the cache to memory before H/W XOR touches them
  3923. + consistent_sync(p1, bytes, DMA_BIDIRECTIONAL);
  3924. +
  3925. + tp.tx_desc = tp.tx_first_desc;
  3926. + if((tp.tx_desc->func_ctrl.bits.own == CPU)/*&&(tp.rx_desc->func_ctrl.bits.own == DMA)*/){
  3927. + // prepare tx descript
  3928. + raid_write_reg(RAID_FCHDMA_CURR_DESC,(unsigned int)tp.tx_desc-tx_desc_virtual_base,0xFFFFFFFF);
  3929. + tp.tx_desc->buf_addr = (unsigned int)__pa(p1); // physical address
  3930. + tp.tx_desc->func_ctrl.bits.raid_ctrl_status = 0;
  3931. + tp.tx_desc->func_ctrl.bits.buffer_size = bytes ; /* total frame byte count */
  3932. + tp.tx_desc->flg_status.bits32 = CMD_CHK; // only support memory FILL command
  3933. + tp.tx_desc->next_desc_addr.bits.sof_eof = 0x03; /*only one descriptor*/
  3934. + tp.tx_desc->func_ctrl.bits.own = DMA; /* set owner bit */
  3935. + tp.tx_desc->next_desc_addr.bits32 = 0x0000000b;
  3936. +// tp.tx_cur_desc = (RAID_DESCRIPTOR_T *)((tp.tx_desc->next_desc_addr.bits32 & 0xFFFFFFF0)+tx_desc_virtual_base);
  3937. +
  3938. + }
  3939. + else{
  3940. + /* no free tx descriptor */
  3941. + printk("XOR:no free tx descript");
  3942. + return -1;
  3943. + }
  3944. +
  3945. + // change status
  3946. + //tp.status = RUNNING;
  3947. + status = tp.busy = 1;
  3948. +
  3949. + // start tx DMA
  3950. + txdma_ctrl.bits.td_start = 1;
  3951. +
  3952. + raid_write_reg(RAID_FCHDMA_CTRL, txdma_ctrl.bits32,0x80000000);
  3953. +// raid_write_reg(RAID_STRDMA_CTRL, rxdma_ctrl.bits32,0x80000000);
  3954. +
  3955. +#ifdef SPIN_WAIT
  3956. + gemini_xor_isr(2);
  3957. +#else
  3958. + xor_queue_descriptor();
  3959. +#endif
  3960. +
  3961. +// dma_status.bits32 = raid_read_reg(RAID_DMA_STATUS);
  3962. +// if (dma_status.bits32 & (1<<15)) {
  3963. +
  3964. + if((tp.tx_first_desc->func_ctrl.bits.raid_ctrl_status & 0x2)) {
  3965. + status = 1;
  3966. +// raid_write_reg(RAID_DMA_STATUS,0x00008000,0x00080000);
  3967. + }
  3968. + else{
  3969. + status = 0;
  3970. + }
  3971. +
  3972. + tp.tx_desc->next_desc_addr.bits32 = ((unsigned long)tp.tx_first_desc - tx_desc_virtual_base + sizeof(RAID_DESCRIPTOR_T)*1) ;
  3973. + tp.status = COMPLETE;
  3974. +// tp.rx_desc->func_ctrl.bits.own = DMA;
  3975. + return status ;
  3976. +}
  3977. +#endif
  3978. +
  3979. +int __init gemini_xor_init(void)
  3980. +{
  3981. + unsigned int res;
  3982. + unsigned int *paddr1,*paddr2,*paddr3,i;
  3983. + unsigned volatile char *charact;
  3984. + unsigned volatile short *two_char;
  3985. + unsigned volatile int *four_char;
  3986. +
  3987. + // init descript
  3988. + res = gemini_xor_init_desc();
  3989. + if(res) {
  3990. + printk("Init RAID Descript Fail!!\n");
  3991. + return -res;
  3992. + }
  3993. +
  3994. + tp.device_name = "Gemini XOR Acceleration";
  3995. +
  3996. + // request irq
  3997. +#ifndef SPIN_WAIT
  3998. + res = request_irq(IRQ_RAID, gemini_xor_isr, SA_INTERRUPT, tp.device_name, NULL);
  3999. +#endif
  4000. + if(res){
  4001. + printk(KERN_ERR "%s: unable to request IRQ %d for "
  4002. + "HW XOR %d\n", tp.device_name, IRQ_RAID, res);
  4003. + return -EBUSY;
  4004. + }
  4005. +
  4006. +#ifdef XOR_TEST
  4007. +
  4008. +RETEST:
  4009. + paddr1 = kmalloc(0x1000,GFP_KERNEL);
  4010. + paddr2 = kmalloc(0x1000,GFP_KERNEL);
  4011. + paddr3 = kmalloc(0x1000,GFP_KERNEL);
  4012. + for(i=0;i<TEST_ITERATION;i++) {
  4013. + printk("XOR test round %d\n",i);
  4014. + for(res=0;res<(0x1000)/sizeof(int);res++){ // prepare data pattern
  4015. + paddr1[res]= readl(0xf62000ac);
  4016. + paddr2[res]= readl(0xf62000ac);
  4017. + }
  4018. + for(res=0;res<0x1000/sizeof(int);res++){ // calculate xor by software
  4019. + paddr3[res] = paddr1[res]^paddr2[res];
  4020. + }
  4021. + xor_gemini_2(0x1000,paddr1,paddr2); // calculate xor by hw
  4022. + for(res=0;res<0x1000/sizeof(int);res++){ // check error
  4023. + if(paddr1[res]!=paddr3[res]){
  4024. + printk("XOR ERROR\n");
  4025. + printk("[%d][0x%x]=0x%x should be %x\n",res,&paddr1[res],paddr1[res],paddr3[res]);
  4026. + while(1);
  4027. + }
  4028. + }
  4029. + }
  4030. + kfree(paddr1);
  4031. + kfree(paddr2);
  4032. + kfree(paddr3);
  4033. +
  4034. +
  4035. + // memcpy test
  4036. + paddr1 = kmalloc(0x4000,GFP_KERNEL);
  4037. + for(i=0;i<TEST_ITERATION;i++) {
  4038. + for(res=0;res<(0x4000)/sizeof(int);res++)
  4039. + paddr1[res]= readl(0xf62000ac);
  4040. +
  4041. + printk("MEMCOPY round %d\n",i);
  4042. + paddr2 = kmalloc(0x4000,GFP_KERNEL);
  4043. + raid_memcpy(paddr2,paddr1,0x4000);
  4044. + kfree(paddr2);
  4045. + }
  4046. + kfree(paddr1);
  4047. +
  4048. + // memset test
  4049. + for(i=0;i<TEST_ITERATION;i++) {
  4050. + raid_memset(paddr1,0xFFFFFFFF,0x4000);
  4051. + res = readl(0xf62000ac);
  4052. + printk("MEMFILL fill 0x%x round %d\n",res,i);
  4053. + paddr1 = kmalloc(0x4000,GFP_KERNEL);
  4054. + raid_memset(paddr1,res,0x4000);
  4055. + raid_memset(paddr1,0x0,0x4000);
  4056. + kfree(paddr1);
  4057. + }
  4058. +
  4059. + paddr1 = kmalloc(0x4000,GFP_KERNEL);
  4060. + for(i=0;i<TEST_ITERATION;i++){
  4061. + raid_memset(paddr1, i,0x4000);
  4062. + printk("Pattern check same ? ");
  4063. + res = raid_memchk(paddr1, i,0x4000);
  4064. + printk("%s\n",res?"Fail":"OK");
  4065. + if(res) while(1);
  4066. +
  4067. + printk("Pattern check diff ? ");
  4068. + res = raid_memchk(paddr1,readl(0xf62000ac),0x4000);
  4069. + printk("%s\n",res?"OK":"Fail");
  4070. + if(!res) while(1);
  4071. + }
  4072. + kfree(paddr1);
  4073. +
  4074. + // SRAM test
  4075. + raid_write_reg(RAID_PCR, 0,0x00000003);
  4076. + for(i=0;i<TEST_ITERATION;i++) {
  4077. + printk("SRAM test %d\n",i);
  4078. + charact = 0xF7000000;
  4079. + two_char = 0xF7000000;
  4080. + four_char = 0xF7000000;
  4081. + for(res=0;res<(16*1024)/sizeof(char);res++) { // 8-bit access
  4082. + *charact++ = (unsigned char)res;
  4083. + }
  4084. + charact = 0xF7000000;
  4085. + for(res=0;res<(16*1024)/sizeof(char);res++) {
  4086. + if(*charact++ != (unsigned char)res){
  4087. + printk("SRAM data error(8)\n");
  4088. + while(1);
  4089. + }
  4090. + }
  4091. +
  4092. + for(res=0;res<(16*1024)/sizeof(short);res++) { // 16-bit access
  4093. + *two_char++ = (unsigned short)res;
  4094. + }
  4095. + two_char = 0xF7000000;
  4096. + for(res=0;res<(16*1024)/sizeof(short);res++) {
  4097. + if(*two_char++ != (unsigned short)res){
  4098. + printk("SRAM data error(16)\n");
  4099. + while(1);
  4100. + }
  4101. + }
  4102. +
  4103. + for(res=0;res<(16*1024)/sizeof(int);res++) { // 32-bit access
  4104. + *four_char++ = (unsigned int)res;
  4105. + }
  4106. + four_char = 0xF7000000;
  4107. + for(res=0;res<(16*1024)/sizeof(int);res++) {
  4108. + if(*four_char++ != (unsigned int)res){
  4109. + printk("SRAM data error(32)\n");
  4110. + while(1);
  4111. + }
  4112. + }
  4113. + }
  4114. + raid_write_reg(RAID_PCR, SRAM_PAR_SIZE,0x00000003);
  4115. +
  4116. +#endif
  4117. + return 0;
  4118. +}
  4119. +
  4120. +void __exit gemini_xor_exit(void)
  4121. +{
  4122. + DMA_MFREE(tp.tx_desc, TX_DESC_NUM*sizeof(RAID_DESCRIPTOR_T),(unsigned int)tp.tx_desc_dma);
  4123. + DMA_MFREE(tp.rx_desc, RX_DESC_NUM*sizeof(RAID_DESCRIPTOR_T),(unsigned int)tp.rx_desc_dma);
  4124. + free_irq(IRQ_RAID, NULL);
  4125. +}
  4126. +
  4127. +
  4128. +static int gemini_xor_init_desc(void)
  4129. +{
  4130. + unsigned int i;
  4131. + dma_addr_t tx_first_desc_dma;
  4132. + dma_addr_t rx_first_desc_dma;
  4133. + RAID_DMA_STATUS_T dma_status;
  4134. +
  4135. + printk("Initial RAID Descripter...\n");
  4136. +
  4137. + tp.tx_desc = (RAID_DESCRIPTOR_T*)DMA_MALLOC(TX_DESC_NUM*sizeof(RAID_DESCRIPTOR_T),(dma_addr_t *)&tp.tx_desc_dma);
  4138. + tx_desc_virtual_base = (unsigned int)tp.tx_desc - (unsigned int)tp.tx_desc_dma;
  4139. + memset(tp.tx_desc,0x00,TX_DESC_NUM*sizeof(RAID_DESCRIPTOR_T));
  4140. +
  4141. + tp.rx_desc = (RAID_DESCRIPTOR_T*)DMA_MALLOC(RX_DESC_NUM*sizeof(RAID_DESCRIPTOR_T),(dma_addr_t *)&tp.rx_desc_dma);
  4142. + rx_desc_virtual_base = (unsigned int)tp.rx_desc - (unsigned int)tp.rx_desc_dma;
  4143. + memset(tp.rx_desc,0x00,RX_DESC_NUM*sizeof(RAID_DESCRIPTOR_T));
  4144. + printk("XOR:tx_desc = %08x\n",(unsigned int)tp.tx_desc);
  4145. + printk("XOR:rx_desc = %08x\n",(unsigned int)tp.rx_desc);
  4146. + printk("XOR:tx_desc_dma = %08x\n",(unsigned int)tp.tx_desc_dma);
  4147. + printk("XOR:rx_desc_dma = %08x\n",(unsigned int)tp.rx_desc_dma);
  4148. +
  4149. + if ((tp.tx_desc == NULL) || (tp.rx_desc == NULL)) {
  4150. + if (tp.tx_desc)
  4151. + DMA_MFREE(tp.tx_desc, TX_DESC_NUM*sizeof(RAID_DESCRIPTOR_T),(dma_addr_t)tp.tx_desc_dma);
  4152. + if (tp.rx_desc)
  4153. + DMA_MFREE(tp.rx_desc, RX_DESC_NUM*sizeof(RAID_DESCRIPTOR_T),(dma_addr_t)tp.rx_desc_dma);
  4154. + return -ENOMEM;
  4155. + }
  4156. +
  4157. + tp.tx_cur_desc = tp.tx_desc; /* virtual address */
  4158. + tp.tx_finished_desc = tp.tx_desc; /* virtual address */
  4159. + tx_first_desc_dma = (dma_addr_t)tp.tx_desc_dma; /* physical address */
  4160. + for (i = 1; i < TX_DESC_NUM; i++) {
  4161. + tp.tx_desc->func_ctrl.bits.own = CPU;
  4162. + tp.tx_desc->func_ctrl.bits.buffer_size = 0;
  4163. + tp.tx_desc_dma = tp.tx_desc_dma + sizeof(RAID_DESCRIPTOR_T);
  4164. +// tp.tx_desc->next_desc_addr.bits32 = (unsigned int)tp.tx_desc_dma | 0x0B;
  4165. + tp.tx_desc->next_desc_addr.bits32 = ((unsigned int)tx_first_desc_dma | 0x0B) + i*0x10;
  4166. + tp.tx_desc = &tp.tx_desc[1];
  4167. + }
  4168. + tp.tx_desc->func_ctrl.bits.own = DMA;
  4169. + tp.tx_desc->next_desc_addr.bits32 = (unsigned int)tx_first_desc_dma|0x0b;
  4170. + tp.tx_desc = tp.tx_cur_desc;
  4171. + tp.tx_desc_dma = (unsigned int*)tx_first_desc_dma;
  4172. + tp.tx_first_desc = tp.tx_desc ;
  4173. +
  4174. + tp.rx_cur_desc = tp.rx_desc; /* virtual address */
  4175. + tp.rx_finished_desc = tp.rx_desc; /* virtual address */
  4176. + rx_first_desc_dma = (dma_addr_t)tp.rx_desc_dma; /* physical address */
  4177. + for (i = 1; i < RX_DESC_NUM; i++) {
  4178. + tp.rx_desc->func_ctrl.bits.own = DMA;
  4179. + tp.rx_desc->func_ctrl.bits.buffer_size = 0;
  4180. + tp.rx_desc_dma = tp.rx_desc_dma + sizeof(RAID_DESCRIPTOR_T);
  4181. +// tp.rx_desc->next_desc_addr.bits32 = (unsigned int)tp.rx_desc_dma | 0x0B;
  4182. + tp.rx_desc->next_desc_addr.bits32 = ((unsigned int)rx_first_desc_dma | 0x0B) + i*0x10;
  4183. + tp.rx_desc = &tp.rx_desc[1];
  4184. + }
  4185. + tp.rx_desc->func_ctrl.bits.own = DMA;
  4186. + tp.rx_desc->next_desc_addr.bits32 = rx_first_desc_dma|0x0b;
  4187. + tp.rx_desc = tp.rx_cur_desc;
  4188. + tp.rx_desc_dma = (unsigned int*)rx_first_desc_dma;
  4189. + tp.rx_first_desc = tp.rx_desc ;
  4190. + tp.busy = 0;
  4191. + tp.status = COMPLETE;
  4192. +
  4193. + // Partition SRAM size
  4194. + raid_write_reg(RAID_PCR, SRAM_PAR_SIZE,0x00000003);
  4195. +
  4196. + // config tx DMA controler
  4197. + txdma_ctrl.bits32 = 0;
  4198. + txdma_ctrl.bits.td_start = 0;
  4199. + txdma_ctrl.bits.td_continue = 1;
  4200. + txdma_ctrl.bits.td_chain_mode = 1;
  4201. + txdma_ctrl.bits.td_prot = 0;
  4202. + txdma_ctrl.bits.td_burst_size = 1;
  4203. + txdma_ctrl.bits.td_bus = 3;
  4204. + txdma_ctrl.bits.td_endian = 0;
  4205. + txdma_ctrl.bits.td_finish_en = 1;
  4206. + txdma_ctrl.bits.td_fail_en = 1;
  4207. + txdma_ctrl.bits.td_perr_en = 1;
  4208. + txdma_ctrl.bits.td_eod_en = 0; // enable tx descript
  4209. + txdma_ctrl.bits.td_eof_en = 0;
  4210. + raid_write_reg(RAID_FCHDMA_CTRL, txdma_ctrl.bits32,0xFFFFFFFF);
  4211. +
  4212. + // config rx DMA controler
  4213. + rxdma_ctrl.bits32 = 0;
  4214. + rxdma_ctrl.bits.rd_start = 0;
  4215. + rxdma_ctrl.bits.rd_continue = 1;
  4216. + rxdma_ctrl.bits.rd_chain_mode = 1;
  4217. + rxdma_ctrl.bits.rd_prot = 0;
  4218. + rxdma_ctrl.bits.rd_burst_size = 1;
  4219. + rxdma_ctrl.bits.rd_bus = 3;
  4220. + rxdma_ctrl.bits.rd_endian = 0;
  4221. + rxdma_ctrl.bits.rd_finish_en = 0;
  4222. + rxdma_ctrl.bits.rd_fail_en = 1;
  4223. + rxdma_ctrl.bits.rd_perr_en = 1;
  4224. + rxdma_ctrl.bits.rd_eod_en = 0;
  4225. + rxdma_ctrl.bits.rd_eof_en = 0;
  4226. + raid_write_reg(RAID_STRDMA_CTRL, rxdma_ctrl.bits32,0xFFFFFFFF);
  4227. +
  4228. + // enable interrupt
  4229. + dma_status.bits32 = 3; // enable RpInt
  4230. + raid_write_reg(RAID_DMA_STATUS, dma_status.bits32,0xFFFFFFFF);
  4231. +
  4232. + return 0;
  4233. +}
  4234. +
  4235. +module_init(gemini_xor_init);
  4236. +module_exit(gemini_xor_exit);
  4237. +
  4238. --- a/arch/arm/mm/Kconfig
  4239. +++ b/arch/arm/mm/Kconfig
  4240. @@ -187,6 +187,26 @@ config CPU_ARM926T
  4241. Say Y if you want support for the ARM926T processor.
  4242. Otherwise, say N.
  4243. +###### for Storlink SoC ######
  4244. +config CPU_FA526
  4245. + bool "FA526 processor"
  4246. + depends on ARCH_SL2312
  4247. + default y
  4248. + select CPU_32v4
  4249. + select CPU_ABRT_EV4
  4250. + select CPU_CACHE_FA
  4251. + select CPU_CACHE_VIVT
  4252. + select CPU_CP15_MMU
  4253. + select CPU_COPY_FA
  4254. + select CPU_TLB_FA
  4255. + select CPU_FA_BTB
  4256. + help
  4257. + The FA526 is a version of the ARM9 compatible processor, but with smaller
  4258. + instruction and data caches. It is used in Storlink Sword device family.
  4259. +
  4260. + Say Y if you want support for the FA526 processor.
  4261. + Otherwise, say N.
  4262. +
  4263. # ARM940T
  4264. config CPU_ARM940T
  4265. bool "Support ARM940T processor" if ARCH_INTEGRATOR
  4266. @@ -461,6 +481,9 @@ config CPU_CACHE_VIVT
  4267. config CPU_CACHE_VIPT
  4268. bool
  4269. +config CPU_CACHE_FA
  4270. + bool
  4271. +
  4272. if MMU
  4273. # The copy-page model
  4274. config CPU_COPY_V3
  4275. @@ -475,6 +498,12 @@ config CPU_COPY_V4WB
  4276. config CPU_COPY_V6
  4277. bool
  4278. +config CPU_COPY_FA
  4279. + bool
  4280. +
  4281. +config CPU_FA_BTB
  4282. + bool
  4283. +
  4284. # This selects the TLB model
  4285. config CPU_TLB_V3
  4286. bool
  4287. @@ -534,6 +563,14 @@ config CPU_CP15_MPU
  4288. config IO_36
  4289. bool
  4290. +config CPU_TLB_FA
  4291. + bool
  4292. + help
  4293. + //TODO
  4294. + Faraday ARM FA526 architecture, unified TLB with writeback cache
  4295. + and invalidate instruction cache entry. Branch target buffer is also
  4296. + supported.
  4297. +
  4298. comment "Processor Features"
  4299. config ARM_THUMB
  4300. @@ -600,7 +637,7 @@ config CPU_DCACHE_SIZE
  4301. config CPU_DCACHE_WRITETHROUGH
  4302. bool "Force write through D-cache"
  4303. - depends on (CPU_ARM740T || CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM940T || CPU_ARM946E || CPU_ARM1020) && !CPU_DCACHE_DISABLE
  4304. + depends on (CPU_ARM740T || CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM940T || CPU_ARM946E || CPU_ARM1020 || CPU_FA526) && !CPU_DCACHE_DISABLE
  4305. default y if CPU_ARM925T
  4306. help
  4307. Say Y here to use the data cache in writethrough mode. Unless you
  4308. --- a/arch/arm/mm/Makefile
  4309. +++ b/arch/arm/mm/Makefile
  4310. @@ -32,6 +32,7 @@ obj-$(CONFIG_CPU_CACHE_V4WT) += cache-v4
  4311. obj-$(CONFIG_CPU_CACHE_V4WB) += cache-v4wb.o
  4312. obj-$(CONFIG_CPU_CACHE_V6) += cache-v6.o
  4313. obj-$(CONFIG_CPU_CACHE_V7) += cache-v7.o
  4314. +obj-$(CONFIG_CPU_CACHE_FA) += cache-fa.o
  4315. obj-$(CONFIG_CPU_COPY_V3) += copypage-v3.o
  4316. obj-$(CONFIG_CPU_COPY_V4WT) += copypage-v4wt.o
  4317. @@ -40,6 +41,7 @@ obj-$(CONFIG_CPU_COPY_V6) += copypage-v6
  4318. obj-$(CONFIG_CPU_SA1100) += copypage-v4mc.o
  4319. obj-$(CONFIG_CPU_XSCALE) += copypage-xscale.o
  4320. obj-$(CONFIG_CPU_XSC3) += copypage-xsc3.o
  4321. +obj-$(CONFIG_CPU_COPY_FA) += copypage-fa.o
  4322. obj-$(CONFIG_CPU_TLB_V3) += tlb-v3.o
  4323. obj-$(CONFIG_CPU_TLB_V4WT) += tlb-v4.o
  4324. @@ -47,6 +49,7 @@ obj-$(CONFIG_CPU_TLB_V4WB) += tlb-v4wb.o
  4325. obj-$(CONFIG_CPU_TLB_V4WBI) += tlb-v4wbi.o
  4326. obj-$(CONFIG_CPU_TLB_V6) += tlb-v6.o
  4327. obj-$(CONFIG_CPU_TLB_V7) += tlb-v7.o
  4328. +obj-$(CONFIG_CPU_TLB_FA) += tlb-fa.o
  4329. obj-$(CONFIG_CPU_ARM610) += proc-arm6_7.o
  4330. obj-$(CONFIG_CPU_ARM710) += proc-arm6_7.o
  4331. @@ -60,6 +63,7 @@ obj-$(CONFIG_CPU_ARM925T) += proc-arm925
  4332. obj-$(CONFIG_CPU_ARM926T) += proc-arm926.o
  4333. obj-$(CONFIG_CPU_ARM940T) += proc-arm940.o
  4334. obj-$(CONFIG_CPU_ARM946E) += proc-arm946.o
  4335. +obj-$(CONFIG_CPU_FA526) += proc-fa526.o
  4336. obj-$(CONFIG_CPU_ARM1020) += proc-arm1020.o
  4337. obj-$(CONFIG_CPU_ARM1020E) += proc-arm1020e.o
  4338. obj-$(CONFIG_CPU_ARM1022) += proc-arm1022.o
  4339. --- /dev/null
  4340. +++ b/arch/arm/mm/cache-fa.S
  4341. @@ -0,0 +1,400 @@
  4342. +/*
  4343. + * linux/arch/arm/mm/cache-fa.S
  4344. + *
  4345. + * Copyright (C) 2005 Faraday Corp.
  4346. + *
  4347. + * This program is free software; you can redistribute it and/or modify
  4348. + * it under the terms of the GNU General Public License version 2 as
  4349. + * published by the Free Software Foundation.
  4350. + *
  4351. + * Processors: FA520 FA526 FA626
  4352. + * 03/31/2005 : Luke Lee created, modified from cache-v4wb.S
  4353. + * 04/06/2005 : 1. Read CR0-1 and determine the cache size dynamically,
  4354. + * to suit all Faraday CPU series
  4355. + * 2. Fixed all functions
  4356. + * 04/08/2005 : insert CONFIG_CPU_ICACHE_DISABLE and CONFIG_CPU_DCACHE_DISABLE
  4357. + * 04/12/2005 : TODO: make this processor dependent or a self-modifying code to
  4358. + * inline cache len/size info into the instructions, as reading cache
  4359. + * size and len info in memory could cause another cache miss.
  4360. + * 05/05/2005 : Modify fa_flush_user_cache_range to comply APCS.
  4361. + * 05/19/2005 : Adjust for boundary conditions.
  4362. + */
  4363. +#include <linux/linkage.h>
  4364. +#include <linux/init.h>
  4365. +#include <asm/hardware.h>
  4366. +#include <asm/page.h>
  4367. +#include "proc-macros.S"
  4368. +
  4369. +#define CACHE_DLINESIZE 16
  4370. +#ifdef CONFIG_SL3516_ASIC
  4371. +#define CACHE_DSIZE 8192
  4372. +#else
  4373. +#define CACHE_DSIZE 16384
  4374. +#endif
  4375. +#define CACHE_ILINESIZE 16
  4376. +#define CACHE_ISIZE 16384
  4377. +
  4378. +/* Luke Lee 04/06/2005 ins begin */
  4379. +/*
  4380. + * initialize_cache_info()
  4381. + *
  4382. + * Automatic detection of DSIZE, DLEN, ISIZE, ILEN variables according to
  4383. + * system register CR0-1
  4384. + * Destroyed register: r0, r1, r2, r3, ip
  4385. + */
  4386. + .align
  4387. +ENTRY(fa_initialize_cache_info)
  4388. + mov r3, #1 @ r3 always = 1
  4389. + adr ip, __fa_cache_ilen
  4390. +
  4391. + mrc p15, 0, r0, c0, c0, 1
  4392. + /* ILEN */
  4393. + and r1, r0, #3 @ bits [1:0]
  4394. + add r1, r1, #3 @ cache line size is at least 8 bytes (2^3)
  4395. + mov r2, r3, lsl r1 @ r2 = 1<<r1
  4396. + str r2, [ip], #4
  4397. + /* ISIZE */
  4398. + mov r1, r0, lsr #6 @ bits [8:6]
  4399. + and r1, r1, #7
  4400. + add r1, r1, #9 @ cache size is at least 512 bytes (2^9)
  4401. + mov r2, r3, lsl r1
  4402. + str r2, [ip], #4
  4403. + /* DLEN */
  4404. + mov r1, r0, lsr #12
  4405. + and r1, r1, #3 @ bits [13:12]
  4406. + add r1, r1, #3 @ cache line size is at least 8 bytes (2^3)
  4407. + mov r2, r3, lsl r1 @ r2 = 1<<r1
  4408. + str r2, [ip], #4
  4409. + /* DSIZE */
  4410. + mov r1, r0, lsr #18 @ bits [20:18]
  4411. + and r1, r1, #7
  4412. + add r1, r1, #9 @ cache size is at least 512 bytes (2^9)
  4413. + mov r2, r3, lsl r1
  4414. + str r2, [ip]
  4415. + mov pc, lr
  4416. +
  4417. + /* Warning : Do not change the order ! Successive codes depends on this */
  4418. + .align
  4419. + .globl __fa_cache_ilen, __fa_cache_isize, __fa_cache_dlen, __fa_cache_dsize
  4420. +__fa_cache_ilen:
  4421. + .word 0 @ instruction cache line length
  4422. +__fa_cache_isize:
  4423. + .word 0 @ instruction cache size
  4424. +__fa_cache_dlen:
  4425. + .word 0 @ data cahce line length
  4426. +__fa_cache_dsize:
  4427. + .word 0 @ data cache size
  4428. +
  4429. +/* Luke Lee 04/06/2005 ins end */
  4430. +
  4431. +/*
  4432. + * flush_user_cache_all()
  4433. + *
  4434. + * Clean and invalidate all cache entries in a particular address
  4435. + * space.
  4436. + */
  4437. +ENTRY(fa_flush_user_cache_all)
  4438. + /* FALLTHROUGH */
  4439. +/*
  4440. + * flush_kern_cache_all()
  4441. + *
  4442. + * Clean and invalidate the entire cache.
  4443. + */
  4444. +ENTRY(fa_flush_kern_cache_all)
  4445. +/* Luke Lee 04/06/2005 mod ok */
  4446. + mov ip, #0
  4447. +
  4448. +#ifndef CONFIG_CPU_ICACHE_DISABLE
  4449. + mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  4450. +#endif
  4451. +
  4452. +__flush_whole_cache:
  4453. +
  4454. +#ifndef CONFIG_CPU_DCACHE_DISABLE
  4455. + mov ip, #0
  4456. +# ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  4457. + mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  4458. +# else
  4459. + mcr p15, 0, ip, c7,c14, 0 @ clean/invalidate D cache
  4460. +# endif
  4461. +#endif /*CONFIG_CPU_DCACHE_DISABLE*/
  4462. +
  4463. +#ifndef CONFIG_CPU_FA_WB_DISABLE
  4464. + mcr p15, 0, ip, c7, c10, 4 @ drain write buffer
  4465. +#endif
  4466. +
  4467. +#ifdef CONFIG_CPU_FA_BTB
  4468. + mcr p15, 0, ip, c7, c5, 6 @ invalidate BTB
  4469. + nop
  4470. + nop
  4471. +#endif
  4472. +
  4473. +/* Luke Lee 04/06/2005 que todo tofix : should iscratchpad and dscratchpad be invalidated ? */
  4474. + mov pc, lr
  4475. +
  4476. +/*
  4477. + * flush_user_cache_range(start, end, flags)
  4478. + *
  4479. + * Invalidate a range of cache entries in the specified
  4480. + * address space.
  4481. + *
  4482. + * - start - start address (inclusive, page aligned)
  4483. + * - end - end address (exclusive, page aligned)
  4484. + * - flags - vma_area_struct flags describing address space
  4485. + */
  4486. +ENTRY(fa_flush_user_cache_range)
  4487. +
  4488. +/* Luke Lee 04/06/2005 mod ok */
  4489. + /* Luke Lee 04/07/2005 ins 1 */
  4490. + mov ip, #0
  4491. + sub r3, r1, r0 @ calculate total size
  4492. +#ifndef CONFIG_CPU_ICACHE_DISABLE
  4493. + tst r2, #VM_EXEC @ executable region?
  4494. + mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  4495. +#endif
  4496. +
  4497. +#ifndef CONFIG_CPU_DCACHE_DISABLE
  4498. + /* Luke Lee 04/06/2005 ins 2 mod 1 */
  4499. + cmp r3, #CACHE_DSIZE @ total size >= limit?
  4500. + bhs __flush_whole_cache @ flush whole D cache
  4501. +
  4502. + //debug_Aaron
  4503. + bic r0, r0, #CACHE_DLINESIZE-1
  4504. + mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate boundary D entry
  4505. + bic r1, r1, #CACHE_DLINESIZE-1
  4506. + mcr p15, 0, r1, c7, c14, 1 @ clean and invalidate boundary D entry
  4507. +
  4508. +
  4509. +1: /* Luke Lee 04/06/2005 del 2 ins 5 */
  4510. +
  4511. +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  4512. + mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  4513. +#else
  4514. + mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
  4515. +#endif
  4516. + /* Luke Lee 04/06/2005 mod 1 */
  4517. + add r0, r0, #CACHE_DLINESIZE
  4518. + cmp r0, r1
  4519. + bls 1b @ Luke Lee 05/19/2005
  4520. +#endif /* CONFIG_CPU_DCACHE_DISABLE */
  4521. +
  4522. +#ifndef CONFIG_CPU_FA_WB_DISABLE
  4523. + tst r2, #VM_EXEC
  4524. + /* Luke Lee 04/06/2005 mod 1 tofix todo : ne->eq */
  4525. + mcreq p15, 0, r4, c7, c10, 4 @ drain write buffer
  4526. +#endif
  4527. +
  4528. + /* Luke Lee 04/06/2005 ins block */
  4529. +#ifdef CONFIG_CPU_FA_BTB
  4530. + tst r2, #VM_EXEC
  4531. + mov ip, #0
  4532. + mcrne p15, 0, ip, c7, c5, 6 @ invalidate BTB
  4533. + nop
  4534. + nop
  4535. +#endif
  4536. + mov pc, lr
  4537. +
  4538. +/*
  4539. + * flush_kern_dcache_page(void *page)
  4540. + *
  4541. + * Ensure no D cache aliasing occurs, either with itself or
  4542. + * the I cache
  4543. + *
  4544. + * - addr - page aligned address
  4545. + */
  4546. +ENTRY(fa_flush_kern_dcache_page)
  4547. + add r1, r0, #PAGE_SZ
  4548. + /* fall through */
  4549. +
  4550. +/*
  4551. + * coherent_kern_range(start, end)
  4552. + *
  4553. + * Ensure coherency between the Icache and the Dcache in the
  4554. + * region described by start. If you have non-snooping
  4555. + * Harvard caches, you need to implement this function.
  4556. + *
  4557. + * - start - virtual start address
  4558. + * - end - virtual end address
  4559. + */
  4560. +ENTRY(fa_coherent_kern_range)
  4561. + /* fall through */
  4562. +
  4563. +/*
  4564. + * coherent_user_range(start, end)
  4565. + *
  4566. + * Ensure coherency between the Icache and the Dcache in the
  4567. + * region described by start. If you have non-snooping
  4568. + * Harvard caches, you need to implement this function.
  4569. + *
  4570. + * - start - virtual start address
  4571. + * - end - virtual end address
  4572. + */
  4573. +ENTRY(fa_coherent_user_range)
  4574. +
  4575. +/* Luke Lee 04/06/2005 mod ok */
  4576. + /* Luke Lee 04/06/2005 ins 3 mod 1 */
  4577. + bic r0, r0, #CACHE_DLINESIZE-1
  4578. +
  4579. + //debug_Aaron
  4580. + bic r0, r0, #CACHE_DLINESIZE-1
  4581. + mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate boundary D entry
  4582. + bic r1, r1, #CACHE_DLINESIZE-1
  4583. + mcr p15, 0, r1, c7, c14, 1 @ clean and invalidate boundary D entry
  4584. +
  4585. +#if !(defined(CONFIG_CPU_DCACHE_DISABLE) && defined(CONFIG_CPU_ICACHE_DISABLE))
  4586. +1: /* Luke Lee 04/06/2005 del 2 ins 5 mod 1 */
  4587. +#ifndef CONFIG_CPU_DCACHE_DISABLE
  4588. +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  4589. + mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  4590. +#else
  4591. + mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
  4592. +#endif
  4593. +#endif /* CONFIG_CPU_DCACHE_DISABLE */
  4594. +
  4595. +#ifndef CONFIG_CPU_ICACHE_DISABLE
  4596. + mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  4597. +#endif
  4598. + add r0, r0, #CACHE_DLINESIZE
  4599. + cmp r0, r1
  4600. + bls 1b @ Luke Lee 05/19/2005 blo->bls
  4601. +#endif /* !(defined(CONFIG_CPU_DCACHE_DISABLE) && defined(CONFIG_CPU_ICACHE_DISABLE)) */
  4602. +
  4603. + mov ip, #0
  4604. +#ifdef CONFIG_CPU_FA_BTB
  4605. + mcr p15, 0, ip, c7, c5, 6 @ invalidate BTB
  4606. + nop
  4607. + nop
  4608. +#endif
  4609. +
  4610. +/* Luke Lee 04/08/2005 ins 1 skp 1 ins 1 */
  4611. +#ifndef CONFIG_CPU_FA_WB_DISABLE
  4612. + mcr p15, 0, ip, c7, c10, 4 @ drain WB
  4613. +#endif
  4614. +
  4615. + mov pc, lr
  4616. +
  4617. +/*
  4618. + * dma_inv_range(start, end)
  4619. + *
  4620. + * Invalidate (discard) the specified virtual address range.
  4621. + * May not write back any entries. If 'start' or 'end'
  4622. + * are not cache line aligned, those lines must be written
  4623. + * back.
  4624. + *
  4625. + * - start - virtual start address
  4626. + * - end - virtual end address
  4627. + */
  4628. +ENTRY(fa_dma_inv_range)
  4629. +
  4630. +/* Luke Lee 04/06/2005 mod ok */
  4631. +
  4632. +#ifndef CONFIG_CPU_DCACHE_DISABLE
  4633. +
  4634. + //debug_Aaron
  4635. + bic r0, r0, #CACHE_DLINESIZE-1
  4636. + mcr p15, 0, r0, c7, c6, 1 @ invalidate boundary D entry
  4637. + bic r1, r1, #CACHE_DLINESIZE-1
  4638. + mcr p15, 0, r1, c7, c6, 1 @ invalidate boundary D entry
  4639. +
  4640. + /* Luke Lee 04/06/2005 ins 4 mod 2 */
  4641. +#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  4642. + tst r0, #CACHE_DLINESIZE -1
  4643. + bic r0, r0, #CACHE_DLINESIZE -1
  4644. +
  4645. +//debug_Aaron
  4646. + //mcrne p15, 0, r0, c7, c10, 1 @ clean boundary D entry
  4647. +
  4648. + /* Luke Lee 04/06/2005 mod 1 */
  4649. + /* Luke Lee 05/19/2005 always clean the end-point boundary mcrne->mcr */
  4650. + ////tst r1, #CACHE_DLINESIZE -1
  4651. + //mcr p15, 0, r1, c7, c10, 1 @ clean boundary D entry
  4652. + /* Luke Lee 04/06/2005 ins 1 */
  4653. +#else
  4654. + bic r0, r0, #CACHE_DLINESIZE -1
  4655. +#endif
  4656. +
  4657. +//debug_Aaron
  4658. +1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  4659. +//1: mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
  4660. +
  4661. + /* Luke Lee 04/06/2005 mod 1 */
  4662. + add r0, r0, #CACHE_DLINESIZE
  4663. + cmp r0, r1
  4664. + bls 1b @ Luke Lee 05/19/2005 blo->bls
  4665. +#endif /* CONFIG_CPU_DCACHE_DISABLE */
  4666. +
  4667. + /* Luke Lee 04/06/2005 ins 1 */
  4668. +#ifndef CONFIG_CPU_FA_WB_DISABLE
  4669. + mov r0, #0
  4670. + mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  4671. +#endif
  4672. +
  4673. + mov pc, lr
  4674. +
  4675. +/*
  4676. + * dma_clean_range(start, end)
  4677. + *
  4678. + * Clean (write back) the specified virtual address range.
  4679. + *
  4680. + * - start - virtual start address
  4681. + * - end - virtual end address
  4682. + */
  4683. +ENTRY(fa_dma_clean_range)
  4684. +
  4685. +/* Luke Lee 04/06/2005 mod ok */
  4686. +#ifndef CONFIG_CPU_DCACHE_DISABLE
  4687. +
  4688. + //debug_Aaron
  4689. + bic r0, r0, #CACHE_DLINESIZE-1
  4690. + mcr p15, 0, r0, c7, c10, 1 @ clean boundary D entry
  4691. + bic r1, r1, #CACHE_DLINESIZE-1
  4692. + mcr p15, 0, r1, c7, c10, 1 @ clean boundary D entry
  4693. +
  4694. + /* Luke Lee 04/06/2005 ins 4 mod 2 */
  4695. +#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  4696. + bic r0, r0, #CACHE_DLINESIZE - 1
  4697. +
  4698. +//debug_Aaron
  4699. +1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  4700. +//1: mcr p15, 0, r0, c7, c14, 1 @ clean D entry
  4701. + add r0, r0, #CACHE_DLINESIZE
  4702. + cmp r0, r1
  4703. + bls 1b @ Luke Lee 05/19/2005 blo->bls
  4704. + /* Luke Lee 04/06/2005 ins 2 */
  4705. +#endif
  4706. +#endif /* CONFIG_CPU_DCACHE_DISABLE */
  4707. +
  4708. +#ifndef CONFIG_CPU_FA_WB_DISABLE
  4709. + mov r0, #0
  4710. + mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  4711. +#endif
  4712. +
  4713. + mov pc, lr
  4714. +
  4715. +/*
  4716. + * dma_flush_range(start, end)
  4717. + *
  4718. + * Clean and invalidate the specified virtual address range.
  4719. + *
  4720. + * - start - virtual start address
  4721. + * - end - virtual end address
  4722. + *
  4723. + * This is actually the same as fa_coherent_kern_range()
  4724. + */
  4725. + .globl fa_dma_flush_range
  4726. + .set fa_dma_flush_range, fa_coherent_kern_range
  4727. +
  4728. + __INITDATA
  4729. +
  4730. + .type fa_cache_fns, #object
  4731. +ENTRY(fa_cache_fns)
  4732. + .long fa_flush_kern_cache_all
  4733. + .long fa_flush_user_cache_all
  4734. + .long fa_flush_user_cache_range
  4735. + .long fa_coherent_kern_range
  4736. + .long fa_coherent_user_range
  4737. + .long fa_flush_kern_dcache_page
  4738. + .long fa_dma_inv_range
  4739. + .long fa_dma_clean_range
  4740. + .long fa_dma_flush_range
  4741. + .size fa_cache_fns, . - fa_cache_fns
  4742. --- /dev/null
  4743. +++ b/arch/arm/mm/copypage-fa.S
  4744. @@ -0,0 +1,106 @@
  4745. +/*
  4746. + * linux/arch/arm/lib/copypage-fa.S
  4747. + *
  4748. + * Copyright (C) 2005 Faraday Corp.
  4749. + *
  4750. + * This program is free software; you can redistribute it and/or modify
  4751. + * it under the terms of the GNU General Public License version 2 as
  4752. + * published by the Free Software Foundation.
  4753. + *
  4754. + * ASM optimised string functions
  4755. + * 05/18/2005 : Luke Lee created, modified from copypage-v4wb.S
  4756. + */
  4757. +#include <linux/linkage.h>
  4758. +#include <linux/init.h>
  4759. +#include <asm/asm-offsets.h>
  4760. +
  4761. + .text
  4762. +/*
  4763. + * ARMv4 optimised copy_user_page for Faraday processors
  4764. + *
  4765. + * We flush the destination cache lines just before we write the data into the
  4766. + * corresponding address. Since the Dcache is read-allocate, this removes the
  4767. + * Dcache aliasing issue. The writes will be forwarded to the write buffer,
  4768. + * and merged as appropriate.
  4769. + *
  4770. + * Note: We rely on all ARMv4 processors implementing the "invalidate D line"
  4771. + * instruction. If your processor does not supply this, you have to write your
  4772. + * own copy_user_page that does the right thing.
  4773. + *
  4774. + * copy_user_page(to,from,vaddr)
  4775. + */
  4776. + .align 4
  4777. +ENTRY(fa_copy_user_page)
  4778. +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  4779. + /* Write through */
  4780. + stmfd sp!, {r4, lr} @ 2
  4781. + mov r2, #PAGE_SZ/32 @ 1
  4782. +
  4783. + ldmia r1!, {r3, r4, ip, lr} @ 4
  4784. +1: stmia r0!, {r3, r4, ip, lr} @ 4
  4785. + ldmia r1!, {r3, r4, ip, lr} @ 4+1
  4786. + subs r2, r2, #1 @ 1
  4787. + stmia r0!, {r3, r4, ip, lr} @ 4
  4788. + ldmneia r1!, {r3, r4, ip, lr} @ 4
  4789. + bne 1b @ 1
  4790. +
  4791. + mcr p15, 0, r2, c7, c7, 0 @ flush ID cache
  4792. + ldmfd sp!, {r4, pc} @ 3
  4793. +#else
  4794. + /* Write back */
  4795. + stmfd sp!, {r4, lr} @ 2
  4796. + mov r2, #PAGE_SZ/32 @ 1
  4797. +
  4798. +1: ldmia r1!, {r3, r4, ip, lr} @ 4
  4799. + mcr p15, 0, r0, c7, c6, 1 @ 1 invalidate D line
  4800. + stmia r0!, {r3, r4, ip, lr} @ 4
  4801. + ldmia r1!, {r3, r4, ip, lr} @ 4
  4802. + mcr p15, 0, r0, c7, c6, 1 @ 1 invalidate D line
  4803. + stmia r0!, {r3, r4, ip, lr} @ 4
  4804. + subs r2, r2, #1 @ 1
  4805. + bne 1b
  4806. + mcr p15, 0, r2, c7, c10, 4 @ 1 drain WB
  4807. + ldmfd sp!, {r4, pc} @ 3
  4808. +#endif
  4809. +
  4810. +/*
  4811. + * ARMv4 optimised clear_user_page
  4812. + *
  4813. + * Same story as above.
  4814. + */
  4815. + .align 4
  4816. +ENTRY(fa_clear_user_page)
  4817. + str lr, [sp, #-4]!
  4818. + mov r1, #PAGE_SZ/32 @ 1
  4819. + mov r2, #0 @ 1
  4820. + mov r3, #0 @ 1
  4821. + mov ip, #0 @ 1
  4822. + mov lr, #0 @ 1
  4823. +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  4824. + /* Write through */
  4825. +1: stmia r0!, {r2, r3, ip, lr} @ 4
  4826. + stmia r0!, {r2, r3, ip, lr} @ 4
  4827. + subs r1, r1, #1 @ 1
  4828. + bne 1b @ 1
  4829. +
  4830. + mcr p15, 0, r1, c7, c7, 0 @ flush ID cache
  4831. + ldr pc, [sp], #4
  4832. +#else
  4833. + /* Write back */
  4834. +1: mcr p15, 0, r0, c7, c6, 1 @ 1 invalidate D line
  4835. + stmia r0!, {r2, r3, ip, lr} @ 4
  4836. + mcr p15, 0, r0, c7, c6, 1 @ 1 invalidate D line
  4837. + stmia r0!, {r2, r3, ip, lr} @ 4
  4838. + subs r1, r1, #1 @ 1
  4839. + bne 1b @ 1
  4840. + mcr p15, 0, r1, c7, c10, 4 @ 1 drain WB
  4841. + ldr pc, [sp], #4
  4842. +#endif
  4843. +
  4844. + __INITDATA
  4845. +
  4846. + .type fa_user_fns, #object
  4847. +ENTRY(fa_user_fns)
  4848. + .long fa_clear_user_page
  4849. + .long fa_copy_user_page
  4850. + .size fa_user_fns, . - fa_user_fns
  4851. --- a/arch/arm/mm/init.c
  4852. +++ b/arch/arm/mm/init.c
  4853. @@ -23,6 +23,7 @@
  4854. #include <asm/mach/arch.h>
  4855. #include <asm/mach/map.h>
  4856. +#include <asm/arch/ipi.h>
  4857. #include "mm.h"
  4858. @@ -252,6 +253,11 @@ bootmem_init_node(int node, int initrd_n
  4859. initrd_end = initrd_start + phys_initrd_size;
  4860. }
  4861. #endif
  4862. +#ifdef CONFIG_GEMINI_IPI
  4863. + printk("CPU ID:%d\n",getcpuid());
  4864. +// reserve_bootmem_node(NODE_DATA(0), 0x400000, 0x400000); //CPU0 space
  4865. +// reserve_bootmem_node(NODE_DATA(0), SHAREADDR, SHARE_MEM_SIZE); //share memory
  4866. +#endif
  4867. /*
  4868. * Finally, reserve any node zero regions.
  4869. --- /dev/null
  4870. +++ b/arch/arm/mm/proc-fa526.S
  4871. @@ -0,0 +1,407 @@
  4872. +/*
  4873. + * linux/arch/arm/mm/proc-fa526.S: MMU functions for FA526
  4874. + *
  4875. + * Copyright (C) 2005 Faraday Corp.
  4876. + *
  4877. + * This program is free software; you can redistribute it and/or modify
  4878. + * it under the terms of the GNU General Public License as published by
  4879. + * the Free Software Foundation; either version 2 of the License, or
  4880. + * (at your option) any later version.
  4881. + *
  4882. + * This program is distributed in the hope that it will be useful,
  4883. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4884. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4885. + * GNU General Public License for more details.
  4886. + *
  4887. + * You should have received a copy of the GNU General Public License
  4888. + * along with this program; if not, write to the Free Software
  4889. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  4890. + *
  4891. + *
  4892. + * These are the low level assembler for performing cache and TLB
  4893. + * functions on the fa526.
  4894. + *
  4895. + * Written by : Luke Lee
  4896. + */
  4897. +#include <linux/linkage.h>
  4898. +#include <linux/init.h>
  4899. +#include <asm/assembler.h>
  4900. +#include <asm/pgtable.h>
  4901. +#include <asm/pgtable-hwdef.h>
  4902. +#include <asm/elf.h>
  4903. +#include <asm/hardware.h>
  4904. +#include <asm/page.h>
  4905. +#include <asm/ptrace.h>
  4906. +#include <asm/system.h>
  4907. +#include "proc-macros.S"
  4908. +
  4909. +#define CACHE_DLINESIZE 16
  4910. +
  4911. + .text
  4912. +/*
  4913. + * cpu_fa526_proc_init()
  4914. + */
  4915. +ENTRY(cpu_fa526_proc_init)
  4916. + /* MMU is already ON here, ICACHE, DCACHE conditionally disabled */
  4917. +
  4918. + mov r0, #1
  4919. + nop
  4920. + nop
  4921. + mcr p15, 0, r0, c1, c1, 0 @ turn-on ECR
  4922. + nop
  4923. + nop
  4924. +
  4925. + mrc p15, 0, r0, c1, c0, 0 @ read ctrl register
  4926. +
  4927. +#ifdef CONFIG_CPU_FA_BTB
  4928. + orr r0, r0, #CR_Z
  4929. +#else
  4930. + bic r0, r0, #CR_Z
  4931. +#endif
  4932. +#ifdef CONFIG_CPU_FA_WB_DISABLE
  4933. + mov r1, #0
  4934. + mcr p15, 0, r1, c7, c10, 4 @ drain write buffer
  4935. + nop
  4936. + nop
  4937. + bic r0, r0, #CR_W
  4938. +#else
  4939. + orr r0, r0, #CR_W
  4940. +#endif
  4941. +#ifdef CONFIG_CPU_DCACHE_DISABLE
  4942. + bic r0, r0, #CR_C
  4943. +#else
  4944. + orr r0, r0, #CR_C
  4945. +#endif
  4946. +#ifdef CONFIG_CPU_ICACHE_DISABLE
  4947. + bic r0, r0, #CR_I
  4948. +#else
  4949. + orr r0, r0, #CR_I
  4950. +#endif
  4951. +
  4952. + nop
  4953. + nop
  4954. + mcr p15, 0, r0, c1, c0, 0
  4955. + nop
  4956. + nop
  4957. +
  4958. + mov r5, lr
  4959. + bl fa_initialize_cache_info @ destroy r0~r4
  4960. + mov pc, r5 @ return
  4961. +
  4962. +
  4963. +/*
  4964. + * cpu_fa526_proc_fin()
  4965. + */
  4966. +ENTRY(cpu_fa526_proc_fin)
  4967. + stmfd sp!, {lr}
  4968. + mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
  4969. + msr cpsr_c, ip
  4970. +
  4971. + bl fa_flush_kern_cache_all
  4972. + mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  4973. + bic r0, r0, #0x1000 @ ...i............
  4974. + bic r0, r0, #0x000e @ ............wca.
  4975. + mcr p15, 0, r0, c1, c0, 0 @ disable caches
  4976. +
  4977. + nop
  4978. + nop
  4979. + ldmfd sp!, {pc}
  4980. +
  4981. +/*
  4982. + * cpu_fa526_reset(loc)
  4983. + *
  4984. + * Perform a soft reset of the system. Put the CPU into the
  4985. + * same state as it would be if it had been reset, and branch
  4986. + * to what would be the reset vector.
  4987. + *
  4988. + * loc: location to jump to for soft reset
  4989. + */
  4990. + .align 4
  4991. +ENTRY(cpu_fa526_reset)
  4992. + mov ip, #0
  4993. + mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  4994. +#ifndef CONFIG_CPU_FA_WB_DISABLE
  4995. + mcr p15, 0, ip, c7, c10, 4 @ drain WB
  4996. +#endif
  4997. + mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  4998. + mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  4999. + bic ip, ip, #0x000f @ ............wcam
  5000. + bic ip, ip, #0x1100 @ ...i...s........
  5001. +
  5002. + bic ip, ip, #0x0800 @ BTB off
  5003. + mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  5004. + nop
  5005. + nop
  5006. + mov pc, r0
  5007. +
  5008. +/*
  5009. + * cpu_fa526_do_idle()
  5010. + */
  5011. + .align 4
  5012. +ENTRY(cpu_fa526_do_idle)
  5013. +
  5014. +#ifdef CONFIG_CPU_FA_IDLE
  5015. + nop
  5016. + nop
  5017. + mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt (IDLE mode)
  5018. +#endif
  5019. + mov pc, lr
  5020. +
  5021. +
  5022. +ENTRY(cpu_fa526_dcache_clean_area)
  5023. +
  5024. +#ifndef CONFIG_CPU_DCACHE_DISABLE
  5025. +#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  5026. +1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  5027. + add r0, r0, #CACHE_DLINESIZE
  5028. + subs r1, r1, #CACHE_DLINESIZE
  5029. + bhi 1b
  5030. +#endif
  5031. +#endif
  5032. + mov pc, lr
  5033. +
  5034. +
  5035. +/* =============================== PageTable ============================== */
  5036. +
  5037. +/*
  5038. + * cpu_fa526_switch_mm(pgd)
  5039. + *
  5040. + * Set the translation base pointer to be as described by pgd.
  5041. + *
  5042. + * pgd: new page tables
  5043. + */
  5044. + .align 4
  5045. +
  5046. + .globl fault_address
  5047. +fault_address:
  5048. + .long 0
  5049. +
  5050. +ENTRY(cpu_fa526_switch_mm)
  5051. +
  5052. + mov ip, #0
  5053. +#ifndef CONFIG_CPU_DCACHE_DISABLE
  5054. +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  5055. + mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  5056. +#else
  5057. + mcr p15, 0, ip, c7, c14, 0 @ Clean and invalidate whole DCache
  5058. +#endif
  5059. +#endif /*CONFIG_CPU_DCACHE_DISABLE*/
  5060. +
  5061. +#ifndef CONFIG_CPU_ICACHE_DISABLE
  5062. + mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  5063. +#endif
  5064. +
  5065. +#ifndef CONFIG_CPU_FA_WB_DISABLE
  5066. + mcr p15, 0, ip, c7, c10, 4 @ drain WB
  5067. +#endif
  5068. +
  5069. +#ifdef CONFIG_CPU_FA_BTB
  5070. + mcr p15, 0, ip, c7, c5, 6 @ invalidate BTB since mm changed
  5071. + nop
  5072. + nop
  5073. +#endif
  5074. + bic r0, r0, #0xff @ clear bits [7:0]
  5075. + bic r0, r0, #0x3f00 @ clear bits [13:8]
  5076. + mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  5077. + mcr p15, 0, ip, c8, c7, 0 @ invalidate UTLB
  5078. + nop
  5079. + nop
  5080. + mov pc, lr
  5081. +
  5082. +/*
  5083. + * cpu_fa526_set_pte_ext(ptep, pte, ext)
  5084. + *
  5085. + * Set a PTE and flush it out
  5086. + */
  5087. + .align 4
  5088. +ENTRY(cpu_fa526_set_pte_ext)
  5089. + str r1, [r0], #-2048 @ linux version
  5090. +
  5091. + eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
  5092. +
  5093. + bic r2, r1, #PTE_SMALL_AP_MASK
  5094. + bic r2, r2, #PTE_TYPE_MASK
  5095. + orr r2, r2, #PTE_TYPE_SMALL
  5096. +
  5097. + tst r1, #L_PTE_USER @ User?
  5098. + orrne r2, r2, #PTE_SMALL_AP_URO_SRW
  5099. +
  5100. + tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
  5101. + orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
  5102. +
  5103. + tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
  5104. + movne r2, #0
  5105. +
  5106. +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  5107. + eor r3, r2, #0x0a @ C & small page? 1010
  5108. + tst r3, #0x0b @ 1011
  5109. + biceq r2, r2, #4
  5110. +#endif
  5111. + str r2, [r0] @ hardware version
  5112. +
  5113. + mov r2, #0
  5114. + mcr p15, 0, r2, c7, c10, 0 @ clean D cache all
  5115. +
  5116. +#ifndef CONFIG_CPU_FA_WB_DISABLE
  5117. + mcr p15, 0, r2, c7, c10, 4 @ drain WB
  5118. +#endif
  5119. +#ifdef CONFIG_CPU_FA_BTB
  5120. + mcr p15, 0, r2, c7, c5, 6 @ invalidate BTB
  5121. + nop
  5122. + nop
  5123. +#endif
  5124. + mov pc, lr
  5125. +
  5126. + __INIT
  5127. +
  5128. + .type __fa526_setup, #function
  5129. +__fa526_setup:
  5130. + /* On return of this routine, r0 must carry correct flags for CFG register */
  5131. + mov r0, #0
  5132. + mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  5133. + mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  5134. + mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  5135. +
  5136. + mcr p15, 0, r0, c7, c5, 5 @ invalidate IScratchpad RAM
  5137. +
  5138. + mov r0, #1
  5139. + mcr p15, 0, r0, c1, c1, 0 @ turn-on ECR
  5140. +
  5141. + mrc p15, 0, r0, c9, c1, 0 @ DScratchpad
  5142. + bic r0, r0, #1
  5143. + mcr p15, 0, r0, c9, c1, 0
  5144. + mrc p15, 0, r0, c9, c1, 1 @ IScratchpad
  5145. + bic r0, r0, #1
  5146. + mcr p15, 0, r0, c9, c1, 1
  5147. +
  5148. + mov r0, #0
  5149. + mcr p15, 0, r0, c1, c1, 0 @ turn-off ECR
  5150. +
  5151. +#ifdef CONFIG_CPU_FA_BTB
  5152. + mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB All
  5153. + nop
  5154. + nop
  5155. +#endif
  5156. +
  5157. + mov r0, #0x1f @ Domains 0, 1 = manager, 2 = client
  5158. + mcr p15, 0, r0, c3, c0 @ load domain access register
  5159. +
  5160. + mrc p15, 0, r0, c1, c0 @ get control register v4
  5161. + ldr r5, fa526_cr1_clear
  5162. + bic r0, r0, r5
  5163. + ldr r5, fa526_cr1_set
  5164. + orr r0, r0, r5
  5165. +
  5166. +#ifdef CONFIG_CPU_FA_BTB
  5167. + orr r0, r0, #CR_Z
  5168. +#else
  5169. + bic r0, r0, #CR_Z
  5170. +#endif
  5171. +#ifdef CONFIG_CPU_FA_WB_DISABLE
  5172. + mov r12, #0
  5173. + mcr p15, 0, r12, c7, c10, 4 @ drain write buffer
  5174. + nop
  5175. + nop
  5176. + bic r0, r0, #CR_W @ .... .... .... 1...
  5177. +#else
  5178. + orr r0, r0, #CR_W
  5179. +#endif
  5180. +
  5181. + mov pc, lr
  5182. + .size __fa526_setup, . - __fa526_setup
  5183. +
  5184. + /*
  5185. + * .RVI ZFRS BLDP WCAM
  5186. + * ..11 0001 .111 1101
  5187. + *
  5188. + */
  5189. + .type fa526_cr1_clear, #object
  5190. + .type fa526_cr1_set, #object
  5191. +fa526_cr1_clear:
  5192. + .word 0x3f3f
  5193. +fa526_cr1_set:
  5194. + .word 0x317D
  5195. +
  5196. + __INITDATA
  5197. +
  5198. +/*
  5199. + * Purpose : Function pointers used to access above functions - all calls
  5200. + * come through these
  5201. + */
  5202. + .type fa526_processor_functions, #object
  5203. +fa526_processor_functions:
  5204. + .word v4_early_abort
  5205. + .word cpu_fa526_proc_init
  5206. + .word cpu_fa526_proc_fin
  5207. + .word cpu_fa526_reset
  5208. + .word cpu_fa526_do_idle
  5209. + .word cpu_fa526_dcache_clean_area
  5210. + .word cpu_fa526_switch_mm
  5211. + .word cpu_fa526_set_pte_ext
  5212. + .size fa526_processor_functions, . - fa526_processor_functions
  5213. +
  5214. + .section ".rodata"
  5215. +
  5216. + .type cpu_arch_name, #object
  5217. +cpu_arch_name:
  5218. + .asciz "armv4"
  5219. + .size cpu_arch_name, . - cpu_arch_name
  5220. +
  5221. + .type cpu_elf_name, #object
  5222. +cpu_elf_name:
  5223. + .asciz "v4"
  5224. + .size cpu_elf_name, . - cpu_elf_name
  5225. +
  5226. + .type cpu_fa526_name, #object
  5227. +cpu_fa526_name:
  5228. + .ascii "FA526"
  5229. +#ifndef CONFIG_CPU_ICACHE_DISABLE
  5230. + .ascii "i"
  5231. +#endif
  5232. +#ifndef CONFIG_CPU_DCACHE_DISABLE
  5233. + .ascii "d"
  5234. +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  5235. + .ascii "(wt)"
  5236. +#else
  5237. + .ascii "(wb)"
  5238. +#endif
  5239. +#endif
  5240. + .ascii "\0"
  5241. + .size cpu_fa526_name, . - cpu_fa526_name
  5242. +
  5243. + .align
  5244. +
  5245. + .section ".proc.info.init", #alloc, #execinstr
  5246. +
  5247. +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  5248. +#define __PMD_SECT_BUFFERABLE 0
  5249. +#else
  5250. +#define __PMD_SECT_BUFFERABLE PMD_SECT_BUFFERABLE
  5251. +#endif
  5252. +
  5253. + .type __fa526_proc_info,#object
  5254. +__fa526_proc_info:
  5255. + .long 0x66015261
  5256. + .long 0xff01fff1
  5257. + .long PMD_TYPE_SECT | \
  5258. + __PMD_SECT_BUFFERABLE | \
  5259. + PMD_SECT_CACHEABLE | \
  5260. + PMD_BIT4 | \
  5261. + PMD_SECT_AP_WRITE | \
  5262. + PMD_SECT_AP_READ
  5263. + .long PMD_TYPE_SECT | \
  5264. + PMD_BIT4 | \
  5265. + PMD_SECT_AP_WRITE | \
  5266. + PMD_SECT_AP_READ
  5267. + b __fa526_setup
  5268. + .long cpu_arch_name
  5269. + .long cpu_elf_name
  5270. + .long HWCAP_SWP | HWCAP_HALF
  5271. + .long cpu_fa526_name
  5272. + .long fa526_processor_functions
  5273. + .long fa_tlb_fns
  5274. + .long fa_user_fns
  5275. + .long fa_cache_fns
  5276. + .size __fa526_proc_info, . - __fa526_proc_info
  5277. +
  5278. +
  5279. --- /dev/null
  5280. +++ b/arch/arm/mm/tlb-fa.S
  5281. @@ -0,0 +1,96 @@
  5282. +/*
  5283. + * linux/arch/arm/mm/tlb-fa.S
  5284. + *
  5285. + * Copyright (C) 2005 Faraday Corp.
  5286. + *
  5287. + * This program is free software; you can redistribute it and/or modify
  5288. + * it under the terms of the GNU General Public License version 2 as
  5289. + * published by the Free Software Foundation.
  5290. + *
  5291. + * ARM architecture version 4, Faraday variation.
  5292. + * This assume an unified TLBs, with a write buffer, and branch target buffer (BTB)
  5293. + *
  5294. + * Processors: FA520 FA526 FA626
  5295. + * 03/31/2005 : Created by Luke Lee, modified from tlb-v4wbi.S
  5296. + * 05/06/2005 : Fixed buggy CPU versions that did not invalidate the associated
  5297. + * data cache entries when invalidating TLB entries.
  5298. + */
  5299. +#include <linux/linkage.h>
  5300. +#include <linux/init.h>
  5301. +#include <asm/asm-offsets.h>
  5302. +#include <asm/tlbflush.h>
  5303. +#include "proc-macros.S"
  5304. +
  5305. +
  5306. +/*
  5307. + * flush_user_tlb_range(start, end, mm)
  5308. + *
  5309. + * Invalidate a range of TLB entries in the specified address space.
  5310. + *
  5311. + * - start - range start address
  5312. + * - end - range end address
  5313. + * - mm - mm_struct describing address space
  5314. + */
  5315. + .align 4
  5316. +ENTRY(fa_flush_user_tlb_range)
  5317. +
  5318. + vma_vm_mm ip, r2
  5319. + act_mm r3 @ get current->active_mm
  5320. + eors r3, ip, r3 @ == mm ?
  5321. + movne pc, lr @ no, we dont do anything
  5322. + mov r3, #0
  5323. +
  5324. +#ifndef CONFIG_CPU_FA_WB_DISABLE
  5325. + mcr p15, 0, r3, c7, c10, 4 @ drain WB
  5326. +#endif
  5327. +
  5328. + vma_vm_flags r2, r2
  5329. + bic r0, r0, #0x0ff
  5330. + bic r0, r0, #0xf00
  5331. +
  5332. +1: mcr p15, 0, r0, c8, c7, 1 @ invalidate UTLB entry
  5333. + add r0, r0, #PAGE_SZ
  5334. + cmp r0, r1
  5335. + bls 1b @ Luke Lee 05/19/2005 blo -> bls
  5336. +
  5337. +#ifdef CONFIG_CPU_FA_BTB
  5338. + mcr p15, 0, r3, c7, c5, 6 @ invalidate BTB
  5339. + nop
  5340. + nop
  5341. +#endif
  5342. + mov pc, lr
  5343. +
  5344. +
  5345. +ENTRY(fa_flush_kern_tlb_range)
  5346. + mov r3, #0
  5347. +
  5348. + mcr p15, 0, r3, c7, c10, 0 @ clean Dcache all 06/03/2005
  5349. +
  5350. +#ifndef CONFIG_CPU_FA_WB_DISABLE
  5351. + mcr p15, 0, r3, c7, c10, 4 @ drain WB
  5352. +#endif
  5353. +
  5354. + bic r0, r0, #0x0ff
  5355. + bic r0, r0, #0xf00
  5356. +1:
  5357. + mcr p15, 0, r0, c8, c7, 1 @ invalidate UTLB entry
  5358. + add r0, r0, #PAGE_SZ
  5359. + cmp r0, r1
  5360. + bls 1b @ Luke Lee 05/19/2005 blo -> bls
  5361. +
  5362. +#ifdef CONFIG_CPU_FA_BTB
  5363. + mcr p15, 0, r3, c7, c5, 6 @ invalidate BTB
  5364. + nop
  5365. + nop
  5366. +#endif
  5367. + mov pc, lr
  5368. +
  5369. +
  5370. + __INITDATA
  5371. +
  5372. + .type fa_tlb_fns, #object
  5373. +ENTRY(fa_tlb_fns)
  5374. + .long fa_flush_user_tlb_range
  5375. + .long fa_flush_kern_tlb_range
  5376. + .long fa_tlb_flags
  5377. + .size fa_tlb_fns, . - fa_tlb_fns
  5378. --- a/arch/arm/tools/mach-types
  5379. +++ b/arch/arm/tools/mach-types
  5380. @@ -208,7 +208,8 @@ karo ARCH_KARO KARO 190
  5381. fester SA1100_FESTER FESTER 191
  5382. gpi ARCH_GPI GPI 192
  5383. smdk2410 ARCH_SMDK2410 SMDK2410 193
  5384. -i519 ARCH_I519 I519 194
  5385. +#i519 ARCH_I519 I519 194
  5386. +sl2312 ARCH_SL2312 SL2312 194
  5387. nexio SA1100_NEXIO NEXIO 195
  5388. bitbox SA1100_BITBOX BITBOX 196
  5389. g200 SA1100_G200 G200 197
  5390. --- /dev/null
  5391. +++ b/include/asm-arm/arch-sl2312/SL_gpio.h
  5392. @@ -0,0 +1,59 @@
  5393. +#define GPIO_MINOR_LAST 31
  5394. +#define GPIO_MAJOR 120 // Experiemental
  5395. +
  5396. +#define GPIO_IRQ_NBR 12
  5397. +
  5398. +#define GPIOBASEADDR (IO_ADDRESS(0x021000000))
  5399. +
  5400. +#define GPIODATAOUTOFF 0x00
  5401. +#define GPIODATAINOFF 0x04
  5402. +#define GPIOPINDIROFF 0x08
  5403. +#define GPIOPINBYPASSOFF 0x0C
  5404. +#define GPIODATASETOFF 0x10
  5405. +#define GPIODATACLEAROFF 0x14
  5406. +#define GPIOPINPULLENBOFF 0x18
  5407. +#define GPIOPINPULLTPOFF 0x1C
  5408. +#define GPIOINTRENBOFF 0x20
  5409. +#define GPIOINTRRAWSOFF 0x24
  5410. +#define GPIOINTRMASKEDSTATEOFF 0x28
  5411. +#define GPIOINTRMASKOFF 0x2C
  5412. +#define GPIOINTRCLEAROFF 0x30
  5413. +#define GPIOINTRTRIGGEROFF 0x34
  5414. +#define GPIOINTRBOTHOFF 0x38
  5415. +#define GPIOINTRRISENEGOFF 0x3C
  5416. +#define GPIOBNCEENBOFF 0x40
  5417. +#define GPIOBNCEPRESOFF 0x44
  5418. +
  5419. +#define GPIO_IOCTRL_SETDIR 0x20
  5420. +#define GPIO_IOCTRL_SET 0x40
  5421. +#define GPIO_IOCTRL_CLEAR 0x50
  5422. +#define GPIO_IOCTRL_ENBINT 0x60
  5423. +#define GPIO_IOCTRL_MASKINT 0x70
  5424. +#define GPIO_IOCTRL_LVLTRIG 0x75
  5425. +#define GPIO_IOCTRL_EDGINT 0x77
  5426. +#define GPIO_IOCTRL_EDGPOLINT 0x78
  5427. +#define GPIO_IOCTRL_BYPASS 0x30
  5428. +#define GPIO_IOCTRL_PRESCLK 0x80
  5429. +#define GPIO_IOCTRL_CLKVAL 0x90
  5430. +#define GPIO_IOCTRL_PULLENB 0xA0
  5431. +#define GPIO_IOCTRL_PULLTYPE 0xA8
  5432. +
  5433. +
  5434. +#define GPIO_MAJOR 120 /* experimental MAJOR number */
  5435. + // Minor - 0 : 31 gpio pins
  5436. +
  5437. +#define GPIO_SET 0x01
  5438. +#define GPIO_CLEAR 0x01
  5439. +
  5440. +#define GPIO_INPUT 0
  5441. +#define GPIO_OUTPUT 1
  5442. +#define GPIO_EDGEINTR 0
  5443. +#define GPIO_EDGESINGL 0
  5444. +#define GPIO_EDGEBOTH 1
  5445. +#define GPIO_POSITIVE 0
  5446. +#define GPIO_ENBINT 1
  5447. +#define GPIO_DISABLEMASK 1
  5448. +#define GPIO_PULLDOWN 0
  5449. +#define GPIO_PULLUP 1
  5450. +#define GPIO_ENABLEPULL 1
  5451. +#define GPIO_DISABLEPULL 0
  5452. --- /dev/null
  5453. +++ b/include/asm-arm/arch-sl2312/debug-macro.S
  5454. @@ -0,0 +1,20 @@
  5455. +/* linux/include/asm-arm/arch-ebsa110/debug-macro.S
  5456. + *
  5457. + * Debugging macro include header
  5458. + *
  5459. + * Copyright (C) 1994-1999 Russell King
  5460. + * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
  5461. + *
  5462. + * This program is free software; you can redistribute it and/or modify
  5463. + * it under the terms of the GNU General Public License version 2 as
  5464. + * published by the Free Software Foundation.
  5465. + *
  5466. +**/
  5467. +
  5468. + .macro addruart,rx
  5469. + mov \rx, #0x42000000
  5470. + .endm
  5471. +
  5472. +#define UART_SHIFT 2
  5473. +#define FLOW_CONTROL
  5474. +#include <asm/hardware/debug-8250.S>
  5475. --- /dev/null
  5476. +++ b/include/asm-arm/arch-sl2312/dma.h
  5477. @@ -0,0 +1,28 @@
  5478. +/*
  5479. + * linux/include/asm-arm/arch-camelot/dma.h
  5480. + *
  5481. + * Copyright (C) 1997,1998 Russell King
  5482. + *
  5483. + * This program is free software; you can redistribute it and/or modify
  5484. + * it under the terms of the GNU General Public License as published by
  5485. + * the Free Software Foundation; either version 2 of the License, or
  5486. + * (at your option) any later version.
  5487. + *
  5488. + * This program is distributed in the hope that it will be useful,
  5489. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  5490. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5491. + * GNU General Public License for more details.
  5492. + *
  5493. + * You should have received a copy of the GNU General Public License
  5494. + * along with this program; if not, write to the Free Software
  5495. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  5496. + */
  5497. +#ifndef __ASM_ARCH_DMA_H
  5498. +#define __ASM_ARCH_DMA_H
  5499. +
  5500. +#define MAX_DMA_ADDRESS 0xffffffff
  5501. +
  5502. +#define MAX_DMA_CHANNELS 0
  5503. +
  5504. +#endif /* _ASM_ARCH_DMA_H */
  5505. +
  5506. --- /dev/null
  5507. +++ b/include/asm-arm/arch-sl2312/entry-macro.S
  5508. @@ -0,0 +1,42 @@
  5509. +/*
  5510. + * include/asm-arm/arch-arm/entry-macro.S
  5511. + *
  5512. + * Low-level IRQ helper macros for ebsa110 platform.
  5513. + *
  5514. + * This file is licensed under the terms of the GNU General Public
  5515. + * License version 2. This program is licensed "as is" without any
  5516. + * warranty of any kind, whether express or implied.
  5517. + */
  5518. +#include <asm/arch/platform.h>
  5519. +#include <asm/arch/int_ctrl.h>
  5520. +
  5521. +
  5522. + .macro disable_fiq
  5523. + .endm
  5524. +
  5525. + .macro get_irqnr_preamble, base, tmp
  5526. + .endm
  5527. +
  5528. + .macro arch_ret_to_user, tmp1, tmp2
  5529. + .endm
  5530. +
  5531. + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  5532. + ldr \irqstat, =IRQ_STATUS(IO_ADDRESS(SL2312_INTERRUPT_BASE))
  5533. + ldr \irqnr,[\irqstat]
  5534. + cmp \irqnr,#0
  5535. + beq 2313f
  5536. + mov \tmp,\irqnr
  5537. + mov \irqnr,#0
  5538. +2312:
  5539. + tst \tmp, #1
  5540. + bne 2313f
  5541. + add \irqnr, \irqnr, #1
  5542. + mov \tmp, \tmp, lsr #1
  5543. + cmp \irqnr, #31
  5544. + bcc 2312b
  5545. +2313:
  5546. + .endm
  5547. +
  5548. + .macro irq_prio_table
  5549. + .endm
  5550. +
  5551. --- /dev/null
  5552. +++ b/include/asm-arm/arch-sl2312/flash.h
  5553. @@ -0,0 +1,83 @@
  5554. +#ifndef __ASM_ARM_ARCH_FLASH_H
  5555. +#define __ASM_ARM_ARCH_FLASH_H
  5556. +
  5557. +#define FLASH_START SL2312_FLASH_BASE
  5558. +#define SFLASH_SIZE 0x00400000
  5559. +#define SPAGE_SIZE 0x200
  5560. +#define BLOCK_ERASE 0x50
  5561. +#define BUFFER1_READ 0x54
  5562. +#define BUFFER2_READ 0x56
  5563. +#define PAGE_ERASE 0x81
  5564. +#define MAIN_MEMORY_PAGE_READ 0x52
  5565. +#define MAIN_MEMORY_PROGRAM_BUFFER1 0x82
  5566. +#define MAIN_MEMORY_PROGRAM_BUFFER2 0x85
  5567. +#define BUFFER1_TO_MAIN_MEMORY 0x83
  5568. +#define BUFFER2_TO_MAIN_MEMORY 0x86
  5569. +#define MAIN_MEMORY_TO_BUFFER1 0x53
  5570. +#define MAIN_MEMORY_TO_BUFFER2 0x55
  5571. +#define BUFFER1_WRITE 0x84
  5572. +#define BUFFER2_WRITE 0x87
  5573. +#define AUTO_PAGE_REWRITE_BUFFER1 0x58
  5574. +#define AUTO_PAGE_REWRITE_BUFFER2 0x59
  5575. +#define READ_STATUS 0x57
  5576. +
  5577. +#define MAIN_MEMORY_PAGE_READ_SPI 0xD2
  5578. +#define BUFFER1_READ_SPI 0xD4
  5579. +#define BUFFER2_READ_SPI 0xD6
  5580. +#define READ_STATUS_SPI 0xD7
  5581. +
  5582. +#define FLASH_ACCESS_OFFSET 0x00000010
  5583. +#define FLASH_ADDRESS_OFFSET 0x00000014
  5584. +#define FLASH_WRITE_DATA_OFFSET 0x00000018
  5585. +#define FLASH_READ_DATA_OFFSET 0x00000018
  5586. +#define SERIAL_FLASH_CHIP1_EN 0x00010000 // 16th bit = 1
  5587. +#define SERIAL_FLASH_CHIP0_EN 0x00000000 // 16th bit = 0
  5588. +#define AT45DB321_PAGE_SHIFT 0xa
  5589. +#define AT45DB642_PAGE_SHIFT 0xb
  5590. +#define CONTINUOUS_MODE 0x00008000
  5591. +
  5592. +#define FLASH_ACCESS_ACTION_OPCODE 0x0000
  5593. +#define FLASH_ACCESS_ACTION_OPCODE_DATA 0x0100
  5594. +#define FLASH_ACCESS_ACTION_SHIFT_ADDRESS 0x0200
  5595. +#define FLASH_ACCESS_ACTION_SHIFT_ADDRESS_DATA 0x0300
  5596. +#define FLASH_ACCESS_ACTION_SHIFT_ADDRESS_X_DATA 0x0400
  5597. +#define FLASH_ACCESS_ACTION_SHIFT_ADDRESS_2X_DATA 0x0500
  5598. +#define FLASH_ACCESS_ACTION_SHIFT_ADDRESS_3X_DATA 0x0600
  5599. +#define FLASH_ACCESS_ACTION_SHIFT_ADDRESS_4X_DATA 0x0700
  5600. +//#define FLASH_ACCESS_ACTION_SHIFT_ADDRESS_X_DATA 0x0600
  5601. +//#define FLASH_ACCESS_ACTION_SHIFT_ADDRESS_4X_DATA 0x0700
  5602. +
  5603. +#define M25P80_PAGE_SIZE 0x100
  5604. +#define M25P80_SECTOR_SIZE 0x10000
  5605. +
  5606. +
  5607. +//#define M25P80_BULK_ERASE 1
  5608. +//#define M25P80_SECTOR_ERASE 2
  5609. +//#define M25P80_SECTOR_SIZE 0x10000
  5610. +
  5611. +#define M25P80_WRITE_ENABLE 0x06
  5612. +#define M25P80_WRITE_DISABLE 0x04
  5613. +#define M25P80_READ_STATUS 0x05
  5614. +#define M25P80_WRITE_STATUS 0x01
  5615. +#define M25P80_READ 0x03
  5616. +#define M25P80_FAST_READ 0x0B
  5617. +#define M25P80_PAGE_PROGRAM 0x02
  5618. +#define M25P80_SECTOR_ERASE 0xD8
  5619. +#define M25P80_BULK_ERASE 0xC7
  5620. +#define FLASH_ERR_OK 0x0
  5621. +
  5622. +extern void address_to_page(__u32, __u16 *, __u16 *);
  5623. +extern void main_memory_page_read(__u8, __u16, __u16, __u8 *);
  5624. +extern void buffer_to_main_memory(__u8, __u16);
  5625. +extern void main_memory_to_buffer(__u8, __u16);
  5626. +extern void main_memory_page_program(__u8, __u16, __u16, __u8);
  5627. +extern void atmel_flash_read_page(__u32, __u8 *, __u32);
  5628. +extern void atmel_erase_page(__u8, __u16);
  5629. +extern void atmel_read_status(__u8, __u8 *);
  5630. +extern void atmel_flash_program_page(__u32, __u8 *, __u32);
  5631. +extern void atmel_buffer_write(__u8, __u16, __u8);
  5632. +extern void flash_delay(void);
  5633. +
  5634. +extern int m25p80_sector_erase(__u32 address, __u32 schip_en);
  5635. +
  5636. +#endif
  5637. --- /dev/null
  5638. +++ b/include/asm-arm/arch-sl2312/gemini_cir.h
  5639. @@ -0,0 +1,102 @@
  5640. +#ifndef _ASM_ARCH_CIR_H
  5641. +#define _ASM_ARCH_CIR_H
  5642. +#include <linux/ioctl.h>
  5643. +
  5644. +#define VCR_KEY_POWER 0x613E609F
  5645. +#define TV1_KEY_POWER 0x40040100
  5646. +#define TV1_KEY_POWER_EXT 0xBCBD
  5647. +#define RC5_KER_POWER 0x0CF3
  5648. +
  5649. +#define VCC_H_ACT_PER (16-1)
  5650. +#define VCC_L_ACT_PER (8-1)
  5651. +#define VCC_DATA_LEN (32-1)
  5652. +#define TV1_H_ACT_PER (8-1)
  5653. +#define TV1_L_ACT_PER (4-1)
  5654. +#define TV1_DATA_LEN (48-1)
  5655. +
  5656. +#define VCC_BAUD 540
  5657. +#define TV1_BAUD 430
  5658. +#ifdef CONFIG_SL3516_ASIC
  5659. +#define EXT_CLK 60
  5660. +#else
  5661. +#define EXT_CLK 20
  5662. +#endif
  5663. +
  5664. +#define NEC_PROTOCOL 0x0
  5665. +#define RC5_PROTOCOL 0x1
  5666. +#define VCC_PROTOCOL 0x0
  5667. +#define TV1_PROTOCOL 0x01
  5668. +
  5669. +#ifndef SL2312_CIR_BASE
  5670. +#define SL2312_CIR_BASE 0x4C000000
  5671. +#endif
  5672. +#define CIR_BASE_ADDR IO_ADDRESS(SL2312_CIR_BASE)
  5673. +#define STORLINK_CIR_ID 0x00010400
  5674. +
  5675. +#define CIR_IP_ID *(volatile unsigned int *)(CIR_BASE_ADDR + 0x00)
  5676. +#define CIR_CTR_REG *(volatile unsigned int *)(CIR_BASE_ADDR + 0x04)
  5677. +#define CIR_STATUS_REG *(volatile unsigned int *)(CIR_BASE_ADDR + 0x08)
  5678. +#define CIR_RX_REG *(volatile unsigned int *)(CIR_BASE_ADDR + 0x0C)
  5679. +#define CIR_RX_EXT_REG *(volatile unsigned int *)(CIR_BASE_ADDR + 0x10)
  5680. +#define CIR_PWR_REG *(volatile unsigned int *)(CIR_BASE_ADDR + 0x14)
  5681. +#define CIR_PWR_EXT_REG *(volatile unsigned int *)(CIR_BASE_ADDR + 0x18)
  5682. +#define CIR_TX_CTR_REG *(volatile unsigned int *)(CIR_BASE_ADDR + 0x1C)
  5683. +#define CIR_TX_FEQ_REG *(volatile unsigned int *)(CIR_BASE_ADDR + 0x20)
  5684. +#define CIR_TX_REG *(volatile unsigned int *)(CIR_BASE_ADDR + 0x24)
  5685. +#define CIR_TX_EXT_REG *(volatile unsigned int *)(CIR_BASE_ADDR + 0x28)
  5686. +
  5687. +
  5688. +#ifndef SL2312_POWER_CTRL_BASE
  5689. +#define SL2312_POWER_CTRL_BASE 0x4B000000
  5690. +#endif
  5691. +
  5692. +#ifndef PWR_BASE_ADDR
  5693. +#define PWR_BASE_ADDR IO_ADDRESS(SL2312_POWER_CTRL_BASE)
  5694. +#endif
  5695. +#define PWR_CTRL_ID *(unsigned int*)(PWR_BASE_ADDR+0x00)
  5696. +#define PWR_CTRL_REG *(unsigned int*)(PWR_BASE_ADDR+0x04)
  5697. +#define PWR_STATUS_REG *(unsigned int*)(PWR_BASE_ADDR+0x08)
  5698. +
  5699. +
  5700. +#define BIT(x) (1<<x)
  5701. +#define TX_STATUS BIT(3)
  5702. +
  5703. +#define PWR_STAT_CIR 0x10
  5704. +#define PWR_STAT_RTC 0x20
  5705. +#define PWR_STAT_PUSH 0x40
  5706. +#define PWR_SHUTDOWN 0x01
  5707. +
  5708. +#define CARR_FREQ 38000
  5709. +
  5710. +struct cir_ioctl_data {
  5711. + __u32 data;
  5712. +};
  5713. +struct cir_ioctl_data48 {
  5714. + __u32 timeout;
  5715. + __u32 length;
  5716. + __u8 ret;
  5717. + __u32 data;
  5718. + __u32 data_ext;
  5719. +};
  5720. +#define OLD_DATA 0
  5721. +#define NEW_RECEIVE 1
  5722. +
  5723. +#define CIR_IOCTL_BASE ('I'|'R')
  5724. +#define CIR_SET_BAUDRATE _IOW (CIR_IOCTL_BASE, 0, struct cir_ioctl_data)
  5725. +#define CIR_SET_HIGH_PERIOD _IOW (CIR_IOCTL_BASE, 1, struct cir_ioctl_data)
  5726. +#define CIR_SET_LOW_PERIOD _IOW (CIR_IOCTL_BASE, 2, struct cir_ioctl_data)
  5727. +#define CIR_SET_PROTOCOL _IOW (CIR_IOCTL_BASE, 3, struct cir_ioctl_data)
  5728. +#define CIR_SET_ENABLE_COMPARE _IOW (CIR_IOCTL_BASE, 4, struct cir_ioctl_data)
  5729. +#define CIR_SET_ENABLE_DEMOD _IOW (CIR_IOCTL_BASE, 5, struct cir_ioctl_data)
  5730. +#define CIR_SET_POWER_KEY _IOW (CIR_IOCTL_BASE, 6, struct cir_ioctl_data)
  5731. +#define CIR_GET_BAUDRATE _IOR (CIR_IOCTL_BASE, 7, struct cir_ioctl_data)
  5732. +#define CIR_GET_HIGH_PERIOD _IOR (CIR_IOCTL_BASE, 8 ,struct cir_ioctl_data)
  5733. +#define CIR_GET_LOW_PERIOD _IOR (CIR_IOCTL_BASE, 9 ,struct cir_ioctl_data)
  5734. +#define CIR_GET_PROTOCOL _IOR (CIR_IOCTL_BASE, 10, struct cir_ioctl_data)
  5735. +#define CIR_GET_ENABLE_COMPARE _IOR (CIR_IOCTL_BASE, 11, struct cir_ioctl_data)
  5736. +#define CIR_GET_ENABLE_DEMOD _IOR (CIR_IOCTL_BASE, 12, struct cir_ioctl_data)
  5737. +#define CIR_GET_POWER_KEY _IOR (CIR_IOCTL_BASE, 13, struct cir_ioctl_data)
  5738. +#define CIR_GET_DATA _IOWR (CIR_IOCTL_BASE, 14, struct cir_ioctl_data48)
  5739. +#define CIR_WAIT_INT_DATA _IOWR (CIR_IOCTL_BASE, 15, struct cir_ioctl_data48)
  5740. +
  5741. +#endif //_ASM_ARCH_CIR_H
  5742. --- /dev/null
  5743. +++ b/include/asm-arm/arch-sl2312/gemini_gpio.h
  5744. @@ -0,0 +1,77 @@
  5745. +/*
  5746. + * FILE NAME gemini_gpio.h
  5747. + *
  5748. + * BRIEF MODULE DESCRIPTION
  5749. + * Generic Gemini GPIO
  5750. + *
  5751. + * Author: Storlink Software [Device driver]
  5752. + * Jason Lee <[email protected]>
  5753. + *
  5754. + * Copyright 2005 Storlink Inc.
  5755. + *
  5756. + * This program is free software; you can redistribute it and/or modify it
  5757. + * under the terms of the GNU General Public License as published by the
  5758. + * Free Software Foundation; either version 2 of the License, or (at your
  5759. + * option) any later version.
  5760. + *
  5761. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  5762. + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  5763. + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  5764. + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  5765. + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  5766. + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  5767. + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  5768. + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  5769. + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  5770. + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5771. + *
  5772. + * You should have received a copy of the GNU General Public License along
  5773. + * with this program; if not, write to the Free Software Foundation, Inc.,
  5774. + * 675 Mass Ave, Cambridge, MA 02139, USA.
  5775. + */
  5776. +
  5777. +#ifndef __GEMINI_GPIO_H
  5778. +#define __GEMINI_GPIO_H
  5779. +
  5780. +#include <linux/ioctl.h>
  5781. +
  5782. +#define STATUS_HIGH 1
  5783. +#define STATUS_LOW 0
  5784. +#define DIRECT_OUT 1
  5785. +#define DIRECT_IN 0
  5786. +
  5787. +#define EDGE_TRIG 0
  5788. +#define RISING_EDGE 0
  5789. +#define FALL_EDGE 1
  5790. +#define SINGLE_EDGE 0
  5791. +#define BOTH_EDGE 1
  5792. +
  5793. +#define LEVEL_TRIG 1
  5794. +#define HIGH_ACTIVE 0
  5795. +#define LOW_ACTIVE 1
  5796. +
  5797. +struct gemini_gpio_ioctl_data {
  5798. + __u32 pin;
  5799. + __u8 status; // status or pin direction
  5800. + // 0: status low or Input
  5801. + // 1: status high or Output
  5802. +
  5803. + /* these member are used to config GPIO interrupt parameter */
  5804. + __u8 use_default; // if not sure ,set this argument 1
  5805. + __u8 trig_type; // 0/1:edge/level triger ?
  5806. + __u8 trig_polar; // 0/1:rising/falling high/low active ?
  5807. + __u8 trig_both; // 0/1:single/both detect both ?
  5808. +};
  5809. +
  5810. +#define GEMINI_GPIO_IOCTL_BASE 'Z'
  5811. +
  5812. +#define GEMINI_SET_GPIO_PIN_DIR _IOW (GEMINI_GPIO_IOCTL_BASE,16, struct gemini_gpio_ioctl_data)
  5813. +#define GEMINI_SET_GPIO_PIN_STATUS _IOW (GEMINI_GPIO_IOCTL_BASE,17, struct gemini_gpio_ioctl_data)
  5814. +#define GEMINI_GET_GPIO_PIN_STATUS _IOWR(GEMINI_GPIO_IOCTL_BASE,18, struct gemini_gpio_ioctl_data)
  5815. +#define GEMINI_WAIT_GPIO_PIN_INT _IOWR(GEMINI_GPIO_IOCTL_BASE,19, struct gemini_gpio_ioctl_data)
  5816. +
  5817. +
  5818. +extern void init_gpio_int(__u32 pin,__u8 trig_type,__u8 trig_polar,__u8 trig_both);
  5819. +extern int request_gpio_irq(int bit,void (*handler)(int),char level,char high,char both);
  5820. +extern int free_gpio_irq(int bit);
  5821. +#endif
  5822. --- /dev/null
  5823. +++ b/include/asm-arm/arch-sl2312/gemini_i2s.h
  5824. @@ -0,0 +1,169 @@
  5825. +#ifndef __GEMINI_I2S_H__
  5826. +#define __GEMINI_I2S_H__
  5827. +#include <linux/ioctl.h>
  5828. +#include <linux/types.h>
  5829. +#include <asm/arch-sl2312/irqs.h>
  5830. +
  5831. +typedef __u16 UINT16;
  5832. +typedef __u32 UINT32;
  5833. +typedef __u8 UINT8;
  5834. +typedef __u8 BOOL;
  5835. +
  5836. +/***************************************/
  5837. +/* define GPIO module base address */
  5838. +/***************************************/
  5839. +#define DMA_CONTROL_PHY_BASE (IO_ADDRESS(SL2312_GENERAL_DMA_BASE))
  5840. +#define DMA_CONTROL_SSP_BASE (IO_ADDRESS(SL2312_SSP_CTRL_BASE))
  5841. +#define SSP_INT IRQ_SSP
  5842. +#define GPIO_BASE_ADDR (IO_ADDRESS(SL2312_GPIO_BASE))
  5843. +#define GPIO_BASE_ADDR1 (IO_ADDRESS(SL2312_GPIO_BASE1))
  5844. +#define GLOBAL_BASE (IO_ADDRESS(SL2312_GLOBAL_BASE))
  5845. +
  5846. +/* define read/write register utility */
  5847. +#define READ_SSP_REG(offset) (__raw_readl(offset+DMA_CONTROL_SSP_BASE))
  5848. +#define WRITE_SSP_REG(offset,val) (__raw_writel(val,offset+DMA_CONTROL_SSP_BASE))
  5849. +
  5850. +#define READ_GPIO_REG(offset) (__raw_readl(offset+GPIO_BASE_ADDR))
  5851. +#define WRITE_GPIO_REG(offset,val) (__raw_writel(val,offset+GPIO_BASE_ADDR))
  5852. +
  5853. +#define READ_GPIO1_REG(offset) (__raw_readl(offset+GPIO_BASE_ADDR1))
  5854. +#define WRITE_GPIO1_REG(offset,val) (__raw_writel(val,offset+GPIO_BASE_ADDR1))
  5855. +
  5856. +#define READ_DMA_REG(offset) (__raw_readl(offset+DMA_CONTROL_PHY_BASE))
  5857. +#define WRITE_DMA_REG(offset,val) (__raw_writel(val,offset+DMA_CONTROL_PHY_BASE))
  5858. +
  5859. +#define READ_GLOBAL_REG(offset) (__raw_readl(offset+GLOBAL_BASE))
  5860. +#define WRITE_GLOBAL_REG(offset,val) (__raw_writel(val,offset+GLOBAL_BASE))
  5861. +
  5862. +#define SSP_GPIO_INT IRQ_GPIO
  5863. +
  5864. +#ifndef CONFIG_SL3516_ASIC
  5865. +#define SSP_GPIO_INT_BIT 0x00000400 //GPIO[10] : SLIC interrupt pin
  5866. +
  5867. +#define GPIO_EECK 0x00000040 /* SCK: GPIO[06] */
  5868. +#define GPIO_EECS 0x00000080 /* SCS: GPIO[07] */
  5869. +#define GPIO_MISO 0x00000200 /* SDO: GPIO[09] receive from 6996*/
  5870. +#define GPIO_MOSI 0x00000100 /* SDI: GPIO[08] send to 6996*/
  5871. +#define GPIO_MISO_BIT 9
  5872. +#else
  5873. +#define SSP_GPIO_INT_BIT 0x00000001 //GPIO[0] : SLIC interrupt pin
  5874. +
  5875. +//#if 0
  5876. +//#define GPIO_EECK 0x80000000 /* SCK: GPIO1[31] */
  5877. +//#define GPIO_EECS 0x40000000 /* SCS: GPIO1[30] */
  5878. +//#define GPIO_MISO 0x20000000 /* SDO: GPIO1[29] receive from 6996*/
  5879. +//#define GPIO_MOSI 0x10000000 /* SDI: GPIO1[28] send to 6996*/
  5880. +//#define GPIO_MISO_BIT 29
  5881. +//#else
  5882. +//#define GPIO_EECK 0x00000100 /* SCK: GPIO1[08] */
  5883. +//#define GPIO_EECS 0x08000000 /* SCS: GPIO1[27] */
  5884. +//#define GPIO_MISO 0x00000080 /* SDO: GPIO1[07] receive from 6996*/
  5885. +//#define GPIO_MOSI 0x00000200 /* SDI: GPIO1[09] send to 6996*/
  5886. +//#define GPIO_MISO_BIT 7
  5887. +//#endif
  5888. +#endif
  5889. +
  5890. +
  5891. +enum GPIO_REG
  5892. +{
  5893. + GPIO_DATA_OUT = 0x00,
  5894. + GPIO_DATA_IN = 0x04,
  5895. + GPIO_PIN_DIR = 0x08,
  5896. + GPIO_BY_PASS = 0x0c,
  5897. + GPIO_DATA_SET = 0x10,
  5898. + GPIO_DATA_CLEAR = 0x14,
  5899. + GPIO_INT_ENABLE = 0x20,
  5900. + GPIO_INT_RAWSTATE = 0x24,
  5901. + GPIO_INT_MASKSTATE = 0x28,
  5902. + GPIO_INT_MASK = 0x2C,
  5903. + GPIO_INT_CLEAR = 0x30,
  5904. + GPIO_INT_TRIGGER = 0x34,
  5905. + GPIO_INT_BOTH = 0x38,
  5906. + GPIO_INT_POLARITY = 0x3C
  5907. +};
  5908. +
  5909. +typedef struct
  5910. +{
  5911. + UINT32 src_addr;
  5912. + UINT32 dst_addr;
  5913. + UINT32 llp;
  5914. + UINT32 ctrl_size;
  5915. + UINT32 owner;
  5916. +}DMA_LLP_t;
  5917. +
  5918. +typedef struct
  5919. +{
  5920. + UINT32 owner;
  5921. + UINT32 src_addr;
  5922. + UINT32 ctrl_size;
  5923. +}IOCTL_LLP_t;
  5924. +
  5925. +typedef unsigned char byte;
  5926. +typedef unsigned short word;
  5927. +typedef unsigned long dword;
  5928. +
  5929. +/* DMA Registers */
  5930. +#define DMA_INT 0x00000000
  5931. +#define DMA_INT_TC 0x00000004
  5932. +#define DMA_CFG 0x00000024
  5933. +#define DMA_INT_TC_CLR 0x00000008
  5934. +#define DMA_TC 0x00000014
  5935. +#define DMA_CSR 0x00000024
  5936. +#define DMA_SYNC 0x00000028
  5937. +
  5938. +#define DMA_CH2_CSR 0x00000140
  5939. +#define DMA_CH2_CFG 0x00000144
  5940. +#define DMA_CH2_SRC_ADDR 0x00000148
  5941. +#define DMA_CH2_DST_ADDR 0x0000014c
  5942. +#define DMA_CH2_LLP 0x00000150
  5943. +#define DMA_CH2_SIZE 0x00000154
  5944. +
  5945. +#define DMA_CH3_CSR 0x00000160
  5946. +#define DMA_CH3_CFG 0x00000164
  5947. +#define DMA_CH3_SRC_ADDR 0x00000168
  5948. +#define DMA_CH3_DST_ADDR 0x0000016c
  5949. +#define DMA_CH3_LLP 0x00000170
  5950. +#define DMA_CH3_SIZE 0x00000174
  5951. +
  5952. +#define SSP_DEVICE_ID 0x00
  5953. +#define SSP_CTRL_STATUS 0x04
  5954. +#define SSP_FRAME_CTRL 0x08
  5955. +#define SSP_BAUD_RATE 0x0c
  5956. +#define SSP_FRAME_CTRL2 0x10
  5957. +#define SSP_FIFO_CTRL 0x14
  5958. +#define SSP_TX_SLOT_VALID0 0x18
  5959. +#define SSP_TX_SLOT_VALID1 0x1c
  5960. +#define SSP_TX_SLOT_VALID2 0x20
  5961. +#define SSP_TX_SLOT_VALID3 0x24
  5962. +#define SSP_RX_SLOT_VALID0 0x28
  5963. +#define SSP_RX_SLOT_VALID1 0x2c
  5964. +#define SSP_RX_SLOT_VALID2 0x30
  5965. +#define SSP_RX_SLOT_VALID3 0x34
  5966. +#define SSP_SLOT_SIZE0 0x38
  5967. +#define SSP_SLOT_SIZE1 0x3c
  5968. +#define SSP_SLOT_SIZE2 0x40
  5969. +#define SSP_SLOT_SIZE3 0x44
  5970. +#define SSP_READ_PORT 0x48
  5971. +#define SSP_WRITE_PORT 0x4c
  5972. +
  5973. +
  5974. +
  5975. +#define SSP_I2S_INIT_BUF _IO ('q', 0x00)
  5976. +#define SSP_I2S_STOP_DMA _IO ('q', 0x01)
  5977. +#define SSP_I2S_FILE_LEN _IOW ('q', 0x2, int)
  5978. +/*
  5979. +#define SSP_GET_HOOK_STATUS _IOR ('q', 0xC0, int)
  5980. +#define SSP_GET_LINEFEED _IOR ('q', 0xC1, int)
  5981. +#define SSP_SET_LINEFEED _IOW ('q', 0xC2, int)
  5982. +#define SSP_GET_REG _IOWR ('q', 0xC3, struct Ssp_reg *)
  5983. +#define SSP_SET_REG _IOWR ('q', 0xC4, struct Ssp_reg *)
  5984. +#define SSP_GEN_OFFHOOK_TONE _IO ('q', 0xC5)
  5985. +#define SSP_GEN_BUSY_TONE _IO ('q', 0xC6)
  5986. +#define SSP_GEN_RINGBACK_TONE _IO ('q', 0xC7)
  5987. +#define SSP_GEN_CONGESTION_TONE _IO ('q', 0xC8)
  5988. +#define SSP_DISABLE_DIALTONE _IO ('q', 0xC9)
  5989. +#define SSP_PHONE_RING_START _IO ('q', 0xCA)
  5990. +*/
  5991. +
  5992. +
  5993. +#endif //__GEMINI_I2S_H__
  5994. --- /dev/null
  5995. +++ b/include/asm-arm/arch-sl2312/gemini_ssp.h
  5996. @@ -0,0 +1,263 @@
  5997. +/******************************************************************************
  5998. + * gemini_ssp.h
  5999. + *
  6000. + *
  6001. + *****************************************************************************/
  6002. +
  6003. +#include <linux/types.h>
  6004. +#include <asm/arch-sl2312/irqs.h>
  6005. +#include <linux/phonedev.h>
  6006. +#include <linux/telephony.h>
  6007. +//#include "proslic.h"
  6008. +
  6009. +typedef __u16 UINT16;
  6010. +typedef __u32 UINT32;
  6011. +typedef __u8 UINT8;
  6012. +typedef __u8 BOOL;
  6013. +
  6014. +#define TRUE 1
  6015. +#define FALSE 0
  6016. +
  6017. +/***************************************/
  6018. +/* define GPIO module base address */
  6019. +/***************************************/
  6020. +#define DMA_CONTROL_PHY_BASE (IO_ADDRESS(SL2312_GENERAL_DMA_BASE))
  6021. +#define DMA_CONTROL_SSP_BASE (IO_ADDRESS(SL2312_SSP_CTRL_BASE))
  6022. +#define SSP_INT IRQ_SSP
  6023. +#define GPIO_BASE_ADDR (IO_ADDRESS(SL2312_GPIO_BASE))
  6024. +#define GPIO_BASE_ADDR1 (IO_ADDRESS(SL2312_GPIO_BASE1))
  6025. +#define GLOBAL_BASE (IO_ADDRESS(SL2312_GLOBAL_BASE))
  6026. +
  6027. +/* define read/write register utility */
  6028. +#define READ_SSP_REG(offset) (__raw_readl(offset+DMA_CONTROL_SSP_BASE))
  6029. +#define WRITE_SSP_REG(offset,val) (__raw_writel(val,offset+DMA_CONTROL_SSP_BASE))
  6030. +
  6031. +#define READ_GPIO_REG(offset) (__raw_readl(offset+GPIO_BASE_ADDR))
  6032. +#define WRITE_GPIO_REG(offset,val) (__raw_writel(val,offset+GPIO_BASE_ADDR))
  6033. +
  6034. +#define READ_GPIO1_REG(offset) (__raw_readl(offset+GPIO_BASE_ADDR1))
  6035. +#define WRITE_GPIO1_REG(offset,val) (__raw_writel(val,offset+GPIO_BASE_ADDR1))
  6036. +
  6037. +#define READ_DMA_REG(offset) (__raw_readl(offset+DMA_CONTROL_PHY_BASE))
  6038. +#define WRITE_DMA_REG(offset,val) (__raw_writel(val,offset+DMA_CONTROL_PHY_BASE))
  6039. +
  6040. +#define READ_GLOBAL_REG(offset) (__raw_readl(offset+GLOBAL_BASE))
  6041. +#define WRITE_GLOBAL_REG(offset,val) (__raw_writel(val,offset+GLOBAL_BASE))
  6042. +
  6043. +
  6044. +#define SSP_GPIO_INT IRQ_GPIO
  6045. +
  6046. +#ifndef CONFIG_SL3516_ASIC
  6047. +#define SSP_GPIO_INT_BIT 0x00000400 //GPIO[10] : SLIC interrupt pin
  6048. +
  6049. +#define GPIO_EECK 0x00000040 /* SCK: GPIO[06] */
  6050. +#define GPIO_EECS 0x00000080 /* SCS: GPIO[07] */
  6051. +#define GPIO_MISO 0x00000200 /* SDO: GPIO[09] receive from 6996*/
  6052. +#define GPIO_MOSI 0x00000100 /* SDI: GPIO[08] send to 6996*/
  6053. +#define GPIO_MISO_BIT 9
  6054. +#else
  6055. +#define SSP_GPIO_INT_BIT 0x00000001 //GPIO[0] : SLIC interrupt pin
  6056. +
  6057. +//#if 0
  6058. +//#define GPIO_EECK 0x80000000 /* SCK: GPIO1[31] */
  6059. +//#define GPIO_EECS 0x40000000 /* SCS: GPIO1[30] */
  6060. +//#define GPIO_MISO 0x20000000 /* SDO: GPIO1[29] receive from 6996*/
  6061. +//#define GPIO_MOSI 0x10000000 /* SDI: GPIO1[28] send to 6996*/
  6062. +//#define GPIO_MISO_BIT 29
  6063. +//#else
  6064. +//#define GPIO_EECK 0x00000100 /* SCK: GPIO1[08] */
  6065. +//#define GPIO_EECS 0x08000000 /* SCS: GPIO1[27] */
  6066. +//#define GPIO_MISO 0x00000080 /* SDO: GPIO1[07] receive from 6996*/
  6067. +//#define GPIO_MOSI 0x00000200 /* SDI: GPIO1[09] send to 6996*/
  6068. +//#define GPIO_MISO_BIT 7
  6069. +//#endif
  6070. +#endif
  6071. +
  6072. +
  6073. +enum GPIO_REG
  6074. +{
  6075. + GPIO_DATA_OUT = 0x00,
  6076. + GPIO_DATA_IN = 0x04,
  6077. + GPIO_PIN_DIR = 0x08,
  6078. + GPIO_BY_PASS = 0x0c,
  6079. + GPIO_DATA_SET = 0x10,
  6080. + GPIO_DATA_CLEAR = 0x14,
  6081. + GPIO_INT_ENABLE = 0x20,
  6082. + GPIO_INT_RAWSTATE = 0x24,
  6083. + GPIO_INT_MASKSTATE = 0x28,
  6084. + GPIO_INT_MASK = 0x2C,
  6085. + GPIO_INT_CLEAR = 0x30,
  6086. + GPIO_INT_TRIGGER = 0x34,
  6087. + GPIO_INT_BOTH = 0x38,
  6088. + GPIO_INT_POLARITY = 0x3C
  6089. +};
  6090. +
  6091. +
  6092. +#define SPI_ADD_LEN 7 // bits of Address
  6093. +#define SPI_DAT_LEN 8 // bits of Data
  6094. +
  6095. +
  6096. +
  6097. +//#ifdef MIDWAY_DIAG
  6098. +#define DAISY_MODE 1
  6099. +#if (DAISY_MODE==1)
  6100. +#define NUMBER_OF_CHAN 2
  6101. +#else
  6102. +#define NUMBER_OF_CHAN 1
  6103. +#endif
  6104. +#define LLP_SIZE 8
  6105. +#define SBUF_SIZE 512 //0xff0 //2560
  6106. +#define DBUF_SIZE SBUF_SIZE*NUMBER_OF_CHAN //0xff0 //2560
  6107. +#define TBUF_SIZE (LLP_SIZE)*DBUF_SIZE
  6108. +#define DESC_NUM 1
  6109. +#define DTMF_NUM 20
  6110. +
  6111. +/* define owner bit of SSP */
  6112. +//data into SSP and transfer to AP==> SSP_Rx
  6113. +//data out of SSP and transfer to SLIC==> SSP_Tx
  6114. +#define CPU 0
  6115. +#define DMA 1
  6116. +
  6117. +#define DMA_DEMO 0
  6118. +#define DMA_NDEMO 1
  6119. +//#define DMA_NONE 2
  6120. +
  6121. +enum exceptions {
  6122. + PROSLICiNSANE,
  6123. + TIMEoUTpOWERuP,
  6124. + TIMEoUTpOWERdOWN,
  6125. + POWERlEAK,
  6126. + TIPoRrINGgROUNDsHORT,
  6127. + POWERaLARMQ1,
  6128. + POWERaLARMQ2,
  6129. + POWERaLARMQ3,
  6130. + POWERaLARMQ4,
  6131. + POWERaLARMQ5,
  6132. + OWERaLARMQ6,
  6133. + CM_CAL_ERR
  6134. +};
  6135. +
  6136. +typedef struct
  6137. +{
  6138. + UINT32 src_addr;
  6139. + UINT32 dst_addr;
  6140. + UINT32 llp;
  6141. + UINT32 ctrl_size;
  6142. +}DMA_LLP_t;
  6143. +
  6144. +typedef struct {
  6145. + unsigned int own ;
  6146. + char *tbuf;
  6147. + //UINT32 *LinkAddrT;
  6148. + DMA_LLP_t LLPT[LLP_SIZE];
  6149. +}DMA_Tx_t;
  6150. +
  6151. +typedef struct {
  6152. + unsigned int own ;
  6153. + char *rbuf;
  6154. + //UINT32 *LinkAddrR;
  6155. + DMA_LLP_t LLPR[LLP_SIZE];
  6156. +}DMA_Rx_t;
  6157. +
  6158. +//typedef struct {
  6159. +// //UINT32 init_stat;
  6160. +// struct chipStruct chipData ; /* Represents a proslics state, cached information, and timers */
  6161. +// struct phone_device p;
  6162. +//
  6163. +//
  6164. +//}SSP_SLIC;
  6165. +
  6166. +
  6167. +
  6168. +/* DMA Registers */
  6169. +#define DMA_INT 0x00000000
  6170. +#define DMA_INT_TC 0x00000004
  6171. +#define DMA_CFG 0x00000024
  6172. +#define DMA_INT_TC_CLR 0x00000008
  6173. +#define DMA_TC 0x00000014
  6174. +#define DMA_CSR 0x00000024
  6175. +#define DMA_SYNC 0x00000028
  6176. +
  6177. +#define DMA_CH2_CSR 0x00000140
  6178. +#define DMA_CH2_CFG 0x00000144
  6179. +#define DMA_CH2_SRC_ADDR 0x00000148
  6180. +#define DMA_CH2_DST_ADDR 0x0000014c
  6181. +#define DMA_CH2_LLP 0x00000150
  6182. +#define DMA_CH2_SIZE 0x00000154
  6183. +
  6184. +#define DMA_CH3_CSR 0x00000160
  6185. +#define DMA_CH3_CFG 0x00000164
  6186. +#define DMA_CH3_SRC_ADDR 0x00000168
  6187. +#define DMA_CH3_DST_ADDR 0x0000016c
  6188. +#define DMA_CH3_LLP 0x00000170
  6189. +#define DMA_CH3_SIZE 0x00000174
  6190. +
  6191. +#define SSP_DEVICE_ID 0x00
  6192. +#define SSP_CTRL_STATUS 0x04
  6193. +#define SSP_FRAME_CTRL 0x08
  6194. +#define SSP_BAUD_RATE 0x0c
  6195. +#define SSP_FRAME_CTRL2 0x10
  6196. +#define SSP_FIFO_CTRL 0x14
  6197. +#define SSP_TX_SLOT_VALID0 0x18
  6198. +#define SSP_TX_SLOT_VALID1 0x1c
  6199. +#define SSP_TX_SLOT_VALID2 0x20
  6200. +#define SSP_TX_SLOT_VALID3 0x24
  6201. +#define SSP_RX_SLOT_VALID0 0x28
  6202. +#define SSP_RX_SLOT_VALID1 0x2c
  6203. +#define SSP_RX_SLOT_VALID2 0x30
  6204. +#define SSP_RX_SLOT_VALID3 0x34
  6205. +#define SSP_SLOT_SIZE0 0x38
  6206. +#define SSP_SLOT_SIZE1 0x3c
  6207. +#define SSP_SLOT_SIZE2 0x40
  6208. +#define SSP_SLOT_SIZE3 0x44
  6209. +#define SSP_READ_PORT 0x48
  6210. +#define SSP_WRITE_PORT 0x4c
  6211. +
  6212. +
  6213. +void printFreq_Revision(int num);
  6214. +void SLIC_SPI_write(int num, UINT8 ,UINT8);
  6215. +UINT8 SLIC_SPI_read(int num, UINT8);
  6216. +void SLIC_SPI_write_bit(char);
  6217. +void SLIC_SPI_ind_write(int num, UINT8, UINT16);
  6218. +UINT16 SLIC_SPI_ind_read(int num, UINT8);
  6219. +void SLIC_SPI_CS_enable(UINT8);
  6220. +unsigned int SLIC_SPI_read_bit(void);
  6221. +void SLIC_SPI_pre_st(void);
  6222. +UINT32 ssp_init(void);
  6223. +UINT16 SLIC_SPI_get_identifier(int num);
  6224. +int selfTest(int num);
  6225. +void exception (int num, enum exceptions e);
  6226. +int SLIC_init(int num);
  6227. +UINT8 version(int num);
  6228. +UINT8 chipType (int num);
  6229. +void SLIC_init_ind_reg_set(int num);
  6230. +UINT8 powerUp(int num);
  6231. +UINT8 powerLeakTest(int num);
  6232. +void SLIC_init_reg_set(int num);
  6233. +int calibrate(int num);
  6234. +void goActive(int num);
  6235. +void clearInterrupts(int num);
  6236. +void setState(int num, int);
  6237. +UINT8 loopStatus(int num);
  6238. +int verifyIndirectRegisters(int num);
  6239. +int verifyIndirectReg(int num, UINT8 , UINT16);
  6240. +void sendProSLICID(int num);
  6241. +void disableOscillators(int num);
  6242. +UINT8 checkSum(int num, char * string );
  6243. +void fskInitialization (int num);
  6244. +void fskByte(int num, UINT8 c);
  6245. +void waitForInterrupt (int num);
  6246. +//void findNumber(void);
  6247. +UINT8 dtmfAction(int num);
  6248. +UINT8 digit(int num);
  6249. +void interrupt_init(void);
  6250. +//void gemini_slic_isr (int );
  6251. +int groundShort(int num);
  6252. +void clearAlarmBits(int num);
  6253. +void stopRinging(int num);
  6254. +void activateRinging(int num);
  6255. +void initializeLoopDebounceReg(int num);
  6256. +void busyJapan(int num) ;
  6257. +void ringBackJapan(int num) ;
  6258. +void stateMachine(int num);
  6259. +
  6260. --- /dev/null
  6261. +++ b/include/asm-arm/arch-sl2312/hardware.h
  6262. @@ -0,0 +1,47 @@
  6263. +/*
  6264. + * linux/include/asm-arm/arch-epxa10/hardware.h
  6265. + *
  6266. + * This file contains the hardware definitions of the Integrator.
  6267. + *
  6268. + * Copyright (C) 1999 ARM Limited.
  6269. + * Copyright (C) 2001 Altera Corporation
  6270. + *
  6271. + * This program is free software; you can redistribute it and/or modify
  6272. + * it under the terms of the GNU General Public License as published by
  6273. + * the Free Software Foundation; either version 2 of the License, or
  6274. + * (at your option) any later version.
  6275. + *
  6276. + * This program is distributed in the hope that it will be useful,
  6277. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6278. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6279. + * GNU General Public License for more details.
  6280. + *
  6281. + * You should have received a copy of the GNU General Public License
  6282. + * along with this program; if not, write to the Free Software
  6283. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  6284. + */
  6285. +#ifndef __ASM_ARCH_HARDWARE_H
  6286. +#define __ASM_ARCH_HARDWARE_H
  6287. +
  6288. +#include <asm/arch/platform.h>
  6289. +
  6290. +#define pcibios_assign_all_busses() 1
  6291. +
  6292. +/*
  6293. + * Where in virtual memory the IO devices (timers, system controllers
  6294. + * and so on)
  6295. + *
  6296. + * macro to get at IO space when running virtually
  6297. +*/
  6298. +
  6299. +#define IO_ADDRESS(x) (((x&0xfff00000)>>4)|(x & 0x000fffff)|0xF0000000)
  6300. +#define FLASH_VBASE 0xFE000000
  6301. +#define FLASH_SIZE 0x1000000// 8M
  6302. +#define FLASH_START SL2312_FLASH_BASE
  6303. +#define FLASH_VADDR(x) ((x & 0x00ffffff)|0xFE000000) // flash virtual address
  6304. +
  6305. +#define PCIBIOS_MIN_IO 0x100 // 0x000-0x100 AHB reg and PCI config, data
  6306. +#define PCIBIOS_MIN_MEM 0
  6307. +
  6308. +#endif
  6309. +
  6310. --- /dev/null
  6311. +++ b/include/asm-arm/arch-sl2312/int_ctrl.h
  6312. @@ -0,0 +1,171 @@
  6313. +/*
  6314. + *
  6315. + * This file contains the register definitions for the Excalibur
  6316. + * Timer TIMER00.
  6317. + *
  6318. + * Copyright (C) 2001 Altera Corporation
  6319. + *
  6320. + * This program is free software; you can redistribute it and/or modify
  6321. + * it under the terms of the GNU General Public License as published by
  6322. + * the Free Software Foundation; either version 2 of the License, or
  6323. + * (at your option) any later version.
  6324. + *
  6325. + * This program is distributed in the hope that it will be useful,
  6326. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6327. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6328. + * GNU General Public License for more details.
  6329. + *
  6330. + * You should have received a copy of the GNU General Public License
  6331. + * along with this program; if not, write to the Free Software
  6332. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  6333. + */
  6334. +
  6335. +#ifndef __INT_CTRL_H
  6336. +#define __INT_CTRL_H
  6337. +
  6338. +#define PCI_IRQ_OFFSET 64 /* PCI start IRQ number */
  6339. +#define FIQ_OFFSET 32
  6340. +
  6341. +#define IRQ_SOURCE(base_addr) (INT_CTRL_TYPE(base_addr + 0x00))
  6342. +#define IRQ_MASK(base_addr) (INT_CTRL_TYPE (base_addr + 0x04 ))
  6343. +#define IRQ_CLEAR(base_addr) (INT_CTRL_TYPE (base_addr + 0x08 ))
  6344. +#define IRQ_TMODE(base_addr) (INT_CTRL_TYPE (base_addr + 0x0C ))
  6345. +#define IRQ_TLEVEL(base_addr) (INT_CTRL_TYPE (base_addr + 0x10 ))
  6346. +#define IRQ_STATUS(base_addr) (INT_CTRL_TYPE (base_addr + 0x14 ))
  6347. +#define FIQ_SOURCE(base_addr) (INT_CTRL_TYPE (base_addr + 0x20 ))
  6348. +#define FIQ_MASK(base_addr) (INT_CTRL_TYPE (base_addr + 0x24 ))
  6349. +#define FIQ_CLEAR(base_addr) (INT_CTRL_TYPE (base_addr + 0x28 ))
  6350. +#define FIQ_TMODE(base_addr) (INT_CTRL_TYPE (base_addr + 0x2C ))
  6351. +#define FIQ_LEVEL(base_addr) (INT_CTRL_TYPE (base_addr + 0x30 ))
  6352. +#define FIQ_STATUS(base_addr) (INT_CTRL_TYPE (base_addr + 0x34 ))
  6353. +
  6354. +#ifdef CONFIG_SL3516_ASIC
  6355. +#define IRQ_SERIRQ0_OFFSET 30
  6356. +#define IRQ_PCID_OFFSET 29
  6357. +#define IRQ_PCIC_OFFSET 28
  6358. +#define IRQ_PCIB_OFFSET 27
  6359. +#define IRQ_PWR_OFFSET 26
  6360. +#define IRQ_CIR_OFFSET 25
  6361. +#define IRQ_GPIO2_OFFSET 24
  6362. +#define IRQ_GPIO1_OFFSET 23
  6363. +#define IRQ_GPIO_OFFSET 22
  6364. +#define IRQ_SSP_OFFSET 21
  6365. +#define IRQ_LPC_OFFSET 20
  6366. +#define IRQ_LCD_OFFSET 19
  6367. +#define IRQ_UART_OFFSET 18
  6368. +#define IRQ_RTC_OFFSET 17
  6369. +#define IRQ_TIMER3_OFFSET 16
  6370. +#define IRQ_TIMER2_OFFSET 15
  6371. +#define IRQ_TIMER1_OFFSET 14
  6372. +#define IRQ_FLASH_OFFSET 12
  6373. +#define IRQ_USB1_OFFSET 11
  6374. +#define IRQ_USB0_OFFSET 10
  6375. +#define IRQ_DMA_OFFSET 9
  6376. +#define IRQ_PCI_OFFSET 8
  6377. +#define IRQ_IPSEC_OFFSET 7
  6378. +#define IRQ_RAID_OFFSET 6
  6379. +#define IRQ_IDE1_OFFSET 5
  6380. +#define IRQ_IDE0_OFFSET 4
  6381. +#define IRQ_WATCHDOG_OFFSET 3
  6382. +#define IRQ_GMAC1_OFFSET 2
  6383. +#define IRQ_GMAC0_OFFSET 1
  6384. +#define IRQ_CPU0_IP_IRQ_OFFSET 0
  6385. +
  6386. +#define IRQ_SERIRQ0_MASK (1<<30)
  6387. +#define IRQ_PCID_MASK (1<<29)
  6388. +#define IRQ_PCIC_MASK (1<<28)
  6389. +#define IRQ_PCIB_MASK (1<<27)
  6390. +#define IRQ_PWR_MASK (1<<26)
  6391. +#define IRQ_CIR_MASK (1<<25)
  6392. +#define IRQ_GPIO2_MASK (1<<24)
  6393. +#define IRQ_GPIO1_MASK (1<<23)
  6394. +#define IRQ_GPIO_MASK (1<<22)
  6395. +#define IRQ_SSP_MASK (1<<21)
  6396. +#define IRQ_LPC_MASK (1<<20)
  6397. +#define IRQ_LCD_MASK (1<<19)
  6398. +#define IRQ_UART_MASK (1<<18)
  6399. +#define IRQ_RTC_MASK (1<<17)
  6400. +#define IRQ_TIMER3_MASK (1<<16)
  6401. +#define IRQ_TIMER2_MASK (1<<15)
  6402. +#define IRQ_TIMER1_MASK (1<<14)
  6403. +#define IRQ_FLASH_MASK (1<<12)
  6404. +#define IRQ_USB1_MASK (1<<11)
  6405. +#define IRQ_USB0_MASK (1<<10)
  6406. +#define IRQ_DMA_MASK (1<< 9)
  6407. +#define IRQ_PCI_MASK (1<< 8)
  6408. +#define IRQ_IPSEC_MASK (1<< 7)
  6409. +#define IRQ_RAID_MASK (1<< 6)
  6410. +#define IRQ_IDE1_MASK (1<< 5)
  6411. +#define IRQ_IDE0_MASK (1<< 4)
  6412. +#define IRQ_WATCHDOG_MASK (1<< 3)
  6413. +#define IRQ_GMAC1_MASK (1<< 2)
  6414. +#define IRQ_GMAC0_MASK (1<< 1)
  6415. +#define IRQ_CPU0_IP_IRQ_MASK (1<< 0)
  6416. +#else
  6417. +#define IRQ_SERIRQ0_OFFSET 30
  6418. +#define IRQ_PCID_OFFSET 29
  6419. +#define IRQ_PCIC_OFFSET 28
  6420. +#define IRQ_PCIB_OFFSET 27
  6421. +#define IRQ_PWR_OFFSET 26
  6422. +#define IRQ_CIR_OFFSET 25
  6423. +#define IRQ_GPIO2_OFFSET 24
  6424. +#define IRQ_GPIO1_OFFSET 23
  6425. +#define IRQ_GPIO_OFFSET 22
  6426. +#define IRQ_SSP_OFFSET 21
  6427. +#define IRQ_LPC_OFFSET 20
  6428. +#define IRQ_LCD_OFFSET 19
  6429. +#define IRQ_UART_OFFSET 18
  6430. +#define IRQ_RTC_OFFSET 17
  6431. +#define IRQ_TIMER3_OFFSET 16
  6432. +#define IRQ_TIMER2_OFFSET 15
  6433. +#define IRQ_TIMER1_OFFSET 14
  6434. +#define IRQ_FLASH_OFFSET 12
  6435. +#define IRQ_USB1_OFFSET 11
  6436. +#define IRQ_USB0_OFFSET 10
  6437. +#define IRQ_DMA_OFFSET 9
  6438. +#define IRQ_PCI_OFFSET 8
  6439. +#define IRQ_IPSEC_OFFSET 7
  6440. +#define IRQ_RAID_OFFSET 6
  6441. +#define IRQ_IDE1_OFFSET 5
  6442. +#define IRQ_IDE0_OFFSET 4
  6443. +#define IRQ_WATCHDOG_OFFSET 3
  6444. +#define IRQ_GMAC1_OFFSET 2
  6445. +#define IRQ_GMAC0_OFFSET 1
  6446. +#define IRQ_CPU0_IP_IRQ_OFFSET 0
  6447. +
  6448. +#define IRQ_SERIRQ0_MASK (1<<30)
  6449. +#define IRQ_PCID_MASK (1<<29)
  6450. +#define IRQ_PCIC_MASK (1<<28)
  6451. +#define IRQ_PCIB_MASK (1<<27)
  6452. +#define IRQ_PWR_MASK (1<<26)
  6453. +#define IRQ_CIR_MASK (1<<25)
  6454. +#define IRQ_GPIO2_MASK (1<<24)
  6455. +#define IRQ_GPIO1_MASK (1<<23)
  6456. +#define IRQ_GPIO_MASK (1<<22)
  6457. +#define IRQ_SSP_MASK (1<<21)
  6458. +#define IRQ_LPC_MASK (1<<20)
  6459. +#define IRQ_LCD_MASK (1<<19)
  6460. +#define IRQ_UART_MASK (1<<18)
  6461. +#define IRQ_RTC_MASK (1<<17)
  6462. +#define IRQ_TIMER3_MASK (1<<16)
  6463. +#define IRQ_TIMER2_MASK (1<<15)
  6464. +#define IRQ_TIMER1_MASK (1<<14)
  6465. +#define IRQ_FLASH_MASK (1<<12)
  6466. +#define IRQ_USB1_MASK (1<<11)
  6467. +#define IRQ_USB0_MASK (1<<10)
  6468. +#define IRQ_DMA_MASK (1<< 9)
  6469. +#define IRQ_PCI_MASK (1<< 8)
  6470. +#define IRQ_IPSEC_MASK (1<< 7)
  6471. +#define IRQ_RAID_MASK (1<< 6)
  6472. +#define IRQ_IDE1_MASK (1<< 5)
  6473. +#define IRQ_IDE0_MASK (1<< 4)
  6474. +#define IRQ_WATCHDOG_MASK (1<< 3)
  6475. +#define IRQ_GMAC1_MASK (1<< 2)
  6476. +#define IRQ_GMAC0_MASK (1<< 1)
  6477. +#define IRQ_CPU0_IP_IRQ_MASK (1<< 0)
  6478. +#endif
  6479. +
  6480. +
  6481. +#endif /* __INT_CTRL_H */
  6482. +
  6483. +
  6484. --- /dev/null
  6485. +++ b/include/asm-arm/arch-sl2312/io.h
  6486. @@ -0,0 +1,50 @@
  6487. +/*
  6488. + * linux/include/asm-arm/arch-epxa10db/io.h
  6489. + *
  6490. + * Copyright (C) 1999 ARM Limited
  6491. + *
  6492. + * This program is free software; you can redistribute it and/or modify
  6493. + * it under the terms of the GNU General Public License as published by
  6494. + * the Free Software Foundation; either version 2 of the License, or
  6495. + * (at your option) any later version.
  6496. + *
  6497. + * This program is distributed in the hope that it will be useful,
  6498. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6499. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6500. + * GNU General Public License for more details.
  6501. + *
  6502. + * You should have received a copy of the GNU General Public License
  6503. + * along with this program; if not, write to the Free Software
  6504. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  6505. + */
  6506. +#ifndef __ASM_ARM_ARCH_IO_H
  6507. +#define __ASM_ARM_ARCH_IO_H
  6508. +
  6509. +#define IO_SPACE_LIMIT 0xffffffff
  6510. +
  6511. +
  6512. +/*
  6513. + * Generic virtual read/write
  6514. + */
  6515. +/*
  6516. +#define __arch_getw(a) (*(volatile unsigned short *)(a))
  6517. +#define __arch_putw(v,a) (*(volatile unsigned short *)(a) = (v))
  6518. +*/
  6519. +/*#define outsw __arch_writesw
  6520. +#define outsl __arch_writesl
  6521. +#define outsb __arch_writesb
  6522. +#define insb __arch_readsb
  6523. +#define insw __arch_readsw
  6524. +#define insl __arch_readsl*/
  6525. +
  6526. +#define __io(a) (a)
  6527. +#define __mem_pci(a) (a)
  6528. +/*
  6529. +#define __arch_getw(a) (*(volatile unsigned short *)(a))
  6530. +#define __arch_putw(v,a) (*(volatile unsigned short *)(a) = (v))
  6531. +*/
  6532. +#define iomem_valid_addr(off,size) (1)
  6533. +#define iomem_to_phys(off) (off)
  6534. +
  6535. +
  6536. +#endif
  6537. --- /dev/null
  6538. +++ b/include/asm-arm/arch-sl2312/ipi.h
  6539. @@ -0,0 +1,189 @@
  6540. +/*
  6541. + * linux/include/asm-arm/arch-sl2312/system.h
  6542. + *
  6543. + * Copyright (C) 1999 ARM Limited
  6544. + * Copyright (C) 2000 Deep Blue Solutions Ltd
  6545. + * Copyright (C) 2001 Altera Corporation
  6546. + *
  6547. + * This program is free software; you can redistribute it and/or modify
  6548. + * it under the terms of the GNU General Public License as published by
  6549. + * the Free Software Foundation; either version 2 of the License, or
  6550. + * (at your option) any later version.
  6551. + *
  6552. + * This program is distributed in the hope that it will be useful,
  6553. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6554. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6555. + * GNU General Public License for more details.
  6556. + *
  6557. + * You should have received a copy of the GNU General Public License
  6558. + * along with this program; if not, write to the Free Software
  6559. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  6560. + */
  6561. +#ifndef __ASM_ARCH_IPI_H
  6562. +#define __ASM_ARCH_IPI_H
  6563. +#include <asm/io.h>
  6564. +
  6565. +//#define spin_lock(x) spin_lock_dt(x)
  6566. +//#define spin_unlock(x) spin_unlock_dt(x)
  6567. +
  6568. +#define SWAP_OFFSET 0x400000
  6569. +#define SWAP_SIZE 0x400000
  6570. +
  6571. +#define SHARE_MEM_ADDR 0x2000000
  6572. +#define SHARE_MEM_SIZE 1024*1024
  6573. +
  6574. +
  6575. +//--> Add by jason for IPI testing
  6576. +// memory layout for maste & slave bin
  6577. +#define MASTERTEXT 0x8000
  6578. +#define SLAVETEXT 0x108000
  6579. +#define SHARESIZE 0x4000
  6580. +#define SHAREADDR SHARE_MEM_ADDR // starting 8M
  6581. +
  6582. +// CPU1 reset release
  6583. +#define GLOBAL_BASE IO_ADDRESS(0x40000000)
  6584. +#define GLOBAL_SOFTRESET (GLOBAL_BASE + 0x0C)
  6585. +#define CPU1_RESET_BIT_MASK 0x40000000
  6586. +
  6587. +// IPI , need to redefine the folliwing, bug
  6588. +#define CPU0_STATUS (GLOBAL_BASE + 0x0038)
  6589. +#define CPU1_STATUS (GLOBAL_BASE + 0x003C)
  6590. +#define CPU_IPI_BIT_MASK 0x80000000
  6591. +
  6592. +/* Your basic SMP spinlocks, allowing only a single CPU anywhere
  6593. +*/
  6594. +typedef struct {
  6595. + volatile unsigned int lock;
  6596. +} spinlock_dt;
  6597. +
  6598. +
  6599. +#define MASTER_BIT 0x01
  6600. +#define SLAVE_BIT 0x02
  6601. +#define HEART_BIT 0x04
  6602. +#define IPI0_IRQ_BIT 0x08
  6603. +#define IPI0_FIQ_BIT 0x10
  6604. +#define IPI1_IRQ_BIT 0x20
  6605. +#define IPI1_FIQ_BIT 0x40
  6606. +
  6607. +#define IRQ 0
  6608. +#define FIQ 1
  6609. +#define DONE 0xff
  6610. +
  6611. +#define CPU0 0x0
  6612. +#define CPU1 0x1
  6613. +
  6614. +#define MAXCHAR 128*1024
  6615. +typedef struct {
  6616. + int flag;
  6617. + int uart_flag;
  6618. + int cnt;
  6619. + spinlock_dt lk;
  6620. + char message[MAXCHAR];
  6621. +}s_mailbox;
  6622. +
  6623. +// JScale proj definition
  6624. +typedef struct {
  6625. + u16 type; // message Type
  6626. + u16 length; // message length, including message header
  6627. +} IPC_MSG_HDR_T;
  6628. +
  6629. +typedef struct{
  6630. + IPC_MSG_HDR_T hdr;
  6631. + u32 input_location;
  6632. + u32 input_size;
  6633. + u32 output_location;
  6634. + u16 ScaledImageWidth;
  6635. + u16 ScaledImageHeight;
  6636. + u8 ScaledImageQuality;
  6637. + u8 MaintainResultionRatio;
  6638. + u8 TwoStepScaling;
  6639. + u8 InputFormat;
  6640. + u8 verbose;
  6641. + u8 reserved[3];
  6642. +} JSCALE_REQ_T;
  6643. +
  6644. +typedef struct{
  6645. + IPC_MSG_HDR_T hdr;
  6646. + u32 status;
  6647. + u32 code;
  6648. + u32 output_size;
  6649. +} JSCALE_RSP_T;
  6650. +
  6651. +#define IPC_JSCALE_REQ_MSG 0 // JScale request from CPU-0 to CPU-1
  6652. +#define IPC_JSCALE_RSP_MSG 1 // JScale response from CPU-1 to CPU-0
  6653. +
  6654. +enum {
  6655. + JSCALE_STATUS_OK = 0,
  6656. + JSCALE_UNKNOWN_MSG_TYPE,
  6657. + JSCALE_FAILED_FILE_SIZE,
  6658. + JSCALE_FAILED_MALLOC,
  6659. + JSCALE_FAILED_FORMAT,
  6660. + JSCALE_DECODE_ERROR,
  6661. + JSCALE_BUSY,
  6662. +};
  6663. +// <-- JScale
  6664. +
  6665. +#define GEMINI_IPI_IOCTL_BASE 'Z'
  6666. +#define GEMINI_IPI_JSCALE_REQ _IOW (GEMINI_IPI_IOCTL_BASE,0,JSCALE_REQ_T)
  6667. +#define GEMINI_IPI_JSCALE_STAT _IOR (GEMINI_IPI_IOCTL_BASE,1,JSCALE_RSP_T)
  6668. +
  6669. +
  6670. +/*
  6671. +* Simple spin lock operations.
  6672. +*
  6673. +*/
  6674. +
  6675. +#define spin_is_locked_dt(x)((x)->lock != 0)
  6676. +
  6677. +static inline int test_and_set_dt(spinlock_dt *lock)
  6678. +{
  6679. +unsigned long tmp;
  6680. +__asm__ __volatile__(
  6681. +"swp %0, %2, [%1]\n"
  6682. +: "=&r" (tmp)
  6683. +: "r" (&lock->lock), "r" (1)
  6684. +: "cc", "memory");
  6685. +
  6686. +return tmp;
  6687. +}
  6688. +
  6689. +static inline void spin_lock_dt(spinlock_dt *lock)
  6690. +{
  6691. +
  6692. +unsigned long tmp;
  6693. +__asm__ __volatile__(
  6694. +"1: ldr %0, [%1]\n"
  6695. +"teq %0, #0\n"
  6696. +"swpeq %0, %2, [%1]\n"
  6697. +" teqeq %0, #0\n"
  6698. +" bne 1b"
  6699. + : "=&r" (tmp)
  6700. + : "r" (&lock->lock), "r" (1)
  6701. + : "cc", "memory");
  6702. +}
  6703. +
  6704. +static inline void spin_unlock_dt(spinlock_dt *lock)
  6705. +{
  6706. + __asm__ __volatile__(
  6707. +" str %1, [%0]"
  6708. + :
  6709. + : "r" (&lock->lock), "r" (0)
  6710. + : "cc", "memory");
  6711. +}
  6712. +
  6713. +static inline int getcpuid(void)
  6714. +{
  6715. + int cpuid;
  6716. +
  6717. + __asm__(
  6718. +"mrc p8, 0, r0, c0, c0, 0\n"
  6719. +"mov %0, r0"
  6720. + :"=r"(cpuid)
  6721. + :
  6722. + :"r0");
  6723. + return (cpuid & 0x07);
  6724. +}
  6725. +
  6726. +
  6727. +
  6728. +#endif
  6729. --- /dev/null
  6730. +++ b/include/asm-arm/arch-sl2312/irq.h
  6731. @@ -0,0 +1,23 @@
  6732. +/*
  6733. + * linux/include/asm-arm/arch-sl2312/irq.h
  6734. + *
  6735. + * Copyright (C) 1999 ARM Limited
  6736. + *
  6737. + * This program is free software; you can redistribute it and/or modify
  6738. + * it under the terms of the GNU General Public License as published by
  6739. + * the Free Software Foundation; either version 2 of the License, or
  6740. + * (at your option) any later version.
  6741. + *
  6742. + * This program is distributed in the hope that it will be useful,
  6743. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6744. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6745. + * GNU General Public License for more details.
  6746. + *
  6747. + * You should have received a copy of the GNU General Public License
  6748. + * along with this program; if not, write to the Free Software
  6749. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  6750. + */
  6751. +
  6752. + // Since we have PCI interrupt which the interrupt line is pseudo
  6753. + // we need do some fixup
  6754. +int fixup_irq(int irq);
  6755. --- /dev/null
  6756. +++ b/include/asm-arm/arch-sl2312/irqs.h
  6757. @@ -0,0 +1,102 @@
  6758. +/*
  6759. + * linux/include/asm-arm/arch-camelot/irqs.h
  6760. + *
  6761. + * Copyright (C) 2001 Altera Corporation
  6762. + *
  6763. + * This program is free software; you can redistribute it and/or modify
  6764. + * it under the terms of the GNU General Public License as published by
  6765. + * the Free Software Foundation; either version 2 of the License, or
  6766. + * (at your option) any later version.
  6767. + *
  6768. + * This program is distributed in the hope that it will be useful,
  6769. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6770. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6771. + * GNU General Public License for more details.
  6772. + *
  6773. + * You should have received a copy of the GNU General Public License
  6774. + * along with this program; if not, write to the Free Software
  6775. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  6776. + */
  6777. +
  6778. +/* Use the Excalibur chip definitions */
  6779. +#define INT_CTRL_TYPE
  6780. +#include "asm/arch/int_ctrl.h"
  6781. +
  6782. +#ifdef CONFIG_SL3516_ASIC
  6783. +#define IRQ_SERIRQ_MAX 31
  6784. +#define IRQ_SERIRQ1 31
  6785. +#define IRQ_SERIRQ0 30
  6786. +#define IRQ_PCID 29
  6787. +#define IRQ_PCIC 28
  6788. +#define IRQ_PCIB 27
  6789. +#define IRQ_PWR 26
  6790. +#define IRQ_CIR 25
  6791. +#define IRQ_GPIO2 24
  6792. +#define IRQ_GPIO1 23
  6793. +#define IRQ_GPIO 22
  6794. +#define IRQ_SSP 21
  6795. +#define IRQ_LPC 20
  6796. +#define IRQ_LCD 19
  6797. +#define IRQ_UART 18
  6798. +#define IRQ_RTC 17
  6799. +#define IRQ_TIMER3 16
  6800. +#define IRQ_TIMER2 15
  6801. +#define IRQ_TIMER1 14
  6802. +#define IRQ_FLASH 12
  6803. +#define IRQ_USB1 11
  6804. +#define IRQ_USB0 10
  6805. +#define IRQ_DMA 9
  6806. +#define IRQ_PCI 8
  6807. +#define IRQ_IPSEC 7
  6808. +#define IRQ_RAID 6
  6809. +#define IRQ_IDE1 5
  6810. +#define IRQ_IDE0 4
  6811. +#define IRQ_WATCHDOG 3
  6812. +#define IRQ_GMAC1 2
  6813. +#define IRQ_GMAC0 1
  6814. +#define IRQ_CPU0_IP_IRQ 0
  6815. +#else
  6816. +#define IRQ_SERIRQ_MAX 31
  6817. +#define IRQ_SERIRQ1 31
  6818. +#define IRQ_SERIRQ0 30
  6819. +#define IRQ_PCID 29
  6820. +#define IRQ_PCIC 28
  6821. +#define IRQ_PCIB 27
  6822. +#define IRQ_PWR 26
  6823. +#define IRQ_CIR 25
  6824. +#define IRQ_GPIO2 24
  6825. +#define IRQ_GPIO1 23
  6826. +#define IRQ_GPIO 22
  6827. +#define IRQ_SSP 21
  6828. +#define IRQ_LPC 20
  6829. +#define IRQ_LCD 19
  6830. +#define IRQ_UART 18
  6831. +#define IRQ_RTC 17
  6832. +#define IRQ_TIMER3 16
  6833. +#define IRQ_TIMER2 15
  6834. +#define IRQ_TIMER1 14
  6835. +#define IRQ_FLASH 12
  6836. +#define IRQ_USB1 11
  6837. +#define IRQ_USB0 10
  6838. +#define IRQ_DMA 9
  6839. +#define IRQ_PCI 8
  6840. +#define IRQ_IPSEC 7
  6841. +#define IRQ_RAID 6
  6842. +#define IRQ_IDE1 5
  6843. +#define IRQ_IDE0 4
  6844. +#define IRQ_WATCHDOG 3
  6845. +#define IRQ_GMAC1 2
  6846. +#define IRQ_GMAC0 1
  6847. +#endif
  6848. +
  6849. +#define ARCH_TIMER_IRQ IRQ_TIMER2 /* for MV 4.0 */
  6850. +
  6851. +#define IRQ_PCI_INTA PCI_IRQ_OFFSET + 0
  6852. +#define IRQ_PCI_INTB PCI_IRQ_OFFSET + 1
  6853. +#define IRQ_PCI_INTC PCI_IRQ_OFFSET + 2
  6854. +#define IRQ_PCI_INTD PCI_IRQ_OFFSET + 3
  6855. +
  6856. +#define NR_IRQS (IRQ_PCI_INTD + 4)
  6857. +
  6858. +
  6859. +
  6860. --- /dev/null
  6861. +++ b/include/asm-arm/arch-sl2312/it8712.h
  6862. @@ -0,0 +1,24 @@
  6863. +
  6864. +#ifndef __IT8712_H__
  6865. +#define __IT8712_H__
  6866. +
  6867. +#include "asm/arch/sl2312.h"
  6868. +
  6869. +#define IT8712_IO_BASE SL2312_LPC_IO_BASE
  6870. +// Device LDN
  6871. +#define LDN_SERIAL1 0x01
  6872. +#define LDN_SERIAL2 0x02
  6873. +#define LDN_PARALLEL 0x03
  6874. +#define LDN_KEYBOARD 0x05
  6875. +#define LDN_MOUSE 0x06
  6876. +#define LDN_GPIO 0x07
  6877. +
  6878. +#define IT8712_UART1_PORT 0x3F8
  6879. +#define IT8712_UART2_PORT 0x2F8
  6880. +
  6881. +#define IT8712_GPIO_BASE 0x800 // 0x800-0x804 for GPIO set1-set5
  6882. +
  6883. +void LPCSetConfig(char LdnNumber, char Index, char data);
  6884. +char LPCGetConfig(char LdnNumber, char Index);
  6885. +
  6886. +#endif
  6887. --- /dev/null
  6888. +++ b/include/asm-arm/arch-sl2312/memory.h
  6889. @@ -0,0 +1,38 @@
  6890. +/*
  6891. + * linux/include/asm-arm/arch-sl2312/memory.h
  6892. + *
  6893. + * Copyright (C) 2001 Altera Corporation
  6894. + *
  6895. + * This program is free software; you can redistribute it and/or modify
  6896. + * it under the terms of the GNU General Public License as published by
  6897. + * the Free Software Foundation; either version 2 of the License, or
  6898. + * (at your option) any later version.
  6899. + *
  6900. + * This program is distributed in the hope that it will be useful,
  6901. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6902. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6903. + * GNU General Public License for more details.
  6904. + *
  6905. + * You should have received a copy of the GNU General Public License
  6906. + * along with this program; if not, write to the Free Software
  6907. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  6908. + */
  6909. +#ifndef __ASM_ARCH_MMU_H
  6910. +#define __ASM_ARCH_MMU_H
  6911. +
  6912. +/*
  6913. + * Physical DRAM offset.
  6914. + */
  6915. +#define PHYS_OFFSET UL(0x00000000)
  6916. +
  6917. +/*
  6918. + * Virtual view <-> DMA view memory address translations
  6919. + * virt_to_bus: Used to translate the virtual address to an
  6920. + * address suitable to be passed to set_dma_addr
  6921. + * bus_to_virt: Used to convert an address for DMA operations
  6922. + * to an address that the kernel can use.
  6923. + */
  6924. +#define __virt_to_bus(x) (x - PAGE_OFFSET + /*SDRAM_BASE*/0)
  6925. +#define __bus_to_virt(x) (x - /*SDRAM_BASE*/0 + PAGE_OFFSET)
  6926. +
  6927. +#endif
  6928. --- /dev/null
  6929. +++ b/include/asm-arm/arch-sl2312/param.h
  6930. @@ -0,0 +1,20 @@
  6931. +/*
  6932. + * linux/include/asm-arm/arch-epxa10db/param.h
  6933. + *
  6934. + * Copyright (C) 1999 ARM Limited
  6935. + *
  6936. + * This program is free software; you can redistribute it and/or modify
  6937. + * it under the terms of the GNU General Public License as published by
  6938. + * the Free Software Foundation; either version 2 of the License, or
  6939. + * (at your option) any later version.
  6940. + *
  6941. + * This program is distributed in the hope that it will be useful,
  6942. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6943. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6944. + * GNU General Public License for more details.
  6945. + *
  6946. + * You should have received a copy of the GNU General Public License
  6947. + * along with this program; if not, write to the Free Software
  6948. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  6949. + */
  6950. +
  6951. --- /dev/null
  6952. +++ b/include/asm-arm/arch-sl2312/pci.h
  6953. @@ -0,0 +1,18 @@
  6954. +
  6955. +#ifndef __SL2312_PCI_H__
  6956. +#define __SL2312_PCI_H__
  6957. +
  6958. +#define SL2312_PCI_PMC 0x40
  6959. +#define SL2312_PCI_PMCSR 0x44
  6960. +#define SL2312_PCI_CTRL1 0x48
  6961. +#define SL2312_PCI_CTRL2 0x4c
  6962. +#define SL2312_PCI_MEM1_BASE_SIZE 0x50
  6963. +#define SL2312_PCI_MEM2_BASE_SIZE 0x54
  6964. +#define SL2312_PCI_MEM3_BASE_SIZE 0x58
  6965. +
  6966. +
  6967. +void sl2312_pci_mask_irq(unsigned int irq);
  6968. +void sl2312_pci_unmask_irq(unsigned int irq);
  6969. +int sl2312_pci_get_int_src(void);
  6970. +
  6971. +#endif
  6972. --- /dev/null
  6973. +++ b/include/asm-arm/arch-sl2312/platform.h
  6974. @@ -0,0 +1,7 @@
  6975. +#ifndef PLATFORM_H
  6976. +#define PLATFORM_H
  6977. +#include "sl2312.h"
  6978. +
  6979. +#define MAXIRQNUM 68
  6980. +#endif
  6981. +
  6982. --- /dev/null
  6983. +++ b/include/asm-arm/arch-sl2312/preempt.h
  6984. @@ -0,0 +1,63 @@
  6985. +/*
  6986. + * include/asm-arm/arch-sl2312/preempt.h
  6987. + *
  6988. + * Timing support for preempt-stats, kfi, ilatency patches
  6989. + *
  6990. + * Author: dsingleton <[email protected]>
  6991. + *
  6992. + * 2001-2004 (c) MontaVista Software, Inc. This file is licensed under
  6993. + * the terms of the GNU General Public License version 2. This program
  6994. + * is licensed "as is" without any warranty of any kind, whether express
  6995. + * or implied.
  6996. + */
  6997. +
  6998. +#ifndef _ASM_ARCH_PREEMT_H
  6999. +#define _ASM_ARCH_PREEMT_H
  7000. +
  7001. +#include <asm/arch/hardware.h>
  7002. +#include <asm/arch/sl2312.h>
  7003. +
  7004. +static inline unsigned long clock_diff(unsigned long start, unsigned long stop)
  7005. +{
  7006. + return (start - stop);
  7007. +}
  7008. +
  7009. +static inline unsigned int readclock(void)
  7010. +{
  7011. + unsigned int x;
  7012. +
  7013. + x = readl(IO_ADDRESS(SL2312_TIMER2_BASE));
  7014. + return x;
  7015. +}
  7016. +
  7017. +static inline unsigned __ticks_per_usec(void)
  7018. +{
  7019. +#ifdef CONFIG_SL3516_ASIC
  7020. + unsigned int ahb_clock_rate_base=130; /* unit = MHz*/
  7021. + unsigned int reg_v=0;
  7022. + unsigned int ticks_usec;
  7023. +
  7024. + reg_v = readl(IO_ADDRESS((SL2312_GLOBAL_BASE+4)));
  7025. + reg_v >>=15;
  7026. + ticks_usec = (ahb_clock_rate_base + (reg_v & 0x07)*10)>>2;
  7027. +
  7028. +#else
  7029. + unsigned int ticks_usec=20;
  7030. +#endif
  7031. +
  7032. + return ticks_usec;
  7033. +}
  7034. +
  7035. +/*
  7036. + * timer 1 runs @ 6Mhz 6 ticks = 1 microsecond
  7037. + * and is configed as a count down timer.
  7038. + */
  7039. +#define TICKS_PER_USEC __ticks_per_usec()
  7040. +#define ARCH_PREDEFINES_TICKS_PER_USEC
  7041. +
  7042. +#define clock_to_usecs(x) ((x) / TICKS_PER_USEC)
  7043. +
  7044. +#define INTERRUPTS_ENABLED(x) (!(x & PSR_I_BIT))
  7045. +
  7046. +#endif
  7047. +
  7048. --- /dev/null
  7049. +++ b/include/asm-arm/arch-sl2312/sl2312.h
  7050. @@ -0,0 +1,254 @@
  7051. +#ifndef __sl2312_h
  7052. +#define __sl2312_h
  7053. +
  7054. +/****************************************************************************
  7055. + * Copyright Storlink Corp 2002-2003. All rights reserved. *
  7056. + *--------------------------------------------------------------------------*
  7057. + * Name:board.s *
  7058. + * Description: SL231x specfic define *
  7059. + * Author: Plus Chen *
  7060. + * Version: 0.9 Create
  7061. + ****************************************************************************/
  7062. +
  7063. +/*
  7064. + CPE address map;
  7065. +
  7066. + +====================================================
  7067. + 0x00000000 | FLASH
  7068. + 0x0FFFFFFF |
  7069. + |====================================================
  7070. + 0x10000000 | SDRAM
  7071. + 0x1FFFFFFF |
  7072. + |====================================================
  7073. + 0x20000000 | Global Registers 0x20000000-0x20FFFFFF
  7074. + | EMAC and DMA 0x21000000-0x21FFFFFF
  7075. + | UART Module 0x22000000-0x22FFFFFF
  7076. + | Timer Module 0x23000000-0x23FFFFFF
  7077. + | Interrupt Module 0x24000000-0x24FFFFFF
  7078. + | RTC Module 0x25000000-0x25FFFFFF
  7079. + | LPC Host Controller 0x26000000-0x26FFFFFF
  7080. + | LPC Peripherial IO 0x27000000-0x27FFFFFF
  7081. + | WatchDog Timer 0x28000000-0x28FFFFFF
  7082. + 0x2FFFFFFF | Reserved 0x29000000-0x29FFFFFF
  7083. + |=====================================================
  7084. + 0x30000000 | PCI IO, Configuration Registers
  7085. + 0x3FFFFFFF |
  7086. + |=====================================================
  7087. + 0x40000000 | PCI Memory
  7088. + 0x4FFFFFFF |
  7089. + |=====================================================
  7090. + 0x50000000 | Ethernet MAC and DMA 0x50000000-0x50FFFFFF
  7091. + | Security and DMA 0x51000000-0x51FFFFFF
  7092. + | IDE Channel 0 Register 0x52000000-0x527FFFFF
  7093. + | IDE Channel 1 Register 0x52800000-0x52FFFFFF
  7094. + | USB Register 0x53000000-0x53FFFFFF
  7095. + | Flash Controller 0x54000000-0x54FFFFFF
  7096. + | DRAM Controller 0x55000000-0x55FFFFFF
  7097. + 0x5FFFFFFF | Reserved 0x56000000-0x5FFFFFFF
  7098. + |=====================================================
  7099. + 0x60000000 | Reserved
  7100. + 0x6FFFFFFF |
  7101. + |=====================================================
  7102. + 0x70000000 | FLASH shadow Memory
  7103. + 0x7FFFFFFF |
  7104. + |=====================================================
  7105. + 0x80000000 | Big Endian of memory 0x00000000-0x7FFFFFFF
  7106. + 0xFFFFFFFF |
  7107. + +=====================================================
  7108. +*/
  7109. +
  7110. +
  7111. +
  7112. +/*-------------------------------------------------------------------------------
  7113. + Memory Map definitions
  7114. +-------------------------------------------------------------------------------- */
  7115. +#define TEST 1
  7116. +#if 0
  7117. +
  7118. +static inline int GETCPUID()
  7119. +{
  7120. + int cpuid;
  7121. + __asm__(
  7122. +"mrc p8, 0, r0, c0, c0, 0\n"
  7123. +"mov %0, r0"
  7124. + :"=r"(cpuid)
  7125. + :
  7126. + :"r0");
  7127. + return (cpuid & 0x07);
  7128. +}
  7129. +#endif
  7130. +#define SL2312_SRAM_BASE 0x70000000 // SRAM base after remap
  7131. +#define SL2312_DRAM_BASE 0x00000000 // DRAM base after remap
  7132. +#define SL2312_RAM_BASE 0x10000000 // RAM code base before remap
  7133. +#define SL2312_FLASH_BASE 0x30000000
  7134. +#define SL2312_ROM_BASE 0x30000000
  7135. +#define SL2312_GLOBAL_BASE 0x40000000
  7136. +#define SL2312_WAQTCHDOG_BASE 0x41000000
  7137. +#define SL2312_UART_BASE 0x42000000
  7138. +#define SL2312_TIMER_BASE 0x43000000
  7139. +#define SL2312_LCD_BASE 0x44000000
  7140. +#define SL2312_RTC_BASE 0x45000000
  7141. +#define SL2312_SATA_BASE 0x46000000
  7142. +#define SL2312_LPC_HOST_BASE 0x47000000
  7143. +#define SL2312_LPC_IO_BASE 0x47800000
  7144. +// #define SL2312_INTERRUPT_BASE 0x48000000
  7145. +#define SL2312_INTERRUPT0_BASE 0x48000000
  7146. +#define SL2312_INTERRUPT1_BASE 0x49000000
  7147. +//#define SL2312_INTERRUPT_BASE ((getcpuid()==0)?SL2312_INTERRUPT0_BASE:SL2312_INTERRUPT1_BASE)
  7148. +#define SL2312_INTERRUPT_BASE 0x48000000
  7149. +#define SL2312_SSP_CTRL_BASE 0x4A000000
  7150. +#define SL2312_POWER_CTRL_BASE 0x4B000000
  7151. +#define SL2312_CIR_BASE 0x4C000000
  7152. +#define SL2312_GPIO_BASE 0x4D000000
  7153. +#define SL2312_GPIO_BASE1 0x4E000000
  7154. +#define SL2312_GPIO_BASE2 0x4F000000
  7155. +#define SL2312_PCI_IO_BASE 0x50000000
  7156. +#define SL2312_PCI_MEM_BASE 0x58000000
  7157. +#ifdef CONFIG_NET_SL351X
  7158. +#define SL2312_TOE_BASE 0x60000000
  7159. +#define SL2312_GMAC0_BASE 0x6000A000
  7160. +#define SL2312_GMAC1_BASE 0x6000E000
  7161. +#else
  7162. +#define SL2312_GMAC0_BASE 0x60000000
  7163. +#define SL2312_GMAC1_BASE 0x61000000
  7164. +#endif
  7165. +#define SL2312_SECURITY_BASE 0x62000000
  7166. +#define SL2312_IDE0_BASE 0x63000000
  7167. +#define SL2312_IDE1_BASE 0x63400000
  7168. +#define SL2312_RAID_BASE 0x64000000
  7169. +#define SL2312_FLASH_CTRL_BASE 0x65000000
  7170. +#define SL2312_DRAM_CTRL_BASE 0x66000000
  7171. +#define SL2312_GENERAL_DMA_BASE 0x67000000
  7172. +#define SL2312_USB_BASE 0x68000000
  7173. +#define SL2312_USB0_BASE 0x68000000
  7174. +#define SL2312_USB1_BASE 0x69000000
  7175. +#define SL2312_FLASH_SHADOW 0x30000000
  7176. +#define SL2312_BIG_ENDIAN_BASE 0x80000000
  7177. +
  7178. +#ifdef CONFIG_GEMINI_IPI
  7179. +#define CPU_1_MEM_BASE 0x4000000 // 64 MB
  7180. +#define CPU_1_DATA_OFFSET 0x4000000-0x300000 // Offset 61 MB
  7181. +#endif
  7182. +
  7183. +#define SL2312_TIMER1_BASE SL2312_TIMER_BASE
  7184. +#define SL2312_TIMER2_BASE (SL2312_TIMER_BASE + 0x10)
  7185. +#define SL2312_TIMER3_BASE (SL2312_TIMER_BASE + 0x20)
  7186. +
  7187. +#define SL2312_PCI_DMA_MEM1_BASE 0x00000000
  7188. +#define SL2312_PCI_DMA_MEM2_BASE 0x00000000
  7189. +#define SL2312_PCI_DMA_MEM3_BASE 0x00000000
  7190. +#define SL2312_PCI_DMA_MEM1_SIZE 7
  7191. +#define SL2312_PCI_DMA_MEM2_SIZE 6
  7192. +#define SL2312_PCI_DMA_MEM3_SIZE 6
  7193. +
  7194. +/*-------------------------------------------------------------------------------
  7195. + Global Module
  7196. +---------------------------------------------------------------------------------*/
  7197. +#define GLOBAL_ID 0x00
  7198. +#define GLOBAL_CHIP_ID 0x002311
  7199. +#define GLOBAL_CHIP_REV 0xA0
  7200. +#define GLOBAL_STATUS 0x04
  7201. +#define GLOBAL_CONTROL 0x1C
  7202. +#define GLOBAL_REMAP_BIT 0x01
  7203. +#define GLOBAL_RESET_REG 0x0C
  7204. +#define GLOBAL_MISC_REG 0x30
  7205. +#define PFLASH_SHARE_BIT 0x02
  7206. +
  7207. +#define GLOBAL_RESET (1<<31)
  7208. +#define RESET_CPU1 (1<<30)
  7209. +#define RESET_SATA1 (1<<27)
  7210. +#define RESET_SATA0 (1<<26)
  7211. +#define RESET_CIR (1<<25)
  7212. +#define RESET_EXT_DEV (1<<24)
  7213. +#define RESET_WD (1<<23)
  7214. +#define RESET_GPIO2 (1<<22)
  7215. +#define RESET_GPIO1 (1<<21)
  7216. +#define RESET_GPIO0 (1<<20)
  7217. +#define RESET_SSP (1<<19)
  7218. +#define RESET_UART (1<<18)
  7219. +#define RESET_TIMER (1<<17)
  7220. +#define RESET_RTC (1<<16)
  7221. +#define RESET_INT0 (1<<15)
  7222. +#define RESET_INT1 (1<<14)
  7223. +#define RESET_LCD (1<<13)
  7224. +#define RESET_LPC (1<<12)
  7225. +#define RESET_APB (1<<11)
  7226. +#define RESET_DMA (1<<10)
  7227. +#define RESET_USB1 (1<<9 )
  7228. +#define RESET_USB0 (1<<8 )
  7229. +#define RESET_PCI (1<<7 )
  7230. +#define RESET_GMAC1 (1<<6 )
  7231. +#define RESET_GMAC0 (1<<5 )
  7232. +#define RESET_IPSEC (1<<4 )
  7233. +#define RESET_RAID (1<<3 )
  7234. +#define RESET_IDE (1<<2 )
  7235. +#define RESET_FLASH (1<<1 )
  7236. +#define RESET_DRAM (1<<0 )
  7237. +
  7238. +
  7239. +
  7240. +
  7241. +
  7242. +
  7243. +
  7244. +
  7245. +/*-------------------------------------------------------------------------------
  7246. + DRAM Module
  7247. +---------------------------------------------------------------------------------*/
  7248. +#define DRAM_SIZE_32M 0x2000000
  7249. +#define DRAM_SIZE_64M 0x4000000
  7250. +#define DRAM_SIZE_128M 0x8000000
  7251. +
  7252. +#define DRAM_SIZE DRAM_SIZE_128M
  7253. +
  7254. +#define DRAM_SDRMR 0x00
  7255. +#define SDRMR_DISABLE_DLL 0x80010000
  7256. +
  7257. +/*------------------------------------------------------------------------------
  7258. + Share Pin Flag
  7259. +--------------------------------------------------------------------------------*/
  7260. +#ifdef CONFIG_SL2312_SHARE_PIN
  7261. +#define FLASH_SHARE_BIT 0
  7262. +#define UART_SHARE_BIT 1
  7263. +#define EMAC_SHARE_BIT 2
  7264. +#define IDE_RW_SHARE_BIT 3
  7265. +#define IDE_CMD_SHARE_BIT 4
  7266. +#endif
  7267. +/*-------------------------------------------------------------------------------
  7268. + System Clock
  7269. +---------------------------------------------------------------------------------*/
  7270. +
  7271. +#ifndef SYS_CLK
  7272. +#ifdef CONFIG_SL3516_ASIC
  7273. +#define SYS_CLK 150000000
  7274. +#else
  7275. +#define SYS_CLK 20000000
  7276. +#endif
  7277. +#endif
  7278. +
  7279. +#define AHB_CLK SYS_CLK
  7280. +#define MAX_TIMER 3
  7281. +#ifndef APB_CLK
  7282. +#ifdef CONFIG_SL3516_ASIC
  7283. +#define APB_CLK (SYS_CLK / 6)
  7284. +#else
  7285. +#define APB_CLK SYS_CLK
  7286. +#endif
  7287. +#endif
  7288. +
  7289. +#ifdef CONFIG_SL3516_ASIC
  7290. +#define UART_CLK 48000000 // 30000000 for GeminiA chip, else 48000000
  7291. +#else
  7292. +#define UART_CLK 48000000
  7293. +#endif
  7294. +
  7295. +#define SL2312_BAUD_115200 (UART_CLK / 1843200)
  7296. +#define SL2312_BAUD_57600 (UART_CLK / 921600)
  7297. +#define SL2312_BAUD_38400 (UART_CLK / 614400)
  7298. +#define SL2312_BAUD_19200 (UART_CLK / 307200)
  7299. +#define SL2312_BAUD_14400 (UART_CLK / 230400)
  7300. +#define SL2312_BAUD_9600 (UART_CLK / 153600)
  7301. +
  7302. +#endif
  7303. +
  7304. +
  7305. --- /dev/null
  7306. +++ b/include/asm-arm/arch-sl2312/sl2312_ipsec.h
  7307. @@ -0,0 +1,684 @@
  7308. +#ifndef _IPSEC_DIAG_H
  7309. +#define _IPSEC_DIAG_H
  7310. +
  7311. +#include <linux/scatterlist.h>
  7312. +
  7313. +#define BIG_ENDIAN 0
  7314. +
  7315. +#define IPSEC_TEST 0
  7316. +#define ZERO_COPY 1
  7317. +
  7318. +#define UINT unsigned int
  7319. +#define BYTE unsigned char
  7320. +
  7321. +/* define cipher algorithm */
  7322. +enum CIPHER {
  7323. + DES_ECB_E =20,
  7324. + TDES_ECB_E =21,
  7325. + AES_ECB_E =22,
  7326. + DES_CBC_E =24,
  7327. + TDES_CBC_E =25,
  7328. + AES_CBC_E =26,
  7329. +
  7330. + DES_ECB_D =27,
  7331. + TDES_ECB_D =28,
  7332. + AES_ECB_D =29,
  7333. + DES_CBC_D =31,
  7334. + TDES_CBC_D =32,
  7335. + AES_CBC_D =33,
  7336. + A_SHA1 =12,
  7337. + A_HMAC_SHA1 =13,
  7338. + A_MD5 =14,
  7339. + A_HMAC_MD5 =15,
  7340. +};
  7341. +
  7342. +// opMode
  7343. +#define CIPHER_ENC 0x1
  7344. +#define CIPHER_DEC 0x3
  7345. +#define AUTH 0x4
  7346. +#define ENC_AUTH 0x5
  7347. +#define AUTH_DEC 0x7
  7348. +
  7349. +// cipherAlgorithm
  7350. +#define CBC_DES 0x4
  7351. +#define CBC_3DES 0x5
  7352. +#define CBC_AES 0x6
  7353. +#define ECB_DES 0x0
  7354. +#define ECB_3DES 0x1
  7355. +#define ECB_AES 0x2
  7356. +
  7357. +// authAlgorithm
  7358. +#define SHA1 0
  7359. +#define MD5 1
  7360. +#define HMAC_SHA1 2
  7361. +#define HMAC_MD5 3
  7362. +#define FCS 4
  7363. +
  7364. +//cipher mode
  7365. +#define ECB 0
  7366. +#define CBC 1
  7367. +
  7368. +// authMode
  7369. +#define AUTH_APPEND 0
  7370. +#define AUTH_CHKVAL 1
  7371. +
  7372. +/******************************************************/
  7373. +/* the offset of IPSEC DMA register */
  7374. +/******************************************************/
  7375. +enum IPSEC_DMA_REGISTER {
  7376. + IPSEC_DMA_DEVICE_ID = 0xff00,
  7377. + IPSEC_DMA_STATUS = 0xff04,
  7378. + IPSEC_TXDMA_CTRL = 0xff08,
  7379. + IPSEC_TXDMA_FIRST_DESC = 0xff0c,
  7380. + IPSEC_TXDMA_CURR_DESC = 0xff10,
  7381. + IPSEC_RXDMA_CTRL = 0xff14,
  7382. + IPSEC_RXDMA_FIRST_DESC = 0xff18,
  7383. + IPSEC_RXDMA_CURR_DESC = 0xff1c,
  7384. + IPSEC_TXDMA_BUF_ADDR = 0xff28,
  7385. + IPSEC_RXDMA_BUF_ADDR = 0xff38,
  7386. + IPSEC_RXDMA_BUF_SIZE = 0xff30,
  7387. +};
  7388. +
  7389. +#define IPSEC_STATUS_REG 0x00a8
  7390. +#define IPSEC_RAND_NUM_REG 0x00ac
  7391. +
  7392. +/******************************************************/
  7393. +/* the field definition of IPSEC DMA Module Register */
  7394. +/******************************************************/
  7395. +typedef union
  7396. +{
  7397. + unsigned int bits32;
  7398. + struct bit2_ff00
  7399. + {
  7400. +#if (BIG_ENDIAN==1)
  7401. + unsigned int p_wclk : 4; /* DMA_APB write clock period */
  7402. + unsigned int p_rclk : 4; /* DMA_APB read clock period */
  7403. + unsigned int : 8;
  7404. + unsigned int device_id : 12;
  7405. + unsigned int revision_id : 4;
  7406. +#else
  7407. + unsigned int revision_id : 4;
  7408. + unsigned int device_id : 12;
  7409. + unsigned int : 8;
  7410. + unsigned int p_rclk : 4; /* DMA_APB read clock period */
  7411. + unsigned int p_wclk : 4; /* DMA_APB write clock period */
  7412. +#endif
  7413. + } bits;
  7414. +} IPSEC_DMA_DEVICE_ID_T;
  7415. +
  7416. +typedef union
  7417. +{
  7418. + unsigned int bits32;
  7419. + struct bit2_ff04
  7420. + {
  7421. +#if (BIG_ENDIAN==1)
  7422. + unsigned int ts_finish : 1; /* finished tx interrupt */
  7423. + unsigned int ts_derr : 1; /* AHB Bus Error while tx */
  7424. + unsigned int ts_perr : 1; /* Tx Descriptor protocol error */
  7425. + unsigned int ts_eodi : 1; /* TxDMA end of descriptor interrupt */
  7426. + unsigned int ts_eofi : 1; /* TxDMA end of frame interrupt */
  7427. + unsigned int rs_finish : 1; /* finished rx interrupt */
  7428. + unsigned int rs_derr : 1; /* AHB Bus Error while rx */
  7429. + unsigned int rs_perr : 1; /* Rx Descriptor protocol error */
  7430. + unsigned int rs_eodi : 1; /* RxDMA end of descriptor interrupt */
  7431. + unsigned int rs_eofi : 1; /* RxDMA end of frame interrupt */
  7432. + unsigned int intr : 8; /* Peripheral interrupt */
  7433. + unsigned int dma_reset : 1; /* write 1 to this bit will cause DMA HClk domain soft reset */
  7434. + unsigned int peri_reset : 1; /* write 1 to this bit will cause DMA PClk domain soft reset */
  7435. + unsigned int : 3;
  7436. + unsigned int loop_back : 1; /* loopback TxDMA to RxDMA */
  7437. + unsigned int intr_enable : 8; /* Peripheral Interrupt Enable */
  7438. +#else
  7439. + unsigned int intr_enable : 8; /* Peripheral Interrupt Enable */
  7440. + unsigned int loop_back : 1; /* loopback TxDMA to RxDMA */
  7441. + unsigned int : 3;
  7442. + unsigned int peri_reset : 1; /* write 1 to this bit will cause DMA PClk domain soft reset */
  7443. + unsigned int dma_reset : 1; /* write 1 to this bit will cause DMA HClk domain soft reset */
  7444. + unsigned int intr : 8; /* Peripheral interrupt */
  7445. + unsigned int rs_eofi : 1; /* RxDMA end of frame interrupt */
  7446. + unsigned int rs_eodi : 1; /* RxDMA end of descriptor interrupt */
  7447. + unsigned int rs_perr : 1; /* Rx Descriptor protocol error */
  7448. + unsigned int rs_derr : 1; /* AHB Bus Error while rx */
  7449. + unsigned int rs_finish : 1; /* finished rx interrupt */
  7450. + unsigned int ts_eofi : 1; /* TxDMA end of frame interrupt */
  7451. + unsigned int ts_eodi : 1; /* TxDMA end of descriptor interrupt */
  7452. + unsigned int ts_perr : 1; /* Tx Descriptor protocol error */
  7453. + unsigned int ts_derr : 1; /* AHB Bus Error while tx */
  7454. + unsigned int ts_finish : 1; /* finished tx interrupt */
  7455. +#endif
  7456. + } bits;
  7457. +} IPSEC_DMA_STATUS_T;
  7458. +
  7459. +typedef union
  7460. +{
  7461. + unsigned int bits32;
  7462. + struct bit2_ff08
  7463. + {
  7464. +#if (BIG_ENDIAN==1)
  7465. + unsigned int td_start : 1; /* Start DMA transfer */
  7466. + unsigned int td_continue : 1; /* Continue DMA operation */
  7467. + unsigned int td_chain_mode : 1; /* Descriptor Chain Mode;1-Descriptor Chain mode, 0-Direct DMA mode*/
  7468. + unsigned int : 1;
  7469. + unsigned int td_prot : 4; /* TxDMA protection control */
  7470. + unsigned int td_burst_size : 2; /* TxDMA max burst size for every AHB request */
  7471. + unsigned int td_bus : 2; /* peripheral bus width;0 - 8 bits;1 - 16 bits */
  7472. + unsigned int td_endian : 1; /* AHB Endian. 0-little endian; 1-big endian */
  7473. + unsigned int td_finish_en : 1; /* DMA Finish Event Interrupt Enable;1-enable;0-mask */
  7474. + unsigned int td_fail_en : 1; /* DMA Fail Interrupt Enable;1-enable;0-mask */
  7475. + unsigned int td_perr_en : 1; /* Protocol Failure Interrupt Enable;1-enable;0-mask */
  7476. + unsigned int td_eod_en : 1; /* End of Descriptor interrupt Enable;1-enable;0-mask */
  7477. + unsigned int td_eof_en : 1; /* End of frame interrupt Enable;1-enable;0-mask */
  7478. + unsigned int : 14;
  7479. +#else
  7480. + unsigned int : 14;
  7481. + unsigned int td_eof_en : 1; /* End of frame interrupt Enable;1-enable;0-mask */
  7482. + unsigned int td_eod_en : 1; /* End of Descriptor interrupt Enable;1-enable;0-mask */
  7483. + unsigned int td_perr_en : 1; /* Protocol Failure Interrupt Enable;1-enable;0-mask */
  7484. + unsigned int td_fail_en : 1; /* DMA Fail Interrupt Enable;1-enable;0-mask */
  7485. + unsigned int td_finish_en : 1; /* DMA Finish Event Interrupt Enable;1-enable;0-mask */
  7486. + unsigned int td_endian : 1; /* AHB Endian. 0-little endian; 1-big endian */
  7487. + unsigned int td_bus : 2; /* peripheral bus width;0 - 8 bits;1 - 16 bits */
  7488. + unsigned int td_burst_size : 2; /* TxDMA max burst size for every AHB request */
  7489. + unsigned int td_prot : 4; /* TxDMA protection control */
  7490. + unsigned int : 1;
  7491. + unsigned int td_chain_mode : 1; /* Descriptor Chain Mode;1-Descriptor Chain mode, 0-Direct DMA mode*/
  7492. + unsigned int td_continue : 1; /* Continue DMA operation */
  7493. + unsigned int td_start : 1; /* Start DMA transfer */
  7494. +#endif
  7495. + } bits;
  7496. +} IPSEC_TXDMA_CTRL_T;
  7497. +
  7498. +typedef union
  7499. +{
  7500. + unsigned int bits32;
  7501. + struct bit2_ff0c
  7502. + {
  7503. +#if (BIG_ENDIAN==1)
  7504. + unsigned int td_first_des_ptr : 28;/* first descriptor address */
  7505. + unsigned int td_busy : 1;/* 1-TxDMA busy; 0-TxDMA idle */
  7506. + unsigned int : 3;
  7507. +#else
  7508. + unsigned int : 3;
  7509. + unsigned int td_busy : 1;/* 1-TxDMA busy; 0-TxDMA idle */
  7510. + unsigned int td_first_des_ptr : 28;/* first descriptor address */
  7511. +#endif
  7512. + } bits;
  7513. +} IPSEC_TXDMA_FIRST_DESC_T;
  7514. +
  7515. +typedef union
  7516. +{
  7517. + unsigned int bits32;
  7518. + struct bit2_ff10
  7519. + {
  7520. +#if (BIG_ENDIAN==1)
  7521. + unsigned int ndar : 28; /* next descriptor address */
  7522. + unsigned int eofie : 1; /* end of frame interrupt enable */
  7523. + unsigned int dec : 1; /* AHB bus address increment(0)/decrement(1) */
  7524. + unsigned int sof_eof : 2;
  7525. +#else
  7526. + unsigned int sof_eof : 2;
  7527. + unsigned int dec : 1; /* AHB bus address increment(0)/decrement(1) */
  7528. + unsigned int eofie : 1; /* end of frame interrupt enable */
  7529. + unsigned int ndar : 28; /* next descriptor address */
  7530. +#endif
  7531. + } bits;
  7532. +} IPSEC_TXDMA_CURR_DESC_T;
  7533. +
  7534. +
  7535. +typedef union
  7536. +{
  7537. + unsigned int bits32;
  7538. + struct bit2_ff14
  7539. + {
  7540. +#if (BIG_ENDIAN==1)
  7541. + unsigned int rd_start : 1; /* Start DMA transfer */
  7542. + unsigned int rd_continue : 1; /* Continue DMA operation */
  7543. + unsigned int rd_chain_mode : 1; /* Descriptor Chain Mode;1-Descriptor Chain mode, 0-Direct DMA mode*/
  7544. + unsigned int : 1;
  7545. + unsigned int rd_prot : 4; /* DMA protection control */
  7546. + unsigned int rd_burst_size : 2; /* DMA max burst size for every AHB request */
  7547. + unsigned int rd_bus : 2; /* peripheral bus width;0 - 8 bits;1 - 16 bits */
  7548. + unsigned int rd_endian : 1; /* AHB Endian. 0-little endian; 1-big endian */
  7549. + unsigned int rd_finish_en : 1; /* DMA Finish Event Interrupt Enable;1-enable;0-mask */
  7550. + unsigned int rd_fail_en : 1; /* DMA Fail Interrupt Enable;1-enable;0-mask */
  7551. + unsigned int rd_perr_en : 1; /* Protocol Failure Interrupt Enable;1-enable;0-mask */
  7552. + unsigned int rd_eod_en : 1; /* End of Descriptor interrupt Enable;1-enable;0-mask */
  7553. + unsigned int rd_eof_en : 1; /* End of frame interrupt Enable;1-enable;0-mask */
  7554. + unsigned int : 14;
  7555. +#else
  7556. + unsigned int : 14;
  7557. + unsigned int rd_eof_en : 1; /* End of frame interrupt Enable;1-enable;0-mask */
  7558. + unsigned int rd_eod_en : 1; /* End of Descriptor interrupt Enable;1-enable;0-mask */
  7559. + unsigned int rd_perr_en : 1; /* Protocol Failure Interrupt Enable;1-enable;0-mask */
  7560. + unsigned int rd_fail_en : 1; /* DMA Fail Interrupt Enable;1-enable;0-mask */
  7561. + unsigned int rd_finish_en : 1; /* DMA Finish Event Interrupt Enable;1-enable;0-mask */
  7562. + unsigned int rd_endian : 1; /* AHB Endian. 0-little endian; 1-big endian */
  7563. + unsigned int rd_bus : 2; /* peripheral bus width;0 - 8 bits;1 - 16 bits */
  7564. + unsigned int rd_burst_size : 2; /* DMA max burst size for every AHB request */
  7565. + unsigned int rd_prot : 4; /* DMA protection control */
  7566. + unsigned int : 1;
  7567. + unsigned int rd_chain_mode : 1; /* Descriptor Chain Mode;1-Descriptor Chain mode, 0-Direct DMA mode*/
  7568. + unsigned int rd_continue : 1; /* Continue DMA operation */
  7569. + unsigned int rd_start : 1; /* Start DMA transfer */
  7570. +#endif
  7571. + } bits;
  7572. +} IPSEC_RXDMA_CTRL_T;
  7573. +
  7574. +typedef union
  7575. +{
  7576. + unsigned int bits32;
  7577. + struct bit2_ff18
  7578. + {
  7579. +#if (BIG_ENDIAN==1)
  7580. + unsigned int rd_first_des_ptr : 28;/* first descriptor address */
  7581. + unsigned int rd_busy : 1;/* 1-RxDMA busy; 0-RxDMA idle */
  7582. + unsigned int : 3;
  7583. +#else
  7584. + unsigned int : 3;
  7585. + unsigned int rd_busy : 1;/* 1-RxDMA busy; 0-RxDMA idle */
  7586. + unsigned int rd_first_des_ptr : 28;/* first descriptor address */
  7587. +#endif
  7588. + } bits;
  7589. +} IPSEC_RXDMA_FIRST_DESC_T;
  7590. +
  7591. +typedef union
  7592. +{
  7593. + unsigned int bits32;
  7594. + struct bit2_ff1c
  7595. + {
  7596. +#if (BIG_ENDIAN==1)
  7597. + unsigned int ndar : 28; /* next descriptor address */
  7598. + unsigned int eofie : 1; /* end of frame interrupt enable */
  7599. + unsigned int dec : 1; /* AHB bus address increment(0)/decrement(1) */
  7600. + unsigned int sof_eof : 2;
  7601. +#else
  7602. + unsigned int sof_eof : 2;
  7603. + unsigned int dec : 1; /* AHB bus address increment(0)/decrement(1) */
  7604. + unsigned int eofie : 1; /* end of frame interrupt enable */
  7605. + unsigned int ndar : 28; /* next descriptor address */
  7606. +#endif
  7607. + } bits;
  7608. +} IPSEC_RXDMA_CURR_DESC_T;
  7609. +
  7610. +
  7611. +
  7612. +/******************************************************/
  7613. +/* the field definition of IPSEC module Register */
  7614. +/******************************************************/
  7615. +typedef union
  7616. +{
  7617. + unsigned int id;
  7618. + struct bit_0000
  7619. + {
  7620. +#if (BIG_ENDIAN==1)
  7621. + unsigned int device_id : 28;
  7622. + unsigned int revision_id : 4;
  7623. +#else
  7624. + unsigned int revision_id : 4;
  7625. + unsigned int device_id : 28;
  7626. +#endif
  7627. + } bits;
  7628. +} IPSEC_ID_T;
  7629. +
  7630. +typedef union
  7631. +{
  7632. + unsigned int control;
  7633. + struct bit_0004
  7634. + {
  7635. +#if (BIG_ENDIAN==1)
  7636. + unsigned int op_mode : 4; /* Operation Mode for the IPSec Module */
  7637. + unsigned int : 1;
  7638. + unsigned int cipher_algorithm : 3;
  7639. + unsigned int aesnk : 4; /* AES Key Size */
  7640. + unsigned int mix_key_sel : 1; /* 0:use rCipherKey0-3 1:use Key Mixer */
  7641. + unsigned int : 2;
  7642. + unsigned int fcs_stream_copy : 1; /* enable authentication stream copy */
  7643. + unsigned int auth_mode : 1; /* 0-Append or 1-Check Authentication Result */
  7644. + unsigned int auth_algorithm : 3;
  7645. + unsigned int : 1;
  7646. + unsigned int auth_check_len : 3; /* Number of 32-bit words to be check or appended */
  7647. + /* by the authentication module */
  7648. + unsigned int process_id : 8; /* Used to identify process.This number will be */
  7649. + /* copied to the descriptor status of received packet*/
  7650. +#else
  7651. + unsigned int process_id : 8; /* Used to identify process.This number will be */
  7652. + /* copied to the descriptor status of received packet*/
  7653. + unsigned int auth_check_len : 3; /* Number of 32-bit words to be check or appended */
  7654. + /* by the authentication module */
  7655. + unsigned int : 1;
  7656. + unsigned int auth_algorithm : 3;
  7657. + unsigned int auth_mode : 1; /* 0-Append or 1-Check Authentication Result */
  7658. + unsigned int fcs_stream_copy : 1; /* enable authentication stream copy */
  7659. + unsigned int : 2;
  7660. + unsigned int mix_key_sel : 1; /* 0:use rCipherKey0-3 1:use Key Mixer */
  7661. + unsigned int aesnk : 4; /* AES Key Size */
  7662. + unsigned int cipher_algorithm : 3;
  7663. + unsigned int : 1;
  7664. + unsigned int op_mode : 4; /* Operation Mode for the IPSec Module */
  7665. +#endif
  7666. + } bits;
  7667. +} IPSEC_CONTROL_T;
  7668. +
  7669. +
  7670. +typedef union
  7671. +{
  7672. + unsigned int cipher_packet;
  7673. + struct bit_0008
  7674. + {
  7675. +#if (BIG_ENDIAN==1)
  7676. + unsigned int cipher_header_len : 16; /* The header length to be skipped by the cipher */
  7677. + unsigned int cipher_algorithm_len : 16; /* The length of message body to be encrypted/decrypted */
  7678. +#else
  7679. + unsigned int cipher_algorithm_len : 16; /* The length of message body to be encrypted/decrypted */
  7680. + unsigned int cipher_header_len : 16; /* The header length to be skipped by the cipher */
  7681. +#endif
  7682. + } bits;
  7683. +} IPSEC_CIPHER_PACKET_T;
  7684. +
  7685. +typedef union
  7686. +{
  7687. + unsigned int auth_packet;
  7688. + struct bit_000c
  7689. + {
  7690. +#if (BIG_ENDIAN==1)
  7691. + unsigned int auth_header_len : 16; /* The header length that is to be skipped by the authenticator */
  7692. + unsigned int auth_algorithm_len : 16; /* The length of message body that is to be authenticated */
  7693. +#else
  7694. + unsigned int auth_algorithm_len : 16; /* The length of message body that is to be authenticated */
  7695. + unsigned int auth_header_len : 16; /* The header length that is to be skipped by the authenticator */
  7696. +#endif
  7697. + } bits;
  7698. +} IPSEC_AUTH_PACKET_T;
  7699. +
  7700. +typedef union
  7701. +{
  7702. + unsigned int status;
  7703. + struct bit_00a8
  7704. + {
  7705. +#if (BIG_ENDIAN==1)
  7706. + unsigned int auth_cmp_rslt : 1; /* Authentication Compare result */
  7707. + unsigned int wep_crc_ok : 1; /* WEP ICV compare result */
  7708. + unsigned int tkip_mic_ok : 1; /* TKIP Mic compare result */
  7709. + unsigned int ccm_mic_ok : 1; /* CCM Mic compare result */
  7710. + unsigned int : 16;
  7711. + unsigned int parser_err_code: 4; /* Authentication Compare result */
  7712. + unsigned int auth_err_code : 4; /* Authentication module error code */
  7713. + unsigned int cipher_err_code: 4; /* Cipher module erroe code */
  7714. +#else
  7715. + unsigned int cipher_err_code: 4; /* Cipher module erroe code */
  7716. + unsigned int auth_err_code : 4; /* Authentication module error code */
  7717. + unsigned int parser_err_code: 4; /* Authentication Compare result */
  7718. + unsigned int : 16;
  7719. + unsigned int ccm_mic_ok : 1; /* CCM Mic compare result */
  7720. + unsigned int tkip_mic_ok : 1; /* TKIP Mic compare result */
  7721. + unsigned int wep_crc_ok : 1; /* WEP ICV compare result */
  7722. + unsigned int auth_cmp_rslt : 1; /* Authentication Compare result */
  7723. +#endif
  7724. + } bits;
  7725. +} IPSEC_STATUS_T;
  7726. +
  7727. +
  7728. +
  7729. +/************************************************************************/
  7730. +/* IPSec Descriptor Format */
  7731. +/************************************************************************/
  7732. +typedef struct descriptor_t
  7733. +{
  7734. + union frame_control_t
  7735. + {
  7736. + unsigned int bits32;
  7737. + struct bits_0000
  7738. + {
  7739. +#if (BIG_ENDIAN==1)
  7740. + unsigned int own : 1; /* owner bit. 0-CPU, 1-DMA */
  7741. + unsigned int derr : 1; /* data error during processing this descriptor */
  7742. + unsigned int perr : 1; /* protocol error during processing this descriptor */
  7743. + unsigned int : 1; /* authentication compare result */
  7744. + unsigned int : 6; /* checksum[15:8] */
  7745. + unsigned int desc_count : 6; /* number of descriptors used for the current frame */
  7746. + unsigned int buffer_size:16; /* transfer buffer size associated with current description*/
  7747. +#else
  7748. + unsigned int buffer_size:16; /* transfer buffer size associated with current description*/
  7749. + unsigned int desc_count : 6; /* number of descriptors used for the current frame */
  7750. + unsigned int : 6; /* checksum[15:8] */
  7751. + unsigned int : 1; /* authentication compare result */
  7752. + unsigned int perr : 1; /* protocol error during processing this descriptor */
  7753. + unsigned int derr : 1; /* data error during processing this descriptor */
  7754. + unsigned int own : 1; /* owner bit. 0-CPU, 1-DMA */
  7755. +#endif
  7756. + } bits;
  7757. + } frame_ctrl;
  7758. +
  7759. + union flag_status_t
  7760. + {
  7761. + unsigned int bits32;
  7762. + struct bits_0004
  7763. + {
  7764. +#if (BIG_ENDIAN==1)
  7765. +// unsigned int checksum : 8; /* checksum[7:0] */
  7766. + unsigned int : 4;
  7767. + unsigned int auth_result: 1;
  7768. + unsigned int wep_crc_ok : 1;
  7769. + unsigned int tkip_mic_ok: 1;
  7770. + unsigned int ccmp_mic_ok: 1;
  7771. + unsigned int process_id : 8;
  7772. + unsigned int frame_count:16;
  7773. +#else
  7774. + unsigned int frame_count:16;
  7775. + unsigned int process_id : 8;
  7776. + unsigned int ccmp_mic_ok: 1;
  7777. + unsigned int tkip_mic_ok: 1;
  7778. + unsigned int wep_crc_ok : 1;
  7779. + unsigned int auth_result: 1;
  7780. + unsigned int : 4;
  7781. +// unsigned int checksum : 8; /* checksum[7:0] */
  7782. +#endif
  7783. + } bits_rx_status;
  7784. +
  7785. + struct bits_0005
  7786. + {
  7787. +#if (BIG_ENDIAN==1)
  7788. + unsigned int : 8;
  7789. + unsigned int process_id : 8;
  7790. + unsigned int frame_count:16;
  7791. +#else
  7792. + unsigned int frame_count:16;
  7793. + unsigned int process_id : 8;
  7794. + unsigned int : 8;
  7795. +#endif
  7796. + } bits_tx_status;
  7797. +
  7798. + struct bits_0006
  7799. + {
  7800. +#if (BIG_ENDIAN==1)
  7801. + unsigned int :22;
  7802. + unsigned int tqflag :10;
  7803. +#else
  7804. + unsigned int tqflag :10;
  7805. + unsigned int :22;
  7806. +#endif
  7807. + } bits_tx_flag;
  7808. + } flag_status;
  7809. +
  7810. + unsigned int buf_adr; /* data buffer address */
  7811. +
  7812. + union next_desc_t
  7813. + {
  7814. + unsigned int next_descriptor;
  7815. + struct bits_000c
  7816. + {
  7817. +#if (BIG_ENDIAN==1)
  7818. + unsigned int ndar :28; /* next descriptor address */
  7819. + unsigned int eofie : 1; /* end of frame interrupt enable */
  7820. + unsigned int dec : 1; /* AHB bus address. 0-increment; 1-decrement */
  7821. + unsigned int sof_eof : 2; /* 00-the linking descriptor 01-the last descriptor of a frame*/
  7822. + /* 10-the first descriptor of a frame 11-only one descriptor for a frame*/
  7823. +#else
  7824. + unsigned int sof_eof : 2; /* 00-the linking descriptor 01-the last descriptor of a frame*/
  7825. + /* 10-the first descriptor of a frame 11-only one descriptor for a frame*/
  7826. + unsigned int dec : 1; /* AHB bus address. 0-increment; 1-decrement */
  7827. + unsigned int eofie : 1; /* end of frame interrupt enable */
  7828. + unsigned int ndar :28; /* next descriptor address */
  7829. +#endif
  7830. + } bits;
  7831. + } next_desc;
  7832. +} IPSEC_DESCRIPTOR_T;
  7833. +
  7834. +
  7835. +typedef struct IPSEC_S
  7836. +{
  7837. + unsigned char *tx_bufs;
  7838. + unsigned char *rx_bufs;
  7839. + IPSEC_DESCRIPTOR_T *tx_desc; /* point to virtual TX descriptor address*/
  7840. + IPSEC_DESCRIPTOR_T *rx_desc; /* point to virtual RX descriptor address*/
  7841. + IPSEC_DESCRIPTOR_T *tx_cur_desc; /* point to current TX descriptor */
  7842. + IPSEC_DESCRIPTOR_T *rx_cur_desc; /* point to current RX descriptor */
  7843. + IPSEC_DESCRIPTOR_T *tx_finished_desc;
  7844. + IPSEC_DESCRIPTOR_T *rx_finished_desc;
  7845. + dma_addr_t rx_desc_dma; /* physical RX descriptor address */
  7846. + dma_addr_t tx_desc_dma; /* physical TX descriptor address */
  7847. + dma_addr_t rx_bufs_dma; /* physical RX descriptor address */
  7848. + dma_addr_t tx_bufs_dma; /* physical TX descriptor address */
  7849. +} IPSEC_T;
  7850. +
  7851. +
  7852. +/*=====================================================================================================*/
  7853. +/* Data Structure of IPSEC Control Packet */
  7854. +/*=====================================================================================================*/
  7855. +typedef struct IPSEC_ECB_AUTH_S
  7856. +{
  7857. + IPSEC_CONTROL_T control; /* control parameter */
  7858. + IPSEC_CIPHER_PACKET_T cipher; /* cipher packet parameter */
  7859. + IPSEC_AUTH_PACKET_T auth; /* authentication packet parameter */
  7860. + unsigned char cipher_key[8*4];
  7861. + unsigned char auth_check_val[5*4];
  7862. +} IPSEC_ECB_AUTH_T;
  7863. +
  7864. +typedef struct IPSEC_CBC_AUTH_S
  7865. +{
  7866. + IPSEC_CONTROL_T control; /* control parameter */
  7867. + IPSEC_CIPHER_PACKET_T cipher; /* cipher packet parameter */
  7868. + IPSEC_AUTH_PACKET_T auth; /* authentication packet parameter */
  7869. + unsigned char cipher_iv[4*4];
  7870. + unsigned char cipher_key[8*4];
  7871. + unsigned char auth_check_val[5*4];
  7872. +} IPSEC_CBC_AUTH_T;
  7873. +
  7874. +typedef struct IPSEC_ECB_HMAC_AUTH_S
  7875. +{
  7876. + IPSEC_CONTROL_T control; /* control parameter */
  7877. + IPSEC_CIPHER_PACKET_T cipher; /* cipher packet parameter */
  7878. + IPSEC_AUTH_PACKET_T auth; /* authentication packet parameter */
  7879. + unsigned char cipher_key[8*4];
  7880. + unsigned char auth_key[16*4];
  7881. + unsigned char auth_check_val[5*4];
  7882. +} IPSEC_ECB_AUTH_HMAC_T;
  7883. +
  7884. +typedef struct IPSEC_CBC_HMAC_AUTH_S
  7885. +{
  7886. + IPSEC_CONTROL_T control; /* control parameter */
  7887. + IPSEC_CIPHER_PACKET_T cipher; /* cipher packet parameter */
  7888. + IPSEC_AUTH_PACKET_T auth; /* authentication packet parameter */
  7889. + unsigned char cipher_iv[4*4];
  7890. + unsigned char cipher_key[8*4];
  7891. + unsigned char auth_key[16*4];
  7892. + unsigned char auth_check_val[5*4];
  7893. +} IPSEC_CBC_AUTH_HMAC_T;
  7894. +
  7895. +typedef struct IPSEC_HMAC_AUTH_S
  7896. +{
  7897. + IPSEC_CONTROL_T control; /* control parameter */
  7898. + IPSEC_AUTH_PACKET_T auth; /* authentication packet parameter */
  7899. + unsigned char auth_key[16*4];
  7900. + unsigned char auth_check_val[5*4];
  7901. +} IPSEC_HMAC_AUTH_T;
  7902. +
  7903. +typedef union
  7904. +{
  7905. + unsigned char auth_pkt[28];
  7906. +
  7907. + struct IPSEC_AUTH_S
  7908. + {
  7909. + IPSEC_CONTROL_T control; /* control parameter(4-byte) */
  7910. + IPSEC_AUTH_PACKET_T auth; /* authentication packet parameter(4-byte) */
  7911. + unsigned char auth_check_val[5*4];
  7912. + } var;
  7913. +} IPSEC_AUTH_T;
  7914. +
  7915. +typedef struct IPSEC_CIPHER_CBC_S
  7916. +{
  7917. + IPSEC_CONTROL_T control; /* control parameter */
  7918. + IPSEC_CIPHER_PACKET_T cipher; /* cipher packet parameter */
  7919. + unsigned char cipher_iv[4*4];
  7920. + unsigned char cipher_key[8*4];
  7921. +} IPSEC_CIPHER_CBC_T;
  7922. +
  7923. +typedef struct IPSEC_CIPHER_ECB_S
  7924. +{
  7925. + IPSEC_CONTROL_T control; /* control parameter */
  7926. + IPSEC_CIPHER_PACKET_T cipher; /* cipher packet parameter */
  7927. + unsigned char cipher_key[8*4];
  7928. +} IPSEC_CIPHER_ECB_T;
  7929. +
  7930. +
  7931. +/****************************************************************************
  7932. + * Structure Definition *
  7933. + ****************************************************************************/
  7934. +struct IPSEC_PACKET_S
  7935. +{
  7936. + unsigned int op_mode; /* CIPHER_ENC(1),CIPHER_DEC(3),AUTH(4),ENC_AUTH(5),AUTH_DEC(7) */
  7937. + unsigned int cipher_algorithm; /* ECB_DES(0),ECB_3DES(1),ECB_AES(2),CBC_DES(4),CBC_3DES(5),CBC_AES(6) */
  7938. + unsigned int auth_algorithm; /* SHA1(0),MD5(1),HMAC_SHA1(2),HMAC_MD5(3),FCS(4) */
  7939. + unsigned int auth_result_mode; /* AUTH_APPEND(0),AUTH_CHKVAL(1) */
  7940. + unsigned int process_id; /* Used to identify the process */
  7941. + unsigned int auth_header_len; /* Header length to be skipped by the authenticator */
  7942. + unsigned int auth_algorithm_len; /* Length of message body that is to be authenticated */
  7943. + unsigned int cipher_header_len; /* Header length to be skipped by the cipher */
  7944. + unsigned int cipher_algorithm_len; /* Length of message body to be encrypted or decrypted */
  7945. + unsigned char iv[16]; /* Initial vector used for DES,3DES,AES */
  7946. + unsigned int iv_size; /* Initial vector size */
  7947. + unsigned char auth_key[64]; /* authentication key */
  7948. + unsigned int auth_key_size; /* authentication key size */
  7949. + unsigned char cipher_key[32]; /* cipher key */
  7950. + unsigned int cipher_key_size; /* cipher key size */
  7951. + struct scatterlist *in_packet; /* input_packet buffer pointer */
  7952. + //unsigned char *in_packet; /* input_packet buffer pointer */
  7953. + unsigned int pkt_len; /* input total packet length */
  7954. + unsigned char auth_checkval[20]; /* Authentication check value/FCS check value */
  7955. + struct IPSEC_PACKET_S *next,*prev; /* pointer to next/previous operation to perform on buffer */
  7956. + void (*callback)(struct IPSEC_PACKET_S *); /* function to call when done authentication/cipher */
  7957. + unsigned char *out_packet; /* output_packet buffer pointer */
  7958. + //struct scatterlist *out_packet; /* output_packet buffer pointer */
  7959. + unsigned int out_pkt_len; /* output total packet length */
  7960. + unsigned int auth_cmp_result; /* authentication compare result */
  7961. + unsigned int checksum; /* checksum value */
  7962. + unsigned int status; /* ipsec return status. 0:success, others:fail */
  7963. +#if (IPSEC_TEST == 1)
  7964. + unsigned char *sw_packet; /* for test only */
  7965. + unsigned int sw_pkt_len; /* for test only */
  7966. +#endif
  7967. +} ;
  7968. +
  7969. +/*****************************************************************************
  7970. + * Function : ipsec_crypto_hw_process
  7971. + * Description : This function processes H/W authentication and cipher.
  7972. + * Input : op_info - the authentication and cipher information for IPSec module.
  7973. + * Output : none.
  7974. + * Return : 0 - success, others - failure.
  7975. + *****************************************************************************/
  7976. +int ipsec_crypto_hw_process(struct IPSEC_PACKET_S *op_info);
  7977. +
  7978. +int ipsec_get_cipher_algorithm(unsigned char *alg_name,unsigned int alg_mode);
  7979. +int ipsec_get_auth_algorithm(unsigned char *alg_name,unsigned int alg_mode);
  7980. +#if 0
  7981. +void ipsec_sw_authentication(char *data,unsigned int data_len,char *authkey,char authAlgorithm,char *auth_result);
  7982. +void ipsec_sw_cipher(unsigned char *pt,unsigned int pt_len, unsigned char *cipher_key, unsigned int key_size,
  7983. + unsigned char *iv,unsigned int cipherAlgorithm,unsigned char *ct);
  7984. +void ipsec_sw_auth_cipher(unsigned int op_mode,char *data,unsigned int data_len,
  7985. + BYTE *auth_key,char authAlgorithm,char *auth_result,
  7986. + char *pt, unsigned int pt_len,char *cipher_key, int key_size,
  7987. + char *iv, char cipherAlgorithm,char *ct);
  7988. +#endif
  7989. +
  7990. +
  7991. +#endif
  7992. --- /dev/null
  7993. +++ b/include/asm-arm/arch-sl2312/sl_random.h
  7994. @@ -0,0 +1,2 @@
  7995. +#define RANDOM_ADD (IO_ADDRESS (0x051000000) + 0x0AC)
  7996. +
  7997. --- /dev/null
  7998. +++ b/include/asm-arm/arch-sl2312/system.h
  7999. @@ -0,0 +1,54 @@
  8000. +/*
  8001. + * linux/include/asm-arm/arch-sl2312/system.h
  8002. + *
  8003. + * Copyright (C) 1999 ARM Limited
  8004. + * Copyright (C) 2000 Deep Blue Solutions Ltd
  8005. + * Copyright (C) 2001 Altera Corporation
  8006. + *
  8007. + * This program is free software; you can redistribute it and/or modify
  8008. + * it under the terms of the GNU General Public License as published by
  8009. + * the Free Software Foundation; either version 2 of the License, or
  8010. + * (at your option) any later version.
  8011. + *
  8012. + * This program is distributed in the hope that it will be useful,
  8013. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8014. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8015. + * GNU General Public License for more details.
  8016. + *
  8017. + * You should have received a copy of the GNU General Public License
  8018. + * along with this program; if not, write to the Free Software
  8019. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  8020. + */
  8021. +#ifndef __ASM_ARCH_SYSTEM_H
  8022. +#define __ASM_ARCH_SYSTEM_H
  8023. +
  8024. +#include <asm/arch/platform.h>
  8025. +#include <asm/arch/hardware.h>
  8026. +#include <asm/arch/it8712.h>
  8027. +#include <asm/io.h>
  8028. +
  8029. +static void arch_idle(void)
  8030. +{
  8031. + /*
  8032. + * This should do all the clock switching
  8033. + * and wait for interrupt tricks
  8034. + */
  8035. + cpu_do_idle();
  8036. +}
  8037. +
  8038. +extern __inline__ void arch_reset(char mode)
  8039. +{
  8040. + __raw_writel( (int) GLOBAL_RESET|RESET_CPU1, IO_ADDRESS(SL2312_GLOBAL_BASE) + GLOBAL_RESET_REG);
  8041. +}
  8042. +
  8043. +
  8044. +void (*pm_power_off)(void);
  8045. +//{
  8046. +// printk("arch_power_off\n");
  8047. +
  8048. + // Power off
  8049. +// __raw_writel( (int) 0x00000001, IO_ADDRESS(SL2312_POWER_CTRL_BASE) + 0x04);
  8050. +
  8051. +//}
  8052. +
  8053. +#endif
  8054. --- /dev/null
  8055. +++ b/include/asm-arm/arch-sl2312/timer.h
  8056. @@ -0,0 +1,53 @@
  8057. +/*
  8058. + *
  8059. + * This file contains the register definitions for the Excalibur
  8060. + * Timer TIMER00.
  8061. + *
  8062. + * Copyright (C) 2001 Altera Corporation
  8063. + *
  8064. + * This program is free software; you can redistribute it and/or modify
  8065. + * it under the terms of the GNU General Public License as published by
  8066. + * the Free Software Foundation; either version 2 of the License, or
  8067. + * (at your option) any later version.
  8068. + *
  8069. + * This program is distributed in the hope that it will be useful,
  8070. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8071. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8072. + * GNU General Public License for more details.
  8073. + *
  8074. + * You should have received a copy of the GNU General Public License
  8075. + * along with this program; if not, write to the Free Software
  8076. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  8077. + */
  8078. +#ifndef __TIMER_H
  8079. +#define __TIMER_H
  8080. +
  8081. +/*
  8082. + * Register definitions for the timers
  8083. + */
  8084. +
  8085. +#define TIMER_COUNT(BASE_ADDR) (TIMER_TYPE (BASE_ADDR + 0x00 ))
  8086. +#define TIMER_LOAD(BASE_ADDR) (TIMER_TYPE (BASE_ADDR + 0x04 ))
  8087. +#define TIMER_MATCH1(BASE_ADDR) (TIMER_TYPE (BASE_ADDR + 0x08 ))
  8088. +#define TIMER_MATCH2(BASE_ADDR) (TIMER_TYPE (BASE_ADDR + 0x0C ))
  8089. +#define TIMER_CR(BASE_ADDR) (TIMER_TYPE (BASE_ADDR + 0x30 ))
  8090. +#define TIMER_1_CR_ENABLE_MSK (0x00000001)
  8091. +#define TIMER_1_CR_ENABLE_OFST (0)
  8092. +#define TIMER_1_CR_CLOCK_MSK (0x00000002)
  8093. +#define TIMER_1_CR_CLOCK_OFST (1)
  8094. +#define TIMER_1_CR_INT_MSK (0x00000004)
  8095. +#define TIMER_1_CR_INT_OFST (2)
  8096. +#define TIMER_2_CR_ENABLE_MSK (0x00000008)
  8097. +#define TIMER_2_CR_ENABLE_OFST (3)
  8098. +#define TIMER_2_CR_CLOCK_MSK (0x00000010)
  8099. +#define TIMER_2_CR_CLOCK_OFST (4)
  8100. +#define TIMER_2_CR_INT_MSK (0x00000020)
  8101. +#define TIMER_2_CR_INT_OFST (5)
  8102. +#define TIMER_3_CR_ENABLE_MSK (0x00000040)
  8103. +#define TIMER_3_CR_ENABLE_OFST (6)
  8104. +#define TIMER_3_CR_CLOCK_MSK (0x00000080)
  8105. +#define TIMER_3_CR_CLOCK_OFST (7)
  8106. +#define TIMER_3_CR_INT_MSK (0x00000100)
  8107. +#define TIMER_3_CR_INT_OFST (8)
  8108. +
  8109. +#endif /* __TIMER00_H */
  8110. --- /dev/null
  8111. +++ b/include/asm-arm/arch-sl2312/timex.h
  8112. @@ -0,0 +1,29 @@
  8113. +/*
  8114. + * linux/include/asm-arm/arch-epxa10db/timex.h
  8115. + *
  8116. + * Excalibur timex specifications
  8117. + *
  8118. + * Copyright (C) 2001 Altera Corporation
  8119. + *
  8120. + * This program is free software; you can redistribute it and/or modify
  8121. + * it under the terms of the GNU General Public License as published by
  8122. + * the Free Software Foundation; either version 2 of the License, or
  8123. + * (at your option) any later version.
  8124. + *
  8125. + * This program is distributed in the hope that it will be useful,
  8126. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8127. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8128. + * GNU General Public License for more details.
  8129. + *
  8130. + * You should have received a copy of the GNU General Public License
  8131. + * along with this program; if not, write to the Free Software
  8132. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  8133. + */
  8134. +
  8135. +/*
  8136. + * ??
  8137. + */
  8138. +#include <asm/arch/sl2312.h>
  8139. +
  8140. +#define CLOCK_TICK_RATE APB_CLK
  8141. +
  8142. --- /dev/null
  8143. +++ b/include/asm-arm/arch-sl2312/uart.h
  8144. @@ -0,0 +1,100 @@
  8145. +/* *
  8146. + * Copyright (C) 2001 Altera Corporation
  8147. + *
  8148. + * This program is free software; you can redistribute it and/or modify
  8149. + * it under the terms of the GNU General Public License as published by
  8150. + * the Free Software Foundation; either version 2 of the License, or
  8151. + * (at your option) any later version.
  8152. + *
  8153. + * This program is distributed in the hope that it will be useful,
  8154. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8155. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8156. + * GNU General Public License for more details.
  8157. + *
  8158. + * You should have received a copy of the GNU General Public License
  8159. + * along with this program; if not, write to the Free Software
  8160. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  8161. + */
  8162. +#ifndef __UART_H
  8163. +#define __UART_H
  8164. +
  8165. +/*
  8166. + * Register definitions for the UART
  8167. + */
  8168. +
  8169. +#define UART_TX_FIFO_SIZE (15)
  8170. +
  8171. +#define UART_RBR(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x00)) // read
  8172. +#define UART_THR(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x00)) // write
  8173. +#define UART_IER(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x04))
  8174. +#define UART_IER_MS (0x08)
  8175. +#define UART_IER_RLS (0x04)
  8176. +#define UART_IER_TE (0x02)
  8177. +#define UART_IER_DR (0x01)
  8178. +#define UART_IIR(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x08)) // read
  8179. +#define UART_IIR_NONE (0x01) /* No interrupt pending */
  8180. +#define UART_IIR_RLS (0x06) /* Receive Line Status */
  8181. +#define UART_IIR_DR (0x04) /* Receive Data Ready */
  8182. +#define UART_IIR_TIMEOUT (0x0c) /* Receive Time Out */
  8183. +#define UART_IIR_TE (0x02) /* THR Empty */
  8184. +#define UART_IIR_MODEM (0x00) /* Modem Status */
  8185. +#define UART_FCR(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x08)) // write
  8186. +#define UART_FCR_FE (0x01) /* FIFO Enable */
  8187. +#define UART_FCR_RXFR (0x02) /* Rx FIFO Reset */
  8188. +#define UART_FCR_TXFR (0x04) /* Tx FIFO Reset */
  8189. +#define UART_FCR_FIFO_1C (0x00)
  8190. +#define UART_FCR_FIFO_4C (0x40)
  8191. +#define UART_FCR_FIFO_8C (0x80)
  8192. +#define UART_FCR_FIFO_14C (0xC0)
  8193. +#define UART_LCR(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x0C))
  8194. +#define UART_LCR_MSK (0x03)
  8195. +#define UART_LCR_LEN5 (0x00)
  8196. +#define UART_LCR_LEN6 (0x01)
  8197. +#define UART_LCR_LEN7 (0x02)
  8198. +#define UART_LCR_LEN8 (0x03)
  8199. +#define UART_LCR_STOP (0x04)
  8200. +#define UART_LCR_EVEN (0x18) /* Even Parity */
  8201. +#define UART_LCR_ODD (0x08) /* Odd Parity */
  8202. +#define UART_LCR_PE (0x08) /* Parity Enable */
  8203. +#define UART_LCR_SETBREAK (0x40) /* Set Break condition */
  8204. +#define UART_LCR_STICKPARITY (0x20) /* Stick Parity Enable */
  8205. +#define UART_LCR_DLAB (0x80) /* Divisor Latch Access Bit */
  8206. +#define UART_MCR(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x10))
  8207. +#define UART_MCR_DTR (0x1) /* Data Terminal Ready */
  8208. +#define UART_MCR_RTS (0x2) /* Request to Send */
  8209. +#define UART_MCR_OUT1 (0x4) /* output 1 */
  8210. +#define UART_MCR_OUT2 (0x8) /* output2 or global interrupt enable */
  8211. +#define UART_MCR_LPBK (0x10) /* loopback mode */
  8212. +#define UART_MCR_MASK (0xE3)
  8213. +#define UART_LSR(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x14))
  8214. +#define UART_LSR_DR (0x01) /* Data Ready */
  8215. +#define UART_LSR_OE (0x02) /* Overrun Error */
  8216. +#define UART_LSR_PE (0x04) /* Parity Error */
  8217. +#define UART_LSR_FE (0x08) /* Framing Error */
  8218. +#define UART_LSR_BI (0x10) /* Break Interrupt */
  8219. +#define UART_LSR_THRE (0x20) /* THR Empty */
  8220. +#define UART_LSR_TE (0x40) /* Transmitte Empty */
  8221. +#define UART_LSR_DE (0x80) /* FIFO Data Error */
  8222. +#define UART_MSR(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x18))
  8223. +#define UART_MSR_DELTACTS (0x01) /* Delta CTS */
  8224. +#define UART_MSR_DELTADSR (0x02) /* Delta DSR */
  8225. +#define UART_MSR_TERI (0x04) /* Trailing Edge RI */
  8226. +#define UART_MSR_DELTACD (0x08) /* Delta CD */
  8227. +#define UART_MSR_CTS (0x10) /* Clear To Send */
  8228. +#define UART_MSR_DSR (0x20) /* Data Set Ready */
  8229. +#define UART_MSR_RI (0x40) /* Ring Indicator */
  8230. +#define UART_MSR_DCD (0x80) /* Data Carrier Detect */
  8231. +#define UART_SPR(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x1C))
  8232. +#define UART_DIV_LO(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x0))
  8233. +#define UART_DIV_HI(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x4))
  8234. +#define UART_PSR(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x8))
  8235. +#define UART_MDR(BASE_ADDR) (UART_TYPE (BASE_ADDR + 0x20))
  8236. +#define UART_MDR_SERIAL (0x0)
  8237. +
  8238. +#define UART_MSR_DDCD 0x08 /* Delta DCD */
  8239. +#define UART_MSR_DDSR 0x02 /* Delta DSR */
  8240. +#define UART_MSR_DCTS 0x01 /* Delta CTS */
  8241. +#define UART_MSR_ANY_DELTA 0x0F /* Any of the delta bits! */
  8242. +
  8243. +
  8244. +#endif /* __UART_H */
  8245. --- /dev/null
  8246. +++ b/include/asm-arm/arch-sl2312/uncompress.h
  8247. @@ -0,0 +1,94 @@
  8248. +/*
  8249. + * linux/include/asm-arm/arch-epxa10db/uncompress.h
  8250. + *
  8251. + * Copyright (C) 1999 ARM Limited
  8252. + * Copyright (C) 2001 Altera Corporation
  8253. + *
  8254. + * This program is free software; you can redistribute it and/or modify
  8255. + * it under the terms of the GNU General Public License as published by
  8256. + * the Free Software Foundation; either version 2 of the License, or
  8257. + * (at your option) any later version.
  8258. + *
  8259. + * This program is distributed in the hope that it will be useful,
  8260. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8261. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8262. + * GNU General Public License for more details.
  8263. + *
  8264. + * You should have received a copy of the GNU General Public License
  8265. + * along with this program; if not, write to the Free Software
  8266. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  8267. + */
  8268. +#include "asm/arch/platform.h"
  8269. +#include "asm/arch/hardware.h"
  8270. +#define UART_TYPE (volatile unsigned int*)
  8271. +#ifndef CONFIG_SERIAL_IT8712
  8272. +#include "asm/arch/uart.h"
  8273. +#endif
  8274. +extern unsigned int it8712_uart_base;
  8275. +
  8276. +/*
  8277. + * This does not append a newline
  8278. + */
  8279. +static void putstr(const char *s)
  8280. +{
  8281. +
  8282. +#ifdef CONFIG_SERIAL_IT8712
  8283. +
  8284. + unsigned char *base,*status,stat;
  8285. + int i ;
  8286. +
  8287. + status = (unsigned char*)it8712_uart_base + 5;
  8288. + base = (unsigned char*)it8712_uart_base ;
  8289. +
  8290. + while (*s) {
  8291. +
  8292. + stat = *status;
  8293. + while (!(stat&0x20)) { // check status
  8294. + for(i=0;i<0x10;i++) ;
  8295. + status = (unsigned char*)it8712_uart_base + 5;
  8296. + stat = *status ;
  8297. + }
  8298. +
  8299. + *base = *s;
  8300. + barrier();
  8301. +
  8302. + if (*s == '\n') {
  8303. + stat = *status;
  8304. + while (!(stat&0x20)) { // check status
  8305. + for(i=0;i<0x10;i++) ;
  8306. + status = (unsigned char*)it8712_uart_base + 5;
  8307. + stat = *status ;
  8308. + }
  8309. +
  8310. + barrier();
  8311. + *base = '\r';
  8312. + }
  8313. + s++;
  8314. + }
  8315. +
  8316. +#else
  8317. + while (*s) {
  8318. + while (!(*UART_LSR(SL2312_UART_BASE) &
  8319. + UART_LSR_THRE));
  8320. + barrier();
  8321. +
  8322. + *UART_THR(SL2312_UART_BASE) = *s;
  8323. +
  8324. + if (*s == '\n') {
  8325. + while (!(*UART_LSR(SL2312_UART_BASE) &
  8326. + UART_LSR_THRE));
  8327. + barrier();
  8328. +
  8329. + *UART_THR(SL2312_UART_BASE) = '\r';
  8330. + }
  8331. + s++;
  8332. + }
  8333. +#endif
  8334. +}
  8335. +
  8336. +/*
  8337. + * nothing to do
  8338. + */
  8339. +#define arch_decomp_setup()
  8340. +
  8341. +#define arch_decomp_wdog()
  8342. --- /dev/null
  8343. +++ b/include/asm-arm/arch-sl2312/vmalloc.h
  8344. @@ -0,0 +1,36 @@
  8345. +/*
  8346. + * linux/include/asm-arm/arch-epxa10db/vmalloc.h
  8347. + *
  8348. + * Copyright (C) 2000 Russell King.
  8349. + *
  8350. + * This program is free software; you can redistribute it and/or modify
  8351. + * it under the terms of the GNU General Public License as published by
  8352. + * the Free Software Foundation; either version 2 of the License, or
  8353. + * (at your option) any later version.
  8354. + *
  8355. + * This program is distributed in the hope that it will be useful,
  8356. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8357. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8358. + * GNU General Public License for more details.
  8359. + *
  8360. + * You should have received a copy of the GNU General Public License
  8361. + * along with this program; if not, write to the Free Software
  8362. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  8363. + */
  8364. +
  8365. +/*
  8366. + * Just any arbitrary offset to the start of the vmalloc VM area: the
  8367. + * current 8MB value just means that there will be a 8MB "hole" after the
  8368. + * physical memory until the kernel virtual memory starts. That means that
  8369. + * any out-of-bounds memory accesses will hopefully be caught.
  8370. + * The vmalloc() routines leaves a hole of 4kB between each vmalloced
  8371. + * area for the same reason. ;)
  8372. + */
  8373. +#define VMALLOC_OFFSET (8*1024*1024)
  8374. +#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
  8375. +#define VMALLOC_VMADDR(x) ((unsigned long)(x))
  8376. +#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
  8377. +
  8378. +//#define MODULE_START (PAGE_OFFSET - 16*1048576)
  8379. +//#define MODULE_END (PAGE_OFFSET)
  8380. +
  8381. --- /dev/null
  8382. +++ b/include/asm-arm/arch-sl2312/watchdog.h
  8383. @@ -0,0 +1,58 @@
  8384. +#ifndef __WATCHDOG_H
  8385. +#define __WATCHDOG_H
  8386. +
  8387. +#define WATCHDOG_BASE (IO_ADDRESS (SL2312_WAQTCHDOG_BASE))
  8388. +#define WATCHDOG_COUNTER (WATCHDOG_BASE + 0x00)
  8389. +#define WATCHDOG_LOAD (WATCHDOG_BASE + 0x04)
  8390. +#define WATCHDOG_RESTART (WATCHDOG_BASE + 0x08)
  8391. +#define WATCHDOG_CR (WATCHDOG_BASE + 0x0C)
  8392. +#define WATCHDOG_STATUS (WATCHDOG_BASE + 0x10)
  8393. +#define WATCHDOG_CLEAR (WATCHDOG_BASE + 0x14)
  8394. +#define WATCHDOG_INTRLEN (WATCHDOG_BASE + 0x18)
  8395. +
  8396. +#define WATCHDOG_WDENABLE_MSK (0x00000001)
  8397. +#define WATCHDOG_WDENABLE_OFST (0)
  8398. +#define WATCHDOG_WDRST_MSK (0x00000002)
  8399. +#define WATCHDOG_WDRST_OFST (1)
  8400. +#define WATCHDOG_WDINTR_MSK (0x00000004)
  8401. +#define WATCHDOG_WDINTR_OFST (2)
  8402. +#define WATCHDOG_WDEXT_MSK (0x00000008)
  8403. +#define WATCHDOG_WDEXT_OFST (3)
  8404. +#define WATCHDOG_WDCLOCK_MSK (0x00000010)
  8405. +#define WATCHDOG_WDCLOCK_OFST (4)
  8406. +#define WATCHDOG_CR_MASK (0x0000001F)
  8407. +
  8408. +#define WATCHDOG_CLEAR_STATUS 0x1
  8409. +#define WATCHDOG_ENABLE 1
  8410. +#define WATCHDOG_DISABLE 0
  8411. +#define WATCHDOG_RESTART_VALUE 0x5AB9
  8412. +
  8413. +#define WATCHDOG_MINOR 130
  8414. +
  8415. +#define WATCHDOG_IOCTRL_DISABLE 0x01
  8416. +#define WATCHDOG_IOCTRL_SETTIME 0x02
  8417. +#define WATCHDOG_IOCTRL_ENABLE 0x03
  8418. +#define WATCHDOG_IOCTRL_RESTART 0x04
  8419. +
  8420. +#define WATCHDOG_TIMEOUT_SCALE APB_CLK
  8421. +#define WATCHDOG_TIMEOUT_MARGIN 30
  8422. +#define WATCHDOG_DRIVER_OPEN 1
  8423. +#define WATCHDOG_DRIVER_CLOSE 0
  8424. +
  8425. +
  8426. +static void watchdog_disable(void);
  8427. +static void watchdog_enable(void);
  8428. +static int watchdog_open(struct inode *, struct file *);
  8429. +static int watchdog_release(struct inode *, struct file *);
  8430. +static ssize_t watchdog_read(struct file *, char *, size_t, loff_t *);
  8431. +static ssize_t watchdog_write(struct file *, const char *, size_t, loff_t *);
  8432. +static int watchdog_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
  8433. +#ifdef WATCHDOG_TEST
  8434. +static void watchdog_fire(int, void *, struct pt_regs *);
  8435. +#endif
  8436. +
  8437. +
  8438. +
  8439. +
  8440. +
  8441. +#endif
  8442. --- /dev/null
  8443. +++ b/include/asm-arm/arch-sl2312/xor.h
  8444. @@ -0,0 +1,29 @@
  8445. +/*
  8446. + * include/asm-arm/arch-sl2312/xor.h
  8447. + *
  8448. + * Copyright (C) 2005 Storlink Corp.
  8449. + *
  8450. + * This program is free software; you can redistribute it and/or modify
  8451. + * it under the terms of the GNU General Public License version 2 as
  8452. + * published by the Free Software Foundation.
  8453. + */
  8454. +
  8455. +#ifndef _ASM_ARCH_XOR_H
  8456. +#define _ASM_ARCH_XOR_H
  8457. +
  8458. +/*
  8459. + * Function prototypes
  8460. + */
  8461. +void xor_gemini_2(unsigned long bytes, unsigned long *p1, unsigned long *p2);
  8462. +
  8463. +void xor_gemini_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
  8464. + unsigned long *p3);
  8465. +
  8466. +void xor_gemini_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
  8467. + unsigned long *p3, unsigned long *p4);
  8468. +
  8469. +void xor_gemini_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
  8470. + unsigned long *p3, unsigned long *p4, unsigned long *p5);
  8471. +
  8472. +#endif /* _ASM_ARCH_XOR_H */
  8473. +
  8474. --- a/include/asm-arm/cacheflush.h
  8475. +++ b/include/asm-arm/cacheflush.h
  8476. @@ -46,6 +46,18 @@
  8477. # define MULTI_CACHE 1
  8478. #endif
  8479. +/***********************************************************************
  8480. + * Storlink SoC -- Cache
  8481. + ***********************************************************************/
  8482. +#if defined(CONFIG_CPU_FA526)
  8483. +# ifdef _CACHE
  8484. +# define MULTI_CACHE 1
  8485. +# else
  8486. +# define _CACHE fa
  8487. +# endif
  8488. +#endif
  8489. +/***********************************************************************/
  8490. +
  8491. #if defined(CONFIG_CPU_ARM926T)
  8492. # ifdef _CACHE
  8493. # define MULTI_CACHE 1
  8494. --- a/include/asm-arm/page.h
  8495. +++ b/include/asm-arm/page.h
  8496. @@ -74,6 +74,18 @@
  8497. # endif
  8498. #endif
  8499. +/***********************************************************************
  8500. + * Storlink SoC -- flash
  8501. + ***********************************************************************/
  8502. +#ifdef CONFIG_CPU_COPY_FA
  8503. +# ifdef _USER
  8504. +# define MULTI_USER 1
  8505. +# else
  8506. +# define _USER fa
  8507. +# endif
  8508. +#endif
  8509. +/***********************************************************************/
  8510. +
  8511. #ifdef CONFIG_CPU_SA1100
  8512. # ifdef _USER
  8513. # define MULTI_USER 1
  8514. --- a/include/asm-arm/proc-fns.h
  8515. +++ b/include/asm-arm/proc-fns.h
  8516. @@ -89,6 +89,14 @@
  8517. # define CPU_NAME cpu_arm922
  8518. # endif
  8519. # endif
  8520. +# ifdef CONFIG_CPU_FA526
  8521. +# ifdef CPU_NAME
  8522. +# undef MULTI_CPU
  8523. +# define MULTI_CPU
  8524. +# else
  8525. +# define CPU_NAME cpu_fa526
  8526. +# endif
  8527. +# endif
  8528. # ifdef CONFIG_CPU_ARM925T
  8529. # ifdef CPU_NAME
  8530. # undef MULTI_CPU
  8531. --- a/include/asm-arm/tlbflush.h
  8532. +++ b/include/asm-arm/tlbflush.h
  8533. @@ -39,6 +39,8 @@
  8534. #define TLB_V6_D_ASID (1 << 17)
  8535. #define TLB_V6_I_ASID (1 << 18)
  8536. +#define TLB_DINVAL (1 << 28)
  8537. +#define TLB_BTB (1 << 29)
  8538. #define TLB_DCLEAN (1 << 30)
  8539. #define TLB_WB (1 << 31)
  8540. @@ -52,6 +54,7 @@
  8541. * v4wb - ARMv4 with write buffer without I TLB flush entry instruction
  8542. * v4wbi - ARMv4 with write buffer with I TLB flush entry instruction
  8543. * v6wbi - ARMv6 with write buffer with I TLB flush entry instruction
  8544. + * fa - ARMv4 with write buffer with UTLB and branch target buffer (BTB)
  8545. */
  8546. #undef _TLB
  8547. #undef MULTI_TLB
  8548. @@ -86,6 +89,44 @@
  8549. # define v4_always_flags (-1UL)
  8550. #endif
  8551. +#ifdef CONFIG_CPU_FA_BTB
  8552. +#define __TLB_BTB TLB_BTB
  8553. +#else
  8554. +#define __TLB_BTB 0
  8555. +#endif
  8556. +
  8557. +#ifdef CONFIG_CPU_FA_WB_DISABLE
  8558. +#define __TLB_WB 0
  8559. +#else
  8560. +#define __TLB_WB TLB_WB
  8561. +#endif
  8562. +
  8563. +/* Fix buggy CPU which doesn't invalidate Dcache properly */
  8564. +#ifdef CONFIG_CPU_FA520
  8565. +#define __TLB_DINVAL TLB_DINVAL
  8566. +#elif defined(CONFIG_CPU_FA526)
  8567. +//#define __TLB_DINVAL TLB_DINVAL
  8568. +#define __TLB_DINVAL 0
  8569. +#else
  8570. +#define __TLB_DINVAL 0
  8571. +#endif
  8572. +
  8573. +#define fa_tlb_flags (__TLB_WB | __TLB_BTB | __TLB_DINVAL | TLB_DCLEAN | \
  8574. + TLB_V4_U_FULL | TLB_V4_U_PAGE)
  8575. +
  8576. +#ifdef CONFIG_CPU_TLB_FA
  8577. +# define fa_possible_flags fa_tlb_flags
  8578. +# define fa_always_flags fa_tlb_flags
  8579. +# ifdef _TLB
  8580. +# define MULTI_TLB 1
  8581. +# else
  8582. +# define _TLB fa
  8583. +# endif
  8584. +#else
  8585. +# define fa_possible_flags 0
  8586. +# define fa_always_flags (-1UL)
  8587. +#endif
  8588. +
  8589. #define v4wbi_tlb_flags (TLB_WB | TLB_DCLEAN | \
  8590. TLB_V4_I_FULL | TLB_V4_D_FULL | \
  8591. TLB_V4_I_PAGE | TLB_V4_D_PAGE)
  8592. @@ -246,12 +287,14 @@ extern struct cpu_tlb_fns cpu_tlb;
  8593. v4_possible_flags | \
  8594. v4wbi_possible_flags | \
  8595. v4wb_possible_flags | \
  8596. + fa_possible_flags | \
  8597. v6wbi_possible_flags)
  8598. #define always_tlb_flags (v3_always_flags & \
  8599. v4_always_flags & \
  8600. v4wbi_always_flags & \
  8601. v4wb_always_flags & \
  8602. + fa_always_flags & \
  8603. v6wbi_always_flags)
  8604. #define tlb_flag(f) ((always_tlb_flags & (f)) || (__tlb_flag & possible_tlb_flags & (f)))
  8605. @@ -261,6 +304,9 @@ static inline void local_flush_tlb_all(v
  8606. const int zero = 0;
  8607. const unsigned int __tlb_flag = __cpu_tlb_flags;
  8608. + if (tlb_flag(TLB_DINVAL))
  8609. + asm("mcr%? p15, 0, %0, c7, c14, 0" : : "r" (zero));
  8610. +
  8611. if (tlb_flag(TLB_WB))
  8612. dsb();
  8613. @@ -281,6 +327,13 @@ static inline void local_flush_tlb_all(v
  8614. dsb();
  8615. isb();
  8616. }
  8617. +
  8618. + if (tlb_flag(TLB_BTB))
  8619. + {
  8620. + asm("mcr%? p15, 0, %0, c7, c5, 6" : : "r" (zero));
  8621. + asm("mov r0, r0" : : );
  8622. + asm("mov r0, r0" : : );
  8623. + }
  8624. }
  8625. static inline void local_flush_tlb_mm(struct mm_struct *mm)
  8626. @@ -289,6 +342,9 @@ static inline void local_flush_tlb_mm(st
  8627. const int asid = ASID(mm);
  8628. const unsigned int __tlb_flag = __cpu_tlb_flags;
  8629. + if (tlb_flag(TLB_DINVAL))
  8630. + asm("mcr%? p15, 0, %0, c7, c14, 0" : : "r" (zero));
  8631. +
  8632. if (tlb_flag(TLB_WB))
  8633. dsb();
  8634. @@ -317,6 +373,14 @@ static inline void local_flush_tlb_mm(st
  8635. asm("mcr p15, 0, %0, c7, c5, 6" : : "r" (zero) : "cc");
  8636. dsb();
  8637. }
  8638. +
  8639. + if (tlb_flag(TLB_BTB))
  8640. + {
  8641. + asm("mcr%? p15, 0, %0, c7, c5, 6" : : "r" (zero));
  8642. + asm("mov r0, r0" : : );
  8643. + asm("mov r0, r0" : : );
  8644. + }
  8645. +
  8646. }
  8647. static inline void
  8648. @@ -327,6 +391,9 @@ local_flush_tlb_page(struct vm_area_stru
  8649. uaddr = (uaddr & PAGE_MASK) | ASID(vma->vm_mm);
  8650. + if (tlb_flag(TLB_DINVAL))
  8651. + asm("mcr%? p15, 0, %0, c7, c14, 0" : : "r" (zero)); // clean & invalidate data cache all
  8652. +
  8653. if (tlb_flag(TLB_WB))
  8654. dsb();
  8655. @@ -357,6 +424,13 @@ local_flush_tlb_page(struct vm_area_stru
  8656. asm("mcr p15, 0, %0, c7, c5, 6" : : "r" (zero) : "cc");
  8657. dsb();
  8658. }
  8659. +
  8660. + if (tlb_flag(TLB_BTB))
  8661. + {
  8662. + asm("mcr%? p15, 0, %0, c7, c5, 6" : : "r" (zero));
  8663. + asm("mov r0, r0" : : );
  8664. + asm("mov r0, r0" : : );
  8665. + }
  8666. }
  8667. static inline void local_flush_tlb_kernel_page(unsigned long kaddr)
  8668. @@ -366,6 +440,9 @@ static inline void local_flush_tlb_kerne
  8669. kaddr &= PAGE_MASK;
  8670. + if (tlb_flag(TLB_DINVAL))
  8671. + asm("mcr%? p15, 0, %0, c7, c14, 0" : : "r" (zero));
  8672. +
  8673. if (tlb_flag(TLB_WB))
  8674. dsb();
  8675. @@ -386,6 +463,12 @@ static inline void local_flush_tlb_kerne
  8676. asm("mcr p15, 0, %0, c8, c6, 1" : : "r" (kaddr) : "cc");
  8677. if (tlb_flag(TLB_V6_I_PAGE))
  8678. asm("mcr p15, 0, %0, c8, c5, 1" : : "r" (kaddr) : "cc");
  8679. + if (tlb_flag(TLB_BTB))
  8680. + {
  8681. + asm("mcr%? p15, 0, %0, c7, c5, 6" : : "r" (zero));
  8682. + asm("mov r0, r0" : : );
  8683. + asm("mov r0, r0" : : );
  8684. + }
  8685. if (tlb_flag(TLB_V6_I_FULL | TLB_V6_D_FULL |
  8686. TLB_V6_I_PAGE | TLB_V6_D_PAGE |
  8687. @@ -412,6 +495,7 @@ static inline void local_flush_tlb_kerne
  8688. */
  8689. static inline void flush_pmd_entry(pmd_t *pmd)
  8690. {
  8691. + const unsigned int zero = 0;
  8692. const unsigned int __tlb_flag = __cpu_tlb_flags;
  8693. if (tlb_flag(TLB_DCLEAN))
  8694. @@ -419,15 +503,30 @@ static inline void flush_pmd_entry(pmd_t
  8695. : : "r" (pmd) : "cc");
  8696. if (tlb_flag(TLB_WB))
  8697. dsb();
  8698. +
  8699. + if (tlb_flag(TLB_BTB)) // Luke Lee 05/16/2005
  8700. + {
  8701. + asm("mcr%? p15, 0, %0, c7, c5, 6" : : "r" (zero));
  8702. + asm("mov r0, r0" : : );
  8703. + asm("mov r0, r0" : : );
  8704. + }
  8705. }
  8706. static inline void clean_pmd_entry(pmd_t *pmd)
  8707. {
  8708. + const unsigned int zero = 0; // Luke Lee 05/16/2005 ins 1
  8709. const unsigned int __tlb_flag = __cpu_tlb_flags;
  8710. if (tlb_flag(TLB_DCLEAN))
  8711. asm("mcr p15, 0, %0, c7, c10, 1 @ flush_pmd"
  8712. : : "r" (pmd) : "cc");
  8713. +
  8714. + if (tlb_flag(TLB_BTB)) // Luke Lee 05/16/2005
  8715. + {
  8716. + asm("mcr%? p15, 0, %0, c7, c5, 6" : : "r" (zero));
  8717. + asm("mov r0, r0" : : );
  8718. + asm("mov r0, r0" : : );
  8719. + }
  8720. }
  8721. #undef tlb_flag
  8722. --- a/include/asm-arm/xor.h
  8723. +++ b/include/asm-arm/xor.h
  8724. @@ -139,3 +139,18 @@ static struct xor_block_template xor_blo
  8725. xor_speed(&xor_block_8regs); \
  8726. xor_speed(&xor_block_32regs); \
  8727. } while (0)
  8728. +
  8729. +#ifdef CONFIG_GEMINI_XOR_ACCE
  8730. +#include <asm/arch/xor.h>
  8731. +static struct xor_block_template xor_block_gemini = {
  8732. + .name = "gemini xor acceleration",
  8733. + .do_2 = xor_gemini_2,
  8734. + .do_3 = xor_gemini_3,
  8735. + .do_4 = xor_gemini_4,
  8736. + .do_5 = xor_gemini_5,};
  8737. +#undef XOR_TRY_TEMPLATES
  8738. +#define XOR_TRY_TEMPLATES \
  8739. + do { \
  8740. + xor_speed(&xor_block_gemini); \
  8741. + } while (0)
  8742. +#endif
  8743. --- a/include/linux/apm_bios.h
  8744. +++ b/include/linux/apm_bios.h
  8745. @@ -217,4 +217,24 @@ extern struct apm_info apm_info;
  8746. #define APM_IOC_STANDBY _IO('A', 1)
  8747. #define APM_IOC_SUSPEND _IO('A', 2)
  8748. +// add by jason for power control
  8749. +struct pwc_ioctl_data {
  8750. + unsigned int action; // sword struct
  8751. + unsigned int data; // stand shutdown time for PWC_SET_SHUT_TIME
  8752. + // stand shutdown source for PWC_WAIT_BTN
  8753. +};
  8754. +
  8755. +#define POWEROFF 0x01
  8756. +#define RESTORE_DEFAULT 0x02
  8757. +#define SYSTEM_REBOOT 0x04
  8758. +
  8759. +#define PWR_SRC_CIR 0x10
  8760. +#define PWR_SRC_RTC 0x20
  8761. +#define PWR_SRC_BTN 0x40
  8762. +
  8763. +#define PWC_IOCTL_BASE 'A' // use linux APM ioctl
  8764. +#define PWC_SET_SHUT_TIME _IOW('A', 16, struct pwc_ioctl_data)
  8765. +#define PWC_WAIT_BTN _IOR('A', 17, struct pwc_ioctl_data)
  8766. +#define PWC_SHUTDOWN _IO ('A', 18)
  8767. +
  8768. #endif /* LINUX_APM_H */
  8769. --- a/kernel/time.c
  8770. +++ b/kernel/time.c
  8771. @@ -76,6 +76,7 @@ asmlinkage long sys_time(time_t __user *
  8772. * why not move it into the appropriate arch directory (for those
  8773. * architectures that need it).
  8774. */
  8775. +extern void rtc_set_time_second(unsigned int second);
  8776. asmlinkage long sys_stime(time_t __user *tptr)
  8777. {
  8778. @@ -87,6 +88,10 @@ asmlinkage long sys_stime(time_t __user
  8779. tv.tv_nsec = 0;
  8780. +#ifdef CONFIG_SL2312_RTC
  8781. + rtc_set_time_second(tv.tv_sec);
  8782. +#endif
  8783. +
  8784. err = security_settime(&tv, NULL);
  8785. if (err)
  8786. return err;