2
1

002-patch-2.4.26-vrs1-lnode80 435 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498
  1. diff -urN linux-2.4.26/arch/arm/boot/compressed/head.S linux-2.4.26-vrs1-lnode80/arch/arm/boot/compressed/head.S
  2. --- linux-2.4.26/arch/arm/boot/compressed/head.S 2005-11-02 16:54:16.000000000 -0400
  3. +++ linux-2.4.26-vrs1-lnode80/arch/arm/boot/compressed/head.S 2005-11-02 17:37:31.000000000 -0400
  4. @@ -17,6 +17,7 @@
  5. * 100% relocatable. Any attempt to do so will result in a crash.
  6. * Please select one of the following when turning on debugging.
  7. */
  8. +#define DEBUG
  9. #ifdef DEBUG
  10. #if defined(CONFIG_DEBUG_DC21285_PORT)
  11. .macro loadsp, rb
  12. @@ -81,6 +82,20 @@
  13. */
  14. str \rb, [r3, #0x14] @ UTDR
  15. .endm
  16. +#elif 1 /* Sharp LH79520-type */
  17. + .macro loadsp, rb
  18. + ldr \rb, =0xfffc0000 @ UART1 base
  19. + .endm
  20. + .macro writeb, rb
  21. + strb \rb, [r3, #0]
  22. + .endm
  23. +#elif 0 /* Sharp LH7A400-type */
  24. + .macro loadsp, rb
  25. + ldr \rb, =0x80000700 @ UART1 base
  26. + .endm
  27. + .macro writeb, rb
  28. + strb \rb, [r3, #0]
  29. + .endm
  30. #else
  31. #error no serial architecture defined
  32. #endif
  33. @@ -97,6 +112,7 @@
  34. bl phex
  35. .endm
  36. +#undef DEBUG
  37. .macro debug_reloc_start
  38. #ifdef DEBUG
  39. kputc #'\n'
  40. @@ -140,7 +156,9 @@
  41. .word 0x016f2818 @ Magic numbers to help the loader
  42. .word start @ absolute load/run zImage address
  43. .word _edata @ zImage end address
  44. -1: mov r7, r1 @ save architecture ID
  45. +1: @mov r7, r1 @ save architecture ID
  46. + mov r7, #0x300
  47. + orr r7,r7,#0xe7
  48. mov r8, #0 @ save r0
  49. #ifndef __ARM_ARCH_2__
  50. @@ -314,6 +332,11 @@
  51. LC1: .word reloc_end - reloc_start
  52. .size LC0, . - LC0
  53. + .type proc_lh7a400_type,#object
  54. +proc_lh7a400_type:
  55. + .word 0x41029220
  56. + .size proc_lh7a400_type, . - proc_lh7a400_type
  57. +
  58. /*
  59. * Turn on the cache. We need to setup some page tables so that we
  60. * can have both the I and D caches on.
  61. diff -urN linux-2.4.26/arch/arm/boot/Makefile linux-2.4.26-vrs1-lnode80/arch/arm/boot/Makefile
  62. --- linux-2.4.26/arch/arm/boot/Makefile 2003-08-25 07:44:39.000000000 -0400
  63. +++ linux-2.4.26-vrs1-lnode80/arch/arm/boot/Makefile 2005-11-02 17:37:31.000000000 -0400
  64. @@ -101,6 +101,24 @@
  65. INITRD_VIRT = 0x0C800000
  66. endif
  67. +ifeq ($(CONFIG_ARCH_LH79520),y)
  68. + ZTEXTADDR = 0x20008000
  69. + ZBSSADDR = 0x20200000
  70. + ZRELADDR = 0x20008000
  71. + INITRD_PHYS = 0x20400000
  72. + INITRD_VIRT = 0xC0400000
  73. + PARAMS_PHYS = 0x20110000
  74. +endif
  75. +
  76. +ifeq ($(CONFIG_ARCH_LH7A400),y)
  77. + ZTEXTADDR = 0xC0008000
  78. + ZBSSADDR = 0xC0200000
  79. + ZRELADDR = 0xC0008000
  80. + INITRD_PHYS = 0xC4000000
  81. + INITRD_VIRT = 0xC4000000
  82. + PARAMS_PHYS = 0xC0000100
  83. +endif
  84. +
  85. ifeq ($(CONFIG_ARCH_SA1100),y)
  86. ZRELADDR = 0xc0008000
  87. # No defconfig file to move this into...
  88. diff -urN linux-2.4.26/arch/arm/config.in linux-2.4.26-vrs1-lnode80/arch/arm/config.in
  89. --- linux-2.4.26/arch/arm/config.in 2005-11-02 16:54:16.000000000 -0400
  90. +++ linux-2.4.26-vrs1-lnode80/arch/arm/config.in 2005-11-02 17:37:31.000000000 -0400
  91. @@ -48,6 +48,8 @@
  92. RiscPC CONFIG_ARCH_RPC \
  93. RiscStation CONFIG_ARCH_RISCSTATION \
  94. SA1100-based CONFIG_ARCH_SA1100 \
  95. + LH79520-based CONFIG_ARCH_LH79520 \
  96. + LH7A400-based CONFIG_ARCH_LH7A400 \
  97. Shark CONFIG_ARCH_SHARK \
  98. AT91RM9200-based CONFIG_ARCH_AT91RM9200 " RiscPC
  99. @@ -182,6 +184,17 @@
  100. endmenu
  101. +mainmenu_option next_comment
  102. +comment 'Sharp LH79520 Implementations'
  103. +dep_bool ' LH79520 EVB' CONFIG_LH79520_EVB $CONFIG_ARCH_LH79520
  104. +dep_bool ' 520 BOGUS EVB' CONFIG_BOGON_EVB $CONFIG_ARCH_LH79520
  105. +endmenu
  106. +
  107. +mainmenu_option next_comment
  108. +comment 'Sharp LH7A400 Implementations'
  109. +dep_bool ' LH7A400 EVB' CONFIG_LH7A400_EVB $CONFIG_ARCH_LH7A400
  110. +endmenu
  111. +
  112. # Definitions to make life easier
  113. if [ "$CONFIG_ARCH_ARCA5K" = "y" -o \
  114. "$CONFIG_ARCH_RPC" = "y" ]; then
  115. @@ -295,6 +308,7 @@
  116. # ARM720T
  117. if [ "$CONFIG_ARCH_CLPS711X" = "y" -o \
  118. "$CONFIG_ARCH_L7200" = "y" -o \
  119. + "$CONFIG_ARCH_LH79520" = "y" -o \
  120. "$CONFIG_ARCH_CDB89712" = "y" ]; then
  121. define_bool CONFIG_CPU_ARM720T y
  122. else
  123. @@ -320,7 +334,8 @@
  124. # ARM922T
  125. -if [ "$CONFIG_ARCH_CAMELOT" = "y" ]; then
  126. +if [ "$CONFIG_ARCH_CAMELOT" = "y" -o \
  127. + "$CONFIG_ARCH_LH7A400" = "y" ]; then
  128. define_bool CONFIG_CPU_ARM922T y
  129. else
  130. if [ "$CONFIG_ARCH_INTEGRATOR" = "y" ]; then
  131. @@ -399,6 +414,7 @@
  132. "$CONFIG_ARCH_TBOX" = "y" -o "$CONFIG_ARCH_SHARK" = "y" -o \
  133. "$CONFIG_ARCH_NEXUSPCI" = "y" -o "$CONFIG_ARCH_CLPS711X" = "y" -o \
  134. "$CONFIG_ARCH_INTEGRATOR" = "y" -o "$CONFIG_ARCH_SA1100" = "y" -o \
  135. + "$CONFIG_ARCH_LH79520" = "y" -o "$CONFIG_ARCH_LH7A400" = "y" -o \
  136. "$CONFIG_ARCH_L7200" = "y" -o "$CONFIG_ARCH_ANAKIN" = "y" -o \
  137. "$CONFIG_ARCH_CAMELOT" = "y" -o "$CONFIG_ARCH_MX1ADS" = "y" -o \
  138. "$CONFIG_ARCH_OMAHA" = "y" -o "$CONFIG_ARCH_AT91RM9200" = "y" ]; then
  139. @@ -440,6 +456,8 @@
  140. # Select various configuration options depending on the machine type
  141. if [ "$CONFIG_ARCH_EDB7211" = "y" -o \
  142. + "$CONFIG_ARCH_LH79520" = "y" -o \
  143. + "$CONFIG_ARCH_LH7A400" = "y" -o \
  144. "$CONFIG_ARCH_SA1100" = "y" -o \
  145. "$CONFIG_ARCH_RISCSTATION" = "y" ]; then
  146. define_bool CONFIG_DISCONTIGMEM y
  147. @@ -473,6 +491,8 @@
  148. "$CONFIG_ARCH_EBSA110" = "y" -o \
  149. "$CONFIG_ARCH_CDB89712" = "y" -o \
  150. "$CONFIG_ARCH_EDB7211" = "y" -o \
  151. + "$CONFIG_ARCH_LH79520" = "y" -o \
  152. + "$CONFIG_ARCH_LH7A400" = "y" -o \
  153. "$CONFIG_ARCH_SA1100" = "y" ]; then
  154. define_bool CONFIG_ISA y
  155. else
  156. @@ -690,6 +710,8 @@
  157. "$CONFIG_ARCH_TBOX" = "y" -o \
  158. "$CONFIG_ARCH_CLPS7500" = "y" -o \
  159. "$CONFIG_ARCH_P720T" = "y" -o \
  160. + "$CONFIG_ARCH_LH79520" = "y" -o \
  161. + "$CONFIG_ARCH_LH7A400" = "y" -o \
  162. "$CONFIG_ARCH_ANAKIN" = "y" -o \
  163. "$CONFIG_ARCH_MX1ADS" = "y" ]; then
  164. define_bool CONFIG_PC_KEYMAP y
  165. @@ -707,6 +729,8 @@
  166. "$CONFIG_ARCH_TBOX" = "y" -o \
  167. "$CONFIG_ARCH_SHARK" = "y" -o \
  168. "$CONFIG_ARCH_SA1100" = "y" -o \
  169. + "$CONFIG_ARCH_LH79520" = "y" -o \
  170. + "$CONFIG_ARCH_LH7A400" = "y" -o \
  171. "$CONFIG_PCI" = "y" ]; then
  172. mainmenu_option next_comment
  173. comment 'Sound'
  174. diff -urN linux-2.4.26/arch/arm/def-configs/lnode80 linux-2.4.26-vrs1-lnode80/arch/arm/def-configs/lnode80
  175. --- linux-2.4.26/arch/arm/def-configs/lnode80 1969-12-31 20:00:00.000000000 -0400
  176. +++ linux-2.4.26-vrs1-lnode80/arch/arm/def-configs/lnode80 2005-11-03 09:11:23.000000000 -0400
  177. @@ -0,0 +1,804 @@
  178. +#
  179. +# Automatically generated make config: don't edit
  180. +#
  181. +CONFIG_ARM=y
  182. +# CONFIG_EISA is not set
  183. +# CONFIG_SBUS is not set
  184. +# CONFIG_MCA is not set
  185. +CONFIG_UID16=y
  186. +CONFIG_RWSEM_GENERIC_SPINLOCK=y
  187. +# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
  188. +# CONFIG_GENERIC_BUST_SPINLOCK is not set
  189. +# CONFIG_GENERIC_ISA_DMA is not set
  190. +
  191. +#
  192. +# Code maturity level options
  193. +#
  194. +CONFIG_EXPERIMENTAL=y
  195. +# CONFIG_OBSOLETE is not set
  196. +
  197. +#
  198. +# Loadable module support
  199. +#
  200. +CONFIG_MODULES=y
  201. +# CONFIG_MODVERSIONS is not set
  202. +# CONFIG_KMOD is not set
  203. +
  204. +#
  205. +# System Type
  206. +#
  207. +# CONFIG_ARCH_ANAKIN is not set
  208. +# CONFIG_ARCH_ARCA5K is not set
  209. +# CONFIG_ARCH_CLPS7500 is not set
  210. +# CONFIG_ARCH_CLPS711X is not set
  211. +# CONFIG_ARCH_CO285 is not set
  212. +# CONFIG_ARCH_EBSA110 is not set
  213. +# CONFIG_ARCH_CAMELOT is not set
  214. +# CONFIG_ARCH_FOOTBRIDGE is not set
  215. +# CONFIG_ARCH_INTEGRATOR is not set
  216. +# CONFIG_ARCH_OMAHA is not set
  217. +# CONFIG_ARCH_L7200 is not set
  218. +# CONFIG_ARCH_MX1ADS is not set
  219. +# CONFIG_ARCH_RPC is not set
  220. +# CONFIG_ARCH_RISCSTATION is not set
  221. +# CONFIG_ARCH_SA1100 is not set
  222. +CONFIG_ARCH_LH79520=y
  223. +# CONFIG_ARCH_LH7A400 is not set
  224. +# CONFIG_ARCH_SHARK is not set
  225. +# CONFIG_ARCH_AT91RM9200 is not set
  226. +
  227. +#
  228. +# Archimedes/A5000 Implementations
  229. +#
  230. +
  231. +#
  232. +# Archimedes/A5000 Implementations (select only ONE)
  233. +#
  234. +# CONFIG_ARCH_ARC is not set
  235. +# CONFIG_ARCH_A5K is not set
  236. +
  237. +#
  238. +# Footbridge Implementations
  239. +#
  240. +# CONFIG_ARCH_CATS is not set
  241. +# CONFIG_ARCH_PERSONAL_SERVER is not set
  242. +# CONFIG_ARCH_EBSA285_ADDIN is not set
  243. +# CONFIG_ARCH_EBSA285_HOST is not set
  244. +# CONFIG_ARCH_NETWINDER is not set
  245. +
  246. +#
  247. +# SA11x0 Implementations
  248. +#
  249. +# CONFIG_SA1100_ACCELENT is not set
  250. +# CONFIG_SA1100_ASSABET is not set
  251. +# CONFIG_ASSABET_NEPONSET is not set
  252. +# CONFIG_SA1100_ADSAGC is not set
  253. +# CONFIG_SA1100_ADSBITSY is not set
  254. +# CONFIG_SA1100_ADSBITSYPLUS is not set
  255. +# CONFIG_SA1100_BRUTUS is not set
  256. +# CONFIG_SA1100_CEP is not set
  257. +# CONFIG_SA1100_CERF is not set
  258. +# CONFIG_SA1100_H3100 is not set
  259. +# CONFIG_SA1100_H3600 is not set
  260. +# CONFIG_SA1100_H3800 is not set
  261. +# CONFIG_SA1100_H3XXX is not set
  262. +# CONFIG_H3600_SLEEVE is not set
  263. +# CONFIG_SA1100_EXTENEX1 is not set
  264. +# CONFIG_SA1100_FLEXANET is not set
  265. +# CONFIG_SA1100_FREEBIRD is not set
  266. +# CONFIG_SA1100_FRODO is not set
  267. +# CONFIG_SA1100_GRAPHICSCLIENT is not set
  268. +# CONFIG_SA1100_GRAPHICSMASTER is not set
  269. +# CONFIG_SA1100_HACKKIT is not set
  270. +# CONFIG_SA1100_BADGE4 is not set
  271. +# CONFIG_SA1100_JORNADA720 is not set
  272. +# CONFIG_SA1100_HUW_WEBPANEL is not set
  273. +# CONFIG_SA1100_ITSY is not set
  274. +# CONFIG_SA1100_LART is not set
  275. +# CONFIG_SA1100_NANOENGINE is not set
  276. +# CONFIG_SA1100_OMNIMETER is not set
  277. +# CONFIG_SA1100_PANGOLIN is not set
  278. +# CONFIG_SA1100_PLEB is not set
  279. +# CONFIG_SA1100_PT_SYSTEM3 is not set
  280. +# CONFIG_SA1100_SHANNON is not set
  281. +# CONFIG_SA1100_SHERMAN is not set
  282. +# CONFIG_SA1100_SIMPAD is not set
  283. +# CONFIG_SA1100_SIMPUTER is not set
  284. +# CONFIG_SA1100_PFS168 is not set
  285. +# CONFIG_SA1100_VICTOR is not set
  286. +# CONFIG_SA1100_XP860 is not set
  287. +# CONFIG_SA1100_YOPY is not set
  288. +# CONFIG_SA1100_USB is not set
  289. +# CONFIG_SA1100_USB_NETLINK is not set
  290. +# CONFIG_SA1100_USB_CHAR is not set
  291. +# CONFIG_SA1100_SSP is not set
  292. +
  293. +#
  294. +# AT91RM9200 Implementations
  295. +#
  296. +# CONFIG_ARCH_AT91RM9200DK is not set
  297. +# CONFIG_MACH_CSB337 is not set
  298. +
  299. +#
  300. +# CLPS711X/EP721X Implementations
  301. +#
  302. +# CONFIG_ARCH_AUTCPU12 is not set
  303. +# CONFIG_ARCH_CDB89712 is not set
  304. +# CONFIG_ARCH_CLEP7312 is not set
  305. +# CONFIG_ARCH_EDB7211 is not set
  306. +# CONFIG_ARCH_FORTUNET is not set
  307. +# CONFIG_ARCH_GUIDEA07 is not set
  308. +# CONFIG_ARCH_P720T is not set
  309. +# CONFIG_ARCH_EP7211 is not set
  310. +# CONFIG_ARCH_EP7212 is not set
  311. +
  312. +#
  313. +# Sharp LH79520 Implementations
  314. +#
  315. +CONFIG_LH79520_EVB=y
  316. +# CONFIG_BOGON_EVB is not set
  317. +
  318. +#
  319. +# Sharp LH7A400 Implementations
  320. +#
  321. +# CONFIG_LH7A400_EVB is not set
  322. +# CONFIG_ARCH_ACORN is not set
  323. +# CONFIG_PLD is not set
  324. +# CONFIG_FOOTBRIDGE is not set
  325. +# CONFIG_FOOTBRIDGE_HOST is not set
  326. +# CONFIG_FOOTBRIDGE_ADDIN is not set
  327. +
  328. +#
  329. +# Processor Type
  330. +#
  331. +CONFIG_CPU_32=y
  332. +# CONFIG_CPU_26 is not set
  333. +# CONFIG_CPU_ARM610 is not set
  334. +# CONFIG_CPU_ARM710 is not set
  335. +CONFIG_CPU_ARM720T=y
  336. +# CONFIG_CPU_ARM920T is not set
  337. +# CONFIG_CPU_ARM922T is not set
  338. +# CONFIG_CPU_ARM926T is not set
  339. +# CONFIG_CPU_ARM1020 is not set
  340. +# CONFIG_CPU_ARM1020E is not set
  341. +# CONFIG_CPU_ARM1022 is not set
  342. +# CONFIG_CPU_ARM1026 is not set
  343. +# CONFIG_CPU_SA110 is not set
  344. +# CONFIG_CPU_SA1100 is not set
  345. +# CONFIG_CPU_32v3 is not set
  346. +CONFIG_CPU_32v4=y
  347. +
  348. +#
  349. +# Processor Features
  350. +#
  351. +CONFIG_ARM_THUMB=y
  352. +CONFIG_DISCONTIGMEM=y
  353. +
  354. +#
  355. +# General setup
  356. +#
  357. +# CONFIG_PCI is not set
  358. +CONFIG_ISA=y
  359. +# CONFIG_ISA_DMA is not set
  360. +# CONFIG_ZBOOT_ROM is not set
  361. +CONFIG_ZBOOT_ROM_TEXT=0
  362. +CONFIG_ZBOOT_ROM_BSS=0
  363. +# CONFIG_HOTPLUG is not set
  364. +# CONFIG_PCMCIA is not set
  365. +CONFIG_NET=y
  366. +CONFIG_SYSVIPC=y
  367. +# CONFIG_BSD_PROCESS_ACCT is not set
  368. +CONFIG_SYSCTL=y
  369. +
  370. +#
  371. +# At least one math emulation must be selected
  372. +#
  373. +CONFIG_FPE_NWFPE=y
  374. +# CONFIG_FPE_NWFPE_XP is not set
  375. +# CONFIG_FPE_FASTFPE is not set
  376. +CONFIG_KCORE_ELF=y
  377. +# CONFIG_KCORE_AOUT is not set
  378. +CONFIG_BINFMT_AOUT=y
  379. +CONFIG_BINFMT_ELF=y
  380. +# CONFIG_BINFMT_MISC is not set
  381. +# CONFIG_PM is not set
  382. +# CONFIG_ARTHUR is not set
  383. +CONFIG_CMDLINE=""
  384. +CONFIG_ALIGNMENT_TRAP=y
  385. +
  386. +#
  387. +# Parallel port support
  388. +#
  389. +# CONFIG_PARPORT is not set
  390. +
  391. +#
  392. +# Memory Technology Devices (MTD)
  393. +#
  394. +CONFIG_MTD=y
  395. +# CONFIG_MTD_DEBUG is not set
  396. +CONFIG_MTD_PARTITIONS=y
  397. +# CONFIG_MTD_CONCAT is not set
  398. +# CONFIG_MTD_REDBOOT_PARTS is not set
  399. +# CONFIG_MTD_CMDLINE_PARTS is not set
  400. +# CONFIG_MTD_AFS_PARTS is not set
  401. +
  402. +#
  403. +# User Modules And Translation Layers
  404. +#
  405. +CONFIG_MTD_CHAR=y
  406. +CONFIG_MTD_BLOCK=y
  407. +# CONFIG_FTL is not set
  408. +# CONFIG_NFTL is not set
  409. +
  410. +#
  411. +# RAM/ROM/Flash chip drivers
  412. +#
  413. +CONFIG_MTD_CFI=y
  414. +CONFIG_MTD_JEDECPROBE=y
  415. +CONFIG_MTD_GEN_PROBE=y
  416. +CONFIG_MTD_CFI_ADV_OPTIONS=y
  417. +CONFIG_MTD_CFI_NOSWAP=y
  418. +# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
  419. +# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
  420. +# CONFIG_MTD_CFI_GEOMETRY is not set
  421. +CONFIG_MTD_CFI_INTELEXT=y
  422. +# CONFIG_MTD_CFI_AMDSTD is not set
  423. +# CONFIG_MTD_CFI_STAA is not set
  424. +# CONFIG_MTD_RAM is not set
  425. +# CONFIG_MTD_ROM is not set
  426. +# CONFIG_MTD_ABSENT is not set
  427. +# CONFIG_MTD_OBSOLETE_CHIPS is not set
  428. +# CONFIG_MTD_AMDSTD is not set
  429. +# CONFIG_MTD_SHARP is not set
  430. +# CONFIG_MTD_JEDEC is not set
  431. +
  432. +#
  433. +# Mapping drivers for chip access
  434. +#
  435. +CONFIG_MTD_PHYSMAP=y
  436. +CONFIG_MTD_PHYSMAP_START=40400000
  437. +CONFIG_MTD_PHYSMAP_LEN=400000
  438. +CONFIG_MTD_PHYSMAP_BUSWIDTH=2
  439. +# CONFIG_MTD_NORA is not set
  440. +# CONFIG_MTD_ARM_INTEGRATOR is not set
  441. +# CONFIG_MTD_CDB89712 is not set
  442. +# CONFIG_MTD_SA1100 is not set
  443. +# CONFIG_MTD_DC21285 is not set
  444. +# CONFIG_MTD_IQ80310 is not set
  445. +# CONFIG_MTD_FORTUNET is not set
  446. +# CONFIG_MTD_EPXA is not set
  447. +# CONFIG_MTD_AUTCPU12 is not set
  448. +# CONFIG_MTD_EDB7312 is not set
  449. +# CONFIG_MTD_IMPA7 is not set
  450. +# CONFIG_MTD_CEIVA is not set
  451. +# CONFIG_MTD_PCI is not set
  452. +# CONFIG_MTD_PCMCIA is not set
  453. +
  454. +#
  455. +# Self-contained MTD device drivers
  456. +#
  457. +# CONFIG_MTD_PMC551 is not set
  458. +# CONFIG_MTD_SLRAM is not set
  459. +# CONFIG_MTD_MTDRAM is not set
  460. +# CONFIG_MTD_BLKMTD is not set
  461. +
  462. +#
  463. +# Disk-On-Chip Device Drivers
  464. +#
  465. +# CONFIG_MTD_DOC1000 is not set
  466. +# CONFIG_MTD_DOC2000 is not set
  467. +# CONFIG_MTD_DOC2001 is not set
  468. +# CONFIG_MTD_DOCPROBE is not set
  469. +
  470. +#
  471. +# NAND Flash Device Drivers
  472. +#
  473. +# CONFIG_MTD_NAND is not set
  474. +
  475. +#
  476. +# Plug and Play configuration
  477. +#
  478. +# CONFIG_PNP is not set
  479. +# CONFIG_ISAPNP is not set
  480. +
  481. +#
  482. +# Block devices
  483. +#
  484. +# CONFIG_BLK_DEV_FD is not set
  485. +# CONFIG_BLK_DEV_XD is not set
  486. +# CONFIG_PARIDE is not set
  487. +# CONFIG_BLK_CPQ_DA is not set
  488. +# CONFIG_BLK_CPQ_CISS_DA is not set
  489. +# CONFIG_CISS_SCSI_TAPE is not set
  490. +# CONFIG_CISS_MONITOR_THREAD is not set
  491. +# CONFIG_BLK_DEV_DAC960 is not set
  492. +# CONFIG_BLK_DEV_UMEM is not set
  493. +# CONFIG_BLK_DEV_LOOP is not set
  494. +# CONFIG_BLK_DEV_NBD is not set
  495. +CONFIG_BLK_DEV_RAM=y
  496. +CONFIG_BLK_DEV_RAM_SIZE=8192
  497. +CONFIG_BLK_DEV_INITRD=y
  498. +# CONFIG_BLK_STATS is not set
  499. +
  500. +#
  501. +# Multi-device support (RAID and LVM)
  502. +#
  503. +# CONFIG_MD is not set
  504. +# CONFIG_BLK_DEV_MD is not set
  505. +# CONFIG_MD_LINEAR is not set
  506. +# CONFIG_MD_RAID0 is not set
  507. +# CONFIG_MD_RAID1 is not set
  508. +# CONFIG_MD_RAID5 is not set
  509. +# CONFIG_MD_MULTIPATH is not set
  510. +# CONFIG_BLK_DEV_LVM is not set
  511. +
  512. +#
  513. +# Networking options
  514. +#
  515. +CONFIG_PACKET=y
  516. +# CONFIG_PACKET_MMAP is not set
  517. +# CONFIG_NETLINK_DEV is not set
  518. +# CONFIG_NETFILTER is not set
  519. +# CONFIG_FILTER is not set
  520. +CONFIG_UNIX=y
  521. +CONFIG_INET=y
  522. +# CONFIG_IP_MULTICAST is not set
  523. +# CONFIG_IP_ADVANCED_ROUTER is not set
  524. +# CONFIG_IP_PNP is not set
  525. +# CONFIG_NET_IPIP is not set
  526. +# CONFIG_NET_IPGRE is not set
  527. +# CONFIG_ARPD is not set
  528. +# CONFIG_INET_ECN is not set
  529. +# CONFIG_SYN_COOKIES is not set
  530. +# CONFIG_IPV6 is not set
  531. +# CONFIG_KHTTPD is not set
  532. +
  533. +#
  534. +# SCTP Configuration (EXPERIMENTAL)
  535. +#
  536. +# CONFIG_IP_SCTP is not set
  537. +# CONFIG_ATM is not set
  538. +# CONFIG_VLAN_8021Q is not set
  539. +
  540. +#
  541. +#
  542. +#
  543. +# CONFIG_IPX is not set
  544. +# CONFIG_ATALK is not set
  545. +
  546. +#
  547. +# Appletalk devices
  548. +#
  549. +# CONFIG_DEV_APPLETALK is not set
  550. +# CONFIG_DECNET is not set
  551. +# CONFIG_BRIDGE is not set
  552. +# CONFIG_X25 is not set
  553. +# CONFIG_LAPB is not set
  554. +# CONFIG_LLC is not set
  555. +# CONFIG_NET_DIVERT is not set
  556. +# CONFIG_ECONET is not set
  557. +# CONFIG_WAN_ROUTER is not set
  558. +# CONFIG_NET_FASTROUTE is not set
  559. +# CONFIG_NET_HW_FLOWCONTROL is not set
  560. +
  561. +#
  562. +# QoS and/or fair queueing
  563. +#
  564. +# CONFIG_NET_SCHED is not set
  565. +
  566. +#
  567. +# Network testing
  568. +#
  569. +# CONFIG_NET_PKTGEN is not set
  570. +
  571. +#
  572. +# Network device support
  573. +#
  574. +# CONFIG_NETDEVICES is not set
  575. +
  576. +#
  577. +# Amateur Radio support
  578. +#
  579. +# CONFIG_HAMRADIO is not set
  580. +
  581. +#
  582. +# IrDA (infrared) support
  583. +#
  584. +# CONFIG_IRDA is not set
  585. +
  586. +#
  587. +# ATA/ATAPI/MFM/RLL support
  588. +#
  589. +# CONFIG_IDE is not set
  590. +# CONFIG_BLK_DEV_HD is not set
  591. +
  592. +#
  593. +# SCSI support
  594. +#
  595. +# CONFIG_SCSI is not set
  596. +
  597. +#
  598. +# I2O device support
  599. +#
  600. +# CONFIG_I2O is not set
  601. +# CONFIG_I2O_BLOCK is not set
  602. +# CONFIG_I2O_LAN is not set
  603. +# CONFIG_I2O_SCSI is not set
  604. +# CONFIG_I2O_PROC is not set
  605. +
  606. +#
  607. +# ISDN subsystem
  608. +#
  609. +# CONFIG_ISDN is not set
  610. +
  611. +#
  612. +# Input core support
  613. +#
  614. +# CONFIG_INPUT is not set
  615. +# CONFIG_INPUT_KEYBDEV is not set
  616. +# CONFIG_INPUT_MOUSEDEV is not set
  617. +# CONFIG_INPUT_JOYDEV is not set
  618. +# CONFIG_INPUT_EVDEV is not set
  619. +# CONFIG_INPUT_UINPUT is not set
  620. +# CONFIG_INPUT_MX1TS is not set
  621. +
  622. +#
  623. +# Character devices
  624. +#
  625. +CONFIG_VT=y
  626. +CONFIG_VT_CONSOLE=y
  627. +# CONFIG_SERIAL is not set
  628. +# CONFIG_SERIAL_EXTENDED is not set
  629. +# CONFIG_SERIAL_NONSTANDARD is not set
  630. +
  631. +#
  632. +# Serial drivers
  633. +#
  634. +# CONFIG_SERIAL_ANAKIN is not set
  635. +# CONFIG_SERIAL_ANAKIN_CONSOLE is not set
  636. +# CONFIG_SERIAL_AMBA is not set
  637. +# CONFIG_SERIAL_AMBA_CONSOLE is not set
  638. +CONFIG_SERIAL_AMBA_PL011=y
  639. +CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
  640. +# CONFIG_SERIAL_LH7A400 is not set
  641. +# CONFIG_SERIAL_CLPS711X is not set
  642. +# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
  643. +# CONFIG_SERIAL_21285 is not set
  644. +# CONFIG_SERIAL_21285_OLD is not set
  645. +# CONFIG_SERIAL_21285_CONSOLE is not set
  646. +# CONFIG_SERIAL_UART00 is not set
  647. +# CONFIG_SERIAL_UART00_CONSOLE is not set
  648. +# CONFIG_SERIAL_SA1100 is not set
  649. +# CONFIG_SERIAL_SA1100_CONSOLE is not set
  650. +# CONFIG_SERIAL_OMAHA is not set
  651. +# CONFIG_SERIAL_OMAHA_CONSOLE is not set
  652. +# CONFIG_SERIAL_AT91 is not set
  653. +# CONFIG_SERIAL_AT91_CONSOLE is not set
  654. +# CONFIG_SERIAL_8250 is not set
  655. +# CONFIG_SERIAL_8250_CONSOLE is not set
  656. +# CONFIG_SERIAL_8250_EXTENDED is not set
  657. +# CONFIG_SERIAL_8250_MANY_PORTS is not set
  658. +# CONFIG_SERIAL_8250_SHARE_IRQ is not set
  659. +# CONFIG_SERIAL_8250_DETECT_IRQ is not set
  660. +# CONFIG_SERIAL_8250_MULTIPORT is not set
  661. +# CONFIG_SERIAL_8250_HUB6 is not set
  662. +CONFIG_SERIAL_CORE=y
  663. +CONFIG_SERIAL_CORE_CONSOLE=y
  664. +CONFIG_UNIX98_PTYS=y
  665. +CONFIG_UNIX98_PTY_COUNT=256
  666. +
  667. +#
  668. +# I2C support
  669. +#
  670. +# CONFIG_I2C is not set
  671. +
  672. +#
  673. +# L3 serial bus support
  674. +#
  675. +# CONFIG_L3 is not set
  676. +# CONFIG_L3_ALGOBIT is not set
  677. +# CONFIG_L3_BIT_SA1100_GPIO is not set
  678. +
  679. +#
  680. +# Other L3 adapters
  681. +#
  682. +# CONFIG_L3_SA1111 is not set
  683. +# CONFIG_BIT_SA1100_GPIO is not set
  684. +
  685. +#
  686. +# Mice
  687. +#
  688. +# CONFIG_BUSMOUSE is not set
  689. +CONFIG_MOUSE=y
  690. +CONFIG_PSMOUSE=y
  691. +# CONFIG_82C710_MOUSE is not set
  692. +# CONFIG_PC110_PAD is not set
  693. +# CONFIG_MK712_MOUSE is not set
  694. +
  695. +#
  696. +# Joysticks
  697. +#
  698. +# CONFIG_INPUT_GAMEPORT is not set
  699. +
  700. +#
  701. +# Input core support is needed for gameports
  702. +#
  703. +
  704. +#
  705. +# Input core support is needed for joysticks
  706. +#
  707. +# CONFIG_QIC02_TAPE is not set
  708. +# CONFIG_IPMI_HANDLER is not set
  709. +# CONFIG_IPMI_PANIC_EVENT is not set
  710. +# CONFIG_IPMI_DEVICE_INTERFACE is not set
  711. +# CONFIG_IPMI_KCS is not set
  712. +# CONFIG_IPMI_WATCHDOG is not set
  713. +
  714. +#
  715. +# Watchdog Cards
  716. +#
  717. +CONFIG_WATCHDOG=y
  718. +# CONFIG_WATCHDOG_NOWAYOUT is not set
  719. +# CONFIG_ACQUIRE_WDT is not set
  720. +# CONFIG_ADVANTECH_WDT is not set
  721. +# CONFIG_ALIM1535_WDT is not set
  722. +# CONFIG_ALIM7101_WDT is not set
  723. +# CONFIG_SC520_WDT is not set
  724. +# CONFIG_PCWATCHDOG is not set
  725. +# CONFIG_21285_WATCHDOG is not set
  726. +# CONFIG_977_WATCHDOG is not set
  727. +# CONFIG_SA1100_WATCHDOG is not set
  728. +# CONFIG_LH79520_WATCHDOG is not set
  729. +# CONFIG_EPXA_WATCHDOG is not set
  730. +# CONFIG_OMAHA_WATCHDOG is not set
  731. +# CONFIG_AT91_WATCHDOG is not set
  732. +# CONFIG_EUROTECH_WDT is not set
  733. +# CONFIG_IB700_WDT is not set
  734. +# CONFIG_WAFER_WDT is not set
  735. +# CONFIG_I810_TCO is not set
  736. +# CONFIG_MIXCOMWD is not set
  737. +# CONFIG_60XX_WDT is not set
  738. +# CONFIG_SC1200_WDT is not set
  739. +# CONFIG_SCx200_WDT is not set
  740. +# CONFIG_SOFT_WATCHDOG is not set
  741. +# CONFIG_W83877F_WDT is not set
  742. +# CONFIG_WDT is not set
  743. +# CONFIG_WDTPCI is not set
  744. +# CONFIG_MACHZ_WDT is not set
  745. +# CONFIG_AMD7XX_TCO is not set
  746. +# CONFIG_SCx200 is not set
  747. +# CONFIG_SCx200_GPIO is not set
  748. +# CONFIG_LH79520_PWM is not set
  749. +# CONFIG_AMD_PM768 is not set
  750. +# CONFIG_NVRAM is not set
  751. +# CONFIG_RTC is not set
  752. +# CONFIG_DTLK is not set
  753. +# CONFIG_R3964 is not set
  754. +# CONFIG_APPLICOM is not set
  755. +
  756. +#
  757. +# Ftape, the floppy tape device driver
  758. +#
  759. +# CONFIG_FTAPE is not set
  760. +# CONFIG_AGP is not set
  761. +
  762. +#
  763. +# Direct Rendering Manager (XFree86 DRI support)
  764. +#
  765. +# CONFIG_DRM is not set
  766. +
  767. +#
  768. +# Multimedia devices
  769. +#
  770. +# CONFIG_VIDEO_DEV is not set
  771. +
  772. +#
  773. +# File systems
  774. +#
  775. +# CONFIG_QUOTA is not set
  776. +# CONFIG_QFMT_V2 is not set
  777. +# CONFIG_AUTOFS_FS is not set
  778. +# CONFIG_AUTOFS4_FS is not set
  779. +# CONFIG_REISERFS_FS is not set
  780. +# CONFIG_REISERFS_CHECK is not set
  781. +# CONFIG_REISERFS_PROC_INFO is not set
  782. +# CONFIG_ADFS_FS is not set
  783. +# CONFIG_ADFS_FS_RW is not set
  784. +# CONFIG_AFFS_FS is not set
  785. +# CONFIG_HFS_FS is not set
  786. +# CONFIG_HFSPLUS_FS is not set
  787. +# CONFIG_BEFS_FS is not set
  788. +# CONFIG_BEFS_DEBUG is not set
  789. +# CONFIG_BFS_FS is not set
  790. +# CONFIG_EXT3_FS is not set
  791. +# CONFIG_JBD is not set
  792. +# CONFIG_JBD_DEBUG is not set
  793. +CONFIG_FAT_FS=y
  794. +# CONFIG_MSDOS_FS is not set
  795. +# CONFIG_UMSDOS_FS is not set
  796. +CONFIG_VFAT_FS=y
  797. +# CONFIG_EFS_FS is not set
  798. +# CONFIG_JFFS_FS is not set
  799. +CONFIG_JFFS2_FS=y
  800. +CONFIG_JFFS2_FS_DEBUG=0
  801. +# CONFIG_CRAMFS is not set
  802. +# CONFIG_TMPFS is not set
  803. +CONFIG_RAMFS=y
  804. +# CONFIG_ISO9660_FS is not set
  805. +# CONFIG_JOLIET is not set
  806. +# CONFIG_ZISOFS is not set
  807. +# CONFIG_JFS_FS is not set
  808. +# CONFIG_JFS_DEBUG is not set
  809. +# CONFIG_JFS_STATISTICS is not set
  810. +CONFIG_MINIX_FS=y
  811. +# CONFIG_VXFS_FS is not set
  812. +# CONFIG_NTFS_FS is not set
  813. +# CONFIG_NTFS_RW is not set
  814. +# CONFIG_HPFS_FS is not set
  815. +CONFIG_PROC_FS=y
  816. +# CONFIG_DEVFS_FS is not set
  817. +# CONFIG_DEVFS_MOUNT is not set
  818. +# CONFIG_DEVFS_DEBUG is not set
  819. +CONFIG_DEVPTS_FS=y
  820. +# CONFIG_QNX4FS_FS is not set
  821. +# CONFIG_QNX4FS_RW is not set
  822. +# CONFIG_ROMFS_FS is not set
  823. +CONFIG_EXT2_FS=y
  824. +# CONFIG_SYSV_FS is not set
  825. +# CONFIG_UDF_FS is not set
  826. +# CONFIG_UDF_RW is not set
  827. +# CONFIG_UFS_FS is not set
  828. +# CONFIG_UFS_FS_WRITE is not set
  829. +# CONFIG_XFS_FS is not set
  830. +# CONFIG_XFS_QUOTA is not set
  831. +# CONFIG_XFS_RT is not set
  832. +# CONFIG_XFS_TRACE is not set
  833. +# CONFIG_XFS_DEBUG is not set
  834. +
  835. +#
  836. +# Network File Systems
  837. +#
  838. +# CONFIG_CODA_FS is not set
  839. +# CONFIG_INTERMEZZO_FS is not set
  840. +# CONFIG_NFS_FS is not set
  841. +# CONFIG_NFS_V3 is not set
  842. +# CONFIG_NFS_DIRECTIO is not set
  843. +# CONFIG_ROOT_NFS is not set
  844. +# CONFIG_NFSD is not set
  845. +# CONFIG_NFSD_V3 is not set
  846. +# CONFIG_NFSD_TCP is not set
  847. +# CONFIG_SUNRPC is not set
  848. +# CONFIG_LOCKD is not set
  849. +# CONFIG_SMB_FS is not set
  850. +# CONFIG_NCP_FS is not set
  851. +# CONFIG_NCPFS_PACKET_SIGNING is not set
  852. +# CONFIG_NCPFS_IOCTL_LOCKING is not set
  853. +# CONFIG_NCPFS_STRONG is not set
  854. +# CONFIG_NCPFS_NFS_NS is not set
  855. +# CONFIG_NCPFS_OS2_NS is not set
  856. +# CONFIG_NCPFS_SMALLDOS is not set
  857. +# CONFIG_NCPFS_NLS is not set
  858. +# CONFIG_NCPFS_EXTRAS is not set
  859. +# CONFIG_ZISOFS_FS is not set
  860. +
  861. +#
  862. +# Partition Types
  863. +#
  864. +# CONFIG_PARTITION_ADVANCED is not set
  865. +CONFIG_MSDOS_PARTITION=y
  866. +# CONFIG_SMB_NLS is not set
  867. +CONFIG_NLS=y
  868. +
  869. +#
  870. +# Native Language Support
  871. +#
  872. +CONFIG_NLS_DEFAULT="iso8859-1"
  873. +# CONFIG_NLS_CODEPAGE_437 is not set
  874. +# CONFIG_NLS_CODEPAGE_737 is not set
  875. +# CONFIG_NLS_CODEPAGE_775 is not set
  876. +# CONFIG_NLS_CODEPAGE_850 is not set
  877. +# CONFIG_NLS_CODEPAGE_852 is not set
  878. +# CONFIG_NLS_CODEPAGE_855 is not set
  879. +# CONFIG_NLS_CODEPAGE_857 is not set
  880. +# CONFIG_NLS_CODEPAGE_860 is not set
  881. +# CONFIG_NLS_CODEPAGE_861 is not set
  882. +# CONFIG_NLS_CODEPAGE_862 is not set
  883. +# CONFIG_NLS_CODEPAGE_863 is not set
  884. +# CONFIG_NLS_CODEPAGE_864 is not set
  885. +# CONFIG_NLS_CODEPAGE_865 is not set
  886. +# CONFIG_NLS_CODEPAGE_866 is not set
  887. +# CONFIG_NLS_CODEPAGE_869 is not set
  888. +# CONFIG_NLS_CODEPAGE_936 is not set
  889. +# CONFIG_NLS_CODEPAGE_950 is not set
  890. +# CONFIG_NLS_CODEPAGE_932 is not set
  891. +# CONFIG_NLS_CODEPAGE_949 is not set
  892. +# CONFIG_NLS_CODEPAGE_874 is not set
  893. +# CONFIG_NLS_ISO8859_8 is not set
  894. +# CONFIG_NLS_CODEPAGE_1250 is not set
  895. +# CONFIG_NLS_CODEPAGE_1251 is not set
  896. +# CONFIG_NLS_ISO8859_1 is not set
  897. +# CONFIG_NLS_ISO8859_2 is not set
  898. +# CONFIG_NLS_ISO8859_3 is not set
  899. +# CONFIG_NLS_ISO8859_4 is not set
  900. +# CONFIG_NLS_ISO8859_5 is not set
  901. +# CONFIG_NLS_ISO8859_6 is not set
  902. +# CONFIG_NLS_ISO8859_7 is not set
  903. +# CONFIG_NLS_ISO8859_9 is not set
  904. +# CONFIG_NLS_ISO8859_13 is not set
  905. +# CONFIG_NLS_ISO8859_14 is not set
  906. +# CONFIG_NLS_ISO8859_15 is not set
  907. +# CONFIG_NLS_KOI8_R is not set
  908. +# CONFIG_NLS_KOI8_U is not set
  909. +# CONFIG_NLS_UTF8 is not set
  910. +
  911. +#
  912. +# Console drivers
  913. +#
  914. +CONFIG_PC_KEYMAP=y
  915. +# CONFIG_VGA_CONSOLE is not set
  916. +
  917. +#
  918. +# Frame-buffer support
  919. +#
  920. +# CONFIG_FB is not set
  921. +
  922. +#
  923. +# Sound
  924. +#
  925. +# CONFIG_SOUND is not set
  926. +
  927. +#
  928. +# Multimedia Capabilities Port drivers
  929. +#
  930. +# CONFIG_MCP is not set
  931. +# CONFIG_MCP_SA1100 is not set
  932. +# CONFIG_MCP_UCB1200 is not set
  933. +# CONFIG_MCP_UCB1200_AUDIO is not set
  934. +# CONFIG_MCP_UCB1200_TS is not set
  935. +
  936. +#
  937. +# Misc devices
  938. +#
  939. +# CONFIG_TOUCHSCREEN_LH79520 is not set
  940. +# CONFIG_EEPROM_LH79520 is not set
  941. +# CONFIG_7SEGMENT_LH79520 is not set
  942. +
  943. +#
  944. +# USB support
  945. +#
  946. +# CONFIG_USB is not set
  947. +
  948. +#
  949. +# Support for USB gadgets
  950. +#
  951. +# CONFIG_USB_GADGET is not set
  952. +
  953. +#
  954. +# Bluetooth support
  955. +#
  956. +# CONFIG_BLUEZ is not set
  957. +
  958. +#
  959. +# Kernel hacking
  960. +#
  961. +CONFIG_FRAME_POINTER=y
  962. +CONFIG_DEBUG_USER=y
  963. +CONFIG_DEBUG_INFO=y
  964. +# CONFIG_NO_PGT_CACHE is not set
  965. +CONFIG_DEBUG_KERNEL=y
  966. +# CONFIG_DEBUG_SLAB is not set
  967. +# CONFIG_MAGIC_SYSRQ is not set
  968. +# CONFIG_DEBUG_SPINLOCK is not set
  969. +# CONFIG_DEBUG_WAITQ is not set
  970. +CONFIG_DEBUG_BUGVERBOSE=y
  971. +CONFIG_DEBUG_ERRORS=y
  972. +CONFIG_DEBUG_LL=y
  973. +# CONFIG_DEBUG_DC21285_PORT is not set
  974. +# CONFIG_DEBUG_CLPS711X_UART2 is not set
  975. +
  976. +#
  977. +# Library routines
  978. +#
  979. +# CONFIG_CRC32 is not set
  980. +CONFIG_ZLIB_INFLATE=y
  981. +CONFIG_ZLIB_DEFLATE=y
  982. diff -urN linux-2.4.26/arch/arm/kernel/debug-armv.S linux-2.4.26-vrs1-lnode80/arch/arm/kernel/debug-armv.S
  983. --- linux-2.4.26/arch/arm/kernel/debug-armv.S 2003-08-25 07:44:39.000000000 -0400
  984. +++ linux-2.4.26-vrs1-lnode80/arch/arm/kernel/debug-armv.S 2005-11-02 17:37:31.000000000 -0400
  985. @@ -470,6 +470,53 @@
  986. +#elif defined(CONFIG_ARCH_LH79520)
  987. +
  988. + .macro addruart,rx
  989. + ldr \rx, =0xfffc1000 @UART1 base
  990. + .endm
  991. +
  992. + .macro senduart,rd,rx
  993. + strb \rd, [\rx] @ UART1_DR
  994. + .endm
  995. +
  996. + .macro busyuart,rd,rx @ spin while busy
  997. +1001: ldr \rd, [\rx, #0x18] @ UART1_FR
  998. + tst \rd, #1 << 3 @ BUSY ?
  999. + bne 1001b @ yes, spin
  1000. + .endm
  1001. +
  1002. + .macro waituart,rd,rx @ wait for Tx FIFO room
  1003. +1001: ldrb \rd, [\rx, #0x18] @ UART1_FR
  1004. + tst \rd, #1 << 5 @ TXFF full?
  1005. + bne 1001b @ yes, spin
  1006. + .endm
  1007. +
  1008. +#elif defined(CONFIG_ARCH_LH7A400)
  1009. +
  1010. + .macro addruart,rx
  1011. + mrc p15, 0, \rx, c1, c0
  1012. + tst \rx, #1 @ MMU enabled?
  1013. + ldr \rx, =UART2_PHYS @ physical base address
  1014. + orrne \rx, \rx, #0xf8000000 @ virtual base
  1015. + .endm
  1016. +
  1017. + .macro senduart,rd,rx
  1018. + strb \rd, [\rx] @ UART3_DR
  1019. + .endm
  1020. +
  1021. + .macro busyuart,rd,rx @ spin while busy
  1022. +1001: ldr \rd, [\rx, #0x10] @ UART3_FR
  1023. + tst \rd, #1 << 3 @ BUSY ?
  1024. + bne 1001b @ yes, spin
  1025. + .endm
  1026. +
  1027. + .macro waituart,rd,rx @ wait for Tx FIFO room
  1028. +1001: ldrb \rd, [\rx, #0x10] @ UART3_FR
  1029. + tst \rd, #1 << 5 @ TXFF full?
  1030. + bne 1001b @ yes, spin
  1031. + .endm
  1032. +
  1033. #else
  1034. #error Unknown architecture
  1035. #endif
  1036. diff -urN linux-2.4.26/arch/arm/kernel/entry-armv.S linux-2.4.26-vrs1-lnode80/arch/arm/kernel/entry-armv.S
  1037. --- linux-2.4.26/arch/arm/kernel/entry-armv.S 2005-11-02 16:54:17.000000000 -0400
  1038. +++ linux-2.4.26-vrs1-lnode80/arch/arm/kernel/entry-armv.S 2005-11-02 17:37:31.000000000 -0400
  1039. @@ -615,6 +615,49 @@
  1040. .text
  1041. .endm
  1042. +#elif defined(CONFIG_ARCH_LH79520)
  1043. +#include <asm/arch/hardware.h>
  1044. +
  1045. + .macro disable_fiq
  1046. + .endm
  1047. +
  1048. + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  1049. + ldr \irqstat, =VIC_BASE @ Virt addr IRQ regs
  1050. + ldr \irqstat, [\irqstat, #0] @ get masked interrupt status
  1051. + mov \irqnr, #0
  1052. +1001: tst \irqstat, #1
  1053. + addeq \irqnr, \irqnr, #1
  1054. + moveq \irqstat, \irqstat, lsr #1
  1055. + tsteq \irqnr, #32
  1056. + beq 1001b
  1057. + teq \irqnr, #32
  1058. + .endm
  1059. +
  1060. + .macro irq_prio_table
  1061. + .endm
  1062. +
  1063. +#elif defined(CONFIG_ARCH_LH7A400)
  1064. +#include <asm/arch/hardware.h>
  1065. +
  1066. + .macro disable_fiq
  1067. + .endm
  1068. +
  1069. + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  1070. + ldr \irqstat, =IO_ADDRESS(INTC_PHYS) @ Virt addr IRQ regs
  1071. + ldr \irqstat, [\irqstat, #0] @ get masked interrupt status
  1072. + mov \irqnr, #0
  1073. +1001: tst \irqstat, #1
  1074. + bne 1002f
  1075. + add \irqnr, \irqnr, #1
  1076. + mov \irqstat, \irqstat, lsr #1
  1077. + cmp \irqnr, #28
  1078. + bcc 1001b
  1079. +1002: /* EQ will be set if we reach 28 */
  1080. + .endm
  1081. +
  1082. + .macro irq_prio_table
  1083. + .endm
  1084. +
  1085. #else
  1086. #error Unknown architecture
  1087. #endif
  1088. diff -urN linux-2.4.26/arch/arm/kernel/irq.c linux-2.4.26-vrs1-lnode80/arch/arm/kernel/irq.c
  1089. --- linux-2.4.26/arch/arm/kernel/irq.c 2005-11-02 16:54:17.000000000 -0400
  1090. +++ linux-2.4.26-vrs1-lnode80/arch/arm/kernel/irq.c 2005-11-02 17:37:31.000000000 -0400
  1091. @@ -216,6 +216,18 @@
  1092. desc->triggered = 1;
  1093. +#ifdef CONFIG_ARCH_LH79520
  1094. + if( irq < 8) { /* external interrupt */
  1095. + vicRegs_t *vic = (vicRegs_t *)VIC_BASE;
  1096. + rcpcRegs_t *rcpc = (rcpcRegs_t *)IO_ADDRESS( RCPC_PHYS);
  1097. +
  1098. + rcpc->control |= RCPC_CTRL_WRTLOCK_ENABLED; /* unlock RCPC registers */
  1099. + barrier();
  1100. + rcpc->intClear = (1 << irq); /* clear corresponding IRQ */
  1101. + rcpc->control &= ~RCPC_CTRL_WRTLOCK_ENABLED; /* lock RCPC registers */
  1102. + }
  1103. +#endif
  1104. +
  1105. /*
  1106. * Acknowledge and clear the IRQ, but (if its
  1107. * a level-based IRQ, don't mask it)
  1108. diff -urN linux-2.4.26/arch/arm/kernel/ptrace.c linux-2.4.26-vrs1-lnode80/arch/arm/kernel/ptrace.c
  1109. --- linux-2.4.26/arch/arm/kernel/ptrace.c 2005-11-02 16:54:17.000000000 -0400
  1110. +++ linux-2.4.26-vrs1-lnode80/arch/arm/kernel/ptrace.c 2005-11-02 17:37:31.000000000 -0400
  1111. @@ -594,6 +594,9 @@
  1112. */
  1113. case PTRACE_POKETEXT:
  1114. case PTRACE_POKEDATA:
  1115. + if(data == 0xe7ffdefe)
  1116. + data = 0xef9f0001;
  1117. +
  1118. ret = access_process_vm(child, addr, &data,
  1119. sizeof(unsigned long), 1);
  1120. if (ret == sizeof(unsigned long))
  1121. diff -urN linux-2.4.26/arch/arm/mach-lh79520/arch.c linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/arch.c
  1122. --- linux-2.4.26/arch/arm/mach-lh79520/arch.c 1969-12-31 20:00:00.000000000 -0400
  1123. +++ linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/arch.c 2005-11-03 10:30:56.000000000 -0400
  1124. @@ -0,0 +1,65 @@
  1125. +/*
  1126. + * linux/arch/arm/mach-lh79520/arch.c
  1127. + *
  1128. + * Architecture specific fixups.
  1129. + *
  1130. + * Copyright (C) 2001 Lineo, Inc
  1131. + *
  1132. + * This program is free software; you can redistribute it and/or modify
  1133. + * it under the terms of the GNU General Public License as published by
  1134. + * the Free Software Foundation; either version 2 of the License, or
  1135. + * (at your option) any later version.
  1136. + *
  1137. + * This program is distributed in the hope that it will be useful,
  1138. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1139. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1140. + * GNU General Public License for more details.
  1141. + *
  1142. + * You should have received a copy of the GNU General Public License
  1143. + * along with this program; if not, write to the Free Software
  1144. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  1145. + */
  1146. +#include <linux/config.h>
  1147. +#include <linux/types.h>
  1148. +#include <linux/sched.h>
  1149. +#include <linux/interrupt.h>
  1150. +#include <linux/init.h>
  1151. +
  1152. +#include <asm/hardware.h>
  1153. +#include <asm/irq.h>
  1154. +#include <asm/setup.h>
  1155. +#include <asm/mach-types.h>
  1156. +
  1157. +#include <asm/mach/arch.h>
  1158. +
  1159. +extern void genarch_init_irq( void);
  1160. +extern void lh79520_map_io( void);
  1161. +
  1162. +#ifdef CONFIG_ARCH_LH79520
  1163. +
  1164. +static void __init
  1165. +fixup_lh79520(struct machine_desc *desc, struct param_struct *unused,
  1166. + char **cmdline, struct meminfo *mi)
  1167. +{
  1168. + mi->nr_banks = 1;
  1169. + mi->bank[0].start = PHYS_OFFSET;
  1170. + mi->bank[0].size = (32*1024*1024);
  1171. + mi->bank[0].node = 0;
  1172. +
  1173. + ROOT_DEV = MKDEV(RAMDISK_MAJOR,0);
  1174. + setup_ramdisk( 1, 0, 0, CONFIG_BLK_DEV_RAM_SIZE);
  1175. + setup_initrd( __phys_to_virt(0x20400000), 3 * 1024 * 1024);
  1176. +
  1177. + /* Serial Console on UART 1 */
  1178. + strcpy( *cmdline, "console=ttyAM1,115200");
  1179. +}
  1180. +
  1181. +
  1182. +MACHINE_START(LH79520EVB, "Sharp LH79520 Evaluation Board")
  1183. + MAINTAINER("Duck")
  1184. + BOOT_MEM( 0x20000000, 0xff800000, 0xff800000) // pio, vio must be 8MB
  1185. + FIXUP( fixup_lh79520)
  1186. + MAPIO( lh79520_map_io)
  1187. + INITIRQ( genarch_init_irq)
  1188. +MACHINE_END
  1189. +#endif
  1190. diff -urN linux-2.4.26/arch/arm/mach-lh79520/dma.c linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/dma.c
  1191. --- linux-2.4.26/arch/arm/mach-lh79520/dma.c 1969-12-31 20:00:00.000000000 -0400
  1192. +++ linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/dma.c 2005-11-02 17:38:44.000000000 -0400
  1193. @@ -0,0 +1,841 @@
  1194. +/*
  1195. + * arch/arm/mach-lh79520/dma-lh79520.c
  1196. + * Copyright (C) 2002 Embedix, Inc.
  1197. + *
  1198. + * Support functions for the Sharp LH79520 internal DMA channels.
  1199. + *
  1200. + * Based on arch/arm/mach-sa1100/dma-sa1100.c, which is
  1201. + * Copyright (C) 2000 Nicolas Pitre
  1202. + *
  1203. + * This program is free software; you can redistribute it and/or modify
  1204. + * it under the terms of the GNU General Public License version 2 as
  1205. + * published by the Free Software Foundation.
  1206. + *
  1207. + */
  1208. +
  1209. +#include <linux/module.h>
  1210. +#include <linux/init.h>
  1211. +#include <linux/sched.h>
  1212. +#include <linux/spinlock.h>
  1213. +#include <linux/slab.h>
  1214. +#include <linux/errno.h>
  1215. +
  1216. +#include <asm/system.h>
  1217. +#include <asm/irq.h>
  1218. +#include <asm/hardware.h>
  1219. +#include <asm/io.h>
  1220. +#include <asm/dma.h>
  1221. +#include <asm/mach/dma.h>
  1222. +#include <asm/arch/iocon.h>
  1223. +
  1224. +
  1225. +#undef DEBUG
  1226. +
  1227. +#ifdef DEBUG
  1228. +#define DPRINTK( s, arg... ) printk( "dma<%s>: " s, dma->device_id , ##arg )
  1229. +#define DUMPREGS(r,d) \
  1230. + printk( "regs=0x%x src=0x%x:%x dest=0x%x:%x count=%d control=0x%x tcnt=%d mask=0x%x status=0x%x\n", \
  1231. + (u32)r, r->srcHi, r->srcLow, r->destHi, r->destLow, r->count, r->control, r->termCnt, d->mask, d->status)
  1232. +#define DUMPQ(d) dumpq(d)
  1233. +#else
  1234. +#define DPRINTK( x... )
  1235. +#define DUMPREGS(r,d)
  1236. +#define DUMPQ(d)
  1237. +#endif
  1238. +
  1239. +/*
  1240. + * DMA channel registers structure
  1241. + */
  1242. +typedef struct {
  1243. + volatile u32 srcLow; /* Source base addr, low 16 bits */
  1244. + volatile u32 srcHi; /* Source base addr, hi 16 bits */
  1245. + volatile u32 destLow; /* Dest base addr, low 16 bits */
  1246. + volatile u32 destHi; /* Dest base addr, hi 16 bits */
  1247. + volatile u32 count; /* Maximum Count */
  1248. + volatile u32 control; /* Control */
  1249. + volatile u32 currSrcHi; /* Current src addr, hi 16 bits*/
  1250. + volatile u32 currSrcLow; /* Current src addr, low 16 bits*/
  1251. + volatile u32 currDstHi; /* Curr dest addr, hi 16 bits*/
  1252. + volatile u32 currDstLow; /* Curr src addr, low 16 bits*/
  1253. + volatile u32 termCnt; /* Terminal Count */
  1254. +} channelRegs_t;
  1255. +
  1256. +
  1257. +/*
  1258. + * Control Register Bit Field
  1259. + */
  1260. +#define DMAC_CTRL_ENABLE _BIT(0) /* Enable DMA */
  1261. +#define DMAC_CTRL_SOINC _BIT(1) /* Source Reg inc.bit */
  1262. +#define DMAC_CTRL_DEINC _BIT(2) /* Dest Reg inc.bit */
  1263. +/* Source Size */
  1264. +#define DMAC_CTRL_SOSIZE_1BYTE _SBF(3,0)
  1265. +#define DMAC_CTRL_SOSIZE_2BYTE _SBF(3,1)
  1266. +#define DMAC_CTRL_SOSIZE_4BYTE _SBF(3,2)
  1267. +/* Destination Size */
  1268. +#define DMAC_CTRL_DESIZE_1BYTE _SBF(7,0)
  1269. +#define DMAC_CTRL_DESIZE_2BYTE _SBF(7,1)
  1270. +#define DMAC_CTRL_DESIZE_4BYTE _SBF(7,2)
  1271. +/* Peripheral Burst Sizes */
  1272. +#define DMAC_CTRL_SOBURST_SINGLE _SBF(5,0) /* Single */
  1273. +#define DMAC_CTRL_SOBURST_4INC _SBF(5,1) /* 4 incrementing */
  1274. +#define DMAC_CTRL_SOBURST_8INC _SBF(5,2) /* 8 incrementing */
  1275. +#define DMAC_CTRL_SOBURST_16INC _SBF(5,3) /* 16 incrementing */
  1276. +/* Address Modes */
  1277. +#define DMAC_CTRL_ADDR_MODE_WRAP _SBF(9,0)
  1278. +#define DMAC_CTRL_ADDR_MODE_INCR _SBF(9,1)
  1279. +
  1280. +#define DMAC_CTRL_MEM2MEM _BIT(11) /* Memory to Memory */
  1281. +/* Direction */
  1282. +#define DMAC_CTRL_PERIPH_SOURCE _SBF(13,0)
  1283. +#define DMAC_CTRL_PERIPH_DEST _SBF(13,1)
  1284. +
  1285. +
  1286. +typedef struct {
  1287. + channelRegs_t stream0; /* Data Stream 0 */
  1288. + volatile u32 reserved0[5];
  1289. + channelRegs_t stream1; /* Data Stream 1 */
  1290. + volatile u32 reserved1[5];
  1291. + channelRegs_t stream2; /* Data Stream 2 */
  1292. + volatile u32 reserved2[5];
  1293. + channelRegs_t stream3; /* Data Stream 3 */
  1294. + volatile u32 reserved3;
  1295. + volatile u32 mask;
  1296. + volatile u32 clear;
  1297. + volatile u32 status;
  1298. + volatile u32 reserved4;
  1299. +} dmaRegs_t;
  1300. +
  1301. +channelRegs_t *streamRegs[] = {
  1302. + &((dmaRegs_t *)IO_ADDRESS(DMAC_PHYS))->stream0,
  1303. + &((dmaRegs_t *)IO_ADDRESS(DMAC_PHYS))->stream1,
  1304. + &((dmaRegs_t *)IO_ADDRESS(DMAC_PHYS))->stream2,
  1305. + &((dmaRegs_t *)IO_ADDRESS(DMAC_PHYS))->stream3
  1306. +};
  1307. +
  1308. +/*
  1309. + * mask - Mask Register Bit Fields
  1310. + * clear - Clear Register Bit Fields
  1311. + * status - Clear Register Bit Fields
  1312. + *
  1313. + * Writing DMAC_xN to mask register enables corresponding interrupt
  1314. + * Writing DMAC_xN to clear register disables corresponding interrupt
  1315. + * AND'ing DMAC_xN with status register yields status
  1316. + * Note: "ACTIVEx" constants are only applicable to Status Register
  1317. + */
  1318. +#define DMAC_INT0 _BIT(0) /* Stream 0 Interrupt */
  1319. +#define DMAC_INT1 _BIT(1) /* Stream 1 Interrupt */
  1320. +#define DMAC_INT2 _BIT(2) /* Stream 2 Interrupt */
  1321. +#define DMAC_INT3 _BIT(3) /* Stream 3 Interrupt */
  1322. +#define DMAC_ERRINT0 _BIT(4) /* Stream 0 Error Interrupt */
  1323. +#define DMAC_ERRINT1 _BIT(5) /* Stream 1 Error Interrupt */
  1324. +#define DMAC_ERRINT2 _BIT(6) /* Stream 2 Error Interrupt */
  1325. +#define DMAC_ERRINT3 _BIT(7) /* Stream 3 Error Interrupt */
  1326. +#define DMAC_ACTIVE0 _BIT(8) /* Stream 0 Active */
  1327. +#define DMAC_ACTIVE1 _BIT(9) /* Stream 1 Active */
  1328. +#define DMAC_ACTIVE2 _BIT(10) /* Stream 2 Active */
  1329. +#define DMAC_ACTIVE3 _BIT(11) /* Stream 3 Active */
  1330. +
  1331. +/* all DMA error bits */
  1332. +#define DMAC_ERROR (DMAC_ERRINT0 | DMAC_ERRINT1 | DMAC_ERRINT2 | DMAC_ERRINT3 )
  1333. +
  1334. +/* all DMA done bits */
  1335. +#define DMAC_DONE (DMAC_INT0 | DMAC_INT1 | DMAC_INT2 | DMAC_INT3)
  1336. +
  1337. +/* all the bits in the clear register */
  1338. +#define DMAC_CLEAR_ALL (DMAC_DONE | DMAC_ERROR)
  1339. +
  1340. +
  1341. +#include "dma.h"
  1342. +
  1343. +lh79520_dma_t dma_chan[LH79520_DMA_CHANNELS];
  1344. +
  1345. +/*
  1346. + * Maximum physical DMA buffer size
  1347. + */
  1348. +#define MAX_DMA_SIZE 0x3ffff
  1349. +#define MAX_DMA_ORDER 18
  1350. +
  1351. +
  1352. +static inline void dumpq (lh79520_dma_t *dma)
  1353. +{
  1354. + dma_buf_t *p=dma->tail;
  1355. +
  1356. + printk( "Q: curr=0x%p tail=0x%p head=0x%p bid: ", dma->curr, dma->tail, dma->head);
  1357. +
  1358. + while( p) {
  1359. + printk( "(0x%p 0x%p) ", p, p->id);
  1360. + p = p->next;
  1361. + }
  1362. + printk("\n");
  1363. +}
  1364. +
  1365. +
  1366. +/*
  1367. + * DMA processing...
  1368. + */
  1369. +
  1370. +static inline int start_lh79520_dma(lh79520_dma_t * dma, dma_addr_t dma_ptr, int size)
  1371. +{
  1372. + dmaRegs_t *dmaRegs = (dmaRegs_t *)IO_ADDRESS(DMAC_PHYS);
  1373. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  1374. + channelRegs_t *regs = dma->regs;
  1375. + int status;
  1376. +
  1377. + status = dmaRegs->status;
  1378. +
  1379. + /* If the DMA channel is active, there's nothing else we can do. */
  1380. + if( status & (DMAC_ACTIVE0 << dma->channel)) {
  1381. + DPRINTK("start: st %#x busy\n", status);
  1382. + return -EBUSY;
  1383. + }
  1384. +
  1385. + /* If there's an interrupt pending, split now
  1386. + * and let it happen.
  1387. + */
  1388. + if( status & (DMAC_INT0 << dma->channel)) {
  1389. + DPRINTK("start: st %#x IRQ pending\n", status);
  1390. + return -EAGAIN;
  1391. + }
  1392. +
  1393. + /*
  1394. + * if we're goint to the uda1341, we have to tell the CPLD
  1395. + * to start to send/receive via DMA.
  1396. + */
  1397. + switch( dma->channel) {
  1398. + case 2:
  1399. + cpld->audio_control |= CPLD_DAC_DMA_ENABLE;
  1400. + dmaRegs->mask |= DMAC_INT2;
  1401. + break;
  1402. +
  1403. + case 3:
  1404. + cpld->audio_control |= (CPLD_DAC_DMA_ENABLE | CPLD_DAC_USE_REQ1 );
  1405. + dmaRegs->mask |= DMAC_INT3;
  1406. + break;
  1407. + }
  1408. +
  1409. + /*
  1410. + * set the source or destination registers, based on which
  1411. + * direction the data's going.
  1412. + */
  1413. + if( dma->direction == DMA_IN) { /* data coming from peripheral */
  1414. + regs->destLow = dma_ptr & 0xffff;
  1415. + regs->destHi = (dma_ptr >> 16 ) & 0xffff;
  1416. + } else { /* data going to peripheral */
  1417. + regs->srcLow = dma_ptr & 0xffff;
  1418. + regs->srcHi = (dma_ptr >> 16 ) & 0xffff;
  1419. + }
  1420. +
  1421. + regs->count = size >> 2; /* DDD assumes 4-byte transfer size */
  1422. + regs->control |= DMAC_CTRL_ENABLE;
  1423. +
  1424. + DPRINTK("audio_control=0x%x\n", cpld->audio_control);
  1425. + DPRINTK("jif=%d start a=%#x sz=%d st=0x%x dma=0x%p dir=%d\n",
  1426. + jiffies, dma_ptr, size, status, dma, dma->direction);
  1427. + DUMPREGS(regs,dmaRegs);
  1428. +
  1429. +#if 0
  1430. + {
  1431. + u32 *p = phys_to_virt(dma_ptr);
  1432. + int i;
  1433. +
  1434. + for( i=0; i<8; i++)
  1435. + printk( " %08x %08x %08x %08x\n", *p++, *p++, *p++, *p++);
  1436. + }
  1437. +#endif // 0
  1438. +
  1439. + return 0;
  1440. +}
  1441. +
  1442. +
  1443. +static int start_dma(lh79520_dma_t *dma, dma_addr_t dma_ptr, int size)
  1444. +{
  1445. + return start_lh79520_dma(dma, dma_ptr, size);
  1446. +}
  1447. +
  1448. +
  1449. +/* This must be called with IRQ disabled */
  1450. +static void process_dma(lh79520_dma_t * dma)
  1451. +{
  1452. + dma_buf_t *buf;
  1453. + int chunksize;
  1454. +
  1455. + DUMPQ(dma);
  1456. +
  1457. + for (;;) {
  1458. + buf = dma->tail;
  1459. +
  1460. + if (!buf || dma->stopped) {
  1461. + /* no more data available */
  1462. + DPRINTK("process: no more buf (dma %s) buf=0x%p stopped=%d\n",
  1463. + dma->curr ? "active" : "inactive", buf, dma->stopped);
  1464. + /*
  1465. + * Some devices may require DMA still sending data
  1466. + * at any time for clock reference, etc.
  1467. + * Note: if there is still a data buffer being
  1468. + * processed then the ref count is negative. This
  1469. + * allows for the DMA termination to be accounted in
  1470. + * the proper order.
  1471. + */
  1472. + if (dma->spin_size && dma->spin_ref >= 0) {
  1473. + chunksize = dma->spin_size;
  1474. + if (chunksize > MAX_DMA_SIZE)
  1475. + chunksize = (1 << MAX_DMA_ORDER);
  1476. + while (start_dma(dma, dma->spin_addr, chunksize) == 0)
  1477. + dma->spin_ref++;
  1478. + if (dma->curr != NULL)
  1479. + dma->spin_ref = -dma->spin_ref;
  1480. + }
  1481. + break;
  1482. + }
  1483. +
  1484. + /*
  1485. + * Let's try to start DMA on the current buffer.
  1486. + * If DMA is busy then we break here.
  1487. + */
  1488. + chunksize = buf->size;
  1489. + if (chunksize > MAX_DMA_SIZE)
  1490. + chunksize = (1 << MAX_DMA_ORDER);
  1491. +
  1492. + DPRINTK("process: bid=%#x s=%d\n", (int) buf->id, buf->size);
  1493. + if (start_dma(dma, buf->dma_ptr, chunksize) != 0)
  1494. + break;
  1495. +
  1496. + if (!dma->curr) {
  1497. + dma->curr = buf;
  1498. + DPRINTK("process: set curr %#p\n", dma->curr);
  1499. + }
  1500. +
  1501. + buf->ref++;
  1502. + buf->dma_ptr += chunksize;
  1503. + buf->size -= chunksize;
  1504. + if (buf->size == 0) {
  1505. + /* current buffer is done: move tail to the next one */
  1506. + dma->tail = buf->next;
  1507. + DPRINTK("process: set tail b=%#x\n", (int) dma->tail);
  1508. + }
  1509. + }
  1510. +
  1511. + DUMPQ(dma);
  1512. +}
  1513. +
  1514. +
  1515. +/* This must be called with IRQ disabled */
  1516. +void lh79520_dma_done (lh79520_dma_t *dma)
  1517. +{
  1518. + dma_buf_t *buf = dma->curr;
  1519. +
  1520. + if (dma->spin_ref > 0) {
  1521. + dma->spin_ref--;
  1522. + } else if (buf) {
  1523. + buf->ref--;
  1524. + if (buf->ref == 0 && buf->size == 0) {
  1525. + /*
  1526. + * Current buffer is done.
  1527. + * Move current reference to the next one and send
  1528. + * the processed buffer to the callback function,
  1529. + * then discard it.
  1530. + */
  1531. + DPRINTK("IRQ: buf done set curr=%#p\n", buf->next);
  1532. + dma->curr = buf->next;
  1533. + if (dma->curr == NULL)
  1534. + dma->spin_ref = -dma->spin_ref;
  1535. + if (dma->head == buf)
  1536. + dma->head = NULL;
  1537. + if (dma->callback) {
  1538. + int size = buf->dma_ptr - buf->dma_start;
  1539. + dma->callback(buf->id, size);
  1540. + }
  1541. + kfree(buf);
  1542. + }
  1543. + }
  1544. +
  1545. + process_dma(dma);
  1546. +}
  1547. +
  1548. +
  1549. +static void dma_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
  1550. +{
  1551. + dmaRegs_t *dmaRegs = (dmaRegs_t *)IO_ADDRESS(DMAC_PHYS);
  1552. + lh79520_dma_t *dma = (lh79520_dma_t *) dev_id;
  1553. + int status = dmaRegs->status;
  1554. +
  1555. + DPRINTK("jif=%d IRQ: irq=%d regs=0x%x bid=%#x st=%#x, dma=0x%p\n",
  1556. + jiffies, irq, (u32)dma->regs, (int) dma->curr->id, status, dma);
  1557. +
  1558. + if (status & (DMAC_ERROR)) {
  1559. + printk(KERN_ERR "DMA on \"%s\" caused an error\n", dma->device_id);
  1560. + dmaRegs->clear = DMAC_ERROR;
  1561. + }
  1562. +
  1563. + dmaRegs->clear = status & DMAC_DONE;
  1564. +
  1565. + if (status & DMAC_DONE)
  1566. + lh79520_dma_done (dma);
  1567. +}
  1568. +
  1569. +
  1570. +/*
  1571. + * DMA interface functions
  1572. + */
  1573. +
  1574. +static spinlock_t dma_list_lock;
  1575. +
  1576. +int lh79520_request_dma (dmach_t * channel, const char *device_id, dma_device_t device)
  1577. +{
  1578. + lh79520_dma_t *dma = NULL;
  1579. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  1580. + channelRegs_t *regs;
  1581. + int i, err;
  1582. +
  1583. + /* DMA address (physical) of audio device */
  1584. + void *cpldAudioAddr = (void *) &((cpldRegs_t *)CPLD_START)->adc_dac_left;
  1585. +
  1586. +
  1587. +#ifdef DEBUG
  1588. + printk( __FUNCTION__ "(channel=0x%x, device_id=0x%x device=0x%x)\n",
  1589. + (u32)channel, (u32)device_id, device);
  1590. +#endif
  1591. +
  1592. + *channel = -1; /* to be sure we catch the freeing of a misregistered channel */
  1593. +
  1594. + err = 0;
  1595. + spin_lock(&dma_list_lock);
  1596. +
  1597. + /*
  1598. + * Allocate a channel. On the lh79520, channels 0 and 1
  1599. + * are dedicated to the SSP. Channels 2 and 3 are general purpose,
  1600. + * but channel 3 can only be used for audio if the rework described
  1601. + * in the User's Guide has been performed.
  1602. + */
  1603. + switch( device) {
  1604. + case DMA_Audio_Out:
  1605. + dma = &dma_chan[2];
  1606. + regs = dma->regs;
  1607. +
  1608. + dma->direction = DMA_OUT;
  1609. +
  1610. + regs->destLow = (u32)cpldAudioAddr & 0xffff;
  1611. + regs->destHi = ((u32)cpldAudioAddr >> 16) & 0xffff;
  1612. + regs->control = DMAC_CTRL_SOINC |
  1613. + DMAC_CTRL_SOSIZE_4BYTE |
  1614. + DMAC_CTRL_DESIZE_4BYTE |
  1615. + DMAC_CTRL_SOBURST_SINGLE |
  1616. + DMAC_CTRL_ADDR_MODE_WRAP |
  1617. + DMAC_CTRL_PERIPH_DEST;
  1618. + break;
  1619. +
  1620. + case DMA_Audio_In:
  1621. + dma = &dma_chan[3];
  1622. + regs = dma->regs;
  1623. +
  1624. + dma->direction = DMA_IN;
  1625. +
  1626. + regs->srcLow = (u32)cpldAudioAddr & 0xffff;
  1627. + regs->srcHi = ((u32)cpldAudioAddr >> 16) & 0xffff;
  1628. + regs->control = DMAC_CTRL_SOINC |
  1629. + DMAC_CTRL_SOSIZE_4BYTE |
  1630. + DMAC_CTRL_DESIZE_4BYTE |
  1631. + DMAC_CTRL_SOBURST_SINGLE |
  1632. + DMAC_CTRL_ADDR_MODE_WRAP |
  1633. + DMAC_CTRL_PERIPH_SOURCE;
  1634. + break;
  1635. +
  1636. + case DMA_SSP_Rx: /* not supported */
  1637. + case DMA_SSP_Tx: /* not supported */
  1638. + default:
  1639. + err = -ENOSR;
  1640. + break;
  1641. + }
  1642. +
  1643. + if (!err) {
  1644. + if (dma)
  1645. + dma->in_use = 1;
  1646. + else
  1647. + err = -ENOSR;
  1648. + }
  1649. + spin_unlock(&dma_list_lock);
  1650. + if (err)
  1651. + return err;
  1652. +
  1653. + err = request_irq(dma->irq, dma_irq_handler, SA_INTERRUPT,
  1654. + device_id, (void *) dma);
  1655. + if (err) {
  1656. + printk(KERN_ERR
  1657. + "%s: unable to request IRQ %d for DMA channel. error=0x%x\n",
  1658. + device_id, dma->irq, err);
  1659. + return err;
  1660. + }
  1661. +
  1662. + *channel = dma - dma_chan;
  1663. + dma->device_id = device_id;
  1664. + dma->device = device;
  1665. + dma->callback = NULL;
  1666. + dma->spin_size = 0;
  1667. +
  1668. + regs = dma->regs;
  1669. +
  1670. + DPRINTK( "channel=%d regs=0x%x\n", *channel, (u32)regs);
  1671. + DPRINTK("requested\n");
  1672. +
  1673. + return 0;
  1674. +}
  1675. +
  1676. +
  1677. +int lh79520_dma_set_callback(dmach_t channel, dma_callback_t cb)
  1678. +{
  1679. + lh79520_dma_t *dma = &dma_chan[channel];
  1680. +
  1681. + if ((unsigned)channel >= LH79520_DMA_CHANNELS || !dma->in_use)
  1682. + return -EINVAL;
  1683. +
  1684. + dma->callback = cb;
  1685. + DPRINTK("cb = %p\n", cb);
  1686. + return 0;
  1687. +}
  1688. +
  1689. +
  1690. +int lh79520_dma_set_spin(dmach_t channel, dma_addr_t addr, int size)
  1691. +{
  1692. + lh79520_dma_t *dma = &dma_chan[channel];
  1693. + int flags;
  1694. +
  1695. + if ((unsigned)channel >= LH79520_DMA_CHANNELS || !dma->in_use)
  1696. + return -EINVAL;
  1697. +
  1698. + DPRINTK("set spin %d at %#x\n", size, addr);
  1699. + local_irq_save(flags);
  1700. + dma->spin_addr = addr;
  1701. + dma->spin_size = size;
  1702. + if (size)
  1703. + process_dma(dma);
  1704. +
  1705. + local_irq_restore(flags);
  1706. + return 0;
  1707. +}
  1708. +
  1709. +
  1710. +int lh79520_dma_queue_buffer(dmach_t channel, void *buf_id,
  1711. + dma_addr_t data, int size)
  1712. +{
  1713. + lh79520_dma_t *dma;
  1714. + dma_buf_t *buf;
  1715. + int flags;
  1716. +
  1717. + dma = &dma_chan[channel];
  1718. + if ((unsigned)channel >= LH79520_DMA_CHANNELS || !dma->in_use)
  1719. + return -EINVAL;
  1720. +
  1721. + buf = kmalloc(sizeof(*buf), GFP_ATOMIC);
  1722. + if (!buf)
  1723. + return -ENOMEM;
  1724. +
  1725. + buf->next = NULL;
  1726. + buf->ref = 0;
  1727. + buf->dma_ptr = buf->dma_start = data;
  1728. + buf->size = size;
  1729. + buf->id = buf_id;
  1730. +
  1731. + local_irq_save(flags);
  1732. +
  1733. + DPRINTK("queueing bid=%#x a=%#x s=%d\n", (int) buf_id, data, size);
  1734. +
  1735. + if (dma->head)
  1736. + dma->head->next = buf;
  1737. +
  1738. + dma->head = buf;
  1739. + if (!dma->tail)
  1740. + dma->tail = buf;
  1741. +
  1742. + process_dma(dma);
  1743. + local_irq_restore(flags);
  1744. +
  1745. + return 0;
  1746. +}
  1747. +
  1748. +
  1749. +int lh79520_dma_get_current(dmach_t channel, void **buf_id, dma_addr_t *addr)
  1750. +{
  1751. + int flags, ret;
  1752. + lh79520_dma_t *dma = &dma_chan[channel];
  1753. + channelRegs_t *regs;
  1754. +
  1755. + if ((unsigned)channel >= LH79520_DMA_CHANNELS || !dma->in_use)
  1756. + return -EINVAL;
  1757. +
  1758. + regs = dma->regs;
  1759. + local_irq_save(flags);
  1760. + if (dma->curr && dma->spin_ref <= 0) {
  1761. + dma_buf_t *buf = dma->curr;
  1762. +
  1763. + /*
  1764. + * If we got here, that's because there is, or recently was, a
  1765. + * buffer being processed. Two possibilities: either we are
  1766. + * in the middle of a buffer, or the DMA controller just
  1767. + * switched to the next toggle but the interrupt hasn't been
  1768. + * serviced yet. The former case is straight forward. In
  1769. + * the later case, we'll do like if DMA is just at the end
  1770. + * of the previous toggle since all registers haven't been
  1771. + * reset yet. This goes around the edge case and since we're
  1772. + * always a little behind anyways it shouldn't make a big
  1773. + * difference. If DMA has been stopped prior calling this
  1774. + * then the position is always exact.
  1775. + */
  1776. + if (buf_id)
  1777. + *buf_id = buf->id;
  1778. +
  1779. + if( dma->direction == DMA_IN)
  1780. + *addr = (regs->currDstHi << 16 ) | (regs->currDstLow);
  1781. + else
  1782. + *addr = (regs->currSrcHi << 16 ) | (regs->currSrcLow);
  1783. +
  1784. + /*
  1785. + * Clamp funky pointers sometimes returned by the hardware
  1786. + * on completed DMA transfers
  1787. + */
  1788. + if (*addr < buf->dma_start ||
  1789. + *addr > buf->dma_ptr)
  1790. + *addr = buf->dma_ptr;
  1791. + DPRINTK("curr_pos: b=%#x a=%#x\n", (int)dma->curr->id, *addr);
  1792. + ret = 0;
  1793. + } else if (dma->tail && dma->stopped) {
  1794. + dma_buf_t *buf = dma->tail;
  1795. + if (buf_id)
  1796. + *buf_id = buf->id;
  1797. + *addr = buf->dma_ptr;
  1798. + ret = 0;
  1799. + } else {
  1800. + if (buf_id)
  1801. + *buf_id = NULL;
  1802. + *addr = 0;
  1803. + ret = -ENXIO;
  1804. + }
  1805. + local_irq_restore(flags);
  1806. + return ret;
  1807. +}
  1808. +
  1809. +
  1810. +int lh79520_dma_stop(dmach_t channel)
  1811. +{
  1812. + dmaRegs_t *dmaRegs = (dmaRegs_t *)IO_ADDRESS(DMAC_PHYS);
  1813. + lh79520_dma_t *dma = &dma_chan[channel];
  1814. + int flags;
  1815. +
  1816. + DPRINTK( "lh79520_dma_stop channel=%d\n", channel);
  1817. +
  1818. + if (dma->stopped)
  1819. + return 0;
  1820. +
  1821. + local_irq_save(flags);
  1822. + dma->stopped = 1;
  1823. +
  1824. + /*
  1825. + * Stop DMA and tweak state variables so everything could restart
  1826. + * from there when resume/wakeup occurs.
  1827. + */
  1828. + dma->regs->control &= ~DMAC_CTRL_ENABLE;
  1829. + dmaRegs->mask &= ~((DMAC_INT0 << channel) | (DMAC_ERRINT0 << channel));
  1830. +
  1831. + if (dma->curr) {
  1832. + dma_buf_t *buf = dma->curr;
  1833. + if (dma->spin_ref <= 0) {
  1834. + dma_addr_t curpos;
  1835. + lh79520_dma_get_current(channel, NULL, &curpos);
  1836. + buf->size += buf->dma_ptr - curpos;
  1837. + buf->dma_ptr = curpos;
  1838. + }
  1839. + buf->ref = 0;
  1840. + dma->tail = buf;
  1841. + dma->curr = NULL;
  1842. + }
  1843. + dma->spin_ref = 0;
  1844. + process_dma(dma);
  1845. + local_irq_restore(flags);
  1846. + return 0;
  1847. +}
  1848. +
  1849. +
  1850. +int lh79520_dma_resume(dmach_t channel)
  1851. +{
  1852. + lh79520_dma_t *dma = &dma_chan[channel];
  1853. +
  1854. + if ((unsigned)channel >= LH79520_DMA_CHANNELS || !dma->in_use)
  1855. + return -EINVAL;
  1856. +
  1857. + if (dma->stopped) {
  1858. + int flags;
  1859. + save_flags_cli(flags);
  1860. + dma->stopped = 0;
  1861. + dma->spin_ref = 0;
  1862. + process_dma(dma);
  1863. + restore_flags(flags);
  1864. + }
  1865. + return 0;
  1866. +}
  1867. +
  1868. +
  1869. +int lh79520_dma_flush_all(dmach_t channel)
  1870. +{
  1871. + dmaRegs_t *dmaRegs = (dmaRegs_t *)IO_ADDRESS(DMAC_PHYS);
  1872. + lh79520_dma_t *dma = &dma_chan[channel];
  1873. + dma_buf_t *buf, *next_buf;
  1874. + int flags;
  1875. +
  1876. + DPRINTK("dma_flush_all channel=%d\n", channel);
  1877. + DUMPQ(dma);
  1878. +
  1879. + if ((unsigned)channel >= LH79520_DMA_CHANNELS || !dma->in_use)
  1880. + return -EINVAL;
  1881. +
  1882. + local_irq_save(flags);
  1883. +
  1884. + /*
  1885. + * Disable the channel, and mask off its interrupts
  1886. + */
  1887. + dma->regs->control &= ~(DMAC_CTRL_ENABLE);
  1888. + dmaRegs->mask &= ~((DMAC_INT0 << channel) | (DMAC_ERRINT0 << channel));
  1889. +
  1890. + buf = dma->curr;
  1891. + if (!buf)
  1892. + buf = dma->tail;
  1893. +
  1894. + dma->head = dma->tail = dma->curr = NULL;
  1895. + dma->stopped = 0;
  1896. + dma->spin_ref = 0;
  1897. + process_dma(dma);
  1898. + local_irq_restore(flags);
  1899. +
  1900. + while (buf) {
  1901. + next_buf = buf->next;
  1902. + kfree(buf);
  1903. + buf = next_buf;
  1904. + }
  1905. + DPRINTK("flushed\n");
  1906. + return 0;
  1907. +}
  1908. +
  1909. +
  1910. +void lh79520_free_dma(dmach_t channel)
  1911. +{
  1912. + lh79520_dma_t *dma;
  1913. +
  1914. + if ((unsigned)channel >= LH79520_DMA_CHANNELS)
  1915. + return;
  1916. +
  1917. + dma = &dma_chan[channel];
  1918. + if (!dma->in_use) {
  1919. + printk(KERN_ERR "Trying to free free DMA%d\n", channel);
  1920. + return;
  1921. + }
  1922. +
  1923. + lh79520_dma_set_spin(channel, 0, 0);
  1924. + lh79520_dma_flush_all(channel);
  1925. +
  1926. + free_irq(dma->irq, (void *) dma);
  1927. + dma->in_use = 0;
  1928. +
  1929. + DPRINTK("freed\n");
  1930. +}
  1931. +
  1932. +
  1933. +EXPORT_SYMBOL(lh79520_request_dma);
  1934. +EXPORT_SYMBOL(lh79520_dma_set_callback);
  1935. +EXPORT_SYMBOL(lh79520_dma_set_spin);
  1936. +EXPORT_SYMBOL(lh79520_dma_queue_buffer);
  1937. +EXPORT_SYMBOL(lh79520_dma_get_current);
  1938. +EXPORT_SYMBOL(lh79520_dma_stop);
  1939. +EXPORT_SYMBOL(lh79520_dma_resume);
  1940. +EXPORT_SYMBOL(lh79520_dma_flush_all);
  1941. +EXPORT_SYMBOL(lh79520_free_dma);
  1942. +
  1943. +
  1944. +#ifdef CONFIG_PM
  1945. +/* Drivers should call this from their PM callback function */
  1946. +
  1947. +int lh79520_dma_sleep(dmach_t channel)
  1948. +{
  1949. + dmaRegs_t *dmaRegs = (dmaRegs_t *)IO_ADDRESS(DMAC_PHYS);
  1950. + lh79520_dma_t *dma = &dma_chan[channel];
  1951. + int orig_state;
  1952. +
  1953. + if ((unsigned)channel >= LH79520_DMA_CHANNELS || !dma->in_use)
  1954. + return -EINVAL;
  1955. +
  1956. + orig_state = dma->stopped;
  1957. + lh79520_dma_stop(channel);
  1958. + dma->regs->control &= ~DMAC_CTRL_ENABLE;
  1959. + dmaRegs->mask &= ~((DMAC_INT0 << channel) | (DMAC_ERRINT0 << channel));
  1960. +
  1961. + dma->stopped = orig_state;
  1962. + dma->spin_ref = 0;
  1963. + return 0;
  1964. +}
  1965. +
  1966. +int lh79520_dma_wakeup(dmach_t channel)
  1967. +{
  1968. + dmaRegs_t *dmaRegs = (dmaRegs_t *)IO_ADDRESS(DMAC_PHYS);
  1969. + lh79520_dma_t *dma = &dma_chan[channel];
  1970. + int flags;
  1971. +
  1972. + if ((unsigned)channel >= LH79520_DMA_CHANNELS || !dma->in_use)
  1973. + return -EINVAL;
  1974. +
  1975. + dma->regs->control &= ~DMAC_CTRL_ENABLE;
  1976. + dmaRegs->mask &= ~((DMAC_INT0 << channel) | (DMAC_ERRINT0 << channel));
  1977. +
  1978. + local_irq_save(flags);
  1979. + process_dma(dma);
  1980. + local_irq_restore(flags);
  1981. +
  1982. + return 0;
  1983. +}
  1984. +
  1985. +EXPORT_SYMBOL(lh79520_dma_sleep);
  1986. +EXPORT_SYMBOL(lh79520_dma_wakeup);
  1987. +
  1988. +#endif /* CONFIG_PM */
  1989. +
  1990. +
  1991. +static int __init lh79520_init_dma(void)
  1992. +{
  1993. + int channel;
  1994. + dmaRegs_t *dmaRegs = (dmaRegs_t *)IO_ADDRESS(DMAC_PHYS);
  1995. + ioconRegs_t *ioconRegs = (ioconRegs_t *)IO_ADDRESS( IOCON_PHYS);
  1996. + channelRegs_t *regs;
  1997. +
  1998. +#ifdef DEBUG
  1999. + printk( __FUNCTION__ "\n");
  2000. +#endif
  2001. +
  2002. + dmaRegs->clear = DMAC_CLEAR_ALL;
  2003. + dmaRegs->mask = 0;
  2004. +
  2005. + for (channel = 0; channel < LH79520_DMA_CHANNELS; channel++) {
  2006. + dma_chan[channel].regs = regs = streamRegs[channel];
  2007. +
  2008. + regs->control = 0;
  2009. + regs->count = 0;
  2010. + regs->srcHi = 0;
  2011. + regs->srcLow = 0;
  2012. + regs->destHi = 0;
  2013. + regs->destLow = 0;
  2014. +
  2015. + dma_chan[channel].irq = IRQ_DMA;
  2016. + dma_chan[channel].channel = channel;
  2017. +
  2018. +#ifdef DEBUG
  2019. + printk( "dma channel %d at 0x%x\n", channel, (u32)regs);
  2020. +#endif
  2021. + }
  2022. +
  2023. + /* assign pins to DMA stream 2 */
  2024. + ioconRegs->DMAMux |= (DMAMUX_DCDEOT0 | DMAMUX_DCDREQ0) ;
  2025. +
  2026. + /* assign pins to DMA Stream 3 */
  2027. + // These two lines interfere with PWM Audio
  2028. + // ioconRegs->MiscMux |= MISCMUX_DCDEOT1;
  2029. + // ioconRegs->MiscMux &= ~MISCMUX_RCEII5;
  2030. +
  2031. + return 0;
  2032. +}
  2033. +
  2034. +__initcall(lh79520_init_dma);
  2035. diff -urN linux-2.4.26/arch/arm/mach-lh79520/dma.h linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/dma.h
  2036. --- linux-2.4.26/arch/arm/mach-lh79520/dma.h 1969-12-31 20:00:00.000000000 -0400
  2037. +++ linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/dma.h 2005-11-02 17:38:44.000000000 -0400
  2038. @@ -0,0 +1,61 @@
  2039. +/*
  2040. + * arch/arm/mach-lh79520/dma.h
  2041. + * Copyright (C) 2002 Embedix, Inc.
  2042. + *
  2043. + * Based on arch/arm/mach-sa1100/dma.h which is
  2044. + * (C) 2000 Nicolas Pitre <nico@cam.org>
  2045. + *
  2046. + * This program is free software; you can redistribute it and/or modify
  2047. + * it under the terms of the GNU General Public License version 2 as
  2048. + * published by the Free Software Foundation.
  2049. + */
  2050. +
  2051. +#include <linux/config.h>
  2052. +
  2053. +/*
  2054. + * DMA buffer structure
  2055. + */
  2056. +
  2057. +typedef struct dma_buf_s {
  2058. + int size; /* buffer size */
  2059. + dma_addr_t dma_start; /* starting DMA address */
  2060. + dma_addr_t dma_ptr; /* next DMA pointer to use */
  2061. + int ref; /* number of DMA references */
  2062. + void *id; /* to identify buffer from outside */
  2063. + struct dma_buf_s *next; /* next buffer to process */
  2064. +} dma_buf_t;
  2065. +
  2066. +typedef enum {
  2067. + DMA_OUT,
  2068. + DMA_IN
  2069. +} dma_direction_t;
  2070. +
  2071. +/*
  2072. + * DMA channel structure.
  2073. + */
  2074. +typedef struct {
  2075. + unsigned int in_use; /* Device is allocated */
  2076. + const char *device_id; /* Device name */
  2077. + dma_device_t device; /* ... to which this channel is attached */
  2078. + dma_buf_t *head; /* where to insert buffers */
  2079. + dma_buf_t *tail; /* where to remove buffers */
  2080. + dma_buf_t *curr; /* buffer currently DMA'ed */
  2081. + int stopped; /* 1 if DMA is stalled */
  2082. + channelRegs_t *regs; /* points to appropriate DMA registers */
  2083. + int irq; /* IRQ used by the channel */
  2084. + dma_callback_t callback; /* ... to call when buffers are done */
  2085. + int spin_size; /* > 0 when DMA should spin when no more buffer */
  2086. + dma_addr_t spin_addr; /* DMA address to spin onto */
  2087. + int spin_ref; /* number of spinning references */
  2088. + int channel; /* channel number */
  2089. + dma_direction_t direction; /* DMA direction: 0=Out / 1=In */
  2090. +} lh79520_dma_t;
  2091. +
  2092. +extern lh79520_dma_t dma_chan[LH79520_DMA_CHANNELS];
  2093. +
  2094. +
  2095. +void lh79520_dma_done( lh79520_dma_t *dma);
  2096. +
  2097. +
  2098. +
  2099. +
  2100. diff -urN linux-2.4.26/arch/arm/mach-lh79520/generic.c linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/generic.c
  2101. --- linux-2.4.26/arch/arm/mach-lh79520/generic.c 1969-12-31 20:00:00.000000000 -0400
  2102. +++ linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/generic.c 2005-11-02 17:38:09.000000000 -0400
  2103. @@ -0,0 +1,71 @@
  2104. +/*
  2105. + * linux/arch/arm/mach-lh79520/generic.c
  2106. + *
  2107. + * Common code for all LH79520 based machines.
  2108. + *
  2109. + * Copyright (C) 2001 Lineo, Inc
  2110. + *
  2111. + * This program is free software; you can redistribute it and/or modify
  2112. + * it under the terms of the GNU General Public License as published by
  2113. + * the Free Software Foundation; either version 2 of the License, or
  2114. + * (at your option) any later version.
  2115. + *
  2116. + * This program is distributed in the hope that it will be useful,
  2117. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2118. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2119. + * GNU General Public License for more details.
  2120. + *
  2121. + * You should have received a copy of the GNU General Public License
  2122. + * along with this program; if not, write to the Free Software
  2123. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  2124. + */
  2125. +#include <linux/config.h>
  2126. +#include <linux/types.h>
  2127. +#include <linux/sched.h>
  2128. +#include <linux/interrupt.h>
  2129. +#include <linux/init.h>
  2130. +
  2131. +#include <asm/hardware.h>
  2132. +#include <asm/irq.h>
  2133. +#include <asm/setup.h>
  2134. +#include <asm/mach-types.h>
  2135. +
  2136. +#include <asm/mach/arch.h>
  2137. +#include <asm/arch/rcpc.h>
  2138. +
  2139. +
  2140. +/*
  2141. + * return the CPU clock frequency (FCLK) in Hz.
  2142. + */
  2143. +unsigned int
  2144. +cpufreq_get( int cpu)
  2145. +{
  2146. + int divider;
  2147. + rcpcRegs_t *RCPC = (rcpcRegs_t *)IO_ADDRESS(RCPC_PHYS);
  2148. +
  2149. + divider = RCPC->CpuClkPrescale * 2;
  2150. + if( divider == 0)
  2151. + divider = 1;
  2152. + return PLL_CLOCK / divider;;
  2153. +}
  2154. +EXPORT_SYMBOL(cpufreq_get);
  2155. +
  2156. +
  2157. +/*
  2158. + * return the bus clock frequency (HCLK) in Hz.
  2159. + */
  2160. +unsigned int
  2161. +hclkfreq_get( void)
  2162. +{
  2163. + int divider;
  2164. + rcpcRegs_t *RCPC = (rcpcRegs_t *)IO_ADDRESS(RCPC_PHYS);
  2165. +
  2166. + divider = RCPC->HCLKPrescale * 2; /* HCLK prescale value */
  2167. +
  2168. + if( divider == 0) /* no prescalar == divide by 1 */
  2169. + divider = 1;
  2170. +
  2171. + return PLL_CLOCK / divider;
  2172. +}
  2173. +
  2174. +
  2175. diff -urN linux-2.4.26/arch/arm/mach-lh79520/generic.h linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/generic.h
  2176. --- linux-2.4.26/arch/arm/mach-lh79520/generic.h 1969-12-31 20:00:00.000000000 -0400
  2177. +++ linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/generic.h 2005-11-02 17:38:09.000000000 -0400
  2178. @@ -0,0 +1,24 @@
  2179. +/*
  2180. + * linux/arch/arm/mach-lh79520/generic.h
  2181. + *
  2182. + * Common code for all LH79520 based machines.
  2183. + *
  2184. + * Copyright (C) 2001 Lineo, Inc
  2185. + *
  2186. + * This program is free software; you can redistribute it and/or modify
  2187. + * it under the terms of the GNU General Public License as published by
  2188. + * the Free Software Foundation; either version 2 of the License, or
  2189. + * (at your option) any later version.
  2190. + *
  2191. + * This program is distributed in the hope that it will be useful,
  2192. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2193. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2194. + * GNU General Public License for more details.
  2195. + *
  2196. + * You should have received a copy of the GNU General Public License
  2197. + * along with this program; if not, write to the Free Software
  2198. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  2199. + */
  2200. +
  2201. +unsigned int cpufreq_get( int cpu);
  2202. +unsigned int hclkfreq_get( void);
  2203. diff -urN linux-2.4.26/arch/arm/mach-lh79520/Makefile linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/Makefile
  2204. --- linux-2.4.26/arch/arm/mach-lh79520/Makefile 1969-12-31 20:00:00.000000000 -0400
  2205. +++ linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/Makefile 2005-11-02 17:38:09.000000000 -0400
  2206. @@ -0,0 +1,24 @@
  2207. +#
  2208. +# Makefile for the linux kernel.
  2209. +#
  2210. +# Note! Dependencies are done automagically by 'make dep', which also
  2211. +# removes any old dependencies. DON'T put your own dependencies here
  2212. +# unless it's something special (ie not a .c file).
  2213. +
  2214. +USE_STANDARD_AS_RULE := true
  2215. +
  2216. +O_TARGET := lh79520.o
  2217. +
  2218. +# Object file lists.
  2219. +
  2220. +obj-y := arch.o mm.o generic.o dma.o
  2221. +obj-m :=
  2222. +obj-n :=
  2223. +obj- :=
  2224. +
  2225. +export-objs := generic.o dma.o
  2226. +
  2227. +# obj-$(CONFIG_LEDS) += leds.o
  2228. +# obj-$(CONFIG_PCI) += pci_v3.o pci.o
  2229. +
  2230. +include $(TOPDIR)/Rules.make
  2231. diff -urN linux-2.4.26/arch/arm/mach-lh79520/mm.c linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/mm.c
  2232. --- linux-2.4.26/arch/arm/mach-lh79520/mm.c 1969-12-31 20:00:00.000000000 -0400
  2233. +++ linux-2.4.26-vrs1-lnode80/arch/arm/mach-lh79520/mm.c 2005-11-02 17:38:09.000000000 -0400
  2234. @@ -0,0 +1,38 @@
  2235. +/*
  2236. + * linux/arch/arm/mach-lh79520/mm.c
  2237. + *
  2238. + * Copyright (C) 2001 Lineo, Inc.
  2239. + *
  2240. + * This program is free software; you can redistribute it and/or modify
  2241. + * it under the terms of the GNU General Public License version 2 as
  2242. + * published by the Free Software Foundation.
  2243. + */
  2244. +#include <linux/sched.h>
  2245. +#include <linux/mm.h>
  2246. +#include <linux/init.h>
  2247. +
  2248. +#include <asm/pgtable.h>
  2249. +#include <asm/page.h>
  2250. +#include <asm/io.h>
  2251. +
  2252. +#include <asm/mach/map.h>
  2253. +
  2254. +static struct map_desc lh79520_io_desc[] __initdata = {
  2255. + /* virt phys size r w c b */
  2256. + { FLASH_BASE, FLASH_START, FLASH_SIZE, DOMAIN_IO, 0, 1, 0, 0 },
  2257. + { CPLD_BASE, CPLD_START, CPLD_SIZE, DOMAIN_IO, 0, 1, 0, 0 },
  2258. + { CS8900_BASE, CS8900_START, CS8900_SIZE, DOMAIN_IO, 0, 1, 0, 0 },
  2259. + { IDE_BASE, IDE_START, IDE_SIZE, DOMAIN_IO, 0, 1, 0, 0 },
  2260. + { IDE2_BASE, IDE2_START, IDE2_SIZE, DOMAIN_IO, 0, 1, 0, 0 },
  2261. + { INT_SRAM_BASE, INT_SRAM_START, INT_SRAM_SIZE, DOMAIN_IO, 0, 1, 0, 0 },
  2262. + { APB_BASE, APB_START, APB_SIZE, DOMAIN_IO, 0, 1, 0, 0 },
  2263. + { AHB_BASE, AHB_START, AHB_SIZE, DOMAIN_IO, 0, 1, 0, 0 },
  2264. + { VIC_BASE, VIC_START, VIC_SIZE, DOMAIN_IO, 0, 1, 0, 0 },
  2265. + LAST_DESC
  2266. +};
  2267. +
  2268. +void __init lh79520_map_io(void)
  2269. +{
  2270. + iotable_init( lh79520_io_desc);
  2271. +}
  2272. +
  2273. diff -urN linux-2.4.26/arch/arm/Makefile linux-2.4.26-vrs1-lnode80/arch/arm/Makefile
  2274. --- linux-2.4.26/arch/arm/Makefile 2005-11-02 16:54:16.000000000 -0400
  2275. +++ linux-2.4.26-vrs1-lnode80/arch/arm/Makefile 2005-11-02 17:37:31.000000000 -0400
  2276. @@ -160,6 +160,16 @@
  2277. MACHINE = anakin
  2278. endif
  2279. +ifeq ($(CONFIG_ARCH_LH79520),y)
  2280. +# C0008000 is the default, so not needed -- DDD
  2281. +# DDD TEXTADDR = 0xC0008000
  2282. +MACHINE = lh79520
  2283. +endif
  2284. +
  2285. +ifeq ($(CONFIG_ARCH_LH7A400),y)
  2286. +MACHINE = lh7a400
  2287. +endif
  2288. +
  2289. ifeq ($(CONFIG_ARCH_OMAHA),y)
  2290. MACHINE = omaha
  2291. endif
  2292. diff -urN linux-2.4.26/arch/arm/tools/mach-types linux-2.4.26-vrs1-lnode80/arch/arm/tools/mach-types
  2293. --- linux-2.4.26/arch/arm/tools/mach-types 2005-11-02 16:54:18.000000000 -0400
  2294. +++ linux-2.4.26-vrs1-lnode80/arch/arm/tools/mach-types 2005-11-02 17:37:31.000000000 -0400
  2295. @@ -525,3 +525,5 @@
  2296. omap_osk MACH_OMAP_OSK OMAP_OSK 515
  2297. rg100v3 MACH_RG100V3 RG100V3 516
  2298. mx2ads MACH_MX2ADS MX2ADS 517
  2299. +lh79520evb LH79520_EVB LH79520EVB 999
  2300. +lh7a400evb LH7A400_EVB LH7A400EVB 998
  2301. diff -urN linux-2.4.26/Documentation/Configure.help linux-2.4.26-vrs1-lnode80/Documentation/Configure.help
  2302. --- linux-2.4.26/Documentation/Configure.help 2005-11-02 16:54:16.000000000 -0400
  2303. +++ linux-2.4.26-vrs1-lnode80/Documentation/Configure.help 2005-11-02 17:37:31.000000000 -0400
  2304. @@ -25531,6 +25531,136 @@
  2305. a debugging option; you probably do not want to set it unless you
  2306. are an S390 port maintainer.
  2307. +Sharp LH79520 based bords
  2308. +CONFIG_ARCH_LH79520
  2309. + Say Y here to support the Sharp LH79520 System on Chip.
  2310. +
  2311. +Sharp LH79520 Evaluation Board (Isis)
  2312. +CONFIG_LH79520_EVB
  2313. + Say Y here to support the Sharp LH79520 Evaluation Board.
  2314. +
  2315. +Sharp LH79520 Watchdog Timer
  2316. +CONFIG_LH79520_WATCHDOG
  2317. + Say Y here to include support for the LH79520 watchdog timer.
  2318. + The watchdog timer will reboot your system when the timeout is reached.
  2319. + Note that once enabled, this timer cannot be disabled.
  2320. +
  2321. + This driver is also available as a module ( = code which can be
  2322. + inserted in and removed from the running kernel whenever you want).
  2323. + If you want to compile it as a module, say M here and read
  2324. + Documentation/modules.txt. The module will be called lh79520_wdt.o.
  2325. +
  2326. + If unsure, say N.
  2327. +
  2328. +Sharp LH79520 PWM controller
  2329. +CONFIG_LH79520_PWM
  2330. + Say Y here to include support for the PWM device.
  2331. + PWM0 is for the LCD backlight intensity, and
  2332. + PWM1 is for audio. The major number is dynamically assigned unless
  2333. + module parameter is provided. Device nodes must exist to control
  2334. + the ioctls.
  2335. + /dev/pwm0 c 254 0
  2336. + /dev/pwm1 c 254 1
  2337. + 254 may or may not be the major number for your driver.
  2338. + Check /proc/devices for major number of pwm520.
  2339. +
  2340. + If unsure, say N.
  2341. +
  2342. +Sharp LH79520 7-segment display
  2343. +CONFIG_7SEGMENT_LH79520
  2344. + Say Y here to include support for the LH79520 7-segment display.
  2345. +
  2346. + If unsure, say N.
  2347. +
  2348. +Sharp LH79520 Touchscreen
  2349. +CONFIG_TOUCHSCREEN_LH79520
  2350. + Say Y here to include support for the LH79520 touchscreen.
  2351. +
  2352. + If unsure, say N.
  2353. +
  2354. +Sharp LH79520 LCD EEPROM
  2355. +CONFIG_EEPROM_LH79520
  2356. + Say Y here to include support for the EEPROM on the LCD
  2357. + board on the Sharp LH79520 EVB.
  2358. +
  2359. + If unsure, say N.
  2360. +
  2361. +ARM PrimeCell PL011 UART
  2362. +CONFIG_SERIAL_AMBA_PL011
  2363. + Say Y here to include support for the ARM PrimeCell PL011 UART.
  2364. +
  2365. + If unsure, say N.
  2366. +
  2367. +Console on ARM PL011 UART
  2368. +CONFIG_SERIAL_AMBA_PL011_CONSOLE
  2369. + Say Y here to support a serial console on an ARM PrimeCell PL011 UART.
  2370. +
  2371. + If unsure, say N.
  2372. +
  2373. +ARM PrimeCell PL110 LCD Controller
  2374. +CONFIG_FB_PL110
  2375. + Say Y here to include support the ARM PrimeCell PL110
  2376. + LCD controller.
  2377. +
  2378. + If unsure, say N.
  2379. +
  2380. +Sharp LQ039Q2DS53-HR-TFT LCD panel
  2381. +CONFIG_PL110_LQ39
  2382. + Say Y here to if you've got a Sharp LQ039Q2DS53-HR-TFT
  2383. + LCD panel connected to an ARM PL110 LCD controller.
  2384. +
  2385. + If unsure, say N.
  2386. +
  2387. +Sharp LM057QCTT03-QVGA-STN LCD panel
  2388. +CONFIG_PL110_LM57
  2389. + Say Y here to if you've got a Sharp LM057QCTT03-QVGA-STN
  2390. + LCD panel connected to an ARM PL110 LCD controller.
  2391. +
  2392. + If unsure, say N.
  2393. +
  2394. +Sharp LQ057Q3DC02-VGA/QVGA-TFT LCD panel
  2395. +CONFIG_PL110_LQ57
  2396. + Say Y here to if you've got a Sharp LQ057Q3DC02-VGA/QVGA-TFT
  2397. + LCD panel connected to an ARM PL110 LCD controller.
  2398. +
  2399. + If unsure, say N
  2400. +
  2401. +Sharp LQ121S1DG31-800x600-TFT LCD panel
  2402. +CONFIG_PL110_LQ121
  2403. + Say Y here to if you've got a Sharp LQ121S1DG31-800x600-TFT
  2404. + LCD panel connected to an ARM PL110 LCD controller.
  2405. +
  2406. + If unsure, say N
  2407. +
  2408. +Sharp LQ104V1DG11-640x480-TFT LCD panel
  2409. +CONFIG_PL110_LQ104
  2410. + Say Y here to if you've got a Sharp LQ104V1DG11-640x480-TFT
  2411. + LCD panel connected to an ARM PL110 LCD controller.
  2412. +
  2413. + If unsure, say N
  2414. +
  2415. +Sharp LH7A400 based bords
  2416. +CONFIG_ARCH_LH7A400
  2417. + Say Y here to support the Sharp LH7A400 System on Chip.
  2418. +
  2419. +Sharp LH7A400 Evaluation Board (Aruba)
  2420. +CONFIG_LH7A400_EVB
  2421. + Say Y here to support the Sharp LH7A400 SoC Evaluation Board.
  2422. +
  2423. +Sharp LH7A400 UART
  2424. +CONFIG_SERIAL_LH7A400
  2425. + Say Y here to include support for the UART on the Sharp
  2426. + LH7A400 SoC.
  2427. +
  2428. + If unsure, say N.
  2429. +
  2430. +Console on a Sharp LH7A400 Serial port
  2431. +CONFIG_SERIAL_LH7A400_CONSOLE
  2432. + Say Y here to support a serial console on the
  2433. + Sharp LH7A400 SoC Serial port.
  2434. +
  2435. + If unsure, say N.
  2436. +
  2437. #
  2438. # ARM options
  2439. #
  2440. diff -urN linux-2.4.26/drivers/char/Config.in linux-2.4.26-vrs1-lnode80/drivers/char/Config.in
  2441. --- linux-2.4.26/drivers/char/Config.in 2005-11-02 16:54:20.000000000 -0400
  2442. +++ linux-2.4.26-vrs1-lnode80/drivers/char/Config.in 2005-11-02 17:37:31.000000000 -0400
  2443. @@ -253,6 +253,7 @@
  2444. dep_tristate ' DC21285 watchdog' CONFIG_21285_WATCHDOG $CONFIG_FOOTBRIDGE
  2445. dep_tristate ' NetWinder WB83C977 watchdog' CONFIG_977_WATCHDOG $CONFIG_ARCH_NETWINDER
  2446. dep_tristate ' SA1100 watchdog' CONFIG_SA1100_WATCHDOG $CONFIG_ARCH_SA1100
  2447. + dep_tristate ' Sharp LH79520 watchdog' CONFIG_LH79520_WATCHDOG $CONFIG_ARCH_LH79520
  2448. dep_tristate ' EPXA watchdog' CONFIG_EPXA_WATCHDOG $CONFIG_ARCH_CAMELOT
  2449. dep_tristate ' Omaha watchdog' CONFIG_OMAHA_WATCHDOG $CONFIG_ARCH_OMAHA
  2450. dep_tristate ' AT91RM9200 watchdog' CONFIG_AT91_WATCHDOG $CONFIG_ARCH_AT91RM9200
  2451. @@ -304,6 +305,11 @@
  2452. if [ "$CONFIG_X86" = "y" -o "$CONFIG_X86_64" = "y" ]; then
  2453. dep_tristate 'AMD 768/8111 Random Number Generator support' CONFIG_AMD_RNG $CONFIG_PCI
  2454. fi
  2455. +
  2456. +if [ "$CONFIG_ARCH_LH79520" = "y" ]; then
  2457. + tristate 'LH79520 PWM support' CONFIG_LH79520_PWM
  2458. +fi
  2459. +
  2460. if [ "$CONFIG_X86" = "y" -o "$CONFIG_IA64" = "y" ]; then
  2461. dep_tristate 'Intel i8x0 Random Number Generator support' CONFIG_INTEL_RNG $CONFIG_PCI
  2462. fi
  2463. diff -urN linux-2.4.26/drivers/char/console.c linux-2.4.26-vrs1-lnode80/drivers/char/console.c
  2464. --- linux-2.4.26/drivers/char/console.c 2005-11-02 16:54:20.000000000 -0400
  2465. +++ linux-2.4.26-vrs1-lnode80/drivers/char/console.c 2005-11-02 17:37:31.000000000 -0400
  2466. @@ -169,7 +169,7 @@
  2467. int console_blanked;
  2468. static int vesa_blank_mode; /* 0:none 1:suspendV 2:suspendH 3:powerdown */
  2469. -static int blankinterval = 10*60*HZ;
  2470. +static int blankinterval = 0; // 10*60*HZ;
  2471. static int vesa_off_interval;
  2472. static struct tq_struct console_callback_tq = {
  2473. diff -urN linux-2.4.26/drivers/char/cradle.c linux-2.4.26-vrs1-lnode80/drivers/char/cradle.c
  2474. --- linux-2.4.26/drivers/char/cradle.c 1969-12-31 20:00:00.000000000 -0400
  2475. +++ linux-2.4.26-vrs1-lnode80/drivers/char/cradle.c 2005-11-02 17:37:31.000000000 -0400
  2476. @@ -0,0 +1,486 @@
  2477. +/*
  2478. +** cradle.c
  2479. +**
  2480. +** Device driver for the cradle interface on the Touchblock device.
  2481. +**
  2482. +** Copyright (C) 2002 The PTR Group, Inc. <www.theptrgroup.com>
  2483. +**
  2484. +** This program is free software; you can redistribute it and/or modify
  2485. +** it under the terms of the GNU General Public License as published by
  2486. +** the Free Software Foundation; either version 2 of the License, or
  2487. +** (at your option) any later version.
  2488. +**
  2489. +** This program is distributed in the hope that it will be useful,
  2490. +** but WITHOUT ANY WARRANTY; without even the implied warranty of
  2491. +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2492. +** GNU General Public License for more details.
  2493. +**
  2494. +** You should have received a copy of the GNU General Public License
  2495. +** along with this program; if not, write to the Free Software
  2496. +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  2497. +**
  2498. +*/
  2499. +
  2500. +#include <linux/module.h>
  2501. +#include <linux/kernel.h>
  2502. +#include <linux/sched.h>
  2503. +#include <linux/signal.h>
  2504. +#include <linux/errno.h>
  2505. +#include <linux/mm.h>
  2506. +#include <linux/slab.h>
  2507. +#include <linux/poll.h>
  2508. +#include <linux/miscdevice.h>
  2509. +#include <linux/random.h>
  2510. +#include <linux/init.h>
  2511. +#include <asm/system.h>
  2512. +#include <asm/hardware.h>
  2513. +#include <asm/arch/iocon.h>
  2514. +#include <asm/arch/gpio.h>
  2515. +#include <asm/hardware/cradle.h>
  2516. +
  2517. +static ssize_t cradle_read(struct file *filp, char *buf, size_t count, loff_t *f_pos);
  2518. +static int cradle_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
  2519. +static int cradle_open(struct inode *inode, struct file *filp);
  2520. +static int cradle_release(struct inode *inode, struct file *filp);
  2521. +static int cradle_fasync(int fd, struct file *filp, int mode );
  2522. +static unsigned int cradle_poll(struct file *filp, poll_table *wait);
  2523. +
  2524. +
  2525. +static char read_docking_state(void);
  2526. +static inline void cradle_update_buffer(volatile char **index, int delta, char *buf, int size);
  2527. +
  2528. +#if 0
  2529. +void cradle_do_tasklet_docked(unsigned long data);
  2530. +DECLARE_TASKLET( cradle_tasklet_docked, cradle_do_tasklet_docked,0);
  2531. +void cradle_do_tasklet_undocked(unsigned long data);
  2532. +DECLARE_TASKLET( cradle_tasklet_undocked, cradle_do_tasklet_undocked,0);
  2533. +#endif
  2534. +
  2535. +//#define min(a,b) (((a)<(b))?(a):(b))
  2536. +
  2537. +#define CRADLE_IBUF_SIZE 2
  2538. +
  2539. +typedef struct
  2540. +{
  2541. + int users;
  2542. + int ready;
  2543. + volatile char *ibuf_wp;
  2544. + volatile char *ibuf_rp;
  2545. + char *ibuf;
  2546. + wait_queue_head_t wait_inq;
  2547. + struct fasync_struct *fasync; /* asynchronous readers */
  2548. +} cradle_dev_t;
  2549. +
  2550. +static cradle_dev_t cradle_dev;
  2551. +
  2552. +struct file_operations cradle_fops = {
  2553. +// NULL, // seek
  2554. +read: cradle_read, // read
  2555. +// NULL, // write
  2556. +// NULL, // readdir
  2557. +poll: cradle_poll, // poll/select
  2558. +ioctl: cradle_ioctl, // ioctl
  2559. +// NULL, // mmap
  2560. +open: cradle_open, // open
  2561. +// NULL, // flush
  2562. +release: cradle_release, // release
  2563. +// NULL, // fsync
  2564. +fasync: cradle_fasync, // fasync
  2565. +};
  2566. +
  2567. +/************************************************************************
  2568. +** Read the docking state from the hardware
  2569. +************************************************************************/
  2570. +static char read_docking_state(void)
  2571. +{
  2572. +
  2573. + return( (GPIOG->dr & 0x10) ? CRADLE_UNDOCKED_STATE : CRADLE_DOCKED_STATE );
  2574. +}
  2575. +
  2576. +/************************************************************************
  2577. +** Manipulate the buffer pointers safely without using locks
  2578. +************************************************************************/
  2579. +static inline void cradle_update_buffer(volatile char **index, int delta, char *buf, int size)
  2580. +{
  2581. + volatile char *new = *index + delta;
  2582. + barrier();
  2583. + *index=(new >= (buf+size)) ? buf : new;
  2584. +}
  2585. +
  2586. +
  2587. +#if 0
  2588. +/************************************************************************
  2589. +** Enable the interrupt(s) associated with the cradle
  2590. +************************************************************************/
  2591. +static void cradle_enable_interrupt(void)
  2592. +{
  2593. + /* printk(KERN_INFO "cradle: interrupts enabled\n"); */
  2594. +}
  2595. +
  2596. +/************************************************************************
  2597. +** Disable the interrupt(s) associated with the cradle
  2598. +************************************************************************/
  2599. +static void cradle_disable_interrupt(void)
  2600. +{
  2601. + /* printk(KERN_INFO "cradle: interrupts disabled\n"); */
  2602. +}
  2603. +
  2604. +/************************************************************************
  2605. +**
  2606. +************************************************************************/
  2607. +static void cradle_docked_interrupt_handler(int irq, void *dev_id, struct pt_regs *regs)
  2608. +{
  2609. + cradle_dev_t *dev=dev_id;
  2610. +
  2611. + /* printk(KERN_INFO "cradle: docked irq\n"); */
  2612. +
  2613. + /* Reset the interrupt request */
  2614. +
  2615. + /* Get the state */
  2616. + *dev->ibuf_wp=read_docking_state();
  2617. + cradle_update_buffer(&dev->ibuf_wp, 1, dev->ibuf, CRADLE_IBUF_SIZE);
  2618. +
  2619. + /* Notify any asynchronous readers */
  2620. + if( dev->fasync )
  2621. + {
  2622. + /* printk(KERN_INFO "cradle: kill_fasync()\n"); */
  2623. + kill_fasync(dev->fasync, SIGIO, POLL_IN);
  2624. + }
  2625. +
  2626. + wake_up_interruptible( &dev->wait_inq );
  2627. +
  2628. + /* Schedule the bottom-half */
  2629. + /* tasklet_schedule(&cradle_tasklet_docked); */
  2630. +}
  2631. +
  2632. +/************************************************************************
  2633. +**
  2634. +************************************************************************/
  2635. +static void cradle_undocked_interrupt_handler(int irq, void *dev_id, struct pt_regs *regs)
  2636. +{
  2637. + cradle_dev_t *dev=dev_id;
  2638. +
  2639. + /* printk(KERN_INFO "cradle: undocked irq\n"); */
  2640. +
  2641. + /* Reset the interrupt request */
  2642. +
  2643. + /* Get the state */
  2644. + *dev->ibuf_wp=read_docking_state();
  2645. + cradle_update_buffer(&dev->ibuf_wp, 1, dev->ibuf, CRADLE_IBUF_SIZE);
  2646. +
  2647. + /* Notify any asynchronous readers */
  2648. + if( dev->fasync )
  2649. + {
  2650. + /* printk(KERN_INFO "cradle: kill_fasync()\n"); */
  2651. + kill_fasync(dev->fasync, SIGIO, POLL_IN);
  2652. + }
  2653. +
  2654. + wake_up_interruptible( &dev->wait_inq );
  2655. +
  2656. + /* Schedule the bottom-half */
  2657. + /* tasklet_schedule(&cradle_tasklet_undocked); */
  2658. +}
  2659. +
  2660. +/*************************************************************************
  2661. +** Bottom-half processing
  2662. +*************************************************************************/
  2663. +void cradle_do_tasklet_docked(unsigned long data)
  2664. +{
  2665. + printk(KERN_INFO "cradle: tasklet\n");
  2666. +}
  2667. +
  2668. +
  2669. +/*************************************************************************
  2670. +** Bottom-half processing
  2671. +*************************************************************************/
  2672. +void cradle_do_tasklet_undocked(unsigned long data)
  2673. +{
  2674. + printk(KERN_INFO "cradle: tasklet undocked\n");
  2675. +}
  2676. +#endif
  2677. +
  2678. +/************************************************************************
  2679. +** Open the cradle device
  2680. +************************************************************************/
  2681. +static int cradle_open(struct inode *inode, struct file *filp)
  2682. +{
  2683. + cradle_dev_t *dev;
  2684. + int status;
  2685. +
  2686. + /* printk(KERN_INFO "cradle: open()\n"); */
  2687. +
  2688. + /* Initialize the device information */
  2689. + dev=(cradle_dev_t *)filp->private_data;
  2690. + if(!dev)
  2691. + {
  2692. + dev=&cradle_dev;
  2693. + filp->private_data=dev;
  2694. + }
  2695. +
  2696. + if( dev->users++ ) return 0;
  2697. +
  2698. + MOD_INC_USE_COUNT;
  2699. +
  2700. + /* allocate the buffers */
  2701. + dev->ibuf=(char *)kmalloc(CRADLE_IBUF_SIZE,GFP_KERNEL);
  2702. + if( !dev->ibuf )
  2703. + {
  2704. + MOD_DEC_USE_COUNT;
  2705. + return -ENOMEM;
  2706. + }
  2707. +
  2708. + /* clear the buffers */
  2709. + dev->ibuf_wp=dev->ibuf_rp=dev->ibuf;
  2710. +
  2711. + /* mark the device ready */
  2712. + dev->ready=1;
  2713. +
  2714. + /* Install the interrupt handler(s) */
  2715. +
  2716. + /* Enable the interrupts */
  2717. + //cradle_enable_interrupt();
  2718. +
  2719. +
  2720. + return 0;
  2721. +}
  2722. +
  2723. +/************************************************************************
  2724. +** Release the cradle device
  2725. +************************************************************************/
  2726. +static int cradle_release(struct inode *inode, struct file *filp)
  2727. +{
  2728. +
  2729. + cradle_dev_t *dev=(cradle_dev_t *)filp->private_data;
  2730. +
  2731. + /* printk(KERN_INFO "cradle: release\n"); */
  2732. +
  2733. + if( --dev->users ) return 0;
  2734. +
  2735. + //cradle_disable_interrupt();
  2736. +
  2737. + //free the irq
  2738. +
  2739. + /* release any asynchronous readers */
  2740. + cradle_fasync(-1,filp,0);
  2741. +
  2742. + /* free up resources */
  2743. + kfree(dev->ibuf);
  2744. +
  2745. +
  2746. + MOD_DEC_USE_COUNT;
  2747. +
  2748. + return 0;
  2749. +}
  2750. +
  2751. +/************************************************************************
  2752. +** Read the cradle device
  2753. +**
  2754. +** This implementation supports both non-blocking and blocking i/o.
  2755. +************************************************************************/
  2756. +static ssize_t cradle_read(struct file *filp, char *buf, size_t count, loff_t *f_pos)
  2757. +{
  2758. + cradle_dev_t *dev=(cradle_dev_t *)filp->private_data;
  2759. + wait_queue_t wait;
  2760. +
  2761. + /* printk(KERN_INFO "cradle: read()\n"); */
  2762. +
  2763. + /* unseekable device */
  2764. + if( f_pos!=&filp->f_pos )
  2765. + return -ESPIPE;
  2766. +
  2767. + /*
  2768. + ** safe implementation of sleeping that avoids race conditions
  2769. + */
  2770. +
  2771. + /* init our local wait queue */
  2772. + init_waitqueue_entry(&wait, current);
  2773. +
  2774. + /* add out queue to the drivers queue */
  2775. + add_wait_queue(&dev->wait_inq, &wait);
  2776. +
  2777. + while( 1 )
  2778. + {
  2779. + /* tell the schedule we are asleep (even though we aren't yet) */
  2780. + set_current_state(TASK_INTERRUPTIBLE);
  2781. +
  2782. + /* check for available data */
  2783. + if( dev->ibuf_wp != dev->ibuf_rp )
  2784. + {
  2785. + break;
  2786. + }
  2787. +
  2788. + if( filp->f_flags & O_NONBLOCK )
  2789. + {
  2790. + remove_wait_queue(&dev->wait_inq, &wait);
  2791. + set_current_state(TASK_RUNNING);
  2792. + return -EAGAIN;
  2793. + /* return -EWOULDBLOCK; */
  2794. + }
  2795. +
  2796. + /* check to see if it is a signal */
  2797. + if( signal_pending(current))
  2798. + {
  2799. + remove_wait_queue(&dev->wait_inq, &wait);
  2800. + set_current_state(TASK_RUNNING);
  2801. + return -ERESTARTSYS;
  2802. + }
  2803. +
  2804. + /* allow other processes to run (we'll go to sleep) */
  2805. + schedule();
  2806. + }
  2807. +
  2808. + set_current_state(TASK_RUNNING);
  2809. + remove_wait_queue(&dev->wait_inq, &wait);
  2810. +
  2811. + /* calculate how much data is available */
  2812. + if( dev->ibuf_wp > dev->ibuf_rp )
  2813. + count=min(count, dev->ibuf_wp - dev->ibuf_rp );
  2814. + else
  2815. + count=min(count, (dev->ibuf+CRADLE_IBUF_SIZE) - dev->ibuf_rp );
  2816. +
  2817. + /* printk("cradle: read() %d available\n", count); */
  2818. +
  2819. + /* copy the data to user space */
  2820. + if( copy_to_user(buf, dev->ibuf_rp, count) )
  2821. + {
  2822. + return -EFAULT;
  2823. + }
  2824. +
  2825. + /* manager the buffer pointers */
  2826. + cradle_update_buffer(&dev->ibuf_rp, count, dev->ibuf, CRADLE_IBUF_SIZE);
  2827. +
  2828. +
  2829. + return count;
  2830. +}
  2831. +
  2832. +/************************************************************************
  2833. +** Poll/select the cradle device
  2834. +************************************************************************/
  2835. +static unsigned int cradle_poll(struct file *filp, poll_table *wait)
  2836. +{
  2837. + cradle_dev_t *dev=filp->private_data;
  2838. + unsigned int mask=0;
  2839. +
  2840. + poll_wait(filp, &dev->wait_inq, wait);
  2841. +
  2842. + /* check for readable */
  2843. + if( dev->ibuf_wp != dev->ibuf_rp )
  2844. + mask |= POLLIN | POLLRDNORM;
  2845. +
  2846. + return mask;
  2847. +}
  2848. +
  2849. +/************************************************************************
  2850. +** IOCTL interface for the cradle device
  2851. +************************************************************************/
  2852. +static int cradle_ioctl(struct inode *inode, struct file *filp,
  2853. + unsigned int cmd, unsigned long arg)
  2854. +{
  2855. + int docking_state;
  2856. + int retval=0;
  2857. +
  2858. + /* printk(KERN_INFO "cradle: ioct %d\n", cmd); */
  2859. +
  2860. + switch(cmd)
  2861. + {
  2862. + case CRADLE_GET_DOCKING_STATE_IOCTL:
  2863. + docking_state=read_docking_state();
  2864. + //this code is here temporarily until
  2865. + // a timer is added to check the state and set
  2866. + // the LED automatically
  2867. + if(docking_state == CRADLE_DOCKED_STATE)
  2868. + {
  2869. + // turn on dock led
  2870. + GPIOF->dr |= 0x40;
  2871. + }
  2872. + else
  2873. + {
  2874. + // turn off dock led
  2875. + GPIOF->dr &= ~0x40;
  2876. + }
  2877. +
  2878. + retval=put_user(docking_state, (int *)arg);
  2879. +
  2880. + break;
  2881. + default:
  2882. + printk(KERN_INFO "cradle: unknown ioctl %d\n", cmd);
  2883. + retval=-1;
  2884. + break;
  2885. + }
  2886. +
  2887. + return retval;
  2888. +}
  2889. +
  2890. +/************************************************************************
  2891. +** Aynchronous i/o support for the cradle device
  2892. +************************************************************************/
  2893. +static int cradle_fasync(int fd, struct file *filp, int on )
  2894. +{
  2895. + int retval;
  2896. + cradle_dev_t *dev=filp->private_data;
  2897. +
  2898. + /*
  2899. + printk(KERN_INFO "cradle: fasync fd=%d filp=0x%08x mode=%d\n",
  2900. + fd, (unsigned int) filp, on );
  2901. + */
  2902. +
  2903. + retval=fasync_helper(fd, filp, on, &dev->fasync);
  2904. + if( retval < 0 )
  2905. + return retval;
  2906. + else
  2907. + return 0;
  2908. +}
  2909. +
  2910. +/************************************************************************
  2911. +** Initialize the cradle interface and the hardware associated with the
  2912. +** cradle.
  2913. +**
  2914. +** This configuration is specific to the hardware design for the
  2915. +** Touchblock device. Moreover, this configuration *must* match the
  2916. +** configuration of the MIPS interrupt handler.
  2917. +************************************************************************/
  2918. +void cradle_init(void)
  2919. +{
  2920. + int retval;
  2921. + int cradle_major = 0;
  2922. +
  2923. + /* register the device */
  2924. + retval=register_chrdev( cradle_major, "cradle", &cradle_fops );
  2925. + if( retval < 0 )
  2926. + {
  2927. + printk(KERN_WARNING "cradle: Failed to register device\n");
  2928. + }
  2929. + if (cradle_major == 0)
  2930. + {
  2931. + cradle_major = retval; /* Dynamic Allocation of major number */
  2932. + printk("<4>Cradle Dynamic Major Number %d\n",cradle_major);
  2933. + }
  2934. +
  2935. +
  2936. + /* initialize the device structure */
  2937. + memset( &cradle_dev, 0, sizeof( cradle_dev_t ) );
  2938. + init_waitqueue_head(&cradle_dev.wait_inq);
  2939. +
  2940. +
  2941. + /* printk(KERN_INFO "cradle: initalized\n"); */
  2942. +}
  2943. +
  2944. +/************************************************************************
  2945. +**
  2946. +** Since the cradle device is statically compiled into the kernel this
  2947. +** is not really used. However, when the driver switches to loadable
  2948. +** modules this should be the basis of the
  2949. +** module cleanup routine.
  2950. +************************************************************************/
  2951. +void cradle_cleanup(void)
  2952. +{
  2953. + /* unregister the device */
  2954. + unregister_chrdev( CRADLE_MAJOR, "cradle");
  2955. +
  2956. +
  2957. + /* printk(KERN_INFO "cradle: cleanup\n"); */
  2958. +}
  2959. +
  2960. +
  2961. +module_init(cradle_init);
  2962. +module_exit(cradle_cleanup);
  2963. diff -urN linux-2.4.26/drivers/char/lh79520_wdt.c linux-2.4.26-vrs1-lnode80/drivers/char/lh79520_wdt.c
  2964. --- linux-2.4.26/drivers/char/lh79520_wdt.c 1969-12-31 20:00:00.000000000 -0400
  2965. +++ linux-2.4.26-vrs1-lnode80/drivers/char/lh79520_wdt.c 2005-11-02 17:37:31.000000000 -0400
  2966. @@ -0,0 +1,259 @@
  2967. +/*
  2968. + * Watchdog driver for the LH79520
  2969. + *
  2970. + * (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
  2971. + * Based on SoftDog driver by Alan Cox <alan@redhat.com>
  2972. + *
  2973. + * This program is free software; you can redistribute it and/or
  2974. + * modify it under the terms of the GNU General Public License
  2975. + * as published by the Free Software Foundation; either version
  2976. + * 2 of the License, or (at your option) any later version.
  2977. + *
  2978. + * Neither Oleg Drokin nor iXcelerator.com admit liability nor provide
  2979. + * warranty for any of this software. This material is provided
  2980. + * "AS-IS" and at no charge.
  2981. + *
  2982. + * (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
  2983. + *
  2984. + * 27/11/2000 Initial release
  2985. + */
  2986. +
  2987. +#include <linux/module.h>
  2988. +#include <linux/config.h>
  2989. +#include <linux/types.h>
  2990. +#include <linux/kernel.h>
  2991. +#include <linux/fs.h>
  2992. +#include <linux/mm.h>
  2993. +#include <linux/miscdevice.h>
  2994. +#include <linux/watchdog.h>
  2995. +#include <linux/reboot.h>
  2996. +#include <linux/smp_lock.h>
  2997. +#include <linux/init.h>
  2998. +#include <asm/uaccess.h>
  2999. +#include <asm/hardware.h>
  3000. +#include <asm/bitops.h>
  3001. +
  3002. +#include "lh79520_wdt.h"
  3003. +
  3004. +unsigned int hclkfreq_get( void);
  3005. +
  3006. +#define TIMER_MARGIN 60 /* default in seconds */
  3007. +#ifdef OLDWAY
  3008. +#define PCLK 51609600 /* ticks per second of AHB clock, 51MHz */
  3009. +#else
  3010. +#define PCLK hclkfreq_get()
  3011. +#endif
  3012. +#define SLEEP_TIME 10 /* number of seconds between each counter reload */
  3013. +
  3014. +static int lh79520_margin = TIMER_MARGIN; /* in seconds */
  3015. +static int lh79520wdt_users; /* mutex */
  3016. +#ifdef FIQ_ENABLED
  3017. +static int irq = 0x1c; /* FIQ. Normally 0x18 for standard irq */
  3018. +#else
  3019. +static int irq = 0x18; /* IRQ. Normally the FIQ is 0x1c */
  3020. +#endif
  3021. +
  3022. +#define WDTBase 0xFFFE3000L /* Base Address for all LH79520 Watchdog Registers */
  3023. +WDTIMERREGS *wtdregs = (WDTIMERREGS *) WDTBase;
  3024. +
  3025. +#ifdef MODULE
  3026. +MODULE_PARM(lh79520_margin,"i");
  3027. +#endif
  3028. +
  3029. +/*
  3030. + * Allow only one person to hold it open
  3031. + */
  3032. +
  3033. +static int lh79520dog_open(struct inode *inode, struct file *file)
  3034. +{
  3035. + if(test_and_set_bit(1,&lh79520wdt_users))
  3036. + return -EBUSY;
  3037. + MOD_INC_USE_COUNT;
  3038. +
  3039. + if ((lh79520_margin > (PCLK / 0xffffffff)) || /* 83 seconds max, 20 sec min margin */
  3040. + (lh79520_margin <= SLEEP_TIME * 2))
  3041. + lh79520_margin = TIMER_MARGIN;
  3042. +
  3043. +/* setting bits 7-4 of WDCTLR to 0x0 through 0xF sets the *initial* counter value upon a reset */
  3044. +/* 0x0 is 2^16 tics of PCLK, or reset immediatly, 0x10 is 2^17 tics of PCLK, ... */
  3045. +/* 0xF is 2^31 tics of PCLK, if PCLK is 51 MHz, 2^31 / 51 MHz = 41.6 seconds */
  3046. +/* WDCTLR=0xF, the F sets initial counter to 41.6 seconds (assuming PCLK is 51 MHz) */
  3047. +/* The counter will be set to the user selected margin the first time a reload occurs */
  3048. + wtdregs->wdctlr |= 0xF0;
  3049. +
  3050. + /* Activate LH79520 Watchdog timer */
  3051. + wtdregs->wdctlr |= WDT_CTRL_ENABLE;
  3052. + ///wtdregs->wdctlr |= WDT_CTRL_FRZ_ENABLE;
  3053. + // The 1 sets the enable bit (bit 0) to 1 enabling the watchdog fuctionality
  3054. + // The freeze or lock bit (bit 4) makes bit 0 read-only (to avoid accidental disabling)
  3055. + // Bit 1 is left at 0 signifing that when the counter reaches 0, a machine reset occurs
  3056. + // If bit 1 were 1, then the first time the counter reached 0 an interrupt occurs, and
  3057. + // the second time the counter reaches 0 the machine is reset.
  3058. +
  3059. + // Now reset Watchdog to let the above settings take effect
  3060. + wtdregs->wdcntr = WDT_WDCNTR; // 0x1984 is a special reset value
  3061. + return 0;
  3062. +}
  3063. +
  3064. +static int lh79520dog_release(struct inode *inode, struct file *file)
  3065. +{
  3066. + /*
  3067. + * Shut off the timer.
  3068. + * Lock it in if it's a module and we defined ...NOWAYOUT
  3069. + */
  3070. + ///wtdregs->wdctr |= 0x0; // turns off bit 4 the freeze lock so we can write to bit 0
  3071. + wtdregs->wdctlr |= WDT_CTRL_DISABLE; // turns off watchdog bit 0
  3072. +
  3073. + lh79520wdt_users = 0;
  3074. + MOD_DEC_USE_COUNT;
  3075. + return 0;
  3076. +}
  3077. +
  3078. +static ssize_t lh79520dog_write(struct file *file, const char *data, size_t len, loff_t *ppos)
  3079. +{
  3080. + /* Can't seek (pwrite) on this device */
  3081. + if (ppos != &file->f_pos)
  3082. + return -ESPIPE;
  3083. +
  3084. + /* Refresh/reload counter */
  3085. + if(len) {
  3086. + unsigned int count = (lh79520_margin * PCLK);
  3087. + wtdregs->wdcnt3 = count && 0xFF000000;
  3088. + wtdregs->wdcnt2 = count && 0x00FF0000;
  3089. + wtdregs->wdcnt1 = count && 0x0000FF00;
  3090. + wtdregs->wdcnt0 = count && 0x000000FF;
  3091. + return 1;
  3092. + }
  3093. + return 0;
  3094. +}
  3095. +
  3096. +static int lh79520dog_ioctl(struct inode *inode, struct file *file,
  3097. + unsigned int cmd, unsigned long arg)
  3098. +{
  3099. + static struct watchdog_info ident = {
  3100. + identity: "LH79520 Watchdog",
  3101. + };
  3102. +
  3103. + switch(cmd){
  3104. + default:
  3105. + return -ENOIOCTLCMD;
  3106. + case WDIOC_GETSUPPORT:
  3107. + return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident));
  3108. + case WDIOC_GETSTATUS:
  3109. + return put_user(0,(int *)arg);
  3110. + case WDIOC_GETBOOTSTATUS: /* 1 = last reboot was cause by watchdog, 0 means no */
  3111. + return put_user( ! (wtdregs->wdtstr & WDT_WD_NWDRES), (int *)arg);
  3112. + case WDIOC_KEEPALIVE:
  3113. + {
  3114. + unsigned int count = (lh79520_margin * PCLK);
  3115. + wtdregs->wdcnt3 = count && 0xFF000000;
  3116. + wtdregs->wdcnt2 = count && 0x00FF0000;
  3117. + wtdregs->wdcnt1 = count && 0x0000FF00;
  3118. + wtdregs->wdcnt0 = count && 0x000000FF;
  3119. + }
  3120. + return 0;
  3121. + }
  3122. +}
  3123. +
  3124. +/**
  3125. + * lh79520dog_interrupt:
  3126. + * @irq: Interrupt number
  3127. + * @dev_id: Unused as we don't allow multiple devices.
  3128. + * @regs: Unused.
  3129. + *
  3130. + * Handle an interrupt from the board. These are raised when the status
  3131. + * map changes in what the board considers an interesting way. That means
  3132. + * a failure condition occuring.
  3133. + */
  3134. +
  3135. +void lh79520dog_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  3136. +{
  3137. + /*
  3138. + * Read the status register see what is up and
  3139. + * then printk it.
  3140. + */
  3141. +
  3142. + unsigned char status=wtdregs->wdtstr;
  3143. +
  3144. +/* status|=FEATUREMAP1;
  3145. + status&=~FEATUREMAP2; */
  3146. +
  3147. + printk(KERN_CRIT "WDT status %d\n", status);
  3148. +
  3149. + wtdregs->wdcntr = WDT_WDCNTR; // 0x1984 is a special reset value
  3150. +/*
  3151. + if(!(status&WDC_SR_TGOOD))
  3152. + printk(KERN_CRIT "Overheat alarm.(%d)\n",inb_p(WDT_RT));
  3153. + if(!(status&WDC_SR_PSUOVER))
  3154. + printk(KERN_CRIT "PSU over voltage.\n");
  3155. + if(!(status&WDC_SR_PSUUNDR))
  3156. + printk(KERN_CRIT "PSU under voltage.\n");
  3157. + if(!(status&WDC_SR_FANGOOD))
  3158. + printk(KERN_CRIT "Possible fan fault.\n");
  3159. + if(!(status&WDC_SR_WCCR))
  3160. +#ifdef SOFTWARE_REBOOT
  3161. +#ifdef ONLY_TESTING
  3162. + printk(KERN_CRIT "Would Reboot.\n");
  3163. +#else
  3164. + printk(KERN_CRIT "Initiating system reboot.\n");
  3165. + machine_restart(NULL);
  3166. +#endif
  3167. +#else
  3168. + printk(KERN_CRIT "Reset in 5ms.\n");
  3169. +#endif
  3170. +*/
  3171. +}
  3172. +
  3173. +
  3174. +static struct file_operations lh79520dog_fops=
  3175. +{
  3176. + owner: THIS_MODULE,
  3177. + write: lh79520dog_write,
  3178. + ioctl: lh79520dog_ioctl,
  3179. + open: lh79520dog_open,
  3180. + release: lh79520dog_release,
  3181. +};
  3182. +
  3183. +static struct miscdevice lh79520dog_miscdev=
  3184. +{
  3185. + WATCHDOG_MINOR,
  3186. + "LH79520 watchdog",
  3187. + &lh79520dog_fops
  3188. +};
  3189. +
  3190. +static int __init lh79520dog_init(void)
  3191. +{
  3192. + int ret;
  3193. +
  3194. + ret = misc_register(&lh79520dog_miscdev);
  3195. +
  3196. + if (ret)
  3197. + {
  3198. + goto out;
  3199. + }
  3200. +
  3201. +// ret = request_irq(irq, lh79520dog_interrupt, SA_INTERRUPT, "lh79520wdt", NULL);
  3202. +// if(ret) {
  3203. +// printk(KERN_ERR "wdt: IRQ %d is not free.\n", irq);
  3204. +// goto outmisc;
  3205. +// }
  3206. +
  3207. + printk("LH79520 Watchdog Timer: timer margin %d sec\n", lh79520_margin);
  3208. +
  3209. + ret=0;
  3210. + out:
  3211. + return ret;
  3212. +
  3213. + outmisc:
  3214. + misc_deregister(&lh79520dog_miscdev);
  3215. + goto out;
  3216. +
  3217. +}
  3218. +
  3219. +static void __exit lh79520dog_exit(void)
  3220. +{
  3221. + misc_deregister(&lh79520dog_miscdev);
  3222. +}
  3223. +
  3224. +module_init(lh79520dog_init);
  3225. +module_exit(lh79520dog_exit);
  3226. diff -urN linux-2.4.26/drivers/char/lh79520_wdt.h linux-2.4.26-vrs1-lnode80/drivers/char/lh79520_wdt.h
  3227. --- linux-2.4.26/drivers/char/lh79520_wdt.h 1969-12-31 20:00:00.000000000 -0400
  3228. +++ linux-2.4.26-vrs1-lnode80/drivers/char/lh79520_wdt.h 2005-11-02 17:37:31.000000000 -0400
  3229. @@ -0,0 +1,63 @@
  3230. +/**********************************************************************
  3231. + * $Workfile: LH79520_wdt.h $
  3232. + * $Revision: 1.1.1.1 $
  3233. + * $Author: brad $
  3234. + * $Date: 2003/01/04 17:20:29 $
  3235. + *
  3236. + * Project: LH79520 headers
  3237. + *
  3238. + * Description:
  3239. + * This file contains the structure definitions and manifest
  3240. + * constants for LH79520 component:
  3241. + * Watchdog Timer
  3242. + *
  3243. + * References:
  3244. + * (1) ARM Isis Technical Reference Manual, System on Chip Group,
  3245. + * ARM SC063-TRM-0001-B
  3246. + *
  3247. + * COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
  3248. + * CAMAS, WA
  3249. + *********************************************************************/
  3250. +
  3251. +#ifndef LH79520_WDT_H
  3252. +#define LH79520_WDT_H
  3253. +
  3254. +/*
  3255. + * Watchdog Timer Module Register Structure
  3256. + */
  3257. +typedef struct {
  3258. + volatile unsigned int wdctlr; /* Control */
  3259. + volatile unsigned int wdcntr; /* Counter Reset */
  3260. + volatile unsigned int wdtstr; /* Test */
  3261. + volatile unsigned int wdcnt0; /* Counter Bits [7:0] */
  3262. + volatile unsigned int wdcnt1; /* Counter Bits [15:8] */
  3263. + volatile unsigned int wdcnt2; /* Counter Bits [23:16] */
  3264. + volatile unsigned int wdcnt3; /* Counter Bits [31:24] */
  3265. +} WDTIMERREGS;
  3266. +
  3267. +/**********************************************************************
  3268. + * Watchdog Timer Register Bit Fields
  3269. + *********************************************************************/
  3270. +
  3271. +/**********************************************************************
  3272. + * Watchdog Control Register Bit Fields
  3273. + *********************************************************************/
  3274. +#define WDT_CTRL_DISABLE 0
  3275. +#define WDT_CTRL_ENABLE _SBF(0,1)
  3276. +#define WDT_CTRL_RSP_FIQ _SBF(1,0)
  3277. +#define WDT_CTRL_RSP_RESET _SBF(1,1)
  3278. +#define WDT_CTRL_FRZ_ENABLE _BIT(3)
  3279. +#define WDT_CTRL_TOP _SBF(4,((n)&0xF)
  3280. +
  3281. +/**********************************************************************
  3282. + * Watchdog Counter Reset Register Bit Fields
  3283. + *********************************************************************/
  3284. +#define WDT_WDCNTR (0x1984)
  3285. +
  3286. +/**********************************************************************
  3287. + * Watchdog Register Bit Fields
  3288. + *********************************************************************/
  3289. +#define WDT_WD_NWDFIQ _BIT(7)
  3290. +#define WDT_WD_NWDRES _BIT(6)
  3291. +
  3292. +#endif /* LH79520_WDT_H */
  3293. diff -urN linux-2.4.26/drivers/char/Makefile linux-2.4.26-vrs1-lnode80/drivers/char/Makefile
  3294. --- linux-2.4.26/drivers/char/Makefile 2005-11-02 16:54:20.000000000 -0400
  3295. +++ linux-2.4.26-vrs1-lnode80/drivers/char/Makefile 2005-11-02 17:37:31.000000000 -0400
  3296. @@ -16,7 +16,7 @@
  3297. O_TARGET := char.o
  3298. -obj-y += mem.o tty_io.o n_tty.o tty_ioctl.o raw.o pty.o misc.o random.o
  3299. +obj-y += mem.o tty_io.o n_tty.o tty_ioctl.o raw.o pty.o misc.o random.o cradle.o
  3300. # All of the (potential) objects that export symbols.
  3301. # This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'.
  3302. @@ -349,6 +349,7 @@
  3303. obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o
  3304. obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o
  3305. obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
  3306. +obj-$(CONFIG_LH79520_WATCHDOG) += lh79520_wdt.o
  3307. obj-$(CONFIG_EPXA_WATCHDOG) += epxa_wdt.o
  3308. obj-$(CONFIG_OMAHA_WATCHDOG) += omaha_wdt.o
  3309. obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
  3310. @@ -359,6 +360,12 @@
  3311. # I2C char devices
  3312. obj-$(CONFIG_I2C_DS1307) += ds1307.o
  3313. +# Specific to the LH79520 Sharp dev board.
  3314. +# Controls both PWM0 and PWM1
  3315. +# PWM0 is the backlighting
  3316. +# PWM1 is the audio
  3317. +obj-$(CONFIG_LH79520_PWM) += pwm520.o
  3318. +
  3319. subdir-$(CONFIG_MWAVE) += mwave
  3320. ifeq ($(CONFIG_MWAVE),y)
  3321. obj-y += mwave/mwave.o
  3322. diff -urN linux-2.4.26/drivers/char/pwm520.c linux-2.4.26-vrs1-lnode80/drivers/char/pwm520.c
  3323. --- linux-2.4.26/drivers/char/pwm520.c 1969-12-31 20:00:00.000000000 -0400
  3324. +++ linux-2.4.26-vrs1-lnode80/drivers/char/pwm520.c 2005-11-02 17:37:31.000000000 -0400
  3325. @@ -0,0 +1,870 @@
  3326. +/*
  3327. + * linux/drivers/char/pwm520.c
  3328. + *
  3329. + * Copyright (C) 2002 Lineo.
  3330. + *
  3331. + * Original code write was authored by Craig Matsuura <cmatsuura@lineo.com>
  3332. + * Parts of this code are from Sharp.
  3333. + * This code falls under the license of the GPL.
  3334. + *
  3335. + * This modules is for controlling the PWM audio and backlighting.
  3336. + * Jumps for backlighting and audio must be set correctly on the LH79520
  3337. + * Board for this module to work properly. See Sharp LH79520 Documentation
  3338. + * for jumper settings.
  3339. + */
  3340. +//#define MODULES
  3341. +#include <linux/config.h>
  3342. +#include <linux/delay.h>
  3343. +#include <linux/types.h>
  3344. +#include <linux/fcntl.h>
  3345. +#include <linux/fs.h>
  3346. +#include <linux/init.h>
  3347. +#include <linux/ioctl.h>
  3348. +#include <asm/irq.h>
  3349. +#include <asm/segment.h>
  3350. +#include <asm/uaccess.h>
  3351. +#include <linux/module.h>
  3352. +//#include <limits.h>
  3353. +#include <asm/arch/rcpc.h>
  3354. +#include <asm/arch/iocon.h>
  3355. +#include <asm/arch/hardware.h>
  3356. +
  3357. +#include "pwm520.h"
  3358. +
  3359. +pwmRegs_t *pwmregs = (pwmRegs_t *) IO_ADDRESS( PWM_PHYS);
  3360. +ioconRegs_t *ioconregs = (ioconRegs_t *)IO_ADDRESS( IOCON_PHYS);
  3361. +rcpcRegs_t *rcpcregs = (rcpcRegs_t *)IO_ADDRESS( RCPC_PHYS);
  3362. +
  3363. +#define TYPE(dev) (MINOR(dev) >> 4) /* high nibble */
  3364. +#define NUM(dev) (MINOR(dev) & 0xf) /* low nibble */
  3365. +#if OLDWAY
  3366. +#define PCLK 51609600 /* ticks per second of AHB clock, 51MHz */
  3367. +static int pwm_xtal_freq = XTAL_IN; // From hardware.h
  3368. +static int pwm_clkin_freq = 0; // PLL_CLOCK? LH79520_CLKIN_FREQ;
  3369. +#else
  3370. +unsigned int hclkfreq_get( void);
  3371. +#endif
  3372. +
  3373. +static int pwm_major = 0; // Major Number for Driver 0 indicates dynamic assignment
  3374. +static int pwm_prescale = 1;
  3375. +
  3376. +// Default Freq and Duty Cycles
  3377. +static int pwm_audio_freq = 440; // Freq of tone
  3378. +static int pwm_audio_dcycle = 50; // Duty Cycle for Audio
  3379. +static int pwm_audio_duration = 100000;// Delay (udelay) for beep
  3380. +
  3381. +static int pwm_backlight_dcycle = 100;// DC for Backlight
  3382. +static int pwm_backlight_mode = 0; // Normal Mode
  3383. +static int pwm_backlight_freq = BACKLIGHT_INVERTER_PWM_FREQUENCY; // Freq of backlight
  3384. +
  3385. +#ifdef MODULES
  3386. +MODULE_PARM(pwm_major,"i");
  3387. +MODULE_PARM(pwm_prescale,"i");
  3388. +MODULE_PARM(pwm_xtal_freq,"i");
  3389. +MODULE_PARM(pwm_clkin_freq,"i");
  3390. +MODULE_PARM(pwm_audio_freq,"i");
  3391. +MODULE_PARM(pwm_audio_dcycle,"i");
  3392. +MODULE_PARM(pwm_audio_duration,"i");
  3393. +MODULE_PARM(pwm_backlight_dcycle,"i");
  3394. +MODULE_PARM(pwm_backlight_mode,"i");
  3395. +MODULE_PARM(pwm_backlight_freq,"i");
  3396. +#endif
  3397. +
  3398. +
  3399. +//void showPWM0Registers();
  3400. +
  3401. +#if OLDWAY
  3402. +/**********************************************************************
  3403. +*
  3404. +* Function: rcpc_get_bus_clock - From Sharp Source
  3405. +*
  3406. +* Purpose:
  3407. +* return the frequency of the bus clock.
  3408. +*
  3409. +* Processing:
  3410. +* this function returns the frequency of the bus clock in Hz
  3411. +* based on the value of frequencies passed in and the value
  3412. +* of the RCPC control register CLK_SEL bit.
  3413. +*
  3414. +* Parameters:
  3415. +* xtalin: the frequency at the XTALIN pin; use 0 if there is no
  3416. +* crystal or external clock driving the pin.
  3417. +* clkin: the frequency driving the CLKIN pin; use 0 if that pin
  3418. +* is not driven.
  3419. +*
  3420. +* Outputs: None
  3421. +*
  3422. +* Returns:
  3423. +* The bus clock frequency in Hz
  3424. +*
  3425. +* Notes:
  3426. +* The nominal crystal input frequency in 14745600 Hz.
  3427. +*
  3428. +**********************************************************************/
  3429. +volatile unsigned long rcpc_get_bus_clock(unsigned long xtalin, unsigned long clkin)
  3430. +{
  3431. + unsigned long timebase, divider;
  3432. +
  3433. + if ( (rcpcregs->control & RCPC_CTRL_CLKSEL_EXT)
  3434. + == RCPC_CTRL_CLKSEL_EXT)
  3435. + {
  3436. + /* clock source is external clock */
  3437. + timebase = clkin;
  3438. + }
  3439. + else
  3440. + {
  3441. + /* clock source is from PLL output */
  3442. + timebase = xtalin * 21;
  3443. + }
  3444. +
  3445. + divider = rcpcregs->HCLKPrescale * 2;
  3446. + if (divider == 0)
  3447. + divider = 1;
  3448. +
  3449. + return timebase / divider;
  3450. +}
  3451. +#endif // OLDWAY
  3452. +
  3453. +/**********************************************************************
  3454. +*
  3455. +* Function: pwm1_enable - Taken for Sharp Driver Example code
  3456. +*
  3457. +* Purpose:
  3458. +* Enable PWM output on the PWM1 channel of the LH79520
  3459. +*
  3460. +* Processing:
  3461. +* N/A
  3462. +*
  3463. +* Parameters: None
  3464. +*
  3465. +* Outputs: None
  3466. +*
  3467. +* Returns: Nothing
  3468. +*
  3469. +* Notes:
  3470. +*
  3471. +**********************************************************************/
  3472. +inline volatile void pwm1_enable(void)
  3473. +{
  3474. + pwmregs->pwm1.enable = PWM_EN_ENABLE;
  3475. +}
  3476. +
  3477. +/**********************************************************************
  3478. +*
  3479. +* Function: pwm1_disable - Taken for Sharp Driver Example code
  3480. +*
  3481. +* Purpose:
  3482. +* Disable PWM output on the PWM1 channel of the LH79520
  3483. +*
  3484. +* Processing:
  3485. +* N/A
  3486. +*
  3487. +* Parameters: None
  3488. +*
  3489. +* Outputs: None
  3490. +*
  3491. +* Returns: Nothing
  3492. +*
  3493. +* Notes:
  3494. +*
  3495. +**********************************************************************/
  3496. +inline volatile void pwm1_disable(void)
  3497. +{
  3498. + pwmregs->pwm1.enable = ~PWM_EN_ENABLE;
  3499. +}
  3500. +
  3501. +/**********************************************************************
  3502. +*
  3503. +* Function: pwm0_enable - Taken for Sharp Driver Example code
  3504. +*
  3505. +* Purpose:
  3506. +* Enable PWM output on the PWM0 channel of the LH79520
  3507. +*
  3508. +* Processing:
  3509. +* N/A
  3510. +*
  3511. +* Parameters: None
  3512. +*
  3513. +* Outputs: None
  3514. +*
  3515. +* Returns: Nothing
  3516. +*
  3517. +* Notes:
  3518. +*
  3519. +**********************************************************************/
  3520. +inline volatile void pwm0_enable(void)
  3521. +{
  3522. + pwmregs->pwm0.enable = PWM_EN_ENABLE;
  3523. +}
  3524. +
  3525. +/**********************************************************************
  3526. +*
  3527. +* Function: pwm0_disable - Taken for Sharp Driver Example code
  3528. +*
  3529. +* Purpose:
  3530. +* Disable PWM output on the PWM0 channel of the LH79520
  3531. +*
  3532. +* Processing:
  3533. +* N/A
  3534. +*
  3535. +* Parameters: None
  3536. +*
  3537. +* Outputs: None
  3538. +*
  3539. +* Returns: Nothing
  3540. +*
  3541. +* Notes:
  3542. +*
  3543. +**********************************************************************/
  3544. +inline volatile void pwm0_disable(void)
  3545. +{
  3546. + pwmregs->pwm0.enable = ~PWM_EN_ENABLE;
  3547. +}
  3548. +
  3549. +/**********************************************************************
  3550. +*
  3551. +* Function: pwm0_normal - Taken for Sharp Driver Example code146
  3552. +*
  3553. +* Purpose:
  3554. +* Restores the normal sense of the PWM output signal on the PWM0
  3555. +* channel of the LH79520
  3556. +*
  3557. +* Processing:
  3558. +* N/A
  3559. +*
  3560. +* Parameters: None
  3561. +*
  3562. +* Outputs: None
  3563. +*
  3564. +* Returns: Nothing
  3565. +*
  3566. +* Notes:
  3567. +*
  3568. +**********************************************************************/
  3569. +inline volatile void pwm0_normal(void)
  3570. +{
  3571. + pwmregs->pwm0.invert = ~PWM_INV_INVERT;
  3572. +}
  3573. +
  3574. +
  3575. +/**********************************************************************
  3576. +*
  3577. +* Function: pwm1_frequency - Taken for Sharp Driver Example code
  3578. +*
  3579. +* Purpose:
  3580. +* Sets the PWM1 output frequency to the value specified
  3581. +*
  3582. +* Processing:
  3583. +* Compute the prescale and period count to be programmed from the
  3584. +* PCLK frequency. If the frequency value is too high or too low to
  3585. +* be programmed within the permissible ranges of prescale and period,
  3586. +* signal an error.
  3587. +*
  3588. +* Parameters:
  3589. +* freq - Desired frequency, in Hz
  3590. +*
  3591. +* Outputs: None
  3592. +*
  3593. +* Returns:
  3594. +* -1 - if frequency specified is zero
  3595. +* -1 - if prescale is zero (an impossible condition)
  3596. +* -1 - if the frequency is out of bounds
  3597. +* 0 - if the frequency is changed successfully
  3598. +*
  3599. +* Notes:
  3600. +* This function depends on the values of LH79520_XTAL_FREQ and
  3601. +* LH79520_CLKIN_FREQ to be set correctly in the LH79520_evb.h file.
  3602. +* If external clock is used, LH79520_CLKIN_FREQ should be set
  3603. +* to the external clock frequency. Otherwise, this function will
  3604. +* fail.
  3605. +*
  3606. +*
  3607. +**********************************************************************/
  3608. +long pwm1_frequency(unsigned long freq)
  3609. +{
  3610. + unsigned long pclk, pwm1clk, prescale;
  3611. + unsigned long div;
  3612. +
  3613. + if (0 == freq) {
  3614. + return -1;
  3615. + }
  3616. +
  3617. +#if OLDWAY
  3618. + pclk = rcpc_get_bus_clock(pwm_xtal_freq,pwm_clkin_freq);
  3619. +#else
  3620. + pclk = hclkfreq_get();
  3621. +#endif
  3622. + prescale = rcpcregs->PWM1Prescale;
  3623. + if (prescale > 0) {
  3624. + pwm1clk = pclk / (prescale * 2);
  3625. + } else {
  3626. + printk("<4>THIS IS BAD. SHOULD NOT GET HERE...\n");
  3627. + //this should not happen
  3628. + return -1;
  3629. + }
  3630. + div = pwm1clk / freq;
  3631. + rcpcregs->control |= RCPC_CTRL_WRTLOCK_ENABLED;
  3632. + barrier();
  3633. +
  3634. + while (div > USHRT_MAX && prescale <= SHRT_MAX) {
  3635. + prescale += 1;
  3636. + rcpcregs->PWM1Prescale = prescale;
  3637. + pwm1clk = pclk / (prescale * 2);
  3638. + div = pwm1clk / freq;
  3639. + }
  3640. + rcpcregs->control &= ~RCPC_CTRL_WRTLOCK_ENABLED;
  3641. + pwmregs->pwm1.tc = div;
  3642. +
  3643. + return 0;
  3644. +}
  3645. +
  3646. +
  3647. +/**********************************************************************
  3648. +*
  3649. +* Function: pwm1_duty_cycle - Taken for Sharp Driver Example code
  3650. +*
  3651. +* Purpose:
  3652. +* Sets the PWM1 duty cycle to the value specified
  3653. +*
  3654. +* Processing:
  3655. +* Compute the duty cycle count to program into the dc register
  3656. +* from the percentage specified and the tc count. Accounts for
  3657. +* integer division truncation errors.
  3658. +*
  3659. +* Parameters:
  3660. +* dcpercent - Desired duty cycle as a percentage of the total period
  3661. +*
  3662. +* Outputs: None
  3663. +*
  3664. +* Returns:
  3665. +* the previous value of the duty cycle, as a percentage
  3666. +*
  3667. +* Notes:
  3668. +*
  3669. +**********************************************************************/
  3670. +long pwm1_duty_cycle(short dcpercent)
  3671. +{
  3672. + unsigned short period;
  3673. + unsigned long duty_cycle, prev_dc, prev_dc_percent;
  3674. + period = (unsigned short) pwmregs->pwm1.tc;
  3675. + prev_dc = pwmregs->pwm1.dc;
  3676. + if (period > 0) {
  3677. + prev_dc_percent = ((prev_dc * 100) + (period >> 1)) / period;
  3678. + } else {
  3679. + prev_dc_percent = 100;
  3680. + }
  3681. + duty_cycle = ((dcpercent * period) + 50) / 100;
  3682. + pwmregs->pwm1.dc = duty_cycle;
  3683. + return(long)prev_dc_percent;
  3684. +}
  3685. +
  3686. +/**********************************************************************
  3687. +*
  3688. +* Function: pwm0_frequency - Taken for Sharp Driver Example code
  3689. +*
  3690. +* Purpose:
  3691. +* Sets the PWM0 output frequency to the value specified
  3692. +*
  3693. +* Processing:
  3694. +* Compute the prescale and period count to be programmed from the
  3695. +* PCLK frequency. If the frequency value is too high or too low to
  3696. +* be programmed within the permissible ranges of prescale and period,
  3697. +* signal an error.
  3698. +*
  3699. +* Parameters:
  3700. +* freq - Desired frequency, in Hz
  3701. +*
  3702. +* Outputs: None
  3703. +*
  3704. +* Returns:
  3705. +* -1 - if frequency specified is zero
  3706. +* -1 - if prescale is zero (an impossible condition)
  3707. +* -1 - if the frequency is out of bounds
  3708. +* 0 - if the frequency is changed successfully
  3709. +*
  3710. +* Notes:
  3711. +* This function depends on the values of LH79520_XTAL_FREQ and
  3712. +* LH79520_CLKIN_FREQ to be set correctly in the LH79520_evb.h file.
  3713. +* If external clock is used, LH79520_CLKIN_FREQ should be set
  3714. +* to the external clock frequency. Otherwise, this function will
  3715. +* fail.
  3716. +*
  3717. +*
  3718. +**********************************************************************/
  3719. +long pwm0_frequency(unsigned long freq)
  3720. +{
  3721. + unsigned long pclk, pwm0clk, prescale;
  3722. + unsigned long div;
  3723. +
  3724. + if (0 == freq) {
  3725. + return -1;
  3726. + }
  3727. +
  3728. +#if OLDWAY
  3729. + pclk = rcpc_get_bus_clock(pwm_xtal_freq,pwm_clkin_freq);
  3730. +#else
  3731. + pclk = hclkfreq_get();
  3732. +#endif
  3733. + prescale = rcpcregs->PWM0Prescale;
  3734. + if (prescale > 0) {
  3735. + pwm0clk = pclk / (prescale * 2);
  3736. + } else {
  3737. + printk("<4>THIS IS BAD. SHOULD NOT GET HERE...\n");
  3738. + //this should not happen
  3739. + return -1;
  3740. + }
  3741. + div = pwm0clk / freq;
  3742. + rcpcregs->control |= RCPC_CTRL_WRTLOCK_ENABLED;
  3743. + barrier();
  3744. +
  3745. + //FJB hack for orderite
  3746. + rcpcregs->PWM0Prescale = 0x0a;
  3747. +#if 0
  3748. + while (div > USHRT_MAX && prescale <= SHRT_MAX) {
  3749. + prescale += 1;
  3750. + rcpcregs->PWM0Prescale = prescale;
  3751. + pwm0clk = pclk / (prescale * 2);
  3752. + div = pwm0clk / freq;
  3753. + }
  3754. +#endif
  3755. + rcpcregs->control &= ~RCPC_CTRL_WRTLOCK_ENABLED;
  3756. + //pwmregs->pwm0.tc = div;
  3757. + pwmregs->pwm0.tc = 0x285;
  3758. +
  3759. + return 0;
  3760. +}
  3761. +
  3762. +
  3763. +/**********************************************************************
  3764. +*
  3765. +* Function: pwm0_duty_cycle - Taken for Sharp Driver Example code
  3766. +*
  3767. +* Purpose:
  3768. +* Sets the PWM0 duty cycle to the value specified
  3769. +*
  3770. +* Processing:
  3771. +* Compute the duty cycle count to program into the dc register
  3772. +* from the percentage specified and the tc count. Accounts for
  3773. +* integer division truncation errors.
  3774. +*
  3775. +* Parameters:
  3776. +* dcpercent - Desired duty cycle as a percentage of the total period
  3777. +*
  3778. +* Outputs: None
  3779. +*
  3780. +* Returns:
  3781. +* the previous value of the duty cycle, as a percentage
  3782. +*
  3783. +* Notes:
  3784. +*
  3785. +**********************************************************************/
  3786. +long pwm0_duty_cycle(short dcpercent)
  3787. +{
  3788. + unsigned short period;
  3789. + unsigned long duty_cycle, prev_dc, prev_dc_percent;
  3790. + period = (unsigned short) pwmregs->pwm0.tc;
  3791. + prev_dc = pwmregs->pwm0.dc;
  3792. + if (period > 0) {
  3793. + prev_dc_percent = ((prev_dc * 100) + (period >> 1)) / period;
  3794. + } else {
  3795. + prev_dc_percent = 100;
  3796. + }
  3797. + duty_cycle = ((dcpercent * period) + 50) / 100;
  3798. + pwmregs->pwm0.dc = duty_cycle;
  3799. + return(long)prev_dc_percent;
  3800. +}
  3801. +
  3802. +/**********************************************************************
  3803. +*
  3804. +* Function: backlight_decrease_brightness
  3805. +*
  3806. +* Purpose:
  3807. +* Decrease the LCD backlight brightness
  3808. +*
  3809. +* Processing:
  3810. +* Decrement static variable holding current brightness level and
  3811. +* set the PWM duty cycle.
  3812. +*
  3813. +* Parameters: None
  3814. +*
  3815. +* Outputs: None
  3816. +*
  3817. +* Returns: Nothing
  3818. +*
  3819. +* Notes:
  3820. +*
  3821. +**********************************************************************/
  3822. +void backlight_increase_brightness(void)
  3823. +{
  3824. + pwm_backlight_dcycle--;
  3825. + if (pwm_backlight_dcycle < 0)
  3826. + {
  3827. + pwm_backlight_dcycle = 0;
  3828. + }
  3829. + pwm0_duty_cycle(pwm_backlight_dcycle);
  3830. +}
  3831. +
  3832. +/**********************************************************************
  3833. +*
  3834. +* Function: backlight_increase_brightness
  3835. +*
  3836. +* Purpose:
  3837. +* Increase the LCD backlight brightness
  3838. +*
  3839. +* Processing:
  3840. +* Increment static variable holding current brightness level and
  3841. +* set the PWM duty cycle.
  3842. +*
  3843. +* Parameters: None
  3844. +*
  3845. +* Outputs: None
  3846. +*
  3847. +* Returns: Nothing
  3848. +*
  3849. +* Notes:
  3850. +*
  3851. +**********************************************************************/
  3852. +void backlight_decrease_brightness(void)
  3853. +{
  3854. + pwm_backlight_dcycle++;
  3855. + if (pwm_backlight_dcycle > 100)
  3856. + {
  3857. + pwm_backlight_dcycle = 100;
  3858. + }
  3859. + pwm0_duty_cycle(pwm_backlight_dcycle);
  3860. +}
  3861. +
  3862. +/**********************************************************************
  3863. +*
  3864. +* Function: backlight_set_brightness
  3865. +*
  3866. +* Purpose:
  3867. +* Set the LCD backlight brightness to the level specified
  3868. +*
  3869. +* Processing:
  3870. +* N/A
  3871. +*
  3872. +* Parameters:
  3873. +* bright - desired brightness level as a percentage of maximum
  3874. +* brightness
  3875. +*
  3876. +* Outputs: None
  3877. +*
  3878. +* Returns: Nothing
  3879. +*
  3880. +* Notes:
  3881. +*
  3882. +**********************************************************************/
  3883. +void backlight_set_brightness(int bright)
  3884. +{
  3885. + //bright = 0 means least brightness
  3886. + //bright = 100 means max brightness
  3887. + if (bright > 100)
  3888. + {
  3889. + bright = 100;
  3890. + }
  3891. + if (bright < 0)
  3892. + {
  3893. + bright = 0;
  3894. + }
  3895. +
  3896. + pwm_backlight_dcycle = 100 - bright;
  3897. + pwm0_duty_cycle(pwm_backlight_dcycle);
  3898. +}
  3899. +
  3900. +
  3901. +/****************************************************************************
  3902. + * Open Function - Open the device either the Backlight or the Audio
  3903. + * /dev/pwm0 c 254 1 is the Backlighting
  3904. + * /dev/pwm1 c 254 0 is the Audio
  3905. + * Keep in mind the 254 is only an example. If you do not specify a
  3906. + * major code then a dynamic one will be assigned. You will have to
  3907. + * look at /proc/devices to see the major code for pwm
  3908. + */
  3909. +int pwm_open(struct inode * inode, struct file * filp)
  3910. +{
  3911. +
  3912. + MOD_INC_USE_COUNT;
  3913. +
  3914. +// printk("<4>open pwm... dc=%d, bl_dc=%d\n",pwmregs->pwm0.dc,pwm_backlight_dcycle);
  3915. + switch (NUM(inode->i_rdev)) {
  3916. + case 0: // Audio
  3917. + rcpcregs->control |= RCPC_CTRL_WRTLOCK_ENABLED;
  3918. + barrier();
  3919. + rcpcregs->periphClkCtrl &= ~RCPC_CLKCTRL_PWM0_DISABLE;
  3920. + rcpcregs->PWM0Prescale = ((~_BIT(15)) & pwm_prescale);
  3921. + rcpcregs->control &= ~RCPC_CTRL_WRTLOCK_ENABLED;
  3922. + ioconregs->MiscMux |= MISCMUX_PWM0;
  3923. + break;
  3924. +#if 0
  3925. + case 1: // Backlight
  3926. + rcpcregs->control |= RCPC_CTRL_WRTLOCK_ENABLED;
  3927. + barrier();
  3928. + rcpcregs->periphClkCtrl &= ~RCPC_CLKCTRL_PWM1_DISABLE;
  3929. + rcpcregs->PWM0Prescale = ((~_BIT(15)) & pwm_prescale);
  3930. + rcpcregs->control &= ~RCPC_CTRL_WRTLOCK_ENABLED;
  3931. + ioconregs->MiscMux |= MISCMUX_PWM1;
  3932. +
  3933. + if (pwm_backlight_mode) {
  3934. + pwmregs->pwm0.sync = PWM_SYNC_SYNC;
  3935. + ioconregs->MiscMux |= MISCMUX_PWM0SYNC;
  3936. + }
  3937. + else
  3938. + {
  3939. + pwmregs->pwm0.sync = PWM_SYNC_NORMAL;
  3940. + }
  3941. +
  3942. + pwm0_frequency(pwm_backlight_freq);
  3943. + pwm0_duty_cycle(pwm_backlight_dcycle);
  3944. + pwm0_normal();
  3945. + pwm0_enable();
  3946. + break;
  3947. +#endif
  3948. + default:
  3949. + printk("<4>Minor device unknown %d\n",NUM(inode->i_rdev));
  3950. + break;
  3951. + }
  3952. +
  3953. + return 0;
  3954. +}
  3955. +
  3956. +/****************************************************************************
  3957. + *
  3958. + */
  3959. +int pwm_release(struct inode *inode, struct file * filp)
  3960. +{
  3961. +// printk("<4>release pwm...\n");
  3962. + switch (NUM(inode->i_rdev)) {
  3963. + case 0: // Audio
  3964. + rcpcregs->control |= RCPC_CTRL_WRTLOCK_ENABLED;
  3965. + barrier();
  3966. + rcpcregs->periphClkCtrl |= RCPC_CLKCTRL_PWM0_DISABLE;
  3967. + rcpcregs->control &= ~RCPC_CTRL_WRTLOCK_ENABLED;
  3968. + ioconregs->MiscMux &= ~MISCMUX_PWM0;
  3969. + pwm0_disable();
  3970. + break;
  3971. + case 1: // Should be backlight of touchscreen
  3972. + //rcpcregs->control |= RCPC_CTRL_WRTLOCK_ENABLED;
  3973. + //barrier();
  3974. + //rcpcregs->periphClkCtrl |= RCPC_CLKCTRL_PWM0_DISABLE;
  3975. + //rcpcregs->control &= ~RCPC_CTRL_WRTLOCK_ENABLED;
  3976. + //ioconregs->MiscMux &= ~MISCMUX_PWM0;
  3977. + //pwmregs->pwm0.enable = ~PWM_EN_ENABLE;
  3978. + break;
  3979. +
  3980. + default:
  3981. + printk("<4>Minor device unknown %d\n",NUM(inode->i_rdev));
  3982. + break;
  3983. + }
  3984. +
  3985. + MOD_DEC_USE_COUNT;
  3986. + return 0;
  3987. +}
  3988. +
  3989. +/****************************************************************************
  3990. + *
  3991. + */
  3992. +ssize_t pwm_read(struct file * file, char * buf,
  3993. + size_t count, loff_t *ppos)
  3994. +{
  3995. + return 0;
  3996. +}
  3997. +
  3998. +/****************************************************************************
  3999. + *
  4000. + */
  4001. +ssize_t pwm_write(struct file * file, const char * buf,
  4002. + size_t count, loff_t *ppos)
  4003. +{
  4004. + return 0;
  4005. +}
  4006. +
  4007. +/****************************************************************************
  4008. + *
  4009. + */
  4010. +int pwm_ioctl(struct inode *inode, struct file * file,
  4011. + unsigned int cmd, unsigned long arg)
  4012. +{
  4013. + //int err = 0, size = _IOC_SIZE(cmd);
  4014. +
  4015. + if (_IOC_TYPE(cmd) != PWM520_IOC_MAGIC) {
  4016. + return -EINVAL;
  4017. + }
  4018. + if (_IOC_NR(cmd) > PWM520_IOC_MAXNR) {
  4019. + return -EINVAL;
  4020. + }
  4021. +
  4022. + /*
  4023. + Should check for direction bits see page 101 in "Linux Device Drivers Book"
  4024. + size and err used here.
  4025. + */
  4026. +
  4027. + switch (NUM(inode->i_rdev)) {
  4028. + case 0: // Audio
  4029. + switch (cmd) {
  4030. + case PWM520_IOCBEEP:
  4031. + pwm0_frequency(pwm_audio_freq);
  4032. + pwm0_duty_cycle(pwm_audio_dcycle);
  4033. + pwm0_enable();
  4034. + udelay(pwm_audio_duration);
  4035. + pwm0_disable();
  4036. + break;
  4037. +
  4038. + case PWM520_IOCSTARTSND:
  4039. + pwm0_frequency(pwm_audio_freq);
  4040. + pwm0_duty_cycle(pwm_audio_dcycle);
  4041. + pwm0_enable();
  4042. + break;
  4043. +
  4044. + case PWM520_IOCSTOPSND:
  4045. + pwm0_disable();
  4046. + break;
  4047. +
  4048. + case PWM520_IOCSETFREQ: // Set Frequency
  4049. + pwm_audio_freq = arg;
  4050. + break;
  4051. +
  4052. + case PWM520_IOCSETDCYCLE: // Set Duty Cycle
  4053. + pwm_audio_dcycle = arg;
  4054. + break;
  4055. +
  4056. + case PWM520_IOCGETFREQ: // Get Frequency
  4057. + __put_user(pwm_audio_freq, (int *) arg);
  4058. + break;
  4059. +
  4060. + case PWM520_IOCGETDCYCLE: // Get Duty Cycle
  4061. + __put_user(pwm_audio_dcycle, (int *) arg);
  4062. + break;
  4063. + }
  4064. + break;
  4065. +#if 0
  4066. + case 1: // Should be backlight of touchscreen
  4067. + switch (cmd) {
  4068. + case PWM520_IOCRESET:
  4069. +// printk("Reset pwm0\n");
  4070. + pwm_backlight_dcycle = 100;// DC for Backlight
  4071. + pwm_backlight_mode = 0; // Normal Mode
  4072. + pwm_backlight_freq = BACKLIGHT_INVERTER_PWM_FREQUENCY; // Freq of backlight
  4073. + break;
  4074. + case PWM520_IOCSTOPPWM0: // Stop PWM0
  4075. + rcpcregs->control |= RCPC_CTRL_WRTLOCK_ENABLED;
  4076. + barrier();
  4077. + rcpcregs->periphClkCtrl |= RCPC_CLKCTRL_PWM0_DISABLE;
  4078. + rcpcregs->control &= ~RCPC_CTRL_WRTLOCK_ENABLED;
  4079. + ioconregs->MiscMux &= ~MISCMUX_PWM0;
  4080. + pwmregs->pwm0.enable = ~PWM_EN_ENABLE;
  4081. + break;
  4082. + case PWM520_IOCINCREASEBL:
  4083. +// printk("Brighter\n");
  4084. + backlight_increase_brightness();
  4085. + break;
  4086. +
  4087. + case PWM520_IOCDECREASEBL:
  4088. +// printk("Lighter\n");
  4089. + backlight_decrease_brightness();
  4090. + break;
  4091. +
  4092. + case PWM520_IOCSETBL:
  4093. +// printk("Set to %ld\n",arg);
  4094. + backlight_set_brightness(arg);
  4095. + break;
  4096. + }
  4097. + break;
  4098. +#endif
  4099. +
  4100. + }
  4101. +
  4102. + return 0;
  4103. +}
  4104. +
  4105. +
  4106. +/****************************************************************************
  4107. + *
  4108. + */
  4109. +struct file_operations pwm_fops = {
  4110. + owner: THIS_MODULE,
  4111. + llseek: no_llseek,
  4112. + read: pwm_read,
  4113. + write: pwm_write,
  4114. + ioctl: pwm_ioctl,
  4115. + open: pwm_open,
  4116. + release: pwm_release,
  4117. +};
  4118. +
  4119. +#if 0
  4120. +void test_pwm1()
  4121. +{
  4122. + printk("TEST CASE PLEASE REMOVE ONCE DONE\n");
  4123. +
  4124. + rcpcregs->control |= RCPC_CTRL_WRTLOCK_ENABLED;
  4125. + barrier();
  4126. + rcpcregs->periphClkCtrl &= ~RCPC_CLKCTRL_PWM1_DISABLE;
  4127. + rcpcregs->PWM1Prescale = ((~_BIT(15)) & pwm_prescale);
  4128. + rcpcregs->control &= ~RCPC_CTRL_WRTLOCK_ENABLED;
  4129. + ioconregs->MiscMux |= MISCMUX_PWM1;
  4130. +
  4131. + pwm1_frequency(pwm_audio_freq);
  4132. + pwm1_duty_cycle(pwm_audio_dcycle);
  4133. + pwm1_enable();
  4134. +}
  4135. +
  4136. +void showPWM1Registers()
  4137. +{
  4138. + printk("PWM1 Registers\n");
  4139. + printk("=============\n\n");
  4140. + printk("pwm1.tc = %x\n",pwmregs->pwm1.tc);
  4141. + printk("pwm1.dc = %x\n",pwmregs->pwm1.dc);
  4142. + printk("pwm1.enable = %x\n",pwmregs->pwm1.enable);
  4143. + printk("pwm1.invert = %x\n",pwmregs->pwm1.invert);
  4144. + printk("pwm1.sync = %x\n",pwmregs->pwm1.sync);
  4145. +}
  4146. +
  4147. +void showPWM0Registers()
  4148. +{
  4149. + printk("PWM0 Registers\n");
  4150. + printk("=============\n\n");
  4151. + printk("pwm0.tc = %d\n",pwmregs->pwm0.tc);
  4152. + printk("pwm0.dc = %d\n",pwmregs->pwm0.dc);
  4153. + printk("pwm0.enable = 0x%x\n",pwmregs->pwm0.enable);
  4154. + printk("pwm0.invert = 0x%x\n",pwmregs->pwm0.invert);
  4155. + printk("pwm0.sync = 0x%x\n",pwmregs->pwm0.sync);
  4156. +}
  4157. +
  4158. +#endif
  4159. +
  4160. +/****************************************************************************
  4161. + *
  4162. + */
  4163. +static int __init pwm_init_module(void)
  4164. +{
  4165. + int result;
  4166. +
  4167. + //printk("<1>Start PWM Module\n");
  4168. + printk("<1>Sharp LH79520 PWM Driver Copyright 2002 Lineo\n");
  4169. +
  4170. + result = register_chrdev(pwm_major,"pwm",&pwm_fops);
  4171. + if (result < 0) {
  4172. + printk("<4>pwm: can't get major number %d\n",pwm_major);
  4173. + return result;
  4174. + }
  4175. + if (pwm_major == 0) {
  4176. + pwm_major = result; /* Dynamic Allocation of major number */
  4177. + printk("<4>PWM Dynamic Major Number %d\n",pwm_major);
  4178. + }
  4179. +
  4180. + return 0;
  4181. +}
  4182. +
  4183. +/****************************************************************************
  4184. + *
  4185. + */
  4186. +static void __exit pwm_cleanup_module(void)
  4187. +{
  4188. + int result;
  4189. +
  4190. + printk("<1>End PWM Module...\n");
  4191. + result = unregister_chrdev(pwm_major,"pwm");
  4192. +}
  4193. +
  4194. +module_init(pwm_init_module);
  4195. +module_exit(pwm_cleanup_module);
  4196. diff -urN linux-2.4.26/drivers/char/pwm520.h linux-2.4.26-vrs1-lnode80/drivers/char/pwm520.h
  4197. --- linux-2.4.26/drivers/char/pwm520.h 1969-12-31 20:00:00.000000000 -0400
  4198. +++ linux-2.4.26-vrs1-lnode80/drivers/char/pwm520.h 2005-11-02 17:37:31.000000000 -0400
  4199. @@ -0,0 +1,58 @@
  4200. +/*
  4201. + * linux/drivers/char/pwm520.h
  4202. + *
  4203. + * Copyright (C) 2002 Lineo.
  4204. + *
  4205. + * Original code write was authored by Craig Matsuura <cmatsuura@lineo.com>
  4206. + * Parts of this code are from Sharp.
  4207. + * This code falls under the license of the GPL.
  4208. + *
  4209. + * This modules is for controlling the PWM audio and backlighting.
  4210. + * Jumps for backlighting and audio must be set correctly on the LH79520
  4211. + * Board for this module to work properly. See Sharp LH79520 Documentation
  4212. + * for jumper settings.
  4213. + */
  4214. +#ifndef __PWM520_H
  4215. +#define __PWM520_H
  4216. +
  4217. +typedef struct {
  4218. + volatile unsigned int tc;
  4219. + volatile unsigned int dc;
  4220. + volatile unsigned int enable;
  4221. + volatile unsigned int invert;
  4222. + volatile unsigned int sync;
  4223. + volatile unsigned int res[3];
  4224. +} pwmXRegs_t;
  4225. +
  4226. +typedef struct {
  4227. + volatile pwmXRegs_t pwm0;
  4228. + volatile pwmXRegs_t pwm1;
  4229. +} pwmRegs_t;
  4230. +
  4231. +extern pwmRegs_t *pwmregs;
  4232. +
  4233. +#define PWM_EN_ENABLE _BIT(0)
  4234. +#define PWM_INV_INVERT _BIT(0)
  4235. +#define PWM_SYNC_SYNC _SBF(0,1)
  4236. +#define PWM_SYNC_NORMAL _SBF(0,0)
  4237. +
  4238. +#define BACKLIGHT_INVERTER_PWM_FREQUENCY (200) // 200Hz
  4239. +
  4240. +// IOCTL's
  4241. +#define PWM520_IOC_MAGIC 'p'
  4242. +#define PWM520_IOCBEEP _IO(PWM520_IOC_MAGIC, 0)
  4243. +#define PWM520_IOCSTARTSND _IO(PWM520_IOC_MAGIC, 1)
  4244. +#define PWM520_IOCSTOPSND _IO(PWM520_IOC_MAGIC, 2)
  4245. +#define PWM520_IOCSETFREQ _IOW(PWM520_IOC_MAGIC, 3, int)
  4246. +#define PWM520_IOCSETDCYCLE _IOW(PWM520_IOC_MAGIC, 4, int)
  4247. +#define PWM520_IOCGETFREQ _IOR(PWM520_IOC_MAGIC, 5, int)
  4248. +#define PWM520_IOCGETDCYCLE _IOR(PWM520_IOC_MAGIC, 6, int)
  4249. +
  4250. +#define PWM520_IOCRESET _IO(PWM520_IOC_MAGIC, 7)
  4251. +#define PWM520_IOCSTOPPWM0 _IO(PWM520_IOC_MAGIC, 8)
  4252. +#define PWM520_IOCINCREASEBL _IO(PWM520_IOC_MAGIC, 9)
  4253. +#define PWM520_IOCDECREASEBL _IO(PWM520_IOC_MAGIC, 10)
  4254. +#define PWM520_IOCSETBL _IOW(PWM520_IOC_MAGIC, 11, int)
  4255. +
  4256. +#define PWM520_IOC_MAXNR 11
  4257. +#endif
  4258. diff -urN linux-2.4.26/drivers/misc/ads784x.c linux-2.4.26-vrs1-lnode80/drivers/misc/ads784x.c
  4259. --- linux-2.4.26/drivers/misc/ads784x.c 1969-12-31 20:00:00.000000000 -0400
  4260. +++ linux-2.4.26-vrs1-lnode80/drivers/misc/ads784x.c 2005-11-02 17:37:31.000000000 -0400
  4261. @@ -0,0 +1,1064 @@
  4262. +/* vi: set sw=4 ts=4 ai: */
  4263. +
  4264. +// #define MODULE
  4265. +
  4266. +#define TS_DATA_QTOPIA
  4267. +#undef CONFIG_ADS7846
  4268. +
  4269. +/**********************************************************************
  4270. +* linux/drivers/misc/ads784x.c
  4271. +*
  4272. +* Provide ADS_784x (touchscreen) functionality for LH7x EVB boards
  4273. +*
  4274. +* Copyright (C) 2002 Lineo, Inc.
  4275. +*
  4276. +* This program is free software; you can redistribute it and/or modify
  4277. +* it under the terms of the GNU General Public License (GPL) version 2
  4278. +* as published by the Free Software Foundation.
  4279. +*
  4280. +**********************************************************************/
  4281. +
  4282. +/**********************************************************************
  4283. +* Algorithm:
  4284. +*
  4285. +* The driver sleeps when there is no pen on the screen. When a pen_down
  4286. +* interrupt occurs, the pen_down interrupt handler wakes the polling thread.
  4287. +* The polling thread polls the ADS chip SAMPLES_PER_SECOND. When the polling
  4288. +* thread polls the ADS chip and the pen is no longer down, the polling
  4289. +* thread goes to sleep and the pen_down interrupt handler is enabled.
  4290. +*
  4291. +* The ADS device sleeps between conversions to save power.
  4292. +*
  4293. +* The driver stores pen coordinates in a queue. An application can access
  4294. +* the coordinate queue by opening and reading the associated device file
  4295. +* (char major=10 minor=20). An application can poll the queue to see if
  4296. +* it contains coordinates. If it does, the application can read a coordinate
  4297. +* structure back. The coordinate queue is flushed when the application
  4298. +* opens the device file.
  4299. +*
  4300. +**********************************************************************/
  4301. +
  4302. +#include <linux/config.h>
  4303. +#include <linux/types.h>
  4304. +#include <linux/kernel.h>
  4305. +#include <linux/init.h>
  4306. +#include <linux/module.h>
  4307. +#include <linux/delay.h>
  4308. +#include <linux/proc_fs.h>
  4309. +#include <linux/smp_lock.h>
  4310. +#include <linux/miscdevice.h>
  4311. +#include <linux/poll.h>
  4312. +
  4313. +#undef DEBUG
  4314. +#undef VERBOSE
  4315. +#define DRVNAME "ads_784x"
  4316. +#include <linux/verbosedebug.h>
  4317. +
  4318. +#include <linux/version.h>
  4319. +#ifdef MODULE
  4320. +char kernel_version[] = UTS_RELEASE;
  4321. +#endif /* MODULE */
  4322. +
  4323. +#include "ssp.h"
  4324. +
  4325. +#if defined(CONFIG_ADS7846) && defined(CONFIG_PROC_FS)
  4326. +# define PROC_TEMPERATURE
  4327. +# define PROC_BATTERY
  4328. +#endif
  4329. +
  4330. +#ifdef PROC_BATTERY
  4331. +static struct proc_dir_entry *ads_784x_proc_battery;
  4332. +#endif
  4333. +#ifdef PROC_TEMPERATURE
  4334. +static struct proc_dir_entry *ads_784x_proc_temperature;
  4335. +#endif
  4336. +
  4337. +/*********************************************************************
  4338. +* A couple of macros we use here...
  4339. +*********************************************************************/
  4340. +#ifndef _BIT
  4341. +#define _BIT(n) (1 << (n))
  4342. +#endif
  4343. +#ifndef _SBF
  4344. +#define _SBF(f,v) ((v) << (f))
  4345. +#endif
  4346. +#ifndef _BITMASK
  4347. +#define _BITMASK(field_width) ( _BIT(field_width) - 1)
  4348. +#endif
  4349. +
  4350. +/**********************************************************************
  4351. +* Define ADS 784x Control byte
  4352. +**********************************************************************/
  4353. +
  4354. +#define CTRL_S _BIT(7) /* Start bit (REQUIRED) */
  4355. +
  4356. +// #define CTRL_ADDR(n) _SBF(4,(n&0x7))
  4357. +#define CTRL_X _SBF(4,0x1) /* Read X value */
  4358. +#define CTRL_Y _SBF(4,0x5) /* Read Y value */
  4359. +#ifdef CONFIG_ADS7846
  4360. +#define CTRL_P1 _SBF(4,0x3) /* Read P1 value */
  4361. +#define CTRL_P2 _SBF(4,0x4) /* Read P2 value */
  4362. +#define CTRL_BATTERY _SBF(4,0x2) /* Read BATTERY value */
  4363. +#define CTRL_TEMP0 _SBF(4,0x0) /* Read Temperature-0 value */
  4364. +#define CTRL_TEMP1 _SBF(4,0x7) /* Read Temperature-1 value */
  4365. +#endif // CONFIG_ADS7846
  4366. +
  4367. +// #define CTRL_MODE(n) _SBF(3,(n&0x1))
  4368. +#define CTRL_12BIT _SBF(3,0x0) /* 12-Bit conversions */
  4369. +#define CTRL_8BIT _SBF(3,0x1) /* 8-Bit conversions */
  4370. +
  4371. +// #define CTRL_SER_DFR(n) _SBF(2,(n&0x1))
  4372. +#define CTRL_SER _SBF(2,0x1) /* Single-Ended reference */
  4373. +#define CTRL_DFR _SBF(2,0x0) /* Differential reference */
  4374. +
  4375. +// #define CTRL_PD(n) (n&0x3)
  4376. +#define CTRL_PD_ZERO (0x0) /* PenIRQ enabled - PowerDown after */
  4377. +#define CTRL_PD_ONE (0x1) /* PenIRQ disabled - PowerDown after */
  4378. +#define CTRL_PD_TWO (0x2) /* PenIRQ disabled - RESERVED */
  4379. +#define CTRL_PD_THREE (0x3) /* PenIRQ disabled - Powered ON */
  4380. +
  4381. +/**********************************************************************
  4382. +* Define Simplified ADS 784x Control Codes
  4383. +**********************************************************************/
  4384. +
  4385. +//#define ADS_784x_PD 0 /* Power Down Settings */
  4386. +//#define ADS_784x_PD_INIT 0 /* Init setting reference and ADC Off */
  4387. +
  4388. +#define ADS_784x_INIT \
  4389. + ( CTRL_S | CTRL_X | CTRL_12BIT | CTRL_DFR | CTRL_PD_ZERO)
  4390. +#define ADS_784x_READ_X \
  4391. + ( CTRL_S | CTRL_X | CTRL_12BIT | CTRL_DFR | CTRL_PD_ZERO)
  4392. +#define ADS_784x_READ_Y \
  4393. + ( CTRL_S | CTRL_Y | CTRL_12BIT | CTRL_DFR | CTRL_PD_ZERO)
  4394. +#ifdef CONFIG_ADS7846
  4395. +#define ADS_784x_READ_P1 \
  4396. + ( CTRL_S | CTRL_P1 | CTRL_12BIT | CTRL_DFR | CTRL_PD_ZERO)
  4397. +#define ADS_784x_READ_P2 \
  4398. + ( CTRL_S | CTRL_P2 | CTRL_12BIT | CTRL_DFR | CTRL_PD_ZERO)
  4399. +#define ADS_784x_READ_BATTERY \
  4400. + ( CTRL_S | CTRL_BATTERY | CTRL_12BIT | CTRL_SER | CTRL_PD_ZERO)
  4401. +#define ADS_784x_READ_TEMP0 \
  4402. + ( CTRL_S | CTRL_TEMP0 | CTRL_12BIT | CTRL_SER | CTRL_PD_ZERO)
  4403. +#define ADS_784x_READ_TEMP1 \
  4404. + ( CTRL_S | CTRL_TEMP1 | CTRL_12BIT | CTRL_SER | CTRL_PD_ZERO)
  4405. +#endif // CONFIG_ADS7846
  4406. +
  4407. +/**********************************************************************
  4408. +* Define our touchscreen data type
  4409. +*
  4410. +* This structure is nonsense - millisecs is not very useful
  4411. +* since the field size is too small. Also, we SHOULD NOT
  4412. +* be exposing jiffies to user space directly.
  4413. +**********************************************************************/
  4414. +typedef struct tsData_t tsData_t;
  4415. +
  4416. +#ifdef TS_DATA_COLLIE
  4417. +#define TS_DATA_STRUCT
  4418. +#define PROVIDE_TS_MILLISECS
  4419. +struct tsData_t {
  4420. + long x;
  4421. + long y;
  4422. + long pressure;
  4423. + long long millisecs;
  4424. +};
  4425. +#endif
  4426. +
  4427. +#ifdef TS_DATA_IPAQ
  4428. +#define TS_DATA_STRUCT
  4429. +struct tsData_t {
  4430. + unsigned short pressure;
  4431. + unsigned short x;
  4432. + unsigned short y;
  4433. + unsigned short pad;
  4434. +};
  4435. +#endif
  4436. +
  4437. +#ifdef TS_DATA_LH79X
  4438. +#define TS_DATA_STRUCT
  4439. +struct tsData_t {
  4440. + uint16_t pressure;
  4441. + uint16_t y; /* Will be read as X */
  4442. + uint16_t x; /* Will be read as Y */
  4443. + uint16_t pad;
  4444. +};
  4445. +#endif
  4446. +
  4447. +/*
  4448. +QTopia data format:
  4449. +unsigned char data2[5];
  4450. +data.status=data2[0]; // bit 0x40 is "touch"/left mouse
  4451. +data.xpos=(data2[1] << 8) | data2[2];
  4452. +data.ypos=(data2[3] << 8) | data2[4];
  4453. +*/
  4454. +
  4455. +#ifdef TS_DATA_QTOPIA
  4456. +#define TS_DATA_STRUCT
  4457. +struct tsData_t {
  4458. + unsigned char pressure;
  4459. + unsigned char xhigh;
  4460. + unsigned char xlow;
  4461. + unsigned char yhigh;
  4462. + unsigned char ylow;
  4463. +} __attribute__ ((packed));
  4464. +#endif
  4465. +
  4466. +#ifndef TS_DATA_STRUCT
  4467. +#define TS_DATA_DEFAULT
  4468. +#define PROVIDE_TS_TIMESTAMP
  4469. +struct tsData_t {
  4470. + uint16_t pressure;
  4471. + uint16_t x;
  4472. + uint16_t y;
  4473. + uint16_t pad;
  4474. + struct timeval stamp;
  4475. +};
  4476. +#endif
  4477. +
  4478. +#define MAX_TS_DATA 16
  4479. +
  4480. +#define X_DELTA_MAX 10
  4481. +#define Y_DELTA_MAX 10
  4482. +
  4483. +/* Define the readings we are to take per second (default to 50) */
  4484. +#define SAMPLES_PER_SECOND 10
  4485. +
  4486. +/*
  4487. +* Define the pen down debounce we are to take.
  4488. +* (default of 20 == 1/20 of a second)
  4489. +*/
  4490. +#define DEBOUNCE_FRACTION_OF_A_SECOND 50
  4491. +
  4492. +/**********************************************************************
  4493. +* Define our ADS context structure
  4494. +**********************************************************************/
  4495. +typedef struct adsContext_t adsContext_t;
  4496. +struct adsContext_t {
  4497. +
  4498. + void *sspContext;
  4499. + void (*write) (void *sspContext, unsigned int data);
  4500. + unsigned int (*read) (void *sspContext);
  4501. + int (*enable_pen_down_irq)(void *sspContext);
  4502. + int (*disable_pen_down_irq)(void *sspContext);
  4503. + int (*is_pen_down)(void *sspContext);
  4504. + int (*lock)(void *sspContext, int device);
  4505. + int (*unlock)(void *sspContext, int device);
  4506. + void (*chipselect_enable)(void);
  4507. + void (*chipselect_disable)(void);
  4508. + void (*chipselect_manual)(void);
  4509. +
  4510. + struct fasync_struct *fasync;
  4511. + struct completion complete;
  4512. + struct task_struct *rtask;
  4513. +
  4514. + wait_queue_head_t read_wait;
  4515. + wait_queue_head_t irq_wait;
  4516. +
  4517. + int tsDataHead;
  4518. + int tsDataTail;
  4519. + tsData_t tsData[MAX_TS_DATA];
  4520. +};
  4521. +static adsContext_t adsContext_l;
  4522. +
  4523. +/**********************************************************************
  4524. +* Macro: ads_784x_tsData_pending
  4525. +**********************************************************************/
  4526. +#define ads_784x_tsData_pending(adsContext) \
  4527. + ((adsContext)->tsDataHead != (adsContext)->tsDataTail)
  4528. +
  4529. +/**********************************************************************
  4530. +* Macro: ads_784x_tsData_get
  4531. +**********************************************************************/
  4532. +#define ads_784x_tsData_get(adsContext) \
  4533. + ((adsContext)->tsData + (adsContext)->tsDataTail)
  4534. +
  4535. +/**********************************************************************
  4536. +* Macro: ads_784x_tsData_pull
  4537. +**********************************************************************/
  4538. +#define ads_784x_tsData_pull(adsContext) \
  4539. + ((adsContext)->tsDataTail = \
  4540. + ((adsContext)->tsDataTail + 1) & (MAX_TS_DATA - 1))
  4541. +
  4542. +/**********************************************************************
  4543. +* Macro: ads_784x_tsData_flush
  4544. +**********************************************************************/
  4545. +#define ads_784x_tsData_flush(adsContext) \
  4546. + ((adsContext)->tsDataTail = (adsContext)->tsDataHead)
  4547. +
  4548. +/**********************************************************************
  4549. +* Function: ads_784x_tsData_add
  4550. +**********************************************************************/
  4551. +static inline void ads_784x_tsData_add(
  4552. + adsContext_t *adsContext,
  4553. + unsigned int pressure,
  4554. + unsigned int x,
  4555. + unsigned int y)
  4556. +{
  4557. + int next_head;
  4558. + long xcoff, ycoff;
  4559. +
  4560. + vdprintk("ENTER: ads_784x_tsData_add()\n");
  4561. + next_head = (adsContext->tsDataHead + 1) & (MAX_TS_DATA - 1);
  4562. + if (next_head != adsContext->tsDataTail) {
  4563. +#ifndef TS_DATA_QTOPIA
  4564. + adsContext->tsData[adsContext->tsDataHead].pressure = pressure;
  4565. + adsContext->tsData[adsContext->tsDataHead].x = x;
  4566. + adsContext->tsData[adsContext->tsDataHead].y = y;
  4567. +#ifdef PROVIDE_TS_TIMESTAMP
  4568. + get_fast_time(&adsContext->tsData[adsContext->tsDataHead].stamp);
  4569. +#endif
  4570. +#else // TS_DATA_QTOPIA
  4571. + adsContext->tsData[adsContext->tsDataHead].pressure = pressure ? 0x40 : 0;
  4572. + adsContext->tsData[adsContext->tsDataHead].xlow = x & 0xFF;
  4573. + adsContext->tsData[adsContext->tsDataHead].xhigh = x >> 8;
  4574. + adsContext->tsData[adsContext->tsDataHead].ylow = y & 0xFF;
  4575. + adsContext->tsData[adsContext->tsDataHead].yhigh = y >> 8;
  4576. +#endif // TS_DATA_QTOPIA
  4577. + adsContext->tsDataHead = next_head;
  4578. + if (adsContext->fasync)
  4579. + kill_fasync(&adsContext->fasync, SIGIO, POLL_IN);
  4580. + wake_up_interruptible(&adsContext->read_wait);
  4581. + }
  4582. + vdprintk("LEAVE: ads_784x_tsData_add()\n");
  4583. + return;
  4584. +}
  4585. +
  4586. +/**********************************************************************
  4587. +* Function: ads_784x_Read_tsData
  4588. +**********************************************************************/
  4589. +static int x_last, y_last;
  4590. +static int ads_784x_Read_tsData(adsContext_t *adsContext)
  4591. +{
  4592. + void *sspContext = adsContext->sspContext;
  4593. + int x=0, x_1=0, x_2=0;
  4594. + int y=0, y_1=0, y_2=0;
  4595. + int pen_down = 0;
  4596. + int p = 0;
  4597. +#ifdef CONFIG_ADS7846
  4598. + int p1=0, p1_1=0, p1_2=0;
  4599. + int p2=0, p2_1=0, p2_2=0;
  4600. +#endif
  4601. +
  4602. + vdprintk("ENTER: ads_784x_Read_tsData()\n");
  4603. +
  4604. +#define TS_AVG_ITERS 8
  4605. +
  4606. + /*
  4607. + * Filtering is policy. Policy belongs in user space. We
  4608. + * therefore leave it to user space to do any filtering
  4609. + * they please.
  4610. + *
  4611. + * We do however, read twice and check against maximum x & y deltas
  4612. + * to reduce the amount of garbage returned.
  4613. + *
  4614. + * Note: There will be one reading with p=0 given when the pen is raised.
  4615. + */
  4616. +
  4617. + /* Read the pen_down data first as it jitters after the other reads */
  4618. + /* MUST lock the SSP before accessing it */
  4619. + adsContext->lock(sspContext, SSP_DEV_TOUCHSCREEN);
  4620. + pen_down = adsContext->is_pen_down(sspContext);
  4621. + /* MUST unlock the SSP after it has been locked */
  4622. + adsContext->unlock(sspContext, SSP_DEV_TOUCHSCREEN);
  4623. +
  4624. + do {
  4625. + /* MUST lock the SSP before accessing it */
  4626. + adsContext->lock(sspContext, SSP_DEV_TOUCHSCREEN);
  4627. + /*
  4628. + * Read the pressure, X position, and Y position.
  4629. + * Interleave them for better performance
  4630. + */
  4631. + //FJB
  4632. + adsContext->chipselect_enable();
  4633. +#ifdef CONFIG_ADS7846
  4634. + adsContext->write(sspContext, ADS_784x_READ_P1);
  4635. + adsContext->write(sspContext, ADS_784x_READ_P2);
  4636. + p1_1 = adsContext->read(sspContext);
  4637. + p2_1 = adsContext->read(sspContext);
  4638. +#endif
  4639. + adsContext->write(sspContext, ADS_784x_READ_X);
  4640. + x_1 = adsContext->read(sspContext);
  4641. + adsContext->write(sspContext, ADS_784x_READ_Y);
  4642. + y_1 = adsContext->read(sspContext);
  4643. +
  4644. + /*
  4645. + * ... AGAIN ...
  4646. + * Read the pressure, X position, and Y position.
  4647. + * Interleave them for better performance
  4648. + */
  4649. +#ifdef CONFIG_ADS7846
  4650. + adsContext->write(sspContext, ADS_784x_READ_P1);
  4651. + adsContext->write(sspContext, ADS_784x_READ_P2);
  4652. + p1_2 = adsContext->read(sspContext);
  4653. + p2_2 = adsContext->read(sspContext);
  4654. +#endif
  4655. + adsContext->write(sspContext, ADS_784x_READ_X);
  4656. + x_2 = adsContext->read(sspContext);
  4657. + adsContext->write(sspContext, ADS_784x_READ_Y);
  4658. + y_2 = adsContext->read(sspContext);
  4659. +
  4660. + //FJB
  4661. + adsContext->chipselect_disable();
  4662. +
  4663. + /* MUST unlock the SSP after it has been locked */
  4664. + adsContext->unlock(sspContext, SSP_DEV_TOUCHSCREEN);
  4665. +
  4666. + } while ((x_1 > (x_2+X_DELTA_MAX)) || (x_2 > (x_1+X_DELTA_MAX))
  4667. + || (y_1 > (y_2+Y_DELTA_MAX)) || (y_2 > (y_1+Y_DELTA_MAX))
  4668. + || (x_1 == 0) || (y_1 == 0) || (x_2 == 0) || (y_2 == 0));
  4669. +
  4670. +
  4671. +#ifdef CONFIG_ADS7846
  4672. + p1 = (p1_1 + p1_2) / 2;
  4673. + p2 = (p2_1 + p2_2) / 2;
  4674. + p = p2 - p1;
  4675. +#else
  4676. + p = pen_down;
  4677. +#endif
  4678. + x = (x_1 + x_2) / 2;
  4679. + y = (y_1 + y_2) / 2;
  4680. +
  4681. + // normalize values
  4682. + // very subject to experimentation
  4683. +
  4684. +#if 0
  4685. + if((x == 0) || (y == 0))
  4686. + {
  4687. + x = x_last;
  4688. + y = y_last;
  4689. + }
  4690. + else
  4691. + {
  4692. + x_last = x;
  4693. + y_last = y;
  4694. + }
  4695. +#endif
  4696. +
  4697. + y = (1 << 12) - y;
  4698. + vdprintk("LEAVE: ads_784x_Read_tsData(x=0x%03x, y=0x%03x)\n", x, y);
  4699. + ads_784x_tsData_add(adsContext, 0x40, x, y); // generate pen up/pen down sequence
  4700. + ads_784x_tsData_add(adsContext, 0x00, x, y);
  4701. +
  4702. + return(pen_down);
  4703. +}
  4704. +
  4705. +/**********************************************************************
  4706. +* Function: ads_784x_thread
  4707. +*
  4708. +* This is a RT kernel thread that handles the ADC accesses
  4709. +* (mainly so we can use semaphores to serialise accesses to the ADC).
  4710. +**********************************************************************/
  4711. +static int ads_784x_thread(void *_adsContext)
  4712. +{
  4713. + adsContext_t *adsContext = _adsContext;
  4714. + void *sspContext = adsContext->sspContext;
  4715. + struct task_struct *tsk = current;
  4716. + DECLARE_WAITQUEUE(wait, tsk);
  4717. + int pen_down = 0;
  4718. +
  4719. + vdprintk("ENTER: ads_784x_thread()\n");
  4720. + adsContext->rtask = tsk;
  4721. +
  4722. + daemonize();
  4723. + tsk->tty = NULL;
  4724. + strcpy(tsk->comm, "ktsd");
  4725. +
  4726. + /* only want to receive SIGKILL */
  4727. + spin_lock_irq(&tsk->sigmask_lock);
  4728. + siginitsetinv(&tsk->blocked, sigmask(SIGKILL));
  4729. + recalc_sigpending(tsk);
  4730. + spin_unlock_irq(&tsk->sigmask_lock);
  4731. +
  4732. + add_wait_queue(&adsContext->irq_wait, &wait);
  4733. +
  4734. + complete(&adsContext->complete);
  4735. +
  4736. + /* MUST lock the SSP before accessing it */
  4737. + adsContext->lock(sspContext, SSP_DEV_TOUCHSCREEN);
  4738. + pen_down = adsContext->is_pen_down(sspContext);
  4739. + vdprintk("TSThrPD: %d\t", pen_down);
  4740. + /* MUST unlock the SSP after it has been locked */
  4741. + adsContext->unlock(sspContext, SSP_DEV_TOUCHSCREEN);
  4742. + for (;;) {
  4743. + signed long interval;
  4744. +
  4745. + /*
  4746. + * Set to interrupt mode and wait a settling time.
  4747. + */
  4748. + set_task_state(tsk, TASK_INTERRUPTIBLE);
  4749. + if (sspContext == NULL) {
  4750. + interval = HZ; /* Check for change once per second */
  4751. + } else if (pen_down) {
  4752. + /* If pen is down then periodically read pen position */
  4753. + /* MUST lock the SSP before accessing it */
  4754. + adsContext->lock(sspContext, SSP_DEV_TOUCHSCREEN);
  4755. + adsContext->disable_pen_down_irq(sspContext);
  4756. + /* MUST unlock the SSP after it has been locked */
  4757. + adsContext->unlock(sspContext, SSP_DEV_TOUCHSCREEN);
  4758. + interval = HZ/SAMPLES_PER_SECOND;
  4759. + } else {
  4760. + /* If pen is not down then sleep until pen down interrupt */
  4761. + /* MUST lock the SSP before accessing it */
  4762. + adsContext->lock(sspContext, SSP_DEV_TOUCHSCREEN);
  4763. + adsContext->enable_pen_down_irq(sspContext);
  4764. + /* MUST unlock the SSP after it has been locked */
  4765. + adsContext->unlock(sspContext, SSP_DEV_TOUCHSCREEN);
  4766. + interval = MAX_SCHEDULE_TIMEOUT;
  4767. + }
  4768. + schedule_timeout(interval);
  4769. + if (signal_pending(tsk)) {
  4770. + break;
  4771. + }
  4772. +#if 0
  4773. + if (pen_down == 0) {
  4774. + /*
  4775. + * On pen down there is some bounce.
  4776. + * Wait a debounce period and read it again.
  4777. + */
  4778. + schedule_timeout(HZ/DEBOUNCE_FRACTION_OF_A_SECOND);
  4779. + if (signal_pending(tsk)) {
  4780. + break;
  4781. + }
  4782. + /*
  4783. + * If the pen is not down after the debounce period,
  4784. + * ignore the pen down signal.
  4785. + */
  4786. + /* MUST lock the SSP before accessing it */
  4787. + adsContext->lock(sspContext, SSP_DEV_TOUCHSCREEN);
  4788. + pen_down = adsContext->is_pen_down(sspContext);
  4789. + /* MUST unlock the SSP after it has been locked */
  4790. + adsContext->unlock(sspContext, SSP_DEV_TOUCHSCREEN);
  4791. + if (pen_down == 0)
  4792. + continue;
  4793. + }
  4794. +#endif
  4795. + adsContext->disable_pen_down_irq(sspContext);
  4796. + /*
  4797. + * We got an IRQ, which works us up. Process the touchscreen.
  4798. + */
  4799. + pen_down = ads_784x_Read_tsData(adsContext);
  4800. + }
  4801. +
  4802. + remove_wait_queue(&adsContext->irq_wait, &wait);
  4803. + adsContext->rtask = NULL;
  4804. + vdprintk("LEAVE: ads_784x_thread()\n");
  4805. +
  4806. + return(0);
  4807. +}
  4808. +
  4809. +/**********************************************************************
  4810. +* Function: ads_784x_read
  4811. +*
  4812. +* ***********************************
  4813. +* *** User space driver interface ***
  4814. +* ***********************************
  4815. +**********************************************************************/
  4816. +static ssize_t ads_784x_read(struct file *filp, char *buffer, size_t _count, loff_t *ppos)
  4817. +{
  4818. + DECLARE_WAITQUEUE(wait, current);
  4819. + adsContext_t *adsContext = filp->private_data;
  4820. + char *ptr = buffer;
  4821. + int err = 0;
  4822. + int count = (int)_count; /* Force a sigened value to be used */
  4823. +
  4824. + vdprintk("ENTER: ads_784x_read()\n");
  4825. + add_wait_queue(&adsContext->read_wait, &wait);
  4826. + while (count >= sizeof(tsData_t)) {
  4827. + err = -ERESTARTSYS;
  4828. + if (signal_pending(current))
  4829. + break;
  4830. +
  4831. + if (ads_784x_tsData_pending(adsContext)) {
  4832. + tsData_t *tsData = ads_784x_tsData_get(adsContext);
  4833. +
  4834. + err = copy_to_user(ptr, tsData, sizeof(tsData_t));
  4835. + ads_784x_tsData_pull(adsContext);
  4836. +
  4837. + if (err)
  4838. + break;
  4839. +#if 0
  4840. + else
  4841. + printk("ads_784x_read: P: %02X X: %4d Y: %4d\n",
  4842. + tsData->pressure & 0x40, (tsData->xhigh << 8) + tsData->xlow, (tsData->yhigh << 8) + tsData->ylow);
  4843. +#endif
  4844. +
  4845. + ptr += sizeof(tsData_t);
  4846. + count -= sizeof(tsData_t);
  4847. + continue;
  4848. + }
  4849. +
  4850. + set_current_state(TASK_INTERRUPTIBLE);
  4851. + err = -EAGAIN;
  4852. + if (filp->f_flags & O_NONBLOCK)
  4853. + break;
  4854. + schedule();
  4855. + }
  4856. + current->state = TASK_RUNNING;
  4857. + remove_wait_queue(&adsContext->read_wait, &wait);
  4858. + vdprintk("LEAVE: ads_784x_read()\n");
  4859. +
  4860. + return(ptr == buffer ? err : ptr - buffer);
  4861. +}
  4862. +
  4863. +/**********************************************************************
  4864. +* Function: ads_784x_poll
  4865. +*
  4866. +* ***********************************
  4867. +* *** User space driver interface ***
  4868. +* ***********************************
  4869. +**********************************************************************/
  4870. +static unsigned int ads_784x_poll(struct file *filp, poll_table *wait)
  4871. +{
  4872. + adsContext_t *adsContext = filp->private_data;
  4873. + int ret = 0;
  4874. +
  4875. + vdprintk("ENTER: ads_784x_poll()\n");
  4876. + poll_wait(filp, &adsContext->read_wait, wait);
  4877. + if (ads_784x_tsData_pending(adsContext))
  4878. + ret = POLLIN | POLLRDNORM;
  4879. + vdprintk("LEAVE: ads_784x_poll()\n");
  4880. +
  4881. + return(ret);
  4882. +}
  4883. +
  4884. +/**********************************************************************
  4885. +* Function: ads_784x_open
  4886. +*
  4887. +* ***********************************
  4888. +* *** User space driver interface ***
  4889. +* ***********************************
  4890. +**********************************************************************/
  4891. +static int ads_784x_open(struct inode *inode, struct file *filp)
  4892. +{
  4893. + adsContext_t *adsContext = &adsContext_l;
  4894. + int ret = 0;
  4895. +
  4896. + vdprintk("ENTER: ads_784x_open()\n");
  4897. +
  4898. + filp->private_data = adsContext;
  4899. +
  4900. + /* Flush the ts data queue here */
  4901. + ads_784x_tsData_flush(adsContext);
  4902. +
  4903. + vdprintk("LEAVE: ads_784x_open()\n");
  4904. + return(ret);
  4905. +}
  4906. +
  4907. +/**********************************************************************
  4908. +* Function: ads_784x_fasync
  4909. +*
  4910. +* ***********************************
  4911. +* *** User space driver interface ***
  4912. +* ***********************************
  4913. +**********************************************************************/
  4914. +static int ads_784x_fasync(int fd, struct file *filp, int on)
  4915. +{
  4916. + int sts;
  4917. + adsContext_t *adsContext = filp->private_data;
  4918. +
  4919. + vdprintk("ENTER: ads_784x_fasync()\n");
  4920. + sts = fasync_helper(fd, filp, on, &adsContext->fasync);
  4921. + vdprintk("LEAVE: ads_784x_fasync()\n");
  4922. +
  4923. + return(sts);
  4924. +}
  4925. +
  4926. +/**********************************************************************
  4927. +* Function: ads_784x_release
  4928. +*
  4929. +* ***********************************
  4930. +* *** User space driver interface ***
  4931. +* ***********************************
  4932. +*
  4933. +* Release touchscreen resources. Disable IRQs.
  4934. +**********************************************************************/
  4935. +static int ads_784x_release(struct inode *inode, struct file *filp)
  4936. +{
  4937. + // adsContext_t *adsContext = filp->private_data;
  4938. +
  4939. + vdprintk("ENTER: ads_784x_release()\n");
  4940. + lock_kernel();
  4941. + ads_784x_fasync(-1, filp, 0);
  4942. + unlock_kernel();
  4943. + vdprintk("LEAVE: ads_784x_release()\n");
  4944. +
  4945. + return(0);
  4946. +}
  4947. +
  4948. +/**********************************************************************
  4949. +* Define (fill in) the user space file operations for this driver
  4950. +* and initialize the ADS touchscreen driver as a "miscdevice":
  4951. +* Character device
  4952. +* Major(10) --- Non-serial mice, misc features
  4953. +* Minor(20) --- /dev/touchscreen/ads_784x
  4954. +**********************************************************************/
  4955. +static struct file_operations ads_784x_fops = {
  4956. + owner: THIS_MODULE,
  4957. + read: ads_784x_read,
  4958. + poll: ads_784x_poll,
  4959. + open: ads_784x_open,
  4960. + fasync: ads_784x_fasync,
  4961. + release: ads_784x_release,
  4962. +};
  4963. +
  4964. +static struct miscdevice ads_784x_dev = {
  4965. + minor: 20,
  4966. + name: "touchscreen/ads_784x",
  4967. + fops: &ads_784x_fops,
  4968. +};
  4969. +
  4970. +#ifdef PROC_BATTERY
  4971. +/**********************************************************************
  4972. +* ads_784x_proc_battery_read
  4973. +**********************************************************************/
  4974. +static int ads_784x_proc_battery_read(char *buf, char **start, off_t offset,
  4975. + int len, int *eof, void *unused)
  4976. +{
  4977. + adsContext_t *adsContext = &adsContext_l;
  4978. + void *ads784x_sspContext = adsContext->sspContext;
  4979. + int milliVolts;
  4980. + int volts;
  4981. + int hundredthsVolts;
  4982. + int sample;
  4983. + int size;
  4984. + int count;
  4985. + int last_irq_state;
  4986. +
  4987. + vdprintk("ENTER: ads_784x_proc_battery_read(len=%d)\n", len);
  4988. + /*
  4989. + * Reading the ADS784X takes the part out of pen down interrupt mode
  4990. + * causing spurious pen down interrupts. So we must disable
  4991. + * pen down interrupts while reading battery voltage.
  4992. + */
  4993. + last_irq_state = adsContext->disable_pen_down_irq(ads784x_sspContext);
  4994. +
  4995. + /* Do a dummy read to turn on the internal reference voltage */
  4996. + /* MUST lock the SSP before accessing it */
  4997. + adsContext->lock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  4998. +
  4999. + //FJB
  5000. + adsContext->chipselect_enable();
  5001. +
  5002. + adsContext->write(ads784x_sspContext, ADS_784x_READ_BATTERY);
  5003. + sample = adsContext->read(ads784x_sspContext);
  5004. + /* MUST unlock the SSP after it has been locked */
  5005. + adsContext->unlock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5006. + udelay(100); /* wait until the reference voltage settle */
  5007. +
  5008. + sample = 0;
  5009. + for (count = 0; count < 3; count++) {
  5010. + /* MUST lock the SSP before accessing it */
  5011. + adsContext->lock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5012. + adsContext->write(ads784x_sspContext, ADS_784x_READ_BATTERY);
  5013. + sample += adsContext->read(ads784x_sspContext);
  5014. + /* MUST unlock the SSP after it has been locked */
  5015. + adsContext->unlock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5016. + }
  5017. + sample /= count;
  5018. + milliVolts = (sample * 1000 * 10) / 4096;
  5019. + volts = milliVolts / 1000;
  5020. + hundredthsVolts = (milliVolts - (volts * 1000)) / 10;
  5021. + size = sprintf(buf, "battery: %i %i.%02iV\n", sample, volts, hundredthsVolts);
  5022. +
  5023. + /* Do a dummy read to turn off the internal reference voltage */
  5024. + /* MUST lock the SSP before accessing it */
  5025. + adsContext->lock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5026. + adsContext->write(ads784x_sspContext, ADS_784x_READ_X);
  5027. + sample = adsContext->read(ads784x_sspContext);
  5028. +
  5029. + //FJB
  5030. + adsContext->chipselect_disable();
  5031. +
  5032. + /* MUST unlock the SSP after it has been locked */
  5033. + adsContext->unlock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5034. +
  5035. + /* Restore the interrupt enable state */
  5036. + if (last_irq_state) {
  5037. + udelay(100); /* Wait until the pen down interrupt settles */
  5038. + /* MUST lock the SSP before accessing it */
  5039. + adsContext->lock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5040. + adsContext->enable_pen_down_irq(ads784x_sspContext);
  5041. + /* MUST unlock the SSP after it has been locked */
  5042. + adsContext->unlock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5043. + }
  5044. + vdprintk("LEAVE: ads_784x_proc_battery_read(len=%d)\n", len);
  5045. +
  5046. + return(size);
  5047. +}
  5048. +#endif
  5049. +
  5050. +#ifdef PROC_TEMPERATURE
  5051. +/**********************************************************************
  5052. +* ads_784x_proc_temperature_read
  5053. +**********************************************************************/
  5054. +static int ads_784x_proc_temperature_read(char *buf, char **start,
  5055. + off_t offset, int len, int *eof, void *unused)
  5056. +{
  5057. + adsContext_t *adsContext = &adsContext_l;
  5058. + void *ads784x_sspContext = adsContext->sspContext;
  5059. + int size;
  5060. + int count;
  5061. + int C10, F10;
  5062. + int sample1;
  5063. + int sample91;
  5064. + int last_irq_state;
  5065. +
  5066. + vdprintk("ENTER: ads_784x_proc_temperature_read(len=%d)\n", len);
  5067. + /*
  5068. + * Reading the ADS784X takes the part out of pen down interrupt mode
  5069. + * causing spurious pen down interrupts. So we must disable
  5070. + * pen down interrupts while reading temperature.
  5071. + */
  5072. + last_irq_state = adsContext->disable_pen_down_irq(ads784x_sspContext);
  5073. +
  5074. + /* do a dummy read to turn on the internal reference voltage */
  5075. + /* MUST lock the SSP before accessing it */
  5076. + adsContext->lock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5077. +
  5078. + //FJB
  5079. + adsContext->chipselect_enable();
  5080. +
  5081. + adsContext->write(ads784x_sspContext, ADS_784x_READ_TEMP0);
  5082. + sample1 = adsContext->read(ads784x_sspContext);
  5083. + /* MUST unlock the SSP after it has been locked */
  5084. + adsContext->unlock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5085. + udelay(100); /* wait until the reference voltage settle */
  5086. +
  5087. + sample1 = 0;
  5088. + sample91 = 0;
  5089. + /* read the temperature values */
  5090. + for (count = 0; count < 3; count++) {
  5091. + /* MUST lock the SSP before accessing it */
  5092. + adsContext->lock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5093. + adsContext->write(ads784x_sspContext, ADS_784x_READ_TEMP0);
  5094. + sample1 += adsContext->read(ads784x_sspContext);
  5095. + adsContext->write(ads784x_sspContext, ADS_784x_READ_TEMP1);
  5096. + sample91 += adsContext->read(ads784x_sspContext);
  5097. + /* MUST unlock the SSP after it has been locked */
  5098. + adsContext->unlock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5099. + }
  5100. + /* average values */
  5101. + sample1 /= count;
  5102. + sample91 /= count;
  5103. +
  5104. + C10 = (((sample91 - sample1) * (25 * 2573)) / 4095) - 2730;
  5105. + F10 = (C10*9)/5 + 320;
  5106. +
  5107. + size = sprintf(buf, "Temperature: %iC, %iF\n", (C10+5)/10, (F10+5)/10);
  5108. +
  5109. + /* do a dummy read to turn off the internal reference voltage */
  5110. + /* MUST lock the SSP before accessing it */
  5111. + adsContext->lock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5112. + adsContext->write(ads784x_sspContext, ADS_784x_READ_X);
  5113. + sample1 = adsContext->read(ads784x_sspContext);
  5114. +
  5115. + //FJB
  5116. + adsContext->chipselect_disable();
  5117. +
  5118. + /* MUST unlock the SSP after it has been locked */
  5119. + adsContext->unlock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5120. +
  5121. + /* restore the interrupt enable state */
  5122. + if (last_irq_state) {
  5123. + udelay(100); /* wait until the pen down interrupt settles */
  5124. + /* MUST lock the SSP before accessing it */
  5125. + adsContext->lock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5126. + adsContext->enable_pen_down_irq(ads784x_sspContext);
  5127. + /* MUST unlock the SSP after it has been locked */
  5128. + adsContext->unlock(ads784x_sspContext, SSP_DEV_TOUCHSCREEN);
  5129. + }
  5130. + vdprintk("LEAVE: ads_784x_proc_temperature_read(len=%d)\n", len);
  5131. +
  5132. + return(size);
  5133. +}
  5134. +#endif
  5135. +
  5136. +/**********************************************************************
  5137. +* Function: ads_784x_make_ssp_association
  5138. +*
  5139. +* Purpose:
  5140. +* Make the association between the eeprom driver and the ssp driver
  5141. +**********************************************************************/
  5142. +static int ads_784x__make_ssp_association(adsContext_t *adsContext)
  5143. +{
  5144. + int sts = 0;
  5145. + void *vp;
  5146. +
  5147. +/* NOTE: -EOPNOTSUPP == Operation not supported on transport endpoint */
  5148. +#define ASSOCIATION_ERROR -EOPNOTSUPP
  5149. +
  5150. + dprintk("ENTER: ads_784x_make_ssp_association()\n");
  5151. +
  5152. + vp = ssp_request_pointer(SSP_DEV_TOUCHSCREEN, "sspContext");
  5153. + if ( ! vp )
  5154. + sts = ASSOCIATION_ERROR;
  5155. + adsContext->sspContext = vp;
  5156. +
  5157. + vp = ssp_request_pointer(SSP_DEV_TOUCHSCREEN, "write");
  5158. + if ( ! vp )
  5159. + sts = ASSOCIATION_ERROR;
  5160. + adsContext->write = vp;
  5161. +
  5162. + vp = ssp_request_pointer(SSP_DEV_TOUCHSCREEN, "read");
  5163. + if ( ! vp )
  5164. + sts = ASSOCIATION_ERROR;
  5165. + adsContext->read = vp;
  5166. +
  5167. + vp = ssp_request_pointer(SSP_DEV_TOUCHSCREEN, "enable_pen_down_irq");
  5168. + if ( ! vp )
  5169. + sts = ASSOCIATION_ERROR;
  5170. + adsContext->enable_pen_down_irq = vp;
  5171. +
  5172. + vp = ssp_request_pointer(SSP_DEV_TOUCHSCREEN, "disable_pen_down_irq");
  5173. + if ( ! vp )
  5174. + sts = ASSOCIATION_ERROR;
  5175. + adsContext->disable_pen_down_irq = vp;
  5176. +
  5177. + vp = ssp_request_pointer(SSP_DEV_TOUCHSCREEN, "is_pen_down");
  5178. + if ( ! vp )
  5179. + sts = ASSOCIATION_ERROR;
  5180. + adsContext->is_pen_down = vp;
  5181. +
  5182. + vp = ssp_request_pointer(SSP_DEV_TOUCHSCREEN, "lock");
  5183. + if ( ! vp )
  5184. + sts = ASSOCIATION_ERROR;
  5185. + adsContext->lock = vp;
  5186. +
  5187. + vp = ssp_request_pointer(SSP_DEV_TOUCHSCREEN, "unlock");
  5188. + if ( ! vp )
  5189. + sts = ASSOCIATION_ERROR;
  5190. + adsContext->unlock = vp;
  5191. +
  5192. + vp = ssp_request_pointer(SSP_DEV_TOUCHSCREEN, "chipselect_enable");
  5193. + if ( ! vp )
  5194. + sts = ASSOCIATION_ERROR;
  5195. + adsContext->chipselect_enable = vp;
  5196. +
  5197. + vp = ssp_request_pointer(SSP_DEV_TOUCHSCREEN, "chipselect_disable");
  5198. + if ( ! vp )
  5199. + sts = ASSOCIATION_ERROR;
  5200. + adsContext->chipselect_disable = vp;
  5201. +
  5202. + vp = ssp_request_pointer(SSP_DEV_TOUCHSCREEN, "chipselect_manual");
  5203. + if ( ! vp )
  5204. + sts = ASSOCIATION_ERROR;
  5205. + adsContext->chipselect_manual = vp;
  5206. +
  5207. + /* Note: The following need reset to NULL when we are finished */
  5208. +
  5209. + vp = ssp_provide_pointer(SSP_DEV_TOUCHSCREEN, "irq_wait_ptr",
  5210. + &(adsContext->irq_wait));
  5211. + if ( ! vp )
  5212. + sts = ASSOCIATION_ERROR;
  5213. +
  5214. + dprintk("LEAVE: ads_784x_make_ssp_association(%d)\n", sts);
  5215. +
  5216. + return(sts);
  5217. +}
  5218. +
  5219. +/**********************************************************************
  5220. +* Function: ads_784x_init
  5221. +*
  5222. +* Purpose:
  5223. +* Register & Initialize the module
  5224. +**********************************************************************/
  5225. +static int __init ads_784x_init(void)
  5226. +{
  5227. + adsContext_t *adsContext = &adsContext_l;
  5228. + int sts = -ENODEV;
  5229. +
  5230. + vdprintk("ENTER: ads_784x_init()\n");
  5231. + init_waitqueue_head(&adsContext->read_wait);
  5232. + /* Retrieve the service information from the SSP driver */
  5233. + sts = ads_784x__make_ssp_association(adsContext);
  5234. + if (sts == 0) {
  5235. + void *sspContext = adsContext->sspContext;
  5236. +
  5237. + /* Start the ADS polling thread */
  5238. + lock_kernel();
  5239. + if (adsContext->rtask == NULL) {
  5240. + init_completion(&adsContext->complete);
  5241. + init_waitqueue_head(&adsContext->irq_wait);
  5242. + sts = kernel_thread(ads_784x_thread, adsContext,
  5243. + CLONE_FS | CLONE_FILES);
  5244. + if (sts >= 0) {
  5245. + sts = 0;
  5246. + /* Only do this is the tread started correctly */
  5247. + wait_for_completion(&adsContext->complete);
  5248. + }
  5249. + }
  5250. + unlock_kernel();
  5251. +
  5252. + /* MUST lock the SSP before accessing it */
  5253. + adsContext->lock(sspContext, SSP_DEV_TOUCHSCREEN);
  5254. + adsContext->chipselect_manual();
  5255. + adsContext->write(sspContext, ADS_784x_INIT);
  5256. + adsContext->read(sspContext); /* dummy read */
  5257. + /* MUST unlock the SSP after it has been locked */
  5258. + adsContext->unlock(sspContext, SSP_DEV_TOUCHSCREEN);
  5259. +
  5260. + sts = misc_register(&ads_784x_dev);
  5261. +
  5262. +#ifdef PROC_BATTERY
  5263. + ads_784x_proc_battery = create_proc_entry("battery", 0, 0);
  5264. + if (ads_784x_proc_battery) {
  5265. + ads_784x_proc_battery->read_proc = ads_784x_proc_battery_read;
  5266. + } else {
  5267. + printk(KERN_ERR "%s: unable to register /proc/battery\n", DRVNAME);
  5268. + }
  5269. +#endif
  5270. +#ifdef PROC_TEMPERATURE
  5271. + ads_784x_proc_temperature = create_proc_entry("temperature", 0, 0);
  5272. + if (ads_784x_proc_temperature) {
  5273. + ads_784x_proc_temperature->read_proc = ads_784x_proc_temperature_read;
  5274. + } else {
  5275. + printk(KERN_ERR "%s: unable to register /proc/temperature\n", DRVNAME);
  5276. + }
  5277. +#endif
  5278. + }
  5279. +
  5280. + vdprintk("LEAVE: ads_784x_init()\n");
  5281. + return(sts);
  5282. +}
  5283. +
  5284. +/**********************************************************************
  5285. +* Function: ads_784x_exit
  5286. +*
  5287. +* Purpose:
  5288. +* Un-Register & Cleanup the module
  5289. +**********************************************************************/
  5290. +static void ads_784x_exit(void)
  5291. +{
  5292. + adsContext_t *adsContext = &adsContext_l;
  5293. +
  5294. + vdprintk("ENTER: ads_784x_exit()\n");
  5295. +
  5296. + if (adsContext->rtask) {
  5297. + send_sig(SIGKILL, adsContext->rtask, 1);
  5298. + schedule();
  5299. + }
  5300. +
  5301. + vdprintk("ads_784x_exit(): misc_deregister()\n");
  5302. + misc_deregister(&ads_784x_dev);
  5303. +
  5304. + /* Back out the pointer(s) we gave to the SSP driver */
  5305. + (void) ssp_provide_pointer(SSP_DEV_TOUCHSCREEN, "irq_wait_ptr", NULL);
  5306. +
  5307. +#ifdef PROC_BATTERY
  5308. + remove_proc_entry("battery", NULL);
  5309. +#endif
  5310. +#ifdef PROC_TEMPERATURE
  5311. + remove_proc_entry("temperature", NULL);
  5312. +#endif
  5313. +
  5314. + vdprintk("LEAVE: ads_784x_exit()\n");
  5315. +
  5316. + return;
  5317. +}
  5318. +
  5319. +module_init(ads_784x_init);
  5320. +module_exit(ads_784x_exit);
  5321. +
  5322. +MODULE_AUTHOR("Jim Gleason");
  5323. +MODULE_DESCRIPTION("ADS 784x Driver for Sharp LH7x EVB");
  5324. +MODULE_LICENSE("Copyright (c) 2002 Lineo, Inc.");
  5325. +
  5326. diff -urN linux-2.4.26/drivers/misc/Config.in linux-2.4.26-vrs1-lnode80/drivers/misc/Config.in
  5327. --- linux-2.4.26/drivers/misc/Config.in 2005-11-02 16:54:22.000000000 -0400
  5328. +++ linux-2.4.26-vrs1-lnode80/drivers/misc/Config.in 2005-11-02 17:37:31.000000000 -0400
  5329. @@ -15,3 +15,14 @@
  5330. dep_tristate ' Touchscreen interface support' CONFIG_MCP_UCB1200_TS $CONFIG_MCP_UCB1200
  5331. endmenu
  5332. +mainmenu_option next_comment
  5333. +
  5334. +comment 'Misc devices'
  5335. +
  5336. +if [ "$CONFIG_ARCH_LH79520" = "y" ]; then
  5337. + tristate 'LH79590 touchscreen support' CONFIG_TOUCHSCREEN_LH79520
  5338. + tristate 'LH79590 serial eeprom support' CONFIG_EEPROM_LH79520
  5339. + tristate 'LH79590 7-segment support' CONFIG_7SEGMENT_LH79520
  5340. +fi
  5341. +
  5342. +endmenu
  5343. diff -urN linux-2.4.26/drivers/misc/eeprom-lh7x.c linux-2.4.26-vrs1-lnode80/drivers/misc/eeprom-lh7x.c
  5344. --- linux-2.4.26/drivers/misc/eeprom-lh7x.c 1969-12-31 20:00:00.000000000 -0400
  5345. +++ linux-2.4.26-vrs1-lnode80/drivers/misc/eeprom-lh7x.c 2005-11-02 17:37:31.000000000 -0400
  5346. @@ -0,0 +1,709 @@
  5347. +/* vi: set sw=4 ts=4 ai: */
  5348. +
  5349. +// #define MODULE
  5350. +
  5351. +#define READ_AFTER_WRITE
  5352. +
  5353. +/**********************************************************************
  5354. +* linux/drivers/misc/eeprom-lh79x.c
  5355. +*
  5356. +* Provide Microchip 93LC46B 64 x 16 EEPROM access for LH7x EVB boards
  5357. +*
  5358. +* Copyright (C) 2002 Lineo, Inc.
  5359. +*
  5360. +* This program is free software; you can redistribute it and/or modify
  5361. +* it under the terms of the GNU General Public License (GPL) version 2
  5362. +* as published by the Free Software Foundation.
  5363. +*
  5364. +* References:
  5365. +* SHARP_EVB_DISPLAY_BOARD_REV2.pdf
  5366. +* 93LC46.pdf (Microchip 1K Microwire(R) EEPROM chip spec)
  5367. +*
  5368. +**********************************************************************/
  5369. +
  5370. +#include <linux/config.h>
  5371. +#include <linux/types.h>
  5372. +#include <linux/kernel.h>
  5373. +#include <linux/init.h>
  5374. +#include <linux/module.h>
  5375. +#include <linux/fs.h>
  5376. +#include <linux/proc_fs.h>
  5377. +#include <linux/smp_lock.h>
  5378. +#include <linux/miscdevice.h>
  5379. +#include <linux/poll.h>
  5380. +#include <linux/delay.h>
  5381. +
  5382. +#undef DEBUG
  5383. +#undef VERBOSE
  5384. +#define DRVNAME "eeprom-lh79x"
  5385. +#include <linux/verbosedebug.h>
  5386. +
  5387. +#include <linux/version.h>
  5388. +#ifdef MODULE
  5389. +char kernel_version[] = UTS_RELEASE;
  5390. +#endif /* MODULE */
  5391. +
  5392. +#include <asm/arch/hardware.h>
  5393. +
  5394. +#include "ssp.h"
  5395. +
  5396. +#define SIXmsJIFFIES (((HZ*6)/1000)+2)
  5397. +
  5398. +/**********************************************************************
  5399. +* Define EEPROM Control macros for "Microchip 93LC46B Microwire Serial EEPROM"
  5400. +**********************************************************************/
  5401. +
  5402. +/* Erase one 16 bit word at addr */
  5403. +#define EEPROM_ERASE(addr) (0x01C0 | (addr & 0x3F))
  5404. +/* Erase entire eeprom */
  5405. +#define EEPROM_ERAL() (0x0120)
  5406. +/* Erase/Write disable */
  5407. +#define EEPROM_EWDS() (0x0100)
  5408. +/* Erase/Write enable */
  5409. +#define EEPROM_EWEN() (0x0130)
  5410. +/* Read one 16 bit word at addr */
  5411. +#define EEPROM_READ(addr) (0x0180 | (addr & 0x3F))
  5412. +/* (Erase and) Write one 16 bit word at addr */
  5413. +#define EEPROM_WRITE(addr) (0x0140 | (addr & 0x3F))
  5414. +/* Write one 16 bit value throught entire eeprom */
  5415. +#define EEPROM_WRAL() (0x0110)
  5416. +
  5417. +/**********************************************************************
  5418. +* Define our eeprom context structure
  5419. +**********************************************************************/
  5420. +
  5421. +#define EEPROM_SIZE_16BIT 64
  5422. +#define EEPROM_SIZE_8BIT 128
  5423. +
  5424. +typedef struct eepromContext_t eepromContext_t;
  5425. +struct eepromContext_t {
  5426. + union {
  5427. + uint16_t w[EEPROM_SIZE_16BIT]; /* Actual device size */
  5428. + u_char c[EEPROM_SIZE_8BIT];
  5429. + } cache;
  5430. + union {
  5431. + uint16_t w[EEPROM_SIZE_16BIT]; /* Actual device size */
  5432. + u_char c[EEPROM_SIZE_8BIT];
  5433. + } state;
  5434. + wait_queue_head_t read_and_write_wait;
  5435. +
  5436. + void *sspContext;
  5437. + void (*write) (void *sspContext, unsigned int data);
  5438. + unsigned int (*read) (void *sspContext);
  5439. + int (*lock)(void *sspContext, int device);
  5440. + int (*unlock)(void *sspContext, int device);
  5441. + void (*ssp_chipselect_automatic)(void);
  5442. + void (*ssp_chipselect_manual)(void);
  5443. + void (*ssp_chipselect_enable)(void);
  5444. + void (*ssp_chipselect_disable)(void);
  5445. + void (*ssp_flush_tx_fifo)(void *sspContext);
  5446. + void (*ssp_flush_rx_fifo)(void *sspContext);
  5447. + void (*ssp_busy_wait)(void);
  5448. +};
  5449. +static eepromContext_t eepromContext_l;
  5450. +
  5451. +#define CACHE_STATE_VALID_8 0x01
  5452. +#define CACHE_STATE_MODIFIED_8 0x02
  5453. +
  5454. +#define CACHE_STATE_VALID_16 0x0101
  5455. +#define CACHE_STATE_MODIFIED_16 0x0202
  5456. +
  5457. +/**********************************************************************
  5458. +* Function: eeprom_lh79x_erase_write_enable
  5459. +* Function: eeprom_lh79x_erase_write_disable
  5460. +**********************************************************************/
  5461. +static void
  5462. +eeprom_lh79x_erase_write_enable(eepromContext_t *eepromContext)
  5463. +{
  5464. + void *sspContext = eepromContext->sspContext;
  5465. +
  5466. + /* Lock the SSP before accessing it */
  5467. + eepromContext->lock(sspContext, SSP_DEV_EEPROM);
  5468. +
  5469. + eepromContext->ssp_busy_wait(); /* Wait for the SSP to not be busy */
  5470. + eepromContext->ssp_flush_rx_fifo(sspContext);
  5471. +
  5472. + /* EEPROM Writes must be done using manual control of the ChipSelect */
  5473. + eepromContext->ssp_chipselect_manual();
  5474. + eepromContext->ssp_chipselect_enable();
  5475. +
  5476. + eepromContext->write(sspContext, EEPROM_EWEN()); /* Enable Erase/Write */
  5477. +
  5478. + eepromContext->ssp_busy_wait(); /* Wait for the SSP to not be busy */
  5479. + eepromContext->ssp_flush_rx_fifo(sspContext);
  5480. +
  5481. + /* Reset back to automatic control of the EEPROM ChipSelect */
  5482. + eepromContext->ssp_chipselect_disable();
  5483. + eepromContext->ssp_chipselect_automatic();
  5484. +
  5485. + /* Unlock the SSP after it has been locked */
  5486. + eepromContext->unlock(sspContext, SSP_DEV_EEPROM);
  5487. +
  5488. + return;
  5489. +}
  5490. +
  5491. +static void
  5492. +eeprom_lh79x_erase_write_disable(eepromContext_t *eepromContext)
  5493. +{
  5494. + void *sspContext = eepromContext->sspContext;
  5495. +
  5496. + /* Lock the SSP before accessing it */
  5497. + eepromContext->lock(sspContext, SSP_DEV_EEPROM);
  5498. +
  5499. + eepromContext->ssp_busy_wait(); /* Wait for the SSP to not be busy */
  5500. + eepromContext->ssp_flush_rx_fifo(sspContext);
  5501. +
  5502. + /* EEPROM Writes must be done using manual control of the ChipSelect */
  5503. + eepromContext->ssp_chipselect_manual();
  5504. + eepromContext->ssp_chipselect_enable();
  5505. +
  5506. + eepromContext->write(sspContext, EEPROM_EWDS()); /* Disable Erase/Write */
  5507. +
  5508. + eepromContext->ssp_busy_wait(); /* Wait for the SSP to not be busy */
  5509. + eepromContext->ssp_flush_rx_fifo(sspContext);
  5510. +
  5511. + /* Reset back to automatic control of the EEPROM ChipSelect */
  5512. + eepromContext->ssp_chipselect_disable();
  5513. + eepromContext->ssp_chipselect_automatic();
  5514. +
  5515. + /* Unlock the SSP after it has been locked */
  5516. + eepromContext->unlock(sspContext, SSP_DEV_EEPROM);
  5517. +
  5518. + return;
  5519. +}
  5520. +
  5521. +/**********************************************************************
  5522. +* Function: eeprom_lh79x_read_device_word
  5523. +**********************************************************************/
  5524. +static void
  5525. +eeprom_lh79x_read_device_word(eepromContext_t *eepromContext, int offset_w)
  5526. +{
  5527. + void *sspContext = eepromContext->sspContext;
  5528. + uint16_t word = 0;
  5529. +
  5530. + /* Lock the SSP before accessing it */
  5531. + eepromContext->lock(sspContext, SSP_DEV_EEPROM);
  5532. +
  5533. + eepromContext->ssp_busy_wait(); /* Wait for the SSP to not be busy */
  5534. + eepromContext->ssp_flush_rx_fifo(sspContext);
  5535. +
  5536. + /* EEPROM Reads must be done using manual control of the ChipSelect */
  5537. + eepromContext->ssp_chipselect_manual();
  5538. + eepromContext->ssp_chipselect_enable();
  5539. +
  5540. + /* Read eeprom into cache */
  5541. + /* Note: We shift to take care of the "dummy 0" the eeprom sends */
  5542. + eepromContext->write(sspContext, (EEPROM_READ(offset_w))<<1);
  5543. + /* Following is a Dummy/Invalid command to allow the eeprom to be read */
  5544. + eepromContext->write(sspContext, 0);
  5545. + eepromContext->ssp_busy_wait(); /* Wait for the SSP to not be busy */
  5546. + word = eepromContext->read(sspContext); /* Dummy Word */
  5547. + word = eepromContext->read(sspContext); /* Real Word */
  5548. +
  5549. + /* Reset back to automatic control of the EEPROM ChipSelect */
  5550. + eepromContext->ssp_chipselect_disable();
  5551. + eepromContext->ssp_chipselect_automatic();
  5552. +
  5553. + /* Unlock the SSP after it has been locked */
  5554. + eepromContext->unlock(sspContext, SSP_DEV_EEPROM);
  5555. +
  5556. + /* Modify the state of the cache data */
  5557. + eepromContext->cache.w[offset_w] = word;
  5558. + eepromContext->state.w[offset_w] |= CACHE_STATE_VALID_16;
  5559. +
  5560. + schedule(); /* Give the rest of the system a chance to work */
  5561. +
  5562. + return;
  5563. +}
  5564. +
  5565. +/**********************************************************************
  5566. +* Function: eeprom_lh79x_write_device_word
  5567. +**********************************************************************/
  5568. +static void
  5569. +eeprom_lh79x_write_device_word(eepromContext_t *eepromContext, int offset_w)
  5570. +{
  5571. + void *sspContext = eepromContext->sspContext;
  5572. + uint16_t word;
  5573. + long timeoutJiffies;
  5574. +
  5575. + /* Get the modified cache data to write to the eeprom */
  5576. + word = eepromContext->cache.w[offset_w];
  5577. +
  5578. + /* Lock the SSP before accessing it */
  5579. + eepromContext->lock(sspContext, SSP_DEV_EEPROM);
  5580. +
  5581. + eepromContext->ssp_busy_wait(); /* Wait for the SSP to not be busy */
  5582. + eepromContext->ssp_flush_rx_fifo(sspContext);
  5583. +
  5584. + /* EEPROM Writes must be done using manual control of the ChipSelect */
  5585. + eepromContext->ssp_chipselect_manual();
  5586. + eepromContext->ssp_chipselect_enable();
  5587. +
  5588. + /* Write modified cache data to the eeprom */
  5589. + eepromContext->write(sspContext, EEPROM_WRITE(offset_w));
  5590. + eepromContext->write(sspContext, word);
  5591. +
  5592. + /* Reset back to automatic control of the EEPROM ChipSelect */
  5593. + eepromContext->ssp_chipselect_disable();
  5594. + eepromContext->ssp_chipselect_automatic();
  5595. +
  5596. + eepromContext->ssp_busy_wait(); /* Wait for the SSP to not be busy */
  5597. + eepromContext->ssp_flush_rx_fifo(sspContext);
  5598. +
  5599. + /* Unlock the SSP after it has been locked */
  5600. + eepromContext->unlock(sspContext, SSP_DEV_EEPROM);
  5601. +
  5602. + /* Modify the state of the cache data */
  5603. + eepromContext->state.w[offset_w] &= ~CACHE_STATE_MODIFIED_16;
  5604. +
  5605. +#ifdef READ_AFTER_WRITE
  5606. + /* Force the modified cache data to be reread from the eeprom */
  5607. + eepromContext->state.w[offset_w] &= ~CACHE_STATE_VALID_16;
  5608. +#endif /* READ_AFTER_WRITE */
  5609. +
  5610. + /* Cause ~ 6ms delay (actually does 10 on the Sharp LH79520) */
  5611. + timeoutJiffies = SIXmsJIFFIES;
  5612. + while (timeoutJiffies > 0) {
  5613. + __set_current_state(TASK_UNINTERRUPTIBLE);
  5614. + timeoutJiffies = schedule_timeout(timeoutJiffies);
  5615. + }
  5616. + // __set_current_state(TASK_RUNNING);
  5617. +
  5618. + schedule(); /* Give the rest of the system a chance to work */
  5619. +
  5620. + return;
  5621. +}
  5622. +
  5623. +/**********************************************************************
  5624. +* Function: eeprom_lh79x_read_device
  5625. +**********************************************************************/
  5626. +static void
  5627. +eeprom_lh79x_read_device(eepromContext_t *eepromContext)
  5628. +{
  5629. + uint16_t *scwp;
  5630. + int offset_w;
  5631. +
  5632. + scwp = eepromContext->state.w;
  5633. + for (offset_w = 0; offset_w < EEPROM_SIZE_16BIT; offset_w++) {
  5634. + if ((*scwp & CACHE_STATE_VALID_16) != CACHE_STATE_VALID_16) {
  5635. + eeprom_lh79x_read_device_word(eepromContext, offset_w);
  5636. + }
  5637. + scwp++;
  5638. + }
  5639. +
  5640. + return;
  5641. +}
  5642. +
  5643. +/**********************************************************************
  5644. +* Function: eeprom_lh79x_write_device
  5645. +**********************************************************************/
  5646. +static void
  5647. +eeprom_lh79x_write_device(eepromContext_t *eepromContext)
  5648. +{
  5649. + uint16_t *scwp;
  5650. + int offset_w;
  5651. + int timeoutJiffies;
  5652. +
  5653. + /* Enable erase/write of the eeprom */
  5654. + eeprom_lh79x_erase_write_enable(eepromContext);
  5655. +
  5656. + /* Just to get the timeouts in a desirable sequence */
  5657. + /* and so we don't get a "partial" timeout we do the following... */
  5658. + /* Cause ~ 6ms delay (actually does 10 on the Sharp LH79520) */
  5659. + timeoutJiffies = SIXmsJIFFIES;
  5660. + while (timeoutJiffies > 0) {
  5661. + __set_current_state(TASK_UNINTERRUPTIBLE);
  5662. + timeoutJiffies = schedule_timeout(timeoutJiffies);
  5663. + }
  5664. + // __set_current_state(TASK_RUNNING);
  5665. +
  5666. + scwp = eepromContext->state.w;
  5667. + for (offset_w = 0; offset_w < EEPROM_SIZE_16BIT; offset_w++) {
  5668. + if (*scwp & CACHE_STATE_MODIFIED_16) {
  5669. + eeprom_lh79x_write_device_word(eepromContext, offset_w);
  5670. + }
  5671. + scwp++;
  5672. + }
  5673. +
  5674. + /* Disable erase/write of the eeprom */
  5675. + eeprom_lh79x_erase_write_disable(eepromContext);
  5676. +
  5677. +#ifdef READ_AFTER_WRITE
  5678. + /*
  5679. + * NOW ... Update the eeprom cache.
  5680. + * ( Read the actual contents of the eeprom that were
  5681. + * modified instead of relying on what we wrote. )
  5682. + */
  5683. + eeprom_lh79x_read_device(eepromContext);
  5684. +#endif /* READ_AFTER_WRITE */
  5685. +
  5686. + return;
  5687. +}
  5688. +
  5689. +/**********************************************************************
  5690. +* *****************************************************
  5691. +* *** User space "file operation" driver interfaces ***
  5692. +* *****************************************************
  5693. +* Function: lh79x_eeprom_llseek
  5694. +* Function: lh79x_eeprom_read
  5695. +* Function: lh79x_eeprom_write
  5696. +* Function: lh79x_eeprom_poll ( NOT USED --- YET )
  5697. +* Function: lh79x_eeprom_ioctl ( NOT USED --- YET )
  5698. +* Function: lh79x_eeprom_open
  5699. +* Function: lh79x_eeprom_flush ( NOT USED --- YET )
  5700. +* Function: lh79x_eeprom_release ( NOT USED --- YET )
  5701. +* Function: lh79x_eeprom_fsync ( NOT USED --- YET )
  5702. +* Function: lh79x_eeprom_fasync ( NOT USED --- YET )
  5703. +* Function: lh79x_eeprom_lock ( NOT USED --- YET )
  5704. +**********************************************************************/
  5705. +
  5706. +static loff_t
  5707. +lh79x_eeprom_llseek(struct file *filp, loff_t offset, int origin)
  5708. +{
  5709. + // eepromContext_t *eepromContext = filp->private_data;
  5710. + loff_t new_offset = -EINVAL;
  5711. +
  5712. + switch (origin) {
  5713. + case 0: /* SEEK_SET == 0, Offset from the start */
  5714. + new_offset = offset;
  5715. + break;
  5716. + case 1: /* SEEK_CUR == 1, Offset from the current position */
  5717. + new_offset = filp->f_pos + offset;
  5718. + break;
  5719. + case 2: /* SEEK_END == 2, Offset from the end */
  5720. + new_offset = EEPROM_SIZE_8BIT - offset;
  5721. + break;
  5722. + }
  5723. + if ((new_offset < 0) || (new_offset > EEPROM_SIZE_8BIT)) {
  5724. + new_offset = -EINVAL;
  5725. + } else {
  5726. + filp->f_pos = new_offset;
  5727. + }
  5728. +
  5729. + return(new_offset);
  5730. +}
  5731. +
  5732. +static ssize_t
  5733. +lh79x_eeprom_read(struct file *filp, char *buffer,
  5734. + size_t count, loff_t *offsetp)
  5735. +{
  5736. + eepromContext_t *eepromContext = filp->private_data;
  5737. + int sts = 0;
  5738. + int err;
  5739. +
  5740. + vdprintk("ENTER: lh79x_eeprom_read(%d:%d)\n", *offsetp, count);
  5741. + /* Ensure we still have data to read (relative to the offset we are at) */
  5742. + if (*offsetp < EEPROM_SIZE_8BIT) {
  5743. + /* Adjust the size to be read if necessary */
  5744. + if ((*offsetp + count) > EEPROM_SIZE_8BIT) {
  5745. + count = EEPROM_SIZE_8BIT - *offsetp;
  5746. + }
  5747. + /* Ensure the eeprom cache is valid */
  5748. + eeprom_lh79x_read_device(eepromContext);
  5749. + /* Return the contents of the eeprom cache */
  5750. + err = copy_to_user(buffer, &eepromContext->cache.c[*offsetp], count);
  5751. + if ( ! err) {
  5752. + *offsetp += count;
  5753. + sts = count;
  5754. + } else {
  5755. + sts = -EFAULT;
  5756. + }
  5757. + }
  5758. + vdprintk("LEAVE: lh79x_eeprom_read(%d)\n", sts);
  5759. +
  5760. + return(sts);
  5761. +}
  5762. +
  5763. +static ssize_t
  5764. +lh79x_eeprom_write(struct file *filp, const char *buffer,
  5765. + size_t count, loff_t *offsetp)
  5766. +{
  5767. + eepromContext_t *eepromContext = filp->private_data;
  5768. + u_char newcache_c[EEPROM_SIZE_8BIT];
  5769. + int sts = 0;
  5770. + int err;
  5771. +
  5772. + vdprintk("ENTER: lh79x_eeprom_write(%d:%d)\n", *offsetp, count);
  5773. + /* Ensure we still have room to write (relative to the offset we are at) */
  5774. + if (*offsetp < EEPROM_SIZE_8BIT) {
  5775. + /* Adjust the size to be written if necessary */
  5776. + if ((*offsetp + count) > EEPROM_SIZE_8BIT) {
  5777. + count = EEPROM_SIZE_8BIT - *offsetp;
  5778. + }
  5779. + /* Ensure the eeprom cache is valid to start with */
  5780. + eeprom_lh79x_read_device(eepromContext);
  5781. + /* Get the new contents of the eeprom cache */
  5782. + err = copy_from_user(&newcache_c[*offsetp], buffer, count);
  5783. + if ( ! err) {
  5784. + u_char *ccp, *nccp, *sccp;
  5785. + int i;
  5786. + /*
  5787. + * Transfer the new cache contents into the cache
  5788. + * marking what has changed.
  5789. + */
  5790. + ccp = &eepromContext->cache.c[*offsetp];
  5791. + nccp = &newcache_c[*offsetp];
  5792. + sccp = &eepromContext->state.c[*offsetp];
  5793. + for (i = 0; i < count; i++) {
  5794. + if (*ccp != *nccp) {
  5795. + *ccp = *nccp;
  5796. + *sccp |= CACHE_STATE_MODIFIED_8;
  5797. + }
  5798. + ccp++;
  5799. + nccp++;
  5800. + sccp++;
  5801. + }
  5802. + /* Write the modified cache into the eeprom */
  5803. + eeprom_lh79x_write_device(eepromContext);
  5804. + *offsetp += count;
  5805. + sts = count;
  5806. + } else {
  5807. + sts = -EFAULT;
  5808. + }
  5809. + }
  5810. + vdprintk("LEAVE: lh79x_eeprom_write(%d)\n", sts);
  5811. +
  5812. + return(sts);
  5813. +}
  5814. +
  5815. +#if (0) /* NOT USED --- YET */
  5816. +static unsigned int
  5817. +lh79x_eeprom_poll(struct file *filp, struct poll_table_struct *wait)
  5818. +{
  5819. + eepromContext_t *eepromContext = filp->private_data;
  5820. + int sts = 0;
  5821. +
  5822. + return(sts);
  5823. +}
  5824. +#endif /* NOT USED --- YET */
  5825. +
  5826. +#if (0) /* NOT USED --- YET */
  5827. +static int
  5828. +lh79x_eeprom_ioctl(struct inode *, struct file *filp, unsigned int cmd, unsigned long arg)
  5829. +{
  5830. + eepromContext_t *eepromContext = filp->private_data;
  5831. + int sts = 0;
  5832. +
  5833. + return(sts);
  5834. +}
  5835. +#endif /* NOT USED --- YET */
  5836. +
  5837. +static int
  5838. +lh79x_eeprom_open(struct inode *inode, struct file *filp)
  5839. +{
  5840. + eepromContext_t *eepromContext = &eepromContext_l;
  5841. + int sts = 0;
  5842. +
  5843. + filp->private_data = eepromContext;
  5844. +
  5845. + return(sts);
  5846. +}
  5847. +
  5848. +#if (0) /* NOT USED --- YET */
  5849. +static int
  5850. +lh79x_eeprom_flush(struct file *filp)
  5851. +{
  5852. + eepromContext_t *eepromContext = filp->private_data;
  5853. + int sts = 0;
  5854. +
  5855. + return(sts);
  5856. +}
  5857. +#endif /* NOT USED --- YET */
  5858. +
  5859. +#if (0) /* NOT USED --- YET */
  5860. +static int
  5861. +lh79x_eeprom_release(struct inode *inode, struct file *filp)
  5862. +{
  5863. + eepromContext_t *eepromContext = filp->private_data;
  5864. + int sts = 0;
  5865. +
  5866. + return(sts);
  5867. +}
  5868. +#endif /* NOT USED --- YET */
  5869. +
  5870. +#if (0) /* NOT USED --- YET */
  5871. +static int
  5872. +lh79x_eeprom_fsync(struct file *filp, struct dentry *dentry, int datasync)
  5873. +{
  5874. + eepromContext_t *eepromContext = filp->private_data;
  5875. + int sts = 0;
  5876. +
  5877. + return(sts);
  5878. +}
  5879. +#endif /* NOT USED --- YET */
  5880. +
  5881. +#if (0) /* NOT USED --- YET */
  5882. +static int
  5883. +lh79x_eeprom_fasync(int fd, struct file *filp, int on)
  5884. +{
  5885. + eepromContext_t *eepromContext = filp->private_data;
  5886. + int sts = 0;
  5887. +
  5888. + return(sts);
  5889. +}
  5890. +#endif /* NOT USED --- YET */
  5891. +
  5892. +#if (0) /* NOT USED --- YET */
  5893. +static int
  5894. +lh79x_eeprom_lock(struct file *filp, int XXX, struct file_lock *file_lock)
  5895. +{
  5896. + eepromContext_t *eepromContext = filp->private_data;
  5897. + int sts = 0;
  5898. +
  5899. + return(sts);
  5900. +}
  5901. +#endif /* NOT USED --- YET */
  5902. +
  5903. +/**********************************************************************
  5904. +* Define (fill in) the user space file operations for this driver
  5905. +* and initialize the eeprom driver as a "miscdevice":
  5906. +* Character device
  5907. +* Major(10) --- Non-serial mice, misc features
  5908. +* Minor(22) --- /dev/eeprom ( Microchip 93LC46B 64 x 16 EEPROM )
  5909. +**********************************************************************/
  5910. +static struct file_operations lh79x_eeprom_fops = {
  5911. + owner: THIS_MODULE,
  5912. + llseek: lh79x_eeprom_llseek,
  5913. + read: lh79x_eeprom_read,
  5914. + write: lh79x_eeprom_write,
  5915. +// poll: lh79x_eeprom_poll,
  5916. +// ioctl: lh79x_eeprom_ioctl,
  5917. + open: lh79x_eeprom_open,
  5918. +// flush: lh79x_eeprom_flush,
  5919. +// release: lh79x_eeprom_release,
  5920. +// fsync: lh79x_eeprom_fsync,
  5921. +// fasync: lh79x_eeprom_fasync,
  5922. +// lock: lh79x_eeprom_lock,
  5923. +};
  5924. +
  5925. +static struct miscdevice lh79x_eeprom_dev = {
  5926. +minor: 22,
  5927. +name: "eeprom",
  5928. +fops: &lh79x_eeprom_fops,
  5929. +};
  5930. +
  5931. +/**********************************************************************
  5932. +* Function: lh79x_eeprom_make_ssp_association
  5933. +*
  5934. +* Purpose:
  5935. +* Make the association between the eeprom driver and the ssp driver
  5936. +**********************************************************************/
  5937. +static int lh79x_eeprom_make_ssp_association(eepromContext_t *eepromContext)
  5938. +{
  5939. + int sts = 0;
  5940. + void *vp;
  5941. +
  5942. +/* NOTE: -EOPNOTSUPP == Operation not supported on transport endpoint */
  5943. +#define ASSOCIATION_ERROR -EOPNOTSUPP
  5944. +
  5945. + dprintk("ENTER: lh79x_eeprom_make_ssp_association()\n");
  5946. +
  5947. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "sspContext");
  5948. + if ( ! vp )
  5949. + sts = ASSOCIATION_ERROR;
  5950. + eepromContext->sspContext = vp;
  5951. +
  5952. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "write");
  5953. + if ( ! vp )
  5954. + sts = ASSOCIATION_ERROR;
  5955. + eepromContext->write = vp;
  5956. +
  5957. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "read");
  5958. + if ( ! vp )
  5959. + sts = ASSOCIATION_ERROR;
  5960. + eepromContext->read = vp;
  5961. +
  5962. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "lock");
  5963. + if ( ! vp )
  5964. + sts = ASSOCIATION_ERROR;
  5965. + eepromContext->lock = vp;
  5966. +
  5967. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "unlock");
  5968. + if ( ! vp )
  5969. + sts = ASSOCIATION_ERROR;
  5970. + eepromContext->unlock = vp;
  5971. +
  5972. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "chipselect_enable");
  5973. + if ( ! vp )
  5974. + sts = ASSOCIATION_ERROR;
  5975. + eepromContext->ssp_chipselect_enable = vp;
  5976. +
  5977. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "chipselect_disable");
  5978. + if ( ! vp )
  5979. + sts = ASSOCIATION_ERROR;
  5980. + eepromContext->ssp_chipselect_disable = vp;
  5981. +
  5982. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "chipselect_manual");
  5983. + if ( ! vp )
  5984. + sts = ASSOCIATION_ERROR;
  5985. + eepromContext->ssp_chipselect_manual = vp;
  5986. +
  5987. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "chipselect_automatic");
  5988. + if ( ! vp )
  5989. + sts = ASSOCIATION_ERROR;
  5990. + eepromContext->ssp_chipselect_automatic = vp;
  5991. +
  5992. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "flush_tx_fifo");
  5993. + if ( ! vp )
  5994. + sts = ASSOCIATION_ERROR;
  5995. + eepromContext->ssp_flush_tx_fifo = vp;
  5996. +
  5997. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "flush_rx_fifo");
  5998. + if ( ! vp )
  5999. + sts = ASSOCIATION_ERROR;
  6000. + eepromContext->ssp_flush_rx_fifo = vp;
  6001. +
  6002. + vp = ssp_request_pointer(SSP_DEV_EEPROM, "ssp_busy_wait");
  6003. + if ( ! vp )
  6004. + sts = ASSOCIATION_ERROR;
  6005. + eepromContext->ssp_busy_wait = vp;
  6006. +
  6007. + dprintk("LEAVE: lh79x_eeprom_make_ssp_association(%d)\n", sts);
  6008. +
  6009. + return(sts);
  6010. +}
  6011. +
  6012. +/**********************************************************************
  6013. +* Function: lh79x_eeprom_init
  6014. +*
  6015. +* Purpose:
  6016. +* Register & Initialize the module
  6017. +**********************************************************************/
  6018. +static int lh79x_eeprom_init(void)
  6019. +{
  6020. + eepromContext_t *eepromContext = &eepromContext_l;
  6021. + int sts = 0;
  6022. + dprintk("ENTER: lh79x_eeprom_init()\n");
  6023. + init_waitqueue_head(&eepromContext->read_and_write_wait);
  6024. + /* Retrieve the service information from the SSP driver */
  6025. + sts = lh79x_eeprom_make_ssp_association(eepromContext);
  6026. + if (sts == 0) {
  6027. + /* Ensure the eeprom cache is valid */
  6028. + eeprom_lh79x_read_device(eepromContext);
  6029. + sts = misc_register(&lh79x_eeprom_dev);
  6030. + }
  6031. + dprintk("LEAVE: lh79x_eeprom_init(%d)\n", sts);
  6032. + return(sts);
  6033. +}
  6034. +
  6035. +/**********************************************************************
  6036. +* Function: lh79x_eeprom_exit
  6037. +*
  6038. +* Purpose:
  6039. +* Un-Register & Cleanup the module
  6040. +**********************************************************************/
  6041. +static void lh79x_eeprom_exit(void)
  6042. +{
  6043. + dprintk("ENTER: lh79x_eeprom_exit()\n");
  6044. + misc_deregister(&lh79x_eeprom_dev);
  6045. + dprintk("LEAVE: lh79x_eeprom_exit()\n");
  6046. + return;
  6047. +}
  6048. +
  6049. +module_init(lh79x_eeprom_init);
  6050. +module_exit(lh79x_eeprom_exit);
  6051. +
  6052. +MODULE_AUTHOR("Jim Gleason / Lineo, Inc.");
  6053. +MODULE_DESCRIPTION("Microchip 93LC46B 64 x 16 EEPROM access for LH7x EVB");
  6054. +MODULE_LICENSE("Copyright (c) 2002 Lineo, Inc.");
  6055. +
  6056. diff -urN linux-2.4.26/drivers/misc/lh7x-7seg.c linux-2.4.26-vrs1-lnode80/drivers/misc/lh7x-7seg.c
  6057. --- linux-2.4.26/drivers/misc/lh7x-7seg.c 1969-12-31 20:00:00.000000000 -0400
  6058. +++ linux-2.4.26-vrs1-lnode80/drivers/misc/lh7x-7seg.c 2005-11-02 17:37:31.000000000 -0400
  6059. @@ -0,0 +1,649 @@
  6060. +/* vi: set sw=4 ts=4 ai: */
  6061. +
  6062. +//#define MODULE
  6063. +
  6064. +/**********************************************************************
  6065. +* linux/drivers/misc/lh7x-7seg.c
  6066. +*
  6067. +* Provide ADS_784x 7-Segment access for LH7x EVB boards
  6068. +*
  6069. +* Copyright (C) 2002 Lineo, Inc.
  6070. +*
  6071. +* This program is free software; you can redistribute it and/or modify
  6072. +* it under the terms of the GNU General Public License (GPL) version 2
  6073. +* as published by the Free Software Foundation.
  6074. +*
  6075. +**********************************************************************/
  6076. +
  6077. +/**********************************************************************
  6078. +* To light up the 7-segment display, write a 16-bit value to
  6079. +*
  6080. +* cpld->seven_seg.
  6081. +*
  6082. +* The high-order byte is the most significant 7-segment digit,
  6083. +* and the low-order byte is the lsb.
  6084. +*
  6085. +* NOTE: The 7-segment display bars are bit-mapped.
  6086. +* NOTE: The 7-segment display bars are ACTIVE LOW.
  6087. +*
  6088. +* _ == a
  6089. +* | | == f b
  6090. +* - == g
  6091. +* | | == e c
  6092. +* -. == d dot
  6093. +*
  6094. +* a 0x01
  6095. +* b 0x02
  6096. +* c 0x04
  6097. +* d 0x08
  6098. +* e 0x10
  6099. +* f 0x20
  6100. +* g 0x40
  6101. +* dot 0x80 (also known as dp)
  6102. +*
  6103. +* The data to write looks like this:
  6104. +*
  6105. +* static u_char lednum[] =
  6106. +* { 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, // 0-7
  6107. +* 0x80, 0x98, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E, // 8-F
  6108. +* 0xBF, // hyphen
  6109. +* 0xFF, // (blank)
  6110. +* };
  6111. +*
  6112. +* SO - to make "7F" show up, do this:
  6113. +*
  6114. +* cpld->seven_seg = 0xf88e;
  6115. +*
  6116. +* NOTE: When read, the 7-segment display does not return valid data.
  6117. +*
  6118. +**********************************************************************/
  6119. +
  6120. +#include <linux/config.h>
  6121. +#include <linux/types.h>
  6122. +#include <linux/kernel.h>
  6123. +#include <linux/init.h>
  6124. +#include <linux/module.h>
  6125. +#include <linux/fs.h>
  6126. +#include <linux/proc_fs.h>
  6127. +#include <linux/smp_lock.h>
  6128. +#include <linux/miscdevice.h>
  6129. +#include <linux/poll.h>
  6130. +
  6131. +#undef DEBUG
  6132. +#undef VERBOSE
  6133. +#define DRVNAME "lh7x-7seg"
  6134. +#include <linux/verbosedebug.h>
  6135. +
  6136. +#include <linux/version.h>
  6137. +#ifdef MODULE
  6138. +char kernel_version[] = UTS_RELEASE;
  6139. +#endif /* MODULE */
  6140. +
  6141. +#include <asm/arch/hardware.h>
  6142. +#include <asm/arch/cpld.h>
  6143. +#include <asm/arch/lh7x-7seg.h>
  6144. +
  6145. +static cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  6146. +
  6147. +/**********************************************************************
  6148. +* Define our Seven Segment context structure
  6149. +**********************************************************************/
  6150. +typedef struct sevenSegmentContext_t sevenSegmentContext_t;
  6151. +struct sevenSegmentContext_t {
  6152. + struct fasync_struct *fasync;
  6153. + wait_queue_head_t read_and_write_wait;
  6154. +
  6155. + int inEscape; /* 1 == We are in an escape sequence, 0 == NOT */
  6156. + int accessMode; /* See ACCESSMODE_xxx definitions below */
  6157. + int rawData; /* Raw == 1, Cooked == 0 */
  6158. + uint16_t currentRawVal;
  6159. +};
  6160. +static sevenSegmentContext_t sevenSegmentContext_l;
  6161. +
  6162. +#define ESCAPE 27
  6163. +
  6164. +#define ACCESSMODE_SHIFT 0
  6165. +#define ACCESSMODE_LSB 1
  6166. +#define ACCESSMODE_MSB 2
  6167. +#define ACCESSMODE_DAFAULT ACCESSMODE_SHIFT
  6168. +
  6169. +/**********************************************************************
  6170. +* Define our Seven Segment Data
  6171. +**********************************************************************/
  6172. +
  6173. +typedef struct sevenSegmentData_t sevenSegmentData_t;
  6174. +struct sevenSegmentData_t {
  6175. + int val;
  6176. + u_char raw_val;
  6177. +};
  6178. +
  6179. +#define SSD_BLANK ((u_char)~(0x00))
  6180. +
  6181. +static sevenSegmentData_t sevenSegmentData[] = {
  6182. + {'0', (u_char)~(SSD_A | SSD_B | SSD_C | SSD_D | SSD_E | SSD_F) },
  6183. + {'1', (u_char)~(SSD_B | SSD_C) },
  6184. + {'2', (u_char)~(SSD_A | SSD_B | SSD_G | SSD_E | SSD_D) },
  6185. + {'3', (u_char)~(SSD_A | SSD_B | SSD_G | SSD_C | SSD_D) },
  6186. + {'4', (u_char)~(SSD_F | SSD_G | SSD_B | SSD_C) },
  6187. + {'5', (u_char)~(SSD_A | SSD_F | SSD_G | SSD_C | SSD_D) },
  6188. + {'6', (u_char)~(SSD_A | SSD_F | SSD_E | SSD_D | SSD_C | SSD_G) },
  6189. + {'7', (u_char)~(SSD_A | SSD_B | SSD_C) },
  6190. + {'8', (u_char)~(SSD_A | SSD_B | SSD_C | SSD_D | SSD_E | SSD_F | SSD_G) },
  6191. + {'9', (u_char)~(SSD_G | SSD_F | SSD_A | SSD_B | SSD_C) },
  6192. + {'A', (u_char)~(SSD_E | SSD_F | SSD_A | SSD_B | SSD_C | SSD_G) },
  6193. + {'a', (u_char)~(SSD_E | SSD_F | SSD_A | SSD_B | SSD_C | SSD_G) },
  6194. + {'B', (u_char)~(SSD_F | SSD_E | SSD_D | SSD_C | SSD_G) },
  6195. + {'b', (u_char)~(SSD_F | SSD_E | SSD_D | SSD_C | SSD_G) },
  6196. + {'C', (u_char)~(SSD_A | SSD_F | SSD_E | SSD_D) },
  6197. + {'c', (u_char)~(SSD_A | SSD_F | SSD_E | SSD_D) },
  6198. + {'D', (u_char)~(SSD_B | SSD_C | SSD_D | SSD_E | SSD_G) },
  6199. + {'d', (u_char)~(SSD_B | SSD_C | SSD_D | SSD_E | SSD_G) },
  6200. + {'E', (u_char)~(SSD_A | SSD_F | SSD_G | SSD_E | SSD_D) },
  6201. + {'e', (u_char)~(SSD_A | SSD_F | SSD_G | SSD_E | SSD_D) },
  6202. + {'F', (u_char)~(SSD_A | SSD_F | SSD_G | SSD_E) },
  6203. + {'f', (u_char)~(SSD_A | SSD_F | SSD_G | SSD_E) },
  6204. + {'H', (u_char)~(SSD_F | SSD_E | SSD_G | SSD_B | SSD_C) },
  6205. + {'h', (u_char)~(SSD_F | SSD_E | SSD_G | SSD_B | SSD_C) },
  6206. + {'I', (u_char)~(SSD_F | SSD_E) },
  6207. + {'i', (u_char)~(SSD_F | SSD_E) },
  6208. + {'Y', (u_char)~(SSD_F | SSD_G | SSD_B | SSD_C | SSD_D) },
  6209. + {'y', (u_char)~(SSD_F | SSD_G | SSD_B | SSD_C | SSD_D) },
  6210. + {'-', (u_char)~(SSD_G) },
  6211. + {'_', (u_char)~(SSD_D) },
  6212. + {'.', (u_char)~(SSD_DOT) },
  6213. + {' ', SSD_BLANK },
  6214. + {0x00, SSD_BLANK },
  6215. + { -1, (u_char)~(0x00) } /* End Of Data --- Must Be Last */
  6216. +};
  6217. +
  6218. +/**********************************************************************
  6219. +* Function: val_to_raw_val
  6220. +**********************************************************************/
  6221. +static u_char val_to_raw_val(u_char val)
  6222. +{
  6223. + sevenSegmentData_t *data;
  6224. + u_char raw_val = 0xFF; /* Assume a blank if not found */
  6225. + for (data = sevenSegmentData; data->val != -1; data++) {
  6226. + if (val == data->val) {
  6227. + raw_val = data->raw_val;
  6228. + break;
  6229. + }
  6230. + }
  6231. + return(raw_val);
  6232. +}
  6233. +
  6234. +/**********************************************************************
  6235. +* Function: raw_val_to_val
  6236. +**********************************************************************/
  6237. +static u_char raw_val_to_val(u_char raw_val)
  6238. +{
  6239. + sevenSegmentData_t *data;
  6240. + u_char val = ' '; /* Assume a blank if not found */
  6241. + for (data = sevenSegmentData; data->val != -1; data++) {
  6242. + if (raw_val == data->raw_val) {
  6243. + val = data->val;
  6244. + break;
  6245. + }
  6246. + }
  6247. + return(val);
  6248. +}
  6249. +
  6250. +/**********************************************************************
  6251. +* Function: lh79x_7seg_read_raw_display
  6252. +* Function: lh79x_7seg_read_raw_display_lsb
  6253. +* Function: lh79x_7seg_read_raw_display_msb
  6254. +**********************************************************************/
  6255. +uint16_t lh79x_7seg_read_raw_display(void)
  6256. +{
  6257. + sevenSegmentContext_t *sevenSegmentContext = &sevenSegmentContext_l;
  6258. + uint16_t raw_val;
  6259. +
  6260. + /*
  6261. + * NOTE: The device does not read so we have to remember...
  6262. + */
  6263. + raw_val = sevenSegmentContext->currentRawVal;
  6264. + vdprintk("lh79x_7seg_read_raw_display(0x%04X)\n", raw_val);
  6265. +
  6266. + return(raw_val);
  6267. +}
  6268. +
  6269. +u_char lh79x_7seg_read_raw_display_lsb(void)
  6270. +{
  6271. + uint16_t raw_val;
  6272. + u_char raw_lsb;
  6273. +
  6274. + raw_val = lh79x_7seg_read_raw_display();
  6275. + raw_lsb = (u_char)(raw_val & 0xFF);
  6276. +
  6277. + return(raw_lsb);
  6278. +}
  6279. +
  6280. +u_char lh79x_7seg_read_raw_display_msb(void)
  6281. +{
  6282. + uint16_t raw_val;
  6283. + u_char raw_msb;
  6284. +
  6285. + raw_val = lh79x_7seg_read_raw_display();
  6286. + raw_msb = (u_char)((raw_val >> 8) & 0xFF);
  6287. +
  6288. + return(raw_msb);
  6289. +}
  6290. +
  6291. +/**********************************************************************
  6292. +* Function: lh79x_7seg_read_display
  6293. +* Function: lh79x_7seg_read_display_lsb
  6294. +* Function: lh79x_7seg_read_display_msb
  6295. +**********************************************************************/
  6296. +uint16_t lh79x_7seg_read_display(void)
  6297. +{
  6298. + uint16_t raw_val, val;
  6299. + u_char raw_lsb, lsb;
  6300. + u_char raw_msb, msb;
  6301. +
  6302. + raw_val = lh79x_7seg_read_raw_display();
  6303. + raw_lsb = (u_char)( raw_val & 0xFF);
  6304. + raw_msb = (u_char)((raw_val >> 8) & 0xFF);
  6305. + lsb = raw_val_to_val(raw_lsb);
  6306. + msb = raw_val_to_val(raw_msb);
  6307. + val = (uint16_t)((msb << 8) | lsb);
  6308. +
  6309. + return(val);
  6310. +}
  6311. +
  6312. +u_char lh79x_7seg_read_display_lsb(void)
  6313. +{
  6314. + u_char raw_lsb, lsb;
  6315. +
  6316. + raw_lsb = lh79x_7seg_read_raw_display_lsb();
  6317. + lsb = raw_val_to_val(raw_lsb);
  6318. +
  6319. + return(lsb);
  6320. +}
  6321. +
  6322. +u_char lh79x_7seg_read_display_msb(void)
  6323. +{
  6324. + u_char raw_msb, msb;
  6325. +
  6326. + raw_msb = lh79x_7seg_read_raw_display_msb();
  6327. + msb = raw_val_to_val(raw_msb);
  6328. +
  6329. + return(msb);
  6330. +}
  6331. +
  6332. +/**********************************************************************
  6333. +* Function: lh79x_7seg_write_raw_display
  6334. +* Function: lh79x_7seg_write_raw_display_lsb
  6335. +* Function: lh79x_7seg_write_raw_display_msb
  6336. +**********************************************************************/
  6337. +void lh79x_7seg_write_raw_display(uint16_t raw_val)
  6338. +{
  6339. + sevenSegmentContext_t *sevenSegmentContext = &sevenSegmentContext_l;
  6340. +
  6341. + vdprintk("lh79x_7seg_write_raw_display(0x%04X)\n", raw_val);
  6342. + /*
  6343. + * NOTE: The device does not read so we have to remember...
  6344. + */
  6345. + sevenSegmentContext->currentRawVal = raw_val;
  6346. + cpld->seven_seg = raw_val;
  6347. +
  6348. + return;
  6349. +}
  6350. +
  6351. +void lh79x_7seg_write_raw_display_lsb(u_char raw_lsb)
  6352. +{
  6353. + uint16_t raw_val;
  6354. +
  6355. + raw_val = lh79x_7seg_read_raw_display();
  6356. + raw_val &= 0xFF00;
  6357. + raw_val &= ((uint16_t)raw_lsb) & 0x00FF;
  6358. + lh79x_7seg_write_raw_display(raw_val);
  6359. +
  6360. + return;
  6361. +}
  6362. +
  6363. +void lh79x_7seg_write_raw_display_msb(u_char raw_msb)
  6364. +{
  6365. + uint16_t raw_val;
  6366. +
  6367. + raw_val = lh79x_7seg_read_raw_display();
  6368. + raw_val &= 0x00FF;
  6369. + raw_val &= (((uint16_t)raw_msb) << 8) & 0xFF00;
  6370. + lh79x_7seg_write_raw_display(raw_val);
  6371. +
  6372. + return;
  6373. +}
  6374. +
  6375. +/**********************************************************************
  6376. +* Function: lh79x_7seg_write_display
  6377. +* Function: lh79x_7seg_write_display_lsb
  6378. +* Function: lh79x_7seg_write_display_msb
  6379. +* Function: lh79x_7seg_write_display_str
  6380. +**********************************************************************/
  6381. +void lh79x_7seg_write_display(uint16_t val)
  6382. +{
  6383. + u_char raw_lsb, lsb;
  6384. + u_char raw_msb, msb;
  6385. + uint16_t raw_val;
  6386. +
  6387. + lsb = (u_char)( val & 0xFF);
  6388. + msb = (u_char)((val >> 8) & 0xFF);
  6389. + raw_lsb = val_to_raw_val(lsb);
  6390. + raw_msb = val_to_raw_val(msb);
  6391. + raw_val = (uint16_t)((raw_msb << 8) | raw_lsb);
  6392. + lh79x_7seg_write_raw_display(raw_val);
  6393. +
  6394. + return;
  6395. +}
  6396. +
  6397. +void lh79x_7seg_write_display_lsb(u_char lsb)
  6398. +{
  6399. + u_char raw_lsb;
  6400. +
  6401. + raw_lsb = val_to_raw_val(lsb);
  6402. + lh79x_7seg_write_raw_display_lsb(raw_lsb);
  6403. +
  6404. + return;
  6405. +}
  6406. +
  6407. +void lh79x_7seg_write_display_msb(u_char msb)
  6408. +{
  6409. + u_char raw_msb;
  6410. +
  6411. + raw_msb = val_to_raw_val(msb);
  6412. + lh79x_7seg_write_raw_display_msb(raw_msb);
  6413. +
  6414. + return;
  6415. +}
  6416. +
  6417. +void lh79x_7seg_write_display_str(u_char *str)
  6418. +{
  6419. + uint16_t val;
  6420. + uint16_t c16;
  6421. + u_char c;
  6422. +
  6423. + if (str) {
  6424. + /* This is basically a read, shift, write lsb loop */
  6425. + for ( ; *str; str++) {
  6426. + c = *str;
  6427. + if (c == '\n') continue;
  6428. + if (c == '\r') continue;
  6429. + val = lh79x_7seg_read_display();
  6430. + val <<= 8;
  6431. + val &= 0xFF00;
  6432. + c16 = c & 0x00FF;
  6433. + val |= c16;
  6434. + lh79x_7seg_write_display(val);
  6435. + }
  6436. + }
  6437. + return;
  6438. +}
  6439. +
  6440. +/**********************************************************************
  6441. +* Function: sevenSegment_read
  6442. +* Function: sevenSegment_poll
  6443. +* Function: sevenSegment_open
  6444. +* Function: sevenSegment_fasync
  6445. +* Function: sevenSegment_release
  6446. +* ************************************
  6447. +* *** User space driver interfaces ***
  6448. +* ************************************
  6449. +**********************************************************************/
  6450. +
  6451. +/*
  6452. +* NOTE: The read algorithm is wide open for interpretation.
  6453. +* I am not sure what the behaviour ought to be here.
  6454. +*/
  6455. +static ssize_t sevenSegment_read(struct file *filp, char *buffer,
  6456. + size_t _count, loff_t *ppos)
  6457. +{
  6458. + sevenSegmentContext_t *sevenSegmentContext = filp->private_data;
  6459. + DECLARE_WAITQUEUE(wait, current);
  6460. + ssize_t sizeRead = 0;
  6461. + char *ptr = buffer;
  6462. + int err = 0;
  6463. + int count = (int)_count;
  6464. + uint16_t c16;
  6465. + u_char c;
  6466. + int dataSize;
  6467. + int dataByteCount;
  6468. +
  6469. + switch (sevenSegmentContext->accessMode) {
  6470. + case ACCESSMODE_LSB:
  6471. + case ACCESSMODE_MSB:
  6472. + dataSize = 8;
  6473. + break;
  6474. + case ACCESSMODE_SHIFT:
  6475. + default:
  6476. + dataSize = 16;
  6477. + break;
  6478. + }
  6479. + dataByteCount = dataSize / 8;
  6480. +
  6481. + add_wait_queue(&sevenSegmentContext->read_and_write_wait, &wait);
  6482. + while (count >= dataByteCount) {
  6483. + err = -ERESTARTSYS;
  6484. + if (signal_pending(current))
  6485. + break;
  6486. + /* NOTE: We always have data */
  6487. + switch (sevenSegmentContext->accessMode) {
  6488. + case ACCESSMODE_LSB:
  6489. + c = lh79x_7seg_read_display_lsb();
  6490. + break;
  6491. + case ACCESSMODE_MSB:
  6492. + c = lh79x_7seg_read_display_msb();
  6493. + break;
  6494. + case ACCESSMODE_SHIFT:
  6495. + default:
  6496. + c16 = lh79x_7seg_read_display();
  6497. + /* Flip the bytes so they get returned in the correct order */
  6498. + c = (u_char)(c16 >> 8);
  6499. + c16 = ((c16 << 8) & 0xFF00) | ((uint16_t)c);
  6500. + break;
  6501. + }
  6502. + if (dataSize == 8) {
  6503. + err = copy_to_user(ptr, &c, sizeof(c));
  6504. + if (err)
  6505. + break;
  6506. + ptr += sizeof(c);
  6507. + count -= sizeof(c);
  6508. + } else /* (dataSize == 16) */ {
  6509. + err = copy_to_user(ptr, &c16, sizeof(c16));
  6510. + if (err)
  6511. + break;
  6512. + ptr += sizeof(c16);
  6513. + count -= sizeof(c16);
  6514. + }
  6515. + }
  6516. + remove_wait_queue(&sevenSegmentContext->read_and_write_wait, &wait);
  6517. + sizeRead = (ptr == buffer ? err : ptr - buffer);
  6518. + return(sizeRead);
  6519. +}
  6520. +
  6521. +static ssize_t sevenSegment_write(struct file *filp, const char *buffer,
  6522. + size_t _count, loff_t *ppos)
  6523. +{
  6524. + sevenSegmentContext_t *sevenSegmentContext = filp->private_data;
  6525. + ssize_t sizeWritten = 0;
  6526. + const char *ptr = buffer;
  6527. + int count;
  6528. + u_char c;
  6529. + uint16_t c16;
  6530. + uint16_t val;
  6531. + int err = 0;
  6532. +
  6533. + for (count = (int)_count; count > 0; count--) {
  6534. + /* NOTE: We always have room for the data */
  6535. + get_user(c, ptr++);
  6536. + /* Ignore new_line or carriage_return characters */
  6537. + if (c == '\n') continue;
  6538. + if (c == '\r') continue;
  6539. + vdprintk("JMG: (e:%d, r:%d, a:%d) Attempting to write (%c) == (0x%02X)\n",
  6540. + sevenSegmentContext->inEscape,
  6541. + sevenSegmentContext->rawData,
  6542. + sevenSegmentContext->accessMode,
  6543. + c, c);
  6544. + if (sevenSegmentContext->inEscape) {
  6545. + sevenSegmentContext->inEscape = 0;
  6546. + if ( c != ESCAPE ) {
  6547. + switch (c) {
  6548. + case 'r': /* Raw Data */
  6549. + case 'R': /* Raw Data */
  6550. + sevenSegmentContext->rawData = 1;
  6551. + break;
  6552. + case 'c': /* Coooked Data */
  6553. + case 'C': /* Coooked Data */
  6554. + sevenSegmentContext->rawData = 0;
  6555. + break;
  6556. + case 'l': /* LSB */
  6557. + case 'L': /* LSB */
  6558. + sevenSegmentContext->accessMode = ACCESSMODE_LSB;
  6559. + break;
  6560. + case 'm': /* MSB */
  6561. + case 'M': /* MSB */
  6562. + sevenSegmentContext->accessMode = ACCESSMODE_MSB;
  6563. + break;
  6564. + case 's': /* Shift */
  6565. + case 'S': /* Shift */
  6566. + case 'n': /* Normal */
  6567. + case 'N': /* Normal */
  6568. + default:
  6569. + sevenSegmentContext->accessMode = ACCESSMODE_SHIFT;
  6570. + }
  6571. + continue;
  6572. + }
  6573. + } else if ( c == ESCAPE ) {
  6574. + sevenSegmentContext->inEscape = 1;
  6575. + continue;
  6576. + }
  6577. + if (sevenSegmentContext->rawData) {
  6578. + val = lh79x_7seg_read_raw_display();
  6579. + } else {
  6580. + val = lh79x_7seg_read_display();
  6581. + }
  6582. + switch (sevenSegmentContext->accessMode) {
  6583. + case ACCESSMODE_LSB:
  6584. + val &= 0xFF00;
  6585. + c16 = c & 0x00FF;
  6586. + val |= c16;
  6587. + break;
  6588. + case ACCESSMODE_MSB:
  6589. + val &= 0x00FF;
  6590. + c16 = ((uint16_t)c << 8) & 0xFF00;
  6591. + val |= c16;
  6592. + break;
  6593. + case ACCESSMODE_SHIFT:
  6594. + default:
  6595. + val <<= 8;
  6596. + val &= 0xFF00;
  6597. + c16 = c & 0x00FF;
  6598. + val |= c16;
  6599. + break;
  6600. + }
  6601. + vdprintk("JMG: Writing (0x%04X)\n", val);
  6602. + if (sevenSegmentContext->rawData) {
  6603. + lh79x_7seg_write_raw_display(val);
  6604. + } else {
  6605. + lh79x_7seg_write_display(val);
  6606. + }
  6607. + }
  6608. + filp->f_dentry->d_inode->i_mtime = CURRENT_TIME;
  6609. + sizeWritten = (ptr == buffer ? err : ptr - buffer);
  6610. + return(sizeWritten);
  6611. +}
  6612. +
  6613. +static unsigned int sevenSegment_poll(struct file *filp, poll_table *wait)
  6614. +{
  6615. + sevenSegmentContext_t *sevenSegmentContext = filp->private_data;
  6616. + /* We ALWAYS have data waiting ;) */
  6617. + int sts = POLLIN | POLLRDNORM;
  6618. + poll_wait(filp, &sevenSegmentContext->read_and_write_wait, wait);
  6619. + return(sts);
  6620. +}
  6621. +
  6622. +static int sevenSegment_open(struct inode *inode, struct file *filp)
  6623. +{
  6624. + sevenSegmentContext_t *sevenSegmentContext = &sevenSegmentContext_l;
  6625. + int sts = 0;
  6626. + filp->private_data = sevenSegmentContext;
  6627. + return(sts);
  6628. +}
  6629. +
  6630. +static int sevenSegment_fasync(int fd, struct file *filp, int on)
  6631. +{
  6632. + sevenSegmentContext_t *sevenSegmentContext = filp->private_data;
  6633. + int sts;
  6634. + sts = fasync_helper(fd, filp, on, &sevenSegmentContext->fasync);
  6635. + return(sts);
  6636. +}
  6637. +
  6638. +static int sevenSegment_release(struct inode *inode, struct file *filp)
  6639. +{
  6640. + lock_kernel();
  6641. + sevenSegment_fasync(-1, filp, 0);
  6642. + unlock_kernel();
  6643. + return(0);
  6644. +}
  6645. +
  6646. +/**********************************************************************
  6647. +* Define (fill in) the user space file operations for this driver
  6648. +* and initialize the Seven Segment driver as a "miscdevice":
  6649. +* Character device
  6650. +* Major(10) --- Non-serial mice, misc features
  6651. +* Minor(21) --- /dev/7seg (7-segment display)
  6652. +**********************************************************************/
  6653. +static struct file_operations sevenSegment_fops = {
  6654. +owner: THIS_MODULE,
  6655. +read: sevenSegment_read,
  6656. +write: sevenSegment_write,
  6657. +poll: sevenSegment_poll,
  6658. +open: sevenSegment_open,
  6659. +fasync: sevenSegment_fasync,
  6660. +release: sevenSegment_release,
  6661. +};
  6662. +
  6663. +static struct miscdevice sevenSegment_dev = {
  6664. +minor: 21,
  6665. +name: "7seg",
  6666. +fops: &sevenSegment_fops,
  6667. +};
  6668. +
  6669. +/**********************************************************************
  6670. +* Function: lh79x_7seg_init
  6671. +*
  6672. +* Purpose:
  6673. +* Register & Initialize the module
  6674. +**********************************************************************/
  6675. +static int lh79x_7seg_init(void)
  6676. +{
  6677. + sevenSegmentContext_t *sevenSegmentContext = &sevenSegmentContext_l;
  6678. + int sts = 0;
  6679. + dprintk("ENTER: lh79x_7seg_init()\n");
  6680. + init_waitqueue_head(&sevenSegmentContext->read_and_write_wait);
  6681. + sts = misc_register(&sevenSegment_dev);
  6682. + lh79x_7seg_write_display_str((u_char *)"HI");
  6683. + dprintk("LEAVE: lh79x_7seg_init(%d)\n", sts);
  6684. + return(sts);
  6685. +}
  6686. +
  6687. +/**********************************************************************
  6688. +* Function: lh79x_7seg_exit
  6689. +*
  6690. +* Purpose:
  6691. +* Un-Register & Cleanup the module
  6692. +**********************************************************************/
  6693. +static void lh79x_7seg_exit(void)
  6694. +{
  6695. + dprintk("ENTER: lh79x_7seg_exit()\n");
  6696. + misc_deregister(&sevenSegment_dev);
  6697. + lh79x_7seg_write_display_str((u_char *)"BY");
  6698. + dprintk("LEAVE: lh79x_7seg_exit()\n");
  6699. + return;
  6700. +}
  6701. +
  6702. +module_init(lh79x_7seg_init);
  6703. +module_exit(lh79x_7seg_exit);
  6704. +
  6705. +MODULE_AUTHOR("Jim Gleason / Lineo, Inc.");
  6706. +MODULE_DESCRIPTION("Seven Segment Display Driver for Sharp LH7x EVB");
  6707. +MODULE_LICENSE("Copyright (c) 2002 Lineo, Inc.");
  6708. +
  6709. diff -urN linux-2.4.26/drivers/misc/Makefile linux-2.4.26-vrs1-lnode80/drivers/misc/Makefile
  6710. --- linux-2.4.26/drivers/misc/Makefile 2005-11-02 16:54:22.000000000 -0400
  6711. +++ linux-2.4.26-vrs1-lnode80/drivers/misc/Makefile 2005-11-02 17:37:31.000000000 -0400
  6712. @@ -18,6 +18,9 @@
  6713. obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o
  6714. obj-$(CONFIG_MCP_UCB1200_AUDIO) += ucb1x00-audio.o
  6715. obj-$(CONFIG_MCP_UCB1200_TS) += ucb1x00-ts.o
  6716. +obj-$(CONFIG_TOUCHSCREEN_LH79520) += ads784x.o marm-lh7x.o
  6717. +obj-$(CONFIG_EEPROM_LH79520) += eeprom-lh7x.o
  6718. +obj-$(CONFIG_7SEGMENT_LH79520) += lh7x-7seg.o
  6719. include $(TOPDIR)/Rules.make
  6720. diff -urN linux-2.4.26/drivers/misc/marm-lh7x.c linux-2.4.26-vrs1-lnode80/drivers/misc/marm-lh7x.c
  6721. --- linux-2.4.26/drivers/misc/marm-lh7x.c 1969-12-31 20:00:00.000000000 -0400
  6722. +++ linux-2.4.26-vrs1-lnode80/drivers/misc/marm-lh7x.c 2005-11-02 17:37:31.000000000 -0400
  6723. @@ -0,0 +1,521 @@
  6724. +/* vi: set sw=4 ts=4 ai: */
  6725. +
  6726. +// #define MODULE
  6727. +
  6728. +/**********************************************************************
  6729. +* linux/drivers/misc/ssp-lh7x.c
  6730. +*
  6731. +* Provide SSP (synchronous Serial Port) functionality for LH7x EVB boards
  6732. +*
  6733. +* Copyright (C) 2002 Lineo, Inc.
  6734. +*
  6735. +* This program is free software; you can redistribute it and/or modify
  6736. +* it under the terms of the GNU General Public License (GPL) version 2
  6737. +* as published by the Free Software Foundation.
  6738. +*
  6739. +**********************************************************************/
  6740. +
  6741. +#include <linux/config.h>
  6742. +#include <linux/types.h>
  6743. +#include <linux/kernel.h>
  6744. +#include <linux/init.h>
  6745. +#include <linux/module.h>
  6746. +#include <linux/wait.h>
  6747. +#include <linux/sched.h>
  6748. +#include <linux/smp_lock.h>
  6749. +#include <linux/spinlock.h>
  6750. +#include <linux/delay.h>
  6751. +
  6752. +#undef DEBUG
  6753. +#undef VERBOSE
  6754. +#define DRVNAME "marm_lh7x"
  6755. +#include <linux/verbosedebug.h>
  6756. +
  6757. +#include <linux/version.h>
  6758. +#ifdef MODULE
  6759. +char kernel_version[] = UTS_RELEASE;
  6760. +#endif /* MODULE */
  6761. +
  6762. +#include <asm/irq.h>
  6763. +#include <asm/mach/irq.h>
  6764. +#include <asm/arch/irq.h>
  6765. +#include <asm/arch/iocon.h>
  6766. +#include <asm/arch/hardware.h>
  6767. +#include <asm/arch/gpio.h>
  6768. +#include <asm/arch/ssp_lh7x.h>
  6769. +#include <lh79520.h>
  6770. +#include "ssp.h"
  6771. +
  6772. +// global set by pl110fb driver
  6773. +unsigned short marm_backlight;
  6774. +
  6775. +#undef BACKLIGHT
  6776. +#define BACKLIGHT marm_backlight
  6777. +
  6778. +#define MARM_TS_INT 3
  6779. +#define MARM_TS_IOBIT 6
  6780. +
  6781. +static volatile u16 *gpioa = (volatile u16 *) GPOUT16_BASE;
  6782. +static gpioARegs_t *gpioadr = (gpioARegs_t *) GPIO0_BASE;
  6783. +static ioconRegs_t *iocon = (ioconRegs_t *)IOCON_PHYS;
  6784. +static vicRegs_t *vic = (vicRegs_t *)VIC_BASE;
  6785. +static rcpcRegs_t *rcpc = (rcpcRegs_t *) RCPC_PHYS;
  6786. +
  6787. +/**********************************************************************
  6788. +* Function: ssp_busy_wait
  6789. +*
  6790. +* Purpose:
  6791. +* Wait until the state of the SSP busy bit from the status register
  6792. +* indicates the SSP is no longer busy.
  6793. +*
  6794. +* Returns:
  6795. +* N/A
  6796. +**********************************************************************/
  6797. +static void ssp_busy_wait(void)
  6798. +{
  6799. + vdprintk("ENTER: ssp_busy_wait()\n");
  6800. +};
  6801. +
  6802. +/**********************************************************************
  6803. +* Function: ssp_flush_tx_fifo
  6804. +* Function: ssp_flush_rx_fifo
  6805. +*
  6806. +* Purpose:
  6807. +* Flush the transmit (tx) and receive (rx) fifo buffer
  6808. +*
  6809. +* Returns:
  6810. +* N/A
  6811. +**********************************************************************/
  6812. +static void ssp_flush_tx_fifo(sspContext_t *sspContext)
  6813. +{
  6814. + vdprintk("ENTER: ssp_flush_tx_fifo()\n");
  6815. +};
  6816. +
  6817. +static void ssp_flush_rx_fifo(sspContext_t *sspContext)
  6818. +{
  6819. + vdprintk("ENTER: ssp_flush_rx_fifo()\n");
  6820. +};
  6821. +
  6822. +/**********************************************************************
  6823. +* Function: ssp_chipselect_enable
  6824. +* Function: ssp_chipselect_disable
  6825. +* Function: ssp_chipselect_manual
  6826. +* Function: ssp_chipselect_automatic
  6827. +*
  6828. +* Purpose:
  6829. +* Controls the chipselect pin associated with the SSP
  6830. +*
  6831. +* Returns:
  6832. +* N/A
  6833. +*
  6834. +**********************************************************************/
  6835. +static void ssp_chipselect_enable(void)
  6836. +{
  6837. + vdprintk("ENTER: ssp_chipselect_enable()\n");
  6838. +};
  6839. +
  6840. +static void ssp_chipselect_disable(void)
  6841. +{
  6842. + vdprintk("ENTER: ssp_chipselect_disable()\n");
  6843. +};
  6844. +
  6845. +static void ssp_chipselect_manual(void)
  6846. +{
  6847. + vdprintk("ENTER: ssp_chipselect_manual()\n");
  6848. +
  6849. + gpioadr->ddr &= ~(1 << MARM_TS_IOBIT); // make sure PA is input
  6850. + iocon->MiscMux &= ~(MISCMUX_RCEII0); // make it PA6 instead of IRQ0
  6851. +
  6852. + // ensure TS IRQ pin is interrupt
  6853. + iocon->LCDMux &= ~(MISCMUX_PWM0SYNC); // assumes irq 3
  6854. +};
  6855. +
  6856. +static void ssp_chipselect_automatic(void)
  6857. +{
  6858. + vdprintk("ENTER: ssp_chipselect_automatic()\n");
  6859. + ssp_chipselect_manual();
  6860. +};
  6861. +
  6862. +/**********************************************************************
  6863. +* Function: ssp_lh7x_write16
  6864. +*
  6865. +* Purpose:
  6866. +* Write the LH7x SSP data register
  6867. +**********************************************************************/
  6868. +static void ssp_lh7x_write16(sspContext_t *sspContext,
  6869. + unsigned int data)
  6870. +{
  6871. + int i;
  6872. + int ndata = data & 0xFF;
  6873. + int pdata, qdata;
  6874. +
  6875. + vdprintk("ENTER: ssp_lh7x_write16() 0x%04X\n", data);
  6876. +
  6877. + udelay(10);
  6878. + pdata = BACKLIGHT; // keep on backlight
  6879. + *gpioa = pdata; // assert nCS
  6880. +
  6881. + for (i = 8; i > 0; i--)
  6882. + {
  6883. + *gpioa = qdata = pdata | ((ndata & 0x80) ? TS_DIN : 0); // strobe out bit
  6884. + udelay(1);
  6885. + *gpioa = qdata | TS_DCLK | nLED; // raise clock
  6886. + udelay(1);
  6887. + *gpioa = qdata; // lower clock
  6888. + udelay(1);
  6889. +
  6890. + ndata <<= 1;
  6891. + }
  6892. + udelay(50); // leave enough time for conversion
  6893. +
  6894. + *gpioa = pdata;
  6895. +};
  6896. +
  6897. +/**********************************************************************
  6898. +* Function: ssp_lh7x_read16
  6899. +*
  6900. +* Purpose:
  6901. +* Read the LH7x SSP data register
  6902. +**********************************************************************/
  6903. +static unsigned int ssp_lh7x_read16(sspContext_t *sspContext)
  6904. +{
  6905. + int i;
  6906. + int pdata, ndata;
  6907. +
  6908. + pdata = BACKLIGHT;
  6909. + ndata = 0;
  6910. +
  6911. + for (i = 16; i > 0; i--)
  6912. + {
  6913. + *gpioa = pdata;
  6914. + udelay(1);
  6915. + *gpioa = pdata | TS_DCLK | nLED;
  6916. + udelay(1);
  6917. +
  6918. + if (gpioadr->dr & (1 << MARM_TS_IOBIT))
  6919. + ndata |= 1;
  6920. +
  6921. + ndata <<= 1;
  6922. + }
  6923. +
  6924. + vdprintk("LEAVE: ssp_lh7x_read16() 0x%04X (%04d norm) raw\n", ndata, ndata >> 4);
  6925. + return(ndata >> 4);
  6926. +};
  6927. +
  6928. +/**********************************************************************
  6929. +* Macro: ssp_lh7x_ts_pen_down
  6930. +**********************************************************************/
  6931. +static int ssp_lh7x_ts_pen_down(sspContext_t *sspContext)
  6932. +{
  6933. + int pen_down = vic->RawIntr & (1 << MARM_TS_INT); //look for IRQ
  6934. + vdprintk("ssp_lh7x_ts_pen_down(%d)\n", pen_down);
  6935. + return (pen_down);
  6936. +}
  6937. +
  6938. +/**********************************************************************
  6939. +* Macro: ssp_lh7x_ts_pen_down_irq_enable
  6940. +**********************************************************************/
  6941. +static int ssp_lh7x_ts_pen_down_irq_enable(sspContext_t *sspContext)
  6942. +{
  6943. + int lastState = vic->IntEnable & (1 << MARM_TS_INT);
  6944. + vdprintk("ssp_lh7x_ts_pen_down_irq_enable: lastState %d\n", lastState);
  6945. +#if 0
  6946. + //enable_irq(MARM_TS_INT);
  6947. + rcpc->control |= RCPC_CTRL_WRTLOCK_ENABLED;
  6948. + barrier();
  6949. + rcpc->control &= ~RCPC_CTRL_WRTLOCK_ENABLED;
  6950. +#endif
  6951. + sspContext->irq_state = 1;
  6952. + return(lastState);
  6953. +}
  6954. +
  6955. +/**********************************************************************
  6956. +* Macro: ssp_lh7x_ts_pen_down_irq_disable
  6957. +**********************************************************************/
  6958. +static int ssp_lh7x_ts_pen_down_irq_disable(
  6959. + sspContext_t *sspContext)
  6960. +{
  6961. + int lastState = vic->IntEnable & (1 << MARM_TS_INT);
  6962. + vdprintk("ssp_lh7x_ts_pen_down_irq_disable: lastState %d\n", lastState);
  6963. + //disable_irq(MARM_TS_INT);
  6964. + rcpc->control |= RCPC_CTRL_WRTLOCK_ENABLED;
  6965. + barrier();
  6966. + rcpc->intClear = (1 << MARM_TS_INT);
  6967. + rcpc->control &= ~RCPC_CTRL_WRTLOCK_ENABLED;
  6968. + sspContext->irq_state = 0;
  6969. + return(lastState);
  6970. +}
  6971. +
  6972. +/**********************************************************************
  6973. +* Function: ssp_lh7x_ts_pen_down_irq
  6974. +*
  6975. +* We only detect touch screen _touches_ (pen down) with this interrupt
  6976. +* handler, and even then we just schedule our task.
  6977. +*
  6978. +* Note: It has already been determined that this is our interrupt
  6979. +* before we ever get it here so checking is minimal to non-existant.
  6980. +**********************************************************************/
  6981. +static void ssp_lh7x_ts_pen_down_irq(int irq, sspContext_t *sspContext,
  6982. + struct pt_regs * regs)
  6983. +{
  6984. + /*
  6985. + * Disable the touchscreen interrupts
  6986. + * by disabling the touchscreen IRQ
  6987. + * --- AND ---
  6988. + * Enable regular polling of the touchscreen device
  6989. + * (The touchscreen IRQ will be re-enabled and polling
  6990. + * will be disabled when it is detected that the
  6991. + * pen is no longer down.)
  6992. + */
  6993. + /* Disable touch screen IRQ */
  6994. + vdprintk("ENTER: ssp_lh7x_ts_pen_down_irq()\n");
  6995. + ssp_lh7x_ts_pen_down_irq_disable(sspContext);
  6996. + vdprintk("ENTER: wake_up()\n");
  6997. + wake_up(sspContext->irq_wait_ptr);
  6998. + vdprintk("LEAVE: ssp_lh7x_ts_pen_down_irq()\n");
  6999. + return;
  7000. +}
  7001. +
  7002. +/**********************************************************************
  7003. +* Function: ssp_lh7x_irq_handler
  7004. +*
  7005. +* This interrupt handler only directs traffic for the interrupts
  7006. +* by forwarding on the call to the appropriate interrupt handler.
  7007. +**********************************************************************/
  7008. +static void ssp_lh7x_irq_handler(int irq, void *_sspContext,
  7009. + struct pt_regs * regs)
  7010. +{
  7011. + sspContext_t *sspContext = _sspContext;
  7012. +
  7013. + vdprintk("ENTER: ssp_lh7x_irq_handler()\n");
  7014. + if ((sspContext) && (sspContext->irq_wait_ptr)) {
  7015. + if (ssp_lh7x_ts_pen_down(sspContext))
  7016. + ssp_lh7x_ts_pen_down_irq(irq, sspContext, regs);
  7017. + else
  7018. +#if defined(VERBOSE) && defined(DEBUG)
  7019. + printk("ssp_lh7x_irq_handler() --- Not our interrupt\n");
  7020. +#else
  7021. + ;
  7022. +#endif
  7023. + } // if(sspContext) ...
  7024. +#if defined(VERBOSE) && defined(DEBUG)
  7025. + else {
  7026. + printk("ssp_lh7x_irq_handler( NO ACTION )\n");
  7027. + }
  7028. +#endif
  7029. + return;
  7030. +}
  7031. +
  7032. +/**********************************************************************
  7033. +* Function: ssp_lh7x_lock
  7034. +* Function: ssp_lh7x_unlock
  7035. +*
  7036. +* Purpose:
  7037. +* Lock/UnLock the SSP for a particular device (ts/ee)
  7038. +**********************************************************************/
  7039. +static int ssp_lh7x_lock(sspContext_t *sspContext, int device)
  7040. +{
  7041. + vdprintk("ENTER: ssp_lh7x_lock()\n");
  7042. + return -1;
  7043. +};
  7044. +
  7045. +static int ssp_lh7x_unlock(sspContext_t *sspContext, int device)
  7046. +{
  7047. + vdprintk("ENTER: ssp_lh7x_unlock()\n");
  7048. + return -1;
  7049. +};
  7050. +
  7051. +/**********************************************************************
  7052. +* Function: ssp_lh7x_disable
  7053. +*
  7054. +* Purpose:
  7055. +* Disconnect I/O pins from the SSP module
  7056. +* and disable the SSP peripheral and its clocks.
  7057. +**********************************************************************/
  7058. +static void ssp_lh7x_disable(void)
  7059. +{
  7060. + vdprintk("ENTER: ssp_lh7x_disable()\n");
  7061. +};
  7062. +
  7063. +/**********************************************************************
  7064. +* Function: ssp_lh7x_enable
  7065. +*
  7066. +* Purpose:
  7067. +* Disconnect I/O pins from the SSP module
  7068. +* and disable the SSP peripheral and its clocks.
  7069. +**********************************************************************/
  7070. +static void ssp_lh7x_enable(void)
  7071. +{
  7072. + vdprintk("ENTER: ssp_lh7x_enable()\n");
  7073. + return;
  7074. +}
  7075. +
  7076. +/**********************************************************************
  7077. +* Fill in our context structures
  7078. +**********************************************************************/
  7079. +
  7080. +static sspContext_t sspContext_l = {
  7081. + ts_txTimeout: 10000,
  7082. + ts_rxTimeout: 10000,
  7083. + ee_txTimeout: 10000,
  7084. + ee_rxTimeout: 10000,
  7085. + haveIrq: 0,
  7086. +};
  7087. +
  7088. +/**********************************************************************
  7089. +* Function: ssp_request_pointer
  7090. +* Function: ssp_provide_pointer
  7091. +*
  7092. +* Purpose:
  7093. +* Register & Initialize the module
  7094. +**********************************************************************/
  7095. +void *ssp_request_pointer(int device, char *request)
  7096. +{
  7097. + sspContext_t *sspContext = &sspContext_l;
  7098. + void *vp = NULL;
  7099. +
  7100. + vdprintk("ENTER: ssp_request_pointer(\"%d\":\"%s\")\n", device, request);
  7101. + if (device == SSP_DEV_TOUCHSCREEN) {
  7102. + if (strcmp(request, "write") == 0) {
  7103. + vp = ssp_lh7x_write16;
  7104. + } else if (strcmp(request, "read") == 0) {
  7105. + vp = ssp_lh7x_read16;
  7106. + } else if (strcmp(request, "enable_pen_down_irq") == 0) {
  7107. + vp = ssp_lh7x_ts_pen_down_irq_enable;
  7108. + } else if (strcmp(request, "disable_pen_down_irq") == 0) {
  7109. + vp = ssp_lh7x_ts_pen_down_irq_disable;
  7110. + } else if (strcmp(request, "is_pen_down") == 0) {
  7111. + vp = ssp_lh7x_ts_pen_down;
  7112. + } else if (strcmp(request, "lock") == 0) {
  7113. + vp = ssp_lh7x_lock;
  7114. + } else if (strcmp(request, "unlock") == 0) {
  7115. + vp = ssp_lh7x_unlock;
  7116. + } else if (strcmp(request, "sspContext") == 0) {
  7117. + vp = sspContext;
  7118. + } else if (strcmp(request, "flush_tx_fifo") == 0) {
  7119. + vp = ssp_flush_tx_fifo;
  7120. + } else if (strcmp(request, "flush_rx_fifo") == 0) {
  7121. + vp = ssp_flush_rx_fifo;
  7122. + } else if (strcmp(request, "ssp_busy_wait") == 0) {
  7123. + vp = ssp_busy_wait;
  7124. + } else if (strcmp(request, "chipselect_enable") == 0) {
  7125. + vp = ssp_chipselect_enable;
  7126. + } else if (strcmp(request, "chipselect_disable") == 0) {
  7127. + vp = ssp_chipselect_disable;
  7128. + } else if (strcmp(request, "chipselect_manual") == 0) {
  7129. + vp = ssp_chipselect_manual;
  7130. + }
  7131. + } else if (device == SSP_DEV_EEPROM) {
  7132. + vp = NULL;
  7133. + }
  7134. + vdprintk("LEAVE: ssp_request_pointer(0x%08X)\n", (unsigned int)vp);
  7135. +
  7136. + return(vp);
  7137. +}
  7138. +
  7139. +void *ssp_provide_pointer(int device, char *request, void *vp)
  7140. +{
  7141. + sspContext_t *sspContext = &sspContext_l;
  7142. +
  7143. + vdprintk("ENTER: ssp_provide_pointer(\"%d\":\"%s\":0x%08X)\n",
  7144. + device, request, (unsigned int)vp);
  7145. + if (device == SSP_DEV_TOUCHSCREEN) {
  7146. + if (strcmp(request, "irq_wait_ptr") == 0) {
  7147. + sspContext->irq_wait_ptr = vp;
  7148. + } else {
  7149. + vp = NULL;
  7150. + }
  7151. + } else if (device == SSP_DEV_EEPROM) {
  7152. + vp = NULL;
  7153. + } else {
  7154. + vp = NULL;
  7155. + }
  7156. + vdprintk("LEAVE: ssp_provide_pointer(0x%08X)\n", (unsigned int)vp);
  7157. +
  7158. + return(vp);
  7159. +}
  7160. +
  7161. +/**********************************************************************
  7162. +* Function: ssp_lh7x_init
  7163. +*
  7164. +* Purpose:
  7165. +* Register & Initialize the module
  7166. +**********************************************************************/
  7167. +static int __init ssp_lh7x_init(void)
  7168. +{
  7169. + sspContext_t *sspContext = &sspContext_l;
  7170. + int sts = 0;
  7171. + int result;
  7172. +
  7173. + vdprintk("ENTER: ssp_lh7x_init()\n");
  7174. +
  7175. + /*
  7176. + * Disconnect I/O pins from the SSP module
  7177. + * and disable the SSP peripheral and its clocks.
  7178. + */
  7179. + ssp_lh7x_disable();
  7180. +
  7181. + /* Flush the transmit FIFO */
  7182. + ssp_flush_tx_fifo(sspContext);
  7183. +
  7184. + /* Flush the receive FIFO */
  7185. + ssp_flush_rx_fifo(sspContext);
  7186. +
  7187. + ssp_chipselect_automatic();
  7188. + /*
  7189. + * Connect I/O pins from the SSP module
  7190. + * and enable the SSP peripheral and its clocks.
  7191. + */
  7192. + ssp_lh7x_enable();
  7193. +
  7194. + /*
  7195. + * Request IRQ and attach it to the touchscreen pen_down line and enable it
  7196. + */
  7197. + sspContext->haveIrq = 0;
  7198. + result = request_irq(MARM_TS_INT, ssp_lh7x_irq_handler,
  7199. + SA_SAMPLE_RANDOM, DRVNAME, sspContext);
  7200. + if (result < 0) {
  7201. + printk("%s: cannot get requested IRQ(MARM_TS_INT)\n", DRVNAME);
  7202. + } else {
  7203. + sspContext->haveIrq = 1;
  7204. + vdprintk("%s: got requested IRQ(MARM_TS_INT)\n", DRVNAME);
  7205. + }
  7206. + ssp_lh7x_ts_pen_down_irq_enable(sspContext);
  7207. +
  7208. + vdprintk("LEAVE: ssp_lh7x_init()\n");
  7209. + return(sts);
  7210. +}
  7211. +
  7212. +/**********************************************************************
  7213. +* Function: ssp_lh7x_exit
  7214. +*
  7215. +* Purpose:
  7216. +* Un-Register & Cleanup the module
  7217. +**********************************************************************/
  7218. +static void ssp_lh7x_exit(void)
  7219. +{
  7220. + sspContext_t *sspContext = &sspContext_l;
  7221. +
  7222. + vdprintk("ENTER: ssp_lh7x_exit()\n");
  7223. +
  7224. + /*
  7225. + * Disable & Return IRQ
  7226. + */
  7227. + lock_kernel();
  7228. + ssp_lh7x_ts_pen_down_irq_disable(sspContext);
  7229. + if (sspContext->haveIrq) {
  7230. + free_irq(MARM_TS_INT, sspContext);
  7231. + sspContext->haveIrq = 0;
  7232. + }
  7233. + unlock_kernel();
  7234. +
  7235. + vdprintk("LEAVE: ssp_lh7x_exit()\n");
  7236. + return;
  7237. +}
  7238. +
  7239. +module_init(ssp_lh7x_init);
  7240. +module_exit(ssp_lh7x_exit);
  7241. +
  7242. +MODULE_AUTHOR("Jim Gleason / Lineo, Inc.");
  7243. +MODULE_DESCRIPTION("SSP Driver for Sharp LH7x EVB");
  7244. +MODULE_LICENSE("Copyright (c) 2002 Lineo, Inc.");
  7245. diff -urN linux-2.4.26/drivers/misc/ssp.h linux-2.4.26-vrs1-lnode80/drivers/misc/ssp.h
  7246. --- linux-2.4.26/drivers/misc/ssp.h 1969-12-31 20:00:00.000000000 -0400
  7247. +++ linux-2.4.26-vrs1-lnode80/drivers/misc/ssp.h 2005-11-02 17:37:31.000000000 -0400
  7248. @@ -0,0 +1,29 @@
  7249. +/* vi: set sw=4 ts=4 ai: */
  7250. +
  7251. +/**********************************************************************
  7252. +* linux/drivers/misc/ssp.h
  7253. +*
  7254. +* Copyright (C) 2002 Lineo, Inc.
  7255. +*
  7256. +* Provide SSP types & definitions
  7257. +*
  7258. +* This program is free software; you can redistribute it and/or modify
  7259. +* it under the terms of the GNU General Public License (GPL) version 2
  7260. +* as published by the Free Software Foundation.
  7261. +*
  7262. +**********************************************************************/
  7263. +
  7264. +#ifndef _SSP_h
  7265. +#define _SSP_h
  7266. +
  7267. +/*********************************************************************
  7268. +* Global Function Declarations
  7269. +*********************************************************************/
  7270. +extern void *ssp_request_pointer(int device, char *request);
  7271. +extern void *ssp_provide_pointer(int device, char *request, void *vp);
  7272. +
  7273. +#define SSP_DEV_TOUCHSCREEN 1
  7274. +#define SSP_DEV_EEPROM 2
  7275. +
  7276. +#endif /* _SSP_h */
  7277. +
  7278. diff -urN linux-2.4.26/drivers/misc/ssp-lh7x.c linux-2.4.26-vrs1-lnode80/drivers/misc/ssp-lh7x.c
  7279. --- linux-2.4.26/drivers/misc/ssp-lh7x.c 1969-12-31 20:00:00.000000000 -0400
  7280. +++ linux-2.4.26-vrs1-lnode80/drivers/misc/ssp-lh7x.c 2005-11-02 17:37:31.000000000 -0400
  7281. @@ -0,0 +1,1024 @@
  7282. +/* vi: set sw=4 ts=4 ai: */
  7283. +
  7284. +// #define MODULE
  7285. +
  7286. +/**********************************************************************
  7287. +* linux/drivers/misc/ssp-lh7x.c
  7288. +*
  7289. +* Provide SSP (synchronous Serial Port) functionality for LH7x EVB boards
  7290. +*
  7291. +* Copyright (C) 2002 Lineo, Inc.
  7292. +*
  7293. +* This program is free software; you can redistribute it and/or modify
  7294. +* it under the terms of the GNU General Public License (GPL) version 2
  7295. +* as published by the Free Software Foundation.
  7296. +*
  7297. +**********************************************************************/
  7298. +
  7299. +#include <linux/config.h>
  7300. +#include <linux/types.h>
  7301. +#include <linux/kernel.h>
  7302. +#include <linux/init.h>
  7303. +#include <linux/module.h>
  7304. +//#include <linux/wait.h>
  7305. +#include <linux/sched.h>
  7306. +#include <linux/smp_lock.h>
  7307. +#include <linux/spinlock.h>
  7308. +//#include <linux/interrupt.h>
  7309. +//#include <linux/irq.h>
  7310. +
  7311. +#undef DEBUG
  7312. +#undef VERBOSE
  7313. +#undef DRVNAME //"ssp_lh7x"
  7314. +#include <linux/verbosedebug.h>
  7315. +
  7316. +#include <linux/version.h>
  7317. +#ifdef MODULE
  7318. +char kernel_version[] = UTS_RELEASE;
  7319. +#endif /* MODULE */
  7320. +
  7321. +#include <asm/irq.h>
  7322. +#include <asm/mach/irq.h>
  7323. +#include <asm/arch/irq.h>
  7324. +#include <asm/arch/iocon.h>
  7325. +#include <asm/arch/hardware.h>
  7326. +#include <asm/arch/gpio.h>
  7327. +//#include <asm/arch/cpld.h>
  7328. +#include <asm/arch/rcpc.h>
  7329. +#include <asm/arch/ssp_lh7x.h>
  7330. +#include "ssp.h"
  7331. +
  7332. +unsigned int hclkfreq_get( void);
  7333. +
  7334. +static gpioARegs_t *gpioa = (gpioARegs_t *)GPIO0_PHYS;
  7335. +static ioconRegs_t *iocon = (ioconRegs_t *)IOCON_PHYS;
  7336. +static rcpcRegs_t *rcpc = (rcpcRegs_t *)RCPC_PHYS;
  7337. +//static cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  7338. +static sspRegs_t *ssp = (sspRegs_t *)SSP_BASE;
  7339. +static vicRegs_t *vic = (vicRegs_t *)VIC_BASE;
  7340. +/*
  7341. +* hclk_freq:
  7342. +* The frequency of the clock that feeds the SSP clock prescaler in the RCPC
  7343. +* The frequency is in Hz
  7344. +*/
  7345. +static unsigned int hclk_freq = 0;
  7346. +
  7347. +/**********************************************************************
  7348. +* Additional RCPC defines
  7349. +**********************************************************************/
  7350. +#define rcpc_sspClkControl spareClkCtrl
  7351. +#define rcpc_sspClkPrescale spare1Prescale
  7352. +
  7353. +#define RCPC_LOCK 1
  7354. +#define RCPC_LOCKED RCPC_LOCK
  7355. +#define RCPC_UNLOCK 0
  7356. +#define RCPC_UNLOCKED RCPC_UNLOCK
  7357. +
  7358. +/**********************************************************************
  7359. +* Function: ssp_busy_wait
  7360. +*
  7361. +* Purpose:
  7362. +* Wait until the state of the SSP busy bit from the status register
  7363. +* indicates the SSP is no longer busy.
  7364. +*
  7365. +* Returns:
  7366. +* N/A
  7367. +**********************************************************************/
  7368. +static void ssp_busy_wait(void)
  7369. +{
  7370. + while ( ssp->sr & SSP_SR_BSY ) {
  7371. + barrier();
  7372. + }
  7373. + return;
  7374. +}
  7375. +
  7376. +/**********************************************************************
  7377. +* Function: ssp_flush_tx_fifo
  7378. +* Function: ssp_flush_rx_fifo
  7379. +*
  7380. +* Purpose:
  7381. +* Flush the transmit (tx) and receive (rx) fifo buffer
  7382. +*
  7383. +* Returns:
  7384. +* N/A
  7385. +**********************************************************************/
  7386. +static void ssp_flush_tx_fifo(sspContext_t *sspContext)
  7387. +{
  7388. + int i;
  7389. +
  7390. + for (i = sspContext->ts_txTimeout; ((i > 0) && (ssp->sr & SSP_SR_TFE)); i--)
  7391. + {
  7392. + barrier();
  7393. + }
  7394. + return;
  7395. +}
  7396. +
  7397. +static void ssp_flush_rx_fifo(sspContext_t *sspContext)
  7398. +{
  7399. + int i;
  7400. + unsigned int junk;
  7401. +
  7402. + for (i = sspContext->ts_rxTimeout; ((i > 0) && (ssp->sr & SSP_SR_RNE)); i--)
  7403. + {
  7404. + barrier();
  7405. + junk = ssp->dr;
  7406. + //printk("ssp_flush_rx_fifo(0x%04X)\n", junk);
  7407. + }
  7408. + return;
  7409. +}
  7410. +
  7411. +/**********************************************************************
  7412. +* Function: ssp_chipselect_enable
  7413. +* Function: ssp_chipselect_disable
  7414. +* Function: ssp_chipselect_manual
  7415. +* Function: ssp_chipselect_automatic
  7416. +*
  7417. +* Purpose:
  7418. +* Controls the chipselect pin associated with the SSP
  7419. +*
  7420. +* Returns:
  7421. +* N/A
  7422. +*
  7423. +**********************************************************************/
  7424. +static void ssp_chipselect_enable(void)
  7425. +{
  7426. + /* Make the SSPFRM signal (ChipSelect) high (enabled) */
  7427. + /* Note: This must have had ssp_chipselect_manual() called first */
  7428. + //printk("ssp_chipselect_enable()\n");
  7429. +#ifdef ORDERITE_REV4
  7430. + //FJBgpioa->dr &= ~(SSPFRM_GPIO_BIT); /* LOW == Enabled */
  7431. + gpioa->dr &= ~(SSPEN_GPIO_BIT); /* LOW == Enabled */
  7432. +#else
  7433. + gpioa->dr &= ~(SSPFRM_GPIO_BIT); /* LOW == Enabled */
  7434. +#endif
  7435. + return;
  7436. +}
  7437. +
  7438. +static void ssp_chipselect_disable(void)
  7439. +{
  7440. + /* Make the SSPFRM signal (ChipSelect) low (disabled) */
  7441. + /* Note: This must have had ssp_chipselect_manual() called first */
  7442. + //printk("ssp_chipselect_disable()\n");
  7443. +#ifdef ORDERITE_REV4
  7444. + //FJBgpioa->dr |= SSPFRM_GPIO_BIT; /* HIGH == Disabled */
  7445. + gpioa->dr |= SSPEN_GPIO_BIT; /* HIGH == Disabled */
  7446. +#else
  7447. + gpioa->dr |= SSPFRM_GPIO_BIT; /* HIGH == Disabled */
  7448. +#endif
  7449. + return;
  7450. +}
  7451. +
  7452. +static void ssp_chipselect_manual(void)
  7453. +{
  7454. + /* First, disable the ChipSelect */
  7455. + //JMG ssp_chipselect_disable();
  7456. + /* Set up muxing so that we manually control the ChipSelect pin */
  7457. + /* via GPIO port A bit 2 */
  7458. +#ifdef ORDERITE_REV4
  7459. + //FJBgpioa->ddr |= SSPFRM_GPIO_BIT; /* Make GPIO an output */
  7460. + gpioa->ddr |= SSPEN_GPIO_BIT; /* Make GPIO an output */
  7461. + //FJBiocon->SSIMux &= ~SSIMUX_SSPFRM;
  7462. + iocon->SSIMux &= ~SSIMUX_SSPENB;
  7463. +#else
  7464. + gpioa->ddr |= SSPFRM_GPIO_BIT; /* Make GPIO an output */
  7465. + iocon->SSIMux &= ~SSIMUX_SSPFRM;
  7466. +#endif
  7467. + ssp_chipselect_disable();
  7468. + return;
  7469. +}
  7470. +
  7471. +static void ssp_chipselect_automatic(void)
  7472. +{
  7473. + /* First, disable the ChipSelect */
  7474. + ssp_chipselect_disable();
  7475. +#ifdef ORDERITE_REV4
  7476. + /* Set up muxing so the SSP automatically controls the ChipSelect pin */
  7477. + //FJBiocon->SSIMux |= SSIMUX_SSPFRM;
  7478. + iocon->SSIMux |= SSIMUX_SSPENB;
  7479. +#else
  7480. + iocon->SSIMux |= SSIMUX_SSPFRM;
  7481. +#endif
  7482. + return;
  7483. +}
  7484. +
  7485. +/**********************************************************************
  7486. +* Function: rcpc_lh7x_locked
  7487. +*
  7488. +* Purpose:
  7489. +* Determine write access to the RCPC
  7490. +*
  7491. +* Returns:
  7492. +* The lock state of the RCPC
  7493. +*
  7494. +**********************************************************************/
  7495. +static int rcpc_lh7x_locked(void)
  7496. +{
  7497. + int lockState;
  7498. +
  7499. + vdprintk("ENTER: rcpc_lh7x_locked()\n");
  7500. + if (rcpc->control & RCPC_CTRL_WRTLOCK_ENABLED) {
  7501. + lockState = RCPC_LOCKED;
  7502. + } else {
  7503. + lockState = RCPC_UNLOCKED;
  7504. + }
  7505. + vdprintk("LEAVE: rcpc_lh7x_locked(%s)\n",
  7506. + (lockState==RCPC_LOCKED)?"Locked":"UnLocked");
  7507. +
  7508. + return(lockState);
  7509. +}
  7510. +
  7511. +/**********************************************************************
  7512. +* Function: rcpc_lh7x_lock
  7513. +*
  7514. +* Purpose:
  7515. +* Control write access to the RCPC
  7516. +*
  7517. +* Parameters:
  7518. +* action: RCPC_UNLOCK == can write to RCPC
  7519. +* RCPC_LOCK == cannot write to RCPC
  7520. +*
  7521. +* Returns:
  7522. +* The previous lock state of the RCPC
  7523. +*
  7524. +**********************************************************************/
  7525. +static int rcpc_lh7x_lock(int action)
  7526. +{
  7527. + int priorState;
  7528. +
  7529. + vdprintk("ENTER: rcpc_lh7x_lock(%s)\n",
  7530. + (action==RCPC_LOCK)?"Lock":"UnLock");
  7531. + priorState = rcpc_lh7x_locked();
  7532. + if (action == RCPC_UNLOCK) {
  7533. + rcpc->control |= RCPC_CTRL_WRTLOCK_ENABLED;
  7534. + } else /* (action == RCPC_LOCK) */ {
  7535. + rcpc->control &= ~RCPC_CTRL_WRTLOCK_ENABLED;
  7536. + }
  7537. + vdprintk("LEAVE: rcpc_lh7x_lock(%s)\n",
  7538. + (action==RCPC_LOCK)?"Lock":"UnLock");
  7539. +
  7540. + return(priorState);
  7541. +}
  7542. +
  7543. +#if OLDWAY
  7544. +/**********************************************************************
  7545. +* Function: ssp_lh7x_get_hclk_freq
  7546. +*
  7547. +* Purpose:
  7548. +* Get the HCLK (bus clock) frequency in Hz
  7549. +**********************************************************************/
  7550. +static unsigned int ssp_lh7x_get_hclk_freq(void)
  7551. +{
  7552. +#define XTAL_IN 14745600 /* 14.7456 MHz crystal */
  7553. +#define PLL_CLOCK (XTAL_IN * 21) /* 309 MHz PLL clock */
  7554. + int divider;
  7555. + unsigned int _hclk_freq;
  7556. +
  7557. + vdprintk("ENTER: ssp_lh7x_get_hclk_freq()\n");
  7558. + divider = rcpc->HCLKPrescale * 2; /* HCLK prescale value */
  7559. + if( divider == 0) /* No prescalar == divide by 1 */
  7560. + divider = 1;
  7561. + _hclk_freq = PLL_CLOCK / divider;
  7562. + vdprintk("LEAVE: ssp_lh7x_get_hclk_freq(%u)\n", _hclk_freq);
  7563. +
  7564. + return(_hclk_freq);
  7565. +}
  7566. +#endif
  7567. +
  7568. +
  7569. +/**********************************************************************
  7570. +* Function: ssp_lh7x_get_speed
  7571. +*
  7572. +* Purpose:
  7573. +* Get the SSP speed in bits per second
  7574. +**********************************************************************/
  7575. +static int ssp_lh7x_get_speed(void)
  7576. +{
  7577. + int bps;
  7578. + int rcpc_prescale;
  7579. + int ssp_prescale;
  7580. + int ssp_divider;
  7581. +
  7582. + vdprintk("ENTER: ssp_lh7x_get_speed()\n");
  7583. + rcpc_prescale = rcpc->rcpc_sspClkPrescale;
  7584. + if (rcpc_prescale == 0) rcpc_prescale = 1;
  7585. + else rcpc_prescale <<= 1;
  7586. + ssp_prescale = ssp->cpsr;
  7587. + ssp_divider = (ssp->cr0 & _SBF(8,_BITMASK(8) ) ) >> 8;
  7588. + bps = hclk_freq / (rcpc_prescale * (ssp_prescale) * (ssp_divider + 1) );
  7589. + vdprintk("LEAVE: ssp_lh7x_get_speed(%d bps)\n", bps);
  7590. +
  7591. + return(bps);
  7592. +}
  7593. +
  7594. +/**********************************************************************
  7595. +* Function: ssp_lh7x_set_speed
  7596. +*
  7597. +* Purpose:
  7598. +* Set the SSP speed in bits per second
  7599. +*
  7600. +* Processing:
  7601. +* If the requested_bits_per_second is negaitve, return 0
  7602. +* If the requested_bits_per_second is too fast, set the bit rate
  7603. +* as fast as possible.
  7604. +* If the requested_bits_per_second is too slow, set the bit rate as
  7605. +* slow as possible.
  7606. +* If the requested_bits_per_second is in range, set the RCPC
  7607. +* SSP clock prescaler register, SSP prescaler, and SSP divider
  7608. +* to obtain the clock as close as possible.
  7609. +*
  7610. +* Parameters:
  7611. +* bps: The desired bits per second
  7612. +*
  7613. +* Returns:
  7614. +* The actual bps obtained or 0 if the requested bps is not obtainable.
  7615. +*
  7616. +* Notes:
  7617. +* The mode (SPI/uWire/TI) must be set first for this function to work!
  7618. +*
  7619. +**********************************************************************/
  7620. +static int ssp_lh7x_set_speed(int bps)
  7621. +{
  7622. + int rcpcLockState;
  7623. + int32_t ssp_prescale;
  7624. + int32_t ssp_divider;
  7625. + int32_t rcpc_prescale;
  7626. + int32_t new_prescale;
  7627. + int32_t new_divider;
  7628. + int32_t quotient;
  7629. + int32_t delta1;
  7630. + int32_t delta2;
  7631. + int32_t min_error;
  7632. + int32_t new_error;
  7633. +# define MAX_SSP_FREQ (hclk_freq / SSP_PRESCALE_MIN)
  7634. +
  7635. + vdprintk("ENTER: ssp_lh7x_set_speed(%d bps)\n", bps);
  7636. +
  7637. + /* Ensure we are dealing with a legal BPS */
  7638. + if (bps <= 0) {
  7639. + printk("%s: requested ssp speed (%d bps) is to slow\n", DRVNAME, bps);
  7640. + printk("%s: making ssp speed as slow as possible\n", DRVNAME);
  7641. + /* The request bps is slower than the minimum possible */
  7642. + /* ... make it as slow as possible */
  7643. + /* Don't bother calculating the divider values as we know them */
  7644. + rcpc_prescale = RCPC_SSP_PRESCALE_MAX;
  7645. + ssp_prescale = SSP_PRESCALE_MAX;
  7646. + ssp_divider = SSP_DIVIDER_MAX;
  7647. + } else if (bps >= MAX_SSP_FREQ) {
  7648. + printk("%s: requested ssp speed (%d bps) is to fast\n", DRVNAME, bps);
  7649. + printk("%s: making ssp speed as fast as possible\n", DRVNAME);
  7650. + /* Don't bother calculating the divider values as we know them */
  7651. + bps = MAX_SSP_FREQ;
  7652. + ssp_prescale = SSP_PRESCALE_MIN;
  7653. + ssp_divider = 1;
  7654. + rcpc_prescale = 1;
  7655. + } else {
  7656. + /* Calculate the divider values as close as we can */
  7657. + quotient = hclk_freq / bps;
  7658. + if (quotient <= 0)
  7659. + quotient = 1;
  7660. + /* round the quotient */
  7661. + delta1 = bps - (hclk_freq / quotient );
  7662. + if (delta1 < 0)
  7663. + delta1 = -delta1;
  7664. + delta2 = bps - (hclk_freq / (quotient + 1));
  7665. + if (delta2 < 0)
  7666. + delta2 = -delta2;
  7667. + if (delta1 > delta2)
  7668. + quotient++;
  7669. + if (quotient >=
  7670. + (SSP_PRESCALE_MAX * RCPC_SSP_PRESCALE_MAX * SSP_DIVIDER_MAX))
  7671. + {
  7672. + printk("%s: requested ssp speed (%d bps) is to slow\n",
  7673. + DRVNAME, bps);
  7674. + printk("%s: making ssp speed as slow as possible\n", DRVNAME);
  7675. + /* The request bps is slower than the minimum possible */
  7676. + /* ... make it as slow as possible */
  7677. + /* Don't bother calculating the divider values as we know them */
  7678. + rcpc_prescale = RCPC_SSP_PRESCALE_MAX;
  7679. + ssp_prescale = SSP_PRESCALE_MAX;
  7680. + ssp_divider = SSP_DIVIDER_MAX;
  7681. + } else {
  7682. + /*
  7683. + * The computed quotient is in range.
  7684. + * Quotient is the target clock divide frequency.
  7685. + * Get as close as possible.
  7686. + */
  7687. + rcpc_prescale = 1;
  7688. + /*
  7689. + * Try to reduce power by using RCPC prescaler.
  7690. + * Note that the ssp prescaler minimum is two
  7691. + * so can only prescale and maintain accuracy
  7692. + * if quotient is divisible by 4.
  7693. + */
  7694. + while ( ((quotient & 0x3) == 0)
  7695. + && (rcpc_prescale < RCPC_SSP_PRESCALE_MAX) )
  7696. + {
  7697. + quotient >>= 1;
  7698. + rcpc_prescale <<= 1;
  7699. + }
  7700. + /*
  7701. + * Make sure the requested frequency is within range
  7702. + * of the SPP's prescaler and divider.
  7703. + * Hopefully, this loop never executes.
  7704. + * If it does, accuracy suffers.
  7705. + */
  7706. + while (quotient > (SSP_PRESCALE_MAX * SSP_DIVIDER_MAX) ) {
  7707. + rcpc_prescale <<= 1;
  7708. + quotient >>= 1;
  7709. + }
  7710. + /*
  7711. + * Factor the quotient into the divider and prescaler combo
  7712. + * that minimizes the error in the quotient by exhaustively
  7713. + * searching all legal ssp prescaler values.
  7714. + */
  7715. + ssp_prescale = SSP_PRESCALE_MIN;
  7716. + ssp_divider = (quotient / ssp_prescale);
  7717. + ssp_divider = (ssp_divider > SSP_DIVIDER_MAX)
  7718. + ? SSP_DIVIDER_MAX : ssp_divider;
  7719. + min_error = quotient - (ssp_divider * ssp_prescale);
  7720. + min_error = (min_error < 0) ? -min_error : min_error;
  7721. + for (new_prescale = SSP_PRESCALE_MIN + 2;
  7722. + new_prescale < SSP_PRESCALE_MAX;
  7723. + new_prescale += 2)
  7724. + {
  7725. + new_divider = (quotient / new_prescale);
  7726. + new_divider = (new_divider > SSP_DIVIDER_MAX)
  7727. + ? SSP_DIVIDER_MAX : new_divider;
  7728. + new_error = quotient - (new_divider * new_prescale);
  7729. + new_error = (new_error < 0) ? -new_error : new_error;
  7730. + if (new_error < min_error) {
  7731. + min_error = new_error;
  7732. + ssp_prescale = new_prescale;
  7733. + ssp_divider = new_divider;
  7734. + }
  7735. + }
  7736. + }
  7737. + }
  7738. + /* Set up the necessary registers to get the desired BSP */
  7739. + rcpcLockState = rcpc_lh7x_lock(RCPC_UNLOCK);
  7740. + rcpc->rcpc_sspClkPrescale = rcpc_prescale >> 1;
  7741. + (void) rcpc_lh7x_lock(rcpcLockState);
  7742. + ssp->cpsr = ssp_prescale;
  7743. + ssp->cr0 &= 0xff; /* clear old divider value */
  7744. + ssp->cr0 |= SSP_CR0_SCR(ssp_divider - 1);
  7745. +
  7746. + vdprintk("LEAVE: ssp_lh7x_set_speed(%d bps)\n", bps);
  7747. +
  7748. + return(ssp_lh7x_get_speed());
  7749. +}
  7750. +
  7751. +/**********************************************************************
  7752. +* Function: ssp_lh7x_write16
  7753. +*
  7754. +* Purpose:
  7755. +* Write the LH7x SSP data register
  7756. +**********************************************************************/
  7757. +static void ssp_lh7x_write16(sspContext_t *sspContext,
  7758. + unsigned int data)
  7759. +{
  7760. + int i;
  7761. +
  7762. + //if (sspContext->ssp_dev_sel == SSP_EEPROM) { //JMG
  7763. + //printk("ENTER: ssp_lh7x_write16(0x%04X)\n", (uint16_t)data);
  7764. + //}
  7765. + for (i=sspContext->ts_txTimeout; ((i>0) && ((ssp->sr&SSP_SR_TNF) == 0)); i--) {
  7766. + barrier();
  7767. + }
  7768. + if (ssp->sr & SSP_SR_TNF) {
  7769. + ssp->dr = (uint16_t)data;
  7770. + } else {
  7771. + printk("%s: write timout\n", DRVNAME);
  7772. + }
  7773. + //vdprintk("LEAVE: ssp_lh7x_write16(0x%04X)\n", (uint16_t)data);
  7774. + return;
  7775. +}
  7776. +
  7777. +/**********************************************************************
  7778. +* Function: ssp_lh7x_read16
  7779. +*
  7780. +* Purpose:
  7781. +* Read the LH7x SSP data register
  7782. +**********************************************************************/
  7783. +static unsigned int ssp_lh7x_read16(sspContext_t *sspContext)
  7784. +{
  7785. + int i;
  7786. + unsigned int data = -1;
  7787. +
  7788. + //vdprintk("ENTER: ssp_lh7x_read16()\n");
  7789. + for (i=sspContext->ts_txTimeout; ((i>0) && ((ssp->sr&SSP_SR_RNE) == 0)); i--) {
  7790. + barrier();
  7791. + }
  7792. + if (ssp->sr & SSP_SR_RNE) {
  7793. + if (sspContext->ssp_dev_sel == SSP_EEPROM) {
  7794. + data = (unsigned int)ssp->dr; /* EEPROM */
  7795. + //printk("LEAVE: ssp_lh7x_read16(ee: 0x%04X)\n", data);
  7796. + } else {
  7797. + data = (((unsigned int)ssp->dr) >> 4) & 0x0FFF; /* TOUCHSCREEN */
  7798. + //printk("LEAVE: ssp_lh7x_read16(ts: 0x%04X)\n", data);
  7799. + }
  7800. + } else {
  7801. + //printk("%s: read timout\n", DRVNAME);
  7802. + }
  7803. +
  7804. + return(data);
  7805. +}
  7806. +
  7807. +/**********************************************************************
  7808. +* Macro: ssp_lh7x_ts_pen_down
  7809. +**********************************************************************/
  7810. +static int ssp_lh7x_ts_pen_down(sspContext_t *sspContext)
  7811. +{
  7812. +
  7813. + //int pen_down = vic->IRQStatus & 0x01; //look for IRQ0
  7814. + int pen_down = vic->RawIntr & 0x01; //look for IRQ0
  7815. + dprintk("ssp_lh7x_ts_pen_down(%d)\n", pen_down);
  7816. + return (pen_down);
  7817. +}
  7818. +
  7819. +/**********************************************************************
  7820. +* Macro: ssp_lh7x_ts_pen_down_irq_enable
  7821. +**********************************************************************/
  7822. +static int ssp_lh7x_ts_pen_down_irq_enable(sspContext_t *sspContext)
  7823. +{
  7824. + int lastState = vic->IntEnable & 1;
  7825. + dprintk("ssp_lh7x_ts_pen_down_irq_enable\n");
  7826. + //vic->IntEnable = 1;
  7827. + enable_irq(0);
  7828. + sspContext->irq_state = 1;
  7829. + return(lastState);
  7830. +}
  7831. +
  7832. +/**********************************************************************
  7833. +* Macro: ssp_lh7x_ts_pen_down_irq_disable
  7834. +**********************************************************************/
  7835. +static int ssp_lh7x_ts_pen_down_irq_disable(
  7836. + sspContext_t *sspContext)
  7837. +{
  7838. + int lastState = vic->IntEnable & 1;
  7839. + dprintk("ssp_lh7x_ts_pen_down_irq_disable\n");
  7840. + //vic->IntEnClear = 1;
  7841. + disable_irq(0);
  7842. + sspContext->irq_state = 0;
  7843. + return(lastState);
  7844. +}
  7845. +
  7846. +/**********************************************************************
  7847. +* Function: ssp_lh7x_ts_pen_down_irq
  7848. +*
  7849. +* We only detect touch screen _touches_ (pen down) with this interrupt
  7850. +* handler, and even then we just schedule our task.
  7851. +*
  7852. +* Note: It has already been determined that this is our interrupt
  7853. +* before we ever get it here so checking is minimal to non-existant.
  7854. +**********************************************************************/
  7855. +static void ssp_lh7x_ts_pen_down_irq(int irq, sspContext_t *sspContext,
  7856. + struct pt_regs * regs)
  7857. +{
  7858. + /*
  7859. + * Disable the touchscreen interrupts
  7860. + * by disabling the touchscreen IRQ
  7861. + * --- AND ---
  7862. + * Enable regular polling of the touchscreen device
  7863. + * (The touchscreen IRQ will be re-enabled and polling
  7864. + * will be disabled when it is detected that the
  7865. + * pen is no longer down.)
  7866. + */
  7867. + /* Disable touch screen IRQ */
  7868. + dprintk("ENTER: ssp_lh7x_ts_pen_down_irq()\n");
  7869. + ssp_lh7x_ts_pen_down_irq_disable(sspContext);
  7870. + dprintk("ENTER: wake_up()\n");
  7871. + wake_up(sspContext->irq_wait_ptr);
  7872. + vdprintk("LEAVE: ssp_lh7x_ts_pen_down_irq()\n");
  7873. + return;
  7874. +}
  7875. +
  7876. +/**********************************************************************
  7877. +* Function: ssp_lh7x_irq_handler
  7878. +*
  7879. +* This interrupt handler only directs traffic for the interrupts
  7880. +* by forwarding on the call to the appropriate interrupt handler.
  7881. +**********************************************************************/
  7882. +static void ssp_lh7x_irq_handler(int irq, void *_sspContext,
  7883. + struct pt_regs * regs)
  7884. +{
  7885. + sspContext_t *sspContext = _sspContext;
  7886. + if ((sspContext) && (sspContext->irq_wait_ptr)) {
  7887. + //if (ssp_lh7x_ts_pen_down(sspContext)) {
  7888. + if (1) {
  7889. + ssp_lh7x_ts_pen_down_irq(irq, sspContext, regs);
  7890. + }
  7891. +#if defined(VERBOSE) && defined(DEBUG)
  7892. + else {
  7893. + vdprintk("ssp_lh7x_irq_handler() --- Not our interrupt\n");
  7894. + }
  7895. +#endif
  7896. + }
  7897. +#if defined(VERBOSE) && defined(DEBUG)
  7898. + else {
  7899. + vdprintk("ssp_lh7x_irq_handler( NO ACTION )\n");
  7900. + }
  7901. +#endif
  7902. + return;
  7903. +}
  7904. +
  7905. +/**********************************************************************
  7906. +* Function: ssp_lh7x_lock
  7907. +* Function: ssp_lh7x_unlock
  7908. +*
  7909. +* Purpose:
  7910. +* Lock/UnLock the SSP for a particular device (ts/ee)
  7911. +**********************************************************************/
  7912. +static int ssp_lh7x_lock(sspContext_t *sspContext, int device)
  7913. +{
  7914. + int sts = -1;
  7915. + int cr0;
  7916. +
  7917. + spin_lock_irq(&sspContext->sspLock);
  7918. + if (device == SSP_DEV_TOUCHSCREEN) {
  7919. + /* Select the touchscreen */
  7920. + sspContext->ssp_dev_sel = SSP_TOUCHSCREEN;
  7921. + cr0 = ssp->cr0;
  7922. + cr0 &= ~0x00F0;
  7923. + /* National Microwire frame format --- SPI Polarity High */
  7924. + /* Don't mess with data size or clock rate */
  7925. + cr0 |= (SSP_CR0_FRF_NS | SSP_CR0_SPH);
  7926. + ssp->cr0 = cr0;
  7927. + vdprintk("ssp_lh7x_lock(SSP_DEV_TOUCHSCREEN)\n");
  7928. + // sts = 0;
  7929. + } else if (device == SSP_DEV_EEPROM) {
  7930. + /* Select the eeprom */
  7931. + sspContext->ssp_dev_sel = SSP_EEPROM;
  7932. + cr0 = ssp->cr0;
  7933. + cr0 &= ~0x00F0;
  7934. + /* Motorola SPI frame --- w/SPH & w/SPO */
  7935. + /* Don't mess with data size or clock rate */
  7936. + cr0 |= (SSP_CR0_FRF_MOT | SSP_CR0_SPH | SSP_CR0_SPO);
  7937. + ssp->cr0 = cr0;
  7938. + vdprintk("ssp_lh7x_lock(SSP_DEV_EEPROM)\n");
  7939. + // sts = 0;
  7940. + }
  7941. + //cpld->ssp_dev_sel = sspContext->ssp_dev_sel;
  7942. +
  7943. + return(sts);
  7944. +}
  7945. +
  7946. +static int ssp_lh7x_unlock(sspContext_t *sspContext, int device)
  7947. +{
  7948. + int sts = -1;
  7949. +// #define SSP_DEFAULT_DEVICE SSP_TOUCHSCREEN
  7950. +#define SSP_DEFAULT_DEVICE SSP_INVALID_DEVICE
  7951. +
  7952. + spin_unlock_irq(&sspContext->sspLock);
  7953. + if (device == SSP_DEV_TOUCHSCREEN) {
  7954. + /* Select the default device */
  7955. + sspContext->ssp_dev_sel = SSP_DEFAULT_DEVICE;
  7956. + vdprintk("ssp_lh7x_unlock(SSP_DEV_TOUCHSCREEN)\n");
  7957. + // sts = 0;
  7958. + } else if (device == SSP_DEV_EEPROM) {
  7959. + /* Select the default device */
  7960. + sspContext->ssp_dev_sel = SSP_DEFAULT_DEVICE;
  7961. + vdprintk("ssp_lh7x_unlock(SSP_DEV_EEPROM)\n");
  7962. + // sts = 0;
  7963. + }
  7964. + //cpld->ssp_dev_sel = sspContext->ssp_dev_sel;
  7965. +
  7966. + return(sts);
  7967. +}
  7968. +
  7969. +/**********************************************************************
  7970. +* Function: ssp_lh7x_disable
  7971. +*
  7972. +* Purpose:
  7973. +* Disconnect I/O pins from the SSP module
  7974. +* and disable the SSP peripheral and its clocks.
  7975. +**********************************************************************/
  7976. +static void ssp_lh7x_disable(void)
  7977. +{
  7978. + int rcpcLockState;
  7979. +
  7980. + vdprintk("ENTER: ssp_lh7x_disable()\n");
  7981. +
  7982. + /* Switch all muxed I/O away from the SSP */
  7983. + iocon->SSIMux &= ~(
  7984. + SSIMUX_SSPIN |
  7985. + SSIMUX_SSPOUT |
  7986. + SSIMUX_SSPCLK |
  7987. + SSIMUX_SSPENB |
  7988. + SSIMUX_SSPFRM
  7989. + );
  7990. +
  7991. + /* Disable ssp clock */
  7992. + rcpcLockState = rcpc_lh7x_lock(RCPC_UNLOCK);
  7993. + rcpc->rcpc_sspClkControl |= RCPC_SCLKSEL_SSPCLK;
  7994. + (void) rcpc_lh7x_lock(rcpcLockState);
  7995. +
  7996. + /* Set control register to their reset defaults */
  7997. + ssp->cr0 = 0;
  7998. + ssp->cr1 = 0;
  7999. +
  8000. + /* clear any receive overruns */
  8001. + ssp->u.icr = SSP_IIR_RORIS;
  8002. +
  8003. + //JMG /* disable the ssp DMA streams */
  8004. + //JMG dmac->stream0.max = 0;
  8005. + //JMG dmac->stream0.ctrl = 0;
  8006. + //JMG dmac->stream1.max = 0;
  8007. + //JMG dmac->stream1.ctrl = 0;
  8008. + //JMG /* clear any previous SSP DMA completions */
  8009. + //JMG dmac->clear = DMAC_EOT0 | DMAC_EOT1;
  8010. +
  8011. + vdprintk("LEAVE: ssp_lh7x_disable()\n");
  8012. +
  8013. + return;
  8014. +}
  8015. +
  8016. +/**********************************************************************
  8017. +* Function: ssp_lh7x_enable
  8018. +*
  8019. +* Purpose:
  8020. +* Disconnect I/O pins from the SSP module
  8021. +* and disable the SSP peripheral and its clocks.
  8022. +**********************************************************************/
  8023. +static void ssp_lh7x_enable(void)
  8024. +{
  8025. +
  8026. + vdprintk("ENTER: ssp_lh7x_enable()\n");
  8027. +
  8028. + /* Enable the SSP */
  8029. + ssp->cr1 |= SSP_CR1_SSE; /* Synchronous serial port enable */
  8030. +
  8031. + /* Switch all muxed I/O to the SSP */
  8032. + /* Note that SSPENB is not required for spi */
  8033. + iocon->SSIMux = (
  8034. + SSIMUX_SSPIN |
  8035. + SSIMUX_SSPOUT |
  8036. + SSIMUX_SSPCLK |
  8037. + //SSIMUX_SSPENB |
  8038. + SSIMUX_SSPFRM
  8039. + );
  8040. +
  8041. +
  8042. + vdprintk("LEAVE: ssp_lh7x_enable()\n");
  8043. +
  8044. + return;
  8045. +}
  8046. +
  8047. +/**********************************************************************
  8048. +* Fill in our context structures
  8049. +**********************************************************************/
  8050. +
  8051. +static sspContext_t sspContext_l = {
  8052. + ts_txTimeout: 10000,
  8053. + ts_rxTimeout: 10000,
  8054. + ee_txTimeout: 10000,
  8055. + ee_rxTimeout: 10000,
  8056. + haveIrq: 0,
  8057. +};
  8058. +
  8059. +/**********************************************************************
  8060. +* Function: ssp_request_pointer
  8061. +* Function: ssp_provide_pointer
  8062. +*
  8063. +* Purpose:
  8064. +* Register & Initialize the module
  8065. +**********************************************************************/
  8066. +void *ssp_request_pointer(int device, char *request)
  8067. +{
  8068. + sspContext_t *sspContext = &sspContext_l;
  8069. + void *vp = NULL;
  8070. +
  8071. + dprintk("ENTER: ssp_request_pointer(\"%d\":\"%s\")\n", device, request);
  8072. + if (device == SSP_DEV_TOUCHSCREEN) {
  8073. + if (strcmp(request, "write") == 0) {
  8074. + vp = ssp_lh7x_write16;
  8075. + } else if (strcmp(request, "read") == 0) {
  8076. + vp = ssp_lh7x_read16;
  8077. + } else if (strcmp(request, "enable_pen_down_irq") == 0) {
  8078. + vp = ssp_lh7x_ts_pen_down_irq_enable;
  8079. + } else if (strcmp(request, "disable_pen_down_irq") == 0) {
  8080. + vp = ssp_lh7x_ts_pen_down_irq_disable;
  8081. + } else if (strcmp(request, "is_pen_down") == 0) {
  8082. + vp = ssp_lh7x_ts_pen_down;
  8083. + } else if (strcmp(request, "lock") == 0) {
  8084. + vp = ssp_lh7x_lock;
  8085. + } else if (strcmp(request, "unlock") == 0) {
  8086. + vp = ssp_lh7x_unlock;
  8087. + } else if (strcmp(request, "sspContext") == 0) {
  8088. + vp = sspContext;
  8089. + } else if (strcmp(request, "flush_tx_fifo") == 0) {
  8090. + vp = ssp_flush_tx_fifo;
  8091. + } else if (strcmp(request, "flush_rx_fifo") == 0) {
  8092. + vp = ssp_flush_rx_fifo;
  8093. + } else if (strcmp(request, "ssp_busy_wait") == 0) {
  8094. + vp = ssp_busy_wait;
  8095. + } else if (strcmp(request, "chipselect_enable") == 0) {
  8096. + vp = ssp_chipselect_enable;
  8097. + } else if (strcmp(request, "chipselect_disable") == 0) {
  8098. + vp = ssp_chipselect_disable;
  8099. + } else if (strcmp(request, "chipselect_manual") == 0) {
  8100. + vp = ssp_chipselect_manual;
  8101. + }
  8102. + } else if (device == SSP_DEV_EEPROM) {
  8103. + if (strcmp(request, "write") == 0) {
  8104. + vp = ssp_lh7x_write16;
  8105. + } else if (strcmp(request, "read") == 0) {
  8106. + vp = ssp_lh7x_read16;
  8107. + } else if (strcmp(request, "lock") == 0) {
  8108. + vp = ssp_lh7x_lock;
  8109. + } else if (strcmp(request, "unlock") == 0) {
  8110. + vp = ssp_lh7x_unlock;
  8111. + } else if (strcmp(request, "sspContext") == 0) {
  8112. + vp = sspContext;
  8113. + } else if (strcmp(request, "chipselect_enable") == 0) {
  8114. + vp = ssp_chipselect_enable;
  8115. + } else if (strcmp(request, "chipselect_disable") == 0) {
  8116. + vp = ssp_chipselect_disable;
  8117. + } else if (strcmp(request, "chipselect_manual") == 0) {
  8118. + vp = ssp_chipselect_manual;
  8119. + } else if (strcmp(request, "chipselect_automatic") == 0) {
  8120. + vp = ssp_chipselect_automatic;
  8121. + } else if (strcmp(request, "flush_tx_fifo") == 0) {
  8122. + vp = ssp_flush_tx_fifo;
  8123. + } else if (strcmp(request, "flush_rx_fifo") == 0) {
  8124. + vp = ssp_flush_rx_fifo;
  8125. + } else if (strcmp(request, "ssp_busy_wait") == 0) {
  8126. + vp = ssp_busy_wait;
  8127. + }
  8128. + }
  8129. + dprintk("LEAVE: ssp_request_pointer(0x%08X)\n", (unsigned int)vp);
  8130. +
  8131. + return(vp);
  8132. +}
  8133. +
  8134. +void *ssp_provide_pointer(int device, char *request, void *vp)
  8135. +{
  8136. + sspContext_t *sspContext = &sspContext_l;
  8137. +
  8138. + dprintk("ENTER: ssp_provide_pointer(\"%d\":\"%s\":0x%08X)\n",
  8139. + device, request, (unsigned int)vp);
  8140. + if (device == SSP_DEV_TOUCHSCREEN) {
  8141. + if (strcmp(request, "irq_wait_ptr") == 0) {
  8142. + sspContext->irq_wait_ptr = vp;
  8143. + } else {
  8144. + vp = NULL;
  8145. + }
  8146. + } else if (device == SSP_DEV_EEPROM) {
  8147. + vp = NULL;
  8148. + } else {
  8149. + vp = NULL;
  8150. + }
  8151. + dprintk("LEAVE: ssp_provide_pointer(0x%08X)\n", (unsigned int)vp);
  8152. +
  8153. + return(vp);
  8154. +}
  8155. +
  8156. +/**********************************************************************
  8157. +* Function: ssp_lh7x_init
  8158. +*
  8159. +* Purpose:
  8160. +* Register & Initialize the module
  8161. +**********************************************************************/
  8162. +static int __init ssp_lh7x_init(void)
  8163. +{
  8164. + sspContext_t *sspContext = &sspContext_l;
  8165. + int sts = 0;
  8166. + int rcpcLockState;
  8167. + int result;
  8168. +
  8169. + vdprintk("ENTER: ssp_lh7x_init()\n");
  8170. +
  8171. + vdprintk("ssp = 0x%08X\n", (unsigned int)ssp);
  8172. +
  8173. + /* Determine the HCLK (bus clock) frequency in Hz */
  8174. +#ifdef OLDWAY
  8175. + hclk_freq = ssp_lh7x_get_hclk_freq();
  8176. +#else
  8177. + hclk_freq = hclkfreq_get();
  8178. +#endif
  8179. +
  8180. + /*
  8181. + * Disconnect I/O pins from the SSP module
  8182. + * and disable the SSP peripheral and its clocks.
  8183. + */
  8184. + ssp_lh7x_disable();
  8185. +
  8186. + /* Initialize the RCPC SSP clock & prescaler */
  8187. + rcpcLockState = rcpc_lh7x_lock(RCPC_UNLOCK);
  8188. + rcpc->rcpc_sspClkPrescale = 0; /* As fast as possible */
  8189. + rcpc->rcpc_sspClkControl &= ~RCPC_SCLKSEL_SSPCLK; /* Enable SSP clock */
  8190. + (void) rcpc_lh7x_lock(rcpcLockState);
  8191. +
  8192. + ssp->cpsr = SSP_CPSR_CPDVSR(SSP_PRESCALE_MIN);
  8193. +
  8194. + /* Initialize CR0 */
  8195. + ssp->cr0 = (
  8196. + SSP_CR0_DSS(16) /* 16-bit data */
  8197. + | SSP_CR0_FRF_NS /* National Microwire frame format */
  8198. + | SSP_CR0_SPH /* SPI Polarity */
  8199. + | SSP_CR0_SCR(1) /* Serial clock rate (~922kbps) */
  8200. + );
  8201. +
  8202. + /* Initialize CR1 */
  8203. + ssp->cr1 = (
  8204. + SSP_CR1_SSE /* Synchronous serial port enable */
  8205. + );
  8206. +
  8207. + /* Set the SSP speed in bits per second */
  8208. + /* Note this MUST be done after the SSP_CR0_FRF_xxx mode is set */
  8209. + (void) ssp_lh7x_set_speed(LH7x_TS_BPS);
  8210. +
  8211. + /* Select the touchscreen */
  8212. + sspContext->ssp_dev_sel = SSP_TOUCHSCREEN;
  8213. + //cpld->ssp_dev_sel = sspContext->ssp_dev_sel;
  8214. +
  8215. + /* Flush the transmit FIFO */
  8216. + ssp_flush_tx_fifo(sspContext);
  8217. +
  8218. + /* Flush the receive FIFO */
  8219. + ssp_flush_rx_fifo(sspContext);
  8220. +
  8221. + /* clear any receive overruns */
  8222. + ssp->u.icr = SSP_IIR_RORIS;
  8223. +
  8224. + //printk("ssp->cr0 = 0x%04X\n", ssp->cr0);
  8225. + //printk("ssp->cr1 = 0x%04X\n", ssp->cr1);
  8226. + //printk("ssp->sr = 0x%04X\n", ssp->sr);
  8227. + //printk("ssp->cpsr = 0x%04X\n", ssp->cpsr);
  8228. + //printk("ssp->u.icr | u.iir = 0x%04X\n", ssp->u.icr);
  8229. +
  8230. + ssp_chipselect_automatic();
  8231. + /*
  8232. + * Connect I/O pins from the SSP module
  8233. + * and enable the SSP peripheral and its clocks.
  8234. + */
  8235. + ssp_lh7x_enable();
  8236. +
  8237. + /*
  8238. + * Request IRQ2 and attach it to the touchscreen pen_down line and enable it
  8239. + */
  8240. + sspContext->haveIrq = 0;
  8241. + result = request_irq(0, ssp_lh7x_irq_handler,
  8242. + SA_SAMPLE_RANDOM, DRVNAME, sspContext);
  8243. + if (result < 0) {
  8244. + printk("%s: cannot get requested IRQ(0)\n", DRVNAME);
  8245. + } else {
  8246. + sspContext->haveIrq = 1;
  8247. + dprintk("%s: got requested IRQ(0)\n", DRVNAME);
  8248. + }
  8249. + ssp_lh7x_ts_pen_down_irq_enable(sspContext);
  8250. +
  8251. + vdprintk("LEAVE: ssp_lh7x_init()\n");
  8252. + return(sts);
  8253. +}
  8254. +
  8255. +/**********************************************************************
  8256. +* Function: ssp_lh7x_exit
  8257. +*
  8258. +* Purpose:
  8259. +* Un-Register & Cleanup the module
  8260. +**********************************************************************/
  8261. +static void ssp_lh7x_exit(void)
  8262. +{
  8263. + sspContext_t *sspContext = &sspContext_l;
  8264. + int rcpcLockState;
  8265. +
  8266. + vdprintk("ENTER: ssp_lh7x_exit()\n");
  8267. +
  8268. + //printk("ssp->cr0 = 0x%04X\n", ssp->cr0);
  8269. + //printk("ssp->cr1 = 0x%04X\n", ssp->cr1);
  8270. + //printk("ssp->sr = 0x%04X\n", ssp->sr);
  8271. + //printk("ssp->cpsr = 0x%04X\n", ssp->cpsr);
  8272. + //printk("ssp->u.icr | u.iir = 0x%04X\n", ssp->u.icr);
  8273. +
  8274. + /*
  8275. + * Disable & Return IRQ 2
  8276. + */
  8277. + lock_kernel();
  8278. + ssp_lh7x_ts_pen_down_irq_disable(sspContext);
  8279. + if (sspContext->haveIrq) {
  8280. + free_irq(0, sspContext);
  8281. + sspContext->haveIrq = 0;
  8282. + }
  8283. + unlock_kernel();
  8284. +
  8285. + ssp->cr0 = 0;
  8286. + ssp->cr1 = 0;
  8287. + ssp->u.icr = SSP_IIR_RORIS; /* clear any receive overruns */
  8288. + ssp->cpsr = SSP_CPSR_CPDVSR(SSP_PRESCALE_MIN);
  8289. +
  8290. + /* Turn off the RCPC SSP clock */
  8291. + rcpcLockState = rcpc_lh7x_lock(RCPC_UNLOCK);
  8292. + rcpc->rcpc_sspClkControl |= RCPC_SCLKSEL_SSPCLK; /* Disable SSP clock */
  8293. + (void) rcpc_lh7x_lock(rcpcLockState);
  8294. +
  8295. + vdprintk("LEAVE: ssp_lh7x_exit()\n");
  8296. + return;
  8297. +}
  8298. +
  8299. +module_init(ssp_lh7x_init);
  8300. +module_exit(ssp_lh7x_exit);
  8301. +
  8302. +MODULE_AUTHOR("Jim Gleason / Lineo, Inc.");
  8303. +MODULE_DESCRIPTION("SSP Driver for Sharp LH7x EVB");
  8304. +MODULE_LICENSE("Copyright (c) 2002 Lineo, Inc.");
  8305. +
  8306. diff -urN linux-2.4.26/drivers/serial/amba_pl011.c linux-2.4.26-vrs1-lnode80/drivers/serial/amba_pl011.c
  8307. --- linux-2.4.26/drivers/serial/amba_pl011.c 1969-12-31 20:00:00.000000000 -0400
  8308. +++ linux-2.4.26-vrs1-lnode80/drivers/serial/amba_pl011.c 2005-11-02 17:37:32.000000000 -0400
  8309. @@ -0,0 +1,854 @@
  8310. +/*
  8311. + * linux/drivers/char/serial_amba_pl011.c
  8312. + *
  8313. + * Driver for AMBA PrimeCell PL011 serial ports
  8314. + * Copyright (C) 2002 Lineo, Inc.
  8315. + *
  8316. + * Based on drivers/char/serial_amba.c, which is:
  8317. + * Copyright 1999 ARM Limited
  8318. + * Copyright (C) 2000 Deep Blue Solutions Ltd.
  8319. + *
  8320. + * This program is free software; you can redistribute it and/or modify
  8321. + * it under the terms of the GNU General Public License as published by
  8322. + * the Free Software Foundation; either version 2 of the License, or
  8323. + * (at your option) any later version.
  8324. + *
  8325. + * This program is distributed in the hope that it will be useful,
  8326. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8327. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8328. + * GNU General Public License for more details.
  8329. + *
  8330. + * You should have received a copy of the GNU General Public License
  8331. + * along with this program; if not, write to the Free Software
  8332. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  8333. + *
  8334. + */
  8335. +#include <linux/config.h>
  8336. +#include <linux/module.h>
  8337. +#include <linux/tty.h>
  8338. +#include <linux/ioport.h>
  8339. +#include <linux/init.h>
  8340. +#include <linux/sched.h>
  8341. +#include <linux/serial.h>
  8342. +#include <linux/console.h>
  8343. +#include <linux/sysrq.h>
  8344. +
  8345. +#include <asm/io.h>
  8346. +#include <asm/irq.h>
  8347. +
  8348. +#if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
  8349. +#define SUPPORT_SYSRQ
  8350. +#endif
  8351. +
  8352. +#include <linux/serial_core.h>
  8353. +
  8354. +#include <asm/hardware/serial_amba_pl011.h>
  8355. +
  8356. +#ifdef CONFIG_ARCH_LH79520
  8357. +#include <asm/arch/rcpc.h>
  8358. +#include <asm/arch/iocon.h>
  8359. +#include <asm/arch/gpio.h>
  8360. +#endif
  8361. +
  8362. +#define UART_NR 3
  8363. +
  8364. +#define SERIAL_AMBA_MAJOR 204
  8365. +#define SERIAL_AMBA_MINOR 16
  8366. +#define SERIAL_AMBA_NR UART_NR
  8367. +
  8368. +#define CALLOUT_AMBA_NAME "cuaam"
  8369. +#define CALLOUT_AMBA_MAJOR 205
  8370. +#define CALLOUT_AMBA_MINOR 16
  8371. +#define CALLOUT_AMBA_NR UART_NR
  8372. +
  8373. +static struct tty_driver normal, callout;
  8374. +static struct tty_struct *amba11_table[UART_NR];
  8375. +static struct termios *amba11_termios[UART_NR], *amba11_termios_locked[UART_NR];
  8376. +#ifdef SUPPORT_SYSRQ
  8377. +static struct console amba11_console;
  8378. +#endif
  8379. +static void amba11uart_tx_chars(struct uart_port *port);
  8380. +
  8381. +#define AMBA_ISR_PASS_LIMIT 256
  8382. +
  8383. +/*
  8384. + * Access macros for the AMBA UARTs
  8385. + */
  8386. +#define UART_PUT_ICR(p, c) writel((c), (p)->membase + AMBA_UARTICR)
  8387. +#define UART_GET_CHAR(p) readb((p)->membase + AMBA_UARTDR)
  8388. +#define UART_PUT_CHAR(p, c) writel((c), (p)->membase + AMBA_UARTDR)
  8389. +#define UART_GET_RSR(p) readb((p)->membase + AMBA_UARTRSR)
  8390. +#define UART_GET_LCRH(p) readb((p)->membase + AMBA_UARTLCR_H)
  8391. +#define UART_PUT_LCRH(p,c) writel((c), (p)->membase + AMBA_UARTLCR_H)
  8392. +
  8393. +#define UART_RX_DATA(s) (((s) & AMBA_UARTFR_RXFE) == 0)
  8394. +#define UART_TX_READY(s) (((s) & AMBA_UARTFR_TXFF) == 0)
  8395. +#define UART_TX_EMPTY(p) ((UART_GET_FR(p) & AMBA_UARTFR_TMSK) == 0)
  8396. +
  8397. +#define UART_GET_INT_STATUS(p) readw((p)->membase + AMBA_UARTMIS)
  8398. +#define UART_GET_FR(p) readw((p)->membase + AMBA_UARTFR)
  8399. +#define UART_GET_CR(p) readl((p)->membase + AMBA_UARTCR)
  8400. +#define UART_PUT_CR(p,c) writel((c), (p)->membase + AMBA_UARTCR)
  8401. +#define UART_GET_IMSC(p) readl((p)->membase + AMBA_UARTIMSC)
  8402. +#define UART_PUT_IMSC(p,c) writel((c), (p)->membase + AMBA_UARTIMSC)
  8403. +#define UART_GET_IBRD(p) readl((p)->membase + AMBA_UARTIBRD)
  8404. +#define UART_PUT_IBRD(p,c) writel((c), (p)->membase + AMBA_UARTIBRD)
  8405. +
  8406. +
  8407. +#define UART_DUMMY_RSR_RX 256
  8408. +#define UART_PORT_SIZE 64
  8409. +
  8410. +/*
  8411. + * Our private driver data mappings.
  8412. + */
  8413. +#define drv_old_status driver_priv
  8414. +
  8415. +struct uart_amba11_port {
  8416. + struct uart_port port;
  8417. + unsigned int old_status;
  8418. +};
  8419. +
  8420. +static void amba11uart_stop_tx(struct uart_port *port, unsigned int tty_stop)
  8421. +{
  8422. + unsigned int mask;
  8423. +
  8424. + mask = UART_GET_IMSC( port);
  8425. + mask &= ~AMBA_UARTIMSC_TXIM;
  8426. + UART_PUT_IMSC( port, mask); /* disable Tx interrupts */
  8427. +}
  8428. +
  8429. +
  8430. +static void amba11uart_start_tx(struct uart_port *port, unsigned int tty_start)
  8431. +{
  8432. + unsigned int mask;
  8433. +
  8434. + mask = UART_GET_IMSC(port);
  8435. + if( (mask & AMBA_UARTIMSC_TXIM) == 0) { /* not already enabled */
  8436. + mask |= AMBA_UARTIMSC_TXIM; /* enable Tx interrupts */
  8437. + UART_PUT_IMSC(port, mask);
  8438. +
  8439. + amba11uart_tx_chars(port); /* start transmiting */
  8440. + }
  8441. +
  8442. +}
  8443. +
  8444. +
  8445. +static void amba11uart_stop_rx(struct uart_port *port)
  8446. +{
  8447. + unsigned int mask;
  8448. +
  8449. + mask = UART_GET_IMSC(port);
  8450. + mask &= ~(AMBA_UARTIMSC_RXIM | AMBA_UARTIMSC_RTIM);
  8451. + UART_PUT_IMSC(port, mask); /* disable Rx interrupts */
  8452. +}
  8453. +
  8454. +
  8455. +static void amba11uart_enable_ms(struct uart_port *port)
  8456. +{
  8457. + unsigned int mask;
  8458. +
  8459. + mask = UART_GET_IMSC( port);
  8460. + mask |= AMBA_UARTIMSC_Modem;
  8461. + UART_PUT_IMSC(port, mask); /* Disable modem interrupts */
  8462. +}
  8463. +
  8464. +static void
  8465. +#ifdef SUPPORT_SYSRQ
  8466. +amba11uart_rx_chars(struct uart_port *port, struct pt_regs *regs)
  8467. +#else
  8468. +amba11uart_rx_chars(struct uart_port *port)
  8469. +#endif
  8470. +{
  8471. + struct tty_struct *tty = port->info->tty;
  8472. + unsigned int status, ch, rsr, max_count = 256;
  8473. +
  8474. + status = UART_GET_FR(port);
  8475. + while (UART_RX_DATA(status) && max_count--) {
  8476. + if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
  8477. + tty->flip.tqueue.routine((void *)tty);
  8478. + if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
  8479. + printk(KERN_WARNING "TTY_DONT_FLIP set\n");
  8480. + return;
  8481. + }
  8482. + }
  8483. +
  8484. + ch = UART_GET_CHAR(port);
  8485. +
  8486. + *tty->flip.char_buf_ptr = ch;
  8487. + *tty->flip.flag_buf_ptr = TTY_NORMAL;
  8488. + port->icount.rx++;
  8489. +
  8490. + /*
  8491. + * Note that the error handling code is
  8492. + * out of the main execution path
  8493. + */
  8494. + rsr = UART_GET_RSR(port) | UART_DUMMY_RSR_RX;
  8495. + if (rsr & AMBA_UARTRSR_ANY) {
  8496. + if (rsr & AMBA_UARTRSR_BE) {
  8497. + rsr &= ~(AMBA_UARTRSR_FE | AMBA_UARTRSR_PE);
  8498. + port->icount.brk++;
  8499. + if (uart_handle_sysrq_char(port, ch, regs))
  8500. + goto ignore_char;
  8501. + } else if (rsr & AMBA_UARTRSR_PE)
  8502. + port->icount.parity++;
  8503. + else if (rsr & AMBA_UARTRSR_FE)
  8504. + port->icount.frame++;
  8505. + if (rsr & AMBA_UARTRSR_OE)
  8506. + port->icount.overrun++;
  8507. +
  8508. + rsr &= port->read_status_mask;
  8509. +
  8510. + if (rsr & AMBA_UARTRSR_BE)
  8511. + *tty->flip.flag_buf_ptr = TTY_BREAK;
  8512. + else if (rsr & AMBA_UARTRSR_PE)
  8513. + *tty->flip.flag_buf_ptr = TTY_PARITY;
  8514. + else if (rsr & AMBA_UARTRSR_FE)
  8515. + *tty->flip.flag_buf_ptr = TTY_FRAME;
  8516. + }
  8517. +
  8518. + if (uart_handle_sysrq_char(port, ch, regs))
  8519. + goto ignore_char;
  8520. +
  8521. + if ((rsr & port->ignore_status_mask) == 0) {
  8522. + tty->flip.flag_buf_ptr++;
  8523. + tty->flip.char_buf_ptr++;
  8524. + tty->flip.count++;
  8525. + }
  8526. + if ((rsr & AMBA_UARTRSR_OE) &&
  8527. + tty->flip.count < TTY_FLIPBUF_SIZE) {
  8528. + /*
  8529. + * Overrun is special, since it's reported
  8530. + * immediately, and doesn't affect the current
  8531. + * character
  8532. + */
  8533. + *tty->flip.char_buf_ptr++ = 0;
  8534. + *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
  8535. + tty->flip.count++;
  8536. + }
  8537. + ignore_char:
  8538. + status = UART_GET_FR(port);
  8539. + }
  8540. + tty_flip_buffer_push(tty);
  8541. + return;
  8542. +}
  8543. +
  8544. +static void amba11uart_tx_chars(struct uart_port *port)
  8545. +{
  8546. + struct circ_buf *xmit = &port->info->xmit;
  8547. + int count;
  8548. + int status;
  8549. +
  8550. + if (port->x_char) {
  8551. + UART_PUT_CHAR(port, port->x_char);
  8552. + port->icount.tx++;
  8553. + port->x_char = 0;
  8554. + return;
  8555. + }
  8556. + if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
  8557. + amba11uart_stop_tx(port, 0);
  8558. + return;
  8559. + }
  8560. +
  8561. + count = port->fifosize >> 1;
  8562. + do {
  8563. + UART_PUT_CHAR(port, xmit->buf[xmit->tail]);
  8564. + xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  8565. + port->icount.tx++;
  8566. + if (uart_circ_empty(xmit))
  8567. + break;
  8568. + status = UART_GET_FR(port);
  8569. + } while (UART_TX_READY(status));
  8570. + //FJBwhile (--count > 0);
  8571. +
  8572. + if (uart_circ_chars_pending(xmit) <
  8573. + WAKEUP_CHARS)
  8574. + uart_write_wakeup(port);
  8575. +
  8576. + if (uart_circ_empty(xmit))
  8577. + amba11uart_stop_tx(port, 0);
  8578. +}
  8579. +
  8580. +static void amba11uart_modem_status(struct uart_port *port)
  8581. +{
  8582. + struct uart_amba11_port *uap = (struct uart_amba11_port *) port;
  8583. + unsigned int status, delta;
  8584. +
  8585. + UART_PUT_ICR(&uap->port, 0x3ff);
  8586. +
  8587. + status = UART_GET_FR(&uap->port) & AMBA_UARTFR_MODEM_ANY;
  8588. + //FJB - check CTS on modem port only (port 1)
  8589. + if(port == (struct uart_port *)UART1_PHYS)
  8590. + {
  8591. + if(GPIOG->dr & 0x01)
  8592. + {
  8593. + //CTS is high meaning STOP SENDING
  8594. + status |= AMBA_UARTFR_CTS;
  8595. + }
  8596. + }
  8597. +
  8598. + delta = status ^ uap->old_status;
  8599. + uap->old_status = status;
  8600. +
  8601. + if (!delta)
  8602. + return;
  8603. +
  8604. + if (delta & AMBA_UARTFR_DCD)
  8605. + uart_handle_dcd_change(&uap->port, (status & AMBA_UARTFR_DCD) == 0);
  8606. +
  8607. + if ((delta & AMBA_UARTFR_DSR) == 0)
  8608. + uap->port.icount.dsr++;
  8609. +
  8610. + if (delta & AMBA_UARTFR_CTS)
  8611. + uart_handle_cts_change(&uap->port, (status & AMBA_UARTFR_CTS) == 0);
  8612. +
  8613. + wake_up_interruptible(&uap->port.info->delta_msr_wait);
  8614. +}
  8615. +
  8616. +static void amba11uart_int(int irq, void *dev_id, struct pt_regs *regs)
  8617. +{
  8618. + struct uart_port *port = dev_id;
  8619. + unsigned int status, pass_counter = AMBA_ISR_PASS_LIMIT;
  8620. +
  8621. + status = UART_GET_INT_STATUS(port);
  8622. + do {
  8623. + if (status & (AMBA_UART_IS_RT | AMBA_UART_IS_RX))
  8624. +
  8625. +#ifdef SUPPORT_SYSRQ
  8626. + amba11uart_rx_chars(port, regs);
  8627. +#else
  8628. + amba11uart_rx_chars(port);
  8629. +#endif
  8630. +
  8631. + if (status & AMBA_UART_IS_TX)
  8632. + amba11uart_tx_chars(port);
  8633. +
  8634. +
  8635. + if (status & AMBA_UART_IS_MI)
  8636. + amba11uart_modem_status(port);
  8637. +
  8638. + if (pass_counter-- == 0)
  8639. + break;
  8640. +
  8641. + status = UART_GET_INT_STATUS(port);
  8642. + } while (status & (AMBA_UART_IS_RT | AMBA_UART_IS_RX |
  8643. + AMBA_UART_IS_TX));
  8644. +}
  8645. +
  8646. +static unsigned int amba11uart_tx_empty(struct uart_port *port)
  8647. +{
  8648. + return UART_GET_FR(port) & AMBA_UARTFR_BUSY ? 0 : TIOCSER_TEMT;
  8649. +}
  8650. +
  8651. +static unsigned int amba11uart_get_mctrl(struct uart_port *port)
  8652. +{
  8653. + unsigned int result = 0;
  8654. + unsigned int status;
  8655. +
  8656. + status = UART_GET_FR(port);
  8657. + if ((status & AMBA_UARTFR_DCD) == 0)
  8658. + result |= TIOCM_CAR;
  8659. + if ((status & AMBA_UARTFR_DSR) == 0)
  8660. + result |= TIOCM_DSR;
  8661. + if ((status & AMBA_UARTFR_CTS) == 0)
  8662. + result |= TIOCM_CTS;
  8663. +
  8664. + return result;
  8665. +}
  8666. +
  8667. +static void amba11uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
  8668. +{
  8669. + u_int cr;
  8670. +
  8671. + cr = UART_GET_CR( port);
  8672. +
  8673. + if (mctrl & TIOCM_RTS)
  8674. + cr &= ~AMBA_UARTCR_RTS;
  8675. + else
  8676. + cr |= AMBA_UARTCR_RTS;
  8677. +
  8678. + if (mctrl & TIOCM_DTR)
  8679. + cr &= ~AMBA_UARTCR_DTR;
  8680. + else
  8681. + cr |= AMBA_UARTCR_DTR;
  8682. +
  8683. + UART_PUT_CR( port, cr);
  8684. +}
  8685. +
  8686. +
  8687. +static void amba11uart_break_ctl(struct uart_port *port, int break_state)
  8688. +{
  8689. + unsigned int lcr_h;
  8690. + unsigned long flags;
  8691. +
  8692. + spin_lock_irqsave(&port->lock, flags);
  8693. + lcr_h = UART_GET_LCRH(port);
  8694. + if (break_state == -1)
  8695. + lcr_h |= AMBA_UARTLCR_H_BRK;
  8696. + else
  8697. + lcr_h &= ~AMBA_UARTLCR_H_BRK;
  8698. + UART_PUT_LCRH(port, lcr_h);
  8699. + spin_unlock_irqrestore(&port->lock, flags);
  8700. +}
  8701. +
  8702. +static int amba11uart_startup(struct uart_port *port)
  8703. +{
  8704. + int retval;
  8705. + struct uart_amba11_port *uap = (struct uart_amba11_port *)port;
  8706. +
  8707. + /*
  8708. + * Allocate the IRQ
  8709. + */
  8710. + retval = request_irq(port->irq, amba11uart_int, 0, "amba", port);
  8711. + if (retval)
  8712. + return retval;
  8713. +
  8714. + /*
  8715. + * initialise the old status of the modem signals
  8716. + */
  8717. + uap->old_status = UART_GET_FR(port) & AMBA_UARTFR_MODEM_ANY;
  8718. +
  8719. + /*
  8720. + * Finally, enable interrupts
  8721. + */
  8722. +#ifdef CONFIG_ARCH_LH79520
  8723. + {
  8724. + /*
  8725. + * enable the clock to the serial ports
  8726. + */
  8727. + rcpcRegs_t *rcpc = (rcpcRegs_t *)IO_ADDRESS( RCPC_PHYS);
  8728. + ioconRegs_t *iocon = (ioconRegs_t *)IO_ADDRESS( IOCON_PHYS);
  8729. +
  8730. + rcpc->control |= RCPC_CTRL_WRTLOCK_ENABLED; /* unlock RCPC registers */
  8731. + barrier();
  8732. +
  8733. + rcpc->periphClkCtrl &= ~(RCPC_CLKCTRL_U0_DISABLE | RCPC_CLKCTRL_U1_DISABLE | RCPC_CLKCTRL_U2_DISABLE) ;
  8734. + rcpc->control &= ~RCPC_CTRL_WRTLOCK_ENABLED; /* lock RCPC registers */
  8735. +
  8736. + /* set multiplexed pins for UART0 use */
  8737. + iocon->UARTMux |= (UARTMUX_UT0TXD | UARTMUX_UT0RXD);
  8738. + }
  8739. +#endif /* CONFIG_ARCH_LH79520 */
  8740. +
  8741. + /*
  8742. + * Use iobase to store a pointer to info. We need this to start a
  8743. + * transmission as the tranmittr interrupt is only generated on
  8744. + * the transition to the idle state
  8745. + */
  8746. +
  8747. + UART_PUT_IMSC( port, (AMBA_UARTIMSC_RXIM | AMBA_UARTIMSC_RTIM) );
  8748. + UART_PUT_CR( port, (AMBA_UARTCR_UARTEN | AMBA_UARTCR_RXE | AMBA_UARTCR_TXE));
  8749. +
  8750. + return 0;
  8751. +}
  8752. +
  8753. +static void amba11uart_shutdown(struct uart_port *port)
  8754. +{
  8755. + /*
  8756. + * Free the interrupt
  8757. + */
  8758. + free_irq(port->irq, port);
  8759. +
  8760. + /*
  8761. + * disable all interrupts, disable the port
  8762. + */
  8763. + UART_PUT_CR(port, 0);
  8764. +
  8765. + /* disable break condition and fifos */
  8766. + UART_PUT_LCRH(port, UART_GET_LCRH(port) &
  8767. + ~(AMBA_UARTLCR_H_BRK | AMBA_UARTLCR_H_FEN));
  8768. +}
  8769. +
  8770. +static void amba11uart_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot)
  8771. +{
  8772. + unsigned int lcr_h, old_cr;
  8773. + unsigned long flags;
  8774. + unsigned long old_imsc;
  8775. +
  8776. +#if DEBUG
  8777. + printk("amba11uart_set_cflag(0x%x) called\n", cflag);
  8778. +#endif
  8779. + /* byte size and parity */
  8780. + switch (cflag & CSIZE) {
  8781. + case CS5: lcr_h = AMBA_UARTLCR_H_WLEN_5; break;
  8782. + case CS6: lcr_h = AMBA_UARTLCR_H_WLEN_6; break;
  8783. + case CS7: lcr_h = AMBA_UARTLCR_H_WLEN_7; break;
  8784. + default: lcr_h = AMBA_UARTLCR_H_WLEN_8; break; // CS8
  8785. + }
  8786. + if (cflag & CSTOPB)
  8787. + lcr_h |= AMBA_UARTLCR_H_STP2;
  8788. + if (cflag & PARENB) {
  8789. + lcr_h |= AMBA_UARTLCR_H_PEN;
  8790. + if (!(cflag & PARODD))
  8791. + lcr_h |= AMBA_UARTLCR_H_EPS;
  8792. + }
  8793. + if (port->fifosize > 1)
  8794. + lcr_h |= AMBA_UARTLCR_H_FEN;
  8795. +
  8796. + spin_lock_irqsave(&port->lock, flags);
  8797. +
  8798. + port->read_status_mask = AMBA_UARTRSR_OE;
  8799. + if (iflag & INPCK)
  8800. + port->read_status_mask |= AMBA_UARTRSR_FE | AMBA_UARTRSR_PE;
  8801. + if (iflag & (BRKINT | PARMRK))
  8802. + port->read_status_mask |= AMBA_UARTRSR_BE;
  8803. +
  8804. + /*
  8805. + * Characters to ignore
  8806. + */
  8807. + port->ignore_status_mask = 0;
  8808. + if (iflag & IGNPAR)
  8809. + port->ignore_status_mask |= AMBA_UARTRSR_FE | AMBA_UARTRSR_PE;
  8810. + if (iflag & IGNBRK) {
  8811. + port->ignore_status_mask |= AMBA_UARTRSR_BE;
  8812. + /*
  8813. + * If we're ignoring parity and break indicators,
  8814. + * ignore overruns too (for real raw support).
  8815. + */
  8816. + if (iflag & IGNPAR)
  8817. + port->ignore_status_mask |= AMBA_UARTRSR_OE;
  8818. + }
  8819. +
  8820. + /*
  8821. + * Ignore all characters if CREAD is not set.
  8822. + */
  8823. + if ((cflag & CREAD) == 0)
  8824. + port->ignore_status_mask |= UART_DUMMY_RSR_RX;
  8825. +
  8826. + old_cr = UART_GET_CR( port);
  8827. + old_imsc = UART_GET_IMSC( port) & ~AMBA_UARTIMSC_Modem;
  8828. +
  8829. + if (UART_ENABLE_MS(port, cflag))
  8830. + old_imsc |= AMBA_UARTIMSC_Modem;
  8831. +
  8832. + /* Set baud rate */
  8833. + UART_PUT_IBRD( port, quot);
  8834. +
  8835. + /*
  8836. + * ----------v----------v----------v----------v-----
  8837. + * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L
  8838. + * ----------^----------^----------^----------^-----
  8839. + */
  8840. + UART_PUT_LCRH(port, lcr_h);
  8841. + UART_PUT_IMSC( port, old_imsc);
  8842. + UART_PUT_CR(port, old_cr);
  8843. +
  8844. + spin_unlock_irqrestore(&port->lock, flags);
  8845. +}
  8846. +
  8847. +static const char *amba11uart_type(struct uart_port *port)
  8848. +{
  8849. + return port->type == PORT_AMBA_PL011 ? "AMBA PrimeCell PL011" : NULL;
  8850. +}
  8851. +
  8852. +/*
  8853. + * Release the memory region(s) being used by 'port'
  8854. + */
  8855. +static void amba11uart_release_port(struct uart_port *port)
  8856. +{
  8857. + release_mem_region(port->mapbase, UART_PORT_SIZE);
  8858. +}
  8859. +
  8860. +/*
  8861. + * Request the memory region(s) being used by 'port'
  8862. + */
  8863. +static int amba11uart_request_port(struct uart_port *port)
  8864. +{
  8865. + return request_mem_region(port->mapbase, UART_PORT_SIZE, "serial_amba")
  8866. + != NULL ? 0 : -EBUSY;
  8867. +}
  8868. +
  8869. +/*
  8870. + * Configure/autoconfigure the port.
  8871. + */
  8872. +static void amba11uart_config_port(struct uart_port *port, int flags)
  8873. +{
  8874. + if (flags & UART_CONFIG_TYPE) {
  8875. + port->type = PORT_AMBA_PL011;
  8876. + amba11uart_request_port(port);
  8877. + }
  8878. +}
  8879. +
  8880. +/*
  8881. + * verify the new serial_struct (for TIOCSSERIAL).
  8882. + */
  8883. +static int amba11uart_verify_port(struct uart_port *port, struct serial_struct *ser)
  8884. +{
  8885. + int ret = 0;
  8886. + if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA_PL011)
  8887. + ret = -EINVAL;
  8888. + if (ser->irq < 0 || ser->irq >= NR_IRQS)
  8889. + ret = -EINVAL;
  8890. + if (ser->baud_base < 9600)
  8891. + ret = -EINVAL;
  8892. + return ret;
  8893. +}
  8894. +
  8895. +static struct uart_ops amba11_pops = {
  8896. + tx_empty: amba11uart_tx_empty,
  8897. + set_mctrl: amba11uart_set_mctrl,
  8898. + get_mctrl: amba11uart_get_mctrl,
  8899. + stop_tx: amba11uart_stop_tx,
  8900. + start_tx: amba11uart_start_tx,
  8901. + stop_rx: amba11uart_stop_rx,
  8902. + enable_ms: amba11uart_enable_ms,
  8903. + break_ctl: amba11uart_break_ctl,
  8904. + startup: amba11uart_startup,
  8905. + shutdown: amba11uart_shutdown,
  8906. + change_speed: amba11uart_change_speed,
  8907. + type: amba11uart_type,
  8908. + release_port: amba11uart_release_port,
  8909. + request_port: amba11uart_request_port,
  8910. + config_port: amba11uart_config_port,
  8911. + verify_port: amba11uart_verify_port,
  8912. +};
  8913. +
  8914. +static struct uart_amba11_port amba11_ports[UART_NR] = {
  8915. + {
  8916. + .port = {
  8917. + .membase= (void *)IO_ADDRESS(UART0_PHYS), // VA
  8918. + .mapbase= UART0_PHYS,
  8919. + .iotype= SERIAL_IO_MEM,
  8920. + .irq= IRQ_UART0,
  8921. + .uartclk= 14745600,
  8922. + .fifosize= 16,
  8923. + .ops= &amba11_pops,
  8924. + .flags= ASYNC_BOOT_AUTOCONF,
  8925. + .line= 0,
  8926. + },
  8927. + },
  8928. + {
  8929. + .port = {
  8930. + .membase= (void *)IO_ADDRESS(UART1_PHYS),
  8931. + .mapbase= UART1_PHYS,
  8932. + .iotype= SERIAL_IO_MEM,
  8933. + .irq= IRQ_UART1,
  8934. + .uartclk= 14745600,
  8935. + .fifosize= 16,
  8936. + .ops= &amba11_pops,
  8937. + .flags= ASYNC_BOOT_AUTOCONF,
  8938. + .line= 1,
  8939. + },
  8940. + },
  8941. + {
  8942. + .port = {
  8943. + .membase= (void *)IO_ADDRESS(UART2_PHYS),
  8944. + .mapbase= UART2_PHYS,
  8945. + .iotype= SERIAL_IO_MEM,
  8946. + .irq= IRQ_UART2,
  8947. + .uartclk= 14745600,
  8948. + .fifosize= 16,
  8949. + .ops= &amba11_pops,
  8950. + .flags= ASYNC_BOOT_AUTOCONF,
  8951. + .line= 2,
  8952. + },
  8953. + },
  8954. +};
  8955. +
  8956. +
  8957. +#ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
  8958. +#ifdef used_and_not_const_char_pointer
  8959. +static int amba11uart_console_read(struct uart_port *port, char *s, u_int count)
  8960. +{
  8961. + unsigned int status;
  8962. + int c;
  8963. +#if DEBUG
  8964. + printk("amba11uart_console_read() called\n");
  8965. +#endif
  8966. +
  8967. + c = 0;
  8968. + while (c < count) {
  8969. + status = UART_GET_FR(port);
  8970. + if (UART_RX_DATA(status)) {
  8971. + *s++ = UART_GET_CHAR(port);
  8972. + c++;
  8973. + } else {
  8974. + // nothing more to get, return
  8975. + return c;
  8976. + }
  8977. + }
  8978. + // return the count
  8979. + return c;
  8980. +}
  8981. +#endif
  8982. +
  8983. +static void amba11uart_console_write(struct console *co, const char *s, u_int count)
  8984. +{
  8985. + struct uart_port *port = &amba11_ports[co->index].port;
  8986. + unsigned int status;
  8987. + int i;
  8988. +
  8989. + /*
  8990. + * First save the CR then disable the interrupts
  8991. + */
  8992. + unsigned int old_imsc;
  8993. + old_imsc = UART_GET_IMSC( port);
  8994. + UART_PUT_IMSC( port, 0);
  8995. +
  8996. + /*
  8997. + * Now, do each character
  8998. + */
  8999. + for (i = 0; i < count; i++) {
  9000. + do {
  9001. + status = UART_GET_FR(port);
  9002. + } while (!UART_TX_READY(status));
  9003. + UART_PUT_CHAR(port, s[i]);
  9004. + if (s[i] == '\n') {
  9005. + do {
  9006. + status = UART_GET_FR(port);
  9007. + } while (!UART_TX_READY(status));
  9008. + UART_PUT_CHAR(port, '\r');
  9009. + }
  9010. + }
  9011. +
  9012. + /*
  9013. + * Finally, wait for transmitter to become empty
  9014. + * and restore the TCR
  9015. + */
  9016. + do {
  9017. + status = UART_GET_FR(port);
  9018. + } while (status & AMBA_UARTFR_BUSY);
  9019. + UART_PUT_IMSC( port, old_imsc);
  9020. +}
  9021. +
  9022. +static kdev_t amba11uart_console_device(struct console *co)
  9023. +{
  9024. + return MKDEV(SERIAL_AMBA_MAJOR, SERIAL_AMBA_MINOR + co->index);
  9025. +}
  9026. +
  9027. +static int amba11uart_console_wait_key(struct console *co)
  9028. +{
  9029. + struct uart_port *port = &amba11_ports[co->index].port;
  9030. + unsigned int status;
  9031. +
  9032. + do {
  9033. + status = UART_GET_FR(port);
  9034. + } while (!UART_RX_DATA(status));
  9035. + return UART_GET_CHAR(port);
  9036. +}
  9037. +
  9038. +static void __init
  9039. +amba11uart_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
  9040. +{
  9041. + if (UART_GET_CR(port) & AMBA_UARTCR_UARTEN) {
  9042. + unsigned int lcr_h, quot;
  9043. + lcr_h = UART_GET_LCRH(port);
  9044. +
  9045. + *parity = 'n';
  9046. + if (lcr_h & AMBA_UARTLCR_H_PEN) {
  9047. + if (lcr_h & AMBA_UARTLCR_H_EPS)
  9048. + *parity = 'e';
  9049. + else
  9050. + *parity = 'o';
  9051. + }
  9052. +
  9053. + if ((lcr_h & 0x60) == AMBA_UARTLCR_H_WLEN_7)
  9054. + *bits = 7;
  9055. + else
  9056. + *bits = 8;
  9057. +
  9058. + quot = UART_GET_IBRD(port);
  9059. + *baud = port->uartclk / (16 * quot );
  9060. + }
  9061. +}
  9062. +
  9063. +static int __init amba11uart_console_setup(struct console *co, char *options)
  9064. +{
  9065. + struct uart_port *port;
  9066. + int baud = 38400;
  9067. + int bits = 8;
  9068. + int parity = 'n';
  9069. + int flow = 'n';
  9070. +
  9071. + /*
  9072. + * Check whether an invalid uart number has been specified, and
  9073. + * if so, search for the first available port that does have
  9074. + * console support.
  9075. + */
  9076. + if (co->index >= UART_NR)
  9077. + co->index = 0;
  9078. + port = &amba11_ports[co->index].port;
  9079. +
  9080. + if (options)
  9081. + uart_parse_options(options, &baud, &parity, &bits, &flow);
  9082. + else
  9083. + amba11uart_console_get_options(port, &baud, &parity, &bits);
  9084. +
  9085. + return uart_set_options(port, co, baud, parity, bits, flow);
  9086. +}
  9087. +
  9088. +static struct console amba11_console = {
  9089. + name: "ttyAM",
  9090. + write: amba11uart_console_write,
  9091. +#ifdef used_and_not_const_char_pointer
  9092. + read: amba11uart_console_read,
  9093. +#endif
  9094. + device: amba11uart_console_device,
  9095. + setup: amba11uart_console_setup,
  9096. + flags: CON_PRINTBUFFER,
  9097. + index: -1,
  9098. +};
  9099. +
  9100. +void __init amba11uart_console_init(void)
  9101. +{
  9102. + register_console(&amba11_console);
  9103. +}
  9104. +
  9105. +#define AMBA_CONSOLE &amba11_console
  9106. +#else
  9107. +#define AMBA_CONSOLE NULL
  9108. +#endif
  9109. +
  9110. +static struct uart_driver amba11_reg = {
  9111. + owner: THIS_MODULE,
  9112. + normal_major: SERIAL_AMBA_MAJOR,
  9113. +#ifdef CONFIG_DEVFS_FS
  9114. + normal_name: "ttyAM%d",
  9115. + callout_name: "cuaam%d",
  9116. +#else
  9117. + normal_name: "ttyAM",
  9118. + callout_name: "cuaam",
  9119. +#endif
  9120. + normal_driver: &normal,
  9121. + callout_major: CALLOUT_AMBA_MAJOR,
  9122. + callout_driver: &callout,
  9123. + table: amba11_table,
  9124. + termios: amba11_termios,
  9125. + termios_locked: amba11_termios_locked,
  9126. + minor: SERIAL_AMBA_MINOR,
  9127. + nr: UART_NR,
  9128. + cons: AMBA_CONSOLE,
  9129. +};
  9130. +
  9131. +static int __init amba11uart_init(void)
  9132. +{
  9133. + int ret;
  9134. +
  9135. + ret = uart_register_driver(&amba11_reg);
  9136. + if (ret == 0) {
  9137. + int i;
  9138. +
  9139. + for (i = 0; i < UART_NR; i++)
  9140. + uart_add_one_port(&amba11_reg, &amba11_ports[i].port);
  9141. + }
  9142. + return ret;
  9143. +};
  9144. +
  9145. +static void __exit amba11uart_exit(void)
  9146. +{
  9147. + int i;
  9148. +
  9149. + for (i = 0; i < UART_NR; i++)
  9150. + uart_remove_one_port(&amba11_reg, &amba11_ports[i].port);
  9151. +
  9152. + uart_unregister_driver(&amba11_reg);
  9153. +};
  9154. +
  9155. +module_init(amba11uart_init);
  9156. +module_exit(amba11uart_exit);
  9157. +
  9158. +EXPORT_NO_SYMBOLS;
  9159. +
  9160. +MODULE_AUTHOR("Lineo, Inc.");
  9161. +MODULE_DESCRIPTION("ARM AMBA PrimeCell PL011 serial port driver");
  9162. +MODULE_LICENSE("GPL");
  9163. +
  9164. diff -urN linux-2.4.26/drivers/serial/Config.in linux-2.4.26-vrs1-lnode80/drivers/serial/Config.in
  9165. --- linux-2.4.26/drivers/serial/Config.in 2005-11-02 16:54:25.000000000 -0400
  9166. +++ linux-2.4.26-vrs1-lnode80/drivers/serial/Config.in 2005-11-02 17:37:31.000000000 -0400
  9167. @@ -20,6 +20,22 @@
  9168. define_bool CONFIG_SERIAL_INTEGRATOR y
  9169. fi
  9170. + dep_tristate 'ARM PL011 PrimeCell serial port support' CONFIG_SERIAL_AMBA_PL011 $CONFIG_ARCH_LH79520
  9171. +
  9172. + if [ "$CONFIG_SERIAL_AMBA" = "y" ]; then
  9173. + bool ' Support for console on AMBA serial port' CONFIG_SERIAL_AMBA_CONSOLE
  9174. + fi
  9175. +
  9176. + if [ "$CONFIG_SERIAL_AMBA_PL011" = "y" ]; then
  9177. + bool ' Support for console on ARM PrimeCell PL011 serial port' CONFIG_SERIAL_AMBA_PL011_CONSOLE
  9178. + fi
  9179. +
  9180. + dep_tristate 'Sharp LH7A400 serial port support' CONFIG_SERIAL_LH7A400 $CONFIG_ARCH_LH7A400
  9181. +
  9182. + if [ "$CONFIG_SERIAL_LH7A400" = "y" ]; then
  9183. + bool ' Support for console on LH7A400 serial port' CONFIG_SERIAL_LH7A400_CONSOLE
  9184. + fi
  9185. +
  9186. dep_tristate 'CLPS711X serial port support' CONFIG_SERIAL_CLPS711X $CONFIG_ARCH_CLPS711X
  9187. dep_bool ' Support for console on CLPS711X serial port' CONFIG_SERIAL_CLPS711X_CONSOLE $CONFIG_SERIAL_CLPS711X
  9188. @@ -57,6 +73,8 @@
  9189. dep_bool ' Support Bell Technologies HUB6 card' CONFIG_SERIAL_8250_HUB6 $CONFIG_SERIAL_8250_EXTENDED
  9190. if [ "$CONFIG_SERIAL_AMBA" = "y" -o \
  9191. + "$CONFIG_SERIAL_AMBA_PL011" = "y" -o \
  9192. + "$CONFIG_SERIAL_LH7A400" = "y" -o \
  9193. "$CONFIG_SERIAL_CLPS711X" = "y" -o \
  9194. "$CONFIG_SERIAL_SA1100" = "y" -o \
  9195. "$CONFIG_SERIAL_ANAKIN" = "y" -o \
  9196. @@ -67,6 +85,8 @@
  9197. define_bool CONFIG_SERIAL_CORE y
  9198. else
  9199. if [ "$CONFIG_SERIAL_AMBA" = "m" -o \
  9200. + "$CONFIG_SERIAL_AMBA_PL011" = "m" -o \
  9201. + "$CONFIG_SERIAL_LH7A400" = "m" -o \
  9202. "$CONFIG_SERIAL_CLPS711X" = "m" -o \
  9203. "$CONFIG_SERIAL_SA1100" = "m" -o \
  9204. "$CONFIG_SERIAL_ANAKIN" = "m" -o \
  9205. @@ -78,6 +98,8 @@
  9206. fi
  9207. fi
  9208. if [ "$CONFIG_SERIAL_AMBA_CONSOLE" = "y" -o \
  9209. + "$CONFIG_SERIAL_AMBA_PL011_CONSOLE" = "y" -o \
  9210. + "$CONFIG_SERIAL_LH7A400_CONSOLE" = "y" -o \
  9211. "$CONFIG_SERIAL_CLPS711X_CONSOLE" = "y" -o \
  9212. "$CONFIG_SERIAL_SA1100_CONSOLE" = "y" -o \
  9213. "$CONFIG_SERIAL_ANAKIN_CONSOLE" = "y" -o \
  9214. diff -urN linux-2.4.26/drivers/serial/core.c linux-2.4.26-vrs1-lnode80/drivers/serial/core.c
  9215. --- linux-2.4.26/drivers/serial/core.c 2005-11-02 16:54:25.000000000 -0400
  9216. +++ linux-2.4.26-vrs1-lnode80/drivers/serial/core.c 2005-11-02 17:37:32.000000000 -0400
  9217. @@ -1938,6 +1938,7 @@
  9218. }
  9219. extern void ambauart_console_init(void);
  9220. +extern void amba11uart_console_init(void);
  9221. extern void anakin_console_init(void);
  9222. extern void clps711xuart_console_init(void);
  9223. extern void sa1100_rs_console_init(void);
  9224. @@ -1970,6 +1971,12 @@
  9225. #ifdef CONFIG_SERIAL_UART00_CONSOLE
  9226. uart00_console_init();
  9227. #endif
  9228. +#ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
  9229. + amba11uart_console_init();
  9230. +#endif
  9231. +#ifdef CONFIG_SERIAL_LH7A400_CONSOLE
  9232. + lh7a400uart_console_init();
  9233. +#endif
  9234. }
  9235. #endif /* CONFIG_SERIAL_CORE_CONSOLE */
  9236. diff -urN linux-2.4.26/drivers/serial/Makefile linux-2.4.26-vrs1-lnode80/drivers/serial/Makefile
  9237. --- linux-2.4.26/drivers/serial/Makefile 2005-11-02 16:54:25.000000000 -0400
  9238. +++ linux-2.4.26-vrs1-lnode80/drivers/serial/Makefile 2005-11-02 17:37:31.000000000 -0400
  9239. @@ -27,6 +27,8 @@
  9240. obj-$(CONFIG_SERIAL_8250) += 8250.o $(serial-8250-y)
  9241. obj-$(CONFIG_SERIAL_ANAKIN) += anakin.o
  9242. obj-$(CONFIG_SERIAL_AMBA) += amba.o
  9243. +obj-$(CONFIG_SERIAL_AMBA_PL011) += amba_pl011.o
  9244. +obj-$(CONFIG_SERIAL_LH7A400) += serial_lh7a400.o
  9245. obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
  9246. obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
  9247. obj-$(CONFIG_SERIAL_UART00) += uart00.o
  9248. diff -urN linux-2.4.26/drivers/video/Config.in linux-2.4.26-vrs1-lnode80/drivers/video/Config.in
  9249. --- linux-2.4.26/drivers/video/Config.in 2005-11-02 16:54:25.000000000 -0400
  9250. +++ linux-2.4.26-vrs1-lnode80/drivers/video/Config.in 2005-11-02 17:37:32.000000000 -0400
  9251. @@ -40,6 +40,11 @@
  9252. dep_bool ' CLPS711X LCD support' CONFIG_FB_CLPS711X $CONFIG_ARCH_CLPS711X
  9253. dep_bool ' SA-1100 LCD support' CONFIG_FB_SA1100 $CONFIG_ARCH_SA1100
  9254. dep_bool ' MX1ADS LCD support' CONFIG_FB_DBMX1 $CONFIG_ARCH_MX1ADS
  9255. + if [ "$CONFIG_ARCH_LH79520" = "y" -o \
  9256. + "$CONFIG_ARCH_LH7A400" = "y" ];then
  9257. + bool ' ARM PL110 LCD support' CONFIG_FB_PL110
  9258. + fi
  9259. +
  9260. if [ "$CONFIG_FB_SA1100" = "y" -a "$CONFIG_SA1100_CERF" = "y" ]; then
  9261. choice 'CerfBoard LCD Display Size' \
  9262. "3.8_Color CONFIG_CERF_LCD_38_A \
  9263. @@ -50,6 +55,15 @@
  9264. if [ "$CONFIG_FB_SA1100" = "y" -a "$CONFIG_SA1100_CERF_CPLD" = "y" ]; then
  9265. bool 'Cerfboard Backlight (CerfPDA)' CONFIG_SA1100_CERF_LCD_BACKLIGHT
  9266. fi
  9267. + if [ "$CONFIG_FB_PL110" = "y" ]; then
  9268. + choice 'LCD Display panel' \
  9269. + "Panasonic CONFIG_PL110_PAN78 \
  9270. + Sharp_LQ039Q2DS53-HR-TFT CONFIG_PL110_LQ39 \
  9271. + Sharp_LM057QCTT03-QVGA-STN CONFIG_PL110_LM57 \
  9272. + Sharp_LQ057Q3DC02-VGA/QVGA-TFT CONFIG_PL110_LQ57 \
  9273. + Sharp_LQ121S1DG31-800x600-TFT CONFIG_PL110_LQ121 \
  9274. + Sharp_LQ104V1DG11-640x480-TFT CONFIG_PL110_LQ104" Sharp_LQ039Q2DS53-HR-TFT
  9275. + fi
  9276. fi
  9277. dep_tristate ' CyberPro 2000/2010/5000 support' CONFIG_FB_CYBER2000 $CONFIG_PCI
  9278. if [ "$CONFIG_APOLLO" = "y" ]; then
  9279. @@ -280,7 +294,8 @@
  9280. "$CONFIG_FB_MAC" = "y" -o "$CONFIG_FB_RETINAZ3" = "y" -o \
  9281. "$CONFIG_FB_VIRGE" = "y" -o "$CONFIG_FB_VIRTUAL" = "y" -o \
  9282. "$CONFIG_FB_BWTWO" = "y" -o "$CONFIG_FB_CLGEN" = "y" -o \
  9283. - "$CONFIG_FB_TX3912" = "y" -o "$CONFIG_FB_CLPS711X" = "y" ]; then
  9284. + "$CONFIG_FB_TX3912" = "y" -o "$CONFIG_FB_CLPS711X" = "y" -o \
  9285. + "$CONFIG_FB_PL110" = "y" ]; then
  9286. define_tristate CONFIG_FBCON_MFB y
  9287. else
  9288. if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_AMIGA" = "m" -o \
  9289. @@ -288,20 +303,22 @@
  9290. "$CONFIG_FB_MAC" = "m" -o "$CONFIG_FB_RETINAZ3" = "m" -o \
  9291. "$CONFIG_FB_VIRGE" = "m" -o "$CONFIG_FB_VIRTUAL" = "m" -o \
  9292. "$CONFIG_FB_BWTWO" = "m" -o "$CONFIG_FB_CLGEN" = "m" -o \
  9293. - "$CONFIG_FB_TX3912" = "m" -o "$CONFIG_FB_CLPS711X" = "m" ]; then
  9294. + "$CONFIG_FB_TX3912" = "m" -o "$CONFIG_FB_CLPS711X" = "m" -o \
  9295. + "$CONFIG_FB_PL110" = "m" ]; then
  9296. define_tristate CONFIG_FBCON_MFB m
  9297. fi
  9298. fi
  9299. if [ "$CONFIG_FB_ACORN" = "y" -o "$CONFIG_FB_MAC" = "y" -o \
  9300. "$CONFIG_FB_SA1100" = "y" -o "$CONFIG_FB_VIRTUAL" = "y" -o \
  9301. "$CONFIG_FB_TX3912" = "y" -o "$CONFIG_FB_CLPS711X" = "y" -o \
  9302. - "$CONFIG_FB_DBMX1" = "y" ]; then
  9303. + "$CONFIG_FB_DBMX1" = "y" -o "$CONFIG_FB_PL110" = "y"]; then
  9304. define_tristate CONFIG_FBCON_CFB2 y
  9305. define_tristate CONFIG_FBCON_CFB4 y
  9306. else
  9307. if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_MAC" = "m" -o \
  9308. "$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_VIRTUAL" = "m" -o \
  9309. - "$CONFIG_FB_TX3912" = "m" -o "$CONFIG_FB_CLPS711X" = "m" ]; then
  9310. + "$CONFIG_FB_TX3912" = "m" -o "$CONFIG_FB_CLPS711X" = "m" -o \
  9311. + "$CONFIG_FB_PL110" = "m" ]; then
  9312. define_tristate CONFIG_FBCON_CFB2 m
  9313. define_tristate CONFIG_FBCON_CFB4 m
  9314. fi
  9315. @@ -329,6 +346,7 @@
  9316. "$CONFIG_FB_SIS" = "y" -o "$CONFIG_FB_NEOMAGIC" = "y" -o \
  9317. "$CONFIG_FB_STI" = "y" -o "$CONFIG_FB_HP300" = "y" -o \
  9318. "$CONFIG_FB_INTEL" = "y" -o \
  9319. + "$CONFIG_FB_PL110" = "y" -o \
  9320. "$CONFIG_FB_DBMX1" = "y" ]; then
  9321. define_tristate CONFIG_FBCON_CFB8 y
  9322. else
  9323. @@ -352,6 +370,7 @@
  9324. "$CONFIG_FB_RADEON" = "m" -o "$CONFIG_FB_INTEL" = "m" -o \
  9325. "$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_SIS" = "m" -o \
  9326. "$CONFIG_FB_TX3912" = "m" -o "$CONFIG_FB_NEOMAGIC" = "m" -o \
  9327. + "$CONFIG_FB_PL110" = "m" -o \
  9328. "$CONFIG_FB_STI" = "m" -o "$CONFIG_FB_INTEL" = "m" ]; then
  9329. define_tristate CONFIG_FBCON_CFB8 m
  9330. fi
  9331. @@ -373,6 +392,7 @@
  9332. "$CONFIG_FB_PVR2" = "y" -o "$CONFIG_FB_VOODOO1" = "y" -o \
  9333. "$CONFIG_FB_NEOMAGIC" = "y" -o "$CONFIG_FB_INTEL" = "y" -o \
  9334. "$CONFIG_FB_ANAKIN" = "y" -o \
  9335. + "$CONFIG_FB_PL110" = "y" -o \
  9336. "$CONFIG_FB_DBMX1" = "y" ]; then
  9337. define_tristate CONFIG_FBCON_CFB16 y
  9338. else
  9339. @@ -390,6 +410,7 @@
  9340. "$CONFIG_FB_CYBER2000" = "m" -o "$CONFIG_FB_SIS" = "m" -o \
  9341. "$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_RADEON" = "m" -o \
  9342. "$CONFIG_FB_INTEL" = "m" -o \
  9343. + "$CONFIG_FB_PL110" = "m" -o \
  9344. "$CONFIG_FB_PVR2" = "m" -o "$CONFIG_FB_VOODOO1" = "m" -o \
  9345. "$CONFIG_FB_NEOMAGIC" = "m" -o "$CONFIG_FB_INTEL" = "m" ]; then
  9346. define_tristate CONFIG_FBCON_CFB16 m
  9347. diff -urN linux-2.4.26/drivers/video/fbcon.c linux-2.4.26-vrs1-lnode80/drivers/video/fbcon.c
  9348. --- linux-2.4.26/drivers/video/fbcon.c 2003-08-25 07:44:42.000000000 -0400
  9349. +++ linux-2.4.26-vrs1-lnode80/drivers/video/fbcon.c 2005-11-02 17:37:32.000000000 -0400
  9350. @@ -2401,9 +2401,9 @@
  9351. p->type == FB_TYPE_INTERLEAVED_PLANES)) {
  9352. /* monochrome */
  9353. - unsigned char inverse = p->inverse || p->visual == FB_VISUAL_MONO01
  9354. - ? 0x00 : 0xff;
  9355. -
  9356. + //FJBunsigned char inverse = p->inverse || p->visual == FB_VISUAL_MONO01
  9357. + //FJB ? 0x00 : 0xff;
  9358. + unsigned char inverse = 0;
  9359. int is_hga = !strncmp(p->fb_info->modename, "HGA", 3);
  9360. /* can't use simply memcpy because need to apply inverse */
  9361. for( y1 = 0; y1 < LOGO_H; y1++ ) {
  9362. diff -urN linux-2.4.26/drivers/video/fbmem.c linux-2.4.26-vrs1-lnode80/drivers/video/fbmem.c
  9363. --- linux-2.4.26/drivers/video/fbmem.c 2005-11-02 16:54:25.000000000 -0400
  9364. +++ linux-2.4.26-vrs1-lnode80/drivers/video/fbmem.c 2005-11-02 17:37:32.000000000 -0400
  9365. @@ -109,6 +109,7 @@
  9366. extern int chips_init(void);
  9367. extern int g364fb_init(void);
  9368. extern int sa1100fb_init(void);
  9369. +extern int pl110fb_init(void);
  9370. extern int fm2fb_init(void);
  9371. extern int fm2fb_setup(char*);
  9372. extern int q40fb_init(void);
  9373. @@ -305,6 +306,9 @@
  9374. #ifdef CONFIG_FB_SA1100
  9375. { "sa1100", sa1100fb_init, NULL },
  9376. #endif
  9377. +#ifdef CONFIG_FB_PL110
  9378. + { "pl110", pl110fb_init, NULL },
  9379. +#endif
  9380. #ifdef CONFIG_FB_SUN3
  9381. { "sun3", sun3fb_init, sun3fb_setup },
  9382. #endif
  9383. diff -urN linux-2.4.26/drivers/video/Makefile linux-2.4.26-vrs1-lnode80/drivers/video/Makefile
  9384. --- linux-2.4.26/drivers/video/Makefile 2005-11-02 16:54:25.000000000 -0400
  9385. +++ linux-2.4.26-vrs1-lnode80/drivers/video/Makefile 2005-11-02 17:37:32.000000000 -0400
  9386. @@ -4,6 +4,14 @@
  9387. O_TARGET := video.o
  9388. +#
  9389. +# The following is VERY IMPORTANT for the pl110; newer gccs won't compile the driver
  9390. +# properly and it will hang at "Console: switching to colour frame buffer device ..."
  9391. +#
  9392. +ifeq ($(CONFIG_FB_PL110),y)
  9393. +EXTRA_CFLAGS =-O1
  9394. +endif
  9395. +
  9396. mod-subdirs := matrox sti
  9397. # All of the (potential) objects that export symbols.
  9398. @@ -15,7 +23,7 @@
  9399. fbcon-iplan2p8.o fbcon-vga-planes.o fbcon-cfb16.o \
  9400. fbcon-cfb2.o fbcon-cfb24.o fbcon-cfb32.o fbcon-cfb4.o \
  9401. fbcon-cfb8.o fbcon-mac.o fbcon-mfb.o \
  9402. - cyber2000fb.o sa1100fb.o fbcon-hga.o fbgen.o
  9403. + cyber2000fb.o sa1100fb.o fbcon-hga.o fbgen.o pl110fb.o
  9404. # Each configuration option enables a list of files.
  9405. @@ -137,6 +145,7 @@
  9406. obj-$(CONFIG_FB_PVR2) += pvr2fb.o
  9407. obj-$(CONFIG_FB_VOODOO1) += sstfb.o
  9408. obj-$(CONFIG_FB_ANAKIN) += anakinfb.o
  9409. +obj-$(CONFIG_FB_PL110) += pl110fb.o
  9410. # Generic Low Level Drivers
  9411. diff -urN linux-2.4.26/drivers/video/pl110fb.c linux-2.4.26-vrs1-lnode80/drivers/video/pl110fb.c
  9412. --- linux-2.4.26/drivers/video/pl110fb.c 1969-12-31 20:00:00.000000000 -0400
  9413. +++ linux-2.4.26-vrs1-lnode80/drivers/video/pl110fb.c 2005-11-02 17:37:32.000000000 -0400
  9414. @@ -0,0 +1,1719 @@
  9415. +/*
  9416. + * linux/drivers/video/pl110fb.c
  9417. + *
  9418. + * ARM PrimeCell PL110 LCD Controller Frame Buffer Driver
  9419. + *
  9420. + * Copyright (C) 2002 Lineo, Inc.
  9421. + * Based on sa1100fb.c, which is Copyright (C) Eric A. Thomas
  9422. + *
  9423. + * This file is subject to the terms and conditions of the GNU General Public
  9424. + * License. See the file COPYING in the main directory of this archive for
  9425. + * more details.
  9426. + */
  9427. +
  9428. +#include <linux/config.h>
  9429. +#include <linux/module.h>
  9430. +#include <linux/kernel.h>
  9431. +#include <linux/sched.h>
  9432. +#include <linux/errno.h>
  9433. +#include <linux/string.h>
  9434. +#include <linux/interrupt.h>
  9435. +#include <linux/slab.h>
  9436. +#include <linux/fb.h>
  9437. +#include <linux/delay.h>
  9438. +#include <linux/pm.h>
  9439. +#include <linux/init.h>
  9440. +#include <linux/cpufreq.h>
  9441. +
  9442. +#include <asm/hardware.h>
  9443. +#include <asm/io.h>
  9444. +#include <asm/irq.h>
  9445. +#include <asm/mach-types.h>
  9446. +#include <asm/uaccess.h>
  9447. +
  9448. +#include <video/fbcon.h>
  9449. +#include <video/fbcon-mfb.h>
  9450. +#include <video/fbcon-cfb4.h>
  9451. +#include <video/fbcon-cfb8.h>
  9452. +#include <video/fbcon-cfb16.h>
  9453. +
  9454. +#ifdef CONFIG_ARCH_LH79520
  9455. +#include <asm/arch/rcpc.h>
  9456. +#include <asm/arch/cpld.h>
  9457. +#include <asm/arch/iocon.h>
  9458. +#endif
  9459. +
  9460. +#ifdef CONFIG_ARCH_LH7A400
  9461. +#include <asm/arch/cpld.h>
  9462. +#include <asm/arch/gpio.h>
  9463. +#endif
  9464. +
  9465. +/*
  9466. + * debugging?
  9467. + */
  9468. +#define DEBUG 0
  9469. +/*
  9470. + * Complain if VAR is out of range.
  9471. + */
  9472. +#define DEBUG_VAR 1
  9473. +#define BACKLIGHT _BIT(15)
  9474. +//#define GPOUT16 (*(volatile u16*)GPOUT16_BASE)
  9475. +
  9476. +//#define GPOUT16 (*(volatile u16*)GPOUT16_BASE)
  9477. +
  9478. +// global defined in marm-lh7x.c -- driver
  9479. +extern unsigned short marm_backlight;
  9480. +#define GPOUT16 marm_backlight
  9481. +
  9482. +#include "pl110fb.h"
  9483. +
  9484. +extern unsigned int hclkfreq_get( void);
  9485. +
  9486. +void (*pl110fb_blank_helper)(int blank);
  9487. +EXPORT_SYMBOL(pl110fb_blank_helper);
  9488. +
  9489. +
  9490. +//#define _444 1
  9491. +#define _555 1
  9492. +
  9493. +#if _444
  9494. +static struct pl110fb_rgb rgb_8 = {
  9495. + red: { offset: 0, length: 4, },
  9496. + green: { offset: 0, length: 4, },
  9497. + blue: { offset: 0, length: 4, },
  9498. + transp: { offset: 0, length: 0, },
  9499. +};
  9500. +#elif _555
  9501. +static struct pl110fb_rgb rgb_8 = {
  9502. + red: { offset: 0, length: 5, },
  9503. + green: { offset: 0, length: 5, },
  9504. + blue: { offset: 0, length: 5, },
  9505. + transp: { offset: 0, length: 0, },
  9506. +};
  9507. +#else
  9508. +#error define _444 or _555
  9509. +#endif
  9510. +
  9511. +
  9512. +#if 0 // 5-6-5
  9513. +static struct pl110fb_rgb def_rgb_16 = {
  9514. + red: { offset: 11, length: 5, },
  9515. + green: { offset: 5, length: 6, },
  9516. + blue: { offset: 0, length: 5, },
  9517. + transp: { offset: 0, length: 0, },
  9518. +};
  9519. +#else // 5-5-5
  9520. +static struct pl110fb_rgb def_rgb_16 = {
  9521. + red: { offset: 10, length: 5, },
  9522. + green: { offset: 5, length: 5, },
  9523. + blue: { offset: 0, length: 5, },
  9524. + transp: { offset: 0, length: 0, },
  9525. +};
  9526. +#endif
  9527. +
  9528. +
  9529. +#define VERTICAL_REFRESH 70 /* optimum refresh rate, in Hz. */
  9530. +
  9531. +
  9532. +#if defined(CONFIG_ARCH_LH79520) || defined(CONFIG_ARCH_LH7A400)
  9533. +static struct pl110fb_mach_info lh_info __initdata = {
  9534. +
  9535. +#if defined(CONFIG_PL110_LQ39)
  9536. + bpp: 8,
  9537. + xres: 640, yres: 480,
  9538. + hsync_len: 13, /* hsw */ vsync_len: 2, /* vsw */
  9539. + left_margin: 21, /* hbp */ upper_margin: 5, /* vbp */
  9540. + right_margin: 11, /* hfp */ lower_margin: 5, /* vfp */
  9541. +
  9542. + sync: FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
  9543. +
  9544. + LCDtiming2: 0,
  9545. +
  9546. + LCDtiming3: 0,
  9547. +
  9548. + LCDcontrol: LCD_CTRL_BW_COLOR | LCD_CTRL_WATERMARK ,
  9549. +
  9550. + LCDICPcontrol: 0, //LCDICP_CONTROL_CLSEN | LCDICP_CONTROL_SPSEN,
  9551. +
  9552. + LCDICPsetup: LCDICP_SETUP_VERT_NORMAL | LCDICP_SETUP_HORIZ_NORMAL,
  9553. +
  9554. + LCDICPtiming1: LCDICP_TIMING1_PSDEL(9) | LCDICP_TIMING1_REVDEL(3) | LCDICP_TIMING1_LPDEL(14),
  9555. +
  9556. + LCDICPtiming2: LCDICP_TIMING2_PSDEL2(209) | LCDICP_TIMING2_SPLVALUE(34),
  9557. +
  9558. + /*
  9559. + * The Sharp LQ039Q2DS53 panel takes an RGB666 signal,
  9560. + * but we provide it with an RGB555 signal instead (def_rgb_16).
  9561. + */
  9562. +
  9563. + /* bpp set based on DIP switches on LCD board */
  9564. +
  9565. +// xres: 320, yres: 240,
  9566. +// hsync_len: 13, /* hsw */ vsync_len: 2, /* vsw */
  9567. +// left_margin: 21, /* hbp */ upper_margin: 5, /* vbp */
  9568. +// right_margin: 11, /* hfp */ lower_margin: 5, /* vfp */
  9569. +
  9570. +// sync: FB_SYNC_VERT_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  9571. +
  9572. +// LCDtiming2: LCD_TIMING2_IPC,
  9573. +//
  9574. +// LCDtiming3: 0,
  9575. +//
  9576. +// LCDcontrol: LCD_CTRL_TFT | LCD_CTRL_BW_COLOR | LCD_CTRL_WATERMARK,
  9577. +//
  9578. +// LCDICPcontrol: LCDICP_CONTROL_CLSEN | LCDICP_CONTROL_SPSEN,
  9579. +//
  9580. +// LCDICPsetup: LCDICP_SETUP_MODE_HRTFT | LCDICP_SETUP_VERT_NORMAL | LCDICP_SETUP_HORIZ_NORMAL,
  9581. +//
  9582. +// LCDICPtiming1: LCDICP_TIMING1_PSDEL(9) | LCDICP_TIMING1_REVDEL(3) | LCDICP_TIMING1_LPDEL(14),
  9583. +//
  9584. +// LCDICPtiming2: LCDICP_TIMING2_PSDEL2(209) | LCDICP_TIMING2_SPLVALUE(34),
  9585. +
  9586. +
  9587. +#elif defined(CONFIG_PL110_PAN78)
  9588. + bpp: 8,
  9589. + xres: 640, yres: 480,
  9590. + hsync_len: 13, /* hsw */ vsync_len: 2, /* vsw */
  9591. + left_margin: 21, /* hbp */ upper_margin: 5, /* vbp */
  9592. + right_margin: 11, /* hfp */ lower_margin: 5, /* vfp */
  9593. +
  9594. + sync: FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
  9595. +
  9596. + LCDtiming2: 0,
  9597. +
  9598. + LCDtiming3: 0,
  9599. +
  9600. + LCDcontrol: LCD_CTRL_BW_COLOR | LCD_CTRL_WATERMARK,
  9601. +
  9602. + LCDICPcontrol: 0, //LCDICP_CONTROL_CLSEN | LCDICP_CONTROL_SPSEN,
  9603. +
  9604. + LCDICPsetup: LCDICP_SETUP_VERT_NORMAL | LCDICP_SETUP_HORIZ_NORMAL,
  9605. +
  9606. + LCDICPtiming1: LCDICP_TIMING1_PSDEL(9) | LCDICP_TIMING1_REVDEL(3) | LCDICP_TIMING1_LPDEL(14),
  9607. +
  9608. + LCDICPtiming2: LCDICP_TIMING2_PSDEL2(209) | LCDICP_TIMING2_SPLVALUE(34),
  9609. +
  9610. +#elif defined(CONFIG_PL110_LM57)
  9611. + bpp: 8,
  9612. + xres: 320, yres: 240,
  9613. +#elif defined(CONFIG_PL110_LQ57)
  9614. + bpp: 8,
  9615. + xres: 240, yres: 320,
  9616. +#elif defined(CONFIG_PL110_LQ121)
  9617. + bpp: 4,
  9618. + xres: 320, yres: 240,
  9619. +#elif defined(CONFIG_PL110_LQ101)
  9620. +#else
  9621. +#error "You must have an LCD panel configured"
  9622. +#endif
  9623. +};
  9624. +#endif // CONFIG_ARCH_LH79520 || CONFIG_ARCH_LH7A400
  9625. +
  9626. +
  9627. +
  9628. +static struct pl110fb_mach_info * __init
  9629. +pl110fb_get_machine_info(struct pl110fb_info *fbi)
  9630. +{
  9631. + struct pl110fb_mach_info *inf = NULL;
  9632. +
  9633. +#if defined(CONFIG_ARCH_LH79520)
  9634. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  9635. + u8 dipSw = (u8)~(cpld->display_dip_sw & 0xff);
  9636. +
  9637. + if( machine_is_lh79520evb()) {
  9638. + inf = &lh_info;
  9639. +
  9640. + /* set bpp based on LCD board dip switch 0 */
  9641. + inf->bpp = 8; //(dipSw & 1 ? 8 : 16);
  9642. + }
  9643. +#endif
  9644. +#if defined(CONFIG_ARCH_LH7A400)
  9645. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  9646. + u8 dipSw = (u8)~(cpld->u3.dispDipSw & 0xff);
  9647. +
  9648. + if( machine_is_lh7a400evb()) {
  9649. + inf = &lh_info;
  9650. +
  9651. + /* set bpp based on LCD board dip switch 0 */
  9652. + inf->bpp = (dipSw & 1 ? 8 : 16);
  9653. + }
  9654. +#endif
  9655. + return inf;
  9656. +}
  9657. +
  9658. +
  9659. +static int pl110fb_activate_var(struct fb_var_screeninfo *var, struct pl110fb_info *);
  9660. +static void set_ctrlr_state(struct pl110fb_info *fbi, u_int state);
  9661. +
  9662. +
  9663. +static inline void
  9664. +pl110fb_schedule_task(struct pl110fb_info *fbi, u_int state)
  9665. +{
  9666. + unsigned long flags;
  9667. +
  9668. + local_irq_save(flags);
  9669. + /*
  9670. + * We need to handle two requests being made at the same time.
  9671. + * There are two important cases:
  9672. + * 1. When we are changing VT (C_REENABLE) while unblanking (C_ENABLE)
  9673. + * We must perform the unblanking, which will do our REENABLE for us.
  9674. + * 2. When we are blanking, but immediately unblank before we have
  9675. + * blanked. We do the "REENABLE" thing here as well, just to be sure.
  9676. + */
  9677. + if (fbi->task_state == C_ENABLE && state == C_REENABLE)
  9678. + state = (u_int) -1;
  9679. + if (fbi->task_state == C_DISABLE && state == C_ENABLE)
  9680. + state = C_REENABLE;
  9681. +
  9682. + if (state != (u_int)-1) {
  9683. + fbi->task_state = state;
  9684. + schedule_task(&fbi->task);
  9685. + }
  9686. + local_irq_restore(flags);
  9687. +}
  9688. +
  9689. +/*
  9690. + * Get the VAR structure pointer for the specified console
  9691. + */
  9692. +static inline struct fb_var_screeninfo *
  9693. +get_con_var(struct fb_info *info, int con)
  9694. +{
  9695. + struct pl110fb_info *fbi = (struct pl110fb_info *)info;
  9696. + return (con == fbi->currcon || con == -1) ? &fbi->fb.var : &fb_display[con].var;
  9697. +}
  9698. +
  9699. +/*
  9700. + * Get the DISPLAY structure pointer for the specified console
  9701. + */
  9702. +static inline struct display *
  9703. +get_con_display(struct fb_info *info, int con)
  9704. +{
  9705. + struct pl110fb_info *fbi = (struct pl110fb_info *)info;
  9706. + return (con < 0) ? fbi->fb.disp : &fb_display[con];
  9707. +}
  9708. +
  9709. +/*
  9710. + * Get the CMAP pointer for the specified console
  9711. + */
  9712. +static inline struct fb_cmap *
  9713. +get_con_cmap(struct fb_info *info, int con)
  9714. +{
  9715. + struct pl110fb_info *fbi = (struct pl110fb_info *)info;
  9716. +
  9717. + return (con == fbi->currcon || con == -1) ? &fbi->fb.cmap : &fb_display[con].cmap;
  9718. +}
  9719. +
  9720. +static inline u_int
  9721. +chan_to_field(u_int chan, struct fb_bitfield *bf)
  9722. +{
  9723. + chan &= 0xffff;
  9724. + chan >>= 16 - bf->length;
  9725. + return chan << bf->offset;
  9726. +}
  9727. +
  9728. +
  9729. +static int
  9730. +pl110fb_setpalettereg(u_int regno, u_int red, u_int green, u_int blue,
  9731. + u_int trans, struct fb_info *info)
  9732. +{
  9733. + struct pl110fb_info *fbi = (struct pl110fb_info *)info;
  9734. + u_int val, ret = 1;
  9735. + lcdRegs_t *LCD = (lcdRegs_t *)IO_ADDRESS(LCD_PHYS);
  9736. +
  9737. + if (regno < fbi->palette_size) {
  9738. +
  9739. +#if _444 // 4:4:4
  9740. + val = ((red >> 4) & 0x0F00) >> 7; // bits 4:0
  9741. + val |= ((green >> 8) & 0x00F0) << 2; // bits 9:5
  9742. + val |= ((blue >> 12) & 0x000F) << 11; // bits 14:10
  9743. +#else // 5:5:5
  9744. + val = (red & 0xF800) >> 11; // bits 4:0
  9745. + val |= (green & 0xF800) >> 6; // bits 9:5
  9746. + val |= (blue & 0xF800) >> 1; // bits 14:10
  9747. + val |= 0x8000; // always set intensity bit
  9748. +#endif
  9749. +
  9750. + if( regno & 1) /* setting higher number entry */
  9751. + LCD->palette[regno >> 1] = (LCD->palette[regno >> 1] & 0x0000ffff) | (val << 16);
  9752. + else /* setting lower number entry */
  9753. + LCD->palette[regno >> 1] = (LCD->palette[regno >> 1] & 0xffff0000) | val;
  9754. +
  9755. + /* */
  9756. +// DPRINTK( "reg=%x r=%x g=%x b=%x t=%x addr=%x val=%x entry=%x\n",
  9757. +// regno, red, green, blue, trans, &LCD->palette[regno >> 1], val,
  9758. +// LCD->palette[regno >> 1]);
  9759. + /* */
  9760. +
  9761. + ret = 0;
  9762. + }
  9763. + return ret;
  9764. +}
  9765. +
  9766. +static int
  9767. +pl110fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
  9768. + u_int trans, struct fb_info *info)
  9769. +{
  9770. + struct pl110fb_info *fbi = (struct pl110fb_info *)info;
  9771. + struct display *disp = get_con_display(info, fbi->currcon);
  9772. + u_int val;
  9773. + int ret = 1;
  9774. +
  9775. + /*
  9776. + * If inverse mode was selected, invert all the colours
  9777. + * rather than the register number. The register number
  9778. + * is what you poke into the framebuffer to produce the
  9779. + * colour you requested.
  9780. + */
  9781. + if (disp->inverse) {
  9782. + red = 0xffff - red;
  9783. + green = 0xffff - green;
  9784. + blue = 0xffff - blue;
  9785. + }
  9786. +
  9787. + /*
  9788. + * If greyscale is true, then we convert the RGB value
  9789. + * to greyscale no mater what visual we are using.
  9790. + */
  9791. + if (fbi->fb.var.grayscale)
  9792. + red = green = blue = (19595 * red + 38470 * green +
  9793. + 7471 * blue) >> 16;
  9794. +
  9795. + switch (fbi->fb.disp->visual) {
  9796. + case FB_VISUAL_TRUECOLOR:
  9797. + /*
  9798. + * 12 or 16-bit True Colour. We encode the RGB value
  9799. + * according to the RGB bitfield information.
  9800. + */
  9801. + if (regno < 16) {
  9802. + u16 *pal = fbi->fb.pseudo_palette;
  9803. +
  9804. + val = chan_to_field(red, &fbi->fb.var.red);
  9805. + val |= chan_to_field(green, &fbi->fb.var.green);
  9806. + val |= chan_to_field(blue, &fbi->fb.var.blue);
  9807. +
  9808. + pal[regno] = val;
  9809. + ret = 0;
  9810. + }
  9811. + break;
  9812. +
  9813. + case FB_VISUAL_STATIC_PSEUDOCOLOR:
  9814. + case FB_VISUAL_PSEUDOCOLOR:
  9815. + ret = pl110fb_setpalettereg(regno, red, green, blue, trans, info);
  9816. + break;
  9817. + }
  9818. +
  9819. + return ret;
  9820. +}
  9821. +
  9822. +/*
  9823. + * pl110fb_display_dma_period()
  9824. + * Calculate the minimum period (in picoseconds) between two DMA
  9825. + * requests for the LCD controller.
  9826. + */
  9827. +static unsigned int
  9828. +pl110fb_display_dma_period(struct fb_var_screeninfo *var)
  9829. +{
  9830. + unsigned int mem_bits_per_pixel;
  9831. +
  9832. + mem_bits_per_pixel = var->bits_per_pixel;
  9833. + if (mem_bits_per_pixel == 12)
  9834. + mem_bits_per_pixel = 16;
  9835. +
  9836. + /*
  9837. + * Period = pixclock * bits_per_byte * bytes_per_transfer
  9838. + * / memory_bits_per_pixel;
  9839. + */
  9840. + return var->pixclock * 8 * 16 / mem_bits_per_pixel;
  9841. +}
  9842. +
  9843. +/*
  9844. + * pl110fb_decode_var():
  9845. + * Get the video params out of 'var'. If a value doesn't fit, round it up,
  9846. + * if it's too big, return -EINVAL.
  9847. + *
  9848. + * Suggestion: Round up in the following order: bits_per_pixel, xres,
  9849. + * yres, xres_virtual, yres_virtual, xoffset, yoffset, grayscale,
  9850. + * bitfields, horizontal timing, vertical timing.
  9851. + */
  9852. +static int
  9853. +pl110fb_validate_var(struct fb_var_screeninfo *var,
  9854. + struct pl110fb_info *fbi)
  9855. +{
  9856. + int ret = -EINVAL;
  9857. +
  9858. + if (var->xres < MIN_XRES)
  9859. + var->xres = MIN_XRES;
  9860. + if (var->yres < MIN_YRES)
  9861. + var->yres = MIN_YRES;
  9862. + if (var->xres > fbi->max_xres)
  9863. + var->xres = fbi->max_xres;
  9864. + if (var->yres > fbi->max_yres)
  9865. + var->yres = fbi->max_yres;
  9866. + var->xres_virtual =
  9867. + var->xres_virtual < var->xres ? var->xres : var->xres_virtual;
  9868. + var->yres_virtual =
  9869. + var->yres_virtual < var->yres ? var->yres : var->yres_virtual;
  9870. +
  9871. + DPRINTK("var->bits_per_pixel=%d\n", var->bits_per_pixel);
  9872. + switch (var->bits_per_pixel) {
  9873. +#ifdef FBCON_HAS_CFB4
  9874. + case 4: ret = 0; break;
  9875. +#endif
  9876. +#ifdef FBCON_HAS_CFB8
  9877. + case 8: ret = 0; break;
  9878. +#endif
  9879. +#ifdef FBCON_HAS_CFB16
  9880. + case 16: ret = 0; break;
  9881. +#endif
  9882. + default:
  9883. + break;
  9884. + }
  9885. +
  9886. +#ifdef CONFIG_CPU_FREQ
  9887. + printk(KERN_DEBUG "dma period = %d ps, clock = %d kHz\n",
  9888. + pl110fb_display_dma_period(var),
  9889. + cpufreq_get(smp_processor_id()));
  9890. +#endif
  9891. +
  9892. + return ret;
  9893. +}
  9894. +
  9895. +
  9896. +static void
  9897. +pl110fb_hw_set_var(struct fb_var_screeninfo *var, struct pl110fb_info *fbi)
  9898. +{
  9899. + u_long palette_mem_size;
  9900. +
  9901. + fbi->palette_size = var->bits_per_pixel == 8 ? 256 : 16;
  9902. +
  9903. + palette_mem_size = fbi->palette_size * sizeof(u16);
  9904. +
  9905. + DPRINTK("palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size);
  9906. +
  9907. + fb_set_cmap(&fbi->fb.cmap, 1, pl110fb_setcolreg, &fbi->fb);
  9908. +
  9909. + pl110fb_activate_var(var, fbi);
  9910. +}
  9911. +
  9912. +/*
  9913. + * pl110fb_set_var():
  9914. + * Set the user defined part of the display for the specified console
  9915. + */
  9916. +static int
  9917. +pl110fb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
  9918. +{
  9919. + struct pl110fb_info *fbi = (struct pl110fb_info *)info;
  9920. + struct fb_var_screeninfo *dvar = get_con_var(&fbi->fb, con);
  9921. + struct display *display = get_con_display(&fbi->fb, con);
  9922. + int err, chgvar = 0, rgbidx;
  9923. +
  9924. + DPRINTK("called\n");
  9925. +
  9926. + /*
  9927. + * Decode var contents into a par structure, adjusting any
  9928. + * out of range values.
  9929. + */
  9930. + err = pl110fb_validate_var(var, fbi);
  9931. + if (err) {
  9932. + DPRINTK( "pl110fb_validate_var returned err=%d\n", err);
  9933. + return err;
  9934. + }
  9935. +
  9936. + if (var->activate & FB_ACTIVATE_TEST)
  9937. + return 0;
  9938. +
  9939. + if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW)
  9940. + return -EINVAL;
  9941. +
  9942. + if (dvar->xres != var->xres)
  9943. + chgvar = 1;
  9944. + if (dvar->yres != var->yres)
  9945. + chgvar = 1;
  9946. + if (dvar->xres_virtual != var->xres_virtual)
  9947. + chgvar = 1;
  9948. + if (dvar->yres_virtual != var->yres_virtual)
  9949. + chgvar = 1;
  9950. + if (dvar->bits_per_pixel != var->bits_per_pixel)
  9951. + chgvar = 1;
  9952. + if (con < 0)
  9953. + chgvar = 0;
  9954. +
  9955. + switch (var->bits_per_pixel) {
  9956. +#ifdef FBCON_HAS_CFB4
  9957. + case 4:
  9958. + if (fbi->cmap_static)
  9959. + display->visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
  9960. + else
  9961. + display->visual = FB_VISUAL_PSEUDOCOLOR;
  9962. + display->line_length = var->xres / 2;
  9963. + display->dispsw = &fbcon_cfb4;
  9964. + rgbidx = RGB_8;
  9965. + break;
  9966. +#endif
  9967. +#ifdef FBCON_HAS_CFB8
  9968. + case 8:
  9969. + if (fbi->cmap_static)
  9970. + display->visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
  9971. + else
  9972. + display->visual = FB_VISUAL_PSEUDOCOLOR;
  9973. + display->line_length = var->xres;
  9974. + display->dispsw = &fbcon_cfb8;
  9975. + rgbidx = RGB_8;
  9976. + break;
  9977. +#endif
  9978. +#ifdef FBCON_HAS_CFB16
  9979. + case 16:
  9980. + display->visual = FB_VISUAL_TRUECOLOR;
  9981. + display->line_length = var->xres * 2;
  9982. + display->dispsw = &fbcon_cfb16;
  9983. + display->dispsw_data = fbi->fb.pseudo_palette;
  9984. + rgbidx = RGB_16;
  9985. + break;
  9986. +#endif
  9987. + default:
  9988. + rgbidx = 0;
  9989. + display->dispsw = &fbcon_dummy;
  9990. + break;
  9991. + }
  9992. +
  9993. + display->screen_base = fbi->screen_cpu;
  9994. + display->next_line = display->line_length;
  9995. + display->type = fbi->fb.fix.type;
  9996. + display->type_aux = fbi->fb.fix.type_aux;
  9997. + display->ypanstep = fbi->fb.fix.ypanstep;
  9998. + display->ywrapstep = fbi->fb.fix.ywrapstep;
  9999. + display->can_soft_blank = 1;
  10000. + display->inverse = fbi->cmap_inverse;
  10001. +
  10002. + *dvar = *var;
  10003. + dvar->activate &= ~FB_ACTIVATE_ALL;
  10004. +
  10005. + /*
  10006. + * Copy the RGB parameters for this display
  10007. + * from the machine specific parameters.
  10008. + */
  10009. + dvar->red = fbi->rgb[rgbidx]->red;
  10010. + dvar->green = fbi->rgb[rgbidx]->green;
  10011. + dvar->blue = fbi->rgb[rgbidx]->blue;
  10012. + dvar->transp = fbi->rgb[rgbidx]->transp;
  10013. +
  10014. + DPRINTK("RGBT length = %d:%d:%d:%d\n",
  10015. + dvar->red.length, dvar->green.length, dvar->blue.length,
  10016. + dvar->transp.length);
  10017. +
  10018. + DPRINTK("RGBT offset = %d:%d:%d:%d\n",
  10019. + dvar->red.offset, dvar->green.offset, dvar->blue.offset,
  10020. + dvar->transp.offset);
  10021. +
  10022. + /*
  10023. + * Update the old var. The fbcon drivers still use this.
  10024. + * Once they are using fbi->fb.var, this can be dropped.
  10025. + */
  10026. + display->var = *dvar;
  10027. +
  10028. + /*
  10029. + * If we are setting all the virtual consoles, also set the
  10030. + * defaults used to create new consoles.
  10031. + */
  10032. + if (var->activate & FB_ACTIVATE_ALL)
  10033. + fbi->fb.disp->var = *dvar;
  10034. +
  10035. + /*
  10036. + * If the console has changed and the console has defined
  10037. + * a changevar function, call that function.
  10038. + */
  10039. + if (chgvar && info && fbi->fb.changevar)
  10040. + fbi->fb.changevar(con);
  10041. +
  10042. + /* If the current console is selected, activate the new var. */
  10043. + if (con != fbi->currcon)
  10044. + return 0;
  10045. +
  10046. + pl110fb_hw_set_var(dvar, fbi);
  10047. +
  10048. + return 0;
  10049. +}
  10050. +
  10051. +static int
  10052. +__do_set_cmap(struct fb_cmap *cmap, int kspc, int con,
  10053. + struct fb_info *info)
  10054. +{
  10055. + struct pl110fb_info *fbi = (struct pl110fb_info *)info;
  10056. + struct fb_cmap *dcmap = get_con_cmap(info, con);
  10057. + int err = 0;
  10058. +
  10059. + if (con == -1)
  10060. + con = fbi->currcon;
  10061. +
  10062. + /* no colormap allocated? (we always have "this" colour map allocated) */
  10063. + if (con >= 0)
  10064. + err = fb_alloc_cmap(&fb_display[con].cmap, fbi->palette_size, 0);
  10065. +
  10066. + if (!err && con == fbi->currcon)
  10067. + err = fb_set_cmap(cmap, kspc, pl110fb_setcolreg, info);
  10068. +
  10069. + if (!err)
  10070. + fb_copy_cmap(cmap, dcmap, kspc ? 0 : 1);
  10071. +
  10072. + return err;
  10073. +}
  10074. +
  10075. +static int
  10076. +pl110fb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
  10077. + struct fb_info *info)
  10078. +{
  10079. + struct display *disp = get_con_display(info, con);
  10080. +
  10081. + if (disp->visual == FB_VISUAL_TRUECOLOR ||
  10082. + disp->visual == FB_VISUAL_STATIC_PSEUDOCOLOR)
  10083. + return -EINVAL;
  10084. +
  10085. + return __do_set_cmap(cmap, kspc, con, info);
  10086. +}
  10087. +
  10088. +static int
  10089. +pl110fb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info)
  10090. +{
  10091. + struct display *display = get_con_display(info, con);
  10092. +
  10093. + *fix = info->fix;
  10094. +
  10095. + fix->line_length = display->line_length;
  10096. + fix->visual = display->visual;
  10097. + return 0;
  10098. +}
  10099. +
  10100. +static int
  10101. +pl110fb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
  10102. +{
  10103. + *var = *get_con_var(info, con);
  10104. + return 0;
  10105. +}
  10106. +
  10107. +static int
  10108. +pl110fb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info)
  10109. +{
  10110. + struct fb_cmap *dcmap = get_con_cmap(info, con);
  10111. + fb_copy_cmap(dcmap, cmap, kspc ? 0 : 2);
  10112. + return 0;
  10113. +}
  10114. +
  10115. +static struct fb_ops pl110fb_ops = {
  10116. + owner: THIS_MODULE,
  10117. + fb_get_fix: pl110fb_get_fix,
  10118. + fb_get_var: pl110fb_get_var,
  10119. + fb_set_var: pl110fb_set_var,
  10120. + fb_get_cmap: pl110fb_get_cmap,
  10121. + fb_set_cmap: pl110fb_set_cmap,
  10122. +};
  10123. +
  10124. +/*
  10125. + * pl110fb_switch():
  10126. + * Change to the specified console. Palette and video mode
  10127. + * are changed to the console's stored parameters.
  10128. + *
  10129. + * Uh oh, this can be called from a tasklet (IRQ)
  10130. + */
  10131. +static int
  10132. +pl110fb_switch(int con, struct fb_info *info)
  10133. +{
  10134. + struct pl110fb_info *fbi = (struct pl110fb_info *)info;
  10135. + struct display *disp;
  10136. + struct fb_cmap *cmap;
  10137. +
  10138. + DPRINTK("con=%d info->modename=%s\n", con, fbi->fb.modename);
  10139. +
  10140. + if (con == fbi->currcon)
  10141. + return 0;
  10142. +
  10143. + if (fbi->currcon >= 0) {
  10144. + disp = fb_display + fbi->currcon;
  10145. +
  10146. + /*
  10147. + * Save the old colormap and video mode.
  10148. + */
  10149. + disp->var = fbi->fb.var;
  10150. +
  10151. + if (disp->cmap.len)
  10152. + fb_copy_cmap(&fbi->fb.cmap, &disp->cmap, 0);
  10153. + }
  10154. +
  10155. + fbi->currcon = con;
  10156. + disp = fb_display + con;
  10157. +
  10158. + /*
  10159. + * Make sure that our colourmap contains 256 entries.
  10160. + */
  10161. + fb_alloc_cmap(&fbi->fb.cmap, 256, 0);
  10162. +
  10163. + if (disp->cmap.len)
  10164. + cmap = &disp->cmap;
  10165. + else
  10166. + cmap = fb_default_cmap(1 << disp->var.bits_per_pixel);
  10167. +
  10168. + fb_copy_cmap(cmap, &fbi->fb.cmap, 0);
  10169. +
  10170. + fbi->fb.var = disp->var;
  10171. + fbi->fb.var.activate = FB_ACTIVATE_NOW;
  10172. +
  10173. + pl110fb_set_var(&fbi->fb.var, con, info);
  10174. + return 0;
  10175. +}
  10176. +
  10177. +/*
  10178. + * Formal definition of the VESA spec:
  10179. + * On
  10180. + * This refers to the state of the display when it is in full operation
  10181. + * Stand-By
  10182. + * This defines an optional operating state of minimal power reduction with
  10183. + * the shortest recovery time
  10184. + * Suspend
  10185. + * This refers to a level of power management in which substantial power
  10186. + * reduction is achieved by the display. The display can have a longer
  10187. + * recovery time from this state than from the Stand-by state
  10188. + * Off
  10189. + * This indicates that the display is consuming the lowest level of power
  10190. + * and is non-operational. Recovery from this state may optionally require
  10191. + * the user to manually power on the monitor
  10192. + *
  10193. + * Now, the fbdev driver adds an additional state, (blank), where they
  10194. + * turn off the video (maybe by colormap tricks), but don't mess with the
  10195. + * video itself: think of it semantically between on and Stand-By.
  10196. + *
  10197. + * So here's what we should do in our fbdev blank routine:
  10198. + *
  10199. + * VESA_NO_BLANKING (mode 0) Video on, front/back light on
  10200. + * VESA_VSYNC_SUSPEND (mode 1) Video on, front/back light off
  10201. + * VESA_HSYNC_SUSPEND (mode 2) Video on, front/back light off
  10202. + * VESA_POWERDOWN (mode 3) Video off, front/back light off
  10203. + *
  10204. + * This will match the matrox implementation.
  10205. + */
  10206. +/*
  10207. + * pl110fb_blank():
  10208. + * Blank the display by setting all palette values to zero. Note, the
  10209. + * 12 and 16 bpp modes don't really use the palette, so this will not
  10210. + * blank the display in all modes.
  10211. + */
  10212. +static void
  10213. +pl110fb_blank(int blank, struct fb_info *info)
  10214. +{
  10215. + struct pl110fb_info *fbi = (struct pl110fb_info *)info;
  10216. + int i;
  10217. +
  10218. + DPRINTK("pl110fb_blank: blank=%d info->modename=%s\n", blank,
  10219. + fbi->fb.modename);
  10220. +
  10221. + switch (blank) {
  10222. + case VESA_POWERDOWN:
  10223. + case VESA_VSYNC_SUSPEND:
  10224. + case VESA_HSYNC_SUSPEND:
  10225. + if (fbi->fb.disp->visual == FB_VISUAL_PSEUDOCOLOR ||
  10226. + fbi->fb.disp->visual == FB_VISUAL_STATIC_PSEUDOCOLOR)
  10227. + for (i = 0; i < fbi->palette_size; i++)
  10228. + pl110fb_setpalettereg(i, 0, 0, 0, 0, info);
  10229. + pl110fb_schedule_task(fbi, C_DISABLE);
  10230. + if (pl110fb_blank_helper)
  10231. + pl110fb_blank_helper(blank);
  10232. + break;
  10233. +
  10234. + case VESA_NO_BLANKING:
  10235. + if (pl110fb_blank_helper)
  10236. + pl110fb_blank_helper(blank);
  10237. + if (fbi->fb.disp->visual == FB_VISUAL_PSEUDOCOLOR ||
  10238. + fbi->fb.disp->visual == FB_VISUAL_STATIC_PSEUDOCOLOR)
  10239. + fb_set_cmap(&fbi->fb.cmap, 1, pl110fb_setcolreg, info);
  10240. + pl110fb_schedule_task(fbi, C_ENABLE);
  10241. + }
  10242. +}
  10243. +
  10244. +static int
  10245. +pl110fb_updatevar(int con, struct fb_info *info)
  10246. +{
  10247. + DPRINTK("entered\n");
  10248. + return 0;
  10249. +}
  10250. +
  10251. +/*
  10252. + * Calculate the PCD value from the clock rate (in picoseconds).
  10253. + * We take account of the PPCR clock setting.
  10254. + */
  10255. +static inline int
  10256. +get_pcd(unsigned int pixclock)
  10257. +{
  10258. + unsigned int pcd;
  10259. +
  10260. + if (pixclock) {
  10261. + pcd = hclkfreq_get() / 100000;
  10262. + pcd *= pixclock;
  10263. + pcd /= 10000000;
  10264. + pcd += 1; /* make up for integer math truncations */
  10265. + } else {
  10266. + /*
  10267. + * People seem to be missing this message. Make it big.
  10268. + * Make it stand out. Make sure people see it.
  10269. + */
  10270. + printk(KERN_WARNING "******************************************************\n");
  10271. + printk(KERN_WARNING "** ZERO PIXEL CLOCK DETECTED **\n");
  10272. + printk(KERN_WARNING "** You are using a zero pixclock. This means that **\n");
  10273. + printk(KERN_WARNING "** clock scaling will not be able to adjust your **\n");
  10274. + printk(KERN_WARNING "** your timing parameters appropriately, and the **\n");
  10275. + printk(KERN_WARNING "** bandwidth calculations will fail to work. This **\n");
  10276. + printk(KERN_WARNING "** will shortly become an error condition, which **\n");
  10277. + printk(KERN_WARNING "** will prevent your LCD display working. Please **\n");
  10278. + printk(KERN_WARNING "** send your patches in as soon as possible to shut **\n");
  10279. + printk(KERN_WARNING "** this message up. **\n");
  10280. + printk(KERN_WARNING "******************************************************\n");
  10281. + pcd = 0;
  10282. + }
  10283. +
  10284. + DPRINTK( "pcd=%d\n", pcd);
  10285. +
  10286. + return pcd;
  10287. +}
  10288. +
  10289. +/*
  10290. + * pl110fb_activate_var():
  10291. + * Configures LCD Controller based on entries in var parameter. Settings are
  10292. + * only written to the controller if changes were made.
  10293. + */
  10294. +static int
  10295. +pl110fb_activate_var(struct fb_var_screeninfo *var, struct pl110fb_info *fbi)
  10296. +{
  10297. + struct pl110fb_lcd_reg new_regs;
  10298. + u_int half_screen_size, yres, pcd = get_pcd( var->pixclock);
  10299. + u_long flags;
  10300. + lcdRegs_t *LCD = (lcdRegs_t *)IO_ADDRESS(LCD_PHYS);
  10301. + lcdicpRegs_t *LCDICP = (lcdicpRegs_t *)IO_ADDRESS(LCDICP_PHYS);
  10302. +
  10303. + DPRINTK("Configuring pl110 LCD\n");
  10304. + DPRINTK( "LCD=%p LCDICP=%p\n", LCD, LCDICP);
  10305. +
  10306. + DPRINTK("var: xres=%d hslen=%d lm=%d rm=%d\n",
  10307. + var->xres, var->hsync_len,
  10308. + var->left_margin, var->right_margin);
  10309. + DPRINTK("var: yres=%d vslen=%d um=%d bm=%d\n",
  10310. + var->yres, var->vsync_len,
  10311. + var->upper_margin, var->lower_margin);
  10312. +
  10313. +#if DEBUG_VAR
  10314. + if (var->xres < 16 || var->xres > 1024)
  10315. + printk(KERN_ERR "%s: invalid xres %d\n",
  10316. + fbi->fb.fix.id, var->xres);
  10317. + if (var->hsync_len < 1 || var->hsync_len > 64)
  10318. + printk(KERN_ERR "%s: invalid hsync_len %d\n",
  10319. + fbi->fb.fix.id, var->hsync_len);
  10320. + if (var->left_margin < 1 || var->left_margin > 255)
  10321. + printk(KERN_ERR "%s: invalid left_margin %d\n",
  10322. + fbi->fb.fix.id, var->left_margin);
  10323. + if (var->right_margin < 1 || var->right_margin > 255)
  10324. + printk(KERN_ERR "%s: invalid right_margin %d\n",
  10325. + fbi->fb.fix.id, var->right_margin);
  10326. + if (var->yres < 1 || var->yres > 1024)
  10327. + printk(KERN_ERR "%s: invalid yres %d\n",
  10328. + fbi->fb.fix.id, var->yres);
  10329. + if (var->vsync_len < 1 || var->vsync_len > 64)
  10330. + printk(KERN_ERR "%s: invalid vsync_len %d\n",
  10331. + fbi->fb.fix.id, var->vsync_len);
  10332. + if (var->upper_margin < 0 || var->upper_margin > 255)
  10333. + printk(KERN_ERR "%s: invalid upper_margin %d\n",
  10334. + fbi->fb.fix.id, var->upper_margin);
  10335. + if (var->lower_margin < 0 || var->lower_margin > 255)
  10336. + printk(KERN_ERR "%s: invalid lower_margin %d\n",
  10337. + fbi->fb.fix.id, var->lower_margin);
  10338. +#endif
  10339. + if( var->bits_per_pixel == 8) {
  10340. + new_regs.LCDcontrol = LCD_CTRL_BPP8;
  10341. + } else if( var->bits_per_pixel == 16) {
  10342. + new_regs.LCDcontrol = LCD_CTRL_BPP16 | LCD_CTRL_BGR;
  10343. + }
  10344. +
  10345. + new_regs.LCDcontrol |= fbi->LCDcontrol | LCD_CTRL_ENABLE;
  10346. +
  10347. + new_regs.LCDtiming0 =
  10348. + LCD_TIMING0_HFP(var->right_margin) +
  10349. + LCD_TIMING0_HBP(var->left_margin) +
  10350. + LCD_TIMING0_HSW(var->hsync_len) +
  10351. + LCD_TIMING0_PPL(var->xres);
  10352. +
  10353. + /*
  10354. + * If we have a dual scan LCD, then we need to halve
  10355. + * the YRES parameter.
  10356. + */
  10357. + yres = var->yres;
  10358. + if( fbi->LCDcontrol & LCD_CTRL_DUAL)
  10359. + yres /= 2;
  10360. +
  10361. + new_regs.LCDtiming1 =
  10362. + LCD_TIMING1_VBP(var->upper_margin) +
  10363. + LCD_TIMING1_VFP(var->lower_margin) +
  10364. + LCD_TIMING1_VSW(var->vsync_len) +
  10365. + LCD_TIMING1_LPP(yres);
  10366. +
  10367. + new_regs.LCDtiming2 = fbi->LCDtiming2 |
  10368. + LCD_TIMING2_CPL (480) | //(var->xres) |
  10369. + LCD_TIMING2_PCD(pcd) |
  10370. + (var->sync & FB_SYNC_HOR_HIGH_ACT ? 0 : LCD_TIMING2_IHS) |
  10371. + (var->sync & FB_SYNC_VERT_HIGH_ACT ? 0 : LCD_TIMING2_IVS);
  10372. +
  10373. + new_regs.LCDtiming3 = fbi->LCDtiming3;
  10374. + new_regs.LCDICPsetup = fbi->LCDICPsetup | LCDICP_SETUP_PPL(var->xres);
  10375. +#if defined(CONFIG_ARCH_LH7A400)
  10376. + new_regs.LCDICPsetup |= LCDICP_SETUP_POWER;
  10377. +#endif
  10378. +
  10379. + new_regs.LCDICPcontrol = fbi->LCDICPcontrol;
  10380. + new_regs.LCDICPtiming1 = fbi->LCDICPtiming1;
  10381. + new_regs.LCDICPtiming2 = fbi->LCDICPtiming2;
  10382. +
  10383. + DPRINTK("new LCDtiming0 = 0x%08x\n", (u32)new_regs.LCDtiming0);
  10384. + DPRINTK("new LCDtiming1 = 0x%08x\n", (u32)new_regs.LCDtiming1);
  10385. + DPRINTK("new LCDtiming2 = 0x%08x\n", (u32)new_regs.LCDtiming2);
  10386. + DPRINTK("new LCDtiming3 = 0x%08x\n", (u32)new_regs.LCDtiming3);
  10387. + DPRINTK("new LCDcontrol = 0x%08x\n", (u32)new_regs.LCDcontrol);
  10388. + DPRINTK("new LCDICPsetup = 0x%08x\n", (u32)new_regs.LCDICPsetup);
  10389. + DPRINTK("new LCDICPcontrol = 0x%08x\n", (u32)new_regs.LCDICPcontrol);
  10390. + DPRINTK("new LCDICPtiming1 = 0x%08x\n", (u32)new_regs.LCDICPtiming1);
  10391. + DPRINTK("new LCDICPtiming2 = 0x%08x\n", (u32)new_regs.LCDICPtiming2);
  10392. +
  10393. +
  10394. + /* Update shadow copy atomically */
  10395. + local_irq_save(flags);
  10396. + fbi->upbase = fbi->screen_dma;
  10397. +
  10398. + fbi->reg_LCDtiming0 = new_regs.LCDtiming0;
  10399. + fbi->reg_LCDtiming1 = new_regs.LCDtiming1;
  10400. + fbi->reg_LCDtiming2 = new_regs.LCDtiming2;
  10401. + fbi->reg_LCDtiming3 = new_regs.LCDtiming3;
  10402. + fbi->reg_LCDcontrol = new_regs.LCDcontrol;
  10403. + fbi->reg_LCDICPsetup = new_regs.LCDICPsetup;
  10404. + fbi->reg_LCDICPcontrol = new_regs.LCDICPcontrol;
  10405. + fbi->reg_LCDICPtiming1 = new_regs.LCDICPtiming1;
  10406. + fbi->reg_LCDICPtiming2 = new_regs.LCDICPtiming2;
  10407. + local_irq_restore(flags);
  10408. +
  10409. + /*
  10410. + * Only update the registers if the controller is enabled
  10411. + * and something has changed.
  10412. + */
  10413. + if ((LCD->timing0 != fbi->reg_LCDtiming0) || (LCD->timing1 != fbi->reg_LCDtiming1) ||
  10414. + (LCD->timing2 != fbi->reg_LCDtiming2) || (LCD->timing3 != fbi->reg_LCDtiming2) ||
  10415. + (LCD->control != fbi->reg_LCDcontrol) || (LCDICP->setup != fbi->reg_LCDICPsetup) ||
  10416. + (LCDICP->timing1 != fbi->reg_LCDICPtiming1) || (LCDICP->timing2 != fbi->reg_LCDICPtiming2) ||
  10417. + (LCD->upbase != fbi->upbase) || (LCD->lpbase != fbi->lpbase))
  10418. + pl110fb_schedule_task(fbi, C_REENABLE);
  10419. +
  10420. + return 0;
  10421. +}
  10422. +
  10423. +/*
  10424. + * NOTE! The following functions are purely helpers for set_ctrlr_state.
  10425. + * Do not call them directly; set_ctrlr_state does the correct serialisation
  10426. + * to ensure that things happen in the right way 100% of time time.
  10427. + * -- rmk
  10428. + */
  10429. +
  10430. +static void
  10431. +pl110fb_backlight_on(struct pl110fb_info *fbi)
  10432. +{
  10433. + DPRINTK("backlight on\n");
  10434. +
  10435. +#ifdef CONFIG_ARCH_LH79520
  10436. + if( machine_is_lh79520evb()) {
  10437. + //cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  10438. + GPOUT16 |= BACKLIGHT;
  10439. +
  10440. + //cpld->lcd_pwr_cntl |= CPLD_BACKLIGHT_ON;
  10441. + }
  10442. +#endif
  10443. +
  10444. +#ifdef CONFIG_ARCH_LH7A400
  10445. + if( machine_is_lh7a400evb()) {
  10446. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  10447. +
  10448. + cpld->lcd_pwr_cntl |= CPLD_BACKLIGHT_ON;
  10449. + }
  10450. +#endif
  10451. +}
  10452. +
  10453. +static void
  10454. +pl110fb_backlight_off(struct pl110fb_info *fbi)
  10455. +{
  10456. + DPRINTK("backlight off\n");
  10457. +
  10458. +#ifdef CONFIG_ARCH_LH79520
  10459. + if( machine_is_lh79520evb()) {
  10460. + //cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  10461. + GPOUT16 &= ~BACKLIGHT;
  10462. + //cpld->lcd_pwr_cntl &= ~CPLD_BACKLIGHT_ON;
  10463. + }
  10464. +#endif
  10465. +#ifdef CONFIG_ARCH_LH7A400
  10466. + if( machine_is_lh7a400evb()) {
  10467. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  10468. +
  10469. + cpld->lcd_pwr_cntl &= ~CPLD_BACKLIGHT_ON;
  10470. + }
  10471. +#endif
  10472. +}
  10473. +
  10474. +static void
  10475. +pl110fb_power_up_lcd(struct pl110fb_info *fbi)
  10476. +{
  10477. + DPRINTK("LCD power on\n");
  10478. +
  10479. +#ifdef CONFIG_ARCH_LH79520
  10480. + if( machine_is_lh79520evb()) {
  10481. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  10482. +
  10483. + cpld->lcd_pwr_cntl |= CPLD_LCDP_EN;
  10484. + }
  10485. +#endif
  10486. +#ifdef CONFIG_ARCH_LH7A400
  10487. + if( machine_is_lh7a400evb()) {
  10488. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  10489. +
  10490. + cpld->lcd_pwr_cntl |= CPLD_LCDP_EN;
  10491. + }
  10492. +#endif
  10493. +}
  10494. +
  10495. +static void
  10496. +pl110fb_power_down_lcd(struct pl110fb_info *fbi)
  10497. +{
  10498. + DPRINTK("LCD power off\n");
  10499. +#ifdef CONFIG_ARCH_LH79520
  10500. + if( machine_is_lh79520evb()) {
  10501. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  10502. +
  10503. + cpld->lcd_pwr_cntl &= ~CPLD_LCDP_EN;
  10504. + }
  10505. +#endif
  10506. +#ifdef CONFIG_ARCH_LH7A400
  10507. + if( machine_is_lh7a400evb()) {
  10508. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  10509. +
  10510. + cpld->lcd_pwr_cntl &= ~CPLD_LCDP_EN;
  10511. + }
  10512. +#endif
  10513. +}
  10514. +
  10515. +
  10516. +static void
  10517. +pl110fb_setup_hw(struct pl110fb_info *fbi)
  10518. +{
  10519. +#ifdef CONFIG_ARCH_LH79520
  10520. + rcpcRegs_t *rcpc = (rcpcRegs_t *)IO_ADDRESS( RCPC_PHYS);
  10521. + ioconRegs_t *iocon = (ioconRegs_t *)IO_ADDRESS( IOCON_PHYS);
  10522. +
  10523. + rcpc->control |= RCPC_CTRL_WRTLOCK_ENABLED; /* unlock RCPC registers */
  10524. + barrier();
  10525. +
  10526. + /*
  10527. + * use HCLK for the LCD clock.
  10528. + */
  10529. + rcpc->spareClkCtrl &= ~RCPC_SPARE_CLKCTRL_LCDCLK_DISABLE; /* enable LCDCLK */
  10530. + rcpc->spareClkSel &= ~RCPC_SCLKSEL_LCDCLK; /* LCDCLK from HCLK */
  10531. + rcpc->spare0Prescale &= 0;
  10532. + rcpc->AHBClkCtrl &= ~RCPC_CLKCTRL_DMAC_DISABLE; /* ensure DMA gets a clock */
  10533. + rcpc->control &= ~RCPC_CTRL_WRTLOCK_ENABLED; /* lock RCPC registers */
  10534. +
  10535. + /* set the pin mux to enable all required LCD signals and disable the rest */
  10536. +
  10537. + iocon->LCDMux =
  10538. + LCDMUX_CLVDDEN
  10539. +// | LCDMUX_CLXCLK
  10540. +// | LCDMUX_CLSPL /* SPL */
  10541. +// | LCDMUX_CLS /* CLS */
  10542. + | LCDMUX_PIOC2 /* don't need external LCD clock */
  10543. + | LCDMUX_CLCP /* DCLK */
  10544. + | LCDMUX_CLLP /* LP */
  10545. + | LCDMUX_CLD17
  10546. + | LCDMUX_CLD16
  10547. + | LCDMUX_CLD15
  10548. + | LCDMUX_CLD14
  10549. + | LCDMUX_CLD13
  10550. + | LCDMUX_CLD12
  10551. + | LCDMUX_CLFP
  10552. + | LCDMUX_CLD11
  10553. + | LCDMUX_CLD10
  10554. + | LCDMUX_CLD8
  10555. + | LCDMUX_CLD9
  10556. + | LCDMUX_CLD2 /* red[1] */
  10557. + | LCDMUX_CLD3 /* red[2] */
  10558. + | LCDMUX_CLD4 /* red[3] */
  10559. + | LCDMUX_CLD5 /* red[4] */
  10560. + | LCDMUX_CLD7 /* green[0] */
  10561. + | LCDMUX_CLD6; /* green[1] */
  10562. +
  10563. +// iocon->LCDMux = LCDMUX_CLREV
  10564. +// | LCDMUX_CLXCLK
  10565. +// | LCDMUX_CLD13 /* blue[0] */
  10566. +// | LCDMUX_CLD14 /* blue[1] */
  10567. +// | LCDMUX_CLD15 /* blue[2] */
  10568. +// | LCDMUX_CLD16 /* blue[3] */
  10569. +// | LCDMUX_CLD17 /* blue[4] */
  10570. +// | LCDMUX_CLSPL /* SPL */
  10571. +// | LCDMUX_CLS /* CLS */
  10572. +// | LCDMUX_PIOC2 /* don't need external LCD clock */
  10573. +// | LCDMUX_CLCP /* DCLK */
  10574. +// | LCDMUX_CLP /* LP */
  10575. +// | LCDMUX_CLSPS /* SPS */
  10576. +// | LCDMUX_CLD2 /* red[1] */
  10577. +// | LCDMUX_CLD3 /* red[2] */
  10578. +// | LCDMUX_CLD4 /* red[3] */
  10579. +// | LCDMUX_CLD5 /* red[4] */
  10580. +// | LCDMUX_CPS /* PS */
  10581. +// | LCDMUX_CLD7 /* green[0] */
  10582. +// | LCDMUX_CLD8 /* green[1] */
  10583. +// | LCDMUX_CLD9 /* green[2] */
  10584. +// | LCDMUX_CLD10 /* green[3] */
  10585. +// | LCDMUX_CLD11; /* green[4] */
  10586. +
  10587. + DPRINTK( "IOCON->LCDMux=%x\n", iocon->LCDMux);
  10588. +#endif
  10589. +#ifdef CONFIG_ARCH_LH7A400
  10590. + gpioRegs_t *gpio = (gpioRegs_t *)IO_ADDRESS(GPIO_PHYS);
  10591. +
  10592. + gpio->pinmux |= (GPIO_PINMUX_PEOCON | GPIO_PINMUX_PDOCON); /* route LCD data bits */
  10593. +
  10594. + DPRINTK( "gpio: pinmux=%x pdddr=0x%x peddr=0x%x\n",
  10595. + gpio->pinmux, gpio->pdddr, gpio->peddr); // DDD
  10596. +#endif
  10597. +}
  10598. +
  10599. +static void
  10600. +pl110fb_enable_controller(struct pl110fb_info *fbi)
  10601. +{
  10602. + lcdRegs_t *LCD = (lcdRegs_t *)IO_ADDRESS(LCD_PHYS);
  10603. + lcdicpRegs_t *LCDICP = (lcdicpRegs_t *)IO_ADDRESS(LCDICP_PHYS);
  10604. +
  10605. +#if defined(CONFIG_ARCH_LH79520) || defined(CONFIG_ARCH_LH7A400)
  10606. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  10607. +#endif
  10608. + DPRINTK("Enabling LCD controller\n");
  10609. +
  10610. + LCDICP->control = fbi->reg_LCDICPcontrol;
  10611. + LCDICP->setup = fbi->reg_LCDICPsetup;
  10612. + LCDICP->timing1 = fbi->reg_LCDICPtiming1;
  10613. + LCDICP->timing2 = fbi->reg_LCDICPtiming2;
  10614. + LCD->timing0 = fbi->reg_LCDtiming0;
  10615. + LCD->timing1 = fbi->reg_LCDtiming1;
  10616. + LCD->timing2 = fbi->reg_LCDtiming2;
  10617. + LCD->timing3 = fbi->reg_LCDtiming3;
  10618. + LCD->upbase = fbi->upbase;
  10619. +#if defined(CONFIG_ARCH_LH7A400)
  10620. + LCD->lpoverflow = fbi->upbase;
  10621. +#endif
  10622. + LCD->intrEnable = 0;
  10623. + LCD->control = fbi->reg_LCDcontrol;
  10624. +
  10625. + /*
  10626. + * enable lcd output
  10627. + */
  10628. +#if defined(CONFIG_ARCH_LH79520) || defined(CONFIG_ARCH_LH7A400)
  10629. + cpld->lcd_pwr_cntl |= CPLD_LCD_OE;
  10630. +#endif
  10631. +
  10632. + set_current_state(TASK_UNINTERRUPTIBLE);
  10633. + schedule_timeout(20 * HZ / 1000);
  10634. +
  10635. + LCD->control |= LCD_CTRL_PWR;
  10636. +
  10637. +
  10638. +#if defined(CONFIG_ARCH_LH7A400)
  10639. + DPRINTK("real LCDoverflow = %p\n", (void *)LCD->lpoverflow);
  10640. +#endif
  10641. + DPRINTK("real LCDupbase = %p\n", (void *)LCD->upbase);
  10642. + DPRINTK("real LCDlpbase = %p\n", (void *)LCD->lpbase);
  10643. + DPRINTK("real LCDtiming0 = 0x%08x\n", LCD->timing0);
  10644. + DPRINTK("real LCDtiming1 = 0x%08x\n", LCD->timing1);
  10645. + DPRINTK("real LCDtiming2 = 0x%08x\n", LCD->timing2);
  10646. + DPRINTK("real LCDtiming3 = 0x%08x\n", LCD->timing3);
  10647. + DPRINTK("real LCDcontrol = 0x%08x\n", LCD->control);
  10648. + DPRINTK("real LCDICPsetup = 0x%08x\n", LCDICP->setup);
  10649. + DPRINTK("real LCDICPcontrol = 0x%08x\n", LCDICP->control);
  10650. + DPRINTK("real LCDICPtiming1 = 0x%08x\n", LCDICP->timing1);
  10651. + DPRINTK("real LCDICPtiming2 = 0x%08x\n", LCDICP->timing2);
  10652. +}
  10653. +
  10654. +
  10655. +static void
  10656. +pl110fb_disable_controller(struct pl110fb_info *fbi)
  10657. +{
  10658. + lcdRegs_t *LCD = (lcdRegs_t *)IO_ADDRESS(LCD_PHYS);
  10659. + lcdicpRegs_t *LCDICP = (lcdicpRegs_t *)IO_ADDRESS(LCDICP_PHYS);
  10660. +
  10661. +#if defined(CONFIG_ARCH_LH79520) || defined(CONFIG_ARCH_LH7A400)
  10662. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  10663. +#endif
  10664. +
  10665. + DECLARE_WAITQUEUE(wait, current);
  10666. +
  10667. + DPRINTK("Disabling LCD controller\n");
  10668. +
  10669. + add_wait_queue(&fbi->ctrlr_wait, &wait);
  10670. + set_current_state(TASK_UNINTERRUPTIBLE);
  10671. +
  10672. + LCD->intrEnable |= LCD_STATUS_VCOMP; /* allow VCOMP interrupts */
  10673. +
  10674. + /* turn off LCD power, wait a bit, then disable the controller */
  10675. + LCD->control &= ~LCD_CTRL_PWR;
  10676. +
  10677. + set_current_state(TASK_UNINTERRUPTIBLE);
  10678. + schedule_timeout(20 * HZ / 1000);
  10679. +
  10680. + LCD->control = 0;
  10681. + LCDICP->control = 0;
  10682. +
  10683. +#if defined(CONFIG_ARCH_LH79520) || defined(CONFIG_ARCH_LH7A400)
  10684. + cpld->lcd_pwr_cntl &= ~CPLD_LCD_OE;
  10685. +#endif
  10686. +
  10687. + schedule_timeout(20 * HZ / 1000);
  10688. + current->state = TASK_RUNNING;
  10689. + remove_wait_queue(&fbi->ctrlr_wait, &wait);
  10690. +}
  10691. +
  10692. +
  10693. +/*
  10694. + * pl110fb_handle_irq: Handle 'LCD DONE' interrupts.
  10695. + */
  10696. +static void
  10697. +pl110fb_handle_irq(int irq, void *dev_id, struct pt_regs *regs)
  10698. +{
  10699. + struct pl110fb_info *fbi = dev_id;
  10700. + lcdRegs_t *LCD = (lcdRegs_t *)IO_ADDRESS(LCD_PHYS);
  10701. +
  10702. + unsigned int intr = LCD->maskedIntrStatus;
  10703. +
  10704. + DPRINTK("IRQ: status=0x%x\n", intr);
  10705. +
  10706. + if( intr & LCD_STATUS_VCOMP) { /* vertical compare interrupt */
  10707. + LCD->intrEnable = 0; /* only want one interrupt */
  10708. + wake_up(&fbi->ctrlr_wait);
  10709. + }
  10710. +
  10711. + LCD->rawIntrStatus = 0; /* clear interrupt */
  10712. +}
  10713. +
  10714. +/*
  10715. + * This function must be called from task context only, since it will
  10716. + * sleep when disabling the LCD controller, or if we get two contending
  10717. + * processes trying to alter state.
  10718. + */
  10719. +static void
  10720. +set_ctrlr_state(struct pl110fb_info *fbi, u_int state)
  10721. +{
  10722. + u_int old_state;
  10723. +
  10724. + down(&fbi->ctrlr_sem);
  10725. +
  10726. + old_state = fbi->state;
  10727. +
  10728. + switch (state) {
  10729. + case C_DISABLE_CLKCHANGE:
  10730. + /*
  10731. + * Disable controller for clock change. If the
  10732. + * controller is already disabled, then do nothing.
  10733. + */
  10734. + if (old_state != C_DISABLE && old_state != C_DISABLE_PM) {
  10735. + fbi->state = state;
  10736. + pl110fb_disable_controller(fbi);
  10737. + }
  10738. + break;
  10739. +
  10740. + case C_DISABLE_PM:
  10741. + case C_DISABLE:
  10742. + /*
  10743. + * Disable controller
  10744. + */
  10745. + if (old_state != C_DISABLE) {
  10746. + fbi->state = state;
  10747. +
  10748. + pl110fb_backlight_off(fbi);
  10749. + if (old_state != C_DISABLE_CLKCHANGE)
  10750. + pl110fb_disable_controller(fbi);
  10751. + pl110fb_power_down_lcd(fbi);
  10752. + }
  10753. + break;
  10754. +
  10755. + case C_ENABLE_CLKCHANGE:
  10756. + /*
  10757. + * Enable the controller after clock change. Only
  10758. + * do this if we were disabled for the clock change.
  10759. + */
  10760. + if (old_state == C_DISABLE_CLKCHANGE) {
  10761. + fbi->state = C_ENABLE;
  10762. + pl110fb_enable_controller(fbi);
  10763. + }
  10764. + break;
  10765. +
  10766. + case C_REENABLE:
  10767. + /*
  10768. + * Re-enable the controller only if it was already
  10769. + * enabled. This is so we reprogram the control
  10770. + * registers.
  10771. + */
  10772. + if (old_state == C_ENABLE) {
  10773. + pl110fb_disable_controller(fbi);
  10774. + pl110fb_setup_hw(fbi);
  10775. + pl110fb_enable_controller(fbi);
  10776. + }
  10777. + break;
  10778. +
  10779. + case C_ENABLE_PM:
  10780. + /*
  10781. + * Re-enable the controller after PM. This is not
  10782. + * perfect - think about the case where we were doing
  10783. + * a clock change, and we suspended half-way through.
  10784. + */
  10785. + if (old_state != C_DISABLE_PM)
  10786. + break;
  10787. + /* fall through */
  10788. +
  10789. + case C_ENABLE:
  10790. + /*
  10791. + * Power up the LCD screen, enable controller, and
  10792. + * turn on the backlight.
  10793. + */
  10794. + if (old_state != C_ENABLE) {
  10795. + fbi->state = C_ENABLE;
  10796. + pl110fb_setup_hw(fbi);
  10797. + pl110fb_power_up_lcd(fbi);
  10798. + pl110fb_enable_controller(fbi);
  10799. + pl110fb_backlight_on(fbi);
  10800. + }
  10801. + break;
  10802. + }
  10803. + up(&fbi->ctrlr_sem);
  10804. +}
  10805. +
  10806. +
  10807. +/*
  10808. + * Our LCD controller task (which is called when we blank or unblank)
  10809. + * via keventd.
  10810. + */
  10811. +static void
  10812. +pl110fb_task(void *dummy)
  10813. +{
  10814. + struct pl110fb_info *fbi = dummy;
  10815. + u_int state = xchg(&fbi->task_state, -1);
  10816. +
  10817. + set_ctrlr_state(fbi, state);
  10818. +}
  10819. +
  10820. +#ifdef CONFIG_CPU_FREQ
  10821. +/*
  10822. + * Calculate the minimum DMA period over all displays that we own.
  10823. + * This, together with the SDRAM bandwidth defines the slowest CPU
  10824. + * frequency that can be selected.
  10825. + */
  10826. +static unsigned int
  10827. +pl110fb_min_dma_period(struct pl110fb_info *fbi)
  10828. +{
  10829. + unsigned int min_period = (unsigned int)-1;
  10830. + int i;
  10831. +
  10832. + for (i = 0; i < MAX_NR_CONSOLES; i++) {
  10833. + unsigned int period;
  10834. +
  10835. + /*
  10836. + * Do we own this display?
  10837. + */
  10838. + if (fb_display[i].fb_info != &fbi->fb)
  10839. + continue;
  10840. +
  10841. + /*
  10842. + * Ok, calculate its DMA period
  10843. + */
  10844. + period = pl110fb_display_dma_period(get_con_var(&fbi->fb, i));
  10845. + if (period < min_period)
  10846. + min_period = period;
  10847. + }
  10848. +
  10849. + return min_period;
  10850. +}
  10851. +
  10852. +/*
  10853. + * CPU clock speed change handler. We need to adjust the LCD timing
  10854. + * parameters when the CPU clock is adjusted by the power management
  10855. + * subsystem.
  10856. + */
  10857. +static int
  10858. +pl110fb_clkchg_notifier(struct notifier_block *nb, unsigned long val,
  10859. + void *data)
  10860. +{
  10861. + struct pl110fb_info *fbi = TO_INF(nb, clockchg);
  10862. + struct cpufreq_minmax *mm = data;
  10863. + u_int pcd;
  10864. +
  10865. + switch (val) {
  10866. + case CPUFREQ_MINMAX:
  10867. + printk(KERN_DEBUG "min dma period: %d ps, old clock %d kHz, "
  10868. + "new clock %d kHz\n", pl110fb_min_dma_period(fbi),
  10869. + mm->cur_freq, mm->new_freq);
  10870. + /* todo: fill in min/max values */
  10871. + break;
  10872. +
  10873. + case CPUFREQ_PRECHANGE:
  10874. + set_ctrlr_state(fbi, C_DISABLE_CLKCHANGE);
  10875. + break;
  10876. +
  10877. + case CPUFREQ_POSTCHANGE:
  10878. + pcd = get_pcd(fbi->fb.var.pixclock);
  10879. + fbi->reg_lccr3 = (fbi->reg_lccr3 & ~0xff) | LCCR3_PixClkDiv(pcd); // DDD
  10880. + set_ctrlr_state(fbi, C_ENABLE_CLKCHANGE);
  10881. + break;
  10882. + }
  10883. + return 0;
  10884. +}
  10885. +#endif
  10886. +
  10887. +#ifdef CONFIG_PM
  10888. +/*
  10889. + * Power management hook. Note that we won't be called from IRQ context,
  10890. + * unlike the blank functions above, so we may sleep.
  10891. + */
  10892. +static int
  10893. +pl110fb_pm_callback(struct pm_dev *pm_dev, pm_request_t req, void *data)
  10894. +{
  10895. + struct pl110fb_info *fbi = pm_dev->data;
  10896. +
  10897. + DPRINTK("pm_callback: %d\n", req);
  10898. +
  10899. + if (req == PM_SUSPEND || req == PM_RESUME) {
  10900. + int state = (int)data;
  10901. +
  10902. + if (state == 0) {
  10903. + /* Enter D0. */
  10904. + set_ctrlr_state(fbi, C_ENABLE_PM);
  10905. + } else {
  10906. + /* Enter D1-D3. Disable the LCD controller. */
  10907. + set_ctrlr_state(fbi, C_DISABLE_PM);
  10908. + }
  10909. + }
  10910. + DPRINTK("done\n");
  10911. + return 0;
  10912. +}
  10913. +#endif
  10914. +
  10915. +/*
  10916. + * pl110fb_map_video_memory():
  10917. + * Allocates the DRAM memory for the frame buffer. This buffer is
  10918. + * remapped into a non-cached, non-buffered, memory region to
  10919. + * allow palette and pixel writes to occur without flushing the
  10920. + * cache. Once this area is remapped, all virtual memory
  10921. + * access to the video memory should occur at the new region.
  10922. + */
  10923. +static int __init
  10924. +pl110fb_map_video_memory(struct pl110fb_info *fbi)
  10925. +{
  10926. + /*
  10927. + * We reserve one page for the palette, plus the size
  10928. + * of the framebuffer.
  10929. + */
  10930. + fbi->map_size = PAGE_ALIGN(fbi->fb.fix.smem_len);
  10931. + fbi->map_cpu = consistent_alloc(GFP_KERNEL, fbi->map_size,
  10932. + &fbi->map_dma);
  10933. +
  10934. + if (fbi->map_cpu) {
  10935. + fbi->screen_cpu = fbi->map_cpu;
  10936. + fbi->screen_dma = fbi->map_dma;
  10937. + fbi->fb.fix.smem_start = fbi->screen_dma;
  10938. + }
  10939. +
  10940. + DPRINTK( "fix.smem_len = %d map_cpu = 0x%x screen_cpu = 0x%x screen_dma = 0x%x\n",
  10941. + fbi->fb.fix.smem_len, fbi->map_cpu, fbi->screen_cpu, fbi->screen_dma);
  10942. +
  10943. + return fbi->map_cpu ? 0 : -ENOMEM;
  10944. +}
  10945. +
  10946. +/* Fake monspecs to fill in fbinfo structure */
  10947. +static struct fb_monspecs monspecs __initdata = {
  10948. + 30000, 70000, 50, 65, 0 /* Generic */
  10949. +};
  10950. +
  10951. +
  10952. +static struct pl110fb_info * __init
  10953. +pl110fb_init_fbinfo(void)
  10954. +{
  10955. + struct pl110fb_mach_info *inf;
  10956. + struct pl110fb_info *fbi;
  10957. + int pixelsPerSecond;
  10958. +
  10959. + fbi = kmalloc(sizeof(struct pl110fb_info) + sizeof(struct display) +
  10960. + sizeof(u16) * 16, GFP_KERNEL);
  10961. + if (!fbi)
  10962. + return NULL;
  10963. +
  10964. + memset(fbi, 0, sizeof(struct pl110fb_info) + sizeof(struct display));
  10965. +
  10966. + fbi->currcon = -1;
  10967. +
  10968. + strcpy(fbi->fb.fix.id, PL110_NAME);
  10969. +
  10970. + fbi->fb.fix.type = FB_TYPE_PACKED_PIXELS;
  10971. + fbi->fb.fix.type_aux = 0;
  10972. + fbi->fb.fix.xpanstep = 0;
  10973. + fbi->fb.fix.ypanstep = 0;
  10974. + fbi->fb.fix.ywrapstep = 0;
  10975. + fbi->fb.fix.accel = FB_ACCEL_NONE;
  10976. +
  10977. + fbi->fb.var.nonstd = 0;
  10978. + fbi->fb.var.activate = FB_ACTIVATE_NOW;
  10979. + fbi->fb.var.height = -1;
  10980. + fbi->fb.var.width = -1;
  10981. + fbi->fb.var.accel_flags = 0;
  10982. + fbi->fb.var.vmode = FB_VMODE_NONINTERLACED;
  10983. +
  10984. + strcpy(fbi->fb.modename, PL110_NAME);
  10985. + strcpy(fbi->fb.fontname, "Acorn8x8");
  10986. +
  10987. + fbi->fb.fbops = &pl110fb_ops;
  10988. + fbi->fb.changevar = NULL;
  10989. + fbi->fb.switch_con = pl110fb_switch;
  10990. + fbi->fb.updatevar = pl110fb_updatevar;
  10991. + fbi->fb.blank = pl110fb_blank;
  10992. + fbi->fb.flags = FBINFO_FLAG_DEFAULT;
  10993. + fbi->fb.node = -1;
  10994. + fbi->fb.monspecs = monspecs;
  10995. + fbi->fb.disp = (struct display *)(fbi + 1);
  10996. + fbi->fb.pseudo_palette = (void *)(fbi->fb.disp + 1);
  10997. +
  10998. + fbi->rgb[RGB_8] = &rgb_8;
  10999. + fbi->rgb[RGB_16] = &def_rgb_16;
  11000. +
  11001. + inf = pl110fb_get_machine_info(fbi);
  11002. +
  11003. + /*
  11004. + * Calculate pixclock. pixclock is the time in picoseconds spent
  11005. + * drawing a pixel. The time (in seconds) to draw a pixel is
  11006. + * the inverse of how many pixels we draw in a second (pixelsPerSecond).
  11007. + *
  11008. + * pixelsPerSecond is xres*yres*refresh, plus all the overhead time
  11009. + * (horizontal and vertical front and back porches, plus horizontal
  11010. + * and vertical sync lengths).
  11011. + *
  11012. + *
  11013. + */
  11014. + pixelsPerSecond =
  11015. + (inf->xres + inf->hsync_len + inf->left_margin + inf->right_margin) *
  11016. + (inf->yres + inf->vsync_len + inf->upper_margin + inf->lower_margin) *
  11017. + VERTICAL_REFRESH;
  11018. +
  11019. + inf->pixclock = 1000000000 / (pixelsPerSecond / 1000);
  11020. +
  11021. + DPRINTK( "pixelsPerSecond=%d pixclock=%d\n", pixelsPerSecond, inf->pixclock);
  11022. +
  11023. +
  11024. + fbi->max_xres = inf->xres;
  11025. + fbi->fb.var.xres = inf->xres;
  11026. + fbi->fb.var.xres_virtual = inf->xres;
  11027. + fbi->max_yres = inf->yres;
  11028. + fbi->fb.var.yres = inf->yres;
  11029. + fbi->fb.var.yres_virtual = inf->yres;
  11030. + fbi->max_bpp = inf->bpp;
  11031. + fbi->fb.var.bits_per_pixel = inf->bpp;
  11032. + fbi->fb.var.pixclock = inf->pixclock;
  11033. + fbi->fb.var.hsync_len = inf->hsync_len;
  11034. + fbi->fb.var.left_margin = inf->left_margin;
  11035. + fbi->fb.var.right_margin = inf->right_margin;
  11036. + fbi->fb.var.vsync_len = inf->vsync_len;
  11037. + fbi->fb.var.upper_margin = inf->upper_margin;
  11038. + fbi->fb.var.lower_margin = inf->lower_margin;
  11039. + fbi->fb.var.sync = inf->sync;
  11040. + fbi->fb.var.grayscale = inf->cmap_greyscale;
  11041. + fbi->cmap_inverse = inf->cmap_inverse;
  11042. + fbi->cmap_static = inf->cmap_static;
  11043. + fbi->LCDtiming2 = inf->LCDtiming2;
  11044. + fbi->LCDtiming3 = inf->LCDtiming3;
  11045. + fbi->LCDcontrol = inf->LCDcontrol;
  11046. + fbi->LCDICPsetup = inf->LCDICPsetup;
  11047. + fbi->LCDICPcontrol = inf->LCDICPcontrol;
  11048. + fbi->LCDICPtiming1 = inf->LCDICPtiming1;
  11049. + fbi->LCDICPtiming2 = inf->LCDICPtiming2;
  11050. + fbi->state = C_DISABLE;
  11051. + fbi->task_state = (u_char)-1;
  11052. + fbi->fb.fix.smem_len = fbi->max_xres * fbi->max_yres *
  11053. + fbi->max_bpp / 8;
  11054. +
  11055. + init_waitqueue_head(&fbi->ctrlr_wait);
  11056. + INIT_TQUEUE(&fbi->task, pl110fb_task, fbi);
  11057. + init_MUTEX(&fbi->ctrlr_sem);
  11058. +
  11059. + return fbi;
  11060. +}
  11061. +
  11062. +int __init
  11063. +pl110fb_init(void)
  11064. +{
  11065. + struct pl110fb_info *fbi;
  11066. + int ret;
  11067. +
  11068. + DPRINTK( "\n\npl110fb_init\n");
  11069. +
  11070. + DPRINTK( "cpu clock = %d HCLK = %d\n", cpufreq_get(0), hclkfreq_get());
  11071. +
  11072. + fbi = pl110fb_init_fbinfo();
  11073. + ret = -ENOMEM;
  11074. + if (!fbi)
  11075. + goto failed;
  11076. +
  11077. + /* Initialize video memory */
  11078. + ret = pl110fb_map_video_memory(fbi);
  11079. + if (ret)
  11080. + goto failed;
  11081. +
  11082. + ret = request_irq(IRQ_LCD, pl110fb_handle_irq, SA_INTERRUPT,
  11083. + fbi->fb.fix.id, fbi);
  11084. + if (ret) {
  11085. + printk(KERN_ERR "pl110fb: request_irq failed: ret=%d\n", ret);
  11086. + goto failed;
  11087. + }
  11088. +
  11089. + pl110fb_set_var(&fbi->fb.var, -1, &fbi->fb);
  11090. +
  11091. + ret = register_framebuffer(&fbi->fb);
  11092. + if (ret < 0)
  11093. + goto failed;
  11094. +
  11095. +#ifdef CONFIG_PM
  11096. + /*
  11097. + * Note that the console registers this as well, but we want to
  11098. + * power down the display prior to sleeping.
  11099. + */
  11100. + fbi->pm = pm_register(PM_SYS_DEV, PM_SYS_VGA, pl110fb_pm_callback);
  11101. + if (fbi->pm)
  11102. + fbi->pm->data = fbi;
  11103. +#endif
  11104. +#ifdef CONFIG_CPU_FREQ
  11105. + fbi->clockchg.notifier_call = pl110fb_clkchg_notifier;
  11106. + cpufreq_register_notifier(&fbi->clockchg);
  11107. +#endif
  11108. +
  11109. + /*
  11110. + * Ok, now enable the LCD controller
  11111. + */
  11112. + set_ctrlr_state(fbi, C_ENABLE);
  11113. +
  11114. + /* This driver cannot be unloaded at the moment */
  11115. + MOD_INC_USE_COUNT;
  11116. +
  11117. + return 0;
  11118. +
  11119. +failed:
  11120. + if (fbi)
  11121. + kfree(fbi);
  11122. + return ret;
  11123. +}
  11124. +
  11125. +int __init
  11126. +pl110fb_setup(char *options)
  11127. +{
  11128. + return 0;
  11129. +}
  11130. +
  11131. +MODULE_DESCRIPTION("ARM PL110 framebuffer driver");
  11132. +MODULE_LICENSE("GPL");
  11133. +
  11134. diff -urN linux-2.4.26/drivers/video/pl110fb.h linux-2.4.26-vrs1-lnode80/drivers/video/pl110fb.h
  11135. --- linux-2.4.26/drivers/video/pl110fb.h 1969-12-31 20:00:00.000000000 -0400
  11136. +++ linux-2.4.26-vrs1-lnode80/drivers/video/pl110fb.h 2005-11-02 17:37:32.000000000 -0400
  11137. @@ -0,0 +1,350 @@
  11138. +/*
  11139. + * linux/drivers/video/pl110fb.h
  11140. + * -- ARM PrimeCell PL110 LCD controller frame buffer device
  11141. + *
  11142. + * Copyright (C) 2002 Lineo, Inc.
  11143. + *
  11144. + * Portions Copyright (C) 2001 Sharp Microelectronics of the Americas, Inc.
  11145. + * CAMAS, WA
  11146. + *
  11147. + * based in part on sa1100fb.h, which is Copyright (C) Eric A. Thomas
  11148. + *
  11149. + * This file is subject to the terms and conditions of the GNU General Public
  11150. + * License. See the file COPYING in the main directory of this archive
  11151. + * for more details.
  11152. + */
  11153. +
  11154. +/*
  11155. + * Color LCD Controller registers
  11156. + */
  11157. +typedef struct {
  11158. + volatile u32 timing0; /* Horizontal axis panel control */
  11159. + volatile u32 timing1; /* Vertical axis panel control */
  11160. + volatile u32 timing2; /* clock and signal polarity control */
  11161. + volatile u32 timing3; /* line end control */
  11162. + volatile dma_addr_t upbase; /* upper panel frame base address */
  11163. + volatile dma_addr_t lpbase; /* lower panel frame base address */
  11164. + volatile u32 intrEnable; /* interrupt enable mask */
  11165. + volatile u32 control; /* LCD panel pixel parameters */
  11166. + volatile u32 rawIntrStatus; /* raw interrupt status */
  11167. + volatile u32 maskedIntrStatus; /* masked interrupt status */
  11168. + volatile dma_addr_t upcurr; /* upper panel current address */
  11169. + volatile dma_addr_t lpcurr; /* lower panel current address */
  11170. + volatile dma_addr_t lpoverflow; /* SDRAM fb base */
  11171. + volatile u32 reservedcc[115]; /* reserved */
  11172. + volatile u32 palette[128]; /* 256 x 16-bit color palette */
  11173. +} lcdRegs_t;
  11174. +
  11175. +
  11176. +/*
  11177. + * LCDTiming0 Register Bit Field constants
  11178. + *
  11179. + * NOTE: Ensure the argument to the following macros is greater
  11180. + * than zero.
  11181. + */
  11182. +#define LCD_TIMING0_HBP(n) _SBF(24,((n)-1)) /* Horiz Back Porch */
  11183. +#define LCD_TIMING0_HFP(n) _SBF(16,((n)-1)) /* Horiz Front Porch */
  11184. +#define LCD_TIMING0_HSW(n) _SBF(8,((n)-1)) /* Horiz sync Pulse Width */
  11185. +#define LCD_TIMING0_PPL(n) _SBF(2,((((n)/16)-1)&0x3F)) /* Pixels per line */
  11186. +
  11187. +/*
  11188. + * LCDTiming1 Register Bit Field constants
  11189. + *
  11190. + * NOTE: Ensure the argument to the following macros is greater
  11191. + * than zero.
  11192. + */
  11193. +#define LCD_TIMING1_VBP(n) _SBF(24,(n)) /* Vertical Back Porch */
  11194. +#define LCD_TIMING1_VFP(n) _SBF(16,(n)) /* Vertical Front Porch */
  11195. +#define LCD_TIMING1_VSW(n) _SBF(10,(n)) /* Vertical Synchronization Pulse */
  11196. +#define LCD_TIMING1_LPP(n) _SBF(0,((n)-1)) /* Lines per Panel */
  11197. +
  11198. +/*
  11199. + * LCDTiming2 Register Bit Field constants
  11200. + *
  11201. + * NOTE: Ensure the argument to the following macros is greater
  11202. + * than two.
  11203. + */
  11204. +#define LCD_TIMING2_BCD _BIT(26) /* Bypass Pixel Clock Divider */
  11205. +#define LCD_TIMING2_CPL(n) _SBF(16,((n)-1)&0x3FF) /* Clocks Per Line */
  11206. +#define LCD_TIMING2_IOE _BIT(14) /* Invert Output Enable */
  11207. +#define LCD_TIMING2_IPC _BIT(13) /* Invert Panel Clock */
  11208. +#define LCD_TIMING2_IHS _BIT(12) /* Invert Horizontal Synchronization */
  11209. + /* set == HSYNC is active low */
  11210. +#define LCD_TIMING2_IVS _BIT(11) /* Invert Vertical Synchronization */
  11211. + /* set == VSYNC is active low */
  11212. +#define LCD_TIMING2_ACB(n) _SBF(6,((n)-1)) /* AC Bias Pin Frequency */
  11213. +#define LCD_TIMING2_CLKSEL _BIT(5) /* Clock Selector */
  11214. +#define LCD_TIMING2_PCD(n) _SBF(0,((n)-2)) /* Panel Clock Divisor */
  11215. +
  11216. +
  11217. +/*
  11218. + * LCDTiming3 Register Bit Field constants
  11219. + *
  11220. + * NOTE: Ensure the argument to the following macros is greater
  11221. + * than one.
  11222. + */
  11223. +#define LCD_TIMING3_LEE _BIT(16) /* Line End Enable */
  11224. +#define LCD_TIMING3_LED(n) _SBF(0,((n)-1)) /* Line End Signal Delay */
  11225. +
  11226. +
  11227. +/*
  11228. + * intrEnable, rawIntrStatus, maskedIntrStatus bit field positions
  11229. + */
  11230. +#define LCD_STATUS_MBERROR _BIT(4) /* Master Bus Error */
  11231. +#define LCD_STATUS_VCOMP _BIT(3) /* Vertical Compare */
  11232. +#define LCD_STATUS_LNBU _BIT(2) /* LCD Next addr. Base Update*/
  11233. +#define LCD_STATUS_FUF _BIT(1) /* FIFO underflow */
  11234. +
  11235. +
  11236. +/*
  11237. + * Control Register Bit Field constants
  11238. + */
  11239. +#define LCD_CTRL_WATERMARK _BIT(16) /* LCD DMA FIFO Watermark Level */
  11240. +#define LCD_CTRL_LDMAFIFOTME _BIT(15) /* LCD DMA FIFO Test Mode Enable */
  11241. +
  11242. +#define LCD_CTRL_VCOMP(n) _SBF(12,((n)&0x3)) /* Generate interrupt at: */
  11243. +#define LCD_CTRL_VCOMP_SVS _SBF(12,0) /* start of vertical sync */
  11244. +#define LCD_CTRL_VCOMP_SBP _SBF(12,1) /* start of back porch */
  11245. +#define LCD_CTRL_VCOMP_SAV _SBF(12,2) /* start of active video */
  11246. +#define LCD_CTRL_VCOMP_SFP _SBF(12,3) /* start of front porch */
  11247. +
  11248. +#define LCD_CTRL_PWR _BIT(11) /* LCD Power Enable */
  11249. +#define LCD_CTRL_BEPO _BIT(10) /* Big Endian Pixel Order */
  11250. +#define LCD_CTRL_BEBO _BIT(9) /* Big Endian Byte Order */
  11251. +#define LCD_CTRL_BGR _BIT(8) /* Swap Red and Blue (RGB to BGR) */
  11252. +#define LCD_CTRL_DUAL _BIT(7) /* Dual Panel STN */
  11253. +#define LCD_CTRL_MON8 _BIT(6) /* Monochrome LCD has 8-bit interface */
  11254. +#define LCD_CTRL_TFT _BIT(5) /* TFT LCD */
  11255. +
  11256. +#define LCD_CTRL_BW_COLOR _SBF(4,0) /* STN LCD is Color */
  11257. +#define LCD_CTRL_BW_MONO _SBF(4,1) /* STN LCD is Monochrome */
  11258. +
  11259. +#define LCD_CTRL_BPP1 _SBF(1,0) /* Bits per pixel */
  11260. +#define LCD_CTRL_BPP2 _SBF(1,1)
  11261. +#define LCD_CTRL_BPP4 _SBF(1,2)
  11262. +#define LCD_CTRL_BPP8 _SBF(1,3)
  11263. +#define LCD_CTRL_BPP16 _SBF(1,4)
  11264. +#define LCD_CTRL_BPP24 _SBF(1,5)
  11265. +
  11266. +#define LCD_CTRL_ENABLE _BIT(0) /* LCD Controller Enable */
  11267. +
  11268. +
  11269. +
  11270. +typedef struct {
  11271. + volatile u32 setup; /* Setup */
  11272. + volatile u32 control; /* Control */
  11273. + volatile u32 timing1; /* HR-TFT Timing 1 */
  11274. + volatile u32 timing2; /* HR-TFT Timing 2 */
  11275. +} lcdicpRegs_t;
  11276. +
  11277. +
  11278. +
  11279. +/*
  11280. + * LCDICP Setup Register Bit Fields
  11281. + *
  11282. + * NOTE: Ensure the argument to the following macros is greater
  11283. + * than zero.
  11284. + */
  11285. +#define LCDICP_SETUP_MODE_BYPASS _SBF(0,0)
  11286. +#define LCDICP_SETUP_MODE_HRTFT _SBF(0,1)
  11287. +#define LCDICP_SETUP_MODE_DMTN _SBF(0,2)
  11288. +#define LCDICP_SETUP_HORIZ_REVERSE _SBF(2,0)
  11289. +#define LCDICP_SETUP_HORIZ_NORMAL _SBF(2,1)
  11290. +#define LCDICP_SETUP_VERT_REVERSE _SBF(3,0)
  11291. +#define LCDICP_SETUP_VERT_NORMAL _SBF(3,1)
  11292. +/* Calculates bit field value from actual pixels per line */
  11293. +#define LCDICP_SETUP_PPL(n) _SBF(4,((n)-1))
  11294. +#define LCDICP_SETUP_POWER _BIT(13) /* lh7a400 only */
  11295. +
  11296. +
  11297. +/*
  11298. + * LCDICP Control Register Bit Fields
  11299. + */
  11300. +#define LCDICP_CONTROL_SPSEN _BIT(0)
  11301. +#define LCDICP_CONTROL_CLSEN _BIT(1)
  11302. +#define LCDICP_CONTROL_UBLEN _BIT(2)
  11303. +#define LCDICP_CONTROL_DISP _BIT(3)
  11304. +#define LCDICP_CONTROL_EN0 _BIT(4)
  11305. +#define LCDICP_CONTROL_EN1 _BIT(5)
  11306. +#define LCDICP_CONTROL_EN2 _BIT(6)
  11307. +#define LCDICP_CONTROL_EN3 _BIT(7)
  11308. +
  11309. +
  11310. +/*
  11311. + * LCDICP Timing 1 Register Bit Fields
  11312. + *
  11313. + * NOTE: Ensure the argument to the following macros is greater
  11314. + * than zero.
  11315. + */
  11316. +#define LCDICP_TIMING1_LPDEL(n) _SBF(0,((n)-1)&0xF)
  11317. +#define LCDICP_TIMING1_REVDEL(n) _SBF(4,((n)-1)&0xF)
  11318. +#define LCDICP_TIMING1_PSDEL(n) _SBF(8,((n)-1)&0xF)
  11319. +#define LCDICP_TIMING1_CLSDEL(n) _SBF(8,((n)-1)&0xF)
  11320. +
  11321. +
  11322. +/*
  11323. + * LCDICP Timing 2 Register Bit Fields
  11324. + *
  11325. + * NOTE: Ensure the argument to the following macros is greater
  11326. + * than zero.
  11327. + */
  11328. +#define LCDICP_TIMING2_PSDEL2(n) _SBF(0,((n)-1)&0x1FF)
  11329. +#define LCDICP_TIMING2_CLSDEL2(n) _SBF(0,((n)-1)&0x1FF)
  11330. +#define LCDICP_TIMING2_SPLVALUE(n) _SBF(9,((n)-1)&0x7F)
  11331. +
  11332. +
  11333. +/*
  11334. + * These are the bitfields for each
  11335. + * display depth that we support.
  11336. + */
  11337. +struct pl110fb_rgb {
  11338. + struct fb_bitfield red;
  11339. + struct fb_bitfield green;
  11340. + struct fb_bitfield blue;
  11341. + struct fb_bitfield transp;
  11342. +};
  11343. +
  11344. +/*
  11345. + * This structure describes the machine which we are running on.
  11346. + */
  11347. +struct pl110fb_mach_info {
  11348. + u_long pixclock;
  11349. +
  11350. + u_short xres;
  11351. + u_short yres;
  11352. +
  11353. + u_char bpp;
  11354. + u_char hsync_len; /* horiz sync pulse width */
  11355. + u_char left_margin; /* horiz back porch */
  11356. + u_char right_margin; /* horiz front porch */
  11357. +
  11358. + u_char vsync_len; /* vertical sync pulse width */
  11359. + u_char upper_margin; /* vertical back porch */
  11360. + u_char lower_margin; /* vertical front porch */
  11361. + u_char sync;
  11362. +
  11363. + u_int cmap_greyscale:1,
  11364. + cmap_inverse:1,
  11365. + cmap_static:1,
  11366. + unused:29;
  11367. +
  11368. + u_long LCDtiming2;
  11369. + u_long LCDtiming3;
  11370. + u_long LCDcontrol;
  11371. + u_long LCDICPsetup;
  11372. + u_long LCDICPcontrol;
  11373. + u_long LCDICPtiming1;
  11374. + u_long LCDICPtiming2;
  11375. +};
  11376. +
  11377. +
  11378. +/* Shadows for LCD/LCDICP controller registers */
  11379. +struct pl110fb_lcd_reg {
  11380. + u_long LCDtiming0;
  11381. + u_long LCDtiming1;
  11382. + u_long LCDtiming2;
  11383. + u_long LCDtiming3;
  11384. + u_long LCDcontrol;
  11385. + u_long LCDICPsetup;
  11386. + u_long LCDICPcontrol;
  11387. + u_long LCDICPtiming1;
  11388. + u_long LCDICPtiming2;
  11389. +};
  11390. +
  11391. +#define RGB_8 (0)
  11392. +#define RGB_16 (1)
  11393. +#define NR_RGB 2
  11394. +
  11395. +struct pl110fb_info {
  11396. + struct fb_info fb;
  11397. + signed int currcon;
  11398. +
  11399. + struct pl110fb_rgb *rgb[NR_RGB];
  11400. +
  11401. + u_int max_bpp;
  11402. + u_int max_xres;
  11403. + u_int max_yres;
  11404. +
  11405. + /*
  11406. + * These are the addresses we mapped
  11407. + * the framebuffer memory region to.
  11408. + */
  11409. + dma_addr_t map_dma;
  11410. + u_char * map_cpu;
  11411. + u_int map_size;
  11412. +
  11413. + u_char * screen_cpu;
  11414. + dma_addr_t screen_dma;
  11415. + u_int palette_size;
  11416. +
  11417. + dma_addr_t upbase;
  11418. + dma_addr_t lpbase;
  11419. +
  11420. + u_long LCDtiming2;
  11421. + u_long LCDtiming3;
  11422. + u_long LCDcontrol;
  11423. + u_long LCDICPsetup;
  11424. + u_long LCDICPcontrol;
  11425. + u_long LCDICPtiming1;
  11426. + u_long LCDICPtiming2;
  11427. +
  11428. + u_int cmap_inverse:1,
  11429. + cmap_static:1,
  11430. + unused:30;
  11431. +
  11432. + u_long reg_LCDtiming0;
  11433. + u_long reg_LCDtiming1;
  11434. + u_long reg_LCDtiming2;
  11435. + u_long reg_LCDtiming3;
  11436. + u_long reg_LCDcontrol;
  11437. + u_long reg_LCDICPsetup;
  11438. + u_long reg_LCDICPcontrol;
  11439. + u_long reg_LCDICPtiming1;
  11440. + u_long reg_LCDICPtiming2;
  11441. +
  11442. + volatile u_char state;
  11443. + volatile u_char task_state;
  11444. + struct semaphore ctrlr_sem;
  11445. + wait_queue_head_t ctrlr_wait;
  11446. + struct tq_struct task;
  11447. +
  11448. +#ifdef CONFIG_PM
  11449. + struct pm_dev *pm;
  11450. +#endif
  11451. +#ifdef CONFIG_CPU_FREQ
  11452. + struct notifier_block clockchg;
  11453. +#endif
  11454. +};
  11455. +
  11456. +#define __type_entry(ptr,type,member) ((type *)((char *)(ptr)-offsetof(type,member)))
  11457. +
  11458. +#define TO_INF(ptr,member) __type_entry(ptr,struct pl110fb_info,member)
  11459. +
  11460. +/*
  11461. + * These are the actions for set_ctrlr_state
  11462. + */
  11463. +#define C_DISABLE (0)
  11464. +#define C_ENABLE (1)
  11465. +#define C_DISABLE_CLKCHANGE (2)
  11466. +#define C_ENABLE_CLKCHANGE (3)
  11467. +#define C_REENABLE (4)
  11468. +#define C_DISABLE_PM (5)
  11469. +#define C_ENABLE_PM (6)
  11470. +
  11471. +#define PL110_NAME "PL110"
  11472. +
  11473. +/*
  11474. + * Debug macros
  11475. + */
  11476. +#if DEBUG
  11477. +# define DPRINTK(fmt, args...) printk("%s: " fmt, __FUNCTION__ , ## args)
  11478. +#else
  11479. +# define DPRINTK(fmt, args...)
  11480. +#endif
  11481. +
  11482. +/*
  11483. + * Minimum X and Y resolutions
  11484. + */
  11485. +#define MIN_XRES 64
  11486. +#define MIN_YRES 64
  11487. +
  11488. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/ads_784x.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/ads_784x.h
  11489. --- linux-2.4.26/include/asm-arm/arch-lh79520/ads_784x.h 1969-12-31 20:00:00.000000000 -0400
  11490. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/ads_784x.h 2005-11-02 17:37:32.000000000 -0400
  11491. @@ -0,0 +1,25 @@
  11492. +/* vi: set sw=4 ts=4 ai: */
  11493. +
  11494. +/*
  11495. +* linux/include/asm-arm/arch-lh79520/ads_784x.h
  11496. +*
  11497. +* Copyright (C) 2002 Lineo, Inc.
  11498. +*
  11499. +* Provide ADS_784x (touchscreen) types & definitions for LH7x EVB boards
  11500. +*
  11501. +*/
  11502. +
  11503. +#ifndef _ADS_784X_h
  11504. +#define _ADS_784X_h
  11505. +
  11506. +#include <asm-arm/arch-lh79520/ssp_lh7x.h>
  11507. +
  11508. +/*********************************************************************
  11509. +* Global Function Declarations
  11510. +*********************************************************************/
  11511. +extern int ads_784x_register(sspContext_t *sspContext);
  11512. +extern int ads_784x_deregister(void);
  11513. +
  11514. +
  11515. +#endif /* _ADS_784X_h */
  11516. +
  11517. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/cpld.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/cpld.h
  11518. --- linux-2.4.26/include/asm-arm/arch-lh79520/cpld.h 1969-12-31 20:00:00.000000000 -0400
  11519. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/cpld.h 2005-11-02 17:37:32.000000000 -0400
  11520. @@ -0,0 +1,138 @@
  11521. +/*
  11522. + * linux/include/asm-arm/arch-lh79520/cpld.h
  11523. + *
  11524. + * Copyright (C) 2002 Lineo, Inc.
  11525. + *
  11526. + * This program is free software; you can redistribute it and/or modify
  11527. + * it under the terms of the GNU General Public License version 2 as
  11528. + * published by the Free Software Foundation.
  11529. + *
  11530. + */
  11531. +
  11532. +#ifndef _LH79520_CPLD_H
  11533. +#define _LH79520_CPLD_H
  11534. +
  11535. +typedef __attribute((packed)) struct {
  11536. + volatile u16 keys_status;
  11537. + volatile u16 reserved1;
  11538. + volatile u16 l3_reg;
  11539. + volatile u16 reserved2;
  11540. + volatile u16 lcd_pwr_cntl;
  11541. + volatile u16 reserved3;
  11542. + volatile u16 l3_mode;
  11543. + volatile u16 reserved4;
  11544. + volatile u16 gpi;
  11545. + volatile u16 reserved5;
  11546. + volatile u16 gpo;
  11547. + volatile u16 reserved6;
  11548. + volatile u16 adc_dac_left;
  11549. + volatile u16 adc_dac_right;
  11550. + volatile u16 audio_control;
  11551. + volatile u16 reserved7;
  11552. + volatile u16 display_dip_sw;
  11553. + volatile u16 reserved8;
  11554. + volatile u16 seven_seg;
  11555. + volatile u16 reserved9;
  11556. + volatile u16 misc_stat;
  11557. + volatile u16 reserved10;
  11558. + volatile u16 gpio_data_dir;
  11559. + volatile u16 reserved11;
  11560. + volatile u16 ssp_dev_sel;
  11561. + volatile u16 reserved12;
  11562. + volatile u16 ser_port1_rts;
  11563. + volatile u16 reserved13;
  11564. + volatile u16 cf_reset;
  11565. + volatile u16 reserved14;
  11566. + volatile u16 cpu_dip_sw;
  11567. + volatile u16 reserved15;
  11568. + volatile u16 intr_mask;
  11569. + volatile u16 reserved16;
  11570. + volatile u16 reserved17;
  11571. + volatile u16 reserved18;
  11572. + volatile u16 reserved19;
  11573. + volatile u16 reserved20;
  11574. + volatile u16 reserved21;
  11575. + volatile u16 reserved22;
  11576. + volatile u16 nio_reg_clk;
  11577. + volatile u16 reserved23;
  11578. +} cpldRegs_t;
  11579. +
  11580. +
  11581. +/* LCD power bits */
  11582. +#define CPLD_EN26V _BIT(0) /* turn on the 26V supply */
  11583. +#define CPLD_BACKLIGHT_ON _BIT(1) /* turn on the backlight */
  11584. +#define CPLD_DISP_EN _BIT(2) /* note DISP_EN is not wired on the Sharp EVB display board */
  11585. +#define CPLD_LCD_OE _BIT(3) /* enable the LCD drive signals */
  11586. +#define CPLD_LCD_PWR _BIT(4)
  11587. +
  11588. +/*
  11589. + * enable the LCD 3.3V or 5V power supply;
  11590. + * does not effect HR-TFT power on the Sharp EVB display board.
  11591. + */
  11592. +#define CPLD_LCDP_EN _BIT(4)
  11593. +
  11594. +
  11595. +/* intr_mask bits */
  11596. +#define CPLD_TS_INTR_ENABLE _BIT(7) /* Enable touch screen IRQ */
  11597. +#define CPLD_CTS_INTR_ENABLE _BIT(6)
  11598. +#define CPLD_RI_INTR_ENABLE _BIT(5)
  11599. +
  11600. +/* misc_status bits */
  11601. +#define CPLD_MISCSTS_TS_IRQ _BIT(4) /* Touch Screen caused IRQ */
  11602. +#define CPLD_MISCSTS_TS_BUSY _BIT(5) /* Touch Screen busy */
  11603. +
  11604. +/* L3 mode bits */
  11605. +#if 0 // DDD
  11606. +#define CPLD_L3_MODE_HI (cpld->l3_mode |= _BIT(0))
  11607. +#define CPLD_L3_MODE_LOW (cpld->l3_mode |= ~(_BIT(0)))
  11608. +#else
  11609. +#define CPLD_L3_MODE_HI cpld->l3_mode = _BIT(0) ; barrier()
  11610. +#define CPLD_L3_MODE_LOW cpld->l3_mode = 0; barrier()
  11611. +#endif
  11612. +
  11613. +/* I2S audio control register bits */
  11614. +#define CPLD_DAC_USE_REQ1 _BIT(12)
  11615. +#define CPLD_ADC_DMA_ENABLE _BIT(7)
  11616. +#define CPLD_DAC_DMA_ENABLE _BIT(6)
  11617. +#define CPLD_ADC_DMA_AUTO _BIT(5)
  11618. +#define CPLD_DAC_DMA_AUTO _BIT(4)
  11619. +#define CPLD_ADC_IRQ_ENABLE _BIT(3)
  11620. +#define CPLD_DAC_IRQ_ENABLE _BIT(2)
  11621. +#define CPLD_ADC_IRQ_STATUS _BIT(1)
  11622. +#define CPLD_DAC_IRQ_STATUS _BIT(0)
  11623. +#define CPLD_AUDIO_DAC_INT_PENDING _BIT(0)
  11624. +#define CPLD_AUDIO_ADC_INT_PENDING _BIT(1)
  11625. +#define CPLD_AUDIO_DAC_INT_ENALBED _BIT(2)
  11626. +#define CPLD_AUDIO_ADC_INT_ENABLED _BIT(3)
  11627. +#define CPLD_AUDIO_DAC_INT_MASK \
  11628. + (CPLD_AUDIO_DAC_INT_PENDING | CPLD_AUDIO_DAC_INT_ENALBED)
  11629. +#define CPLD_AUDIO_ADC_INT_MASK \
  11630. + (CPLD_AUDIO_ADC_INT_PENDING | CPLD_AUDIO_ADC_INT_ENABLED)
  11631. +
  11632. +#define CPLD_ALL_ADC_BITS (CPLD_ADC_IRQ_STATUS | \
  11633. + CPLD_ADC_IRQ_ENABLE | \
  11634. + CPLD_ADC_DMA_AUTO | \
  11635. + CPLD_ADC_DMA_ENABLE)
  11636. +
  11637. +#define CPLD_ALL_DAC_BITS (CPLD_DAC_IRQ_STATUS | \
  11638. + CPLD_DAC_IRQ_ENABLE | \
  11639. + CPLD_DAC_DMA_AUTO | \
  11640. + CPLD_DAC_DMA_ENABLE | \
  11641. + CPLD_DAC_USE_REQ1)
  11642. +
  11643. +#define CPLD_ALL_AUDIO_BITS (CPLD_ALL_DAC_BITS | CPLD_ALL_DAC_BITS)
  11644. +
  11645. +#define CPLD_FS_BIT_FIELD 8
  11646. +#define CPLD_FS_BITS _SBF(CPLD_FS_BIT_FIELD, _BITMASK(4) );
  11647. +#define CPLD_FS_8000 0
  11648. +#define CPLD_FS_11025 1
  11649. +#define CPLD_FS_12000 2
  11650. +#define CPLD_FS_16000 3
  11651. +#define CPLD_FS_22050 4
  11652. +#define CPLD_FS_24000 5
  11653. +#define CPLD_FS_32000 6
  11654. +#define CPLD_FS_44100 7
  11655. +#define CPLD_FS_48000 8
  11656. +
  11657. +#endif // _LH79520_CPLD_H
  11658. +
  11659. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/dma.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/dma.h
  11660. --- linux-2.4.26/include/asm-arm/arch-lh79520/dma.h 1969-12-31 20:00:00.000000000 -0400
  11661. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/dma.h 2005-11-02 17:42:49.000000000 -0400
  11662. @@ -0,0 +1,63 @@
  11663. +/*
  11664. + * linux/include/asm-arm/arch-lh79520/dma.h
  11665. + *
  11666. + * Copyright (C) 2002 Lineo, Inc.
  11667. + *
  11668. + * This program is free software; you can redistribute it and/or modify
  11669. + * it under the terms of the GNU General Public License as published by
  11670. + * the Free Software Foundation; either version 2 of the License, or
  11671. + * (at your option) any later version.
  11672. + *
  11673. + * This program is distributed in the hope that it will be useful,
  11674. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11675. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11676. + * GNU General Public License for more details.
  11677. + *
  11678. + * You should have received a copy of the GNU General Public License
  11679. + * along with this program; if not, write to the Free Software
  11680. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  11681. + */
  11682. +#ifndef __ASM_ARCH_DMA_H
  11683. +#define __ASM_ARCH_DMA_H
  11684. +
  11685. +#include <asm/hardware.h>
  11686. +#include <asm/arch/cpld.h>
  11687. +
  11688. +#define MAX_DMA_ADDRESS 0xfffc0000
  11689. +
  11690. +#define MAX_DMA_CHANNELS 0
  11691. +#define LH79520_DMA_CHANNELS 4
  11692. +
  11693. +/*
  11694. + * All possible LH79520 devices a DMA channel can be attached to.
  11695. + */
  11696. +/* FIXME */
  11697. +
  11698. +typedef enum {
  11699. + DMA_SSP_Rx,
  11700. + DMA_SSP_Tx,
  11701. + DMA_Audio_Out,
  11702. + DMA_Audio_In
  11703. +} dma_device_t;
  11704. +
  11705. +
  11706. +typedef void (*dma_callback_t)( void *buf_id, int size );
  11707. +
  11708. +
  11709. +/* LH79520 DMA API */
  11710. +extern int lh79520_request_dma( dmach_t *channel, const char *device_id,
  11711. + dma_device_t device );
  11712. +extern int lh79520_dma_set_callback( dmach_t channel, dma_callback_t cb );
  11713. +extern int lh79520_dma_set_spin( dmach_t channel, dma_addr_t addr, int size );
  11714. +extern int lh79520_dma_queue_buffer( dmach_t channel, void *buf_id,
  11715. + dma_addr_t data, int size );
  11716. +extern int lh79520_dma_get_current( dmach_t channel, void **buf_id, dma_addr_t *addr );
  11717. +extern int lh79520_dma_stop( dmach_t channel );
  11718. +extern int lh79520_dma_resume( dmach_t channel );
  11719. +extern int lh79520_dma_flush_all( dmach_t channel );
  11720. +extern void lh79520_free_dma( dmach_t channel );
  11721. +extern int lh79520_dma_sleep( dmach_t channel );
  11722. +extern int lh79520_dma_wakeup( dmach_t channel );
  11723. +
  11724. +#endif /* _ASM_ARCH_DMA_H */
  11725. +
  11726. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/gpio.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/gpio.h
  11727. --- linux-2.4.26/include/asm-arm/arch-lh79520/gpio.h 1969-12-31 20:00:00.000000000 -0400
  11728. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/gpio.h 2005-11-02 17:37:32.000000000 -0400
  11729. @@ -0,0 +1,139 @@
  11730. +/*
  11731. + * linux/include/asm-arm/arch-lh79520/gpio.h
  11732. + *
  11733. + * Copyright (C) 2002 Lineo, Inc.
  11734. + *
  11735. + * This program is free software; you can redistribute it and/or modify
  11736. + * it under the terms of the GNU General Public License version 2 as
  11737. + * published by the Free Software Foundation.
  11738. + *
  11739. + * Original Author: BarnettH
  11740. + * Date: May 17 2001 17:47:58
  11741. + *
  11742. + * Project: ARM IP headers
  11743. + *
  11744. + * Description:
  11745. + * This file contains the structure definitions and manifest
  11746. + * constants for ARM IP component:
  11747. + * General Purpose Input/Output PrimeCell PL060
  11748. + *
  11749. + * Each GPIO Module has two GPIO (digital IO) ports which are
  11750. + * designated PORTA and PORTB.
  11751. + *
  11752. + * Multiple instances of a GPIO module, and thus port pairs,
  11753. + * may be implemented in a single SOC.
  11754. + *
  11755. + * Each port has eight bits, PORTx[7:0].
  11756. + *
  11757. + * Each port has two 8-bit registers associated with it:
  11758. + * GPIOPxDR - Data register (dr)
  11759. + * GPIOPxDDR - Data Direction register (ddr)
  11760. + *
  11761. + * The specific SOC will have its own unique name for the port.
  11762. + * Each port pair will have its own unique base address for the
  11763. + * port pair.
  11764. + *
  11765. + * This include file is designed to permit the definition of
  11766. + * pointers in the SOC map include file to distinct 8-bit ports
  11767. + * using the name designation is suitable for the SOC
  11768. + * implementation.
  11769. + *
  11770. + * Example:
  11771. + * A map file that includes this file should specify a
  11772. + * base address for each GPIO module, e.g.:
  11773. + *
  11774. + * #define GPIO0_BASE (0xFFFDF000)
  11775. + * #define GPIO1_BASE (0xFFFDE000)
  11776. + * *
  11777. + * *
  11778. + * *
  11779. + *
  11780. + * The SOC map file will use these base addresses to define
  11781. + * pointers to GPIO port A, B, C, D, E, ... thusly:
  11782. + *
  11783. + * #define GPIOPA ((volatile GPIOAREGS *)(GPIO0_BASE))
  11784. + * #define GPIOPB ((volatile GPIOBREGS *)(GPIO0_BASE))
  11785. + * #define GPIOPC ((volatile GPIOAREGS *)(GPIO1_BASE))
  11786. + * #define GPIOPD ((volatile GPIOBREGS *)(GPIO1_BASE))
  11787. + * #define GPIOPE ((volatile GPIOAREGS *)(GPIO2_BASE))
  11788. + * *
  11789. + * *
  11790. + * *
  11791. + *
  11792. + * Example usage of these definitions in user code for Port C:
  11793. + *
  11794. + * unsigned int data;
  11795. + *
  11796. + * GPIOC->ddr = 0xF; sets bits [7:4] as outputs
  11797. + * and bits [3:0] as inputs
  11798. + * GPIOC->dr = 0xF0; sets bits [7:4] to "1"
  11799. + *
  11800. + * data = GPIOC->dr; sets data to the value of
  11801. + * data register
  11802. + *
  11803. + * Note: If it is desired to use the type qualifier "__packed"
  11804. + * to enable packing of structures, the manifest constant
  11805. + * "PACKED" must be defined as follows or as a
  11806. + * predefine at compilation (ARM-specific notation):
  11807. + *
  11808. + * #define PACKED __packed
  11809. + *
  11810. + * If a different compiler/preprocessor is used, the appropriate
  11811. + * notation must be substituted for "__packed".
  11812. + *
  11813. + * Reference: ARM PrimeCell General Purpose Input/Output (PL060)
  11814. + * Technical Reference Manual, ARM DDI 0142B.
  11815. + *
  11816. + * Revision History:
  11817. + *
  11818. + * Rev 1.1 May 17 2001 17:47:58 BarnettH
  11819. + * Changed structure component types to reflect 32-bit access requirements.
  11820. + *
  11821. + * Rev 1.0 Mar 30 2001 16:03:30 BarnettH
  11822. + * Initial revision.
  11823. + *
  11824. + * COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
  11825. + * CAMAS, WA
  11826. + *********************************************************************/
  11827. +
  11828. +#ifndef ARM_GPIO_PL060_H
  11829. +#define ARM_GPIO_PL060_H
  11830. +
  11831. +/* GPIO Register Structures */
  11832. +//typedef __attribute((packed)) struct {
  11833. +typedef struct {
  11834. + volatile unsigned int dr;
  11835. + volatile unsigned int reserveda1;
  11836. + volatile unsigned int ddr;
  11837. + volatile unsigned int reserveda2;
  11838. +} gpioARegs_t;
  11839. +
  11840. +//typedef __attribute((packed)) struct {
  11841. +typedef struct {
  11842. + volatile unsigned int reservedb1;
  11843. + volatile unsigned int dr;
  11844. + volatile unsigned int reservedb2;
  11845. + volatile unsigned int ddr;
  11846. +} gpioBRegs_t;
  11847. +
  11848. +/*
  11849. + * The names and usage of the bit fields in these registers is
  11850. + * implementation specific, so few bit field constants are defined.
  11851. + */
  11852. +
  11853. +#ifndef _BIT
  11854. +#define _BIT(n) (1 << (n))
  11855. +#endif
  11856. +
  11857. +#ifndef _SBF
  11858. +#define _SBF(f,v) ((v) << (f))
  11859. +#endif
  11860. +
  11861. +#define SSPFRM_GPIO_BIT _BIT(2)
  11862. +#define SSPEN_GPIO_BIT _BIT(0)
  11863. +
  11864. +#define GPIOPAREGS gpioARegs_t
  11865. +#define GPIOPBREGS gpioBRegs_t
  11866. +
  11867. +#endif /* ARM_GPIO_PL060_H */
  11868. +
  11869. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/hardware.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/hardware.h
  11870. --- linux-2.4.26/include/asm-arm/arch-lh79520/hardware.h 1969-12-31 20:00:00.000000000 -0400
  11871. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/hardware.h 2005-11-02 17:37:32.000000000 -0400
  11872. @@ -0,0 +1,341 @@
  11873. +/*
  11874. + * linux/include/asm-arm/arch-lh79520/hardware.h
  11875. + *
  11876. + * Copyright (C) 2001 Sharp Microelectronics of the Americas, Inc.
  11877. + * CAMAS, WA
  11878. + * Portions Copyright (C) 2002 Lineo, Inc.
  11879. + *
  11880. + * This program is free software; you can redistribute it and/or modify
  11881. + * it under the terms of the GNU General Public License version 2 as
  11882. + * published by the Free Software Foundation.
  11883. + *
  11884. + * References:
  11885. + * (1) Sharp LH79520 Universal Microcontroller User's Guide,
  11886. + * Version 1.x, Sharp Microelectronics of the Americas, Inc.
  11887. + *
  11888. + */
  11889. +
  11890. +#ifndef _BIT
  11891. +#define _BIT(n) (1 << (n))
  11892. +#endif
  11893. +
  11894. +#ifndef _SBF
  11895. +#define _SBF(f,v) ((v) << (f))
  11896. +#endif
  11897. +
  11898. +#ifndef _BITMASK
  11899. +#define _BITMASK(field_width) ( _BIT(field_width) - 1)
  11900. +#endif
  11901. +
  11902. +/* Hardware addresses of major areas.
  11903. + * *_START is the physical address
  11904. + * *_SIZE is the size of the region
  11905. + * *_BASE is the virtual address
  11906. + */
  11907. +
  11908. +/*
  11909. + * we can do an identity mapping (V=P) of all of I/O
  11910. + * space, except for the VIC.
  11911. + *
  11912. + * One of the places you can find the VIC is at 0xffff0000,
  11913. + * which is the same place the interrupt vectors want to live,
  11914. + * so we'll leave a hole there, and use the VIC at it's other
  11915. + * address: 0xfffff000.
  11916. + */
  11917. +
  11918. +#define APB_START 0xfffc0000 /* Physical address of APB I/O space */
  11919. +#define APB_BASE 0xfffc0000 /* Virtual address of APB I/O space */
  11920. +#define APB_SIZE 0x00026000 /* its size (up to 0xfffe6000) */
  11921. +
  11922. +#define AHB_START 0xffff1000 /* Physical address of AHB I/O space */
  11923. +#define AHB_BASE 0xffff1000 /* Virtual address of AHB I/O space */
  11924. +#define AHB_SIZE 0x00004000 /* its size (up to 0xffff5000) */
  11925. +
  11926. +#define VIC_START VIC_PHYS /* Physical address of VIC */
  11927. +#define VIC_BASE 0xfffff000 /* Virtual address of VIC */
  11928. +#define VIC_SIZE 0x1000 /* its size */
  11929. +
  11930. +
  11931. +
  11932. +#define FLASH_START 0x40000000 /* Flash on SMC bank 0 */
  11933. +#define FLASH_BASE 0xf4000000
  11934. +#define FLASH_SIZE (4 * 1024 * 1024)
  11935. +
  11936. +#define EXT_SRAM_START 0x44000000 /* External SRAM on SMC bank 1 */
  11937. +#define EXT_SRAM_BASE 0xf4400000
  11938. +#define EXT_SRAM_SIZE (2 * 1024 * 1024)
  11939. +
  11940. +
  11941. +// not used, but there is still code that breaks without it
  11942. +#define CPLD_START 0x48000000 /* CPLD on SMC bank 2 */
  11943. +#define CPLD_BASE 0xf4800000
  11944. +#define CPLD_SIZE 4096
  11945. +
  11946. +#define CS8900_START 0x48000000 /* Ethernet on SMC bank 2 */
  11947. +#define CS8900_BASE 0xf4800000
  11948. +#define CS8900_SIZE 4096
  11949. +
  11950. +#define GPOUT16_START 0x4c000000 /* latch on bank 3 */
  11951. +#define GPOUT16_BASE 0xf4c00000
  11952. +#define GPOUT16_SIZE 4096
  11953. +
  11954. +
  11955. +#define IDE_START 0x50000000 /* CF/IDE on SMC bank 4 */
  11956. +#define IDE_BASE 0xf5000000
  11957. +#define IDE_SIZE 4096
  11958. +
  11959. +#define IDE2_START 0x54000000 /* CF/IDE on SMC bank 5 */
  11960. +#define IDE2_BASE 0xf5400000
  11961. +#define IDE2_SIZE 4096
  11962. +
  11963. +#define UNUSED_START 0x58000000 /* unused on SMC bank 6 */
  11964. +#define RESERVED_START 0x5C000000 /* reserved on SMC bank 7 */
  11965. +
  11966. +#define INT_SRAM_START 0x60000000 /* on-chip SRAM */
  11967. +#define INT_SRAM_BASE 0xf6000000
  11968. +#define INT_SRAM_SIZE (32 * 1024)
  11969. +
  11970. +
  11971. +#define IO_START APB_START
  11972. +#define IO_BASE APB_BASE
  11973. +
  11974. +/* macro to get at IO space when running virtually */
  11975. +#define IO_ADDRESS(phys) (phys)
  11976. +
  11977. +#define PCIO_BASE IO_BASE
  11978. +
  11979. +
  11980. +/**********************************************************************
  11981. + * AHB BASES
  11982. + *********************************************************************/
  11983. +#define AHB_PHYS (0xFFFF0000)
  11984. +#define VIC_PHYS_MIRROR (AHB_PHYS + 0x0000)
  11985. +#define SMC_REGS_PHYS (AHB_PHYS + 0x1000)
  11986. +#define SDRAM_REGS_PHYS (AHB_PHYS + 0x2000)
  11987. +#define LCD_PHYS (AHB_PHYS + 0x4000)
  11988. +#define VIC_PHYS (AHB_PHYS + 0xF000)
  11989. +
  11990. +/**********************************************************************
  11991. + * APB PHYSS
  11992. + *********************************************************************/
  11993. +#define APB_PHYS (0xFFFC0000)
  11994. +#define UART0_PHYS (APB_PHYS + 0x00000)
  11995. +#define UART1_PHYS (APB_PHYS + 0x01000)
  11996. +#define UART2_PHYS (APB_PHYS + 0x02000)
  11997. +#define PWM_PHYS (APB_PHYS + 0x03000)
  11998. +#define TIMER0_PHYS (APB_PHYS + 0x04000)
  11999. +#define TIMER1_PHYS (APB_PHYS + 0x05000)
  12000. +#define SSP_PHYS (APB_PHYS + 0x06000)
  12001. +#define GPIO3_PHYS (APB_PHYS + 0x1C000)
  12002. +#define GPIO2_PHYS (APB_PHYS + 0x1D000)
  12003. +#define GPIO1_PHYS (APB_PHYS + 0x1E000)
  12004. +#define GPIO0_PHYS (APB_PHYS + 0x1F000)
  12005. +#define RTC_PHYS (APB_PHYS + 0x20000)
  12006. +#define DMAC_PHYS (APB_PHYS + 0x21000)
  12007. +#define RCPC_PHYS (APB_PHYS + 0x22000)
  12008. +#define WDTIMER_PHYS (APB_PHYS + 0x23000)
  12009. +#define LCDICP_PHYS (APB_PHYS + 0x24000)
  12010. +#define IOCON_PHYS (APB_PHYS + 0x25000)
  12011. +
  12012. +/**********************************************************************
  12013. + * REMAPping
  12014. + *********************************************************************/
  12015. +#define SDRAM_MEM_PHYS (0x20000000)
  12016. +#define SMC_MEM_PHYS (0x40000000)
  12017. +#define INTERNAL_MEM_PHYS (0x60000000)
  12018. +
  12019. +// DDD #if REMAP == 0
  12020. +#define SMC_MIRROR_MEM_PHYS (0x00000000)
  12021. +// DDD #elif REMAP == 1
  12022. +// DDD #define SDRAM_MIRROR_MEM_PHYS (0x00000000)
  12023. +// DDD #elif REMAP == 2
  12024. +// DDD #define INTERNAL_MIRROR_MEM_PHYS (0x00000000)
  12025. +// DDD #else
  12026. +// DDD #error REMAP must be defined as 0, 1, or 2
  12027. +// DDD #endif
  12028. +
  12029. +/**********************************************************************
  12030. + * xSPR bits
  12031. + *********************************************************************/
  12032. +#define CORE_IRQ _BIT(7)
  12033. +#define CORE_FIQ _BIT(6)
  12034. +
  12035. +/**********************************************************************
  12036. + * SMC Memory Bank Address Space Bases
  12037. + *********************************************************************/
  12038. +
  12039. +#define SMC_BANK0_PHYS (SMC_MEM_PHYS + 0x00000000)
  12040. +#define SMC_BANK1_PHYS (SMC_MEM_PHYS + 0x04000000)
  12041. +#define SMC_BANK2_PHYS (SMC_MEM_PHYS + 0x08000000)
  12042. +#define SMC_BANK3_PHYS (SMC_MEM_PHYS + 0x0C000000)
  12043. +#define SMC_BANK4_PHYS (SMC_MEM_PHYS + 0x10000000)
  12044. +#define SMC_BANK5_PHYS (SMC_MEM_PHYS + 0x14000000)
  12045. +#define SMC_BANK6_PHYS (SMC_MEM_PHYS + 0x18000000)
  12046. +#define SMC_BANK7_PHYS (SMC_MEM_PHYS + 0x1C000000)
  12047. +
  12048. +/**********************************************************************
  12049. + * SDRAMC Memory Bank Address Space Bases
  12050. + *********************************************************************/
  12051. +
  12052. +#define SDRAM_BANK0_PHYS (SDRAM_MEM_PHYS + 0x00000000)
  12053. +#define SDRAM_BANK1_PHYS (SDRAM_MEM_PHYS + 0x08000000)
  12054. +
  12055. +/**********************************************************************
  12056. + * Vectored Interrupt Controller (VIC)
  12057. + *********************************************************************/
  12058. +#define VICID_OFFSET (0xFE0)
  12059. +// DDD #define VIC ((VICREGS *)(VIC_PHYS))
  12060. +// DDD #define VICID ((VICIDREGS *)(VIC_PHYS + VICID_OFFSET))
  12061. +#define VIC_INT_TYPE_IRQ 0
  12062. +#define VIC_INT_TYPE_FIQ 1
  12063. +
  12064. +/* VIC Interrupt Sources */
  12065. +#define VIC_EXTINT0 0
  12066. +#define VIC_EXTINT1 1
  12067. +#define VIC_EXTINT2 2
  12068. +#define VIC_EXTINT3 3
  12069. +#define VIC_EXTINT4 4
  12070. +#define VIC_EXTINT5 5
  12071. +#define VIC_EXTINT6 6
  12072. +#define VIC_EXTINT7 7
  12073. +#define VIC_SPEXTINT0 8
  12074. +#define VIC_SPEXTINT1 9
  12075. +#define VIC_SPEXTINT2 10
  12076. +#define VIC_SPEXTINT3 11
  12077. +#define VIC_CLCDC 12
  12078. +#define VIC_SSPTXINTR 13
  12079. +#define VIC_SSPRXINTR 14
  12080. +#define VIC_SSPRORINTR 15
  12081. +#define VIC_SSPINTR 16
  12082. +#define VIC_TIMER0 17
  12083. +#define VIC_TIMER1 18
  12084. +#define VIC_TIMER2 19
  12085. +#define VIC_TIMER3 20
  12086. +#define VIC_UART0_RX 21
  12087. +#define VIC_UART0_TX 22
  12088. +#define VIC_UART0 23
  12089. +#define VIC_UART1 24
  12090. +#define VIC_UART2 25
  12091. +#define VIC_DMA0 26
  12092. +#define VIC_DMA1 27
  12093. +#define VIC_DMA2 28
  12094. +#define VIC_DMA3 29
  12095. +#define VIC_RTC 30
  12096. +#define VIC_WDT 31
  12097. +
  12098. +/* VIC Vectors */
  12099. +#define VIC_VECT_0 0
  12100. +#define VIC_VECT_1 1
  12101. +#define VIC_VECT_2 2
  12102. +#define VIC_VECT_3 3
  12103. +#define VIC_VECT_4 4
  12104. +#define VIC_VECT_5 5
  12105. +#define VIC_VECT_6 6
  12106. +#define VIC_VECT_7 7
  12107. +#define VIC_VECT_8 8
  12108. +#define VIC_VECT_9 9
  12109. +#define VIC_VECT_10 10
  12110. +#define VIC_VECT_11 11
  12111. +#define VIC_VECT_12 12
  12112. +#define VIC_VECT_13 13
  12113. +#define VIC_VECT_14 14
  12114. +#define VIC_VECT_15 15
  12115. +#define VIC_VECT_MAX VIC_VECT_15
  12116. +#define VIC_VECT_DEFAULT ~(0)
  12117. +
  12118. +
  12119. +#define XTAL_IN 14745600 /* 14.7456 MHz crystal */
  12120. +#define PLL_CLOCK (XTAL_IN * 21) /* 309 MHz PLL clock */
  12121. +
  12122. +
  12123. +
  12124. +/**********************************************************************
  12125. + * UART'S
  12126. + *********************************************************************/
  12127. +#define UARTID_OFFSET (0xFE0)
  12128. +// DDD #define UART0 ((UARTREGS *)(UART0_PHYS))
  12129. +// DDD #define UART1 ((UARTREGS *)(UART1_PHYS))
  12130. +// DDD #define UART2 ((UARTREGS *)(UART2_PHYS))
  12131. +// DDD #define UART0ID ((UARTIDREGS *)(UART0_PHYS + UARTID_OFFSET))
  12132. +// DDD #define UART1ID ((UARTIDREGS *)(UART1_PHYS + UARTID_OFFSET))
  12133. +// DDD #define UART2ID ((UARTIDREGS *)(UART2_PHYS + UARTID_OFFSET))
  12134. +
  12135. +/**********************************************************************
  12136. + * IRDA
  12137. + *********************************************************************/
  12138. +// DDD #define IRDA0 ((UARTREGS *)(UART0_PHYS))
  12139. +// DDD #define IRDA1 ((UARTREGS *)(UART1_PHYS))
  12140. +// DDD #define IRDA2 ((UARTREGS *)(UART2_PHYS))
  12141. +
  12142. +/**********************************************************************
  12143. + * Pulse Width Modulator (PWM)
  12144. + *********************************************************************/
  12145. +// DDD #define PWMX_OFFSET (0x20)
  12146. +// DDD #define PWM ((PWMREGS *)(PWM_PHYS))
  12147. +// DDD #define PWM0 ((PWMXREGS *)(PWM_PHYS))
  12148. +// DDD #define PWM1 ((PWMXREGS *)(PWM_PHYS + PWMX_OFFSET))
  12149. +
  12150. +/**********************************************************************
  12151. + * TIMER
  12152. + *********************************************************************/
  12153. +// DDD #define TIMER2_OFFSET (0x20)
  12154. +// DDD #define TIMER0 ((TIMERREG *)(TIMER0_PHYS))
  12155. +// DDD #define TIMER1 ((volatile TIMERREG *)(TIMER0_PHYS + TIMER2_OFFSET))
  12156. +// DDD #define TIMER2 ((TIMERREG *)(TIMER1_PHYS))
  12157. +// DDD #define TIMER3 ((TIMERREG *)(TIMER1_PHYS + TIMER2_OFFSET))
  12158. +
  12159. +/**********************************************************************
  12160. + * Synchronous Serial Port (SSP)
  12161. + *********************************************************************/
  12162. +// DDD #define SSP ((SSPREGS *)(SSP_PHYS))
  12163. +
  12164. +/**********************************************************************
  12165. + * General Purpose Input/Output (GPIO)
  12166. + *********************************************************************/
  12167. +#define GPIOA ((GPIOPAREGS *)(GPIO0_PHYS))
  12168. +#define GPIOB ((GPIOPBREGS *)(GPIO0_PHYS))
  12169. +#define GPIOC ((GPIOPAREGS *)(GPIO1_PHYS))
  12170. +#define GPIOD ((GPIOPBREGS *)(GPIO1_PHYS))
  12171. +#define GPIOE ((GPIOPAREGS *)(GPIO2_PHYS))
  12172. +#define GPIOF ((GPIOPBREGS *)(GPIO2_PHYS))
  12173. +#define GPIOG ((GPIOPAREGS *)(GPIO3_PHYS))
  12174. +#define GPIOH ((GPIOPBREGS *)(GPIO3_PHYS))
  12175. +
  12176. +/**********************************************************************
  12177. + * Real Time Clock (RTC)
  12178. + *********************************************************************/
  12179. +// DDD #define RTC ((RTCREGS *)(RTC_PHYS))
  12180. +
  12181. +/**********************************************************************
  12182. + * DMA Controller (DMAC)
  12183. + *********************************************************************/
  12184. +// DDD #define DMAC ((DMACREGS *)(DMAC_PHYS))
  12185. +
  12186. +/**********************************************************************
  12187. + * Reset, Clock, and Power Controller (RCPC)
  12188. + *********************************************************************/
  12189. +// DDD #define RCPC ((RCPCREGS *)(RCPC_PHYS))
  12190. +
  12191. +/**********************************************************************
  12192. + * Watchdog Timer (WDTIMER)
  12193. + *********************************************************************/
  12194. +// DDD #define WDTIMER ((WDTIMERREGS *)(WDTIMER_PHYS))
  12195. +
  12196. +/**********************************************************************
  12197. + * LCD Interface Control Processor (LCDICP)
  12198. + *********************************************************************/
  12199. +// DDD #define LCDICP ((LCDICPREGS *)(LCDICP_PHYS))
  12200. +
  12201. +/**********************************************************************
  12202. + * IOCON
  12203. + *********************************************************************/
  12204. +// DDD #define IOCON ((IOCONREGS *)(IOCON_PHYS))
  12205. +
  12206. +/**********************************************************************
  12207. + * GPOUT16 (MARMALADE)
  12208. + *********************************************************************/
  12209. +#define nLED _BIT(8)
  12210. +#define TS_DIN _BIT(9)
  12211. +#define nTS_CS _BIT(10)
  12212. +#define TS_DCLK _BIT(11)
  12213. +#define BACKLIGHT _BIT(15)
  12214. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/ide.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/ide.h
  12215. --- linux-2.4.26/include/asm-arm/arch-lh79520/ide.h 1969-12-31 20:00:00.000000000 -0400
  12216. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/ide.h 2005-11-02 17:48:27.000000000 -0400
  12217. @@ -0,0 +1,58 @@
  12218. +/*
  12219. + * linux/include/asm-arm/arch-lh79520/ide.h
  12220. + *
  12221. + * Copyright 2002 Lineo, Inc.
  12222. + *
  12223. + * 17-Jan-2002: Initial clone of arch-anakin/ide.h
  12224. + */
  12225. +
  12226. +#include <linux/config.h>
  12227. +#include <asm/irq.h>
  12228. +#include <asm/hardware.h>
  12229. +
  12230. +/*
  12231. + * Set up a hw structure for a specified data port, control port and IRQ.
  12232. + * This should follow whatever the default interface uses.
  12233. + */
  12234. +static __inline__ void
  12235. +ide_init_hwif_ports(hw_regs_t *hw, int data_port, int ctrl_port, int *irq)
  12236. +{
  12237. + ide_ioreg_t reg;
  12238. + int i;
  12239. + int regincr = 4;
  12240. +
  12241. + memset(hw, 0, sizeof(*hw));
  12242. +
  12243. + reg = (ide_ioreg_t)data_port;
  12244. +
  12245. + for( i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
  12246. + hw->io_ports[i] = reg;
  12247. + reg += regincr;
  12248. + }
  12249. +
  12250. + hw->io_ports[IDE_CONTROL_OFFSET] = (ide_ioreg_t) ctrl_port;
  12251. +
  12252. + if (irq)
  12253. + *irq = 0;
  12254. +}
  12255. +
  12256. +
  12257. +/*
  12258. + * This registers the standard ports for this architecture with the IDE
  12259. + * driver.
  12260. + */
  12261. +static __inline__ void
  12262. +ide_init_default_hwifs(void)
  12263. +{
  12264. + hw_regs_t hw;
  12265. +
  12266. + /*
  12267. + * The IDE data ports are mapped in at IDE_BASE, and are aligined on 32 bit boundaries
  12268. + * The IDE control port (usually found at port 0x3f6 on a PC, e.g.) is 6 ints into IDE_BASE2.
  12269. + */
  12270. + ide_init_hwif_ports( &hw, IDE_BASE, (char *)IDE2_BASE + 6*sizeof(int), NULL);
  12271. + hw.irq = IRQ_CF;
  12272. + ide_register_hw( &hw, NULL);
  12273. +}
  12274. +
  12275. +
  12276. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/iocon.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/iocon.h
  12277. --- linux-2.4.26/include/asm-arm/arch-lh79520/iocon.h 1969-12-31 20:00:00.000000000 -0400
  12278. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/iocon.h 2005-11-02 17:37:32.000000000 -0400
  12279. @@ -0,0 +1,210 @@
  12280. +/*
  12281. + * linux/include/asm-arm/arch-lh79520/iocon.h
  12282. + *
  12283. + * Copyright (C) 2002 Lineo, Inc.
  12284. + * COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
  12285. + * CAMAS, WA
  12286. + *
  12287. + * This program is free software; you can redistribute it and/or modify
  12288. + * it under the terms of the GNU General Public License as published by
  12289. + * the Free Software Foundation; either version 2 of the License, or
  12290. + * (at your option) any later version.
  12291. + *
  12292. + * This program is distributed in the hope that it will be useful,
  12293. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12294. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12295. + * GNU General Public License for more details.
  12296. + *
  12297. + * You should have received a copy of the GNU General Public License
  12298. + * along with this program; if not, write to the Free Software
  12299. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  12300. + *
  12301. + * Description:
  12302. + * This file contains the structure definitions and manifest
  12303. + * constants for ARM IP component:
  12304. + * I/O Configuration Block
  12305. + *
  12306. + * References:
  12307. + * (1) Sharp LH79520 Universal Microcontroller User's Guide,
  12308. + * Version 1.x, Sharp Microelectronics of the Americas, Inc.
  12309. + * (2) ARM Isis Technical Reference Manual, System on Chip Group,
  12310. + * ARM SC063-TRM-0001-B
  12311. + *
  12312. + *********************************************************************/
  12313. +
  12314. +#ifndef LH79520_IOCON_H
  12315. +#define LH79520_IOCON_H
  12316. +
  12317. +#if 0
  12318. +#ifndef _BIT
  12319. +#define _BIT(n) (1 << (n))
  12320. +#endif
  12321. +
  12322. +#ifndef _SBF
  12323. +#define _SBF(f,v) ((v) << (f))
  12324. +#endif
  12325. +#endif // 0
  12326. +
  12327. +/*
  12328. + * IO Configuration Block Structure
  12329. + */
  12330. +typedef struct {
  12331. + volatile unsigned int MemMux;
  12332. + volatile unsigned int LCDMux;
  12333. + volatile unsigned int MiscMux;
  12334. + volatile unsigned int DMAMux;
  12335. + volatile unsigned int UARTMux;
  12336. + volatile unsigned int SSIMux;
  12337. + volatile unsigned int Scratchreg;
  12338. +} ioconRegs_t;
  12339. +
  12340. +/*
  12341. + * Memory Multiplexing IOCON Register Bit Field constants
  12342. + */
  12343. +#define MEMMUX_PIOE_NOMUX _SBF(0,0)
  12344. +#define MEMMUX_MIDQM32 _SBF(0,1)
  12345. +#define MEMMUX_MIDQM30 _SBF(0,3)
  12346. +#define MEMMUX_PIOE4 _SBF(2,0)
  12347. +#define MEMMUX_MINWE _SBF(2,1)
  12348. +#define MEMMUX_PIOE5 _SBF(3,0)
  12349. +#define MEMMUX_MISDNCS0 _SBF(3,1)
  12350. +#define MEMMUX_PIOE6 _SBF(4,0)
  12351. +#define MEMMUX_MISDNCS1 _SBF(4,1)
  12352. +#define MEMMUX_PIOE7 _SBF(5,0)
  12353. +#define MEMMUX_MICKE _SBF(5,1)
  12354. +#define MEMMUX_PIOF0 _SBF(6,0)
  12355. +#define MEMMUX_MICLKIO _SBF(6,1)
  12356. +#define MEMMUX_PIO_X _SBF(7,0)
  12357. +#define MEMMUX_MIDATA_X _SBF(7,1)
  12358. +#define MEMMUX_PIOH2 _SBF(8,0)
  12359. +#define MEMMUX_MICSN3 _SBF(8,1)
  12360. +#define MEMMUX_PIOH3 _SBF(9,0)
  12361. +#define MEMMUX_MICSN4 _SBF(9,1)
  12362. +#define MEMMUX_PIOH4 _SBF(10,0)
  12363. +#define MEMMUX_MICSN5 _SBF(10,1)
  12364. +#define MEMMUX_PIOH5 _SBF(11,0)
  12365. +#define MEMMUX_MICSN6 _SBF(11,1)
  12366. +#define MEMMUX_PIOH6 _SBF(12,0)
  12367. +#define MEMMUX_MIBLSN2 _SBF(12,1)
  12368. +#define MEMMUX_PIOH7 _SBF(13,0)
  12369. +#define MEMMUX_MIBLSN3 _SBF(13,1)
  12370. +
  12371. +/*
  12372. + * LCD Multiplexing IOCON Register Bit Field constants
  12373. + */
  12374. +#define LCDMUX_PIOB4 _SBF(0,0)
  12375. +#define LCDMUX_CLD12 _SBF(0,1)
  12376. +#define LCDMUX_CLREV _SBF(0,2)
  12377. +#define LCDMUX_PIOB5 _SBF(2,0)
  12378. +#define LCDMUX_CLD13 _SBF(2,1)
  12379. +#define LCDMUX_PIOB6 _SBF(3,0)
  12380. +#define LCDMUX_CLD14 _SBF(3,1)
  12381. +#define LCDMUX_PIOB7 _SBF(4,0)
  12382. +#define LCDMUX_CLD15 _SBF(4,1)
  12383. +#define LCDMUX_CLDSPLEN _SBF(4,2)
  12384. +#define LCDMUX_PIOC0 _SBF(6,0)
  12385. +#define LCDMUX_CLDEN _SBF(6,1)
  12386. +#define LCDMUX_CLSPL _SBF(6,2)
  12387. +#define LCDMUX_PIOC1 _SBF(8,0)
  12388. +#define LCDMUX_CLVDDEN _SBF(8,1)
  12389. +#define LCDMUX_CLS _SBF(8,2)
  12390. +#define LCDMUX_PIOC2 _SBF(10,0)
  12391. +#define LCDMUX_CLXCLK _SBF(10,1)
  12392. +#define LCDMUX_PIOC3 _SBF(11,0)
  12393. +#define LCDMUX_CLCP _SBF(11,1)
  12394. +#define LCDMUX_PIOC4 _SBF(12,0)
  12395. +#define LCDMUX_CLD16 _SBF(12,1)
  12396. +#define LCDMUX_PIOC5 _SBF(13,0)
  12397. +#define LCDMUX_CLLP _SBF(13,1)
  12398. +#define LCDMUX_CLP _SBF(13,2)
  12399. +#define LCDMUX_PIOC6 _SBF(15,0)
  12400. +#define LCDMUX_CLD17 _SBF(15,1)
  12401. +#define LCDMUX_PIOC7 _SBF(16,0)
  12402. +#define LCDMUX_CLFP _SBF(16,1)
  12403. +#define LCDMUX_CLSPS _SBF(16,2)
  12404. +#define LCDMUX_PIOD0 _SBF(18,0)
  12405. +#define LCDMUX_CLD2 _SBF(18,1)
  12406. +#define LCDMUX_PIOD1 _SBF(19,0)
  12407. +#define LCDMUX_CLD3 _SBF(19,1)
  12408. +#define LCDMUX_PIOD2 _SBF(20,0)
  12409. +#define LCDMUX_CLD4 _SBF(20,1)
  12410. +#define LCDMUX_PIOD3 _SBF(21,0)
  12411. +#define LCDMUX_CLD5 _SBF(21,1)
  12412. +#define LCDMUX_PIOD4 _SBF(22,0)
  12413. +#define LCDMUX_CLD6 _SBF(22,1)
  12414. +#define LCDMUX_CPS _SBF(22,2)
  12415. +#define LCDMUX_PIOD5 _SBF(24,0)
  12416. +#define LCDMUX_CLD7 _SBF(24,1)
  12417. +#define LCDMUX_PIOD6 _SBF(25,0)
  12418. +#define LCDMUX_CLD8 _SBF(25,1)
  12419. +#define LCDMUX_PIOD7 _SBF(26,0)
  12420. +#define LCDMUX_CLD9 _SBF(26,1)
  12421. +#define LCDMUX_RCEII6 _SBF(27,0)
  12422. +#define LCDMUX_CLD10 _SBF(27,1)
  12423. +#define LCDMUX_RCEII7 _SBF(28,0)
  12424. +#define LCDMUX_CLD11 _SBF(28,1)
  12425. +
  12426. +/*
  12427. + * Miscellaneous Multiplexing IOCON Register Bit Field constants
  12428. + */
  12429. +#define MISCMUX_PWM1 _SBF(0,0)
  12430. +#define MISCMUX_DCDEOT1 _SBF(0,1)
  12431. +#define MISCMUX_PIOA5 _SBF(1,0)
  12432. +#define MISCMUX_RCCLKOUT _SBF(1,1)
  12433. +#define MISCMUX_PIOA6 _SBF(2,0)
  12434. +#define MISCMUX_RCEII0 _SBF(2,1)
  12435. +#define MISCMUX_PIOA7 _SBF(3,0)
  12436. +#define MISCMUX_RCEII1 _SBF(3,1)
  12437. +#define MISCMUX_PIOB0 _SBF(4,0)
  12438. +#define MISCMUX_RCEII2 _SBF(4,1)
  12439. +#define MISCMUX_RCEII3 _SBF(5,0)
  12440. +#define MISCMUX_PWM0SYNC _SBF(5,1)
  12441. +#define MISCMUX_RCEII4 _SBF(6,0)
  12442. +#define MISCMUX_PWM0 _SBF(6,1)
  12443. +#define MISCMUX_RCCTOUT _SBF(7,0)
  12444. +#define MISCMUX_DCDACK1 _SBF(7,1)
  12445. +#define MISCMUX_DCDREQ1 _SBF(8,0)
  12446. +#define MISCMUX_RCEII5 _SBF(8,1)
  12447. +#define MISCMUX_PIOF1 _SBF(9,0)
  12448. +#define MISCMUX_RCCLKEN _SBF(9,1)
  12449. +#define MISCMUX_RCCLKIN _SBF(10,0)
  12450. +#define MISCMUX_RCUTCLK _SBF(10,1)
  12451. +
  12452. +/*
  12453. + * DMA Multiplexing IOCON Register Bit Field constants
  12454. + */
  12455. +#define DMAMUX_PIOB1 _SBF(0,0)
  12456. +#define DMAMUX_DCDEOT0 _SBF(0,1)
  12457. +#define DMAMUX_PIOB2 _SBF(1,0)
  12458. +#define DMAMUX_DCDACK0N _SBF(1,1)
  12459. +#define DMAMUX_PIOB3 _SBF(2,0)
  12460. +#define DMAMUX_DCDREQ0 _SBF(2,1)
  12461. +
  12462. +/*
  12463. + * UART Multiplexing IOCON Register Bit Field constants
  12464. + */
  12465. +#define UARTMUX_UT0IRRXA _SBF(0,0)
  12466. +#define UARTMUX_UT0RXD _SBF(0,1)
  12467. +#define UARTMUX_UT0IRTXA _SBF(1,0)
  12468. +#define UARTMUX_UT0TXD _SBF(1,1)
  12469. +#define UARTMUX_PIOA3 _SBF(2,0)
  12470. +#define UARTMUX_UT1RXD _SBF(2,1)
  12471. +#define UARTMUX_PIOA4 _SBF(3,0)
  12472. +#define UARTMUX_UT1TXD _SBF(3,1)
  12473. +
  12474. +/*
  12475. + * SSI Multiplexing IOCON Register Bit Field constants
  12476. + */
  12477. +#define SSIMUX_SSPIN _SBF(0,0)
  12478. +#define SSIMUX_UT2RXD _SBF(0,1)
  12479. +#define SSIMUX_SSPOUT _SBF(1,0)
  12480. +#define SSIMUX_UT2TXD _SBF(1,1)
  12481. +#define SSIMUX_PIOA0 _SBF(2,0)
  12482. +#define SSIMUX_SSPENB _SBF(2,1)
  12483. +#define SSIMUX_PIOA1 _SBF(3,0)
  12484. +#define SSIMUX_SSPCLK _SBF(3,1)
  12485. +#define SSIMUX_PIOA2 _SBF(4,0)
  12486. +#define SSIMUX_SSPFRM _SBF(4,1)
  12487. +
  12488. +#endif /* LH79520_IOCON_H */
  12489. +
  12490. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/io.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/io.h
  12491. --- linux-2.4.26/include/asm-arm/arch-lh79520/io.h 1969-12-31 20:00:00.000000000 -0400
  12492. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/io.h 2005-11-02 17:37:32.000000000 -0400
  12493. @@ -0,0 +1,52 @@
  12494. +/*
  12495. + * linux/include/asm-arm/arch-lh79520/io.h
  12496. + *
  12497. + * Copyright (C) 2002 Lineo, Inc.
  12498. + *
  12499. + * This program is free software; you can redistribute it and/or modify
  12500. + * it under the terms of the GNU General Public License as published by
  12501. + * the Free Software Foundation; either version 2 of the License, or
  12502. + * (at your option) any later version.
  12503. + *
  12504. + * This program is distributed in the hope that it will be useful,
  12505. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12506. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12507. + * GNU General Public License for more details.
  12508. + *
  12509. + * You should have received a copy of the GNU General Public License
  12510. + * along with this program; if not, write to the Free Software
  12511. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  12512. + */
  12513. +#ifndef __ASM_ARM_ARCH_IO_H
  12514. +#define __ASM_ARM_ARCH_IO_H
  12515. +
  12516. +#define IO_SPACE_LIMIT 0xffffffff
  12517. +
  12518. +/*
  12519. + * We don't actually have real ISA nor PCI buses, but there is so many
  12520. + * drivers out there that might just work if we fake them...
  12521. + */
  12522. +// DDD #define __io(a) (PCIO_BASE + (a))
  12523. +#define __io(a) (a)
  12524. +#define __mem_pci(a) ((unsigned long)(a))
  12525. +#define __mem_isa(a) ((unsigned long)(a))
  12526. +
  12527. +/*
  12528. + * Generic virtual read/write
  12529. + */
  12530. +#define __arch_getw(a) (*(volatile unsigned short *)(a))
  12531. +#define __arch_putw(v,a) (*(volatile unsigned short *)(a) = (v))
  12532. +#define __arch_ioremap __ioremap
  12533. +#define __arch_iounmap __iounmap
  12534. +
  12535. +/*
  12536. + * Validate the pci memory address for ioremap.
  12537. + */
  12538. +// DDD #define iomem_valid_addr(iomem,size) (1)
  12539. +
  12540. +/*
  12541. + * Convert PCI memory space to a CPU physical address
  12542. + */
  12543. +// DDD #define iomem_to_phys(iomem) (iomem)
  12544. +
  12545. +#endif
  12546. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/irq.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/irq.h
  12547. --- linux-2.4.26/include/asm-arm/arch-lh79520/irq.h 1969-12-31 20:00:00.000000000 -0400
  12548. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/irq.h 2005-11-02 17:51:52.000000000 -0400
  12549. @@ -0,0 +1,250 @@
  12550. +/*
  12551. + * linux/include/asm-arm/arch-lh79520/irq.h
  12552. + *
  12553. + * Copyright (C) 2002 Lineo, Inc.
  12554. + *
  12555. + * This program is free software; you can redistribute it and/or modify
  12556. + * it under the terms of the GNU General Public License as published by
  12557. + * the Free Software Foundation; either version 2 of the License, or
  12558. + * (at your option) any later version.
  12559. + *
  12560. + * This program is distributed in the hope that it will be useful,
  12561. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12562. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12563. + * GNU General Public License for more details.
  12564. + *
  12565. + * You should have received a copy of the GNU General Public License
  12566. + * along with this program; if not, write to the Free Software
  12567. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  12568. + */
  12569. +
  12570. +#include <linux/delay.h>
  12571. +#include <asm/arch/hardware.h>
  12572. +#include <asm/arch/rcpc.h>
  12573. +#include <asm/arch/iocon.h>
  12574. +#if 0
  12575. +#include <asm/arch/cpld.h> // DDD only for testing the switches
  12576. +#endif
  12577. +
  12578. +
  12579. +#define NR_VEC 16 /* number of vectors */
  12580. +/*
  12581. + * Vectored Interrupt Controller Module Register Structure
  12582. + */
  12583. +typedef struct {
  12584. + u32 IRQStatus; /* masked IRQ status */
  12585. + u32 FIQStatus; /* masked FIQ status */
  12586. + u32 RawIntr; /* raw status */
  12587. + u32 IntSelect; /* select whether source generates IRQ or FIQ */
  12588. + u32 IntEnable; /* int enable mask */
  12589. + u32 IntEnClear; /* writes here clear bits in IntEnable */
  12590. + u32 SoftInt; /* gen soft interrupts */
  12591. + u32 SoftIntClear; /* writes here clear bits in SoftInt */
  12592. + u32 Protection; /* protection enable */
  12593. + u32 reserved1[3];
  12594. + u32 CurrentISR; /* interrupt vector address of current interrupt */
  12595. + u32 DefVectAddr; /* default vector address */
  12596. + u32 reserved2[50];
  12597. + u32 VectAddr[NR_VEC]; /* interrupt vector address 0...NR_VEC */
  12598. + u32 reserved3[48];
  12599. + u32 VectCntl[NR_VEC]; /* vector control 0...NR_VEC */
  12600. + u32 reserved4[48];
  12601. + u32 ITCR; /* test mode */
  12602. + u32 ITIP1; /* test mode */
  12603. + u32 ITIP2; /* test mode */
  12604. + u32 ITOP1; /* test mode */
  12605. + u32 ITOP2; /* test mode */
  12606. + u32 reserved5[819]; /* empty */
  12607. + u32 periphid[4]; /* Peripheral ID register bits */
  12608. + u32 cellid[4]; /* PrimeCell ID register bits */
  12609. +} vicRegs_t;
  12610. +
  12611. +
  12612. +/**********************************************************************
  12613. + * Vectored Interrupt Controller Register Bit Fields
  12614. + *********************************************************************/
  12615. +
  12616. +/**********************************************************************
  12617. + * The bit fields of the following registers have implementation
  12618. + * specific meaning, and must be defined at the implementation level.
  12619. + *
  12620. + * irqstatus - VICIRQStatus
  12621. + * fiqstatus - VICFIQStatus
  12622. + * rawintr - VICRawIntr
  12623. + * intselect - VICIntSelect
  12624. + * intenable - VICIntEnable
  12625. + * intenclear - VICIntEnClear
  12626. + * softint - VICSoftInt
  12627. + * softintclear- VICSoftIntClear
  12628. + *
  12629. + * The following definitions for these registers are generic,
  12630. + * i.e., they are implementation independent. They can be used to
  12631. + * create implementation specific macros.
  12632. + *********************************************************************/
  12633. +
  12634. +/**********************************************************************
  12635. + * VIC Interrupt Select Register Bit Fields
  12636. + *********************************************************************/
  12637. +/* The following can be OR'd with the IntSelect Register to select
  12638. + * an interrupt as FIQ. */
  12639. +#define VIC_INTSELECT_FIQ(n) _BIT((n) & 0x1F)
  12640. +/* The following can be AND'd with the IntSelect Register to select
  12641. + * an interrupt as IRQ. */
  12642. +#define VIC_INTSELECT_IRQ(n) ~(_BIT((n) & 0x1F))
  12643. +
  12644. +/**********************************************************************
  12645. + * VIC Interrupt Enable, Interrupt Enable Clear Register Bit Fields
  12646. + * VIC Soft Interrupt, Soft Interrupt Clear Register Bit Fields
  12647. + *********************************************************************/
  12648. +#define VIC_INT_ENABLE(n) _BIT((n) & 0x1F)
  12649. +#define VIC_INT_CLEAR(n) _BIT((n) & 0x1F)
  12650. +
  12651. +/**********************************************************************
  12652. + * VIC Protection Enable Register Bit Fields
  12653. + *********************************************************************/
  12654. +#define VIC_PROTECTION _BIT(0)
  12655. +
  12656. +/**********************************************************************
  12657. + * VIC Vector Address Clear Register
  12658. + *********************************************************************/
  12659. +#define VIC_VECTORADDR_CLEAR 0
  12660. +
  12661. +/**********************************************************************
  12662. + * VIC Vector Control Register Bit Fields
  12663. + *********************************************************************/
  12664. +/* To revise a Vector Control Register, clear the register, then
  12665. + * use the SELECT macro to associate a line and enable the vector
  12666. + * with the same operation.
  12667. + * The ENABLE macro is provided for completeness.
  12668. + * Use this register to enable and disable the VECTOR feature;
  12669. + * use the intenable register to enable the interrupt
  12670. + * itself, and the intenclear register to clear the interrupt. */
  12671. +#define VIC_VECTCNTL_SELECT(n) (_SBF(0,((n) & 0x1F)) | _BIT(5))
  12672. +#define VIC_VECTCNTL_ENABLE _BIT(5)
  12673. +
  12674. +/**********************************************************************
  12675. + * Vectored Interrupt Controller Test Registers
  12676. + *********************************************************************/
  12677. +/**********************************************************************
  12678. + * itcr - Test Control
  12679. + *********************************************************************/
  12680. +#define VIC_ITCR_ITEN _BIT(0)
  12681. +
  12682. +/**********************************************************************
  12683. + * itip1 - Test Input 1
  12684. + *********************************************************************/
  12685. +#define VIC_ITIP1_F _BIT(6)
  12686. +#define VIC_ITIP1_I _BIT(7)
  12687. +
  12688. +/**********************************************************************
  12689. + * itop1 - Test Output 1
  12690. + *********************************************************************/
  12691. +#define VIC_ITOP1_F _BIT(6)
  12692. +#define VIC_ITOP1_I _BIT(7)
  12693. +
  12694. +
  12695. +
  12696. +
  12697. +#define fixup_irq(i) (i)
  12698. +
  12699. +#define TESTIRQ
  12700. +
  12701. +#ifdef TESTIRQ // DDD
  12702. +static unsigned int myReadCp15(void)
  12703. +{
  12704. + unsigned int x;
  12705. + asm ("mrc p15, 0, %0, c1, c0, 0;" : "=r"(x) : );
  12706. + return x;
  12707. +}
  12708. +#endif
  12709. +
  12710. +
  12711. +
  12712. +static void lh79520_mask_irq( u32 irq)
  12713. +{
  12714. + vicRegs_t *vic = (vicRegs_t *)VIC_BASE;
  12715. + vic->IntEnClear = (1 << irq);
  12716. +}
  12717. +
  12718. +static void lh79520_unmask_irq( u32 irq)
  12719. +{
  12720. + vicRegs_t *vic = (vicRegs_t *)VIC_BASE;
  12721. +
  12722. +#ifdef TESTIRQ
  12723. + if (irq != 17)
  12724. + udelay(1); // printk( "VIC unmask irq %d\n", irq);
  12725. +#endif // 0 DDD
  12726. + vic->IntEnable = (1 << irq);
  12727. +}
  12728. +
  12729. +#undef TESTIRQ
  12730. +
  12731. +static __inline__ void irq_init_irq(void)
  12732. +{
  12733. + int irq, i;
  12734. + vicRegs_t *vic = (vicRegs_t *)VIC_BASE;
  12735. + rcpcRegs_t *rcpc = (rcpcRegs_t *)IO_ADDRESS( RCPC_PHYS);
  12736. + ioconRegs_t *iocon = (ioconRegs_t *)IO_ADDRESS( IOCON_PHYS);
  12737. +
  12738. + /* allow external interrupts to come in */
  12739. + iocon->MiscMux = MISCMUX_RCEII0 |
  12740. + MISCMUX_RCEII1 |
  12741. + MISCMUX_RCEII2;
  12742. +
  12743. +#ifdef TESTIRQ // DDD
  12744. + printk( "irq_init_irq() cr1=%08X\n", myReadCp15());
  12745. + printk( "vic=0x%08lX rcpc=0x%08lX\n", (unsigned long) vic, (unsigned long) rcpc);
  12746. + printk( "vic periph id[0-3] = 0x%X 0x%X 0x%X 0x%X\n", vic->periphid[0], vic->periphid[1], vic->periphid[2], vic->periphid[3]);
  12747. +#endif // 0
  12748. +
  12749. + vic->IntEnClear = 0xffffffff; /* clear all interrupt enables */
  12750. + vic->IntSelect = 0; /* everything generates IRQ */
  12751. +
  12752. + // DDD don't want to do this !! vic->Protection = 1; /* allow only priviledged access */
  12753. +
  12754. + /* disable vectored interrupts */
  12755. + for( i = 0; i < NR_VEC; i++) {
  12756. + vic->VectAddr[i] = 0;
  12757. + vic->VectCntl[i] = 0;
  12758. + }
  12759. +
  12760. + for (irq = 0; irq < NR_IRQS; irq++) {
  12761. + irq_desc[irq].valid = 1;
  12762. + irq_desc[irq].probe_ok = 1;
  12763. + irq_desc[irq].mask_ack = lh79520_mask_irq;
  12764. + irq_desc[irq].mask = lh79520_mask_irq;
  12765. + irq_desc[irq].unmask = lh79520_unmask_irq;
  12766. + }
  12767. +
  12768. + /*
  12769. + * External interrupts 0-2 and 6-7 are active LOW, and External
  12770. + * interrupts 3-5 are active HIGH. <---= DDD wrong
  12771. + */
  12772. +
  12773. + rcpc->control |= RCPC_CTRL_WRTLOCK_ENABLED; /* unlock RCPC registers */
  12774. + barrier();
  12775. +
  12776. + rcpc->intClear = 0xff; /* clear all external interrupts */
  12777. +
  12778. + rcpc->intConfig = (
  12779. + RCPC_INTCONFIG( RCPC_INT1, RCPC_INT_HLT) | // irq 1 (ide) high level
  12780. + RCPC_INTCONFIG( RCPC_INT2, RCPC_INT_LLT) | // irq 2 (MARMALADE ETH) is low level
  12781. + RCPC_INTCONFIG( RCPC_INT3, RCPC_INT_FET) | // irq 3 (MARMALADE TS) active low
  12782. + RCPC_INTCONFIG( RCPC_INT4, RCPC_INT_HLT) |
  12783. + RCPC_INTCONFIG( RCPC_INT5, RCPC_INT_HLT) |
  12784. + RCPC_INTCONFIG( RCPC_INT6, RCPC_INT_LLT)
  12785. + );
  12786. +
  12787. + rcpc->control &= ~RCPC_CTRL_WRTLOCK_ENABLED; /* lock RCPC registers */
  12788. + printk( "RCPC locked ->control=0x%08lX\n", (unsigned long) rcpc->control);
  12789. + printk( "RCPC ->intConfig = 0x%08lX\n", (unsigned long) rcpc->intConfig);
  12790. +
  12791. +#if 0
  12792. + { // DDD test the switches
  12793. + cpldRegs_t *cpld = (cpldRegs_t *)CPLD_BASE;
  12794. + cpld->intr_mask = 0x1f;
  12795. + }
  12796. +#endif
  12797. +
  12798. + // DDD init_FIQ();
  12799. +}
  12800. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/irqs.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/irqs.h
  12801. --- linux-2.4.26/include/asm-arm/arch-lh79520/irqs.h 1969-12-31 20:00:00.000000000 -0400
  12802. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/irqs.h 2005-11-02 17:37:32.000000000 -0400
  12803. @@ -0,0 +1,51 @@
  12804. +/*
  12805. + * linux/include/asm-arm/arch-lh79520/irqs.h
  12806. + *
  12807. + * Copyright (C) 2002 Lineo, Inc.
  12808. + *
  12809. + * This program is free software; you can redistribute it and/or modify
  12810. + * it under the terms of the GNU General Public License version 2 as
  12811. + * published by the Free Software Foundation.
  12812. + *
  12813. + */
  12814. +
  12815. +#ifndef __ASM_ARCH_IRQS_H
  12816. +#define __ASM_ARCH_IRQS_H
  12817. +
  12818. +#define NR_IRQS 32
  12819. +
  12820. +
  12821. +#define IRQ_ETHERNET 0
  12822. +#define IRQ_CF 1
  12823. +#define IRQ_CPLD 2
  12824. +#define IRQ_PWM0SYNC 3
  12825. +#define IRQ_PWM0 4
  12826. +#define IRQ_DREQ1 5
  12827. +#define IRQ_LCDVD10 6
  12828. +#define IRQ_LCDVD11 7
  12829. +#define IRQ_spare_i0 8 /* spare internal */
  12830. +#define IRQ_spare_i1 9 /* spare internal */
  12831. +#define IRQ_spare_i2 10 /* spare internal */
  12832. +#define IRQ_SPEXTINT3 11
  12833. +#define IRQ_LCD 12
  12834. +#define IRQ_SSPTXINTR 13
  12835. +#define IRQ_SSPRXINTR 14
  12836. +#define IRQ_SSPRORINTR 15
  12837. +#define IRQ_SSPINTR 16
  12838. +#define IRQ_TIMER0 17
  12839. +#define IRQ_TIMER1 18
  12840. +#define IRQ_TIMER2 19
  12841. +#define IRQ_TIMER3 20
  12842. +#define IRQ_UART0_RX 21
  12843. +#define IRQ_UART0_TX 22
  12844. +#define IRQ_UART0 23
  12845. +#define IRQ_UART1 24
  12846. +#define IRQ_UART2 25
  12847. +#define IRQ_DMA 26 /* all DMA channels */
  12848. +#define IRQ_spare_i4 27 /* spare internal */
  12849. +#define IRQ_spare_i5 28 /* spare internal */
  12850. +#define IRQ_spare_i6 29 /* spare internal */
  12851. +#define IRQ_RTC 30
  12852. +#define IRQ_WDT 31
  12853. +
  12854. +#endif
  12855. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/keyboard.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/keyboard.h
  12856. --- linux-2.4.26/include/asm-arm/arch-lh79520/keyboard.h 1969-12-31 20:00:00.000000000 -0400
  12857. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/keyboard.h 2005-11-02 17:37:32.000000000 -0400
  12858. @@ -0,0 +1,15 @@
  12859. +/*
  12860. + * linux/include/asm-arm/arch-anakin/keyboard.h
  12861. + *
  12862. + * Copyright (C) 2001 Aleph One Ltd. for Acunia N.V.
  12863. + *
  12864. + * This program is free software; you can redistribute it and/or modify
  12865. + * it under the terms of the GNU General Public License version 2 as
  12866. + * published by the Free Software Foundation.
  12867. + *
  12868. + * Changelog:
  12869. + * 11-Apr-2001 TTC Created
  12870. + */
  12871. +#define kbd_init_hw() do { } while (0)
  12872. +#define kbd_enable_irq() do { } while (0)
  12873. +#define kbd_disable_irq() do { } while (0)
  12874. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/lh7x-7seg.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/lh7x-7seg.h
  12875. --- linux-2.4.26/include/asm-arm/arch-lh79520/lh7x-7seg.h 1969-12-31 20:00:00.000000000 -0400
  12876. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/lh7x-7seg.h 2005-11-02 17:37:32.000000000 -0400
  12877. @@ -0,0 +1,71 @@
  12878. +/* vi: set sw=4 ts=4 ai: */
  12879. +
  12880. +#ifndef _LH79X_7SEG_H_
  12881. +#define _LH79X_7SEG_H_
  12882. +
  12883. +/**********************************************************************
  12884. +* linux/drivers/misc/lh79x_7seg.c
  12885. +*
  12886. +* Provide ADS_784x 7-Segment access for LH7x EVB boards
  12887. +*
  12888. +* Copyright (C) 2002 Lineo, Inc.
  12889. +*
  12890. +* This program is free software; you can redistribute it and/or modify
  12891. +* it under the terms of the GNU General Public License (GPL) version 2
  12892. +* as published by the Free Software Foundation.
  12893. +*
  12894. +**********************************************************************/
  12895. +
  12896. +/**********************************************************************
  12897. +* The sharp 7-segment display
  12898. +*
  12899. +* _ == a
  12900. +* | | == f b
  12901. +* - == g
  12902. +* | | == e c
  12903. +* -. == d dot
  12904. +*
  12905. +* NOTE: The 7-segment display bars are bit-mapped.
  12906. +* NOTE: The 7-segment display bars are ACTIVE LOW.
  12907. +*
  12908. +* NOTE: When read, the 7-segment display does not return valid data. As a
  12909. +* result, it is HIGHLY recommended daemons accessing the display
  12910. +* use the provided routines which programatically track the current
  12911. +* value of the display to simulate read functionality. Otherwise,
  12912. +* application access of the display will be tainted.
  12913. +*
  12914. +**********************************************************************/
  12915. +
  12916. +#define SSD_A 0x01
  12917. +#define SSD_B 0x02
  12918. +#define SSD_C 0x04
  12919. +#define SSD_D 0x08
  12920. +#define SSD_E 0x10
  12921. +#define SSD_F 0x20
  12922. +#define SSD_G 0x40
  12923. +#define SSD_DOT 0x80
  12924. +#define SSD_DP SSD_DOT
  12925. +
  12926. +#ifdef KERNEL
  12927. +
  12928. +extern uint16_t lh79x_7seg_read_raw_display(void);
  12929. +extern u_char lh79x_7seg_read_raw_display_lsb(void);
  12930. +extern u_char lh79x_7seg_read_raw_display_msb(void);
  12931. +
  12932. +extern uint16_t lh79x_7seg_read_display(void);
  12933. +extern u_char lh79x_7seg_read_display_lsb(void);
  12934. +extern u_char lh79x_7seg_read_display_msb(void);
  12935. +
  12936. +extern void lh79x_7seg_write_raw_display(uint16_t raw_val);
  12937. +extern void lh79x_7seg_write_raw_display_lsb(u_char raw_lsb);
  12938. +extern void lh79x_7seg_write_raw_display_msb(u_char raw_msb);
  12939. +
  12940. +extern void lh79x_7seg_write_display(uint16_t val)
  12941. +extern void lh79x_7seg_write_display_lsb(u_char lsb)
  12942. +extern void lh79x_7seg_write_display_msb(u_char msb)
  12943. +extern void lh79x_7seg_write_display_str(u_char *str);
  12944. +
  12945. +#endif /* KERNEL */
  12946. +
  12947. +#endif /* _LH79X_7SEG_H_ */
  12948. +
  12949. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/memory.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/memory.h
  12950. --- linux-2.4.26/include/asm-arm/arch-lh79520/memory.h 1969-12-31 20:00:00.000000000 -0400
  12951. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/memory.h 2005-11-02 17:42:57.000000000 -0400
  12952. @@ -0,0 +1,116 @@
  12953. +/*
  12954. + * linux/include/asm-arm/arch-sa1100/memory.h
  12955. + *
  12956. + * Copyright (C) 1999-2000 Nicolas Pitre <nico@cam.org>
  12957. + */
  12958. +
  12959. +#ifndef __ASM_ARCH_MEMORY_H
  12960. +#define __ASM_ARCH_MEMORY_H
  12961. +
  12962. +#include <linux/config.h>
  12963. +
  12964. +/*
  12965. + * Task size: 3GB
  12966. + */
  12967. +#define TASK_SIZE (0xc0000000UL)
  12968. +#define TASK_SIZE_26 (0x04000000UL)
  12969. +
  12970. +/*
  12971. + * This decides where the kernel will search for a free chunk of vm
  12972. + * space during mmap's.
  12973. + */
  12974. +#define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  12975. +
  12976. +/*
  12977. + * Page offset: 3GB
  12978. + */
  12979. +#define PAGE_OFFSET (0xc0000000UL)
  12980. +
  12981. +/*
  12982. + * Physical DRAM offset is 0xc0000000 on the SA1100
  12983. + */
  12984. +#define PHYS_OFFSET (0x20000000UL)
  12985. +#define PHYS_OFFSET2 (0x28000000UL) /* Phys addr of second bank of SDRAM */
  12986. +
  12987. +/*
  12988. + * We take advantage of the fact that physical and virtual address can be the
  12989. + * same. The NUMA code is handling the large holes that might exist between
  12990. + * all memory banks.
  12991. + */
  12992. +#define __virt_to_phys__is_a_macro
  12993. +#define __phys_to_virt__is_a_macro
  12994. +#define __virt_to_phys(vpage) ((vpage) - PAGE_OFFSET + PHYS_OFFSET)
  12995. +#define __phys_to_virt(ppage) ((ppage) + PAGE_OFFSET - PHYS_OFFSET)
  12996. +
  12997. +/*
  12998. + * Virtual view <-> DMA view memory address translations
  12999. + * virt_to_bus: Used to translate the virtual address to an
  13000. + * address suitable to be passed to set_dma_addr
  13001. + * bus_to_virt: Used to convert an address for DMA operations
  13002. + * to an address that the kernel can use.
  13003. + *
  13004. + * On the SA1100, bus addresses are equivalent to physical addresses.
  13005. + */
  13006. +#define __virt_to_bus__is_a_macro
  13007. +#define __bus_to_virt__is_a_macro
  13008. +#define __virt_to_bus(x) __virt_to_phys(x)
  13009. +#define __bus_to_virt(x) __phys_to_virt(x)
  13010. +
  13011. +#ifdef CONFIG_DISCONTIGMEM
  13012. +/*
  13013. + * Because of the wide memory address space between physical RAM banks on the
  13014. + * SA1100, it's much more convenient to use Linux's NUMA support to implement
  13015. + * our memory map representation. Assuming all memory nodes have equal access
  13016. + * characteristics, we then have generic discontiguous memory support.
  13017. + *
  13018. + * Of course, all this isn't mandatory for SA1100 implementations with only
  13019. + * one used memory bank. For those, simply undefine CONFIG_DISCONTIGMEM.
  13020. + *
  13021. + * The nodes are matched with the physical memory bank addresses which are
  13022. + * incidentally the same as virtual addresses.
  13023. + *
  13024. + * node 0: 0xc0000000 - 0xc7ffffff
  13025. + * node 1: 0xc8000000 - 0xcfffffff
  13026. + * node 2: 0xd0000000 - 0xd7ffffff
  13027. + * node 3: 0xd8000000 - 0xdfffffff
  13028. + */
  13029. +
  13030. +#define NR_NODES 4
  13031. +
  13032. +/*
  13033. + * Given a kernel address, find the home node of the underlying memory.
  13034. + */
  13035. +#define KVADDR_TO_NID(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> 27)
  13036. +
  13037. +/*
  13038. + * Given a page frame number, convert it to a node id.
  13039. + */
  13040. +#define PFN_TO_NID(pfn) (((pfn) - PHYS_PFN_OFFSET) >> (27 - PAGE_SHIFT))
  13041. +
  13042. +/*
  13043. + * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
  13044. + * and returns the mem_map of that node.
  13045. + */
  13046. +#define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
  13047. +
  13048. +/*
  13049. + * Given a page frame number, find the owning node of the memory
  13050. + * and returns the mem_map of that node.
  13051. + */
  13052. +#define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn))
  13053. +
  13054. +/*
  13055. + * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
  13056. + * and returns the index corresponding to the appropriate page in the
  13057. + * node's mem_map.
  13058. + */
  13059. +#define LOCAL_MAP_NR(addr) \
  13060. + (((unsigned long)(addr) & 0x07ffffff) >> PAGE_SHIFT)
  13061. +
  13062. +#else
  13063. +
  13064. +#define PFN_TO_NID(addr) (0)
  13065. +
  13066. +#endif
  13067. +
  13068. +#endif
  13069. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/param.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/param.h
  13070. --- linux-2.4.26/include/asm-arm/arch-lh79520/param.h 1969-12-31 20:00:00.000000000 -0400
  13071. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/param.h 2005-11-02 17:37:32.000000000 -0400
  13072. @@ -0,0 +1,21 @@
  13073. +/*
  13074. + * linux/include/asm-arm/arch-lh79520/param.h
  13075. + *
  13076. + * Copyright (C) 2002 Lineo, Inc.
  13077. + *
  13078. + * This program is free software; you can redistribute it and/or modify
  13079. + * it under the terms of the GNU General Public License as published by
  13080. + * the Free Software Foundation; either version 2 of the License, or
  13081. + * (at your option) any later version.
  13082. + *
  13083. + * This program is distributed in the hope that it will be useful,
  13084. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13085. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13086. + * GNU General Public License for more details.
  13087. + *
  13088. + * You should have received a copy of the GNU General Public License
  13089. + * along with this program; if not, write to the Free Software
  13090. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  13091. + */
  13092. +
  13093. +#define HZ 100
  13094. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/rcpc.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/rcpc.h
  13095. --- linux-2.4.26/include/asm-arm/arch-lh79520/rcpc.h 1969-12-31 20:00:00.000000000 -0400
  13096. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/rcpc.h 2005-11-02 17:37:32.000000000 -0400
  13097. @@ -0,0 +1,222 @@
  13098. +/*
  13099. + * linux/include/asm-arm/arch-lh79520/rcpc.h
  13100. + *
  13101. + * Copyright (C) 2001 Sharp Microelectronics of the Americas, Inc.
  13102. + * Camas, WA
  13103. + * Portions Copyright (C) 2002 Lineo, Inc.
  13104. + *
  13105. + * DDD
  13106. + *
  13107. + * This program is free software; you can redistribute it and/or modify
  13108. + * it under the terms of the GNU General Public License version 2 as
  13109. + * published by the Free Software Foundation.
  13110. + *
  13111. + */
  13112. +
  13113. +
  13114. +#ifndef RCPC_H
  13115. +#define RCPC_H
  13116. +
  13117. +/*
  13118. + * RCPC: Reset, Clock, and Power Controller Register Structure
  13119. + */
  13120. +typedef __attribute((packed)) struct {
  13121. + u32 control; /* control register */
  13122. + u32 id; /* identification */
  13123. + u32 remap; /* Remap Control */
  13124. + u32 softReset; /* Soft Reset */
  13125. + u32 resetStatus; /* Reset Status */
  13126. + u32 resetStatusclr; /* Reset Status Clear */
  13127. + u32 HCLKPrescale; /* HCLK Prescaler */
  13128. + u32 CpuClkPrescale; /* ARM Core Clk Prescaler */
  13129. + u32 PCLKPrescale; /* PCLK Prescaler */
  13130. + u32 periphClkCtrl; /* Peripheral Clock Ctrl */
  13131. + u32 spareClkCtrl; /* Spare Clock Ctrl */
  13132. + u32 AHBClkCtrl; /* AHB Clock Ctrl */
  13133. + u32 periphClkSel; /* Peripheral Clock Select*/
  13134. + u32 spareClkSel; /* Spare Clock Select */
  13135. + u32 PWM0Prescale; /* PWM 0 Prescaler*/
  13136. + u32 PWM1Prescale; /* PWM 1 Prescaler*/
  13137. + u32 spare0Prescale; /* Spare clock 0 Prescaler*/
  13138. + u32 spare1Prescale; /* Spare clock 1 Prescaler*/
  13139. + u32 spare2Prescale; /* Spare clock 2 Prescaler*/
  13140. + u32 spare3Prescale; /* Spare clock 3 Prescaler*/
  13141. + u32 spare4Prescale; /* Spare clock 4 Prescaler*/
  13142. + u32 spare5Prescale; /* Spare clock 5 Prescaler*/
  13143. + u32 spare6Prescale; /* Spare clock 6 Prescaler*/
  13144. + u32 spare7Prescale; /* Spare clock 7 Prescaler*/
  13145. + u32 spare8Prescale; /* Spare clock 8 Prescaler*/
  13146. + u32 spare9Prescale; /* Spare clock 9 Prescaler*/
  13147. + u32 spare10Prescale; /* Spare clck 10 Prescaler*/
  13148. + u32 spare11Prescale; /* Spare clck 11 Prescaler*/
  13149. + u32 spare12Prescale; /* Spare clck 12 Prescaler*/
  13150. + u32 spare13Prescale; /* Spare clck 13 Prescaler*/
  13151. + u32 spare14Prescale; /* Spare clck 14 Prescaler*/
  13152. + u32 spare15Prescale; /* Spare clck 15 Prescaler*/
  13153. + u32 intConfig; /* Ext. Interrupt Config */
  13154. + u32 intClear; /* Ext. Interrupt Clear */
  13155. + u32 coreClkConfig; /* ARM Core Clock Config */
  13156. +} rcpcRegs_t;
  13157. +
  13158. +
  13159. +/*
  13160. + * RCPC Bit Fields
  13161. + */
  13162. +
  13163. +/*
  13164. + * control Register Bit Fields
  13165. + */
  13166. +#define RCPC_CTRL_EP _BIT(0) /* Enable PLL */
  13167. +#define RCPC_CTRL_EX _BIT(1) /* Enable Internal XTAL */
  13168. +
  13169. +#define RCPC_CTRL_PWRDWNSEL(n) _SBF(2,(n)) /* Power Down Mode Sel*/
  13170. +/* Mode Arguments to RCPC_CTRL_PWRDWNSEL(n) */
  13171. +#define PWRDWNSEL_ACTIVE 0
  13172. +#define PWRDWNSEL_STANDBY 1
  13173. +#define PWRDWNSEL_SLEEP 2
  13174. +#define PWRDWNSEL_STOP1 3
  13175. +#define PWRDWNSEL_STOP2 4
  13176. +
  13177. +#define RCPC_CTRL_OUTSEL(n) _SBF(5,(n))
  13178. +/* Arguments to RCPC_CTRL_OUTSEL(n) */
  13179. +#define OUTSEL_CLK_INTOSC 0
  13180. +#define OUTSEL_CLK_PLL 1
  13181. +#define OUTSEL_FCLK_CPU 2
  13182. +#define OUTSEL_HCLK 3
  13183. +
  13184. +#define RCPC_CTRL_CLKSEL_PLL _SBF(7,0)
  13185. +#define RCPC_CTRL_CLKSEL_EXT _SBF(7,1)
  13186. +
  13187. +#define RCPC_CTRL_WRTLOCK_LOCKED _SBF(9,0)
  13188. +#define RCPC_CTRL_WRTLOCK_ENABLED _SBF(9,1)
  13189. +
  13190. +/**********************************************************************
  13191. + * identification - Identification Register Bit Fields
  13192. + *********************************************************************/
  13193. +#define RCPC_ID_DEFAULT (0x5200)
  13194. +
  13195. +/**********************************************************************
  13196. + * remap - Remap Control Register Bit Fields
  13197. + *********************************************************************/
  13198. +#define RCPC_REMAP_SMEM0 (0)
  13199. +#define RCPC_REMAP_SDMEM0 (1)
  13200. +#define RCPC_REMAP_IMEM0 (2)
  13201. +
  13202. +/**********************************************************************
  13203. + * softreset - Soft Reset Register Bit Fields
  13204. + *********************************************************************/
  13205. +#define RCPC_SOFTRESET_ALL (0xDEAD)
  13206. +#define RCPC_SOFTRESET_GBL (0xDEAC)
  13207. +
  13208. +/**********************************************************************
  13209. + * resetstatus, resetstatusclr - Reset Status Register Bit Fields
  13210. + *********************************************************************/
  13211. +#define RCPC_RESET_STATUS_EXT _BIT(0)
  13212. +#define RCPC_RESET_STATUS_WDTO _BIT(1)
  13213. +
  13214. +/**********************************************************************
  13215. + * hclkPrescale - HCLK Prescaler Register Bit Fields
  13216. + * cpuclkPrescale - ARM Core Clock Prescaler Register Bit Fields
  13217. + * pclkPrescale - PCLK Prescaler Register Bit Fields
  13218. + * pwm0Prescale - PWM0 Prescaler Register Bit Fields
  13219. + * pwm1Prescale - PWM1 Prescaler Register Bit Fields
  13220. + * sparePrescale - Spare Prescaler Register Bit Fields
  13221. + * Note: not all constants are applicable to all registers.
  13222. + * See Reference.
  13223. + *********************************************************************/
  13224. +#define RCPC_PRESCALER_DIV1 _SBF(0,0)
  13225. +#define RCPC_PRESCALER_DIV2 _SBF(0,1)
  13226. +#define RCPC_PRESCALER_DIV4 _SBF(0,2)
  13227. +#define RCPC_PRESCALER_DIV6 _SBF(0,3)
  13228. +#define RCPC_PRESCALER_DIV8 _SBF(0,4)
  13229. +#define RCPC_PRESCALER_DIV16 _SBF(0,8)
  13230. +#define RCPC_PRESCALER_DIV30 _SBF(0,15)
  13231. +#define RCPC_PRESCALER_DIV32 _SBF(0,16)
  13232. +#define RCPC_PRESCALER_DIV64 _SBF(0,32)
  13233. +#define RCPC_PRESCALER_DIV128 _SBF(0,64)
  13234. +#define RCPC_PRESCALER_DIV256 _SBF(0,128)
  13235. +#define RCPC_PRESCALER_DIV65534 (0xFFFF)
  13236. +
  13237. +/**********************************************************************
  13238. + * periphclkctrl - Peripheral Clock Control Register Bit Fields
  13239. + * spareclkctrl - Spare Clock Control Register Bit Fields
  13240. + * ahbclkctrl - AHB Clock Control Register Bit Fields
  13241. + * Writing a "0" to a bit in these registers enables the
  13242. + * corresponding clock
  13243. + *********************************************************************/
  13244. +#define RCPC_CLKCTRL_U0_DISABLE _BIT(0)
  13245. +#define RCPC_CLKCTRL_U1_DISABLE _BIT(1)
  13246. +#define RCPC_CLKCTRL_U2_DISABLE _BIT(2)
  13247. +#define RCPC_CLKCTRL_CT0_DISABLE _BIT(3)
  13248. +#define RCPC_CLKCTRL_CT1_DISABLE _BIT(4)
  13249. +#define RCPC_CLKCTRL_CT2_DISABLE _BIT(5)
  13250. +#define RCPC_CLKCTRL_CT3_DISABLE _BIT(6)
  13251. +#define RCPC_CLKCTRL_PWM0_DISABLE _BIT(7)
  13252. +#define RCPC_CLKCTRL_PWM1_DISABLE _BIT(8)
  13253. +#define RCPC_CLKCTRL_RTC_DISABLE _BIT(9)
  13254. +#define RCPC_CLKCTRL_SPARE_DISABLE(f) _BIT(f)
  13255. +
  13256. +#define RCPC_SPARE_CLKCTRL_SSPCLK_DISABLE _BIT(1)
  13257. +#define RCPC_SPARE_CLKCTRL_LCDCLK_DISABLE _BIT(0)
  13258. +
  13259. +#define RCPC_CLKCTRL_DMAC_DISABLE _BIT(0)
  13260. +#define RCPC_CLKCTRL_HCLKSP0_DISABLE _BIT(1)
  13261. +
  13262. +/**********************************************************************
  13263. + * periphclksel - Peripheral Clock Select Register Bit Fields
  13264. + * Writing a "0" to U0-U2 in this register enables the
  13265. + * XTAL Oscillator as the clock source
  13266. + * Writing a "0" to CT0-CT3 in this register enables the
  13267. + * HCLK as the clock source
  13268. + *********************************************************************/
  13269. +#define RCPC_PCLKSEL_U0_EXT _BIT(0) /* U0 Clock Source */
  13270. +#define RCPC_PCLKSEL_U1_EXT _BIT(1) /* U1 Clock Source */
  13271. +#define RCPC_PCLKSEL_U2_EXT _BIT(2) /* U2 Clock Source */
  13272. +#define RCPC_PCLKSEL_CT0_EXT _BIT(3) /* CT0 Clock Source */
  13273. +#define RCPC_PCLKSEL_CT1_EXT _BIT(4) /* CT1 Clock Source */
  13274. +#define RCPC_PCLKSEL_CT2_EXT _BIT(5) /* CT2 Clock Source */
  13275. +#define RCPC_PCLKSEL_CT3_EXT _BIT(6) /* CT3 Clock Source */
  13276. +#define RCPC_PCLKSEL_RTC_32 0 /* RTC Clock Source 32KHz */
  13277. +#define RCPC_PCLKSEL_RTC_EXT _SBF(7,2) /* RTC Clock Source Ext */
  13278. +
  13279. +/**********************************************************************
  13280. + * spareclksel - Peripheral Clock Select Register Bit Fields
  13281. + * Writing a "0" to a bit in this register enables the
  13282. + * HCLK as the clock source
  13283. + *********************************************************************/
  13284. +#define RCPC_SCLKSEL_SP(n) _SBF((n),1) /* SP2 - SP15 */
  13285. +#define RCPC_SCLKSEL_SSPCLK _BIT(1) /* SSP Clock External */
  13286. +#define RCPC_SCLKSEL_LCDCLK _BIT(0) /* LCD Clock External */
  13287. +
  13288. +/**********************************************************************
  13289. + * intconfig - External Interrupt Configuration Register Bit Fields
  13290. + *********************************************************************/
  13291. +#define RCPC_INTCONFIG(f,v) _SBF((f),(v))
  13292. +/* RCPC_INTCONFIG arguments for 'f' parameter */
  13293. +#define RCPC_INT0 0
  13294. +#define RCPC_INT1 2
  13295. +#define RCPC_INT2 4
  13296. +#define RCPC_INT3 6
  13297. +#define RCPC_INT4 8
  13298. +#define RCPC_INT5 10
  13299. +#define RCPC_INT6 12
  13300. +#define RCPC_INT7 14
  13301. +/* RCPC_INTCONFIG arguments for 'v' parameter */
  13302. +#define RCPC_INT_LLT 0 /* Low Level Trigger */
  13303. +#define RCPC_INT_HLT 1 /* High Level Trigger */
  13304. +#define RCPC_INT_FET 2 /* Falling Edge Trigger */
  13305. +#define RCPC_INT_RET 3 /* Rising Edge Trigger */
  13306. +
  13307. +/**********************************************************************
  13308. + * intclear - External Interrupt Clear Register Bit Fields
  13309. + *********************************************************************/
  13310. +#define RCPC_INTCLEAR(n) _BIT(n) /* Clear Edge Interrupt 'n' */
  13311. +
  13312. +/**********************************************************************
  13313. + * coreclkconfig - Core Clock Configuration Register Bit Fields
  13314. + *********************************************************************/
  13315. +#define RCPC_CCC_STDASYNCH 0 /* Standard Mode, Asynch operation */
  13316. +#define RCPC_CCC_FASTBUS 1 /* Fast Bus Extension Mode */
  13317. +#define RCPC_CCC_STDSYNCH 2 /* Standard Mode, Synch operation */
  13318. +
  13319. +#endif // RCPC_H
  13320. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/serial.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/serial.h
  13321. --- linux-2.4.26/include/asm-arm/arch-lh79520/serial.h 1969-12-31 20:00:00.000000000 -0400
  13322. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/serial.h 2005-11-02 17:37:32.000000000 -0400
  13323. @@ -0,0 +1,34 @@
  13324. +/*
  13325. + * linux/include/asm-arm/arch-lh79520/serial.h
  13326. + *
  13327. + * Copyright (c) 2002 Lineo, Inc.
  13328. + *
  13329. + * This program is free software; you can redistribute it and/or modify
  13330. + * it under the terms of the GNU General Public License version 2 as
  13331. + * published by the Free Software Foundation.
  13332. + *
  13333. + */
  13334. +#ifndef __ASM_ARCH_SERIAL_H
  13335. +#define __ASM_ARCH_SERIAL_H
  13336. +
  13337. +/*
  13338. + * This assumes you have a 14.7456 MHz clock for your UART.
  13339. + */
  13340. +#define BASE_BAUD (14745600 / 16)
  13341. +
  13342. +/*
  13343. + * Standard COM flags
  13344. + */
  13345. +#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
  13346. +
  13347. +#define RS_TABLE_SIZE 2
  13348. +
  13349. +#define STD_SERIAL_PORT_DEFNS \
  13350. + /* MAGIC UART CLK PORT IRQ FLAGS */ \
  13351. + { 0, BASE_BAUD, UART0_BASE, IRQ_UART0, STD_COM_FLAGS }, /* ttyAM0 */ \
  13352. + { 0, BASE_BAUD, UART1_BASE, IRQ_UART1, STD_COM_FLAGS }, /* ttyAM0 */ \
  13353. + { 0, BASE_BAUD, UART2_BASE, IRQ_UART2, STD_COM_FLAGS }, /* ttyAM1 */ \
  13354. +
  13355. +#define EXTRA_SERIAL_PORT_DEFNS
  13356. +
  13357. +#endif
  13358. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/smc_pl090.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/smc_pl090.h
  13359. --- linux-2.4.26/include/asm-arm/arch-lh79520/smc_pl090.h 1969-12-31 20:00:00.000000000 -0400
  13360. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/smc_pl090.h 2005-11-02 17:37:32.000000000 -0400
  13361. @@ -0,0 +1,68 @@
  13362. +/*
  13363. + * linux/include/asm-arm/arch-lh79520/smc_pl090.h
  13364. + *
  13365. + * Copyright (C) 2002 Lineo, Inc.
  13366. + *
  13367. + * This program is free software; you can redistribute it and/or modify
  13368. + * it under the terms of the GNU General Public License version 2 as
  13369. + * published by the Free Software Foundation.
  13370. + *
  13371. + *
  13372. + * This file contains the structure definitions and manifest
  13373. + * constants for ARM IP component:
  13374. + * Static Memory Controller PrimeCell PL090
  13375. + *
  13376. + * References:
  13377. + * (1) ARM PrimeCell Static Memory Controller (PL090)
  13378. + * Technical Reference Manual, ARM DDI 0160C.
  13379. + * (2) ARM Isis Technical Reference Manual, System on Chip Group,
  13380. + * ARM SC063-TRM-0001-B
  13381. + *
  13382. + * COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
  13383. + * CAMAS, WA
  13384. + */
  13385. +
  13386. +#ifndef SMC_PL090_H
  13387. +#define SMC_PL090_H
  13388. +
  13389. +#ifndef _BIT
  13390. +#define _BIT(n) (1 << (n))
  13391. +#endif
  13392. +
  13393. +#ifndef _SBF
  13394. +#define _SBF(f,v) ((v) << (f))
  13395. +#endif
  13396. +
  13397. +/*
  13398. + * Static Memory Controller Module Register Structure
  13399. + */
  13400. +typedef struct {
  13401. + volatile unsigned int bcr0; /* Configuration for bank 0 */
  13402. + volatile unsigned int bcr1; /* Configuration for bank 1 */
  13403. + volatile unsigned int bcr2; /* Configuration for bank 2 */
  13404. + volatile unsigned int bcr3; /* Configuration for bank 3 */
  13405. + volatile unsigned int bcr4; /* Configuration for bank 4 */
  13406. + volatile unsigned int bcr5; /* Configuration for bank 5 */
  13407. + volatile unsigned int bcr6; /* Configuration for bank 6 */
  13408. + volatile unsigned int bcr7; /* Configuration for bank 7 */
  13409. +} smcRegs_t;
  13410. +
  13411. +/*
  13412. + * Static Memory Controller Bit Field constants
  13413. + */
  13414. +#define IDCY(n) _SBF(0,((n)&0x0F)) /* Idle Cycle Time */
  13415. +#define WST1(n) _SBF(5,((n)&0x1F)) /* Wait State 1 */
  13416. +#define RBLE(n) _SBF(10,((n)&0x01)) /* Read Byte Lane Enable */
  13417. +#define WST2(n) _SBF(11,((n)&0x1F)) /* Wait State 2 */
  13418. +#define BUSERR _BIT(24) /* Bus Transfer Error Flag */
  13419. +#define WPERR _BIT(25) /* Write Protect Error Flag */
  13420. +#define WP _BIT(26) /* Write Protect */
  13421. +#define BM _BIT(27) /* Burst Mode */
  13422. +#define MW8 _SBF(28,0) /* Memory width 8 bits */
  13423. +#define MW16 _SBF(28,1) /* Memory width 16 bits */
  13424. +#define MW32 _SBF(28,2) /* Memory width 32 bits */
  13425. +#define ATNONE _SBF(30,0) /* No Retry */
  13426. +#define ATEVERY _SBF(30,2) /* Retry after every access */
  13427. +#define ATAFTER4 _SBF(30,3) /* Retry after 4 accesses */
  13428. +
  13429. +#endif /* SMC_PL090_H */
  13430. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/ssp_lh7x.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/ssp_lh7x.h
  13431. --- linux-2.4.26/include/asm-arm/arch-lh79520/ssp_lh7x.h 1969-12-31 20:00:00.000000000 -0400
  13432. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/ssp_lh7x.h 2005-11-02 17:37:32.000000000 -0400
  13433. @@ -0,0 +1,159 @@
  13434. +/* vi: set sw=4 ts=4 ai: */
  13435. +
  13436. +/**********************************************************************
  13437. +* linux/include/asm-arm/arch-lh79520/ssp_lh7x.h
  13438. +*
  13439. +* Provide SSP (Synchronous Serial Port) types & definitions
  13440. +* for LH7x EVB boards
  13441. +*
  13442. +* Copyright (C) 2002 Lineo, Inc.
  13443. +*
  13444. +* This program is free software; you can redistribute it and/or modify
  13445. +* it under the terms of the GNU General Public License (GPL) version 2
  13446. +* as published by the Free Software Foundation.
  13447. +*
  13448. +**********************************************************************/
  13449. +
  13450. +#ifndef _SSP_LH7X_h
  13451. +#define _SSP_LH7X_h
  13452. +
  13453. +//#define SSP_BASE SSP_PHYS
  13454. +
  13455. +/*********************************************************************
  13456. +* Synchronous Serial Port Registers
  13457. +*********************************************************************/
  13458. +#define SSPCR0 (SSP_BASE+0x00) /* Control reg. 0 */
  13459. +#define SSPCR1 (SSP_BASE+0x04) /* Control reg. 1 */
  13460. +#define SSPDR (SSP_BASE+0x08) /* Receive FIFO (Read)*/
  13461. + /* Transmit FIFO data reg. (Write)*/
  13462. +#define SSPSR (SSP_BASE+0x0C) /* Status Reg. */
  13463. +#define SSPCPSR (SSP_BASE+0x10) /* Clock prescale reg. */
  13464. +#define SSPIIR (SSP_BASE+0x14) /* Interrupt identification reg. (Read) */
  13465. +#define SSPICR SSPIIR /* Interrupt clear reg. (Write) */
  13466. +/*
  13467. +* RESERVED:
  13468. +* 0x18 - 0x3C
  13469. +* 0x40 - 0x90 (For test purposes)
  13470. +* 0x94 - 0xFF
  13471. +*/
  13472. +
  13473. +/*********************************************************************
  13474. +* Synchronous Serial Port Register Structure
  13475. +*********************************************************************/
  13476. +typedef struct {
  13477. + volatile unsigned int cr0;
  13478. + volatile unsigned int cr1;
  13479. + volatile unsigned int dr;
  13480. + volatile unsigned int sr;
  13481. + volatile unsigned int cpsr;
  13482. + union {
  13483. + volatile unsigned int iir;
  13484. + volatile unsigned int icr;
  13485. + } u;
  13486. + volatile unsigned int reservedssp[58];
  13487. +} sspRegs_t;
  13488. +
  13489. +/*
  13490. +* To use the structure, declare the following in your source
  13491. +* static sspRegs_t *ssp = (sspRegs_t *)SSP_BASE;
  13492. +*/
  13493. +
  13494. +/*********************************************************************
  13495. +* A couple of macros we use here...
  13496. +*********************************************************************/
  13497. +#ifndef _BIT
  13498. +#define _BIT(n) (1 << (n))
  13499. +#endif
  13500. +#ifndef _SBF
  13501. +#define _SBF(f,v) ((v) << (f))
  13502. +#endif
  13503. +#ifndef _BITMASK
  13504. +#define _BITMASK(field_width) ( _BIT(field_width) - 1)
  13505. +#endif
  13506. +
  13507. +/*********************************************************************
  13508. +* Synchronous Serial Port Bit Fields
  13509. +*********************************************************************/
  13510. +
  13511. +/*********************************************************************
  13512. +* Control 0 Register Bit Fields
  13513. +*********************************************************************/
  13514. +/* Valid range for argument to SSP_CR0_DSS(n) is [4-16] */
  13515. +#define SSP_CR0_DSS(n) _SBF(0,(n)-1) /* Data Size Select */
  13516. +#define SSP_CR0_FRF_MOT _SBF(4,0) /* Motorola SPI frame */
  13517. +#define SSP_CR0_FRF_TI _SBF(4,1) /* TI synchronous serial frame */
  13518. +#define SSP_CR0_FRF_NS _SBF(4,2) /* National Microwire frame */
  13519. +#define SSP_CR0_SPO _BIT(6) /* SPI Polarity */
  13520. +#define SSP_CR0_SPH _BIT(7) /* SPI Polarity */
  13521. +#define SSP_CR0_SCR(n) _SBF(8,(n)) /* Serial Clock Rate */
  13522. +
  13523. +/*********************************************************************
  13524. +* Control 1 Register Bit Fields
  13525. +*********************************************************************/
  13526. +#define SSP_CR1_RIE _BIT(0) /* RX FIFO interrupt enable */
  13527. +#define SSP_CR1_TIE _BIT(1) /* TX FIFO interrupt enable */
  13528. +#define SSP_CR1_RORIE _BIT(2) /* RX FIFO overrun int. enable */
  13529. +#define SSP_CR1_LBM _BIT(3) /* Loop back mode */
  13530. +#define SSP_CR1_SSE _BIT(4) /* Synchronous serial port enable */
  13531. +
  13532. +/*********************************************************************
  13533. +* Status Register Bit Fields
  13534. +*********************************************************************/
  13535. +#define SSP_SR_TFE _BIT(0) /* TX FIFO Empty */
  13536. +#define SSP_SR_TNF _BIT(1) /* TX FIFO not full */
  13537. +#define SSP_SR_RNE _BIT(2) /* RX FIFO not empty */
  13538. +#define SSP_SR_RFF _BIT(3) /* RX FIFO full */
  13539. +#define SSP_SR_BSY _BIT(4) /* Busy flag */
  13540. +
  13541. +/*********************************************************************
  13542. +* Clock Prescale Divisor Register Bit Fields
  13543. +*********************************************************************/
  13544. +#define SSP_CPSR_CPDVSR(n) _SBF(0,(n)&0xFE) /* Clock prescale divisor */
  13545. +
  13546. +/*********************************************************************
  13547. +* Interrupt Identification / Interrupt Clear Register Bit Fields
  13548. +* Note: ARM Reference conflicts on the definition of these bits
  13549. +* and the usage of the registers. Verify before using these
  13550. +* definitions.
  13551. +*********************************************************************/
  13552. +#define SSP_IIR_RIS _BIT(0) /* TX FIFO Empty */
  13553. +#define SSP_IIR_TIS _BIT(1) /* TX FIFO not full */
  13554. +#define SSP_IIR_RORIS _BIT(2) /* RX FIFO overrun int. status */
  13555. +
  13556. +/*********************************************************************
  13557. +* The TouchScreen communication BPS (bits per second)
  13558. +*********************************************************************/
  13559. +#define LH7x_TS_BPS 100000
  13560. +
  13561. +/*********************************************************************
  13562. +* Misc.
  13563. +*********************************************************************/
  13564. +#define SSP_MAX_TIMEOUT 0xffff
  13565. +#define RCPC_SSP_PRESCALE_MAX 256
  13566. +#define SSP_PRESCALE_MAX 254
  13567. +#define SSP_PRESCALE_MIN 2
  13568. +#define SSP_DIVIDER_MAX 256
  13569. +
  13570. +/* Define values to associate with the device we are conencted to */
  13571. +#define SSP_INVALID_DEVICE 0xFF
  13572. +#define SSP_EEPROM 0x00
  13573. +#define SSP_TOUCHSCREEN 0x01
  13574. +
  13575. +/*********************************************************************
  13576. +* Context Structure Definition
  13577. +*********************************************************************/
  13578. +typedef struct sspContext_t sspContext_t;
  13579. +struct sspContext_t {
  13580. + wait_queue_head_t *irq_wait_ptr;
  13581. + int irq_state;
  13582. + int ssp_dev_sel; // cpld->ssp_dev_sel is not readable !!!
  13583. + int ts_txTimeout;
  13584. + int ts_rxTimeout;
  13585. + int ee_txTimeout;
  13586. + int ee_rxTimeout;
  13587. + int haveIrq;
  13588. + spinlock_t sspLock;
  13589. +};
  13590. +
  13591. +#endif /* _SSP_LH7X_h */
  13592. +
  13593. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/system.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/system.h
  13594. --- linux-2.4.26/include/asm-arm/arch-lh79520/system.h 1969-12-31 20:00:00.000000000 -0400
  13595. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/system.h 2005-11-02 17:37:32.000000000 -0400
  13596. @@ -0,0 +1,28 @@
  13597. +/*
  13598. + * linux/include/asm-arm/arch-lh79520/system.h
  13599. + *
  13600. + * Copyright (C) 2002 Lineo, Inc.
  13601. + *
  13602. + * This program is free software; you can redistribute it and/or modify
  13603. + * it under the terms of the GNU General Public License version 2 as
  13604. + * published by the Free Software Foundation.
  13605. + *
  13606. + * Changelog:
  13607. + * 07-Jan-2001 Duck Created
  13608. + */
  13609. +
  13610. +#ifndef __ASM_ARCH_SYSTEM_H
  13611. +#define __ASM_ARCH_SYSTEM_H
  13612. +
  13613. +static inline void
  13614. +arch_idle(void)
  13615. +{
  13616. +}
  13617. +
  13618. +static inline void
  13619. +arch_reset(char mode)
  13620. +{
  13621. + cpu_reset(0);
  13622. +}
  13623. +
  13624. +#endif
  13625. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/time.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/time.h
  13626. --- linux-2.4.26/include/asm-arm/arch-lh79520/time.h 1969-12-31 20:00:00.000000000 -0400
  13627. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/time.h 2005-11-02 17:37:32.000000000 -0400
  13628. @@ -0,0 +1,111 @@
  13629. +/*
  13630. + * linux/include/asm-arm/arch-lh79520/time.h
  13631. + *
  13632. + * Copyright (C) 2002 Lineo, Inc.
  13633. + *
  13634. + * This program is free software; you can redistribute it and/or modify
  13635. + * it under the terms of the GNU General Public License version 2 as
  13636. + * published by the Free Software Foundation.
  13637. + *
  13638. + * Changelog:
  13639. + * 07-Jan-2002 Duck Created
  13640. + */
  13641. +
  13642. +#ifndef __ASM_ARCH_TIME_H
  13643. +#define __ASM_ARCH_TIME_H
  13644. +
  13645. +#include <asm/arch/hardware.h>
  13646. +#include <asm/arch/rcpc.h>
  13647. +
  13648. +/*
  13649. + * Dual Timer Module Register Structure
  13650. + * The LH79520 has two of these.
  13651. + */
  13652. +typedef struct {
  13653. + unsigned int Timer1Load;
  13654. + unsigned int Timer1Value;
  13655. + unsigned int Timer1Control;
  13656. + unsigned int Timer1Clear;
  13657. + unsigned int Timer1Test;
  13658. + unsigned int reservedtmr1[3];
  13659. + unsigned int Timer2Load;
  13660. + unsigned int Timer2Value;
  13661. + unsigned int Timer2Control;
  13662. + unsigned int Timer2Clear;
  13663. + unsigned int Timer2Test;
  13664. + unsigned int reservedtmr2[3];
  13665. +} timerRegs_t;
  13666. +
  13667. +
  13668. +/*
  13669. + * Timer Control Register Bit Field constants
  13670. + * All other bits in the Timer Control Register must be written as
  13671. + * zero
  13672. + */
  13673. +#define TMRCTRL_ENABLE _SBF(7,1)
  13674. +#define TMRCTRL_DISABLE _SBF(7,0)
  13675. +#define TMRCTRL_MODE_PERIODIC _SBF(6,1)
  13676. +#define TMRCTRL_MODE_FREERUN _SBF(6,0)
  13677. +#define TMRCTRL_CASCADE_ENABLE _SBF(4,1)
  13678. +#define TMRCTRL_CASCADE_DISABLE _SBF(4,0)
  13679. +#define TMRCTRL_PRESCALE1 _SBF(2,0)
  13680. +#define TMRCTRL_PRESCALE16 _SBF(2,1)
  13681. +#define TMRCTRL_PRESCALE256 _SBF(2,2)
  13682. +
  13683. +/*
  13684. + * what to load the timer with
  13685. + * it's 14.745600 MHz * 21 (PLL multiplier) / 6 (PCLK prescalar) / 16 (TIMER_PRESCALE) / HZ
  13686. + * this gives us timerLoad=32256 for Hz=100
  13687. + */
  13688. +#define TIMER_PRESCALE 16
  13689. +
  13690. +static void
  13691. +timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  13692. +{
  13693. + timerRegs_t *mod1Timer = (timerRegs_t *)IO_ADDRESS( TIMER0_PHYS);
  13694. +
  13695. + mod1Timer->Timer1Clear = 1; /* clear interrupt */
  13696. +
  13697. + do_timer(regs);
  13698. +}
  13699. +
  13700. +
  13701. +static inline void
  13702. +setup_timer(void)
  13703. +{
  13704. + rcpcRegs_t *rcpc = (rcpcRegs_t *)IO_ADDRESS( RCPC_PHYS);
  13705. + timerRegs_t *mod1Timer = (timerRegs_t *)IO_ADDRESS( TIMER0_PHYS), /* first timer module */
  13706. + *mod2Timer = (timerRegs_t *)IO_ADDRESS( TIMER1_PHYS); /* second timer module */
  13707. + u32 timerLoad;
  13708. +
  13709. + timerLoad = hclkfreq_get() / TIMER_PRESCALE / HZ;
  13710. + printk( "setup_timer(): timerLoad=%d\n", timerLoad);
  13711. +
  13712. + /* stop all timers */
  13713. + mod1Timer->Timer1Control = 0;
  13714. + mod1Timer->Timer2Control = 0;
  13715. + mod2Timer->Timer1Control = 0;
  13716. + mod2Timer->Timer2Control = 0;
  13717. +
  13718. + /* enable clock to first timer */
  13719. + rcpc->control |= RCPC_CTRL_WRTLOCK_ENABLED; /* unlock RCPC registers */
  13720. + barrier();
  13721. +
  13722. + rcpc->periphClkCtrl &= ~RCPC_CLKCTRL_CT0_DISABLE;
  13723. + rcpc->control &= ~RCPC_CTRL_WRTLOCK_ENABLED; /* lock RCPC registers */
  13724. +
  13725. + /* setup the FRC in the first timer in the first module. */
  13726. + mod1Timer->Timer1Load = timerLoad;
  13727. +
  13728. + mod1Timer->Timer1Control = TMRCTRL_ENABLE |
  13729. + TMRCTRL_MODE_PERIODIC |
  13730. + TMRCTRL_PRESCALE16;
  13731. +
  13732. +
  13733. +
  13734. + timer_irq.handler = timer_interrupt;
  13735. + timer_irq.flags = SA_INTERRUPT;
  13736. + setup_arm_irq( IRQ_TIMER0, &timer_irq);
  13737. +}
  13738. +
  13739. +#endif
  13740. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/timex.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/timex.h
  13741. --- linux-2.4.26/include/asm-arm/arch-lh79520/timex.h 1969-12-31 20:00:00.000000000 -0400
  13742. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/timex.h 2005-11-02 17:37:32.000000000 -0400
  13743. @@ -0,0 +1,16 @@
  13744. +/*
  13745. + * linux/include/asm-arm/arch-lh79520/timex.h
  13746. + *
  13747. + * Copyright (C) 2002 Lineo, Inc.
  13748. + *
  13749. + * This program is free software; you can redistribute it and/or modify
  13750. + * it under the terms of the GNU General Public License version 2 as
  13751. + * published by the Free Software Foundation.
  13752. + *
  13753. + */
  13754. +
  13755. +/*
  13756. + * On the LH79520, the DDD
  13757. + */
  13758. +#define CLOCK_TICK_RATE (PLL_CLOCK / 6 / 16)
  13759. +
  13760. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/uncompress.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/uncompress.h
  13761. --- linux-2.4.26/include/asm-arm/arch-lh79520/uncompress.h 1969-12-31 20:00:00.000000000 -0400
  13762. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/uncompress.h 2005-11-02 17:37:32.000000000 -0400
  13763. @@ -0,0 +1,52 @@
  13764. +/*
  13765. + * linux/include/asm-arm/arch-lh79520/uncompress.h
  13766. + *
  13767. + * Copyright (C) 2002 Lineo, Inc.
  13768. + *
  13769. + * This program is free software; you can redistribute it and/or modify
  13770. + * it under the terms of the GNU General Public License as published by
  13771. + * the Free Software Foundation; either version 2 of the License, or
  13772. + * (at your option) any later version.
  13773. + *
  13774. + * This program is distributed in the hope that it will be useful,
  13775. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13776. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13777. + * GNU General Public License for more details.
  13778. + *
  13779. + * You should have received a copy of the GNU General Public License
  13780. + * along with this program; if not, write to the Free Software
  13781. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  13782. + */
  13783. +
  13784. +#define UART_DR (*(volatile unsigned char *)0xfffc1000)
  13785. +#define UART_FR (*(volatile unsigned short *)0xfffc1018)
  13786. +
  13787. +#define UARTFR_TXFE 0x80
  13788. +
  13789. +/*
  13790. + * This does not append a newline
  13791. + */
  13792. +static void
  13793. +puts( const char *s)
  13794. +{
  13795. + while( *s) {
  13796. + while( (UART_FR & UARTFR_TXFE) == 0) /* wait for room in the tx FIFO */
  13797. + ;
  13798. +
  13799. + UART_DR = *s; /* ship a char */
  13800. +
  13801. + if (*s == '\n') { /* it's a new line */
  13802. + while( (UART_FR & UARTFR_TXFE) == 0) /* wait for room in the tx FIFO */
  13803. + ;
  13804. +
  13805. + UART_DR = '\r'; /* ship a carriage return */
  13806. + }
  13807. + s++;
  13808. + }
  13809. +}
  13810. +
  13811. +/*
  13812. + * nothing to do
  13813. + */
  13814. +#define arch_decomp_setup()
  13815. +#define arch_decomp_wdog()
  13816. diff -urN linux-2.4.26/include/asm-arm/arch-lh79520/vmalloc.h linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/vmalloc.h
  13817. --- linux-2.4.26/include/asm-arm/arch-lh79520/vmalloc.h 1969-12-31 20:00:00.000000000 -0400
  13818. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/arch-lh79520/vmalloc.h 2005-11-02 17:37:32.000000000 -0400
  13819. @@ -0,0 +1,32 @@
  13820. +/*
  13821. + * linux/include/asm-arm/arch-lh79520/vmalloc.h
  13822. + *
  13823. + * Copyright (C) 2002 Lineo, Inc.
  13824. + *
  13825. + * This program is free software; you can redistribute it and/or modify
  13826. + * it under the terms of the GNU General Public License as published by
  13827. + * the Free Software Foundation; either version 2 of the License, or
  13828. + * (at your option) any later version.
  13829. + *
  13830. + * This program is distributed in the hope that it will be useful,
  13831. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13832. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13833. + * GNU General Public License for more details.
  13834. + *
  13835. + * You should have received a copy of the GNU General Public License
  13836. + * along with this program; if not, write to the Free Software
  13837. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  13838. + */
  13839. +
  13840. +/*
  13841. + * Just any arbitrary offset to the start of the vmalloc VM area: the
  13842. + * current 8MB value just means that there will be a 8MB "hole" after the
  13843. + * physical memory until the kernel virtual memory starts. That means that
  13844. + * any out-of-bounds memory accesses will hopefully be caught.
  13845. + * The vmalloc() routines leaves a hole of 4kB between each vmalloced
  13846. + * area for the same reason. ;)
  13847. + */
  13848. +#define VMALLOC_OFFSET (8*1024*1024)
  13849. +#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
  13850. +#define VMALLOC_VMADDR(x) ((unsigned long)(x))
  13851. +#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
  13852. diff -urN linux-2.4.26/include/asm-arm/hardware/cradle.h linux-2.4.26-vrs1-lnode80/include/asm-arm/hardware/cradle.h
  13853. --- linux-2.4.26/include/asm-arm/hardware/cradle.h 1969-12-31 20:00:00.000000000 -0400
  13854. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/hardware/cradle.h 2005-11-02 17:37:32.000000000 -0400
  13855. @@ -0,0 +1,14 @@
  13856. +/*
  13857. + * cradle.h
  13858. + */
  13859. +#ifndef _INCLUDE_CRADLE_H_
  13860. +#define _INCLUDE_CRADLE_H_
  13861. +
  13862. +#define CRADLE_MAJOR 254
  13863. +
  13864. +#define CRADLE_GET_DOCKING_STATE_IOCTL 0
  13865. +
  13866. +#define CRADLE_DOCKED_STATE 0
  13867. +#define CRADLE_UNDOCKED_STATE 1
  13868. +
  13869. +#endif
  13870. diff -urN linux-2.4.26/include/asm-arm/hardware/lcd_contrast.h linux-2.4.26-vrs1-lnode80/include/asm-arm/hardware/lcd_contrast.h
  13871. --- linux-2.4.26/include/asm-arm/hardware/lcd_contrast.h 1969-12-31 20:00:00.000000000 -0400
  13872. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/hardware/lcd_contrast.h 2005-11-02 17:37:32.000000000 -0400
  13873. @@ -0,0 +1,30 @@
  13874. +/*
  13875. + lcd_contrast.h
  13876. +
  13877. +
  13878. +These values are intended to be passed to the
  13879. +pl110fb lcd driver. The driver was modified to control
  13880. +a Maxim contrast controller to make life easy.
  13881. +
  13882. +*/
  13883. +
  13884. +
  13885. +#ifndef _LCD_CONTRAST_
  13886. +#define _LCD_CONTRAST_
  13887. +
  13888. +
  13889. +//ioctls
  13890. +#define LCD_CONTRAST_RESET 0
  13891. +#define LCD_CONTRAST_INC 1
  13892. +#define LCD_CONTRAST_DEC 2
  13893. +
  13894. +#define LCD_CONTRAST_PRESET 3
  13895. +// above takes parameters (0 - 63)
  13896. +// 0 - reset
  13897. +// 31 - highest
  13898. +// 63 - lowest
  13899. +
  13900. +
  13901. +#endif //__LCD_CONTRAST__
  13902. +
  13903. +
  13904. diff -urN linux-2.4.26/include/asm-arm/hardware/serial_amba_pl011.h linux-2.4.26-vrs1-lnode80/include/asm-arm/hardware/serial_amba_pl011.h
  13905. --- linux-2.4.26/include/asm-arm/hardware/serial_amba_pl011.h 1969-12-31 20:00:00.000000000 -0400
  13906. +++ linux-2.4.26-vrs1-lnode80/include/asm-arm/hardware/serial_amba_pl011.h 2005-11-02 17:37:32.000000000 -0400
  13907. @@ -0,0 +1,114 @@
  13908. +/*
  13909. + * linux/include/asm-arm/hardware/serial_amba_pl011.h
  13910. + *
  13911. + * Internal header file for AMBA PrimeCell PL011 serial ports
  13912. + *
  13913. + * Copyright (C) 2002 Lineo, Inc.
  13914. + *
  13915. + * Based on serial_amba.h, which is:
  13916. + * Copyright (C) ARM Limited
  13917. + * Copyright (C) 2000 Deep Blue Solutions Ltd.
  13918. + *
  13919. + * This program is free software; you can redistribute it and/or modify
  13920. + * it under the terms of the GNU General Public License as published by
  13921. + * the Free Software Foundation; either version 2 of the License, or
  13922. + * (at your option) any later version.
  13923. + *
  13924. + * This program is distributed in the hope that it will be useful,
  13925. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13926. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13927. + * GNU General Public License for more details.
  13928. + *
  13929. + * You should have received a copy of the GNU General Public License
  13930. + * along with this program; if not, write to the Free Software
  13931. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  13932. + */
  13933. +#ifndef ASM_ARM_HARDWARE_SERIAL_AMBA_PL011_H
  13934. +#define ASM_ARM_HARDWARE_SERIAL_AMBA_PL011_H
  13935. +
  13936. +/* -------------------------------------------------------------------------------
  13937. + * From AMBA UART (PL011) TRM
  13938. + * -------------------------------------------------------------------------------
  13939. + * UART Register Offsets.
  13940. + */
  13941. +#define AMBA_UARTDR 0x00 /* Data read or written from the interface. */
  13942. +#define AMBA_UARTRSR 0x04 /* Receive status register (Read). */
  13943. +#define AMBA_UARTECR 0x04 /* Error clear register (Write). */
  13944. +
  13945. +
  13946. +#define AMBA_UARTFR 0x18 /* Flag register (Read only). */
  13947. +#define AMBA_UARTILPR 0x20 /* IrDA low power counter register. */
  13948. +#define AMBA_UARTIBRD 0x24 /* Integer baud rate divisor. */
  13949. +#define AMBA_UARTFBRD 0x28 /* Fractional baud rate divisor. */
  13950. +#define AMBA_UARTLCR_H 0x2C /* Line control register, high byte. */
  13951. +#define AMBA_UARTCR 0x30 /* Control register. */
  13952. +#define AMBA_UARTIFLS 0x34 /* Interrupt FIFO level select. */
  13953. +#define AMBA_UARTIMSC 0x38 /* Interrupt Mask Set/Clear. */
  13954. +#define AMBA_UARTRIS 0x3C /* Raw Interrupt status register (Read). */
  13955. +#define AMBA_UARTMIS 0x40 /* Masked Interrupt status register (Read). */
  13956. +#define AMBA_UARTICR 0x44 /* Interrupt clear register (Write). */
  13957. +
  13958. +#define AMBA_UARTRSR_OE 0x0800 /* Overrun error */
  13959. +#define AMBA_UARTRSR_BE 0x0400 /* Break error */
  13960. +#define AMBA_UARTRSR_PE 0x0200 /* Parity error */
  13961. +#define AMBA_UARTRSR_FE 0x0100 /* framing error */
  13962. +
  13963. +#define AMBA_UARTFR_TXFF 0x20 /* Tx FIFO full */
  13964. +#define AMBA_UARTFR_RXFE 0x10 /* Rx FIFO empty */
  13965. +#define AMBA_UARTFR_BUSY 0x08 /* busy xmitting */
  13966. +#define AMBA_UARTFR_DCD 0x04
  13967. +#define AMBA_UARTFR_DSR 0x02
  13968. +#define AMBA_UARTFR_CTS 0x01
  13969. +#define AMBA_UARTFR_TMSK (AMBA_UARTFR_TXFF + AMBA_UARTFR_BUSY)
  13970. +
  13971. +/* Interrupt Mask Set/Clear register bits */
  13972. +#define AMBA_UARTIMSC_RTIM 0x40 /* Rx timeout interrupt mask */
  13973. +#define AMBA_UARTIMSC_TXIM 0x20 /* Tx interrupt mask */
  13974. +#define AMBA_UARTIMSC_RXIM 0x10 /* Rx interrupt mask */
  13975. +#define AMBA_UARTIMSC_DSRMIM 0x08 /* DSR Modem Interrupt mask */
  13976. +#define AMBA_UARTIMSC_DCDMIM 0x04 /* DCD Modem Interrupt mask */
  13977. +#define AMBA_UARTIMSC_CTSMIM 0x02 /* CTS Modem Interrupt mask */
  13978. +#define AMBA_UARTIMSC_RIMIM 0x01 /* RI Modem Interrupt mask */
  13979. +/* all modem mask bits */
  13980. +#define AMBA_UARTIMSC_Modem (AMBA_UARTIMSC_DSRMIM |AMBA_UARTIMSC_DCDMIM | \
  13981. + AMBA_UARTIMSC_CTSMIM |AMBA_UARTIMSC_RIMIM)
  13982. +
  13983. +
  13984. +
  13985. +/* Control Register bits */
  13986. +
  13987. +#define AMBA_UARTCR_RTS 0x800 /* nRTS */
  13988. +#define AMBA_UARTCR_DTR 0x400 /* nDTR */
  13989. +#define AMBA_UARTCR_RXE 0x200 /* Rx enable */
  13990. +#define AMBA_UARTCR_TXE 0x100 /* Tx enable */
  13991. +#define AMBA_UARTCR_LBE 0x080 /* Loopback enable */
  13992. +#define AMBA_UARTCR_SIRLP 0x004 /* IR SIR Low Power Mode */
  13993. +#define AMBA_UARTCR_SIREN 0x002 /* IR SIR enable */
  13994. +#define AMBA_UARTCR_UARTEN 0x001 /* UART enable */
  13995. +
  13996. +#define AMBA_UARTLCR_H_WLEN_8 0x60
  13997. +#define AMBA_UARTLCR_H_WLEN_7 0x40
  13998. +#define AMBA_UARTLCR_H_WLEN_6 0x20
  13999. +#define AMBA_UARTLCR_H_WLEN_5 0x00
  14000. +#define AMBA_UARTLCR_H_FEN 0x10
  14001. +#define AMBA_UARTLCR_H_STP2 0x08
  14002. +#define AMBA_UARTLCR_H_EPS 0x04
  14003. +#define AMBA_UARTLCR_H_PEN 0x02
  14004. +#define AMBA_UARTLCR_H_BRK 0x01
  14005. +
  14006. +/* Raw/Masked Interrupt Status Register bits*/
  14007. +#define AMBA_UART_IS_RT 0x40
  14008. +#define AMBA_UART_IS_TX 0x20
  14009. +#define AMBA_UART_IS_RX 0x10
  14010. +#define AMBA_UART_IS_DSR 0x08
  14011. +#define AMBA_UART_IS_DCD 0x04
  14012. +#define AMBA_UART_IS_CTS 0x02
  14013. +#define AMBA_UART_IS_RI 0x01
  14014. +#define AMBA_UART_IS_MI (AMBA_UART_IS_DSR | AMBA_UART_IS_DCD | \
  14015. + AMBA_UART_IS_CTS | AMBA_UART_IS_RI )
  14016. +
  14017. +#define AMBA_UARTRSR_ANY (AMBA_UARTRSR_OE|AMBA_UARTRSR_BE|AMBA_UARTRSR_PE|AMBA_UARTRSR_FE)
  14018. +#define AMBA_UARTFR_MODEM_ANY (AMBA_UARTFR_DCD|AMBA_UARTFR_DSR|AMBA_UARTFR_CTS)
  14019. +
  14020. +#endif /* ASM_ARM_HARDWARE_SERIAL_AMBA_PL011_H */
  14021. +
  14022. diff -urN linux-2.4.26/include/lh79520.h linux-2.4.26-vrs1-lnode80/include/lh79520.h
  14023. --- linux-2.4.26/include/lh79520.h 1969-12-31 20:00:00.000000000 -0400
  14024. +++ linux-2.4.26-vrs1-lnode80/include/lh79520.h 2005-11-02 17:37:33.000000000 -0400
  14025. @@ -0,0 +1,340 @@
  14026. +/*
  14027. + * lh79520.h: LH79520 specific defines
  14028. + *
  14029. + * Copyright (C) 2002 Lineo, Inc.
  14030. + *
  14031. + * This program is free software; you can redistribute it and/or modify
  14032. + * it under the terms of the GNU General Public License as published by
  14033. + * the Free Software Foundation; either version 2 of the License, or
  14034. + * (at your option) any later version.
  14035. + *
  14036. + * This program is distributed in the hope that it will be useful,
  14037. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14038. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14039. + * GNU General Public License for more details.
  14040. + *
  14041. + * You should have received a copy of the GNU General Public License
  14042. + * along with this program; if not, write to the Free Software
  14043. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14044. + */
  14045. +
  14046. +
  14047. +#ifndef BLOB_ARCH_LH79520_H
  14048. +#define BLOB_ARCH_LH79520_H
  14049. +
  14050. +#ifndef _BIT
  14051. +#define _BIT(n) (1 << (n))
  14052. +#endif
  14053. +
  14054. +#ifndef _SBF
  14055. +#define _SBF(f,v) ((v) << (f))
  14056. +#endif
  14057. +
  14058. +/* the base address were BLOB is loaded by the first stage loader */
  14059. +// #define BLOB_ABS_BASE_ADDR (0x60000000) // for gdb bootstrap in SRAM
  14060. +#define BLOB_ABS_BASE_ADDR (0x20200400)
  14061. +
  14062. +
  14063. +/* where do various parts live in RAM */
  14064. +#define BLOB_RAM_BASE (0x20100000)
  14065. +#define KERNEL_RAM_BASE (0x20008000)
  14066. +#define PARAM_RAM_BASE (0x20110000)
  14067. +#define RAMDISK_RAM_BASE (0x20400000)
  14068. +#define RAMDISK_VIRTUAL_BASE (0xC0400000) // kernel virtual address of where ramdisk will be
  14069. +
  14070. +
  14071. +/* and where do they live in flash */
  14072. +#define BLOB_FLASH_BASE (0x00000000)
  14073. +#define BLOB_FLASH_LEN (128 * 1024) // 128 KB for blob
  14074. +
  14075. +#define PARAM_FLASH_BASE (BLOB_FLASH_BASE + BLOB_FLASH_LEN)
  14076. +#define PARAM_FLASH_LEN (64 * 1024) // 64 KB for params
  14077. +
  14078. +#define KERNEL_FLASH_BASE (PARAM_FLASH_BASE + PARAM_FLASH_LEN)
  14079. +#define KERNEL_FLASH_LEN (1024 * 1024 - \
  14080. + (BLOB_FLASH_LEN + PARAM_FLASH_LEN)) // 1 MB - (BLOB + PARAM) for kernel
  14081. +
  14082. +#define RAMDISK_FLASH_BASE (KERNEL_FLASH_BASE + KERNEL_FLASH_LEN)
  14083. +#define RAMDISK_FLASH_LEN (3 * 1024 * 1024) // 3 MB for ramdisk
  14084. +
  14085. +#define PARAM_START PARAM_FLASH_BASE
  14086. +#define PARAM_LEN PARAM_FLASH_LEN
  14087. +
  14088. +/* the position of the kernel boot parameters */
  14089. +#define BOOT_PARAMS (0x20000100)
  14090. +
  14091. +
  14092. +/* the size (in kbytes) to which the compressed ramdisk expands */
  14093. +#define RAMDISK_SIZE (8 * 1024)
  14094. +
  14095. +
  14096. +/* Memory configuration */
  14097. +
  14098. +/**********************************************************************
  14099. + * AHB BASES
  14100. + *********************************************************************/
  14101. +#define AHB_PHYS (0xFFFF0000)
  14102. +#define VIC_PHYS_MIRROR (AHB_PHYS + 0x0000)
  14103. +#define SMC_REGS_BASE (AHB_PHYS + 0x1000)
  14104. +#define SDRAM_REGS_BASE (AHB_PHYS + 0x2000)
  14105. +#define LCD_BASE (AHB_PHYS + 0x4000)
  14106. +#define VIC_PHYS (AHB_PHYS + 0xF000)
  14107. +
  14108. +/**********************************************************************
  14109. + * APB BASES
  14110. + *********************************************************************/
  14111. +#define APB_PHYS (0xFFFC0000)
  14112. +#define UART0_BASE (APB_PHYS + 0x00000)
  14113. +#define UART1_BASE (APB_PHYS + 0x01000)
  14114. +#define UART2_BASE (APB_PHYS + 0x02000)
  14115. +#define PWM_BASE (APB_PHYS + 0x03000)
  14116. +#define TIMER0_BASE (APB_PHYS + 0x04000)
  14117. +#define TIMER1_BASE (APB_PHYS + 0x05000)
  14118. +#define SSP_BASE (APB_PHYS + 0x06000)
  14119. +#define GPIO3_BASE (APB_PHYS + 0x1C000)
  14120. +#define GPIO2_BASE (APB_PHYS + 0x1D000)
  14121. +#define GPIO1_BASE (APB_PHYS + 0x1E000)
  14122. +#define GPIO0_BASE (APB_PHYS + 0x1F000)
  14123. +#define RTC_BASE (APB_PHYS + 0x20000)
  14124. +#define DMAC_BASE (APB_PHYS + 0x21000)
  14125. +#define RCPC_BASE (APB_PHYS + 0x22000)
  14126. +#define WDTIMER_BASE (APB_PHYS + 0x23000)
  14127. +#define LCDICP_BASE (APB_PHYS + 0x24000)
  14128. +#define IOCON_BASE (APB_PHYS + 0x25000)
  14129. +
  14130. +#define SDRAM_MEM_BASE 0x20000000
  14131. +#define SMC_MEM_BASE (0x40000000)
  14132. +#define INTERNAL_MEM_BASE (0x60000000)
  14133. +
  14134. +
  14135. +/**********************************************************************
  14136. + * SMC Memory Bank Address Space Bases
  14137. + *********************************************************************/
  14138. +
  14139. +#define SMC_BANK0_BASE (SMC_MEM_BASE + 0x00000000)
  14140. +#define SMC_BANK1_BASE (SMC_MEM_BASE + 0x04000000)
  14141. +#define SMC_BANK2_BASE (SMC_MEM_BASE + 0x08000000)
  14142. +#define SMC_BANK3_BASE (SMC_MEM_BASE + 0x0C000000)
  14143. +#define SMC_BANK4_BASE (SMC_MEM_BASE + 0x10000000)
  14144. +#define SMC_BANK5_BASE (SMC_MEM_BASE + 0x14000000)
  14145. +#define SMC_BANK6_BASE (SMC_MEM_BASE + 0x18000000)
  14146. +#define SMC_BANK7_BASE (SMC_MEM_BASE + 0x1C000000)
  14147. +
  14148. +/* Flash ROM */
  14149. +#define FLASH_PHYS_BASE 0x00000000
  14150. +#define FLASH_PHYS_SIZE 0x00400000
  14151. +
  14152. +/**********************************************************************
  14153. + * SDRAMC Memory Bank Address Space Bases
  14154. + *********************************************************************/
  14155. +
  14156. +#define SDRAM_BANK0_BASE (SDRAM_MEM_BASE + 0x00000000)
  14157. +#define SDRAM_BANK1_BASE (SDRAM_MEM_BASE + 0x08000000)
  14158. +
  14159. +// WDT offsets
  14160. +#define WDT_WDCTLR_OFFSET 0x0
  14161. +
  14162. +// RCPC offsets for assembly files
  14163. +#define RCPC_CONTROL_OFFSET 0x00
  14164. +#define RCPC_REMAP_OFFSET 0x08
  14165. +#define RCPC_SOFTRESET_OFFSET 0x0C
  14166. +#define RCPC_RESETSTATUS_OFFSET 0x10
  14167. +#define RCPC_RESETSTATUS_CLEAR_OFFSET 0x14
  14168. +#define RCPC_HCLKCLK_PRESCALE_OFFSET 0x18
  14169. +#define RCPC_CPUCLK_PRESCALE_OFFSET 0x1C
  14170. +#define RCPC_PERIPHCLKCTRL_OFFSET 0x24
  14171. +#define RCPC_AHBCLKCTRL_OFFSET 0x2C
  14172. +#define RCPC_PERIPHCLKSELECT_OFFSET 0x30
  14173. +#define RCPC_CORECLKCONFIG_OFFSET 0x88
  14174. +
  14175. +#define RCPC_CPUCLK_PRESCALE_78 0x2
  14176. +#define RCPC_CPUCLK_PRESCALE_52 0x3
  14177. +#define RCPC_CPUCLK_PRESCALE_39 0x4
  14178. +#define RCPC_HCLK_PRESCALE_52 0x3
  14179. +#define RCPC_HCLK_PRESCALE_39 0x4
  14180. +#define RCPC_CPUCLK_PRESCALE_DEFAULT RCPC_CPUCLK_PRESCALE_52
  14181. +#define RCPC_HCLK_PRESCALE_DEFAULT RCPC_HCLK_PRESCALE_52
  14182. +//#define RCPC_CPUCLK_PRESCALE_DEFAULT RCPC_CPUCLK_PRESCALE_78
  14183. +//#define RCPC_HCLK_PRESCALE_DEFAULT RCPC_HCLK_PRESCALE_52
  14184. +
  14185. +/* IOCON offsets for assembly code */
  14186. +#define IOCON_MEMMUX_OFFSET 0x00
  14187. +//#define IOCON_MEMMUX_INIT 0x00003fff
  14188. +#define IOCON_MEMMUX_INIT 0x00000075
  14189. +#define IOCON_LCDMUX_OFFSET 0x04
  14190. +#define IOCON_LCDMUX_INIT 0x1f3db95d
  14191. +#define IOCON_MISCMUX_OFFSET 0x08
  14192. +#define IOCON_MISCMUX_INIT 0x0000005e
  14193. +#define IOCON_DMAMUX_OFFSET 0x0C
  14194. +#define IOCON_DMAMUX_INIT 0x00000000
  14195. +#define IOCON_UARTMUX_OFFSET 0x10
  14196. +#define IOCON_UARTMUX_INIT 0x0000000f
  14197. +#define IOCON_SSPMUX_OFFSET 0x14
  14198. +#define IOCON_SSPMUX_INIT 0x0000001c
  14199. +
  14200. +#if 0
  14201. +/* GPIO Configuration */
  14202. +#define GPIOB_DATA_OFFSET 0x000
  14203. +#define GPIOB_DATA_INIT 0x00000000
  14204. +#define GPIOB_DDR_OFFSET 0x008
  14205. +#define GPIOB_DDR_INIT 0x00000000
  14206. +#define GPIOF_DATA_OFFSET 0x000
  14207. +#define GPIOF_DATA_INIT 0x000000DA
  14208. +#define GPIOF_DDR_OFFSET 0x008
  14209. +#define GPIOF_DDR_INIT 0x000000FA
  14210. +#define GPIOG_DATA_OFFSET 0x000
  14211. +#define GPIOG_DATA_INIT 0x000000E0
  14212. +#define GPIOG_DDR_OFFSET 0x008
  14213. +#define GPIOG_DDR_INIT 0x000000E0
  14214. +#define GPIOH_DATA_OFFSET 0x004
  14215. +#define GPIOH_DATA_INIT 0x00000043
  14216. +#define GPIOH_DDR_OFFSET 0x00C
  14217. +#define GPIOH_DDR_INIT 0x00000043
  14218. +#endif
  14219. +
  14220. +#define GPIOB_DATA_OFFSET 0x004
  14221. +#define GPIOB_DATA_INIT 0x00000000
  14222. +#define GPIOB_DDR_OFFSET 0x00c
  14223. +#define GPIOB_DDR_INIT 0x00000000
  14224. +#define GPIOF_DATA_OFFSET 0x004
  14225. +#define GPIOF_DATA_INIT 0x00000008
  14226. +#define GPIOF_DDR_OFFSET 0x00C
  14227. +#define GPIOF_DDR_INIT 0x00000038
  14228. +#define GPIOG_DATA_OFFSET 0x000
  14229. +#define GPIOG_DATA_INIT 0x000000E0
  14230. +#define GPIOG_DDR_OFFSET 0x008
  14231. +#define GPIOG_DDR_INIT 0x000000E0
  14232. +#define GPIOH_DATA_OFFSET 0x004
  14233. +#define GPIOH_DATA_INIT 0x00000043
  14234. +#define GPIOH_DDR_OFFSET 0x00C
  14235. +#define GPIOH_DDR_INIT 0x00000043
  14236. +
  14237. +
  14238. +
  14239. +
  14240. +/* SDRAM controller offsets */
  14241. +#define SDRAM_CFG0_OFF 0
  14242. +#define SDRAM_CFG1_OFF 4
  14243. +#define SDRAM_REFTIMER_OFF 8
  14244. +
  14245. +#define SDRAM_INIT_NORMAL 0
  14246. +#define SDRAM_INIT_PALL 1
  14247. +#define SDRAM_INIT_MODE 2
  14248. +#define SDRAM_INIT_NOP 3
  14249. +#define SDRAM_BUSY 0x20 /* SDRAM Engine Status */
  14250. +
  14251. +
  14252. +/*
  14253. + * Clock Indexes
  14254. + * Caution: these indexes have to be coherent with the equivalent indexes
  14255. + * included with associated 'C' modules
  14256. + */
  14257. +
  14258. +#define RCPC_CLKIDX_DEFAULT 0
  14259. +#define RCPC_CLKIDX_39_39 1
  14260. +#define RCPC_CLKIDX_52_39 2
  14261. +#define RCPC_CLKIDX_52_52 3
  14262. +#define RCPC_CLKIDX_78_39 4
  14263. +#define RCPC_CLKIDX_78_52 5
  14264. +#define RCPC_CLKIDX_78_78 6
  14265. +#define RCPC_CLKIDX_10_10 7
  14266. +
  14267. +/*
  14268. + * SDRAM Refresh timer values for various Clock Indexes
  14269. + */
  14270. +#define REFTIMER_78 0x480
  14271. +#define REFTIMER_52 0x320
  14272. +#define REFTIMER_39 0x270
  14273. +#define REFTIMER_10 0x80
  14274. +
  14275. +
  14276. +/**********************************************************************
  14277. + * Static Memory Controller (SMC)
  14278. + *********************************************************************/
  14279. +#define SMC ((SMCREGS *)(SMC_REGS_BASE))
  14280. +
  14281. +/**********************************************************************
  14282. + * SDRAM Controller (SDRAM)
  14283. + *********************************************************************/
  14284. +#define SDRAM ((SDRAMREGS *)(SDRAM_REGS_BASE))
  14285. +
  14286. +/**********************************************************************
  14287. + * Color LCD Controller (CLCDC)
  14288. + *********************************************************************/
  14289. +#define CLCDC ((CLCDCREGS *)(LCD_BASE))
  14290. +
  14291. +/**********************************************************************
  14292. + * UARTs
  14293. + *********************************************************************/
  14294. +#define UARTID_OFFSET (0xFE0)
  14295. +#define UART0 ((UART *)(UART0_BASE))
  14296. +#define UART1 ((UART *)(UART1_BASE))
  14297. +#define UART2 ((UART *)(UART2_BASE))
  14298. +#define UART0ID ((UARTID *)(UART0_BASE + UARTID_OFFSET))
  14299. +#define UART1ID ((UARTID *)(UART1_BASE + UARTID_OFFSET))
  14300. +#define UART2ID ((UARTID *)(UART2_BASE + UARTID_OFFSET))
  14301. +
  14302. +/* use this serial port */
  14303. +#define UART ((UARTREGS *)(UART0_BASE))
  14304. +#define LH_UART_NUM 0
  14305. +
  14306. +
  14307. +/**********************************************************************
  14308. + * TIMER
  14309. + *********************************************************************/
  14310. +#define TIMER2_OFFSET (0x20)
  14311. +#define TIMER0 ((TIMERREG *)(TIMER0_BASE))
  14312. +#define TIMER1 ((volatile TIMERREG *)(TIMER0_BASE + TIMER2_OFFSET))
  14313. +#define TIMER2 ((TIMERREG *)(TIMER1_BASE))
  14314. +#define TIMER3 ((TIMERREG *)(TIMER1_BASE + TIMER2_OFFSET))
  14315. +
  14316. +/*
  14317. + * base addresses of each dual timer module
  14318. + */
  14319. +#define MOD1_TIMER ((TIMERREGS *) TIMER0_BASE)
  14320. +#define MOD2_TIMER ((TIMERREGS *) TIMER1_BASE)
  14321. +
  14322. +
  14323. +#define RCPC ((RCPCREGS *)(RCPC_BASE))
  14324. +#define LCDICP ((LCDICPREGS *)(LCDICP_BASE))
  14325. +#define IOCON ((IOCONREGS *)(IOCON_BASE))
  14326. +#define CPLD_PHYS_BASE SMC_BANK2_BASE
  14327. +#define CPLD ((CPLDREGS *)(CPLD_PHYS_BASE))
  14328. +
  14329. +#define _7seg(val) \
  14330. + { \
  14331. + CPLDREGS *cpld = CPLD; \
  14332. + cpld->seven_seg = (val); \
  14333. + }
  14334. +
  14335. +/*
  14336. + * CPU board DIP switches
  14337. + */
  14338. +#define DIPSW1 0x01
  14339. +#define DIPSW2 0x02
  14340. +#define DIPSW3 0x04
  14341. +#define DIPSW4 0x08
  14342. +#define DIPSW5 0x10
  14343. +#define DIPSW6 0x20
  14344. +#define DIPSW7 0x40
  14345. +#define DIPSW8 0x80
  14346. +
  14347. +/*
  14348. + * CPU and BUS speeds, also tied to SDRAM speed
  14349. + * NOTE: Don't change one without changing the others!!!!
  14350. + */
  14351. +
  14352. +#if 0 // run the CPU at 52 MHz, and the bus at 52 MHz
  14353. + #define CPU_CLK_PRESCALAR RCPC_CPUCLK_PRESCALE_52
  14354. + #define SDRAM_REFTIMER REFTIMER_52
  14355. + #define HCLK_PRESCALAR RCPC_HCLK_PRESCALE_52
  14356. + #define CORE_CLK_CONFIG 3 /* FastBus */
  14357. +#else // run the CPU at 78 MHz, and the Bus at 52 MHz
  14358. + #define CPU_CLK_PRESCALAR RCPC_CPUCLK_PRESCALE_78
  14359. + #define SDRAM_REFTIMER 0x320 /*REFTIMER_78*/
  14360. + #define HCLK_PRESCALAR RCPC_HCLK_PRESCALE_52
  14361. + #define CORE_CLK_CONFIG 0 /* std mode, async */
  14362. +#endif
  14363. +
  14364. +
  14365. +#endif // BLOB_ARCH_LH79520_H
  14366. diff -urN linux-2.4.26/include/linux/serial_core.h linux-2.4.26-vrs1-lnode80/include/linux/serial_core.h
  14367. --- linux-2.4.26/include/linux/serial_core.h 2005-11-02 16:54:26.000000000 -0400
  14368. +++ linux-2.4.26-vrs1-lnode80/include/linux/serial_core.h 2005-11-02 17:46:47.000000000 -0400
  14369. @@ -51,6 +51,8 @@
  14370. #define PORT_SA1100 34
  14371. #define PORT_UART00 35
  14372. #define PORT_21285 37
  14373. +#define PORT_AMBA_PL011 38
  14374. +#define PORT_LH7A400 39
  14375. /* Sparc type numbers. */
  14376. #define PORT_SUNZILOG 38
  14377. diff -urN linux-2.4.26/include/linux/verbosedebug.h linux-2.4.26-vrs1-lnode80/include/linux/verbosedebug.h
  14378. --- linux-2.4.26/include/linux/verbosedebug.h 1969-12-31 20:00:00.000000000 -0400
  14379. +++ linux-2.4.26-vrs1-lnode80/include/linux/verbosedebug.h 2005-11-02 17:37:33.000000000 -0400
  14380. @@ -0,0 +1,51 @@
  14381. +/* vi: set sw=4 ts=4 ai: */
  14382. +
  14383. +/**********************************************************************
  14384. +* linux/include/linux/verbosedebug.h
  14385. +*
  14386. +* Provide Verbose, Debug, and Verbose+Debug printk macros that can be
  14387. +* enabled or disabled vi the definitions of DEBUG and VERBOSE.
  14388. +*
  14389. +* vprintk -- Verbose printk
  14390. +* dprintk -- Debug printk
  14391. +* vdprintk -- Verbose+Debug printk
  14392. +*
  14393. +* Copyright (C) 2002 Lineo, Inc.
  14394. +*
  14395. +* This program is free software; you can redistribute it and/or modify
  14396. +* it under the terms of the GNU General Public License (GPL) version 2
  14397. +* as published by the Free Software Foundation.
  14398. +*
  14399. +**********************************************************************/
  14400. +
  14401. +#ifndef _VerboseDebug_h
  14402. +#define _VerboseDebug_h
  14403. +
  14404. +#ifndef DRVNAME
  14405. +# define DRVNAME ""
  14406. +#endif
  14407. +
  14408. +#ifdef VERBOSE
  14409. +# ifdef DEBUG
  14410. +# define vprintk(fmt,args...) {printk(DRVNAME ": " fmt, ## args);}
  14411. +# define dprintk(fmt,args...) {printk(DRVNAME ": " fmt, ## args);}
  14412. +# define vdprintk(fmt,args...) {printk(DRVNAME ": " fmt, ## args);}
  14413. +# else
  14414. +# define vprintk(fmt,args...) {printk(DRVNAME ": " fmt, ## args);}
  14415. +# define dprintk(fmt,args...) {}
  14416. +# define vdprintk(fmt,args...) {}
  14417. +# endif
  14418. +#else
  14419. +# ifdef DEBUG
  14420. +# define vprintk(fmt,args...) {}
  14421. +# define dprintk(fmt,args...) {printk(DRVNAME ": " fmt, ## args);}
  14422. +# define vdprintk(fmt,args...) {}
  14423. +# else
  14424. +# define vprintk(fmt,args...) {}
  14425. +# define dprintk(fmt,args...) {}
  14426. +# define vdprintk(fmt,args...) {}
  14427. +# endif
  14428. +#endif
  14429. +
  14430. +#endif /* _VerboseDebug_h */
  14431. +
  14432. diff -urN linux-2.4.26/Makefile linux-2.4.26-vrs1-lnode80/Makefile
  14433. --- linux-2.4.26/Makefile 2005-11-02 16:54:16.000000000 -0400
  14434. +++ linux-2.4.26-vrs1-lnode80/Makefile 2005-11-03 10:28:43.000000000 -0400
  14435. @@ -1,11 +1,11 @@
  14436. VERSION = 2
  14437. PATCHLEVEL = 4
  14438. SUBLEVEL = 26
  14439. -EXTRAVERSION =-vrs1
  14440. +EXTRAVERSION =-vrs1-lnode80
  14441. KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
  14442. -ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
  14443. +ARCH := arm
  14444. KERNELPATH=kernel-$(shell echo $(KERNELRELEASE) | sed -e "s/-//g")
  14445. CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  14446. @@ -19,7 +19,7 @@
  14447. HOSTCC = gcc
  14448. HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
  14449. -CROSS_COMPILE =
  14450. +CROSS_COMPILE = arm-linux-
  14451. #
  14452. # Include the make variables (CC, etc...)