100-git_sync.patch 421 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092
  1. --- /dev/null
  2. +++ b/arch/avr32/boards/atngw100/Kconfig
  3. @@ -0,0 +1,12 @@
  4. +# NGW100 customization
  5. +
  6. +config BOARD_ATNGW100_I2C_GPIO
  7. + bool "Use GPIO for i2c instead of built-in TWI module"
  8. + help
  9. + The driver for the built-in TWI module has been plagued by
  10. + various problems, while the i2c-gpio driver is based on the
  11. + trusty old i2c-algo-bit bitbanging engine, making it work
  12. + on pretty much any setup.
  13. +
  14. + Choose 'Y' here if you're having i2c-related problems and
  15. + want to rule out the i2c bus driver.
  16. --- a/arch/avr32/boards/atngw100/setup.c
  17. +++ b/arch/avr32/boards/atngw100/setup.c
  18. @@ -25,6 +25,13 @@
  19. #include <asm/arch/init.h>
  20. #include <asm/arch/portmux.h>
  21. +/* Oscillator frequencies. These are board-specific */
  22. +unsigned long at32_board_osc_rates[3] = {
  23. + [0] = 32768, /* 32.768 kHz on RTC osc */
  24. + [1] = 20000000, /* 20 MHz on osc0 */
  25. + [2] = 12000000, /* 12 MHz on osc1 */
  26. +};
  27. +
  28. /* Initialized by bootloader-specific startup code. */
  29. struct tag *bootloader_tags __initdata;
  30. @@ -37,11 +44,16 @@
  31. static struct spi_board_info spi0_board_info[] __initdata = {
  32. {
  33. .modalias = "mtd_dataflash",
  34. - .max_speed_hz = 10000000,
  35. + .max_speed_hz = 8000000,
  36. .chip_select = 0,
  37. },
  38. };
  39. +static struct mci_platform_data __initdata mci0_data = {
  40. + .detect_pin = GPIO_PIN_PC(25),
  41. + .wp_pin = GPIO_PIN_PE(0),
  42. +};
  43. +
  44. /*
  45. * The next two functions should go away as the boot loader is
  46. * supposed to initialize the macb address registers with a valid
  47. @@ -124,6 +136,7 @@
  48. }
  49. };
  50. +#ifdef CONFIG_BOARD_ATNGW100_I2C_GPIO
  51. static struct i2c_gpio_platform_data i2c_gpio_data = {
  52. .sda_pin = GPIO_PIN_PA(6),
  53. .scl_pin = GPIO_PIN_PA(7),
  54. @@ -139,6 +152,7 @@
  55. .platform_data = &i2c_gpio_data,
  56. },
  57. };
  58. +#endif
  59. static int __init atngw100_init(void)
  60. {
  61. @@ -157,6 +171,7 @@
  62. set_hw_addr(at32_add_device_eth(1, &eth_data[1]));
  63. at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
  64. + at32_add_device_mci(0, &mci0_data);
  65. at32_add_device_usba(0, NULL);
  66. for (i = 0; i < ARRAY_SIZE(ngw_leds); i++) {
  67. @@ -165,11 +180,15 @@
  68. }
  69. platform_device_register(&ngw_gpio_leds);
  70. +#ifdef CONFIG_BOARD_ATNGW100_I2C_GPIO
  71. at32_select_gpio(i2c_gpio_data.sda_pin,
  72. AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
  73. at32_select_gpio(i2c_gpio_data.scl_pin,
  74. AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
  75. platform_device_register(&i2c_gpio_device);
  76. +#else
  77. + at32_add_device_twi(0, NULL, 0);
  78. +#endif
  79. return 0;
  80. }
  81. --- a/arch/avr32/boards/atstk1000/atstk1002.c
  82. +++ b/arch/avr32/boards/atstk1000/atstk1002.c
  83. @@ -1,7 +1,7 @@
  84. /*
  85. - * ATSTK1002 daughterboard-specific init code
  86. + * ATSTK1002/ATSTK1006 daughterboard-specific init code
  87. *
  88. - * Copyright (C) 2005-2006 Atmel Corporation
  89. + * Copyright (C) 2005-2007 Atmel Corporation
  90. *
  91. * This program is free software; you can redistribute it and/or modify
  92. * it under the terms of the GNU General Public License version 2 as
  93. @@ -28,6 +28,80 @@
  94. #include "atstk1000.h"
  95. +/* Oscillator frequencies. These are board specific */
  96. +unsigned long at32_board_osc_rates[3] = {
  97. + [0] = 32768, /* 32.768 kHz on RTC osc */
  98. + [1] = 20000000, /* 20 MHz on osc0 */
  99. + [2] = 12000000, /* 12 MHz on osc1 */
  100. +};
  101. +
  102. +/*
  103. + * The ATSTK1006 daughterboard is very similar to the ATSTK1002. Both
  104. + * have the AT32AP7000 chip on board; the difference is that the
  105. + * STK1006 has 128 MB SDRAM (the STK1002 uses the 8 MB SDRAM chip on
  106. + * the STK1000 motherboard) and 256 MB NAND flash (the STK1002 has
  107. + * none.)
  108. + *
  109. + * The RAM difference is handled by the boot loader, so the only
  110. + * difference we end up handling here is the NAND flash.
  111. + */
  112. +#ifdef CONFIG_BOARD_ATSTK1006
  113. +#include <linux/mtd/partitions.h>
  114. +#include <asm/arch/smc.h>
  115. +
  116. +static struct smc_timing nand_timing __initdata = {
  117. + .ncs_read_setup = 0,
  118. + .nrd_setup = 10,
  119. + .ncs_write_setup = 0,
  120. + .nwe_setup = 10,
  121. +
  122. + .ncs_read_pulse = 30,
  123. + .nrd_pulse = 15,
  124. + .ncs_write_pulse = 30,
  125. + .nwe_pulse = 15,
  126. +
  127. + .read_cycle = 30,
  128. + .write_cycle = 30,
  129. +
  130. + .ncs_read_recover = 0,
  131. + .nrd_recover = 15,
  132. + .ncs_write_recover = 0,
  133. + /* WE# high -> RE# low min 60 ns */
  134. + .nwe_recover = 50,
  135. +};
  136. +
  137. +static struct smc_config nand_config __initdata = {
  138. + .bus_width = 1,
  139. + .nrd_controlled = 1,
  140. + .nwe_controlled = 1,
  141. + .nwait_mode = 0,
  142. + .byte_write = 0,
  143. + .tdf_cycles = 2,
  144. + .tdf_mode = 0,
  145. +};
  146. +
  147. +static struct mtd_partition nand_partitions[] = {
  148. + {
  149. + .name = "main",
  150. + .offset = 0x00000000,
  151. + .size = MTDPART_SIZ_FULL,
  152. + },
  153. +};
  154. +
  155. +static struct mtd_partition *nand_part_info(int size, int *num_partitions)
  156. +{
  157. + *num_partitions = ARRAY_SIZE(nand_partitions);
  158. + return nand_partitions;
  159. +}
  160. +
  161. +static struct atmel_nand_data atstk1006_nand_data __initdata = {
  162. + .cle = 21,
  163. + .ale = 22,
  164. + .rdy_pin = GPIO_PIN_PB(30),
  165. + .enable_pin = GPIO_PIN_PB(29),
  166. + .partition_info = nand_part_info,
  167. +};
  168. +#endif
  169. struct eth_addr {
  170. u8 addr[6];
  171. @@ -83,6 +157,19 @@
  172. } };
  173. #endif
  174. +static struct cf_platform_data __initdata cf0_data = {
  175. +#ifdef CONFIG_BOARD_ATSTK1000_CF_HACKS
  176. + .detect_pin = CONFIG_BOARD_ATSTK1000_CF_DETECT_PIN,
  177. + .reset_pin = CONFIG_BOARD_ATSTK1000_CF_RESET_PIN,
  178. +#else
  179. + .detect_pin = GPIO_PIN_NONE,
  180. + .reset_pin = GPIO_PIN_NONE,
  181. +#endif
  182. + .vcc_pin = GPIO_PIN_NONE,
  183. + .ready_pin = GPIO_PIN_PB(27),
  184. + .cs = 4,
  185. +};
  186. +
  187. /*
  188. * The next two functions should go away as the boot loader is
  189. * supposed to initialize the macb address registers with a valid
  190. @@ -212,6 +299,12 @@
  191. at32_add_system_devices();
  192. +#ifdef CONFIG_BOARD_ATSTK1006
  193. + smc_set_timing(&nand_config, &nand_timing);
  194. + smc_set_configuration(3, &nand_config);
  195. + at32_add_device_nand(0, &atstk1006_nand_data);
  196. +#endif
  197. +
  198. #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  199. at32_add_device_usart(1);
  200. #else
  201. @@ -228,16 +321,30 @@
  202. #ifdef CONFIG_BOARD_ATSTK100X_SPI1
  203. at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
  204. #endif
  205. + at32_add_device_twi(0, NULL, 0);
  206. +#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  207. + at32_add_device_mci(0, NULL);
  208. +#endif
  209. #ifdef CONFIG_BOARD_ATSTK1002_SW5_CUSTOM
  210. set_hw_addr(at32_add_device_eth(1, &eth_data[1]));
  211. #else
  212. at32_add_device_lcdc(0, &atstk1000_lcdc_data,
  213. - fbmem_start, fbmem_size);
  214. + fbmem_start, fbmem_size, 0);
  215. #endif
  216. at32_add_device_usba(0, NULL);
  217. +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_AC97
  218. + at32_add_device_ac97c(0);
  219. +#else
  220. + at32_add_device_abdac(0);
  221. +#endif
  222. #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
  223. at32_add_device_ssc(0, ATMEL_SSC_TX);
  224. #endif
  225. + at32_add_device_cf(0, 2, &cf0_data);
  226. +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_PSIF
  227. + at32_add_device_psif(0);
  228. + at32_add_device_psif(1);
  229. +#endif
  230. atstk1000_setup_j2_leds();
  231. atstk1002_setup_extdac();
  232. --- a/arch/avr32/boards/atstk1000/atstk1003.c
  233. +++ b/arch/avr32/boards/atstk1000/atstk1003.c
  234. @@ -27,6 +27,13 @@
  235. #include "atstk1000.h"
  236. +/* Oscillator frequencies. These are board specific */
  237. +unsigned long at32_board_osc_rates[3] = {
  238. + [0] = 32768, /* 32.768 kHz on RTC osc */
  239. + [1] = 20000000, /* 20 MHz on osc0 */
  240. + [2] = 12000000, /* 12 MHz on osc1 */
  241. +};
  242. +
  243. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  244. static struct at73c213_board_info at73c213_data = {
  245. .ssc_id = 0,
  246. @@ -59,6 +66,19 @@
  247. } };
  248. #endif
  249. +static struct cf_platform_data __initdata cf0_data = {
  250. +#ifdef CONFIG_BOARD_ATSTK1000_CF_HACKS
  251. + .detect_pin = CONFIG_BOARD_ATSTK1000_CF_DETECT_PIN,
  252. + .reset_pin = CONFIG_BOARD_ATSTK1000_CF_RESET_PIN,
  253. +#else
  254. + .detect_pin = GPIO_PIN_NONE,
  255. + .reset_pin = GPIO_PIN_NONE,
  256. +#endif
  257. + .vcc_pin = GPIO_PIN_NONE,
  258. + .ready_pin = GPIO_PIN_PB(27),
  259. + .cs = 4,
  260. +};
  261. +
  262. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  263. static void __init atstk1003_setup_extdac(void)
  264. {
  265. @@ -147,12 +167,22 @@
  266. at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
  267. #endif
  268. #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  269. - at32_add_device_mci(0);
  270. + at32_add_device_mci(0, NULL);
  271. #endif
  272. at32_add_device_usba(0, NULL);
  273. +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_AC97
  274. + at32_add_device_ac97c(0);
  275. +#else
  276. + at32_add_device_abdac(0);
  277. +#endif
  278. #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
  279. at32_add_device_ssc(0, ATMEL_SSC_TX);
  280. #endif
  281. + at32_add_device_cf(0, 2, &cf0_data);
  282. +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_PSIF
  283. + at32_add_device_psif(0);
  284. + at32_add_device_psif(1);
  285. +#endif
  286. atstk1000_setup_j2_leds();
  287. atstk1003_setup_extdac();
  288. --- a/arch/avr32/boards/atstk1000/atstk1004.c
  289. +++ b/arch/avr32/boards/atstk1000/atstk1004.c
  290. @@ -29,6 +29,13 @@
  291. #include "atstk1000.h"
  292. +/* Oscillator frequencies. These are board specific */
  293. +unsigned long at32_board_osc_rates[3] = {
  294. + [0] = 32768, /* 32.768 kHz on RTC osc */
  295. + [1] = 20000000, /* 20 MHz on osc0 */
  296. + [2] = 12000000, /* 12 MHz on osc1 */
  297. +};
  298. +
  299. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  300. static struct at73c213_board_info at73c213_data = {
  301. .ssc_id = 0,
  302. @@ -130,14 +137,23 @@
  303. at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
  304. #endif
  305. #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  306. - at32_add_device_mci(0);
  307. + at32_add_device_mci(0, NULL);
  308. #endif
  309. at32_add_device_lcdc(0, &atstk1000_lcdc_data,
  310. - fbmem_start, fbmem_size);
  311. + fbmem_start, fbmem_size, 0);
  312. at32_add_device_usba(0, NULL);
  313. +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_AC97
  314. + at32_add_device_ac97c(0);
  315. +#else
  316. + at32_add_device_abdac(0);
  317. +#endif
  318. #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
  319. at32_add_device_ssc(0, ATMEL_SSC_TX);
  320. #endif
  321. +#ifdef CONFIG_BOARD_ATSTK100X_ENABLE_PSIF
  322. + at32_add_device_psif(0);
  323. + at32_add_device_psif(1);
  324. +#endif
  325. atstk1000_setup_j2_leds();
  326. atstk1004_setup_extdac();
  327. --- a/arch/avr32/boards/atstk1000/Kconfig
  328. +++ b/arch/avr32/boards/atstk1000/Kconfig
  329. @@ -18,6 +18,10 @@
  330. bool "ATSTK1004"
  331. select CPU_AT32AP7002
  332. +config BOARD_ATSTK1006
  333. + bool "ATSTK1006"
  334. + select CPU_AT32AP7000
  335. +
  336. endchoice
  337. @@ -102,4 +106,60 @@
  338. depends on !BOARD_ATSTK100X_SW1_CUSTOM && !BOARD_ATSTK100X_SW3_CUSTOM
  339. default y
  340. +config BOARD_ATSTK100X_ENABLE_AC97
  341. + bool "Use AC97C instead of ABDAC"
  342. + help
  343. + Select this if you want to use the built-in AC97 controller
  344. + instead of the built-in Audio Bitstream DAC. These share
  345. + the same I/O pins on the AP7000, so both can't be enabled
  346. + at the same time.
  347. +
  348. + Note that the STK1000 kit doesn't ship with an AC97 codec on
  349. + board, so say N unless you've got an expansion board with an
  350. + AC97 codec on it that you want to use.
  351. +
  352. +config BOARD_ATSTK1000_CF_HACKS
  353. + bool "ATSTK1000 CompactFlash hacks"
  354. + depends on !BOARD_ATSTK100X_SW4_CUSTOM
  355. + help
  356. + Select this if you have re-routed the CompactFlash RESET and
  357. + CD signals to GPIOs on your STK1000. This is necessary for
  358. + reset and card detection to work properly, although some CF
  359. + cards may be able to cope without reset.
  360. +
  361. +config BOARD_ATSTK1000_CF_RESET_PIN
  362. + hex "CompactFlash RESET pin"
  363. + default 0x30
  364. + depends on BOARD_ATSTK1000_CF_HACKS
  365. + help
  366. + Select which GPIO pin to use for the CompactFlash RESET
  367. + signal. This is specified as a hexadecimal number and should
  368. + be defined as 0x20 * gpio_port + pin.
  369. +
  370. + The default is 0x30, which is pin 16 on PIOB, aka GPIO14.
  371. +
  372. +config BOARD_ATSTK1000_CF_DETECT_PIN
  373. + hex "CompactFlash DETECT pin"
  374. + default 0x3e
  375. + depends on BOARD_ATSTK1000_CF_HACKS
  376. + help
  377. + Select which GPIO pin to use for the CompactFlash CD
  378. + signal. This is specified as a hexadecimal number and should
  379. + be defined as 0x20 * gpio_port + pin.
  380. +
  381. + The default is 0x3e, which is pin 30 on PIOB, aka GPIO15.
  382. +
  383. +config BOARD_ATSTK100X_ENABLE_PSIF
  384. + bool "Enable PSIF peripheral (PS/2 support)"
  385. + default n
  386. + help
  387. + Select this if you want to use the PSIF peripheral to hook up PS/2
  388. + devices to your STK1000. This will require a hardware modification to
  389. + work correctly, since PS/2 devices require 5 volt power and signals,
  390. + while the STK1000 only provides 3.3 volt.
  391. +
  392. + Say N if you have not modified the hardware to boost the voltage, say
  393. + Y if you have level convertion hardware or a PS/2 device capable of
  394. + operating on 3.3 volt.
  395. +
  396. endif # stk 1000
  397. --- a/arch/avr32/boards/atstk1000/Makefile
  398. +++ b/arch/avr32/boards/atstk1000/Makefile
  399. @@ -2,3 +2,4 @@
  400. obj-$(CONFIG_BOARD_ATSTK1002) += atstk1002.o
  401. obj-$(CONFIG_BOARD_ATSTK1003) += atstk1003.o
  402. obj-$(CONFIG_BOARD_ATSTK1004) += atstk1004.o
  403. +obj-$(CONFIG_BOARD_ATSTK1006) += atstk1002.o
  404. --- a/arch/avr32/configs/atngw100_defconfig
  405. +++ b/arch/avr32/configs/atngw100_defconfig
  406. @@ -1,7 +1,7 @@
  407. #
  408. # Automatically generated make config: don't edit
  409. -# Linux kernel version: 2.6.24-rc7
  410. -# Wed Jan 9 23:20:41 2008
  411. +# Linux kernel version: 2.6.25.4
  412. +# Wed Jun 11 15:23:36 2008
  413. #
  414. CONFIG_AVR32=y
  415. CONFIG_GENERIC_GPIO=y
  416. @@ -13,10 +13,10 @@
  417. CONFIG_GENERIC_IRQ_PROBE=y
  418. CONFIG_RWSEM_GENERIC_SPINLOCK=y
  419. CONFIG_GENERIC_TIME=y
  420. +CONFIG_GENERIC_CLOCKEVENTS=y
  421. # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
  422. # CONFIG_ARCH_HAS_ILOG2_U32 is not set
  423. # CONFIG_ARCH_HAS_ILOG2_U64 is not set
  424. -CONFIG_ARCH_SUPPORTS_OPROFILE=y
  425. CONFIG_GENERIC_HWEIGHT=y
  426. CONFIG_GENERIC_CALIBRATE_DELAY=y
  427. CONFIG_GENERIC_BUG=y
  428. @@ -37,17 +37,15 @@
  429. CONFIG_BSD_PROCESS_ACCT=y
  430. CONFIG_BSD_PROCESS_ACCT_V3=y
  431. # CONFIG_TASKSTATS is not set
  432. -# CONFIG_USER_NS is not set
  433. -# CONFIG_PID_NS is not set
  434. # CONFIG_AUDIT is not set
  435. # CONFIG_IKCONFIG is not set
  436. CONFIG_LOG_BUF_SHIFT=14
  437. # CONFIG_CGROUPS is not set
  438. -CONFIG_FAIR_GROUP_SCHED=y
  439. -CONFIG_FAIR_USER_SCHED=y
  440. -# CONFIG_FAIR_CGROUP_SCHED is not set
  441. +# CONFIG_GROUP_SCHED is not set
  442. CONFIG_SYSFS_DEPRECATED=y
  443. +CONFIG_SYSFS_DEPRECATED_V2=y
  444. # CONFIG_RELAY is not set
  445. +# CONFIG_NAMESPACES is not set
  446. CONFIG_BLK_DEV_INITRD=y
  447. CONFIG_INITRAMFS_SOURCE=""
  448. CONFIG_CC_OPTIMIZE_FOR_SIZE=y
  449. @@ -61,11 +59,13 @@
  450. CONFIG_PRINTK=y
  451. CONFIG_BUG=y
  452. CONFIG_ELF_CORE=y
  453. +# CONFIG_COMPAT_BRK is not set
  454. # CONFIG_BASE_FULL is not set
  455. CONFIG_FUTEX=y
  456. CONFIG_ANON_INODES=y
  457. CONFIG_EPOLL=y
  458. CONFIG_SIGNALFD=y
  459. +CONFIG_TIMERFD=y
  460. CONFIG_EVENTFD=y
  461. CONFIG_SHMEM=y
  462. CONFIG_VM_EVENT_COUNTERS=y
  463. @@ -73,6 +73,14 @@
  464. # CONFIG_SLAB is not set
  465. CONFIG_SLUB=y
  466. # CONFIG_SLOB is not set
  467. +CONFIG_PROFILING=y
  468. +# CONFIG_MARKERS is not set
  469. +CONFIG_OPROFILE=m
  470. +CONFIG_HAVE_OPROFILE=y
  471. +CONFIG_KPROBES=y
  472. +CONFIG_HAVE_KPROBES=y
  473. +# CONFIG_HAVE_KRETPROBES is not set
  474. +CONFIG_PROC_PAGE_MONITOR=y
  475. CONFIG_SLABINFO=y
  476. CONFIG_RT_MUTEXES=y
  477. # CONFIG_TINY_SHMEM is not set
  478. @@ -101,10 +109,15 @@
  479. CONFIG_DEFAULT_CFQ=y
  480. # CONFIG_DEFAULT_NOOP is not set
  481. CONFIG_DEFAULT_IOSCHED="cfq"
  482. +CONFIG_CLASSIC_RCU=y
  483. #
  484. # System Type and features
  485. #
  486. +CONFIG_TICK_ONESHOT=y
  487. +CONFIG_NO_HZ=y
  488. +CONFIG_HIGH_RES_TIMERS=y
  489. +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
  490. CONFIG_SUBARCH_AVR32B=y
  491. CONFIG_MMU=y
  492. CONFIG_PERFORMANCE_COUNTERS=y
  493. @@ -113,6 +126,7 @@
  494. CONFIG_CPU_AT32AP7000=y
  495. # CONFIG_BOARD_ATSTK1000 is not set
  496. CONFIG_BOARD_ATNGW100=y
  497. +CONFIG_BOARD_ATNGW100_I2C_GPIO=y
  498. CONFIG_LOADER_U_BOOT=y
  499. #
  500. @@ -121,6 +135,7 @@
  501. # CONFIG_AP700X_32_BIT_SMC is not set
  502. CONFIG_AP700X_16_BIT_SMC=y
  503. # CONFIG_AP700X_8_BIT_SMC is not set
  504. +CONFIG_GPIO_DEV=y
  505. CONFIG_LOAD_ADDRESS=0x10000000
  506. CONFIG_ENTRY_ADDRESS=0x90000000
  507. CONFIG_PHYS_OFFSET=0x10000000
  508. @@ -146,16 +161,26 @@
  509. CONFIG_ZONE_DMA_FLAG=0
  510. CONFIG_VIRT_TO_BUS=y
  511. # CONFIG_OWNERSHIP_TRACE is not set
  512. +CONFIG_NMI_DEBUGGING=y
  513. +CONFIG_DW_DMAC=y
  514. # CONFIG_HZ_100 is not set
  515. CONFIG_HZ_250=y
  516. # CONFIG_HZ_300 is not set
  517. # CONFIG_HZ_1000 is not set
  518. CONFIG_HZ=250
  519. +# CONFIG_SCHED_HRTICK is not set
  520. CONFIG_CMDLINE=""
  521. #
  522. # Power management options
  523. #
  524. +CONFIG_ARCH_SUSPEND_POSSIBLE=y
  525. +CONFIG_PM=y
  526. +# CONFIG_PM_LEGACY is not set
  527. +# CONFIG_PM_DEBUG is not set
  528. +CONFIG_PM_SLEEP=y
  529. +CONFIG_SUSPEND=y
  530. +CONFIG_SUSPEND_FREEZER=y
  531. #
  532. # CPU Frequency scaling
  533. @@ -164,9 +189,9 @@
  534. CONFIG_CPU_FREQ_TABLE=y
  535. # CONFIG_CPU_FREQ_DEBUG is not set
  536. # CONFIG_CPU_FREQ_STAT is not set
  537. -CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
  538. +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
  539. # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
  540. -# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
  541. +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
  542. # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
  543. CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
  544. # CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
  545. @@ -202,6 +227,7 @@
  546. CONFIG_XFRM_USER=y
  547. # CONFIG_XFRM_SUB_POLICY is not set
  548. # CONFIG_XFRM_MIGRATE is not set
  549. +# CONFIG_XFRM_STATISTICS is not set
  550. CONFIG_NET_KEY=y
  551. # CONFIG_NET_KEY_MIGRATE is not set
  552. CONFIG_INET=y
  553. @@ -260,82 +286,33 @@
  554. # CONFIG_NETWORK_SECMARK is not set
  555. CONFIG_NETFILTER=y
  556. # CONFIG_NETFILTER_DEBUG is not set
  557. -CONFIG_BRIDGE_NETFILTER=y
  558. +# CONFIG_NETFILTER_ADVANCED is not set
  559. #
  560. # Core Netfilter Configuration
  561. #
  562. -# CONFIG_NETFILTER_NETLINK is not set
  563. -CONFIG_NF_CONNTRACK_ENABLED=m
  564. +CONFIG_NETFILTER_NETLINK=m
  565. +CONFIG_NETFILTER_NETLINK_LOG=m
  566. CONFIG_NF_CONNTRACK=m
  567. -CONFIG_NF_CT_ACCT=y
  568. -CONFIG_NF_CONNTRACK_MARK=y
  569. -# CONFIG_NF_CONNTRACK_EVENTS is not set
  570. -CONFIG_NF_CT_PROTO_GRE=m
  571. -# CONFIG_NF_CT_PROTO_SCTP is not set
  572. -# CONFIG_NF_CT_PROTO_UDPLITE is not set
  573. -CONFIG_NF_CONNTRACK_AMANDA=m
  574. CONFIG_NF_CONNTRACK_FTP=m
  575. -CONFIG_NF_CONNTRACK_H323=m
  576. CONFIG_NF_CONNTRACK_IRC=m
  577. -CONFIG_NF_CONNTRACK_NETBIOS_NS=m
  578. -CONFIG_NF_CONNTRACK_PPTP=m
  579. -CONFIG_NF_CONNTRACK_SANE=m
  580. CONFIG_NF_CONNTRACK_SIP=m
  581. -CONFIG_NF_CONNTRACK_TFTP=m
  582. +CONFIG_NF_CT_NETLINK=m
  583. CONFIG_NETFILTER_XTABLES=y
  584. -CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
  585. -# CONFIG_NETFILTER_XT_TARGET_CONNMARK is not set
  586. -# CONFIG_NETFILTER_XT_TARGET_DSCP is not set
  587. CONFIG_NETFILTER_XT_TARGET_MARK=m
  588. -CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
  589. CONFIG_NETFILTER_XT_TARGET_NFLOG=m
  590. -# CONFIG_NETFILTER_XT_TARGET_NOTRACK is not set
  591. -# CONFIG_NETFILTER_XT_TARGET_TRACE is not set
  592. CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
  593. -CONFIG_NETFILTER_XT_MATCH_COMMENT=m
  594. -CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
  595. -# CONFIG_NETFILTER_XT_MATCH_CONNLIMIT is not set
  596. -CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
  597. CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
  598. -# CONFIG_NETFILTER_XT_MATCH_DCCP is not set
  599. -# CONFIG_NETFILTER_XT_MATCH_DSCP is not set
  600. -CONFIG_NETFILTER_XT_MATCH_ESP=m
  601. -CONFIG_NETFILTER_XT_MATCH_HELPER=m
  602. -CONFIG_NETFILTER_XT_MATCH_LENGTH=m
  603. -CONFIG_NETFILTER_XT_MATCH_LIMIT=m
  604. -CONFIG_NETFILTER_XT_MATCH_MAC=m
  605. CONFIG_NETFILTER_XT_MATCH_MARK=m
  606. CONFIG_NETFILTER_XT_MATCH_POLICY=m
  607. -CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
  608. -# CONFIG_NETFILTER_XT_MATCH_PHYSDEV is not set
  609. -CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
  610. -CONFIG_NETFILTER_XT_MATCH_QUOTA=m
  611. -CONFIG_NETFILTER_XT_MATCH_REALM=m
  612. -# CONFIG_NETFILTER_XT_MATCH_SCTP is not set
  613. CONFIG_NETFILTER_XT_MATCH_STATE=m
  614. -CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
  615. -CONFIG_NETFILTER_XT_MATCH_STRING=m
  616. -CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
  617. -# CONFIG_NETFILTER_XT_MATCH_TIME is not set
  618. -# CONFIG_NETFILTER_XT_MATCH_U32 is not set
  619. -CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
  620. #
  621. # IP: Netfilter Configuration
  622. #
  623. CONFIG_NF_CONNTRACK_IPV4=m
  624. CONFIG_NF_CONNTRACK_PROC_COMPAT=y
  625. -# CONFIG_IP_NF_QUEUE is not set
  626. CONFIG_IP_NF_IPTABLES=m
  627. -CONFIG_IP_NF_MATCH_IPRANGE=m
  628. -CONFIG_IP_NF_MATCH_TOS=m
  629. -CONFIG_IP_NF_MATCH_RECENT=m
  630. -CONFIG_IP_NF_MATCH_ECN=m
  631. -CONFIG_IP_NF_MATCH_AH=m
  632. -CONFIG_IP_NF_MATCH_TTL=m
  633. -CONFIG_IP_NF_MATCH_OWNER=m
  634. -CONFIG_IP_NF_MATCH_ADDRTYPE=m
  635. CONFIG_IP_NF_FILTER=m
  636. CONFIG_IP_NF_TARGET_REJECT=m
  637. CONFIG_IP_NF_TARGET_LOG=m
  638. @@ -343,54 +320,25 @@
  639. CONFIG_NF_NAT=m
  640. CONFIG_NF_NAT_NEEDED=y
  641. CONFIG_IP_NF_TARGET_MASQUERADE=m
  642. -CONFIG_IP_NF_TARGET_REDIRECT=m
  643. -CONFIG_IP_NF_TARGET_NETMAP=m
  644. -CONFIG_IP_NF_TARGET_SAME=m
  645. -CONFIG_NF_NAT_SNMP_BASIC=m
  646. -CONFIG_NF_NAT_PROTO_GRE=m
  647. CONFIG_NF_NAT_FTP=m
  648. CONFIG_NF_NAT_IRC=m
  649. -CONFIG_NF_NAT_TFTP=m
  650. -CONFIG_NF_NAT_AMANDA=m
  651. -CONFIG_NF_NAT_PPTP=m
  652. -CONFIG_NF_NAT_H323=m
  653. +# CONFIG_NF_NAT_TFTP is not set
  654. +# CONFIG_NF_NAT_AMANDA is not set
  655. +# CONFIG_NF_NAT_PPTP is not set
  656. +# CONFIG_NF_NAT_H323 is not set
  657. CONFIG_NF_NAT_SIP=m
  658. CONFIG_IP_NF_MANGLE=m
  659. -CONFIG_IP_NF_TARGET_TOS=m
  660. -CONFIG_IP_NF_TARGET_ECN=m
  661. -CONFIG_IP_NF_TARGET_TTL=m
  662. -CONFIG_IP_NF_TARGET_CLUSTERIP=m
  663. -CONFIG_IP_NF_RAW=m
  664. -CONFIG_IP_NF_ARPTABLES=m
  665. -CONFIG_IP_NF_ARPFILTER=m
  666. -CONFIG_IP_NF_ARP_MANGLE=m
  667. #
  668. -# IPv6: Netfilter Configuration (EXPERIMENTAL)
  669. +# IPv6: Netfilter Configuration
  670. #
  671. CONFIG_NF_CONNTRACK_IPV6=m
  672. -CONFIG_IP6_NF_QUEUE=m
  673. CONFIG_IP6_NF_IPTABLES=m
  674. -CONFIG_IP6_NF_MATCH_RT=m
  675. -CONFIG_IP6_NF_MATCH_OPTS=m
  676. -CONFIG_IP6_NF_MATCH_FRAG=m
  677. -CONFIG_IP6_NF_MATCH_HL=m
  678. -CONFIG_IP6_NF_MATCH_OWNER=m
  679. CONFIG_IP6_NF_MATCH_IPV6HEADER=m
  680. -CONFIG_IP6_NF_MATCH_AH=m
  681. -CONFIG_IP6_NF_MATCH_MH=m
  682. -CONFIG_IP6_NF_MATCH_EUI64=m
  683. CONFIG_IP6_NF_FILTER=m
  684. CONFIG_IP6_NF_TARGET_LOG=m
  685. CONFIG_IP6_NF_TARGET_REJECT=m
  686. CONFIG_IP6_NF_MANGLE=m
  687. -CONFIG_IP6_NF_TARGET_HL=m
  688. -CONFIG_IP6_NF_RAW=m
  689. -
  690. -#
  691. -# Bridge: Netfilter Configuration
  692. -#
  693. -# CONFIG_BRIDGE_NF_EBTABLES is not set
  694. # CONFIG_IP_DCCP is not set
  695. # CONFIG_IP_SCTP is not set
  696. # CONFIG_TIPC is not set
  697. @@ -407,7 +355,6 @@
  698. # CONFIG_ECONET is not set
  699. # CONFIG_WAN_ROUTER is not set
  700. # CONFIG_NET_SCHED is not set
  701. -CONFIG_NET_CLS_ROUTE=y
  702. #
  703. # Network testing
  704. @@ -415,6 +362,7 @@
  705. # CONFIG_NET_PKTGEN is not set
  706. # CONFIG_NET_TCPPROBE is not set
  707. # CONFIG_HAMRADIO is not set
  708. +# CONFIG_CAN is not set
  709. # CONFIG_IRDA is not set
  710. # CONFIG_BT is not set
  711. # CONFIG_AF_RXRPC is not set
  712. @@ -531,11 +479,18 @@
  713. CONFIG_BLK_DEV_RAM=m
  714. CONFIG_BLK_DEV_RAM_COUNT=16
  715. CONFIG_BLK_DEV_RAM_SIZE=4096
  716. -CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
  717. +# CONFIG_BLK_DEV_XIP is not set
  718. # CONFIG_CDROM_PKTCDVD is not set
  719. # CONFIG_ATA_OVER_ETH is not set
  720. -# CONFIG_MISC_DEVICES is not set
  721. -# CONFIG_IDE is not set
  722. +CONFIG_MISC_DEVICES=y
  723. +# CONFIG_ATMEL_PWM is not set
  724. +CONFIG_ATMEL_TCLIB=y
  725. +CONFIG_ATMEL_TCB_CLKSRC=y
  726. +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
  727. +# CONFIG_EEPROM_93CX6 is not set
  728. +# CONFIG_ATMEL_SSC is not set
  729. +# CONFIG_ENCLOSURE_SERVICES is not set
  730. +# CONFIG_HAVE_IDE is not set
  731. #
  732. # SCSI device support
  733. @@ -568,11 +523,13 @@
  734. # CONFIG_SMSC_PHY is not set
  735. # CONFIG_BROADCOM_PHY is not set
  736. # CONFIG_ICPLUS_PHY is not set
  737. +# CONFIG_REALTEK_PHY is not set
  738. # CONFIG_FIXED_PHY is not set
  739. # CONFIG_MDIO_BITBANG is not set
  740. CONFIG_NET_ETHERNET=y
  741. # CONFIG_MII is not set
  742. CONFIG_MACB=y
  743. +# CONFIG_ENC28J60 is not set
  744. # CONFIG_IBM_NEW_EMAC_ZMII is not set
  745. # CONFIG_IBM_NEW_EMAC_RGMII is not set
  746. # CONFIG_IBM_NEW_EMAC_TAH is not set
  747. @@ -599,7 +556,6 @@
  748. # CONFIG_PPPOL2TP is not set
  749. # CONFIG_SLIP is not set
  750. CONFIG_SLHC=m
  751. -# CONFIG_SHAPER is not set
  752. # CONFIG_NETCONSOLE is not set
  753. # CONFIG_NETPOLL is not set
  754. # CONFIG_NET_POLL_CONTROLLER is not set
  755. @@ -633,6 +589,7 @@
  756. #
  757. CONFIG_SERIAL_ATMEL=y
  758. CONFIG_SERIAL_ATMEL_CONSOLE=y
  759. +CONFIG_SERIAL_ATMEL_PDC=y
  760. # CONFIG_SERIAL_ATMEL_TTYAT is not set
  761. CONFIG_SERIAL_CORE=y
  762. CONFIG_SERIAL_CORE_CONSOLE=y
  763. @@ -640,8 +597,6 @@
  764. # CONFIG_LEGACY_PTYS is not set
  765. # CONFIG_IPMI_HANDLER is not set
  766. # CONFIG_HW_RANDOM is not set
  767. -# CONFIG_RTC is not set
  768. -# CONFIG_GEN_RTC is not set
  769. # CONFIG_R3964 is not set
  770. # CONFIG_RAW_DRIVER is not set
  771. # CONFIG_TCG_TPM is not set
  772. @@ -659,6 +614,7 @@
  773. #
  774. # I2C Hardware Bus support
  775. #
  776. +CONFIG_I2C_ATMELTWI=m
  777. CONFIG_I2C_GPIO=m
  778. # CONFIG_I2C_OCORES is not set
  779. # CONFIG_I2C_PARPORT_LIGHT is not set
  780. @@ -669,13 +625,12 @@
  781. #
  782. # Miscellaneous I2C Chip support
  783. #
  784. -# CONFIG_SENSORS_DS1337 is not set
  785. -# CONFIG_SENSORS_DS1374 is not set
  786. # CONFIG_DS1682 is not set
  787. # CONFIG_SENSORS_EEPROM is not set
  788. # CONFIG_SENSORS_PCF8574 is not set
  789. -# CONFIG_SENSORS_PCA9539 is not set
  790. +# CONFIG_PCF8575 is not set
  791. # CONFIG_SENSORS_PCF8591 is not set
  792. +# CONFIG_TPS65010 is not set
  793. # CONFIG_SENSORS_MAX6875 is not set
  794. # CONFIG_SENSORS_TSL2550 is not set
  795. # CONFIG_I2C_DEBUG_CORE is not set
  796. @@ -702,9 +657,27 @@
  797. # CONFIG_SPI_AT25 is not set
  798. CONFIG_SPI_SPIDEV=m
  799. # CONFIG_SPI_TLE62X0 is not set
  800. +CONFIG_HAVE_GPIO_LIB=y
  801. +
  802. +#
  803. +# GPIO Support
  804. +#
  805. +# CONFIG_DEBUG_GPIO is not set
  806. +
  807. +#
  808. +# I2C GPIO expanders:
  809. +#
  810. +# CONFIG_GPIO_PCA953X is not set
  811. +# CONFIG_GPIO_PCF857X is not set
  812. +
  813. +#
  814. +# SPI GPIO expanders:
  815. +#
  816. +# CONFIG_GPIO_MCP23S08 is not set
  817. # CONFIG_W1 is not set
  818. # CONFIG_POWER_SUPPLY is not set
  819. # CONFIG_HWMON is not set
  820. +# CONFIG_THERMAL is not set
  821. CONFIG_WATCHDOG=y
  822. # CONFIG_WATCHDOG_NOWAYOUT is not set
  823. @@ -757,10 +730,6 @@
  824. #
  825. # NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
  826. #
  827. -
  828. -#
  829. -# USB Gadget Support
  830. -#
  831. CONFIG_USB_GADGET=y
  832. # CONFIG_USB_GADGET_DEBUG is not set
  833. # CONFIG_USB_GADGET_DEBUG_FILES is not set
  834. @@ -787,21 +756,24 @@
  835. # CONFIG_USB_FILE_STORAGE_TEST is not set
  836. CONFIG_USB_G_SERIAL=m
  837. # CONFIG_USB_MIDI_GADGET is not set
  838. -CONFIG_MMC=m
  839. +# CONFIG_USB_G_PRINTER is not set
  840. +CONFIG_MMC=y
  841. # CONFIG_MMC_DEBUG is not set
  842. # CONFIG_MMC_UNSAFE_RESUME is not set
  843. #
  844. # MMC/SD Card Drivers
  845. #
  846. -CONFIG_MMC_BLOCK=m
  847. +CONFIG_MMC_BLOCK=y
  848. CONFIG_MMC_BLOCK_BOUNCE=y
  849. # CONFIG_SDIO_UART is not set
  850. #
  851. # MMC/SD Host Controller Drivers
  852. #
  853. +CONFIG_MMC_ATMELMCI=y
  854. CONFIG_MMC_SPI=m
  855. +# CONFIG_MEMSTICK is not set
  856. CONFIG_NEW_LEDS=y
  857. CONFIG_LEDS_CLASS=y
  858. @@ -844,19 +816,22 @@
  859. # CONFIG_RTC_DRV_PCF8563 is not set
  860. # CONFIG_RTC_DRV_PCF8583 is not set
  861. # CONFIG_RTC_DRV_M41T80 is not set
  862. +# CONFIG_RTC_DRV_S35390A is not set
  863. #
  864. # SPI RTC drivers
  865. #
  866. -# CONFIG_RTC_DRV_RS5C348 is not set
  867. # CONFIG_RTC_DRV_MAX6902 is not set
  868. +# CONFIG_RTC_DRV_R9701 is not set
  869. +# CONFIG_RTC_DRV_RS5C348 is not set
  870. #
  871. # Platform RTC drivers
  872. #
  873. +# CONFIG_RTC_DRV_DS1511 is not set
  874. # CONFIG_RTC_DRV_DS1553 is not set
  875. -# CONFIG_RTC_DRV_STK17TA8 is not set
  876. # CONFIG_RTC_DRV_DS1742 is not set
  877. +# CONFIG_RTC_DRV_STK17TA8 is not set
  878. # CONFIG_RTC_DRV_M48T86 is not set
  879. # CONFIG_RTC_DRV_M48T59 is not set
  880. # CONFIG_RTC_DRV_V3020 is not set
  881. @@ -874,25 +849,23 @@
  882. #
  883. # File systems
  884. #
  885. -CONFIG_EXT2_FS=m
  886. +CONFIG_EXT2_FS=y
  887. # CONFIG_EXT2_FS_XATTR is not set
  888. # CONFIG_EXT2_FS_XIP is not set
  889. -CONFIG_EXT3_FS=m
  890. +CONFIG_EXT3_FS=y
  891. # CONFIG_EXT3_FS_XATTR is not set
  892. # CONFIG_EXT4DEV_FS is not set
  893. -CONFIG_JBD=m
  894. +CONFIG_JBD=y
  895. # CONFIG_REISERFS_FS is not set
  896. # CONFIG_JFS_FS is not set
  897. # CONFIG_FS_POSIX_ACL is not set
  898. # CONFIG_XFS_FS is not set
  899. # CONFIG_GFS2_FS is not set
  900. # CONFIG_OCFS2_FS is not set
  901. -# CONFIG_MINIX_FS is not set
  902. -# CONFIG_ROMFS_FS is not set
  903. +# CONFIG_DNOTIFY is not set
  904. CONFIG_INOTIFY=y
  905. CONFIG_INOTIFY_USER=y
  906. # CONFIG_QUOTA is not set
  907. -# CONFIG_DNOTIFY is not set
  908. # CONFIG_AUTOFS_FS is not set
  909. # CONFIG_AUTOFS4_FS is not set
  910. CONFIG_FUSE_FS=m
  911. @@ -923,7 +896,7 @@
  912. CONFIG_TMPFS=y
  913. # CONFIG_TMPFS_POSIX_ACL is not set
  914. # CONFIG_HUGETLB_PAGE is not set
  915. -CONFIG_CONFIGFS_FS=m
  916. +CONFIG_CONFIGFS_FS=y
  917. #
  918. # Miscellaneous filesystems
  919. @@ -948,8 +921,10 @@
  920. # CONFIG_JFFS2_RUBIN is not set
  921. # CONFIG_CRAMFS is not set
  922. # CONFIG_VXFS_FS is not set
  923. +# CONFIG_MINIX_FS is not set
  924. # CONFIG_HPFS_FS is not set
  925. # CONFIG_QNX4FS_FS is not set
  926. +# CONFIG_ROMFS_FS is not set
  927. # CONFIG_SYSV_FS is not set
  928. # CONFIG_UFS_FS is not set
  929. CONFIG_NETWORK_FILESYSTEMS=y
  930. @@ -1030,11 +1005,6 @@
  931. # CONFIG_NLS_KOI8_U is not set
  932. CONFIG_NLS_UTF8=m
  933. # CONFIG_DLM is not set
  934. -CONFIG_INSTRUMENTATION=y
  935. -CONFIG_PROFILING=y
  936. -CONFIG_OPROFILE=m
  937. -CONFIG_KPROBES=y
  938. -# CONFIG_MARKERS is not set
  939. #
  940. # Kernel hacking
  941. @@ -1053,6 +1023,7 @@
  942. # CONFIG_SCHEDSTATS is not set
  943. # CONFIG_TIMER_STATS is not set
  944. # CONFIG_SLUB_DEBUG_ON is not set
  945. +# CONFIG_SLUB_STATS is not set
  946. # CONFIG_DEBUG_RT_MUTEXES is not set
  947. # CONFIG_RT_MUTEX_TESTER is not set
  948. # CONFIG_DEBUG_SPINLOCK is not set
  949. @@ -1069,9 +1040,10 @@
  950. # CONFIG_DEBUG_LIST is not set
  951. # CONFIG_DEBUG_SG is not set
  952. CONFIG_FRAME_POINTER=y
  953. -# CONFIG_FORCED_INLINING is not set
  954. # CONFIG_BOOT_PRINTK_DELAY is not set
  955. # CONFIG_RCU_TORTURE_TEST is not set
  956. +# CONFIG_KPROBES_SANITY_TEST is not set
  957. +# CONFIG_BACKTRACE_SELF_TEST is not set
  958. # CONFIG_LKDTM is not set
  959. # CONFIG_FAULT_INJECTION is not set
  960. # CONFIG_SAMPLES is not set
  961. @@ -1084,7 +1056,9 @@
  962. # CONFIG_SECURITY_FILE_CAPABILITIES is not set
  963. CONFIG_CRYPTO=y
  964. CONFIG_CRYPTO_ALGAPI=y
  965. +CONFIG_CRYPTO_AEAD=y
  966. CONFIG_CRYPTO_BLKCIPHER=y
  967. +# CONFIG_CRYPTO_SEQIV is not set
  968. CONFIG_CRYPTO_HASH=y
  969. CONFIG_CRYPTO_MANAGER=y
  970. CONFIG_CRYPTO_HMAC=y
  971. @@ -1103,6 +1077,9 @@
  972. CONFIG_CRYPTO_PCBC=m
  973. # CONFIG_CRYPTO_LRW is not set
  974. # CONFIG_CRYPTO_XTS is not set
  975. +# CONFIG_CRYPTO_CTR is not set
  976. +# CONFIG_CRYPTO_GCM is not set
  977. +# CONFIG_CRYPTO_CCM is not set
  978. # CONFIG_CRYPTO_CRYPTD is not set
  979. CONFIG_CRYPTO_DES=y
  980. # CONFIG_CRYPTO_FCRYPT is not set
  981. @@ -1117,12 +1094,14 @@
  982. # CONFIG_CRYPTO_KHAZAD is not set
  983. # CONFIG_CRYPTO_ANUBIS is not set
  984. # CONFIG_CRYPTO_SEED is not set
  985. +# CONFIG_CRYPTO_SALSA20 is not set
  986. CONFIG_CRYPTO_DEFLATE=y
  987. # CONFIG_CRYPTO_MICHAEL_MIC is not set
  988. # CONFIG_CRYPTO_CRC32C is not set
  989. # CONFIG_CRYPTO_CAMELLIA is not set
  990. # CONFIG_CRYPTO_TEST is not set
  991. -# CONFIG_CRYPTO_AUTHENC is not set
  992. +CONFIG_CRYPTO_AUTHENC=y
  993. +# CONFIG_CRYPTO_LZO is not set
  994. CONFIG_CRYPTO_HW=y
  995. #
  996. @@ -1137,10 +1116,7 @@
  997. # CONFIG_LIBCRC32C is not set
  998. CONFIG_ZLIB_INFLATE=y
  999. CONFIG_ZLIB_DEFLATE=y
  1000. -CONFIG_TEXTSEARCH=y
  1001. -CONFIG_TEXTSEARCH_KMP=m
  1002. -CONFIG_TEXTSEARCH_BM=m
  1003. -CONFIG_TEXTSEARCH_FSM=m
  1004. +CONFIG_GENERIC_ALLOCATOR=y
  1005. CONFIG_PLIST=y
  1006. CONFIG_HAS_IOMEM=y
  1007. CONFIG_HAS_IOPORT=y
  1008. --- a/arch/avr32/configs/atstk1002_defconfig
  1009. +++ b/arch/avr32/configs/atstk1002_defconfig
  1010. @@ -1,7 +1,7 @@
  1011. #
  1012. # Automatically generated make config: don't edit
  1013. -# Linux kernel version: 2.6.24-rc7
  1014. -# Wed Jan 9 23:07:43 2008
  1015. +# Linux kernel version: 2.6.25.4
  1016. +# Wed Jun 11 15:29:18 2008
  1017. #
  1018. CONFIG_AVR32=y
  1019. CONFIG_GENERIC_GPIO=y
  1020. @@ -13,10 +13,10 @@
  1021. CONFIG_GENERIC_IRQ_PROBE=y
  1022. CONFIG_RWSEM_GENERIC_SPINLOCK=y
  1023. CONFIG_GENERIC_TIME=y
  1024. +CONFIG_GENERIC_CLOCKEVENTS=y
  1025. # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
  1026. # CONFIG_ARCH_HAS_ILOG2_U32 is not set
  1027. # CONFIG_ARCH_HAS_ILOG2_U64 is not set
  1028. -CONFIG_ARCH_SUPPORTS_OPROFILE=y
  1029. CONFIG_GENERIC_HWEIGHT=y
  1030. CONFIG_GENERIC_CALIBRATE_DELAY=y
  1031. CONFIG_GENERIC_BUG=y
  1032. @@ -36,15 +36,15 @@
  1033. CONFIG_POSIX_MQUEUE=y
  1034. # CONFIG_BSD_PROCESS_ACCT is not set
  1035. # CONFIG_TASKSTATS is not set
  1036. -# CONFIG_USER_NS is not set
  1037. -# CONFIG_PID_NS is not set
  1038. # CONFIG_AUDIT is not set
  1039. # CONFIG_IKCONFIG is not set
  1040. CONFIG_LOG_BUF_SHIFT=14
  1041. # CONFIG_CGROUPS is not set
  1042. -# CONFIG_FAIR_GROUP_SCHED is not set
  1043. +# CONFIG_GROUP_SCHED is not set
  1044. CONFIG_SYSFS_DEPRECATED=y
  1045. +CONFIG_SYSFS_DEPRECATED_V2=y
  1046. CONFIG_RELAY=y
  1047. +# CONFIG_NAMESPACES is not set
  1048. CONFIG_BLK_DEV_INITRD=y
  1049. CONFIG_INITRAMFS_SOURCE=""
  1050. CONFIG_CC_OPTIMIZE_FOR_SIZE=y
  1051. @@ -58,11 +58,13 @@
  1052. CONFIG_PRINTK=y
  1053. CONFIG_BUG=y
  1054. CONFIG_ELF_CORE=y
  1055. +# CONFIG_COMPAT_BRK is not set
  1056. # CONFIG_BASE_FULL is not set
  1057. CONFIG_FUTEX=y
  1058. CONFIG_ANON_INODES=y
  1059. CONFIG_EPOLL=y
  1060. CONFIG_SIGNALFD=y
  1061. +CONFIG_TIMERFD=y
  1062. CONFIG_EVENTFD=y
  1063. CONFIG_SHMEM=y
  1064. CONFIG_VM_EVENT_COUNTERS=y
  1065. @@ -70,6 +72,14 @@
  1066. # CONFIG_SLAB is not set
  1067. CONFIG_SLUB=y
  1068. # CONFIG_SLOB is not set
  1069. +CONFIG_PROFILING=y
  1070. +# CONFIG_MARKERS is not set
  1071. +CONFIG_OPROFILE=m
  1072. +CONFIG_HAVE_OPROFILE=y
  1073. +CONFIG_KPROBES=y
  1074. +CONFIG_HAVE_KPROBES=y
  1075. +# CONFIG_HAVE_KRETPROBES is not set
  1076. +CONFIG_PROC_PAGE_MONITOR=y
  1077. CONFIG_SLABINFO=y
  1078. CONFIG_RT_MUTEXES=y
  1079. # CONFIG_TINY_SHMEM is not set
  1080. @@ -98,10 +108,15 @@
  1081. CONFIG_DEFAULT_CFQ=y
  1082. # CONFIG_DEFAULT_NOOP is not set
  1083. CONFIG_DEFAULT_IOSCHED="cfq"
  1084. +CONFIG_CLASSIC_RCU=y
  1085. #
  1086. # System Type and features
  1087. #
  1088. +CONFIG_TICK_ONESHOT=y
  1089. +CONFIG_NO_HZ=y
  1090. +CONFIG_HIGH_RES_TIMERS=y
  1091. +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
  1092. CONFIG_SUBARCH_AVR32B=y
  1093. CONFIG_MMU=y
  1094. CONFIG_PERFORMANCE_COUNTERS=y
  1095. @@ -113,12 +128,16 @@
  1096. CONFIG_BOARD_ATSTK1002=y
  1097. # CONFIG_BOARD_ATSTK1003 is not set
  1098. # CONFIG_BOARD_ATSTK1004 is not set
  1099. +# CONFIG_BOARD_ATSTK1006 is not set
  1100. # CONFIG_BOARD_ATSTK100X_CUSTOM is not set
  1101. # CONFIG_BOARD_ATSTK100X_SPI1 is not set
  1102. # CONFIG_BOARD_ATSTK1000_J2_LED is not set
  1103. # CONFIG_BOARD_ATSTK1000_J2_LED8 is not set
  1104. # CONFIG_BOARD_ATSTK1000_J2_RGB is not set
  1105. CONFIG_BOARD_ATSTK1000_EXTDAC=y
  1106. +# CONFIG_BOARD_ATSTK100X_ENABLE_AC97 is not set
  1107. +# CONFIG_BOARD_ATSTK1000_CF_HACKS is not set
  1108. +# CONFIG_BOARD_ATSTK100X_ENABLE_PSIF is not set
  1109. CONFIG_LOADER_U_BOOT=y
  1110. #
  1111. @@ -127,6 +146,7 @@
  1112. # CONFIG_AP700X_32_BIT_SMC is not set
  1113. CONFIG_AP700X_16_BIT_SMC=y
  1114. # CONFIG_AP700X_8_BIT_SMC is not set
  1115. +CONFIG_GPIO_DEV=y
  1116. CONFIG_LOAD_ADDRESS=0x10000000
  1117. CONFIG_ENTRY_ADDRESS=0x90000000
  1118. CONFIG_PHYS_OFFSET=0x10000000
  1119. @@ -152,16 +172,26 @@
  1120. CONFIG_ZONE_DMA_FLAG=0
  1121. CONFIG_VIRT_TO_BUS=y
  1122. # CONFIG_OWNERSHIP_TRACE is not set
  1123. +CONFIG_NMI_DEBUGGING=y
  1124. +CONFIG_DW_DMAC=y
  1125. # CONFIG_HZ_100 is not set
  1126. CONFIG_HZ_250=y
  1127. # CONFIG_HZ_300 is not set
  1128. # CONFIG_HZ_1000 is not set
  1129. CONFIG_HZ=250
  1130. +# CONFIG_SCHED_HRTICK is not set
  1131. CONFIG_CMDLINE=""
  1132. #
  1133. # Power management options
  1134. #
  1135. +CONFIG_ARCH_SUSPEND_POSSIBLE=y
  1136. +CONFIG_PM=y
  1137. +# CONFIG_PM_LEGACY is not set
  1138. +# CONFIG_PM_DEBUG is not set
  1139. +CONFIG_PM_SLEEP=y
  1140. +CONFIG_SUSPEND=y
  1141. +CONFIG_SUSPEND_FREEZER=y
  1142. #
  1143. # CPU Frequency scaling
  1144. @@ -170,9 +200,9 @@
  1145. CONFIG_CPU_FREQ_TABLE=y
  1146. # CONFIG_CPU_FREQ_DEBUG is not set
  1147. # CONFIG_CPU_FREQ_STAT is not set
  1148. -CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
  1149. +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
  1150. # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
  1151. -# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
  1152. +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
  1153. # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
  1154. CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
  1155. # CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
  1156. @@ -208,6 +238,7 @@
  1157. CONFIG_XFRM_USER=m
  1158. # CONFIG_XFRM_SUB_POLICY is not set
  1159. # CONFIG_XFRM_MIGRATE is not set
  1160. +# CONFIG_XFRM_STATISTICS is not set
  1161. CONFIG_NET_KEY=m
  1162. # CONFIG_NET_KEY_MIGRATE is not set
  1163. CONFIG_INET=y
  1164. @@ -279,6 +310,7 @@
  1165. # CONFIG_NET_PKTGEN is not set
  1166. # CONFIG_NET_TCPPROBE is not set
  1167. # CONFIG_HAMRADIO is not set
  1168. +# CONFIG_CAN is not set
  1169. # CONFIG_IRDA is not set
  1170. # CONFIG_BT is not set
  1171. # CONFIG_AF_RXRPC is not set
  1172. @@ -395,13 +427,18 @@
  1173. CONFIG_BLK_DEV_RAM=m
  1174. CONFIG_BLK_DEV_RAM_COUNT=16
  1175. CONFIG_BLK_DEV_RAM_SIZE=4096
  1176. -CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
  1177. +# CONFIG_BLK_DEV_XIP is not set
  1178. # CONFIG_CDROM_PKTCDVD is not set
  1179. # CONFIG_ATA_OVER_ETH is not set
  1180. CONFIG_MISC_DEVICES=y
  1181. +CONFIG_ATMEL_PWM=m
  1182. +CONFIG_ATMEL_TCLIB=y
  1183. +CONFIG_ATMEL_TCB_CLKSRC=y
  1184. +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
  1185. # CONFIG_EEPROM_93CX6 is not set
  1186. CONFIG_ATMEL_SSC=m
  1187. -# CONFIG_IDE is not set
  1188. +# CONFIG_ENCLOSURE_SERVICES is not set
  1189. +# CONFIG_HAVE_IDE is not set
  1190. #
  1191. # SCSI device support
  1192. @@ -444,6 +481,7 @@
  1193. # CONFIG_SCSI_LOWLEVEL is not set
  1194. CONFIG_ATA=m
  1195. # CONFIG_ATA_NONSTANDARD is not set
  1196. +# CONFIG_SATA_MV is not set
  1197. CONFIG_PATA_AT32=m
  1198. # CONFIG_PATA_PLATFORM is not set
  1199. # CONFIG_MD is not set
  1200. @@ -469,11 +507,13 @@
  1201. # CONFIG_SMSC_PHY is not set
  1202. # CONFIG_BROADCOM_PHY is not set
  1203. # CONFIG_ICPLUS_PHY is not set
  1204. +# CONFIG_REALTEK_PHY is not set
  1205. # CONFIG_FIXED_PHY is not set
  1206. # CONFIG_MDIO_BITBANG is not set
  1207. CONFIG_NET_ETHERNET=y
  1208. # CONFIG_MII is not set
  1209. CONFIG_MACB=y
  1210. +# CONFIG_ENC28J60 is not set
  1211. # CONFIG_IBM_NEW_EMAC_ZMII is not set
  1212. # CONFIG_IBM_NEW_EMAC_RGMII is not set
  1213. # CONFIG_IBM_NEW_EMAC_TAH is not set
  1214. @@ -500,7 +540,6 @@
  1215. # CONFIG_PPPOL2TP is not set
  1216. # CONFIG_SLIP is not set
  1217. CONFIG_SLHC=m
  1218. -# CONFIG_SHAPER is not set
  1219. # CONFIG_NETCONSOLE is not set
  1220. # CONFIG_NETPOLL is not set
  1221. # CONFIG_NET_POLL_CONTROLLER is not set
  1222. @@ -568,6 +607,7 @@
  1223. #
  1224. CONFIG_SERIAL_ATMEL=y
  1225. CONFIG_SERIAL_ATMEL_CONSOLE=y
  1226. +CONFIG_SERIAL_ATMEL_PDC=y
  1227. # CONFIG_SERIAL_ATMEL_TTYAT is not set
  1228. CONFIG_SERIAL_CORE=y
  1229. CONFIG_SERIAL_CORE_CONSOLE=y
  1230. @@ -575,8 +615,6 @@
  1231. # CONFIG_LEGACY_PTYS is not set
  1232. # CONFIG_IPMI_HANDLER is not set
  1233. # CONFIG_HW_RANDOM is not set
  1234. -# CONFIG_RTC is not set
  1235. -# CONFIG_GEN_RTC is not set
  1236. # CONFIG_R3964 is not set
  1237. # CONFIG_RAW_DRIVER is not set
  1238. # CONFIG_TCG_TPM is not set
  1239. @@ -594,6 +632,7 @@
  1240. #
  1241. # I2C Hardware Bus support
  1242. #
  1243. +CONFIG_I2C_ATMELTWI=m
  1244. CONFIG_I2C_GPIO=m
  1245. # CONFIG_I2C_OCORES is not set
  1246. # CONFIG_I2C_PARPORT_LIGHT is not set
  1247. @@ -604,13 +643,12 @@
  1248. #
  1249. # Miscellaneous I2C Chip support
  1250. #
  1251. -# CONFIG_SENSORS_DS1337 is not set
  1252. -# CONFIG_SENSORS_DS1374 is not set
  1253. # CONFIG_DS1682 is not set
  1254. # CONFIG_SENSORS_EEPROM is not set
  1255. # CONFIG_SENSORS_PCF8574 is not set
  1256. -# CONFIG_SENSORS_PCA9539 is not set
  1257. +# CONFIG_PCF8575 is not set
  1258. # CONFIG_SENSORS_PCF8591 is not set
  1259. +# CONFIG_TPS65010 is not set
  1260. # CONFIG_SENSORS_MAX6875 is not set
  1261. # CONFIG_SENSORS_TSL2550 is not set
  1262. # CONFIG_I2C_DEBUG_CORE is not set
  1263. @@ -637,9 +675,27 @@
  1264. # CONFIG_SPI_AT25 is not set
  1265. CONFIG_SPI_SPIDEV=m
  1266. # CONFIG_SPI_TLE62X0 is not set
  1267. +CONFIG_HAVE_GPIO_LIB=y
  1268. +
  1269. +#
  1270. +# GPIO Support
  1271. +#
  1272. +# CONFIG_DEBUG_GPIO is not set
  1273. +
  1274. +#
  1275. +# I2C GPIO expanders:
  1276. +#
  1277. +# CONFIG_GPIO_PCA953X is not set
  1278. +# CONFIG_GPIO_PCF857X is not set
  1279. +
  1280. +#
  1281. +# SPI GPIO expanders:
  1282. +#
  1283. +# CONFIG_GPIO_MCP23S08 is not set
  1284. # CONFIG_W1 is not set
  1285. # CONFIG_POWER_SUPPLY is not set
  1286. # CONFIG_HWMON is not set
  1287. +# CONFIG_THERMAL is not set
  1288. CONFIG_WATCHDOG=y
  1289. # CONFIG_WATCHDOG_NOWAYOUT is not set
  1290. @@ -732,12 +788,18 @@
  1291. #
  1292. # Generic devices
  1293. #
  1294. +CONFIG_SND_AC97_CODEC=m
  1295. # CONFIG_SND_DUMMY is not set
  1296. # CONFIG_SND_MTPAV is not set
  1297. # CONFIG_SND_SERIAL_U16550 is not set
  1298. # CONFIG_SND_MPU401 is not set
  1299. #
  1300. +# AVR32 devices
  1301. +#
  1302. +CONFIG_SND_ATMEL_AC97=m
  1303. +
  1304. +#
  1305. # SPI devices
  1306. #
  1307. CONFIG_SND_AT73C213=m
  1308. @@ -753,9 +815,14 @@
  1309. #
  1310. #
  1311. +# ALSA SoC audio for Freescale SOCs
  1312. +#
  1313. +
  1314. +#
  1315. # Open Sound System
  1316. #
  1317. # CONFIG_SOUND_PRIME is not set
  1318. +CONFIG_AC97_BUS=m
  1319. # CONFIG_HID_SUPPORT is not set
  1320. CONFIG_USB_SUPPORT=y
  1321. # CONFIG_USB_ARCH_HAS_HCD is not set
  1322. @@ -765,10 +832,6 @@
  1323. #
  1324. # NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
  1325. #
  1326. -
  1327. -#
  1328. -# USB Gadget Support
  1329. -#
  1330. CONFIG_USB_GADGET=y
  1331. # CONFIG_USB_GADGET_DEBUG is not set
  1332. # CONFIG_USB_GADGET_DEBUG_FILES is not set
  1333. @@ -796,27 +859,31 @@
  1334. # CONFIG_USB_FILE_STORAGE_TEST is not set
  1335. CONFIG_USB_G_SERIAL=m
  1336. # CONFIG_USB_MIDI_GADGET is not set
  1337. -CONFIG_MMC=m
  1338. +# CONFIG_USB_G_PRINTER is not set
  1339. +CONFIG_MMC=y
  1340. # CONFIG_MMC_DEBUG is not set
  1341. # CONFIG_MMC_UNSAFE_RESUME is not set
  1342. #
  1343. # MMC/SD Card Drivers
  1344. #
  1345. -CONFIG_MMC_BLOCK=m
  1346. +CONFIG_MMC_BLOCK=y
  1347. CONFIG_MMC_BLOCK_BOUNCE=y
  1348. # CONFIG_SDIO_UART is not set
  1349. #
  1350. # MMC/SD Host Controller Drivers
  1351. #
  1352. +CONFIG_MMC_ATMELMCI=y
  1353. CONFIG_MMC_SPI=m
  1354. +# CONFIG_MEMSTICK is not set
  1355. CONFIG_NEW_LEDS=y
  1356. CONFIG_LEDS_CLASS=m
  1357. #
  1358. # LED drivers
  1359. #
  1360. +CONFIG_LEDS_ATMEL_PWM=m
  1361. CONFIG_LEDS_GPIO=m
  1362. #
  1363. @@ -853,19 +920,22 @@
  1364. # CONFIG_RTC_DRV_PCF8563 is not set
  1365. # CONFIG_RTC_DRV_PCF8583 is not set
  1366. # CONFIG_RTC_DRV_M41T80 is not set
  1367. +# CONFIG_RTC_DRV_S35390A is not set
  1368. #
  1369. # SPI RTC drivers
  1370. #
  1371. -# CONFIG_RTC_DRV_RS5C348 is not set
  1372. # CONFIG_RTC_DRV_MAX6902 is not set
  1373. +# CONFIG_RTC_DRV_R9701 is not set
  1374. +# CONFIG_RTC_DRV_RS5C348 is not set
  1375. #
  1376. # Platform RTC drivers
  1377. #
  1378. +# CONFIG_RTC_DRV_DS1511 is not set
  1379. # CONFIG_RTC_DRV_DS1553 is not set
  1380. -# CONFIG_RTC_DRV_STK17TA8 is not set
  1381. # CONFIG_RTC_DRV_DS1742 is not set
  1382. +# CONFIG_RTC_DRV_STK17TA8 is not set
  1383. # CONFIG_RTC_DRV_M48T86 is not set
  1384. # CONFIG_RTC_DRV_M48T59 is not set
  1385. # CONFIG_RTC_DRV_V3020 is not set
  1386. @@ -883,13 +953,13 @@
  1387. #
  1388. # File systems
  1389. #
  1390. -CONFIG_EXT2_FS=m
  1391. +CONFIG_EXT2_FS=y
  1392. # CONFIG_EXT2_FS_XATTR is not set
  1393. # CONFIG_EXT2_FS_XIP is not set
  1394. -CONFIG_EXT3_FS=m
  1395. +CONFIG_EXT3_FS=y
  1396. # CONFIG_EXT3_FS_XATTR is not set
  1397. # CONFIG_EXT4DEV_FS is not set
  1398. -CONFIG_JBD=m
  1399. +CONFIG_JBD=y
  1400. # CONFIG_JBD_DEBUG is not set
  1401. # CONFIG_REISERFS_FS is not set
  1402. # CONFIG_JFS_FS is not set
  1403. @@ -897,12 +967,10 @@
  1404. # CONFIG_XFS_FS is not set
  1405. # CONFIG_GFS2_FS is not set
  1406. # CONFIG_OCFS2_FS is not set
  1407. -CONFIG_MINIX_FS=m
  1408. -# CONFIG_ROMFS_FS is not set
  1409. +# CONFIG_DNOTIFY is not set
  1410. CONFIG_INOTIFY=y
  1411. CONFIG_INOTIFY_USER=y
  1412. # CONFIG_QUOTA is not set
  1413. -# CONFIG_DNOTIFY is not set
  1414. # CONFIG_AUTOFS_FS is not set
  1415. # CONFIG_AUTOFS4_FS is not set
  1416. CONFIG_FUSE_FS=m
  1417. @@ -933,7 +1001,7 @@
  1418. CONFIG_TMPFS=y
  1419. # CONFIG_TMPFS_POSIX_ACL is not set
  1420. # CONFIG_HUGETLB_PAGE is not set
  1421. -# CONFIG_CONFIGFS_FS is not set
  1422. +CONFIG_CONFIGFS_FS=y
  1423. #
  1424. # Miscellaneous filesystems
  1425. @@ -957,8 +1025,10 @@
  1426. # CONFIG_JFFS2_RUBIN is not set
  1427. # CONFIG_CRAMFS is not set
  1428. # CONFIG_VXFS_FS is not set
  1429. +CONFIG_MINIX_FS=m
  1430. # CONFIG_HPFS_FS is not set
  1431. # CONFIG_QNX4FS_FS is not set
  1432. +# CONFIG_ROMFS_FS is not set
  1433. # CONFIG_SYSV_FS is not set
  1434. # CONFIG_UFS_FS is not set
  1435. CONFIG_NETWORK_FILESYSTEMS=y
  1436. @@ -1028,11 +1098,6 @@
  1437. # CONFIG_NLS_KOI8_U is not set
  1438. CONFIG_NLS_UTF8=m
  1439. # CONFIG_DLM is not set
  1440. -CONFIG_INSTRUMENTATION=y
  1441. -CONFIG_PROFILING=y
  1442. -CONFIG_OPROFILE=m
  1443. -CONFIG_KPROBES=y
  1444. -# CONFIG_MARKERS is not set
  1445. #
  1446. # Kernel hacking
  1447. @@ -1051,6 +1116,7 @@
  1448. # CONFIG_SCHEDSTATS is not set
  1449. # CONFIG_TIMER_STATS is not set
  1450. # CONFIG_SLUB_DEBUG_ON is not set
  1451. +# CONFIG_SLUB_STATS is not set
  1452. # CONFIG_DEBUG_RT_MUTEXES is not set
  1453. # CONFIG_RT_MUTEX_TESTER is not set
  1454. # CONFIG_DEBUG_SPINLOCK is not set
  1455. @@ -1067,9 +1133,10 @@
  1456. # CONFIG_DEBUG_LIST is not set
  1457. # CONFIG_DEBUG_SG is not set
  1458. CONFIG_FRAME_POINTER=y
  1459. -CONFIG_FORCED_INLINING=y
  1460. # CONFIG_BOOT_PRINTK_DELAY is not set
  1461. # CONFIG_RCU_TORTURE_TEST is not set
  1462. +# CONFIG_KPROBES_SANITY_TEST is not set
  1463. +# CONFIG_BACKTRACE_SELF_TEST is not set
  1464. # CONFIG_LKDTM is not set
  1465. # CONFIG_FAULT_INJECTION is not set
  1466. # CONFIG_SAMPLES is not set
  1467. @@ -1082,7 +1149,9 @@
  1468. # CONFIG_SECURITY_FILE_CAPABILITIES is not set
  1469. CONFIG_CRYPTO=y
  1470. CONFIG_CRYPTO_ALGAPI=m
  1471. +CONFIG_CRYPTO_AEAD=m
  1472. CONFIG_CRYPTO_BLKCIPHER=m
  1473. +# CONFIG_CRYPTO_SEQIV is not set
  1474. CONFIG_CRYPTO_HASH=m
  1475. CONFIG_CRYPTO_MANAGER=m
  1476. CONFIG_CRYPTO_HMAC=m
  1477. @@ -1101,6 +1170,9 @@
  1478. # CONFIG_CRYPTO_PCBC is not set
  1479. # CONFIG_CRYPTO_LRW is not set
  1480. # CONFIG_CRYPTO_XTS is not set
  1481. +# CONFIG_CRYPTO_CTR is not set
  1482. +# CONFIG_CRYPTO_GCM is not set
  1483. +# CONFIG_CRYPTO_CCM is not set
  1484. # CONFIG_CRYPTO_CRYPTD is not set
  1485. CONFIG_CRYPTO_DES=m
  1486. # CONFIG_CRYPTO_FCRYPT is not set
  1487. @@ -1115,12 +1187,14 @@
  1488. # CONFIG_CRYPTO_KHAZAD is not set
  1489. # CONFIG_CRYPTO_ANUBIS is not set
  1490. # CONFIG_CRYPTO_SEED is not set
  1491. +# CONFIG_CRYPTO_SALSA20 is not set
  1492. CONFIG_CRYPTO_DEFLATE=m
  1493. # CONFIG_CRYPTO_MICHAEL_MIC is not set
  1494. # CONFIG_CRYPTO_CRC32C is not set
  1495. # CONFIG_CRYPTO_CAMELLIA is not set
  1496. # CONFIG_CRYPTO_TEST is not set
  1497. -# CONFIG_CRYPTO_AUTHENC is not set
  1498. +CONFIG_CRYPTO_AUTHENC=m
  1499. +# CONFIG_CRYPTO_LZO is not set
  1500. # CONFIG_CRYPTO_HW is not set
  1501. #
  1502. @@ -1135,6 +1209,7 @@
  1503. # CONFIG_LIBCRC32C is not set
  1504. CONFIG_ZLIB_INFLATE=y
  1505. CONFIG_ZLIB_DEFLATE=y
  1506. +CONFIG_GENERIC_ALLOCATOR=y
  1507. CONFIG_PLIST=y
  1508. CONFIG_HAS_IOMEM=y
  1509. CONFIG_HAS_IOPORT=y
  1510. --- a/arch/avr32/configs/atstk1003_defconfig
  1511. +++ b/arch/avr32/configs/atstk1003_defconfig
  1512. @@ -1,7 +1,7 @@
  1513. #
  1514. # Automatically generated make config: don't edit
  1515. -# Linux kernel version: 2.6.24-rc7
  1516. -# Wed Jan 9 22:54:34 2008
  1517. +# Linux kernel version: 2.6.25.4
  1518. +# Wed Jun 11 15:33:36 2008
  1519. #
  1520. CONFIG_AVR32=y
  1521. CONFIG_GENERIC_GPIO=y
  1522. @@ -13,10 +13,10 @@
  1523. CONFIG_GENERIC_IRQ_PROBE=y
  1524. CONFIG_RWSEM_GENERIC_SPINLOCK=y
  1525. CONFIG_GENERIC_TIME=y
  1526. +CONFIG_GENERIC_CLOCKEVENTS=y
  1527. # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
  1528. # CONFIG_ARCH_HAS_ILOG2_U32 is not set
  1529. # CONFIG_ARCH_HAS_ILOG2_U64 is not set
  1530. -CONFIG_ARCH_SUPPORTS_OPROFILE=y
  1531. CONFIG_GENERIC_HWEIGHT=y
  1532. CONFIG_GENERIC_CALIBRATE_DELAY=y
  1533. CONFIG_GENERIC_BUG=y
  1534. @@ -39,17 +39,15 @@
  1535. CONFIG_TASKSTATS=y
  1536. CONFIG_TASK_DELAY_ACCT=y
  1537. # CONFIG_TASK_XACCT is not set
  1538. -# CONFIG_USER_NS is not set
  1539. -# CONFIG_PID_NS is not set
  1540. CONFIG_AUDIT=y
  1541. # CONFIG_IKCONFIG is not set
  1542. CONFIG_LOG_BUF_SHIFT=14
  1543. # CONFIG_CGROUPS is not set
  1544. -CONFIG_FAIR_GROUP_SCHED=y
  1545. -CONFIG_FAIR_USER_SCHED=y
  1546. -# CONFIG_FAIR_CGROUP_SCHED is not set
  1547. +# CONFIG_GROUP_SCHED is not set
  1548. CONFIG_SYSFS_DEPRECATED=y
  1549. +CONFIG_SYSFS_DEPRECATED_V2=y
  1550. CONFIG_RELAY=y
  1551. +# CONFIG_NAMESPACES is not set
  1552. CONFIG_BLK_DEV_INITRD=y
  1553. CONFIG_INITRAMFS_SOURCE=""
  1554. CONFIG_CC_OPTIMIZE_FOR_SIZE=y
  1555. @@ -63,11 +61,13 @@
  1556. CONFIG_PRINTK=y
  1557. CONFIG_BUG=y
  1558. CONFIG_ELF_CORE=y
  1559. +# CONFIG_COMPAT_BRK is not set
  1560. # CONFIG_BASE_FULL is not set
  1561. CONFIG_FUTEX=y
  1562. CONFIG_ANON_INODES=y
  1563. CONFIG_EPOLL=y
  1564. CONFIG_SIGNALFD=y
  1565. +CONFIG_TIMERFD=y
  1566. CONFIG_EVENTFD=y
  1567. CONFIG_SHMEM=y
  1568. CONFIG_VM_EVENT_COUNTERS=y
  1569. @@ -75,6 +75,14 @@
  1570. # CONFIG_SLAB is not set
  1571. CONFIG_SLUB=y
  1572. # CONFIG_SLOB is not set
  1573. +CONFIG_PROFILING=y
  1574. +# CONFIG_MARKERS is not set
  1575. +CONFIG_OPROFILE=m
  1576. +CONFIG_HAVE_OPROFILE=y
  1577. +CONFIG_KPROBES=y
  1578. +CONFIG_HAVE_KPROBES=y
  1579. +# CONFIG_HAVE_KRETPROBES is not set
  1580. +CONFIG_PROC_PAGE_MONITOR=y
  1581. CONFIG_SLABINFO=y
  1582. CONFIG_RT_MUTEXES=y
  1583. # CONFIG_TINY_SHMEM is not set
  1584. @@ -103,10 +111,15 @@
  1585. CONFIG_DEFAULT_CFQ=y
  1586. # CONFIG_DEFAULT_NOOP is not set
  1587. CONFIG_DEFAULT_IOSCHED="cfq"
  1588. +CONFIG_CLASSIC_RCU=y
  1589. #
  1590. # System Type and features
  1591. #
  1592. +CONFIG_TICK_ONESHOT=y
  1593. +CONFIG_NO_HZ=y
  1594. +CONFIG_HIGH_RES_TIMERS=y
  1595. +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
  1596. CONFIG_SUBARCH_AVR32B=y
  1597. CONFIG_MMU=y
  1598. CONFIG_PERFORMANCE_COUNTERS=y
  1599. @@ -118,12 +131,16 @@
  1600. # CONFIG_BOARD_ATSTK1002 is not set
  1601. CONFIG_BOARD_ATSTK1003=y
  1602. # CONFIG_BOARD_ATSTK1004 is not set
  1603. +# CONFIG_BOARD_ATSTK1006 is not set
  1604. # CONFIG_BOARD_ATSTK100X_CUSTOM is not set
  1605. # CONFIG_BOARD_ATSTK100X_SPI1 is not set
  1606. # CONFIG_BOARD_ATSTK1000_J2_LED is not set
  1607. # CONFIG_BOARD_ATSTK1000_J2_LED8 is not set
  1608. # CONFIG_BOARD_ATSTK1000_J2_RGB is not set
  1609. CONFIG_BOARD_ATSTK1000_EXTDAC=y
  1610. +# CONFIG_BOARD_ATSTK100X_ENABLE_AC97 is not set
  1611. +# CONFIG_BOARD_ATSTK1000_CF_HACKS is not set
  1612. +# CONFIG_BOARD_ATSTK100X_ENABLE_PSIF is not set
  1613. CONFIG_LOADER_U_BOOT=y
  1614. #
  1615. @@ -132,6 +149,7 @@
  1616. # CONFIG_AP700X_32_BIT_SMC is not set
  1617. CONFIG_AP700X_16_BIT_SMC=y
  1618. # CONFIG_AP700X_8_BIT_SMC is not set
  1619. +CONFIG_GPIO_DEV=y
  1620. CONFIG_LOAD_ADDRESS=0x10000000
  1621. CONFIG_ENTRY_ADDRESS=0x90000000
  1622. CONFIG_PHYS_OFFSET=0x10000000
  1623. @@ -157,16 +175,26 @@
  1624. CONFIG_ZONE_DMA_FLAG=0
  1625. CONFIG_VIRT_TO_BUS=y
  1626. # CONFIG_OWNERSHIP_TRACE is not set
  1627. +CONFIG_NMI_DEBUGGING=y
  1628. +CONFIG_DW_DMAC=y
  1629. # CONFIG_HZ_100 is not set
  1630. CONFIG_HZ_250=y
  1631. # CONFIG_HZ_300 is not set
  1632. # CONFIG_HZ_1000 is not set
  1633. CONFIG_HZ=250
  1634. +# CONFIG_SCHED_HRTICK is not set
  1635. CONFIG_CMDLINE=""
  1636. #
  1637. # Power management options
  1638. #
  1639. +CONFIG_ARCH_SUSPEND_POSSIBLE=y
  1640. +CONFIG_PM=y
  1641. +# CONFIG_PM_LEGACY is not set
  1642. +# CONFIG_PM_DEBUG is not set
  1643. +CONFIG_PM_SLEEP=y
  1644. +CONFIG_SUSPEND=y
  1645. +CONFIG_SUSPEND_FREEZER=y
  1646. #
  1647. # CPU Frequency scaling
  1648. @@ -175,9 +203,9 @@
  1649. CONFIG_CPU_FREQ_TABLE=y
  1650. # CONFIG_CPU_FREQ_DEBUG is not set
  1651. # CONFIG_CPU_FREQ_STAT is not set
  1652. -CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
  1653. +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
  1654. # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
  1655. -# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
  1656. +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
  1657. # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
  1658. CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
  1659. # CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
  1660. @@ -260,6 +288,7 @@
  1661. # CONFIG_NET_PKTGEN is not set
  1662. # CONFIG_NET_TCPPROBE is not set
  1663. # CONFIG_HAMRADIO is not set
  1664. +# CONFIG_CAN is not set
  1665. # CONFIG_IRDA is not set
  1666. # CONFIG_BT is not set
  1667. # CONFIG_AF_RXRPC is not set
  1668. @@ -376,13 +405,18 @@
  1669. CONFIG_BLK_DEV_RAM=m
  1670. CONFIG_BLK_DEV_RAM_COUNT=16
  1671. CONFIG_BLK_DEV_RAM_SIZE=4096
  1672. -CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
  1673. +# CONFIG_BLK_DEV_XIP is not set
  1674. # CONFIG_CDROM_PKTCDVD is not set
  1675. # CONFIG_ATA_OVER_ETH is not set
  1676. CONFIG_MISC_DEVICES=y
  1677. +CONFIG_ATMEL_PWM=m
  1678. +CONFIG_ATMEL_TCLIB=y
  1679. +CONFIG_ATMEL_TCB_CLKSRC=y
  1680. +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
  1681. # CONFIG_EEPROM_93CX6 is not set
  1682. CONFIG_ATMEL_SSC=m
  1683. -# CONFIG_IDE is not set
  1684. +# CONFIG_ENCLOSURE_SERVICES is not set
  1685. +# CONFIG_HAVE_IDE is not set
  1686. #
  1687. # SCSI device support
  1688. @@ -427,6 +461,7 @@
  1689. # CONFIG_SCSI_DEBUG is not set
  1690. CONFIG_ATA=m
  1691. # CONFIG_ATA_NONSTANDARD is not set
  1692. +# CONFIG_SATA_MV is not set
  1693. CONFIG_PATA_AT32=m
  1694. # CONFIG_PATA_PLATFORM is not set
  1695. # CONFIG_MD is not set
  1696. @@ -460,7 +495,6 @@
  1697. # CONFIG_PPPOL2TP is not set
  1698. # CONFIG_SLIP is not set
  1699. CONFIG_SLHC=m
  1700. -# CONFIG_SHAPER is not set
  1701. # CONFIG_NETCONSOLE is not set
  1702. # CONFIG_NETPOLL is not set
  1703. # CONFIG_NET_POLL_CONTROLLER is not set
  1704. @@ -528,6 +562,7 @@
  1705. #
  1706. CONFIG_SERIAL_ATMEL=y
  1707. CONFIG_SERIAL_ATMEL_CONSOLE=y
  1708. +CONFIG_SERIAL_ATMEL_PDC=y
  1709. # CONFIG_SERIAL_ATMEL_TTYAT is not set
  1710. CONFIG_SERIAL_CORE=y
  1711. CONFIG_SERIAL_CORE_CONSOLE=y
  1712. @@ -535,8 +570,6 @@
  1713. # CONFIG_LEGACY_PTYS is not set
  1714. # CONFIG_IPMI_HANDLER is not set
  1715. # CONFIG_HW_RANDOM is not set
  1716. -# CONFIG_RTC is not set
  1717. -# CONFIG_GEN_RTC is not set
  1718. # CONFIG_R3964 is not set
  1719. # CONFIG_RAW_DRIVER is not set
  1720. # CONFIG_TCG_TPM is not set
  1721. @@ -554,6 +587,7 @@
  1722. #
  1723. # I2C Hardware Bus support
  1724. #
  1725. +CONFIG_I2C_ATMELTWI=m
  1726. CONFIG_I2C_GPIO=m
  1727. # CONFIG_I2C_OCORES is not set
  1728. # CONFIG_I2C_PARPORT_LIGHT is not set
  1729. @@ -564,13 +598,12 @@
  1730. #
  1731. # Miscellaneous I2C Chip support
  1732. #
  1733. -# CONFIG_SENSORS_DS1337 is not set
  1734. -# CONFIG_SENSORS_DS1374 is not set
  1735. # CONFIG_DS1682 is not set
  1736. # CONFIG_SENSORS_EEPROM is not set
  1737. # CONFIG_SENSORS_PCF8574 is not set
  1738. -# CONFIG_SENSORS_PCA9539 is not set
  1739. +# CONFIG_PCF8575 is not set
  1740. # CONFIG_SENSORS_PCF8591 is not set
  1741. +# CONFIG_TPS65010 is not set
  1742. # CONFIG_SENSORS_MAX6875 is not set
  1743. # CONFIG_SENSORS_TSL2550 is not set
  1744. # CONFIG_I2C_DEBUG_CORE is not set
  1745. @@ -597,9 +630,27 @@
  1746. # CONFIG_SPI_AT25 is not set
  1747. CONFIG_SPI_SPIDEV=m
  1748. # CONFIG_SPI_TLE62X0 is not set
  1749. +CONFIG_HAVE_GPIO_LIB=y
  1750. +
  1751. +#
  1752. +# GPIO Support
  1753. +#
  1754. +# CONFIG_DEBUG_GPIO is not set
  1755. +
  1756. +#
  1757. +# I2C GPIO expanders:
  1758. +#
  1759. +# CONFIG_GPIO_PCA953X is not set
  1760. +# CONFIG_GPIO_PCF857X is not set
  1761. +
  1762. +#
  1763. +# SPI GPIO expanders:
  1764. +#
  1765. +# CONFIG_GPIO_MCP23S08 is not set
  1766. # CONFIG_W1 is not set
  1767. # CONFIG_POWER_SUPPLY is not set
  1768. # CONFIG_HWMON is not set
  1769. +# CONFIG_THERMAL is not set
  1770. CONFIG_WATCHDOG=y
  1771. # CONFIG_WATCHDOG_NOWAYOUT is not set
  1772. @@ -665,12 +716,18 @@
  1773. #
  1774. # Generic devices
  1775. #
  1776. +CONFIG_SND_AC97_CODEC=m
  1777. # CONFIG_SND_DUMMY is not set
  1778. # CONFIG_SND_MTPAV is not set
  1779. # CONFIG_SND_SERIAL_U16550 is not set
  1780. # CONFIG_SND_MPU401 is not set
  1781. #
  1782. +# AVR32 devices
  1783. +#
  1784. +CONFIG_SND_ATMEL_AC97=m
  1785. +
  1786. +#
  1787. # SPI devices
  1788. #
  1789. CONFIG_SND_AT73C213=m
  1790. @@ -686,9 +743,14 @@
  1791. #
  1792. #
  1793. +# ALSA SoC audio for Freescale SOCs
  1794. +#
  1795. +
  1796. +#
  1797. # Open Sound System
  1798. #
  1799. # CONFIG_SOUND_PRIME is not set
  1800. +CONFIG_AC97_BUS=m
  1801. # CONFIG_HID_SUPPORT is not set
  1802. CONFIG_USB_SUPPORT=y
  1803. # CONFIG_USB_ARCH_HAS_HCD is not set
  1804. @@ -698,10 +760,6 @@
  1805. #
  1806. # NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
  1807. #
  1808. -
  1809. -#
  1810. -# USB Gadget Support
  1811. -#
  1812. CONFIG_USB_GADGET=y
  1813. # CONFIG_USB_GADGET_DEBUG is not set
  1814. # CONFIG_USB_GADGET_DEBUG_FILES is not set
  1815. @@ -729,27 +787,31 @@
  1816. # CONFIG_USB_FILE_STORAGE_TEST is not set
  1817. CONFIG_USB_G_SERIAL=m
  1818. # CONFIG_USB_MIDI_GADGET is not set
  1819. -CONFIG_MMC=m
  1820. +# CONFIG_USB_G_PRINTER is not set
  1821. +CONFIG_MMC=y
  1822. # CONFIG_MMC_DEBUG is not set
  1823. # CONFIG_MMC_UNSAFE_RESUME is not set
  1824. #
  1825. # MMC/SD Card Drivers
  1826. #
  1827. -CONFIG_MMC_BLOCK=m
  1828. +CONFIG_MMC_BLOCK=y
  1829. # CONFIG_MMC_BLOCK_BOUNCE is not set
  1830. # CONFIG_SDIO_UART is not set
  1831. #
  1832. # MMC/SD Host Controller Drivers
  1833. #
  1834. +CONFIG_MMC_ATMELMCI=y
  1835. CONFIG_MMC_SPI=m
  1836. +# CONFIG_MEMSTICK is not set
  1837. CONFIG_NEW_LEDS=y
  1838. CONFIG_LEDS_CLASS=y
  1839. #
  1840. # LED drivers
  1841. #
  1842. +CONFIG_LEDS_ATMEL_PWM=m
  1843. CONFIG_LEDS_GPIO=y
  1844. #
  1845. @@ -786,19 +848,22 @@
  1846. # CONFIG_RTC_DRV_PCF8563 is not set
  1847. # CONFIG_RTC_DRV_PCF8583 is not set
  1848. # CONFIG_RTC_DRV_M41T80 is not set
  1849. +# CONFIG_RTC_DRV_S35390A is not set
  1850. #
  1851. # SPI RTC drivers
  1852. #
  1853. -# CONFIG_RTC_DRV_RS5C348 is not set
  1854. # CONFIG_RTC_DRV_MAX6902 is not set
  1855. +# CONFIG_RTC_DRV_R9701 is not set
  1856. +# CONFIG_RTC_DRV_RS5C348 is not set
  1857. #
  1858. # Platform RTC drivers
  1859. #
  1860. +# CONFIG_RTC_DRV_DS1511 is not set
  1861. # CONFIG_RTC_DRV_DS1553 is not set
  1862. -# CONFIG_RTC_DRV_STK17TA8 is not set
  1863. # CONFIG_RTC_DRV_DS1742 is not set
  1864. +# CONFIG_RTC_DRV_STK17TA8 is not set
  1865. # CONFIG_RTC_DRV_M48T86 is not set
  1866. # CONFIG_RTC_DRV_M48T59 is not set
  1867. # CONFIG_RTC_DRV_V3020 is not set
  1868. @@ -816,13 +881,13 @@
  1869. #
  1870. # File systems
  1871. #
  1872. -CONFIG_EXT2_FS=m
  1873. +CONFIG_EXT2_FS=y
  1874. # CONFIG_EXT2_FS_XATTR is not set
  1875. # CONFIG_EXT2_FS_XIP is not set
  1876. -CONFIG_EXT3_FS=m
  1877. +CONFIG_EXT3_FS=y
  1878. # CONFIG_EXT3_FS_XATTR is not set
  1879. # CONFIG_EXT4DEV_FS is not set
  1880. -CONFIG_JBD=m
  1881. +CONFIG_JBD=y
  1882. # CONFIG_JBD_DEBUG is not set
  1883. # CONFIG_REISERFS_FS is not set
  1884. # CONFIG_JFS_FS is not set
  1885. @@ -830,12 +895,10 @@
  1886. # CONFIG_XFS_FS is not set
  1887. # CONFIG_GFS2_FS is not set
  1888. # CONFIG_OCFS2_FS is not set
  1889. -# CONFIG_MINIX_FS is not set
  1890. -# CONFIG_ROMFS_FS is not set
  1891. +# CONFIG_DNOTIFY is not set
  1892. CONFIG_INOTIFY=y
  1893. CONFIG_INOTIFY_USER=y
  1894. # CONFIG_QUOTA is not set
  1895. -# CONFIG_DNOTIFY is not set
  1896. # CONFIG_AUTOFS_FS is not set
  1897. # CONFIG_AUTOFS4_FS is not set
  1898. CONFIG_FUSE_FS=m
  1899. @@ -866,7 +929,7 @@
  1900. CONFIG_TMPFS=y
  1901. # CONFIG_TMPFS_POSIX_ACL is not set
  1902. # CONFIG_HUGETLB_PAGE is not set
  1903. -CONFIG_CONFIGFS_FS=m
  1904. +CONFIG_CONFIGFS_FS=y
  1905. #
  1906. # Miscellaneous filesystems
  1907. @@ -891,8 +954,10 @@
  1908. # CONFIG_JFFS2_RUBIN is not set
  1909. # CONFIG_CRAMFS is not set
  1910. # CONFIG_VXFS_FS is not set
  1911. +# CONFIG_MINIX_FS is not set
  1912. # CONFIG_HPFS_FS is not set
  1913. # CONFIG_QNX4FS_FS is not set
  1914. +# CONFIG_ROMFS_FS is not set
  1915. # CONFIG_SYSV_FS is not set
  1916. # CONFIG_UFS_FS is not set
  1917. # CONFIG_NETWORK_FILESYSTEMS is not set
  1918. @@ -943,11 +1008,6 @@
  1919. # CONFIG_NLS_KOI8_U is not set
  1920. CONFIG_NLS_UTF8=m
  1921. # CONFIG_DLM is not set
  1922. -CONFIG_INSTRUMENTATION=y
  1923. -CONFIG_PROFILING=y
  1924. -CONFIG_OPROFILE=m
  1925. -CONFIG_KPROBES=y
  1926. -# CONFIG_MARKERS is not set
  1927. #
  1928. # Kernel hacking
  1929. @@ -965,6 +1025,7 @@
  1930. CONFIG_SCHED_DEBUG=y
  1931. # CONFIG_SCHEDSTATS is not set
  1932. # CONFIG_TIMER_STATS is not set
  1933. +# CONFIG_SLUB_STATS is not set
  1934. # CONFIG_DEBUG_RT_MUTEXES is not set
  1935. # CONFIG_RT_MUTEX_TESTER is not set
  1936. # CONFIG_DEBUG_SPINLOCK is not set
  1937. @@ -981,9 +1042,10 @@
  1938. # CONFIG_DEBUG_LIST is not set
  1939. # CONFIG_DEBUG_SG is not set
  1940. CONFIG_FRAME_POINTER=y
  1941. -CONFIG_FORCED_INLINING=y
  1942. # CONFIG_BOOT_PRINTK_DELAY is not set
  1943. # CONFIG_RCU_TORTURE_TEST is not set
  1944. +# CONFIG_KPROBES_SANITY_TEST is not set
  1945. +# CONFIG_BACKTRACE_SELF_TEST is not set
  1946. # CONFIG_LKDTM is not set
  1947. # CONFIG_FAULT_INJECTION is not set
  1948. # CONFIG_SAMPLES is not set
  1949. @@ -1009,6 +1071,7 @@
  1950. CONFIG_AUDIT_GENERIC=y
  1951. CONFIG_ZLIB_INFLATE=y
  1952. CONFIG_ZLIB_DEFLATE=y
  1953. +CONFIG_GENERIC_ALLOCATOR=y
  1954. CONFIG_PLIST=y
  1955. CONFIG_HAS_IOMEM=y
  1956. CONFIG_HAS_IOPORT=y
  1957. --- a/arch/avr32/configs/atstk1004_defconfig
  1958. +++ b/arch/avr32/configs/atstk1004_defconfig
  1959. @@ -1,7 +1,7 @@
  1960. #
  1961. # Automatically generated make config: don't edit
  1962. -# Linux kernel version: 2.6.24-rc7
  1963. -# Wed Jan 9 23:04:20 2008
  1964. +# Linux kernel version: 2.6.25.4
  1965. +# Wed Jun 11 15:37:49 2008
  1966. #
  1967. CONFIG_AVR32=y
  1968. CONFIG_GENERIC_GPIO=y
  1969. @@ -13,10 +13,10 @@
  1970. CONFIG_GENERIC_IRQ_PROBE=y
  1971. CONFIG_RWSEM_GENERIC_SPINLOCK=y
  1972. CONFIG_GENERIC_TIME=y
  1973. +CONFIG_GENERIC_CLOCKEVENTS=y
  1974. # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
  1975. # CONFIG_ARCH_HAS_ILOG2_U32 is not set
  1976. # CONFIG_ARCH_HAS_ILOG2_U64 is not set
  1977. -CONFIG_ARCH_SUPPORTS_OPROFILE=y
  1978. CONFIG_GENERIC_HWEIGHT=y
  1979. CONFIG_GENERIC_CALIBRATE_DELAY=y
  1980. CONFIG_GENERIC_BUG=y
  1981. @@ -34,15 +34,15 @@
  1982. # CONFIG_POSIX_MQUEUE is not set
  1983. # CONFIG_BSD_PROCESS_ACCT is not set
  1984. # CONFIG_TASKSTATS is not set
  1985. -# CONFIG_USER_NS is not set
  1986. -# CONFIG_PID_NS is not set
  1987. # CONFIG_AUDIT is not set
  1988. # CONFIG_IKCONFIG is not set
  1989. CONFIG_LOG_BUF_SHIFT=14
  1990. # CONFIG_CGROUPS is not set
  1991. -# CONFIG_FAIR_GROUP_SCHED is not set
  1992. +# CONFIG_GROUP_SCHED is not set
  1993. CONFIG_SYSFS_DEPRECATED=y
  1994. +CONFIG_SYSFS_DEPRECATED_V2=y
  1995. # CONFIG_RELAY is not set
  1996. +# CONFIG_NAMESPACES is not set
  1997. # CONFIG_BLK_DEV_INITRD is not set
  1998. CONFIG_CC_OPTIMIZE_FOR_SIZE=y
  1999. CONFIG_SYSCTL=y
  2000. @@ -54,24 +54,37 @@
  2001. CONFIG_PRINTK=y
  2002. CONFIG_BUG=y
  2003. CONFIG_ELF_CORE=y
  2004. +# CONFIG_COMPAT_BRK is not set
  2005. # CONFIG_BASE_FULL is not set
  2006. # CONFIG_FUTEX is not set
  2007. # CONFIG_EPOLL is not set
  2008. # CONFIG_SIGNALFD is not set
  2009. +# CONFIG_TIMERFD is not set
  2010. # CONFIG_EVENTFD is not set
  2011. CONFIG_SHMEM=y
  2012. CONFIG_VM_EVENT_COUNTERS=y
  2013. # CONFIG_SLAB is not set
  2014. # CONFIG_SLUB is not set
  2015. CONFIG_SLOB=y
  2016. +# CONFIG_PROFILING is not set
  2017. +# CONFIG_MARKERS is not set
  2018. +CONFIG_HAVE_OPROFILE=y
  2019. +CONFIG_HAVE_KPROBES=y
  2020. +# CONFIG_HAVE_KRETPROBES is not set
  2021. +# CONFIG_PROC_PAGE_MONITOR is not set
  2022. # CONFIG_TINY_SHMEM is not set
  2023. CONFIG_BASE_SMALL=1
  2024. # CONFIG_MODULES is not set
  2025. # CONFIG_BLOCK is not set
  2026. +CONFIG_CLASSIC_RCU=y
  2027. #
  2028. # System Type and features
  2029. #
  2030. +# CONFIG_TICK_ONESHOT is not set
  2031. +# CONFIG_NO_HZ is not set
  2032. +# CONFIG_HIGH_RES_TIMERS is not set
  2033. +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
  2034. CONFIG_SUBARCH_AVR32B=y
  2035. CONFIG_MMU=y
  2036. CONFIG_PERFORMANCE_COUNTERS=y
  2037. @@ -83,10 +96,14 @@
  2038. # CONFIG_BOARD_ATSTK1002 is not set
  2039. # CONFIG_BOARD_ATSTK1003 is not set
  2040. CONFIG_BOARD_ATSTK1004=y
  2041. +# CONFIG_BOARD_ATSTK1006 is not set
  2042. # CONFIG_BOARD_ATSTK100X_CUSTOM is not set
  2043. # CONFIG_BOARD_ATSTK100X_SPI1 is not set
  2044. # CONFIG_BOARD_ATSTK1000_J2_LED is not set
  2045. CONFIG_BOARD_ATSTK1000_EXTDAC=y
  2046. +# CONFIG_BOARD_ATSTK100X_ENABLE_AC97 is not set
  2047. +# CONFIG_BOARD_ATSTK1000_CF_HACKS is not set
  2048. +# CONFIG_BOARD_ATSTK100X_ENABLE_PSIF is not set
  2049. CONFIG_LOADER_U_BOOT=y
  2050. #
  2051. @@ -95,6 +112,7 @@
  2052. # CONFIG_AP700X_32_BIT_SMC is not set
  2053. CONFIG_AP700X_16_BIT_SMC=y
  2054. # CONFIG_AP700X_8_BIT_SMC is not set
  2055. +# CONFIG_GPIO_DEV is not set
  2056. CONFIG_LOAD_ADDRESS=0x10000000
  2057. CONFIG_ENTRY_ADDRESS=0x90000000
  2058. CONFIG_PHYS_OFFSET=0x10000000
  2059. @@ -120,34 +138,26 @@
  2060. CONFIG_ZONE_DMA_FLAG=0
  2061. CONFIG_VIRT_TO_BUS=y
  2062. # CONFIG_OWNERSHIP_TRACE is not set
  2063. +# CONFIG_NMI_DEBUGGING is not set
  2064. +CONFIG_DW_DMAC=y
  2065. # CONFIG_HZ_100 is not set
  2066. CONFIG_HZ_250=y
  2067. # CONFIG_HZ_300 is not set
  2068. # CONFIG_HZ_1000 is not set
  2069. CONFIG_HZ=250
  2070. +# CONFIG_SCHED_HRTICK is not set
  2071. CONFIG_CMDLINE=""
  2072. #
  2073. # Power management options
  2074. #
  2075. +CONFIG_ARCH_SUSPEND_POSSIBLE=y
  2076. +# CONFIG_PM is not set
  2077. #
  2078. # CPU Frequency scaling
  2079. #
  2080. -CONFIG_CPU_FREQ=y
  2081. -CONFIG_CPU_FREQ_TABLE=y
  2082. -# CONFIG_CPU_FREQ_DEBUG is not set
  2083. -# CONFIG_CPU_FREQ_STAT is not set
  2084. -CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
  2085. -# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
  2086. -# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
  2087. -# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
  2088. -CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
  2089. -# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
  2090. -CONFIG_CPU_FREQ_GOV_USERSPACE=y
  2091. -CONFIG_CPU_FREQ_GOV_ONDEMAND=y
  2092. -# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
  2093. -CONFIG_CPU_FREQ_AT32AP=y
  2094. +# CONFIG_CPU_FREQ is not set
  2095. #
  2096. # Bus options
  2097. @@ -222,6 +232,7 @@
  2098. #
  2099. # CONFIG_NET_PKTGEN is not set
  2100. # CONFIG_HAMRADIO is not set
  2101. +# CONFIG_CAN is not set
  2102. # CONFIG_IRDA is not set
  2103. # CONFIG_BT is not set
  2104. # CONFIG_AF_RXRPC is not set
  2105. @@ -321,6 +332,7 @@
  2106. # CONFIG_MTD_UBI is not set
  2107. # CONFIG_PARPORT is not set
  2108. # CONFIG_MISC_DEVICES is not set
  2109. +# CONFIG_HAVE_IDE is not set
  2110. #
  2111. # SCSI device support
  2112. @@ -358,6 +370,7 @@
  2113. #
  2114. CONFIG_SERIAL_ATMEL=y
  2115. CONFIG_SERIAL_ATMEL_CONSOLE=y
  2116. +# CONFIG_SERIAL_ATMEL_PDC is not set
  2117. # CONFIG_SERIAL_ATMEL_TTYAT is not set
  2118. CONFIG_SERIAL_CORE=y
  2119. CONFIG_SERIAL_CORE_CONSOLE=y
  2120. @@ -365,8 +378,6 @@
  2121. # CONFIG_LEGACY_PTYS is not set
  2122. # CONFIG_IPMI_HANDLER is not set
  2123. # CONFIG_HW_RANDOM is not set
  2124. -# CONFIG_RTC is not set
  2125. -# CONFIG_GEN_RTC is not set
  2126. # CONFIG_R3964 is not set
  2127. # CONFIG_TCG_TPM is not set
  2128. # CONFIG_I2C is not set
  2129. @@ -389,9 +400,24 @@
  2130. # CONFIG_SPI_AT25 is not set
  2131. # CONFIG_SPI_SPIDEV is not set
  2132. # CONFIG_SPI_TLE62X0 is not set
  2133. +CONFIG_HAVE_GPIO_LIB=y
  2134. +
  2135. +#
  2136. +# GPIO Support
  2137. +#
  2138. +
  2139. +#
  2140. +# I2C GPIO expanders:
  2141. +#
  2142. +
  2143. +#
  2144. +# SPI GPIO expanders:
  2145. +#
  2146. +# CONFIG_GPIO_MCP23S08 is not set
  2147. # CONFIG_W1 is not set
  2148. # CONFIG_POWER_SUPPLY is not set
  2149. # CONFIG_HWMON is not set
  2150. +# CONFIG_THERMAL is not set
  2151. CONFIG_WATCHDOG=y
  2152. # CONFIG_WATCHDOG_NOWAYOUT is not set
  2153. @@ -471,10 +497,6 @@
  2154. #
  2155. # NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
  2156. #
  2157. -
  2158. -#
  2159. -# USB Gadget Support
  2160. -#
  2161. CONFIG_USB_GADGET=y
  2162. # CONFIG_USB_GADGET_DEBUG_FILES is not set
  2163. CONFIG_USB_GADGET_SELECTED=y
  2164. @@ -499,7 +521,9 @@
  2165. # CONFIG_USB_FILE_STORAGE is not set
  2166. # CONFIG_USB_G_SERIAL is not set
  2167. # CONFIG_USB_MIDI_GADGET is not set
  2168. +# CONFIG_USB_G_PRINTER is not set
  2169. # CONFIG_MMC is not set
  2170. +# CONFIG_MEMSTICK is not set
  2171. # CONFIG_NEW_LEDS is not set
  2172. CONFIG_RTC_LIB=y
  2173. CONFIG_RTC_CLASS=y
  2174. @@ -519,15 +543,17 @@
  2175. #
  2176. # SPI RTC drivers
  2177. #
  2178. -# CONFIG_RTC_DRV_RS5C348 is not set
  2179. # CONFIG_RTC_DRV_MAX6902 is not set
  2180. +# CONFIG_RTC_DRV_R9701 is not set
  2181. +# CONFIG_RTC_DRV_RS5C348 is not set
  2182. #
  2183. # Platform RTC drivers
  2184. #
  2185. +# CONFIG_RTC_DRV_DS1511 is not set
  2186. # CONFIG_RTC_DRV_DS1553 is not set
  2187. -# CONFIG_RTC_DRV_STK17TA8 is not set
  2188. # CONFIG_RTC_DRV_DS1742 is not set
  2189. +# CONFIG_RTC_DRV_STK17TA8 is not set
  2190. # CONFIG_RTC_DRV_M48T86 is not set
  2191. # CONFIG_RTC_DRV_M48T59 is not set
  2192. # CONFIG_RTC_DRV_V3020 is not set
  2193. @@ -545,9 +571,9 @@
  2194. #
  2195. # File systems
  2196. #
  2197. +# CONFIG_DNOTIFY is not set
  2198. # CONFIG_INOTIFY is not set
  2199. # CONFIG_QUOTA is not set
  2200. -# CONFIG_DNOTIFY is not set
  2201. # CONFIG_AUTOFS_FS is not set
  2202. # CONFIG_AUTOFS4_FS is not set
  2203. # CONFIG_FUSE_FS is not set
  2204. @@ -580,7 +606,6 @@
  2205. # CONFIG_NETWORK_FILESYSTEMS is not set
  2206. # CONFIG_NLS is not set
  2207. # CONFIG_DLM is not set
  2208. -# CONFIG_INSTRUMENTATION is not set
  2209. #
  2210. # Kernel hacking
  2211. @@ -616,6 +641,7 @@
  2212. # CONFIG_LIBCRC32C is not set
  2213. CONFIG_ZLIB_INFLATE=y
  2214. CONFIG_ZLIB_DEFLATE=y
  2215. +CONFIG_GENERIC_ALLOCATOR=y
  2216. CONFIG_HAS_IOMEM=y
  2217. CONFIG_HAS_IOPORT=y
  2218. CONFIG_HAS_DMA=y
  2219. --- /dev/null
  2220. +++ b/arch/avr32/configs/atstk1006_defconfig
  2221. @@ -0,0 +1,1235 @@
  2222. +#
  2223. +# Automatically generated make config: don't edit
  2224. +# Linux kernel version: 2.6.25.4
  2225. +# Wed Jun 11 15:40:45 2008
  2226. +#
  2227. +CONFIG_AVR32=y
  2228. +CONFIG_GENERIC_GPIO=y
  2229. +CONFIG_GENERIC_HARDIRQS=y
  2230. +CONFIG_STACKTRACE_SUPPORT=y
  2231. +CONFIG_LOCKDEP_SUPPORT=y
  2232. +CONFIG_TRACE_IRQFLAGS_SUPPORT=y
  2233. +CONFIG_HARDIRQS_SW_RESEND=y
  2234. +CONFIG_GENERIC_IRQ_PROBE=y
  2235. +CONFIG_RWSEM_GENERIC_SPINLOCK=y
  2236. +CONFIG_GENERIC_TIME=y
  2237. +CONFIG_GENERIC_CLOCKEVENTS=y
  2238. +# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
  2239. +# CONFIG_ARCH_HAS_ILOG2_U32 is not set
  2240. +# CONFIG_ARCH_HAS_ILOG2_U64 is not set
  2241. +CONFIG_GENERIC_HWEIGHT=y
  2242. +CONFIG_GENERIC_CALIBRATE_DELAY=y
  2243. +CONFIG_GENERIC_BUG=y
  2244. +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
  2245. +
  2246. +#
  2247. +# General setup
  2248. +#
  2249. +CONFIG_EXPERIMENTAL=y
  2250. +CONFIG_BROKEN_ON_SMP=y
  2251. +CONFIG_INIT_ENV_ARG_LIMIT=32
  2252. +CONFIG_LOCALVERSION=""
  2253. +# CONFIG_LOCALVERSION_AUTO is not set
  2254. +CONFIG_SWAP=y
  2255. +CONFIG_SYSVIPC=y
  2256. +CONFIG_SYSVIPC_SYSCTL=y
  2257. +CONFIG_POSIX_MQUEUE=y
  2258. +# CONFIG_BSD_PROCESS_ACCT is not set
  2259. +# CONFIG_TASKSTATS is not set
  2260. +# CONFIG_AUDIT is not set
  2261. +# CONFIG_IKCONFIG is not set
  2262. +CONFIG_LOG_BUF_SHIFT=14
  2263. +# CONFIG_CGROUPS is not set
  2264. +# CONFIG_GROUP_SCHED is not set
  2265. +CONFIG_SYSFS_DEPRECATED=y
  2266. +CONFIG_SYSFS_DEPRECATED_V2=y
  2267. +CONFIG_RELAY=y
  2268. +# CONFIG_NAMESPACES is not set
  2269. +CONFIG_BLK_DEV_INITRD=y
  2270. +CONFIG_INITRAMFS_SOURCE=""
  2271. +CONFIG_CC_OPTIMIZE_FOR_SIZE=y
  2272. +CONFIG_SYSCTL=y
  2273. +CONFIG_EMBEDDED=y
  2274. +# CONFIG_SYSCTL_SYSCALL is not set
  2275. +CONFIG_KALLSYMS=y
  2276. +# CONFIG_KALLSYMS_ALL is not set
  2277. +# CONFIG_KALLSYMS_EXTRA_PASS is not set
  2278. +CONFIG_HOTPLUG=y
  2279. +CONFIG_PRINTK=y
  2280. +CONFIG_BUG=y
  2281. +CONFIG_ELF_CORE=y
  2282. +# CONFIG_COMPAT_BRK is not set
  2283. +# CONFIG_BASE_FULL is not set
  2284. +CONFIG_FUTEX=y
  2285. +CONFIG_ANON_INODES=y
  2286. +CONFIG_EPOLL=y
  2287. +CONFIG_SIGNALFD=y
  2288. +CONFIG_TIMERFD=y
  2289. +CONFIG_EVENTFD=y
  2290. +CONFIG_SHMEM=y
  2291. +CONFIG_VM_EVENT_COUNTERS=y
  2292. +CONFIG_SLUB_DEBUG=y
  2293. +# CONFIG_SLAB is not set
  2294. +CONFIG_SLUB=y
  2295. +# CONFIG_SLOB is not set
  2296. +CONFIG_PROFILING=y
  2297. +# CONFIG_MARKERS is not set
  2298. +CONFIG_OPROFILE=m
  2299. +CONFIG_HAVE_OPROFILE=y
  2300. +CONFIG_KPROBES=y
  2301. +CONFIG_HAVE_KPROBES=y
  2302. +# CONFIG_HAVE_KRETPROBES is not set
  2303. +CONFIG_PROC_PAGE_MONITOR=y
  2304. +CONFIG_SLABINFO=y
  2305. +CONFIG_RT_MUTEXES=y
  2306. +# CONFIG_TINY_SHMEM is not set
  2307. +CONFIG_BASE_SMALL=1
  2308. +CONFIG_MODULES=y
  2309. +CONFIG_MODULE_UNLOAD=y
  2310. +# CONFIG_MODULE_FORCE_UNLOAD is not set
  2311. +# CONFIG_MODVERSIONS is not set
  2312. +# CONFIG_MODULE_SRCVERSION_ALL is not set
  2313. +# CONFIG_KMOD is not set
  2314. +CONFIG_BLOCK=y
  2315. +# CONFIG_LBD is not set
  2316. +# CONFIG_BLK_DEV_IO_TRACE is not set
  2317. +# CONFIG_LSF is not set
  2318. +# CONFIG_BLK_DEV_BSG is not set
  2319. +
  2320. +#
  2321. +# IO Schedulers
  2322. +#
  2323. +CONFIG_IOSCHED_NOOP=y
  2324. +# CONFIG_IOSCHED_AS is not set
  2325. +# CONFIG_IOSCHED_DEADLINE is not set
  2326. +CONFIG_IOSCHED_CFQ=y
  2327. +# CONFIG_DEFAULT_AS is not set
  2328. +# CONFIG_DEFAULT_DEADLINE is not set
  2329. +CONFIG_DEFAULT_CFQ=y
  2330. +# CONFIG_DEFAULT_NOOP is not set
  2331. +CONFIG_DEFAULT_IOSCHED="cfq"
  2332. +CONFIG_CLASSIC_RCU=y
  2333. +
  2334. +#
  2335. +# System Type and features
  2336. +#
  2337. +CONFIG_TICK_ONESHOT=y
  2338. +CONFIG_NO_HZ=y
  2339. +CONFIG_HIGH_RES_TIMERS=y
  2340. +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
  2341. +CONFIG_SUBARCH_AVR32B=y
  2342. +CONFIG_MMU=y
  2343. +CONFIG_PERFORMANCE_COUNTERS=y
  2344. +CONFIG_PLATFORM_AT32AP=y
  2345. +CONFIG_CPU_AT32AP700X=y
  2346. +CONFIG_CPU_AT32AP7000=y
  2347. +CONFIG_BOARD_ATSTK1000=y
  2348. +# CONFIG_BOARD_ATNGW100 is not set
  2349. +# CONFIG_BOARD_ATSTK1002 is not set
  2350. +# CONFIG_BOARD_ATSTK1003 is not set
  2351. +# CONFIG_BOARD_ATSTK1004 is not set
  2352. +CONFIG_BOARD_ATSTK1006=y
  2353. +# CONFIG_BOARD_ATSTK100X_CUSTOM is not set
  2354. +# CONFIG_BOARD_ATSTK100X_SPI1 is not set
  2355. +# CONFIG_BOARD_ATSTK1000_J2_LED is not set
  2356. +# CONFIG_BOARD_ATSTK1000_J2_LED8 is not set
  2357. +# CONFIG_BOARD_ATSTK1000_J2_RGB is not set
  2358. +CONFIG_BOARD_ATSTK1000_EXTDAC=y
  2359. +# CONFIG_BOARD_ATSTK100X_ENABLE_AC97 is not set
  2360. +# CONFIG_BOARD_ATSTK1000_CF_HACKS is not set
  2361. +# CONFIG_BOARD_ATSTK100X_ENABLE_PSIF is not set
  2362. +CONFIG_LOADER_U_BOOT=y
  2363. +
  2364. +#
  2365. +# Atmel AVR32 AP options
  2366. +#
  2367. +# CONFIG_AP700X_32_BIT_SMC is not set
  2368. +CONFIG_AP700X_16_BIT_SMC=y
  2369. +# CONFIG_AP700X_8_BIT_SMC is not set
  2370. +CONFIG_GPIO_DEV=y
  2371. +CONFIG_LOAD_ADDRESS=0x10000000
  2372. +CONFIG_ENTRY_ADDRESS=0x90000000
  2373. +CONFIG_PHYS_OFFSET=0x10000000
  2374. +CONFIG_PREEMPT_NONE=y
  2375. +# CONFIG_PREEMPT_VOLUNTARY is not set
  2376. +# CONFIG_PREEMPT is not set
  2377. +# CONFIG_HAVE_ARCH_BOOTMEM_NODE is not set
  2378. +# CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
  2379. +# CONFIG_NEED_NODE_MEMMAP_SIZE is not set
  2380. +CONFIG_ARCH_FLATMEM_ENABLE=y
  2381. +# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
  2382. +# CONFIG_ARCH_SPARSEMEM_ENABLE is not set
  2383. +CONFIG_SELECT_MEMORY_MODEL=y
  2384. +CONFIG_FLATMEM_MANUAL=y
  2385. +# CONFIG_DISCONTIGMEM_MANUAL is not set
  2386. +# CONFIG_SPARSEMEM_MANUAL is not set
  2387. +CONFIG_FLATMEM=y
  2388. +CONFIG_FLAT_NODE_MEM_MAP=y
  2389. +# CONFIG_SPARSEMEM_STATIC is not set
  2390. +# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
  2391. +CONFIG_SPLIT_PTLOCK_CPUS=4
  2392. +# CONFIG_RESOURCES_64BIT is not set
  2393. +CONFIG_ZONE_DMA_FLAG=0
  2394. +CONFIG_VIRT_TO_BUS=y
  2395. +# CONFIG_OWNERSHIP_TRACE is not set
  2396. +CONFIG_NMI_DEBUGGING=y
  2397. +CONFIG_DW_DMAC=y
  2398. +# CONFIG_HZ_100 is not set
  2399. +CONFIG_HZ_250=y
  2400. +# CONFIG_HZ_300 is not set
  2401. +# CONFIG_HZ_1000 is not set
  2402. +CONFIG_HZ=250
  2403. +# CONFIG_SCHED_HRTICK is not set
  2404. +CONFIG_CMDLINE=""
  2405. +
  2406. +#
  2407. +# Power management options
  2408. +#
  2409. +CONFIG_ARCH_SUSPEND_POSSIBLE=y
  2410. +CONFIG_PM=y
  2411. +# CONFIG_PM_LEGACY is not set
  2412. +# CONFIG_PM_DEBUG is not set
  2413. +CONFIG_PM_SLEEP=y
  2414. +CONFIG_SUSPEND=y
  2415. +CONFIG_SUSPEND_FREEZER=y
  2416. +
  2417. +#
  2418. +# CPU Frequency scaling
  2419. +#
  2420. +CONFIG_CPU_FREQ=y
  2421. +CONFIG_CPU_FREQ_TABLE=y
  2422. +# CONFIG_CPU_FREQ_DEBUG is not set
  2423. +# CONFIG_CPU_FREQ_STAT is not set
  2424. +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
  2425. +# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
  2426. +CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
  2427. +# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
  2428. +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
  2429. +# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
  2430. +CONFIG_CPU_FREQ_GOV_USERSPACE=y
  2431. +CONFIG_CPU_FREQ_GOV_ONDEMAND=y
  2432. +# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
  2433. +CONFIG_CPU_FREQ_AT32AP=y
  2434. +
  2435. +#
  2436. +# Bus options
  2437. +#
  2438. +# CONFIG_ARCH_SUPPORTS_MSI is not set
  2439. +# CONFIG_PCCARD is not set
  2440. +
  2441. +#
  2442. +# Executable file formats
  2443. +#
  2444. +CONFIG_BINFMT_ELF=y
  2445. +# CONFIG_BINFMT_MISC is not set
  2446. +
  2447. +#
  2448. +# Networking
  2449. +#
  2450. +CONFIG_NET=y
  2451. +
  2452. +#
  2453. +# Networking options
  2454. +#
  2455. +CONFIG_PACKET=y
  2456. +CONFIG_PACKET_MMAP=y
  2457. +CONFIG_UNIX=y
  2458. +CONFIG_XFRM=y
  2459. +CONFIG_XFRM_USER=m
  2460. +# CONFIG_XFRM_SUB_POLICY is not set
  2461. +# CONFIG_XFRM_MIGRATE is not set
  2462. +# CONFIG_XFRM_STATISTICS is not set
  2463. +CONFIG_NET_KEY=m
  2464. +# CONFIG_NET_KEY_MIGRATE is not set
  2465. +CONFIG_INET=y
  2466. +# CONFIG_IP_MULTICAST is not set
  2467. +# CONFIG_IP_ADVANCED_ROUTER is not set
  2468. +CONFIG_IP_FIB_HASH=y
  2469. +CONFIG_IP_PNP=y
  2470. +CONFIG_IP_PNP_DHCP=y
  2471. +# CONFIG_IP_PNP_BOOTP is not set
  2472. +# CONFIG_IP_PNP_RARP is not set
  2473. +CONFIG_NET_IPIP=m
  2474. +CONFIG_NET_IPGRE=m
  2475. +# CONFIG_ARPD is not set
  2476. +# CONFIG_SYN_COOKIES is not set
  2477. +CONFIG_INET_AH=m
  2478. +CONFIG_INET_ESP=m
  2479. +# CONFIG_INET_IPCOMP is not set
  2480. +# CONFIG_INET_XFRM_TUNNEL is not set
  2481. +CONFIG_INET_TUNNEL=m
  2482. +CONFIG_INET_XFRM_MODE_TRANSPORT=m
  2483. +CONFIG_INET_XFRM_MODE_TUNNEL=m
  2484. +CONFIG_INET_XFRM_MODE_BEET=m
  2485. +# CONFIG_INET_LRO is not set
  2486. +CONFIG_INET_DIAG=y
  2487. +CONFIG_INET_TCP_DIAG=y
  2488. +# CONFIG_TCP_CONG_ADVANCED is not set
  2489. +CONFIG_TCP_CONG_CUBIC=y
  2490. +CONFIG_DEFAULT_TCP_CONG="cubic"
  2491. +# CONFIG_TCP_MD5SIG is not set
  2492. +CONFIG_IPV6=m
  2493. +# CONFIG_IPV6_PRIVACY is not set
  2494. +# CONFIG_IPV6_ROUTER_PREF is not set
  2495. +# CONFIG_IPV6_OPTIMISTIC_DAD is not set
  2496. +CONFIG_INET6_AH=m
  2497. +CONFIG_INET6_ESP=m
  2498. +CONFIG_INET6_IPCOMP=m
  2499. +# CONFIG_IPV6_MIP6 is not set
  2500. +CONFIG_INET6_XFRM_TUNNEL=m
  2501. +CONFIG_INET6_TUNNEL=m
  2502. +CONFIG_INET6_XFRM_MODE_TRANSPORT=m
  2503. +CONFIG_INET6_XFRM_MODE_TUNNEL=m
  2504. +CONFIG_INET6_XFRM_MODE_BEET=m
  2505. +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
  2506. +CONFIG_IPV6_SIT=m
  2507. +CONFIG_IPV6_TUNNEL=m
  2508. +# CONFIG_IPV6_MULTIPLE_TABLES is not set
  2509. +# CONFIG_NETWORK_SECMARK is not set
  2510. +# CONFIG_NETFILTER is not set
  2511. +# CONFIG_IP_DCCP is not set
  2512. +# CONFIG_IP_SCTP is not set
  2513. +# CONFIG_TIPC is not set
  2514. +# CONFIG_ATM is not set
  2515. +CONFIG_BRIDGE=m
  2516. +# CONFIG_VLAN_8021Q is not set
  2517. +# CONFIG_DECNET is not set
  2518. +CONFIG_LLC=m
  2519. +# CONFIG_LLC2 is not set
  2520. +# CONFIG_IPX is not set
  2521. +# CONFIG_ATALK is not set
  2522. +# CONFIG_X25 is not set
  2523. +# CONFIG_LAPB is not set
  2524. +# CONFIG_ECONET is not set
  2525. +# CONFIG_WAN_ROUTER is not set
  2526. +# CONFIG_NET_SCHED is not set
  2527. +
  2528. +#
  2529. +# Network testing
  2530. +#
  2531. +# CONFIG_NET_PKTGEN is not set
  2532. +# CONFIG_NET_TCPPROBE is not set
  2533. +# CONFIG_HAMRADIO is not set
  2534. +# CONFIG_CAN is not set
  2535. +# CONFIG_IRDA is not set
  2536. +# CONFIG_BT is not set
  2537. +# CONFIG_AF_RXRPC is not set
  2538. +
  2539. +#
  2540. +# Wireless
  2541. +#
  2542. +# CONFIG_CFG80211 is not set
  2543. +# CONFIG_WIRELESS_EXT is not set
  2544. +# CONFIG_MAC80211 is not set
  2545. +# CONFIG_IEEE80211 is not set
  2546. +# CONFIG_RFKILL is not set
  2547. +# CONFIG_NET_9P is not set
  2548. +
  2549. +#
  2550. +# Device Drivers
  2551. +#
  2552. +
  2553. +#
  2554. +# Generic Driver Options
  2555. +#
  2556. +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
  2557. +CONFIG_STANDALONE=y
  2558. +# CONFIG_PREVENT_FIRMWARE_BUILD is not set
  2559. +# CONFIG_FW_LOADER is not set
  2560. +# CONFIG_DEBUG_DRIVER is not set
  2561. +# CONFIG_DEBUG_DEVRES is not set
  2562. +# CONFIG_SYS_HYPERVISOR is not set
  2563. +# CONFIG_CONNECTOR is not set
  2564. +CONFIG_MTD=y
  2565. +# CONFIG_MTD_DEBUG is not set
  2566. +# CONFIG_MTD_CONCAT is not set
  2567. +CONFIG_MTD_PARTITIONS=y
  2568. +# CONFIG_MTD_REDBOOT_PARTS is not set
  2569. +CONFIG_MTD_CMDLINE_PARTS=y
  2570. +
  2571. +#
  2572. +# User Modules And Translation Layers
  2573. +#
  2574. +CONFIG_MTD_CHAR=y
  2575. +CONFIG_MTD_BLKDEVS=y
  2576. +CONFIG_MTD_BLOCK=y
  2577. +# CONFIG_FTL is not set
  2578. +# CONFIG_NFTL is not set
  2579. +# CONFIG_INFTL is not set
  2580. +# CONFIG_RFD_FTL is not set
  2581. +# CONFIG_SSFDC is not set
  2582. +# CONFIG_MTD_OOPS is not set
  2583. +
  2584. +#
  2585. +# RAM/ROM/Flash chip drivers
  2586. +#
  2587. +CONFIG_MTD_CFI=y
  2588. +# CONFIG_MTD_JEDECPROBE is not set
  2589. +CONFIG_MTD_GEN_PROBE=y
  2590. +# CONFIG_MTD_CFI_ADV_OPTIONS is not set
  2591. +CONFIG_MTD_MAP_BANK_WIDTH_1=y
  2592. +CONFIG_MTD_MAP_BANK_WIDTH_2=y
  2593. +CONFIG_MTD_MAP_BANK_WIDTH_4=y
  2594. +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
  2595. +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
  2596. +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
  2597. +CONFIG_MTD_CFI_I1=y
  2598. +CONFIG_MTD_CFI_I2=y
  2599. +# CONFIG_MTD_CFI_I4 is not set
  2600. +# CONFIG_MTD_CFI_I8 is not set
  2601. +# CONFIG_MTD_CFI_INTELEXT is not set
  2602. +CONFIG_MTD_CFI_AMDSTD=y
  2603. +# CONFIG_MTD_CFI_STAA is not set
  2604. +CONFIG_MTD_CFI_UTIL=y
  2605. +# CONFIG_MTD_RAM is not set
  2606. +# CONFIG_MTD_ROM is not set
  2607. +# CONFIG_MTD_ABSENT is not set
  2608. +
  2609. +#
  2610. +# Mapping drivers for chip access
  2611. +#
  2612. +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
  2613. +CONFIG_MTD_PHYSMAP=y
  2614. +CONFIG_MTD_PHYSMAP_START=0x8000000
  2615. +CONFIG_MTD_PHYSMAP_LEN=0x0
  2616. +CONFIG_MTD_PHYSMAP_BANKWIDTH=2
  2617. +# CONFIG_MTD_PLATRAM is not set
  2618. +
  2619. +#
  2620. +# Self-contained MTD device drivers
  2621. +#
  2622. +CONFIG_MTD_DATAFLASH=m
  2623. +CONFIG_MTD_M25P80=m
  2624. +# CONFIG_MTD_SLRAM is not set
  2625. +# CONFIG_MTD_PHRAM is not set
  2626. +# CONFIG_MTD_MTDRAM is not set
  2627. +# CONFIG_MTD_BLOCK2MTD is not set
  2628. +
  2629. +#
  2630. +# Disk-On-Chip Device Drivers
  2631. +#
  2632. +# CONFIG_MTD_DOC2000 is not set
  2633. +# CONFIG_MTD_DOC2001 is not set
  2634. +# CONFIG_MTD_DOC2001PLUS is not set
  2635. +CONFIG_MTD_NAND=y
  2636. +# CONFIG_MTD_NAND_VERIFY_WRITE is not set
  2637. +# CONFIG_MTD_NAND_ECC_SMC is not set
  2638. +# CONFIG_MTD_NAND_MUSEUM_IDS is not set
  2639. +CONFIG_MTD_NAND_IDS=y
  2640. +# CONFIG_MTD_NAND_DISKONCHIP is not set
  2641. +CONFIG_MTD_NAND_ATMEL=y
  2642. +CONFIG_MTD_NAND_ATMEL_ECC_HW=y
  2643. +# CONFIG_MTD_NAND_ATMEL_ECC_SOFT is not set
  2644. +# CONFIG_MTD_NAND_ATMEL_ECC_NONE is not set
  2645. +# CONFIG_MTD_NAND_NANDSIM is not set
  2646. +# CONFIG_MTD_NAND_PLATFORM is not set
  2647. +# CONFIG_MTD_ONENAND is not set
  2648. +
  2649. +#
  2650. +# UBI - Unsorted block images
  2651. +#
  2652. +CONFIG_MTD_UBI=m
  2653. +CONFIG_MTD_UBI_WL_THRESHOLD=4096
  2654. +CONFIG_MTD_UBI_BEB_RESERVE=1
  2655. +CONFIG_MTD_UBI_GLUEBI=y
  2656. +
  2657. +#
  2658. +# UBI debugging options
  2659. +#
  2660. +# CONFIG_MTD_UBI_DEBUG is not set
  2661. +# CONFIG_PARPORT is not set
  2662. +CONFIG_BLK_DEV=y
  2663. +# CONFIG_BLK_DEV_COW_COMMON is not set
  2664. +CONFIG_BLK_DEV_LOOP=m
  2665. +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
  2666. +CONFIG_BLK_DEV_NBD=m
  2667. +CONFIG_BLK_DEV_RAM=m
  2668. +CONFIG_BLK_DEV_RAM_COUNT=16
  2669. +CONFIG_BLK_DEV_RAM_SIZE=4096
  2670. +# CONFIG_BLK_DEV_XIP is not set
  2671. +# CONFIG_CDROM_PKTCDVD is not set
  2672. +# CONFIG_ATA_OVER_ETH is not set
  2673. +CONFIG_MISC_DEVICES=y
  2674. +CONFIG_ATMEL_PWM=m
  2675. +CONFIG_ATMEL_TCLIB=y
  2676. +CONFIG_ATMEL_TCB_CLKSRC=y
  2677. +CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
  2678. +# CONFIG_EEPROM_93CX6 is not set
  2679. +CONFIG_ATMEL_SSC=m
  2680. +# CONFIG_ENCLOSURE_SERVICES is not set
  2681. +# CONFIG_HAVE_IDE is not set
  2682. +
  2683. +#
  2684. +# SCSI device support
  2685. +#
  2686. +# CONFIG_RAID_ATTRS is not set
  2687. +CONFIG_SCSI=m
  2688. +CONFIG_SCSI_DMA=y
  2689. +# CONFIG_SCSI_TGT is not set
  2690. +# CONFIG_SCSI_NETLINK is not set
  2691. +# CONFIG_SCSI_PROC_FS is not set
  2692. +
  2693. +#
  2694. +# SCSI support type (disk, tape, CD-ROM)
  2695. +#
  2696. +CONFIG_BLK_DEV_SD=m
  2697. +# CONFIG_CHR_DEV_ST is not set
  2698. +# CONFIG_CHR_DEV_OSST is not set
  2699. +CONFIG_BLK_DEV_SR=m
  2700. +# CONFIG_BLK_DEV_SR_VENDOR is not set
  2701. +# CONFIG_CHR_DEV_SG is not set
  2702. +# CONFIG_CHR_DEV_SCH is not set
  2703. +
  2704. +#
  2705. +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
  2706. +#
  2707. +# CONFIG_SCSI_MULTI_LUN is not set
  2708. +# CONFIG_SCSI_CONSTANTS is not set
  2709. +# CONFIG_SCSI_LOGGING is not set
  2710. +# CONFIG_SCSI_SCAN_ASYNC is not set
  2711. +CONFIG_SCSI_WAIT_SCAN=m
  2712. +
  2713. +#
  2714. +# SCSI Transports
  2715. +#
  2716. +# CONFIG_SCSI_SPI_ATTRS is not set
  2717. +# CONFIG_SCSI_FC_ATTRS is not set
  2718. +# CONFIG_SCSI_ISCSI_ATTRS is not set
  2719. +# CONFIG_SCSI_SAS_LIBSAS is not set
  2720. +# CONFIG_SCSI_SRP_ATTRS is not set
  2721. +# CONFIG_SCSI_LOWLEVEL is not set
  2722. +CONFIG_ATA=m
  2723. +# CONFIG_ATA_NONSTANDARD is not set
  2724. +# CONFIG_SATA_MV is not set
  2725. +CONFIG_PATA_AT32=m
  2726. +# CONFIG_PATA_PLATFORM is not set
  2727. +# CONFIG_MD is not set
  2728. +CONFIG_NETDEVICES=y
  2729. +# CONFIG_NETDEVICES_MULTIQUEUE is not set
  2730. +# CONFIG_DUMMY is not set
  2731. +# CONFIG_BONDING is not set
  2732. +# CONFIG_MACVLAN is not set
  2733. +# CONFIG_EQUALIZER is not set
  2734. +CONFIG_TUN=m
  2735. +# CONFIG_VETH is not set
  2736. +CONFIG_PHYLIB=y
  2737. +
  2738. +#
  2739. +# MII PHY device drivers
  2740. +#
  2741. +# CONFIG_MARVELL_PHY is not set
  2742. +# CONFIG_DAVICOM_PHY is not set
  2743. +# CONFIG_QSEMI_PHY is not set
  2744. +# CONFIG_LXT_PHY is not set
  2745. +# CONFIG_CICADA_PHY is not set
  2746. +# CONFIG_VITESSE_PHY is not set
  2747. +# CONFIG_SMSC_PHY is not set
  2748. +# CONFIG_BROADCOM_PHY is not set
  2749. +# CONFIG_ICPLUS_PHY is not set
  2750. +# CONFIG_REALTEK_PHY is not set
  2751. +# CONFIG_FIXED_PHY is not set
  2752. +# CONFIG_MDIO_BITBANG is not set
  2753. +CONFIG_NET_ETHERNET=y
  2754. +# CONFIG_MII is not set
  2755. +CONFIG_MACB=y
  2756. +# CONFIG_ENC28J60 is not set
  2757. +# CONFIG_IBM_NEW_EMAC_ZMII is not set
  2758. +# CONFIG_IBM_NEW_EMAC_RGMII is not set
  2759. +# CONFIG_IBM_NEW_EMAC_TAH is not set
  2760. +# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
  2761. +# CONFIG_B44 is not set
  2762. +# CONFIG_NETDEV_1000 is not set
  2763. +# CONFIG_NETDEV_10000 is not set
  2764. +
  2765. +#
  2766. +# Wireless LAN
  2767. +#
  2768. +# CONFIG_WLAN_PRE80211 is not set
  2769. +# CONFIG_WLAN_80211 is not set
  2770. +# CONFIG_WAN is not set
  2771. +CONFIG_PPP=m
  2772. +# CONFIG_PPP_MULTILINK is not set
  2773. +# CONFIG_PPP_FILTER is not set
  2774. +CONFIG_PPP_ASYNC=m
  2775. +# CONFIG_PPP_SYNC_TTY is not set
  2776. +CONFIG_PPP_DEFLATE=m
  2777. +CONFIG_PPP_BSDCOMP=m
  2778. +# CONFIG_PPP_MPPE is not set
  2779. +# CONFIG_PPPOE is not set
  2780. +# CONFIG_PPPOL2TP is not set
  2781. +# CONFIG_SLIP is not set
  2782. +CONFIG_SLHC=m
  2783. +# CONFIG_NETCONSOLE is not set
  2784. +# CONFIG_NETPOLL is not set
  2785. +# CONFIG_NET_POLL_CONTROLLER is not set
  2786. +# CONFIG_ISDN is not set
  2787. +# CONFIG_PHONE is not set
  2788. +
  2789. +#
  2790. +# Input device support
  2791. +#
  2792. +CONFIG_INPUT=m
  2793. +# CONFIG_INPUT_FF_MEMLESS is not set
  2794. +CONFIG_INPUT_POLLDEV=m
  2795. +
  2796. +#
  2797. +# Userland interfaces
  2798. +#
  2799. +CONFIG_INPUT_MOUSEDEV=m
  2800. +CONFIG_INPUT_MOUSEDEV_PSAUX=y
  2801. +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
  2802. +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
  2803. +# CONFIG_INPUT_JOYDEV is not set
  2804. +CONFIG_INPUT_EVDEV=m
  2805. +# CONFIG_INPUT_EVBUG is not set
  2806. +
  2807. +#
  2808. +# Input Device Drivers
  2809. +#
  2810. +CONFIG_INPUT_KEYBOARD=y
  2811. +# CONFIG_KEYBOARD_ATKBD is not set
  2812. +# CONFIG_KEYBOARD_SUNKBD is not set
  2813. +# CONFIG_KEYBOARD_LKKBD is not set
  2814. +# CONFIG_KEYBOARD_XTKBD is not set
  2815. +# CONFIG_KEYBOARD_NEWTON is not set
  2816. +# CONFIG_KEYBOARD_STOWAWAY is not set
  2817. +CONFIG_KEYBOARD_GPIO=m
  2818. +CONFIG_INPUT_MOUSE=y
  2819. +# CONFIG_MOUSE_PS2 is not set
  2820. +# CONFIG_MOUSE_SERIAL is not set
  2821. +# CONFIG_MOUSE_VSXXXAA is not set
  2822. +CONFIG_MOUSE_GPIO=m
  2823. +# CONFIG_INPUT_JOYSTICK is not set
  2824. +# CONFIG_INPUT_TABLET is not set
  2825. +# CONFIG_INPUT_TOUCHSCREEN is not set
  2826. +# CONFIG_INPUT_MISC is not set
  2827. +
  2828. +#
  2829. +# Hardware I/O ports
  2830. +#
  2831. +# CONFIG_SERIO is not set
  2832. +# CONFIG_GAMEPORT is not set
  2833. +
  2834. +#
  2835. +# Character devices
  2836. +#
  2837. +# CONFIG_VT is not set
  2838. +# CONFIG_SERIAL_NONSTANDARD is not set
  2839. +
  2840. +#
  2841. +# Serial drivers
  2842. +#
  2843. +# CONFIG_SERIAL_8250 is not set
  2844. +
  2845. +#
  2846. +# Non-8250 serial port support
  2847. +#
  2848. +CONFIG_SERIAL_ATMEL=y
  2849. +CONFIG_SERIAL_ATMEL_CONSOLE=y
  2850. +CONFIG_SERIAL_ATMEL_PDC=y
  2851. +# CONFIG_SERIAL_ATMEL_TTYAT is not set
  2852. +CONFIG_SERIAL_CORE=y
  2853. +CONFIG_SERIAL_CORE_CONSOLE=y
  2854. +CONFIG_UNIX98_PTYS=y
  2855. +# CONFIG_LEGACY_PTYS is not set
  2856. +# CONFIG_IPMI_HANDLER is not set
  2857. +# CONFIG_HW_RANDOM is not set
  2858. +# CONFIG_R3964 is not set
  2859. +# CONFIG_RAW_DRIVER is not set
  2860. +# CONFIG_TCG_TPM is not set
  2861. +CONFIG_I2C=m
  2862. +CONFIG_I2C_BOARDINFO=y
  2863. +CONFIG_I2C_CHARDEV=m
  2864. +
  2865. +#
  2866. +# I2C Algorithms
  2867. +#
  2868. +CONFIG_I2C_ALGOBIT=m
  2869. +# CONFIG_I2C_ALGOPCF is not set
  2870. +# CONFIG_I2C_ALGOPCA is not set
  2871. +
  2872. +#
  2873. +# I2C Hardware Bus support
  2874. +#
  2875. +CONFIG_I2C_ATMELTWI=m
  2876. +CONFIG_I2C_GPIO=m
  2877. +# CONFIG_I2C_OCORES is not set
  2878. +# CONFIG_I2C_PARPORT_LIGHT is not set
  2879. +# CONFIG_I2C_SIMTEC is not set
  2880. +# CONFIG_I2C_TAOS_EVM is not set
  2881. +# CONFIG_I2C_STUB is not set
  2882. +
  2883. +#
  2884. +# Miscellaneous I2C Chip support
  2885. +#
  2886. +# CONFIG_DS1682 is not set
  2887. +# CONFIG_SENSORS_EEPROM is not set
  2888. +# CONFIG_SENSORS_PCF8574 is not set
  2889. +# CONFIG_PCF8575 is not set
  2890. +# CONFIG_SENSORS_PCF8591 is not set
  2891. +# CONFIG_TPS65010 is not set
  2892. +# CONFIG_SENSORS_MAX6875 is not set
  2893. +# CONFIG_SENSORS_TSL2550 is not set
  2894. +# CONFIG_I2C_DEBUG_CORE is not set
  2895. +# CONFIG_I2C_DEBUG_ALGO is not set
  2896. +# CONFIG_I2C_DEBUG_BUS is not set
  2897. +# CONFIG_I2C_DEBUG_CHIP is not set
  2898. +
  2899. +#
  2900. +# SPI support
  2901. +#
  2902. +CONFIG_SPI=y
  2903. +# CONFIG_SPI_DEBUG is not set
  2904. +CONFIG_SPI_MASTER=y
  2905. +
  2906. +#
  2907. +# SPI Master Controller Drivers
  2908. +#
  2909. +CONFIG_SPI_ATMEL=y
  2910. +# CONFIG_SPI_BITBANG is not set
  2911. +
  2912. +#
  2913. +# SPI Protocol Masters
  2914. +#
  2915. +# CONFIG_SPI_AT25 is not set
  2916. +CONFIG_SPI_SPIDEV=m
  2917. +# CONFIG_SPI_TLE62X0 is not set
  2918. +CONFIG_HAVE_GPIO_LIB=y
  2919. +
  2920. +#
  2921. +# GPIO Support
  2922. +#
  2923. +# CONFIG_DEBUG_GPIO is not set
  2924. +
  2925. +#
  2926. +# I2C GPIO expanders:
  2927. +#
  2928. +# CONFIG_GPIO_PCA953X is not set
  2929. +# CONFIG_GPIO_PCF857X is not set
  2930. +
  2931. +#
  2932. +# SPI GPIO expanders:
  2933. +#
  2934. +# CONFIG_GPIO_MCP23S08 is not set
  2935. +# CONFIG_W1 is not set
  2936. +# CONFIG_POWER_SUPPLY is not set
  2937. +# CONFIG_HWMON is not set
  2938. +# CONFIG_THERMAL is not set
  2939. +CONFIG_WATCHDOG=y
  2940. +# CONFIG_WATCHDOG_NOWAYOUT is not set
  2941. +
  2942. +#
  2943. +# Watchdog Device Drivers
  2944. +#
  2945. +# CONFIG_SOFT_WATCHDOG is not set
  2946. +CONFIG_AT32AP700X_WDT=y
  2947. +
  2948. +#
  2949. +# Sonics Silicon Backplane
  2950. +#
  2951. +CONFIG_SSB_POSSIBLE=y
  2952. +# CONFIG_SSB is not set
  2953. +
  2954. +#
  2955. +# Multifunction device drivers
  2956. +#
  2957. +# CONFIG_MFD_SM501 is not set
  2958. +
  2959. +#
  2960. +# Multimedia devices
  2961. +#
  2962. +# CONFIG_VIDEO_DEV is not set
  2963. +# CONFIG_DVB_CORE is not set
  2964. +# CONFIG_DAB is not set
  2965. +
  2966. +#
  2967. +# Graphics support
  2968. +#
  2969. +# CONFIG_VGASTATE is not set
  2970. +# CONFIG_VIDEO_OUTPUT_CONTROL is not set
  2971. +CONFIG_FB=y
  2972. +# CONFIG_FIRMWARE_EDID is not set
  2973. +# CONFIG_FB_DDC is not set
  2974. +CONFIG_FB_CFB_FILLRECT=y
  2975. +CONFIG_FB_CFB_COPYAREA=y
  2976. +CONFIG_FB_CFB_IMAGEBLIT=y
  2977. +# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
  2978. +# CONFIG_FB_SYS_FILLRECT is not set
  2979. +# CONFIG_FB_SYS_COPYAREA is not set
  2980. +# CONFIG_FB_SYS_IMAGEBLIT is not set
  2981. +# CONFIG_FB_SYS_FOPS is not set
  2982. +CONFIG_FB_DEFERRED_IO=y
  2983. +# CONFIG_FB_SVGALIB is not set
  2984. +# CONFIG_FB_MACMODES is not set
  2985. +# CONFIG_FB_BACKLIGHT is not set
  2986. +# CONFIG_FB_MODE_HELPERS is not set
  2987. +# CONFIG_FB_TILEBLITTING is not set
  2988. +
  2989. +#
  2990. +# Frame buffer hardware drivers
  2991. +#
  2992. +# CONFIG_FB_S1D13XXX is not set
  2993. +CONFIG_FB_ATMEL=y
  2994. +# CONFIG_FB_VIRTUAL is not set
  2995. +CONFIG_BACKLIGHT_LCD_SUPPORT=y
  2996. +CONFIG_LCD_CLASS_DEVICE=y
  2997. +CONFIG_LCD_LTV350QV=y
  2998. +# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
  2999. +
  3000. +#
  3001. +# Display device support
  3002. +#
  3003. +# CONFIG_DISPLAY_SUPPORT is not set
  3004. +# CONFIG_LOGO is not set
  3005. +
  3006. +#
  3007. +# Sound
  3008. +#
  3009. +CONFIG_SOUND=m
  3010. +
  3011. +#
  3012. +# Advanced Linux Sound Architecture
  3013. +#
  3014. +CONFIG_SND=m
  3015. +CONFIG_SND_TIMER=m
  3016. +CONFIG_SND_PCM=m
  3017. +# CONFIG_SND_SEQUENCER is not set
  3018. +CONFIG_SND_OSSEMUL=y
  3019. +CONFIG_SND_MIXER_OSS=m
  3020. +CONFIG_SND_PCM_OSS=m
  3021. +CONFIG_SND_PCM_OSS_PLUGINS=y
  3022. +# CONFIG_SND_DYNAMIC_MINORS is not set
  3023. +# CONFIG_SND_SUPPORT_OLD_API is not set
  3024. +# CONFIG_SND_VERBOSE_PROCFS is not set
  3025. +# CONFIG_SND_VERBOSE_PRINTK is not set
  3026. +# CONFIG_SND_DEBUG is not set
  3027. +
  3028. +#
  3029. +# Generic devices
  3030. +#
  3031. +CONFIG_SND_AC97_CODEC=m
  3032. +# CONFIG_SND_DUMMY is not set
  3033. +# CONFIG_SND_MTPAV is not set
  3034. +# CONFIG_SND_SERIAL_U16550 is not set
  3035. +# CONFIG_SND_MPU401 is not set
  3036. +
  3037. +#
  3038. +# AVR32 devices
  3039. +#
  3040. +CONFIG_SND_ATMEL_AC97=m
  3041. +
  3042. +#
  3043. +# SPI devices
  3044. +#
  3045. +CONFIG_SND_AT73C213=m
  3046. +CONFIG_SND_AT73C213_TARGET_BITRATE=48000
  3047. +
  3048. +#
  3049. +# System on Chip audio support
  3050. +#
  3051. +# CONFIG_SND_SOC is not set
  3052. +
  3053. +#
  3054. +# SoC Audio support for SuperH
  3055. +#
  3056. +
  3057. +#
  3058. +# ALSA SoC audio for Freescale SOCs
  3059. +#
  3060. +
  3061. +#
  3062. +# Open Sound System
  3063. +#
  3064. +# CONFIG_SOUND_PRIME is not set
  3065. +CONFIG_AC97_BUS=m
  3066. +# CONFIG_HID_SUPPORT is not set
  3067. +CONFIG_USB_SUPPORT=y
  3068. +# CONFIG_USB_ARCH_HAS_HCD is not set
  3069. +# CONFIG_USB_ARCH_HAS_OHCI is not set
  3070. +# CONFIG_USB_ARCH_HAS_EHCI is not set
  3071. +
  3072. +#
  3073. +# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
  3074. +#
  3075. +CONFIG_USB_GADGET=y
  3076. +# CONFIG_USB_GADGET_DEBUG is not set
  3077. +# CONFIG_USB_GADGET_DEBUG_FILES is not set
  3078. +# CONFIG_USB_GADGET_DEBUG_FS is not set
  3079. +CONFIG_USB_GADGET_SELECTED=y
  3080. +# CONFIG_USB_GADGET_AMD5536UDC is not set
  3081. +CONFIG_USB_GADGET_ATMEL_USBA=y
  3082. +CONFIG_USB_ATMEL_USBA=y
  3083. +# CONFIG_USB_GADGET_FSL_USB2 is not set
  3084. +# CONFIG_USB_GADGET_NET2280 is not set
  3085. +# CONFIG_USB_GADGET_PXA2XX is not set
  3086. +# CONFIG_USB_GADGET_M66592 is not set
  3087. +# CONFIG_USB_GADGET_GOKU is not set
  3088. +# CONFIG_USB_GADGET_LH7A40X is not set
  3089. +# CONFIG_USB_GADGET_OMAP is not set
  3090. +# CONFIG_USB_GADGET_S3C2410 is not set
  3091. +# CONFIG_USB_GADGET_AT91 is not set
  3092. +# CONFIG_USB_GADGET_DUMMY_HCD is not set
  3093. +CONFIG_USB_GADGET_DUALSPEED=y
  3094. +CONFIG_USB_ZERO=m
  3095. +CONFIG_USB_ETH=m
  3096. +CONFIG_USB_ETH_RNDIS=y
  3097. +CONFIG_USB_GADGETFS=m
  3098. +CONFIG_USB_FILE_STORAGE=m
  3099. +# CONFIG_USB_FILE_STORAGE_TEST is not set
  3100. +CONFIG_USB_G_SERIAL=m
  3101. +# CONFIG_USB_MIDI_GADGET is not set
  3102. +# CONFIG_USB_G_PRINTER is not set
  3103. +CONFIG_MMC=y
  3104. +# CONFIG_MMC_DEBUG is not set
  3105. +# CONFIG_MMC_UNSAFE_RESUME is not set
  3106. +
  3107. +#
  3108. +# MMC/SD Card Drivers
  3109. +#
  3110. +CONFIG_MMC_BLOCK=y
  3111. +CONFIG_MMC_BLOCK_BOUNCE=y
  3112. +# CONFIG_SDIO_UART is not set
  3113. +
  3114. +#
  3115. +# MMC/SD Host Controller Drivers
  3116. +#
  3117. +CONFIG_MMC_ATMELMCI=y
  3118. +CONFIG_MMC_SPI=m
  3119. +# CONFIG_MEMSTICK is not set
  3120. +CONFIG_NEW_LEDS=y
  3121. +CONFIG_LEDS_CLASS=m
  3122. +
  3123. +#
  3124. +# LED drivers
  3125. +#
  3126. +CONFIG_LEDS_ATMEL_PWM=m
  3127. +CONFIG_LEDS_GPIO=m
  3128. +
  3129. +#
  3130. +# LED Triggers
  3131. +#
  3132. +CONFIG_LEDS_TRIGGERS=y
  3133. +CONFIG_LEDS_TRIGGER_TIMER=m
  3134. +CONFIG_LEDS_TRIGGER_HEARTBEAT=m
  3135. +CONFIG_RTC_LIB=y
  3136. +CONFIG_RTC_CLASS=y
  3137. +CONFIG_RTC_HCTOSYS=y
  3138. +CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
  3139. +# CONFIG_RTC_DEBUG is not set
  3140. +
  3141. +#
  3142. +# RTC interfaces
  3143. +#
  3144. +CONFIG_RTC_INTF_SYSFS=y
  3145. +CONFIG_RTC_INTF_PROC=y
  3146. +CONFIG_RTC_INTF_DEV=y
  3147. +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
  3148. +# CONFIG_RTC_DRV_TEST is not set
  3149. +
  3150. +#
  3151. +# I2C RTC drivers
  3152. +#
  3153. +# CONFIG_RTC_DRV_DS1307 is not set
  3154. +# CONFIG_RTC_DRV_DS1374 is not set
  3155. +# CONFIG_RTC_DRV_DS1672 is not set
  3156. +# CONFIG_RTC_DRV_MAX6900 is not set
  3157. +# CONFIG_RTC_DRV_RS5C372 is not set
  3158. +# CONFIG_RTC_DRV_ISL1208 is not set
  3159. +# CONFIG_RTC_DRV_X1205 is not set
  3160. +# CONFIG_RTC_DRV_PCF8563 is not set
  3161. +# CONFIG_RTC_DRV_PCF8583 is not set
  3162. +# CONFIG_RTC_DRV_M41T80 is not set
  3163. +# CONFIG_RTC_DRV_S35390A is not set
  3164. +
  3165. +#
  3166. +# SPI RTC drivers
  3167. +#
  3168. +# CONFIG_RTC_DRV_MAX6902 is not set
  3169. +# CONFIG_RTC_DRV_R9701 is not set
  3170. +# CONFIG_RTC_DRV_RS5C348 is not set
  3171. +
  3172. +#
  3173. +# Platform RTC drivers
  3174. +#
  3175. +# CONFIG_RTC_DRV_DS1511 is not set
  3176. +# CONFIG_RTC_DRV_DS1553 is not set
  3177. +# CONFIG_RTC_DRV_DS1742 is not set
  3178. +# CONFIG_RTC_DRV_STK17TA8 is not set
  3179. +# CONFIG_RTC_DRV_M48T86 is not set
  3180. +# CONFIG_RTC_DRV_M48T59 is not set
  3181. +# CONFIG_RTC_DRV_V3020 is not set
  3182. +
  3183. +#
  3184. +# on-CPU RTC drivers
  3185. +#
  3186. +CONFIG_RTC_DRV_AT32AP700X=y
  3187. +
  3188. +#
  3189. +# Userspace I/O
  3190. +#
  3191. +# CONFIG_UIO is not set
  3192. +
  3193. +#
  3194. +# File systems
  3195. +#
  3196. +CONFIG_EXT2_FS=y
  3197. +# CONFIG_EXT2_FS_XATTR is not set
  3198. +# CONFIG_EXT2_FS_XIP is not set
  3199. +CONFIG_EXT3_FS=y
  3200. +# CONFIG_EXT3_FS_XATTR is not set
  3201. +# CONFIG_EXT4DEV_FS is not set
  3202. +CONFIG_JBD=y
  3203. +# CONFIG_JBD_DEBUG is not set
  3204. +# CONFIG_REISERFS_FS is not set
  3205. +# CONFIG_JFS_FS is not set
  3206. +# CONFIG_FS_POSIX_ACL is not set
  3207. +# CONFIG_XFS_FS is not set
  3208. +# CONFIG_GFS2_FS is not set
  3209. +# CONFIG_OCFS2_FS is not set
  3210. +# CONFIG_DNOTIFY is not set
  3211. +CONFIG_INOTIFY=y
  3212. +CONFIG_INOTIFY_USER=y
  3213. +# CONFIG_QUOTA is not set
  3214. +# CONFIG_AUTOFS_FS is not set
  3215. +# CONFIG_AUTOFS4_FS is not set
  3216. +CONFIG_FUSE_FS=m
  3217. +
  3218. +#
  3219. +# CD-ROM/DVD Filesystems
  3220. +#
  3221. +# CONFIG_ISO9660_FS is not set
  3222. +# CONFIG_UDF_FS is not set
  3223. +
  3224. +#
  3225. +# DOS/FAT/NT Filesystems
  3226. +#
  3227. +CONFIG_FAT_FS=m
  3228. +CONFIG_MSDOS_FS=m
  3229. +CONFIG_VFAT_FS=m
  3230. +CONFIG_FAT_DEFAULT_CODEPAGE=437
  3231. +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
  3232. +# CONFIG_NTFS_FS is not set
  3233. +
  3234. +#
  3235. +# Pseudo filesystems
  3236. +#
  3237. +CONFIG_PROC_FS=y
  3238. +CONFIG_PROC_KCORE=y
  3239. +CONFIG_PROC_SYSCTL=y
  3240. +CONFIG_SYSFS=y
  3241. +CONFIG_TMPFS=y
  3242. +# CONFIG_TMPFS_POSIX_ACL is not set
  3243. +# CONFIG_HUGETLB_PAGE is not set
  3244. +CONFIG_CONFIGFS_FS=y
  3245. +
  3246. +#
  3247. +# Miscellaneous filesystems
  3248. +#
  3249. +# CONFIG_ADFS_FS is not set
  3250. +# CONFIG_AFFS_FS is not set
  3251. +# CONFIG_HFS_FS is not set
  3252. +# CONFIG_HFSPLUS_FS is not set
  3253. +# CONFIG_BEFS_FS is not set
  3254. +# CONFIG_BFS_FS is not set
  3255. +# CONFIG_EFS_FS is not set
  3256. +CONFIG_JFFS2_FS=y
  3257. +CONFIG_JFFS2_FS_DEBUG=0
  3258. +# CONFIG_JFFS2_FS_WRITEBUFFER is not set
  3259. +# CONFIG_JFFS2_SUMMARY is not set
  3260. +# CONFIG_JFFS2_FS_XATTR is not set
  3261. +# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
  3262. +CONFIG_JFFS2_ZLIB=y
  3263. +# CONFIG_JFFS2_LZO is not set
  3264. +CONFIG_JFFS2_RTIME=y
  3265. +# CONFIG_JFFS2_RUBIN is not set
  3266. +# CONFIG_CRAMFS is not set
  3267. +# CONFIG_VXFS_FS is not set
  3268. +CONFIG_MINIX_FS=m
  3269. +# CONFIG_HPFS_FS is not set
  3270. +# CONFIG_QNX4FS_FS is not set
  3271. +# CONFIG_ROMFS_FS is not set
  3272. +# CONFIG_SYSV_FS is not set
  3273. +# CONFIG_UFS_FS is not set
  3274. +CONFIG_NETWORK_FILESYSTEMS=y
  3275. +CONFIG_NFS_FS=y
  3276. +CONFIG_NFS_V3=y
  3277. +# CONFIG_NFS_V3_ACL is not set
  3278. +# CONFIG_NFS_V4 is not set
  3279. +# CONFIG_NFS_DIRECTIO is not set
  3280. +# CONFIG_NFSD is not set
  3281. +CONFIG_ROOT_NFS=y
  3282. +CONFIG_LOCKD=y
  3283. +CONFIG_LOCKD_V4=y
  3284. +CONFIG_NFS_COMMON=y
  3285. +CONFIG_SUNRPC=y
  3286. +# CONFIG_SUNRPC_BIND34 is not set
  3287. +# CONFIG_RPCSEC_GSS_KRB5 is not set
  3288. +# CONFIG_RPCSEC_GSS_SPKM3 is not set
  3289. +# CONFIG_SMB_FS is not set
  3290. +# CONFIG_CIFS is not set
  3291. +# CONFIG_NCP_FS is not set
  3292. +# CONFIG_CODA_FS is not set
  3293. +# CONFIG_AFS_FS is not set
  3294. +
  3295. +#
  3296. +# Partition Types
  3297. +#
  3298. +# CONFIG_PARTITION_ADVANCED is not set
  3299. +CONFIG_MSDOS_PARTITION=y
  3300. +CONFIG_NLS=m
  3301. +CONFIG_NLS_DEFAULT="iso8859-1"
  3302. +CONFIG_NLS_CODEPAGE_437=m
  3303. +# CONFIG_NLS_CODEPAGE_737 is not set
  3304. +# CONFIG_NLS_CODEPAGE_775 is not set
  3305. +# CONFIG_NLS_CODEPAGE_850 is not set
  3306. +# CONFIG_NLS_CODEPAGE_852 is not set
  3307. +# CONFIG_NLS_CODEPAGE_855 is not set
  3308. +# CONFIG_NLS_CODEPAGE_857 is not set
  3309. +# CONFIG_NLS_CODEPAGE_860 is not set
  3310. +# CONFIG_NLS_CODEPAGE_861 is not set
  3311. +# CONFIG_NLS_CODEPAGE_862 is not set
  3312. +# CONFIG_NLS_CODEPAGE_863 is not set
  3313. +# CONFIG_NLS_CODEPAGE_864 is not set
  3314. +# CONFIG_NLS_CODEPAGE_865 is not set
  3315. +# CONFIG_NLS_CODEPAGE_866 is not set
  3316. +# CONFIG_NLS_CODEPAGE_869 is not set
  3317. +# CONFIG_NLS_CODEPAGE_936 is not set
  3318. +# CONFIG_NLS_CODEPAGE_950 is not set
  3319. +# CONFIG_NLS_CODEPAGE_932 is not set
  3320. +# CONFIG_NLS_CODEPAGE_949 is not set
  3321. +# CONFIG_NLS_CODEPAGE_874 is not set
  3322. +# CONFIG_NLS_ISO8859_8 is not set
  3323. +# CONFIG_NLS_CODEPAGE_1250 is not set
  3324. +# CONFIG_NLS_CODEPAGE_1251 is not set
  3325. +# CONFIG_NLS_ASCII is not set
  3326. +CONFIG_NLS_ISO8859_1=m
  3327. +# CONFIG_NLS_ISO8859_2 is not set
  3328. +# CONFIG_NLS_ISO8859_3 is not set
  3329. +# CONFIG_NLS_ISO8859_4 is not set
  3330. +# CONFIG_NLS_ISO8859_5 is not set
  3331. +# CONFIG_NLS_ISO8859_6 is not set
  3332. +# CONFIG_NLS_ISO8859_7 is not set
  3333. +# CONFIG_NLS_ISO8859_9 is not set
  3334. +# CONFIG_NLS_ISO8859_13 is not set
  3335. +# CONFIG_NLS_ISO8859_14 is not set
  3336. +# CONFIG_NLS_ISO8859_15 is not set
  3337. +# CONFIG_NLS_KOI8_R is not set
  3338. +# CONFIG_NLS_KOI8_U is not set
  3339. +CONFIG_NLS_UTF8=m
  3340. +# CONFIG_DLM is not set
  3341. +
  3342. +#
  3343. +# Kernel hacking
  3344. +#
  3345. +# CONFIG_PRINTK_TIME is not set
  3346. +CONFIG_ENABLE_WARN_DEPRECATED=y
  3347. +CONFIG_ENABLE_MUST_CHECK=y
  3348. +CONFIG_MAGIC_SYSRQ=y
  3349. +# CONFIG_UNUSED_SYMBOLS is not set
  3350. +CONFIG_DEBUG_FS=y
  3351. +# CONFIG_HEADERS_CHECK is not set
  3352. +CONFIG_DEBUG_KERNEL=y
  3353. +# CONFIG_DEBUG_SHIRQ is not set
  3354. +CONFIG_DETECT_SOFTLOCKUP=y
  3355. +CONFIG_SCHED_DEBUG=y
  3356. +# CONFIG_SCHEDSTATS is not set
  3357. +# CONFIG_TIMER_STATS is not set
  3358. +# CONFIG_SLUB_DEBUG_ON is not set
  3359. +# CONFIG_SLUB_STATS is not set
  3360. +# CONFIG_DEBUG_RT_MUTEXES is not set
  3361. +# CONFIG_RT_MUTEX_TESTER is not set
  3362. +# CONFIG_DEBUG_SPINLOCK is not set
  3363. +# CONFIG_DEBUG_MUTEXES is not set
  3364. +# CONFIG_DEBUG_LOCK_ALLOC is not set
  3365. +# CONFIG_PROVE_LOCKING is not set
  3366. +# CONFIG_LOCK_STAT is not set
  3367. +# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
  3368. +# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
  3369. +# CONFIG_DEBUG_KOBJECT is not set
  3370. +CONFIG_DEBUG_BUGVERBOSE=y
  3371. +# CONFIG_DEBUG_INFO is not set
  3372. +# CONFIG_DEBUG_VM is not set
  3373. +# CONFIG_DEBUG_LIST is not set
  3374. +# CONFIG_DEBUG_SG is not set
  3375. +CONFIG_FRAME_POINTER=y
  3376. +# CONFIG_BOOT_PRINTK_DELAY is not set
  3377. +# CONFIG_RCU_TORTURE_TEST is not set
  3378. +# CONFIG_KPROBES_SANITY_TEST is not set
  3379. +# CONFIG_BACKTRACE_SELF_TEST is not set
  3380. +# CONFIG_LKDTM is not set
  3381. +# CONFIG_FAULT_INJECTION is not set
  3382. +# CONFIG_SAMPLES is not set
  3383. +
  3384. +#
  3385. +# Security options
  3386. +#
  3387. +# CONFIG_KEYS is not set
  3388. +# CONFIG_SECURITY is not set
  3389. +# CONFIG_SECURITY_FILE_CAPABILITIES is not set
  3390. +CONFIG_CRYPTO=y
  3391. +CONFIG_CRYPTO_ALGAPI=m
  3392. +CONFIG_CRYPTO_AEAD=m
  3393. +CONFIG_CRYPTO_BLKCIPHER=m
  3394. +# CONFIG_CRYPTO_SEQIV is not set
  3395. +CONFIG_CRYPTO_HASH=m
  3396. +CONFIG_CRYPTO_MANAGER=m
  3397. +CONFIG_CRYPTO_HMAC=m
  3398. +# CONFIG_CRYPTO_XCBC is not set
  3399. +# CONFIG_CRYPTO_NULL is not set
  3400. +# CONFIG_CRYPTO_MD4 is not set
  3401. +CONFIG_CRYPTO_MD5=m
  3402. +CONFIG_CRYPTO_SHA1=m
  3403. +# CONFIG_CRYPTO_SHA256 is not set
  3404. +# CONFIG_CRYPTO_SHA512 is not set
  3405. +# CONFIG_CRYPTO_WP512 is not set
  3406. +# CONFIG_CRYPTO_TGR192 is not set
  3407. +# CONFIG_CRYPTO_GF128MUL is not set
  3408. +# CONFIG_CRYPTO_ECB is not set
  3409. +CONFIG_CRYPTO_CBC=m
  3410. +# CONFIG_CRYPTO_PCBC is not set
  3411. +# CONFIG_CRYPTO_LRW is not set
  3412. +# CONFIG_CRYPTO_XTS is not set
  3413. +# CONFIG_CRYPTO_CTR is not set
  3414. +# CONFIG_CRYPTO_GCM is not set
  3415. +# CONFIG_CRYPTO_CCM is not set
  3416. +# CONFIG_CRYPTO_CRYPTD is not set
  3417. +CONFIG_CRYPTO_DES=m
  3418. +# CONFIG_CRYPTO_FCRYPT is not set
  3419. +# CONFIG_CRYPTO_BLOWFISH is not set
  3420. +# CONFIG_CRYPTO_TWOFISH is not set
  3421. +# CONFIG_CRYPTO_SERPENT is not set
  3422. +# CONFIG_CRYPTO_AES is not set
  3423. +# CONFIG_CRYPTO_CAST5 is not set
  3424. +# CONFIG_CRYPTO_CAST6 is not set
  3425. +# CONFIG_CRYPTO_TEA is not set
  3426. +# CONFIG_CRYPTO_ARC4 is not set
  3427. +# CONFIG_CRYPTO_KHAZAD is not set
  3428. +# CONFIG_CRYPTO_ANUBIS is not set
  3429. +# CONFIG_CRYPTO_SEED is not set
  3430. +# CONFIG_CRYPTO_SALSA20 is not set
  3431. +CONFIG_CRYPTO_DEFLATE=m
  3432. +# CONFIG_CRYPTO_MICHAEL_MIC is not set
  3433. +# CONFIG_CRYPTO_CRC32C is not set
  3434. +# CONFIG_CRYPTO_CAMELLIA is not set
  3435. +# CONFIG_CRYPTO_TEST is not set
  3436. +CONFIG_CRYPTO_AUTHENC=m
  3437. +# CONFIG_CRYPTO_LZO is not set
  3438. +# CONFIG_CRYPTO_HW is not set
  3439. +
  3440. +#
  3441. +# Library routines
  3442. +#
  3443. +CONFIG_BITREVERSE=y
  3444. +CONFIG_CRC_CCITT=m
  3445. +# CONFIG_CRC16 is not set
  3446. +CONFIG_CRC_ITU_T=m
  3447. +CONFIG_CRC32=y
  3448. +CONFIG_CRC7=m
  3449. +# CONFIG_LIBCRC32C is not set
  3450. +CONFIG_ZLIB_INFLATE=y
  3451. +CONFIG_ZLIB_DEFLATE=y
  3452. +CONFIG_GENERIC_ALLOCATOR=y
  3453. +CONFIG_PLIST=y
  3454. +CONFIG_HAS_IOMEM=y
  3455. +CONFIG_HAS_IOPORT=y
  3456. +CONFIG_HAS_DMA=y
  3457. --- /dev/null
  3458. +++ b/arch/avr32/drivers/dw-dmac.c
  3459. @@ -0,0 +1,761 @@
  3460. +/*
  3461. + * Driver for the Synopsys DesignWare DMA Controller
  3462. + *
  3463. + * Copyright (C) 2005-2006 Atmel Corporation
  3464. + *
  3465. + * This program is free software; you can redistribute it and/or modify
  3466. + * it under the terms of the GNU General Public License version 2 as
  3467. + * published by the Free Software Foundation.
  3468. + */
  3469. +#include <linux/clk.h>
  3470. +#include <linux/device.h>
  3471. +#include <linux/dma-mapping.h>
  3472. +#include <linux/dmapool.h>
  3473. +#include <linux/init.h>
  3474. +#include <linux/interrupt.h>
  3475. +#include <linux/module.h>
  3476. +#include <linux/platform_device.h>
  3477. +
  3478. +#include <asm/dma-controller.h>
  3479. +#include <asm/io.h>
  3480. +
  3481. +#include "dw-dmac.h"
  3482. +
  3483. +#define DMAC_NR_CHANNELS 3
  3484. +#define DMAC_MAX_BLOCKSIZE 4095
  3485. +
  3486. +enum {
  3487. + CH_STATE_FREE = 0,
  3488. + CH_STATE_ALLOCATED,
  3489. + CH_STATE_BUSY,
  3490. +};
  3491. +
  3492. +struct dw_dma_lli {
  3493. + dma_addr_t sar;
  3494. + dma_addr_t dar;
  3495. + dma_addr_t llp;
  3496. + u32 ctllo;
  3497. + u32 ctlhi;
  3498. + u32 sstat;
  3499. + u32 dstat;
  3500. +};
  3501. +
  3502. +struct dw_dma_block {
  3503. + struct dw_dma_lli *lli_vaddr;
  3504. + dma_addr_t lli_dma_addr;
  3505. +};
  3506. +
  3507. +struct dw_dma_channel {
  3508. + unsigned int state;
  3509. + int is_cyclic;
  3510. + struct dma_request_sg *req_sg;
  3511. + struct dma_request_cyclic *req_cyclic;
  3512. + unsigned int nr_blocks;
  3513. + int direction;
  3514. + struct dw_dma_block *block;
  3515. +};
  3516. +
  3517. +struct dw_dma_controller {
  3518. + spinlock_t lock;
  3519. + void * __iomem regs;
  3520. + struct dma_pool *lli_pool;
  3521. + struct clk *hclk;
  3522. + struct dma_controller dma;
  3523. + struct dw_dma_channel channel[DMAC_NR_CHANNELS];
  3524. +};
  3525. +#define to_dw_dmac(dmac) container_of(dmac, struct dw_dma_controller, dma)
  3526. +
  3527. +#define dmac_writel_hi(dmac, reg, value) \
  3528. + __raw_writel((value), (dmac)->regs + DW_DMAC_##reg + 4)
  3529. +#define dmac_readl_hi(dmac, reg) \
  3530. + __raw_readl((dmac)->regs + DW_DMAC_##reg + 4)
  3531. +#define dmac_writel_lo(dmac, reg, value) \
  3532. + __raw_writel((value), (dmac)->regs + DW_DMAC_##reg)
  3533. +#define dmac_readl_lo(dmac, reg) \
  3534. + __raw_readl((dmac)->regs + DW_DMAC_##reg)
  3535. +#define dmac_chan_writel_hi(dmac, chan, reg, value) \
  3536. + __raw_writel((value), ((dmac)->regs + 0x58 * (chan) \
  3537. + + DW_DMAC_CHAN_##reg + 4))
  3538. +#define dmac_chan_readl_hi(dmac, chan, reg) \
  3539. + __raw_readl((dmac)->regs + 0x58 * (chan) + DW_DMAC_CHAN_##reg + 4)
  3540. +#define dmac_chan_writel_lo(dmac, chan, reg, value) \
  3541. + __raw_writel((value), (dmac)->regs + 0x58 * (chan) + DW_DMAC_CHAN_##reg)
  3542. +#define dmac_chan_readl_lo(dmac, chan, reg) \
  3543. + __raw_readl((dmac)->regs + 0x58 * (chan) + DW_DMAC_CHAN_##reg)
  3544. +#define set_channel_bit(dmac, reg, chan) \
  3545. + dmac_writel_lo(dmac, reg, (1 << (chan)) | (1 << ((chan) + 8)))
  3546. +#define clear_channel_bit(dmac, reg, chan) \
  3547. + dmac_writel_lo(dmac, reg, (0 << (chan)) | (1 << ((chan) + 8)))
  3548. +
  3549. +static int dmac_alloc_channel(struct dma_controller *_dmac)
  3550. +{
  3551. + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
  3552. + struct dw_dma_channel *chan;
  3553. + unsigned long flags;
  3554. + int i;
  3555. +
  3556. + spin_lock_irqsave(&dmac->lock, flags);
  3557. + for (i = 0; i < DMAC_NR_CHANNELS; i++)
  3558. + if (dmac->channel[i].state == CH_STATE_FREE)
  3559. + break;
  3560. +
  3561. + if (i < DMAC_NR_CHANNELS) {
  3562. + chan = &dmac->channel[i];
  3563. + chan->state = CH_STATE_ALLOCATED;
  3564. + } else {
  3565. + i = -EBUSY;
  3566. + }
  3567. +
  3568. + spin_unlock_irqrestore(&dmac->lock, flags);
  3569. +
  3570. + return i;
  3571. +}
  3572. +
  3573. +static void dmac_release_channel(struct dma_controller *_dmac, int channel)
  3574. +{
  3575. + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
  3576. +
  3577. + BUG_ON(channel >= DMAC_NR_CHANNELS
  3578. + || dmac->channel[channel].state != CH_STATE_ALLOCATED);
  3579. +
  3580. + dmac->channel[channel].state = CH_STATE_FREE;
  3581. +}
  3582. +
  3583. +static struct dw_dma_block *allocate_blocks(struct dw_dma_controller *dmac,
  3584. + unsigned int nr_blocks)
  3585. +{
  3586. + struct dw_dma_block *block;
  3587. + void *p;
  3588. + unsigned int i;
  3589. +
  3590. + block = kmalloc(nr_blocks * sizeof(*block),
  3591. + GFP_KERNEL);
  3592. + if (unlikely(!block))
  3593. + return NULL;
  3594. +
  3595. + for (i = 0; i < nr_blocks; i++) {
  3596. + p = dma_pool_alloc(dmac->lli_pool, GFP_KERNEL,
  3597. + &block[i].lli_dma_addr);
  3598. + block[i].lli_vaddr = p;
  3599. + if (unlikely(!p))
  3600. + goto fail;
  3601. + }
  3602. +
  3603. + return block;
  3604. +
  3605. +fail:
  3606. + for (i = 0; i < nr_blocks; i++) {
  3607. + if (!block[i].lli_vaddr)
  3608. + break;
  3609. + dma_pool_free(dmac->lli_pool, block[i].lli_vaddr,
  3610. + block[i].lli_dma_addr);
  3611. + }
  3612. + kfree(block);
  3613. + return NULL;
  3614. +}
  3615. +
  3616. +static void cleanup_channel(struct dw_dma_controller *dmac,
  3617. + struct dw_dma_channel *chan)
  3618. +{
  3619. + unsigned int i;
  3620. +
  3621. + if (chan->nr_blocks > 1) {
  3622. + for (i = 0; i < chan->nr_blocks; i++)
  3623. + dma_pool_free(dmac->lli_pool, chan->block[i].lli_vaddr,
  3624. + chan->block[i].lli_dma_addr);
  3625. + kfree(chan->block);
  3626. + }
  3627. +
  3628. + chan->state = CH_STATE_ALLOCATED;
  3629. +}
  3630. +
  3631. +static int dmac_prepare_request_sg(struct dma_controller *_dmac,
  3632. + struct dma_request_sg *req)
  3633. +{
  3634. + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
  3635. + struct dw_dma_channel *chan;
  3636. + unsigned long ctlhi, ctllo, cfghi, cfglo;
  3637. + unsigned long block_size;
  3638. + unsigned int nr_blocks;
  3639. + int ret, i, direction;
  3640. + unsigned long flags;
  3641. +
  3642. + spin_lock_irqsave(&dmac->lock, flags);
  3643. +
  3644. + ret = -EINVAL;
  3645. + if (req->req.channel >= DMAC_NR_CHANNELS
  3646. + || dmac->channel[req->req.channel].state != CH_STATE_ALLOCATED
  3647. + || req->block_size > DMAC_MAX_BLOCKSIZE) {
  3648. + spin_unlock_irqrestore(&dmac->lock, flags);
  3649. + return -EINVAL;
  3650. + }
  3651. +
  3652. + chan = &dmac->channel[req->req.channel];
  3653. + chan->state = CH_STATE_BUSY;
  3654. + chan->req_sg = req;
  3655. + chan->is_cyclic = 0;
  3656. +
  3657. + /*
  3658. + * We have marked the channel as busy, so no need to keep the
  3659. + * lock as long as we only touch the channel-specific
  3660. + * registers
  3661. + */
  3662. + spin_unlock_irqrestore(&dmac->lock, flags);
  3663. +
  3664. + /*
  3665. + * There may be limitations in the driver and/or the DMA
  3666. + * controller that prevents us from sending a whole
  3667. + * scatterlist item in one go. Taking this into account,
  3668. + * calculate the number of block transfers we need to set up.
  3669. + *
  3670. + * FIXME: Let the peripheral driver know about the maximum
  3671. + * block size we support. We really don't want to use a
  3672. + * different block size than what was suggested by the
  3673. + * peripheral.
  3674. + *
  3675. + * Each block will get its own Linked List Item (LLI) below.
  3676. + */
  3677. + block_size = req->block_size;
  3678. + nr_blocks = req->nr_blocks;
  3679. + pr_debug("block_size %lu, nr_blocks %u nr_sg = %u\n",
  3680. + block_size, nr_blocks, req->nr_sg);
  3681. +
  3682. + BUG_ON(nr_blocks == 0);
  3683. + chan->nr_blocks = nr_blocks;
  3684. +
  3685. + ret = -EINVAL;
  3686. + cfglo = cfghi = 0;
  3687. + switch (req->direction) {
  3688. + case DMA_DIR_MEM_TO_PERIPH:
  3689. + direction = DMA_TO_DEVICE;
  3690. + cfghi = req->periph_id << (43 - 32);
  3691. + break;
  3692. +
  3693. + case DMA_DIR_PERIPH_TO_MEM:
  3694. + direction = DMA_FROM_DEVICE;
  3695. + cfghi = req->periph_id << (39 - 32);
  3696. + break;
  3697. + default:
  3698. + goto out_unclaim_channel;
  3699. + }
  3700. +
  3701. + chan->direction = direction;
  3702. +
  3703. + dmac_chan_writel_hi(dmac, req->req.channel, CFG, cfghi);
  3704. + dmac_chan_writel_lo(dmac, req->req.channel, CFG, cfglo);
  3705. +
  3706. + ctlhi = block_size >> req->width;
  3707. + ctllo = ((req->direction << 20)
  3708. + // | (1 << 14) | (1 << 11) // source/dest burst trans len
  3709. + | (req->width << 4) | (req->width << 1)
  3710. + | (1 << 0)); // interrupt enable
  3711. +
  3712. + if (nr_blocks == 1) {
  3713. + /* Only one block: No need to use block chaining */
  3714. + if (direction == DMA_TO_DEVICE) {
  3715. + dmac_chan_writel_lo(dmac, req->req.channel, SAR,
  3716. + req->sg->dma_address);
  3717. + dmac_chan_writel_lo(dmac, req->req.channel, DAR,
  3718. + req->data_reg);
  3719. + ctllo |= 2 << 7; // no dst increment
  3720. + } else {
  3721. + dmac_chan_writel_lo(dmac, req->req.channel, SAR,
  3722. + req->data_reg);
  3723. + dmac_chan_writel_lo(dmac, req->req.channel, DAR,
  3724. + req->sg->dma_address);
  3725. + ctllo |= 2 << 9; // no src increment
  3726. + }
  3727. + dmac_chan_writel_lo(dmac, req->req.channel, CTL, ctllo);
  3728. + dmac_chan_writel_hi(dmac, req->req.channel, CTL, ctlhi);
  3729. + pr_debug("ctl hi:lo 0x%lx:%lx\n", ctlhi, ctllo);
  3730. + } else {
  3731. + struct dw_dma_lli *lli, *lli_prev = NULL;
  3732. + int j = 0, offset = 0;
  3733. +
  3734. + ret = -ENOMEM;
  3735. + chan->block = allocate_blocks(dmac, nr_blocks);
  3736. + if (!chan->block)
  3737. + goto out_unclaim_channel;
  3738. +
  3739. + if (direction == DMA_TO_DEVICE)
  3740. + ctllo |= 1 << 28 | 1 << 27 | 2 << 7;
  3741. + else
  3742. + ctllo |= 1 << 28 | 1 << 27 | 2 << 9;
  3743. +
  3744. + /*
  3745. + * Map scatterlist items to blocks. One scatterlist
  3746. + * item may need more than one block for the reasons
  3747. + * mentioned above.
  3748. + */
  3749. + for (i = 0; i < nr_blocks; i++) {
  3750. + lli = chan->block[i].lli_vaddr;
  3751. + if (lli_prev) {
  3752. + lli_prev->llp = chan->block[i].lli_dma_addr;
  3753. + pr_debug("lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
  3754. + i - 1, chan->block[i - 1].lli_vaddr,
  3755. + chan->block[i - 1].lli_dma_addr,
  3756. + lli_prev->sar, lli_prev->dar, lli_prev->llp,
  3757. + lli_prev->ctllo, lli_prev->ctlhi);
  3758. + }
  3759. + lli->llp = 0;
  3760. + lli->ctllo = ctllo;
  3761. + lli->ctlhi = ctlhi;
  3762. + if (direction == DMA_TO_DEVICE) {
  3763. + lli->sar = req->sg[j].dma_address + offset;
  3764. + lli->dar = req->data_reg;
  3765. + } else {
  3766. + lli->sar = req->data_reg;
  3767. + lli->dar = req->sg[j].dma_address + offset;
  3768. + }
  3769. + lli_prev = lli;
  3770. +
  3771. + offset += block_size;
  3772. + if (offset > req->sg[j].length) {
  3773. + j++;
  3774. + offset = 0;
  3775. + }
  3776. + }
  3777. +
  3778. + pr_debug("lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
  3779. + i - 1, chan->block[i - 1].lli_vaddr,
  3780. + chan->block[i - 1].lli_dma_addr, lli_prev->sar,
  3781. + lli_prev->dar, lli_prev->llp,
  3782. + lli_prev->ctllo, lli_prev->ctlhi);
  3783. +
  3784. + /*
  3785. + * SAR, DAR and CTL are initialized from the LLI. We
  3786. + * only have to enable the LLI bits in CTL.
  3787. + */
  3788. + dmac_chan_writel_hi(dmac, req->req.channel, CTL, 0);
  3789. + dmac_chan_writel_lo(dmac, req->req.channel, LLP,
  3790. + chan->block[0].lli_dma_addr);
  3791. + dmac_chan_writel_lo(dmac, req->req.channel, CTL, 1 << 28 | 1 << 27);
  3792. + }
  3793. +
  3794. + set_channel_bit(dmac, MASK_XFER, req->req.channel);
  3795. + set_channel_bit(dmac, MASK_ERROR, req->req.channel);
  3796. + if (req->req.block_complete)
  3797. + set_channel_bit(dmac, MASK_BLOCK, req->req.channel);
  3798. + else
  3799. + clear_channel_bit(dmac, MASK_BLOCK, req->req.channel);
  3800. +
  3801. + return 0;
  3802. +
  3803. +out_unclaim_channel:
  3804. + chan->state = CH_STATE_ALLOCATED;
  3805. + return ret;
  3806. +}
  3807. +
  3808. +static int dmac_prepare_request_cyclic(struct dma_controller *_dmac,
  3809. + struct dma_request_cyclic *req)
  3810. +{
  3811. + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
  3812. + struct dw_dma_channel *chan;
  3813. + unsigned long ctlhi, ctllo, cfghi, cfglo;
  3814. + unsigned long block_size;
  3815. + int ret, i, direction;
  3816. + unsigned long flags;
  3817. +
  3818. + spin_lock_irqsave(&dmac->lock, flags);
  3819. +
  3820. + block_size = (req->buffer_size/req->periods) >> req->width;
  3821. +
  3822. + ret = -EINVAL;
  3823. + if (req->req.channel >= DMAC_NR_CHANNELS
  3824. + || dmac->channel[req->req.channel].state != CH_STATE_ALLOCATED
  3825. + || (req->periods == 0)
  3826. + || block_size > DMAC_MAX_BLOCKSIZE) {
  3827. + spin_unlock_irqrestore(&dmac->lock, flags);
  3828. + return -EINVAL;
  3829. + }
  3830. +
  3831. + chan = &dmac->channel[req->req.channel];
  3832. + chan->state = CH_STATE_BUSY;
  3833. + chan->is_cyclic = 1;
  3834. + chan->req_cyclic = req;
  3835. +
  3836. + /*
  3837. + * We have marked the channel as busy, so no need to keep the
  3838. + * lock as long as we only touch the channel-specific
  3839. + * registers
  3840. + */
  3841. + spin_unlock_irqrestore(&dmac->lock, flags);
  3842. +
  3843. + /*
  3844. + Setup
  3845. + */
  3846. + BUG_ON(req->buffer_size % req->periods);
  3847. + /* printk(KERN_INFO "block_size = %lu, periods = %u\n", block_size, req->periods); */
  3848. +
  3849. + chan->nr_blocks = req->periods;
  3850. +
  3851. + ret = -EINVAL;
  3852. + cfglo = cfghi = 0;
  3853. + switch (req->direction) {
  3854. + case DMA_DIR_MEM_TO_PERIPH:
  3855. + direction = DMA_TO_DEVICE;
  3856. + cfghi = req->periph_id << (43 - 32);
  3857. + break;
  3858. +
  3859. + case DMA_DIR_PERIPH_TO_MEM:
  3860. + direction = DMA_FROM_DEVICE;
  3861. + cfghi = req->periph_id << (39 - 32);
  3862. + break;
  3863. + default:
  3864. + goto out_unclaim_channel;
  3865. + }
  3866. +
  3867. + chan->direction = direction;
  3868. +
  3869. + dmac_chan_writel_hi(dmac, req->req.channel, CFG, cfghi);
  3870. + dmac_chan_writel_lo(dmac, req->req.channel, CFG, cfglo);
  3871. +
  3872. + ctlhi = block_size;
  3873. + ctllo = ((req->direction << 20)
  3874. + | (req->width << 4) | (req->width << 1)
  3875. + | (1 << 0)); // interrupt enable
  3876. +
  3877. + {
  3878. + struct dw_dma_lli *lli = NULL, *lli_prev = NULL;
  3879. +
  3880. + ret = -ENOMEM;
  3881. + chan->block = allocate_blocks(dmac, req->periods);
  3882. + if (!chan->block)
  3883. + goto out_unclaim_channel;
  3884. +
  3885. + if (direction == DMA_TO_DEVICE)
  3886. + ctllo |= 1 << 28 | 1 << 27 | 2 << 7;
  3887. + else
  3888. + ctllo |= 1 << 28 | 1 << 27 | 2 << 9;
  3889. +
  3890. + /*
  3891. + * Set up a linked list items where each period gets
  3892. + * an item. The linked list item for the last period
  3893. + * points back to the star of the buffer making a
  3894. + * cyclic buffer.
  3895. + */
  3896. + for (i = 0; i < req->periods; i++) {
  3897. + lli = chan->block[i].lli_vaddr;
  3898. + if (lli_prev) {
  3899. + lli_prev->llp = chan->block[i].lli_dma_addr;
  3900. + /* printk(KERN_INFO "lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
  3901. + i - 1, chan->block[i - 1].lli_vaddr,
  3902. + chan->block[i - 1].lli_dma_addr,
  3903. + lli_prev->sar, lli_prev->dar, lli_prev->llp,
  3904. + lli_prev->ctllo, lli_prev->ctlhi);*/
  3905. + }
  3906. + lli->llp = 0;
  3907. + lli->ctllo = ctllo;
  3908. + lli->ctlhi = ctlhi;
  3909. + if (direction == DMA_TO_DEVICE) {
  3910. + lli->sar = req->buffer_start + i*(block_size << req->width);
  3911. + lli->dar = req->data_reg;
  3912. + } else {
  3913. + lli->sar = req->data_reg;
  3914. + lli->dar = req->buffer_start + i*(block_size << req->width);
  3915. + }
  3916. + lli_prev = lli;
  3917. + }
  3918. + lli->llp = chan->block[0].lli_dma_addr;
  3919. +
  3920. + /*printk(KERN_INFO "lli[%d] (0x%p/0x%x): 0x%x 0x%x 0x%x 0x%x 0x%x\n",
  3921. + i - 1, chan->block[i - 1].lli_vaddr,
  3922. + chan->block[i - 1].lli_dma_addr, lli_prev->sar,
  3923. + lli_prev->dar, lli_prev->llp,
  3924. + lli_prev->ctllo, lli_prev->ctlhi); */
  3925. +
  3926. + /*
  3927. + * SAR, DAR and CTL are initialized from the LLI. We
  3928. + * only have to enable the LLI bits in CTL.
  3929. + */
  3930. + dmac_chan_writel_lo(dmac, req->req.channel, LLP,
  3931. + chan->block[0].lli_dma_addr);
  3932. + dmac_chan_writel_lo(dmac, req->req.channel, CTL, 1 << 28 | 1 << 27);
  3933. + }
  3934. +
  3935. + clear_channel_bit(dmac, MASK_XFER, req->req.channel);
  3936. + set_channel_bit(dmac, MASK_ERROR, req->req.channel);
  3937. + if (req->req.block_complete)
  3938. + set_channel_bit(dmac, MASK_BLOCK, req->req.channel);
  3939. + else
  3940. + clear_channel_bit(dmac, MASK_BLOCK, req->req.channel);
  3941. +
  3942. + return 0;
  3943. +
  3944. +out_unclaim_channel:
  3945. + chan->state = CH_STATE_ALLOCATED;
  3946. + return ret;
  3947. +}
  3948. +
  3949. +static int dmac_start_request(struct dma_controller *_dmac,
  3950. + unsigned int channel)
  3951. +{
  3952. + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
  3953. +
  3954. + BUG_ON(channel >= DMAC_NR_CHANNELS);
  3955. +
  3956. + set_channel_bit(dmac, CH_EN, channel);
  3957. +
  3958. + return 0;
  3959. +}
  3960. +
  3961. +static dma_addr_t dmac_get_current_pos(struct dma_controller *_dmac,
  3962. + unsigned int channel)
  3963. +{
  3964. + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
  3965. + struct dw_dma_channel *chan;
  3966. + dma_addr_t current_pos;
  3967. +
  3968. + BUG_ON(channel >= DMAC_NR_CHANNELS);
  3969. +
  3970. + chan = &dmac->channel[channel];
  3971. +
  3972. + switch (chan->direction) {
  3973. + case DMA_TO_DEVICE:
  3974. + current_pos = dmac_chan_readl_lo(dmac, channel, SAR);
  3975. + break;
  3976. + case DMA_FROM_DEVICE:
  3977. + current_pos = dmac_chan_readl_lo(dmac, channel, DAR);
  3978. + break;
  3979. + default:
  3980. + return 0;
  3981. + }
  3982. +
  3983. +
  3984. + if (!current_pos) {
  3985. + if (chan->is_cyclic) {
  3986. + current_pos = chan->req_cyclic->buffer_start;
  3987. + } else {
  3988. + current_pos = chan->req_sg->sg->dma_address;
  3989. + }
  3990. + }
  3991. +
  3992. + return current_pos;
  3993. +}
  3994. +
  3995. +
  3996. +static int dmac_stop_request(struct dma_controller *_dmac,
  3997. + unsigned int channel)
  3998. +{
  3999. + struct dw_dma_controller *dmac = to_dw_dmac(_dmac);
  4000. + struct dw_dma_channel *chan;
  4001. +
  4002. + BUG_ON(channel >= DMAC_NR_CHANNELS);
  4003. +
  4004. + chan = &dmac->channel[channel];
  4005. + pr_debug("stop: st%u s%08x d%08x l%08x ctl0x%08x:0x%08x\n",
  4006. + chan->state, dmac_chan_readl_lo(dmac, channel, SAR),
  4007. + dmac_chan_readl_lo(dmac, channel, DAR),
  4008. + dmac_chan_readl_lo(dmac, channel, LLP),
  4009. + dmac_chan_readl_hi(dmac, channel, CTL),
  4010. + dmac_chan_readl_lo(dmac, channel, CTL));
  4011. +
  4012. + if (chan->state == CH_STATE_BUSY) {
  4013. + clear_channel_bit(dmac, CH_EN, channel);
  4014. + cleanup_channel(dmac, &dmac->channel[channel]);
  4015. + }
  4016. +
  4017. + return 0;
  4018. +}
  4019. +
  4020. +
  4021. +static void dmac_block_complete(struct dw_dma_controller *dmac)
  4022. +{
  4023. + struct dw_dma_channel *chan;
  4024. + unsigned long status, chanid;
  4025. +
  4026. + status = dmac_readl_lo(dmac, STATUS_BLOCK);
  4027. +
  4028. + while (status) {
  4029. + struct dma_request *req;
  4030. + chanid = __ffs(status);
  4031. + chan = &dmac->channel[chanid];
  4032. +
  4033. + if (chan->is_cyclic) {
  4034. + BUG_ON(!chan->req_cyclic
  4035. + || !chan->req_cyclic->req.block_complete);
  4036. + req = &chan->req_cyclic->req;
  4037. + } else {
  4038. + BUG_ON(!chan->req_sg || !chan->req_sg->req.block_complete);
  4039. + req = &chan->req_sg->req;
  4040. + }
  4041. + dmac_writel_lo(dmac, CLEAR_BLOCK, 1 << chanid);
  4042. + req->block_complete(req);
  4043. + status = dmac_readl_lo(dmac, STATUS_BLOCK);
  4044. + }
  4045. +}
  4046. +
  4047. +static void dmac_xfer_complete(struct dw_dma_controller *dmac)
  4048. +{
  4049. + struct dw_dma_channel *chan;
  4050. + struct dma_request *req;
  4051. + unsigned long status, chanid;
  4052. +
  4053. + status = dmac_readl_lo(dmac, STATUS_XFER);
  4054. +
  4055. + while (status) {
  4056. + chanid = __ffs(status);
  4057. + chan = &dmac->channel[chanid];
  4058. +
  4059. + dmac_writel_lo(dmac, CLEAR_XFER, 1 << chanid);
  4060. +
  4061. + req = &chan->req_sg->req;
  4062. + BUG_ON(!req);
  4063. + cleanup_channel(dmac, chan);
  4064. + if (req->xfer_complete)
  4065. + req->xfer_complete(req);
  4066. +
  4067. + status = dmac_readl_lo(dmac, STATUS_XFER);
  4068. + }
  4069. +}
  4070. +
  4071. +static void dmac_error(struct dw_dma_controller *dmac)
  4072. +{
  4073. + struct dw_dma_channel *chan;
  4074. + unsigned long status, chanid;
  4075. +
  4076. + status = dmac_readl_lo(dmac, STATUS_ERROR);
  4077. +
  4078. + while (status) {
  4079. + struct dma_request *req;
  4080. +
  4081. + chanid = __ffs(status);
  4082. + chan = &dmac->channel[chanid];
  4083. +
  4084. + dmac_writel_lo(dmac, CLEAR_ERROR, 1 << chanid);
  4085. + clear_channel_bit(dmac, CH_EN, chanid);
  4086. +
  4087. + if (chan->is_cyclic) {
  4088. + BUG_ON(!chan->req_cyclic);
  4089. + req = &chan->req_cyclic->req;
  4090. + } else {
  4091. + BUG_ON(!chan->req_sg);
  4092. + req = &chan->req_sg->req;
  4093. + }
  4094. +
  4095. + cleanup_channel(dmac, chan);
  4096. + if (req->error)
  4097. + req->error(req);
  4098. +
  4099. + status = dmac_readl_lo(dmac, STATUS_XFER);
  4100. + }
  4101. +}
  4102. +
  4103. +static irqreturn_t dmac_interrupt(int irq, void *dev_id)
  4104. +{
  4105. + struct dw_dma_controller *dmac = dev_id;
  4106. + unsigned long status;
  4107. + int ret = IRQ_NONE;
  4108. +
  4109. + spin_lock(&dmac->lock);
  4110. +
  4111. + status = dmac_readl_lo(dmac, STATUS_INT);
  4112. +
  4113. + while (status) {
  4114. + ret = IRQ_HANDLED;
  4115. + if (status & 0x10)
  4116. + dmac_error(dmac);
  4117. + if (status & 0x02)
  4118. + dmac_block_complete(dmac);
  4119. + if (status & 0x01)
  4120. + dmac_xfer_complete(dmac);
  4121. +
  4122. + status = dmac_readl_lo(dmac, STATUS_INT);
  4123. + }
  4124. +
  4125. + spin_unlock(&dmac->lock);
  4126. + return ret;
  4127. +}
  4128. +
  4129. +static int __devinit dmac_probe(struct platform_device *pdev)
  4130. +{
  4131. + struct dw_dma_controller *dmac;
  4132. + struct resource *regs;
  4133. + int ret;
  4134. +
  4135. + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  4136. + if (!regs)
  4137. + return -ENXIO;
  4138. +
  4139. + dmac = kmalloc(sizeof(*dmac), GFP_KERNEL);
  4140. + if (!dmac)
  4141. + return -ENOMEM;
  4142. + memset(dmac, 0, sizeof(*dmac));
  4143. +
  4144. + dmac->hclk = clk_get(&pdev->dev, "hclk");
  4145. + if (IS_ERR(dmac->hclk)) {
  4146. + ret = PTR_ERR(dmac->hclk);
  4147. + goto out_free_dmac;
  4148. + }
  4149. + clk_enable(dmac->hclk);
  4150. +
  4151. + ret = -ENOMEM;
  4152. + dmac->lli_pool = dma_pool_create("dmac", &pdev->dev,
  4153. + sizeof(struct dw_dma_lli), 4, 0);
  4154. + if (!dmac->lli_pool)
  4155. + goto out_disable_clk;
  4156. +
  4157. + spin_lock_init(&dmac->lock);
  4158. + dmac->dma.dev = &pdev->dev;
  4159. + dmac->dma.alloc_channel = dmac_alloc_channel;
  4160. + dmac->dma.release_channel = dmac_release_channel;
  4161. + dmac->dma.prepare_request_sg = dmac_prepare_request_sg;
  4162. + dmac->dma.prepare_request_cyclic = dmac_prepare_request_cyclic;
  4163. + dmac->dma.start_request = dmac_start_request;
  4164. + dmac->dma.stop_request = dmac_stop_request;
  4165. + dmac->dma.get_current_pos = dmac_get_current_pos;
  4166. +
  4167. + dmac->regs = ioremap(regs->start, regs->end - regs->start + 1);
  4168. + if (!dmac->regs)
  4169. + goto out_free_pool;
  4170. +
  4171. + ret = request_irq(platform_get_irq(pdev, 0), dmac_interrupt,
  4172. + IRQF_SAMPLE_RANDOM, pdev->name, dmac);
  4173. + if (ret)
  4174. + goto out_unmap_regs;
  4175. +
  4176. + /* Enable the DMA controller */
  4177. + dmac_writel_lo(dmac, CFG, 1);
  4178. +
  4179. + register_dma_controller(&dmac->dma);
  4180. +
  4181. + printk(KERN_INFO
  4182. + "dmac%d: DesignWare DMA controller at 0x%p irq %d\n",
  4183. + dmac->dma.id, dmac->regs, platform_get_irq(pdev, 0));
  4184. +
  4185. + return 0;
  4186. +
  4187. +out_unmap_regs:
  4188. + iounmap(dmac->regs);
  4189. +out_free_pool:
  4190. + dma_pool_destroy(dmac->lli_pool);
  4191. +out_disable_clk:
  4192. + clk_disable(dmac->hclk);
  4193. + clk_put(dmac->hclk);
  4194. +out_free_dmac:
  4195. + kfree(dmac);
  4196. + return ret;
  4197. +}
  4198. +
  4199. +static struct platform_driver dmac_driver = {
  4200. + .probe = dmac_probe,
  4201. + .driver = {
  4202. + .name = "dmaca",
  4203. + },
  4204. +};
  4205. +
  4206. +static int __init dmac_init(void)
  4207. +{
  4208. + return platform_driver_register(&dmac_driver);
  4209. +}
  4210. +subsys_initcall(dmac_init);
  4211. +
  4212. +static void __exit dmac_exit(void)
  4213. +{
  4214. + platform_driver_unregister(&dmac_driver);
  4215. +}
  4216. +module_exit(dmac_exit);
  4217. +
  4218. +MODULE_DESCRIPTION("Synopsys DesignWare DMA Controller driver");
  4219. +MODULE_AUTHOR("Haavard Skinnemoen <[email protected]>");
  4220. +MODULE_LICENSE("GPL");
  4221. --- /dev/null
  4222. +++ b/arch/avr32/drivers/dw-dmac.h
  4223. @@ -0,0 +1,42 @@
  4224. +/*
  4225. + * Driver for the Synopsys DesignWare DMA Controller
  4226. + *
  4227. + * Copyright (C) 2005-2006 Atmel Corporation
  4228. + *
  4229. + * This program is free software; you can redistribute it and/or modify
  4230. + * it under the terms of the GNU General Public License version 2 as
  4231. + * published by the Free Software Foundation.
  4232. + */
  4233. +#ifndef __AVR32_DW_DMAC_H__
  4234. +#define __AVR32_DW_DMAC_H__
  4235. +
  4236. +#define DW_DMAC_CFG 0x398
  4237. +#define DW_DMAC_CH_EN 0x3a0
  4238. +
  4239. +#define DW_DMAC_STATUS_XFER 0x2e8
  4240. +#define DW_DMAC_STATUS_BLOCK 0x2f0
  4241. +#define DW_DMAC_STATUS_ERROR 0x308
  4242. +
  4243. +#define DW_DMAC_MASK_XFER 0x310
  4244. +#define DW_DMAC_MASK_BLOCK 0x318
  4245. +#define DW_DMAC_MASK_ERROR 0x330
  4246. +
  4247. +#define DW_DMAC_CLEAR_XFER 0x338
  4248. +#define DW_DMAC_CLEAR_BLOCK 0x340
  4249. +#define DW_DMAC_CLEAR_ERROR 0x358
  4250. +
  4251. +#define DW_DMAC_STATUS_INT 0x360
  4252. +
  4253. +#define DW_DMAC_CHAN_SAR 0x000
  4254. +#define DW_DMAC_CHAN_DAR 0x008
  4255. +#define DW_DMAC_CHAN_LLP 0x010
  4256. +#define DW_DMAC_CHAN_CTL 0x018
  4257. +#define DW_DMAC_CHAN_SSTAT 0x020
  4258. +#define DW_DMAC_CHAN_DSTAT 0x028
  4259. +#define DW_DMAC_CHAN_SSTATAR 0x030
  4260. +#define DW_DMAC_CHAN_DSTATAR 0x038
  4261. +#define DW_DMAC_CHAN_CFG 0x040
  4262. +#define DW_DMAC_CHAN_SGR 0x048
  4263. +#define DW_DMAC_CHAN_DSR 0x050
  4264. +
  4265. +#endif /* __AVR32_DW_DMAC_H__ */
  4266. --- /dev/null
  4267. +++ b/arch/avr32/drivers/Makefile
  4268. @@ -0,0 +1 @@
  4269. +obj-$(CONFIG_DW_DMAC) += dw-dmac.o
  4270. --- a/arch/avr32/Kconfig
  4271. +++ b/arch/avr32/Kconfig
  4272. @@ -47,6 +47,9 @@
  4273. config GENERIC_TIME
  4274. def_bool y
  4275. +config GENERIC_CLOCKEVENTS
  4276. + def_bool y
  4277. +
  4278. config RWSEM_XCHGADD_ALGORITHM
  4279. def_bool n
  4280. @@ -70,6 +73,8 @@
  4281. menu "System Type and features"
  4282. +source "kernel/time/Kconfig"
  4283. +
  4284. config SUBARCH_AVR32B
  4285. bool
  4286. config MMU
  4287. @@ -83,6 +88,7 @@
  4288. select MMU
  4289. select PERFORMANCE_COUNTERS
  4290. select HAVE_GPIO_LIB
  4291. + select GENERIC_ALLOCATOR
  4292. #
  4293. # CPU types
  4294. @@ -117,6 +123,9 @@
  4295. if BOARD_ATSTK1000
  4296. source "arch/avr32/boards/atstk1000/Kconfig"
  4297. endif
  4298. +if BOARD_ATNGW100
  4299. +source "arch/avr32/boards/atngw100/Kconfig"
  4300. +endif
  4301. choice
  4302. prompt "Boot loader type"
  4303. @@ -180,6 +189,10 @@
  4304. be dumped to the console when a Non-Maskable Interrupt
  4305. happens.
  4306. +config DW_DMAC
  4307. + tristate "Synopsys DesignWare DMA Controller support"
  4308. + default y if CPU_AT32AP7000
  4309. +
  4310. # FPU emulation goes here
  4311. source "kernel/Kconfig.hz"
  4312. @@ -196,6 +209,11 @@
  4313. menu "Power management options"
  4314. +config ARCH_SUSPEND_POSSIBLE
  4315. + def_bool y
  4316. +
  4317. +source "kernel/power/Kconfig"
  4318. +
  4319. menu "CPU Frequency scaling"
  4320. source "drivers/cpufreq/Kconfig"
  4321. --- a/arch/avr32/kernel/avr32_ksyms.c
  4322. +++ b/arch/avr32/kernel/avr32_ksyms.c
  4323. @@ -29,7 +29,9 @@
  4324. */
  4325. EXPORT_SYMBOL(memset);
  4326. EXPORT_SYMBOL(memcpy);
  4327. +
  4328. EXPORT_SYMBOL(clear_page);
  4329. +EXPORT_SYMBOL(copy_page);
  4330. /*
  4331. * Userspace access stuff.
  4332. @@ -41,6 +43,8 @@
  4333. EXPORT_SYMBOL(__strncpy_from_user);
  4334. EXPORT_SYMBOL(clear_user);
  4335. EXPORT_SYMBOL(__clear_user);
  4336. +EXPORT_SYMBOL(strnlen_user);
  4337. +
  4338. EXPORT_SYMBOL(csum_partial);
  4339. EXPORT_SYMBOL(csum_partial_copy_generic);
  4340. --- /dev/null
  4341. +++ b/arch/avr32/kernel/dma-controller.c
  4342. @@ -0,0 +1,34 @@
  4343. +/*
  4344. + * Preliminary DMA controller framework for AVR32
  4345. + *
  4346. + * Copyright (C) 2005-2006 Atmel Corporation
  4347. + *
  4348. + * This program is free software; you can redistribute it and/or modify
  4349. + * it under the terms of the GNU General Public License version 2 as
  4350. + * published by the Free Software Foundation.
  4351. + */
  4352. +#include <asm/dma-controller.h>
  4353. +
  4354. +static LIST_HEAD(controllers);
  4355. +
  4356. +int register_dma_controller(struct dma_controller *dmac)
  4357. +{
  4358. + static int next_id;
  4359. +
  4360. + dmac->id = next_id++;
  4361. + list_add_tail(&dmac->list, &controllers);
  4362. +
  4363. + return 0;
  4364. +}
  4365. +EXPORT_SYMBOL(register_dma_controller);
  4366. +
  4367. +struct dma_controller *find_dma_controller(int id)
  4368. +{
  4369. + struct dma_controller *dmac;
  4370. +
  4371. + list_for_each_entry(dmac, &controllers, list)
  4372. + if (dmac->id == id)
  4373. + return dmac;
  4374. + return NULL;
  4375. +}
  4376. +EXPORT_SYMBOL(find_dma_controller);
  4377. --- a/arch/avr32/kernel/entry-avr32b.S
  4378. +++ b/arch/avr32/kernel/entry-avr32b.S
  4379. @@ -741,26 +741,6 @@
  4380. .section .irq.text,"ax",@progbits
  4381. -.global cpu_idle_sleep
  4382. -cpu_idle_sleep:
  4383. - mask_interrupts
  4384. - get_thread_info r8
  4385. - ld.w r9, r8[TI_flags]
  4386. - bld r9, TIF_NEED_RESCHED
  4387. - brcs cpu_idle_enable_int_and_exit
  4388. - sbr r9, TIF_CPU_GOING_TO_SLEEP
  4389. - st.w r8[TI_flags], r9
  4390. - unmask_interrupts
  4391. - sleep 0
  4392. -cpu_idle_skip_sleep:
  4393. - mask_interrupts
  4394. - ld.w r9, r8[TI_flags]
  4395. - cbr r9, TIF_CPU_GOING_TO_SLEEP
  4396. - st.w r8[TI_flags], r9
  4397. -cpu_idle_enable_int_and_exit:
  4398. - unmask_interrupts
  4399. - retal r12
  4400. -
  4401. .global irq_level0
  4402. .global irq_level1
  4403. .global irq_level2
  4404. --- a/arch/avr32/kernel/Makefile
  4405. +++ b/arch/avr32/kernel/Makefile
  4406. @@ -9,6 +9,7 @@
  4407. obj-y += setup.o traps.o semaphore.o ocd.o ptrace.o
  4408. obj-y += signal.o sys_avr32.o process.o time.o
  4409. obj-y += init_task.o switch_to.o cpu.o
  4410. +obj-y += dma-controller.o
  4411. obj-$(CONFIG_MODULES) += module.o avr32_ksyms.o
  4412. obj-$(CONFIG_KPROBES) += kprobes.o
  4413. obj-$(CONFIG_STACKTRACE) += stacktrace.o
  4414. --- a/arch/avr32/kernel/process.c
  4415. +++ b/arch/avr32/kernel/process.c
  4416. @@ -18,11 +18,11 @@
  4417. #include <asm/sysreg.h>
  4418. #include <asm/ocd.h>
  4419. +#include <asm/arch/pm.h>
  4420. +
  4421. void (*pm_power_off)(void) = NULL;
  4422. EXPORT_SYMBOL(pm_power_off);
  4423. -extern void cpu_idle_sleep(void);
  4424. -
  4425. /*
  4426. * This file handles the architecture-dependent parts of process handling..
  4427. */
  4428. @@ -54,6 +54,8 @@
  4429. void machine_power_off(void)
  4430. {
  4431. + if (pm_power_off)
  4432. + pm_power_off();
  4433. }
  4434. void machine_restart(char *cmd)
  4435. --- a/arch/avr32/kernel/setup.c
  4436. +++ b/arch/avr32/kernel/setup.c
  4437. @@ -274,6 +274,8 @@
  4438. printk(KERN_WARNING
  4439. "Failed to allocate framebuffer memory\n");
  4440. fbmem_size = 0;
  4441. + } else {
  4442. + memset(__va(fbmem_start), 0, fbmem_size);
  4443. }
  4444. }
  4445. --- a/arch/avr32/kernel/signal.c
  4446. +++ b/arch/avr32/kernel/signal.c
  4447. @@ -93,6 +93,9 @@
  4448. if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
  4449. goto badframe;
  4450. + if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)
  4451. + goto badframe;
  4452. +
  4453. pr_debug("Context restored: pc = %08lx, lr = %08lx, sp = %08lx\n",
  4454. regs->pc, regs->lr, regs->sp);
  4455. --- a/arch/avr32/kernel/time.c
  4456. +++ b/arch/avr32/kernel/time.c
  4457. @@ -1,16 +1,12 @@
  4458. /*
  4459. * Copyright (C) 2004-2007 Atmel Corporation
  4460. *
  4461. - * Based on MIPS implementation arch/mips/kernel/time.c
  4462. - * Copyright 2001 MontaVista Software Inc.
  4463. - *
  4464. * This program is free software; you can redistribute it and/or modify
  4465. * it under the terms of the GNU General Public License version 2 as
  4466. * published by the Free Software Foundation.
  4467. */
  4468. -
  4469. #include <linux/clk.h>
  4470. -#include <linux/clocksource.h>
  4471. +#include <linux/clockchips.h>
  4472. #include <linux/time.h>
  4473. #include <linux/module.h>
  4474. #include <linux/interrupt.h>
  4475. @@ -27,207 +23,133 @@
  4476. #include <asm/io.h>
  4477. #include <asm/sections.h>
  4478. -/* how many counter cycles in a jiffy? */
  4479. -static u32 cycles_per_jiffy;
  4480. +#include <asm/arch/pm.h>
  4481. -/* the count value for the next timer interrupt */
  4482. -static u32 expirelo;
  4483. -cycle_t __weak read_cycle_count(void)
  4484. +static cycle_t read_cycle_count(void)
  4485. {
  4486. return (cycle_t)sysreg_read(COUNT);
  4487. }
  4488. -struct clocksource __weak clocksource_avr32 = {
  4489. - .name = "avr32",
  4490. - .rating = 350,
  4491. +/*
  4492. + * The architectural cycle count registers are a fine clocksource unless
  4493. + * the system idle loop use sleep states like "idle": the CPU cycles
  4494. + * measured by COUNT (and COMPARE) don't happen during sleep states.
  4495. + * Their duration also changes if cpufreq changes the CPU clock rate.
  4496. + * So we rate the clocksource using COUNT as very low quality.
  4497. + */
  4498. +static struct clocksource counter = {
  4499. + .name = "avr32_counter",
  4500. + .rating = 50,
  4501. .read = read_cycle_count,
  4502. .mask = CLOCKSOURCE_MASK(32),
  4503. .shift = 16,
  4504. .flags = CLOCK_SOURCE_IS_CONTINUOUS,
  4505. };
  4506. -irqreturn_t __weak timer_interrupt(int irq, void *dev_id);
  4507. -
  4508. -struct irqaction timer_irqaction = {
  4509. - .handler = timer_interrupt,
  4510. - .flags = IRQF_DISABLED,
  4511. - .name = "timer",
  4512. -};
  4513. -
  4514. -/*
  4515. - * By default we provide the null RTC ops
  4516. - */
  4517. -static unsigned long null_rtc_get_time(void)
  4518. +static irqreturn_t timer_interrupt(int irq, void *dev_id)
  4519. {
  4520. - return mktime(2007, 1, 1, 0, 0, 0);
  4521. -}
  4522. -
  4523. -static int null_rtc_set_time(unsigned long sec)
  4524. -{
  4525. - return 0;
  4526. -}
  4527. + struct clock_event_device *evdev = dev_id;
  4528. -static unsigned long (*rtc_get_time)(void) = null_rtc_get_time;
  4529. -static int (*rtc_set_time)(unsigned long) = null_rtc_set_time;
  4530. -
  4531. -static void avr32_timer_ack(void)
  4532. -{
  4533. - u32 count;
  4534. -
  4535. - /* Ack this timer interrupt and set the next one */
  4536. - expirelo += cycles_per_jiffy;
  4537. - /* setting COMPARE to 0 stops the COUNT-COMPARE */
  4538. - if (expirelo == 0) {
  4539. - sysreg_write(COMPARE, expirelo + 1);
  4540. - } else {
  4541. - sysreg_write(COMPARE, expirelo);
  4542. - }
  4543. + /*
  4544. + * Disable the interrupt until the clockevent subsystem
  4545. + * reprograms it.
  4546. + */
  4547. + sysreg_write(COMPARE, 0);
  4548. - /* Check to see if we have missed any timer interrupts */
  4549. - count = sysreg_read(COUNT);
  4550. - if ((count - expirelo) < 0x7fffffff) {
  4551. - expirelo = count + cycles_per_jiffy;
  4552. - sysreg_write(COMPARE, expirelo);
  4553. - }
  4554. + evdev->event_handler(evdev);
  4555. + return IRQ_HANDLED;
  4556. }
  4557. -int __weak avr32_hpt_init(void)
  4558. -{
  4559. - int ret;
  4560. - unsigned long mult, shift, count_hz;
  4561. -
  4562. - count_hz = clk_get_rate(boot_cpu_data.clk);
  4563. - shift = clocksource_avr32.shift;
  4564. - mult = clocksource_hz2mult(count_hz, shift);
  4565. - clocksource_avr32.mult = mult;
  4566. -
  4567. - {
  4568. - u64 tmp;
  4569. -
  4570. - tmp = TICK_NSEC;
  4571. - tmp <<= shift;
  4572. - tmp += mult / 2;
  4573. - do_div(tmp, mult);
  4574. -
  4575. - cycles_per_jiffy = tmp;
  4576. - }
  4577. +static struct irqaction timer_irqaction = {
  4578. + .handler = timer_interrupt,
  4579. + .flags = IRQF_TIMER | IRQF_DISABLED,
  4580. + .name = "avr32_comparator",
  4581. +};
  4582. - ret = setup_irq(0, &timer_irqaction);
  4583. - if (ret) {
  4584. - pr_debug("timer: could not request IRQ 0: %d\n", ret);
  4585. - return -ENODEV;
  4586. - }
  4587. +static int comparator_next_event(unsigned long delta,
  4588. + struct clock_event_device *evdev)
  4589. +{
  4590. + unsigned long flags;
  4591. - printk(KERN_INFO "timer: AT32AP COUNT-COMPARE at irq 0, "
  4592. - "%lu.%03lu MHz\n",
  4593. - ((count_hz + 500) / 1000) / 1000,
  4594. - ((count_hz + 500) / 1000) % 1000);
  4595. + raw_local_irq_save(flags);
  4596. - return 0;
  4597. -}
  4598. + /* The time to read COUNT then update COMPARE must be less
  4599. + * than the min_delta_ns value for this clockevent source.
  4600. + */
  4601. + sysreg_write(COMPARE, (sysreg_read(COUNT) + delta) ? : 1);
  4602. -/*
  4603. - * Taken from MIPS c0_hpt_timer_init().
  4604. - *
  4605. - * The reason COUNT is written twice is probably to make sure we don't get any
  4606. - * timer interrupts while we are messing with the counter.
  4607. - */
  4608. -int __weak avr32_hpt_start(void)
  4609. -{
  4610. - u32 count = sysreg_read(COUNT);
  4611. - expirelo = (count / cycles_per_jiffy + 1) * cycles_per_jiffy;
  4612. - sysreg_write(COUNT, expirelo - cycles_per_jiffy);
  4613. - sysreg_write(COMPARE, expirelo);
  4614. - sysreg_write(COUNT, count);
  4615. + raw_local_irq_restore(flags);
  4616. return 0;
  4617. }
  4618. -/*
  4619. - * local_timer_interrupt() does profiling and process accounting on a
  4620. - * per-CPU basis.
  4621. - *
  4622. - * In UP mode, it is invoked from the (global) timer_interrupt.
  4623. - */
  4624. -void local_timer_interrupt(int irq, void *dev_id)
  4625. +static void comparator_mode(enum clock_event_mode mode,
  4626. + struct clock_event_device *evdev)
  4627. {
  4628. - if (current->pid)
  4629. - profile_tick(CPU_PROFILING);
  4630. - update_process_times(user_mode(get_irq_regs()));
  4631. + switch (mode) {
  4632. + case CLOCK_EVT_MODE_ONESHOT:
  4633. + pr_debug("%s: start\n", evdev->name);
  4634. + /* FALLTHROUGH */
  4635. + case CLOCK_EVT_MODE_RESUME:
  4636. + cpu_disable_idle_sleep();
  4637. + break;
  4638. + case CLOCK_EVT_MODE_UNUSED:
  4639. + case CLOCK_EVT_MODE_SHUTDOWN:
  4640. + sysreg_write(COMPARE, 0);
  4641. + pr_debug("%s: stop\n", evdev->name);
  4642. + cpu_enable_idle_sleep();
  4643. + break;
  4644. + default:
  4645. + BUG();
  4646. + }
  4647. }
  4648. -irqreturn_t __weak timer_interrupt(int irq, void *dev_id)
  4649. -{
  4650. - /* ack timer interrupt and try to set next interrupt */
  4651. - avr32_timer_ack();
  4652. -
  4653. - /*
  4654. - * Call the generic timer interrupt handler
  4655. - */
  4656. - write_seqlock(&xtime_lock);
  4657. - do_timer(1);
  4658. - write_sequnlock(&xtime_lock);
  4659. -
  4660. - /*
  4661. - * In UP mode, we call local_timer_interrupt() to do profiling
  4662. - * and process accounting.
  4663. - *
  4664. - * SMP is not supported yet.
  4665. - */
  4666. - local_timer_interrupt(irq, dev_id);
  4667. -
  4668. - return IRQ_HANDLED;
  4669. -}
  4670. +static struct clock_event_device comparator = {
  4671. + .name = "avr32_comparator",
  4672. + .features = CLOCK_EVT_FEAT_ONESHOT,
  4673. + .shift = 16,
  4674. + .rating = 50,
  4675. + .cpumask = CPU_MASK_CPU0,
  4676. + .set_next_event = comparator_next_event,
  4677. + .set_mode = comparator_mode,
  4678. +};
  4679. void __init time_init(void)
  4680. {
  4681. + unsigned long counter_hz;
  4682. int ret;
  4683. - /*
  4684. - * Make sure we don't get any COMPARE interrupts before we can
  4685. - * handle them.
  4686. - */
  4687. - sysreg_write(COMPARE, 0);
  4688. -
  4689. - xtime.tv_sec = rtc_get_time();
  4690. + xtime.tv_sec = mktime(2007, 1, 1, 0, 0, 0);
  4691. xtime.tv_nsec = 0;
  4692. set_normalized_timespec(&wall_to_monotonic,
  4693. -xtime.tv_sec, -xtime.tv_nsec);
  4694. - ret = avr32_hpt_init();
  4695. - if (ret) {
  4696. - pr_debug("timer: failed setup: %d\n", ret);
  4697. - return;
  4698. - }
  4699. + /* figure rate for counter */
  4700. + counter_hz = clk_get_rate(boot_cpu_data.clk);
  4701. + counter.mult = clocksource_hz2mult(counter_hz, counter.shift);
  4702. - ret = clocksource_register(&clocksource_avr32);
  4703. + ret = clocksource_register(&counter);
  4704. if (ret)
  4705. pr_debug("timer: could not register clocksource: %d\n", ret);
  4706. - ret = avr32_hpt_start();
  4707. - if (ret) {
  4708. - pr_debug("timer: failed starting: %d\n", ret);
  4709. - return;
  4710. - }
  4711. -}
  4712. + /* setup COMPARE clockevent */
  4713. + comparator.mult = div_sc(counter_hz, NSEC_PER_SEC, comparator.shift);
  4714. + comparator.max_delta_ns = clockevent_delta2ns((u32)~0, &comparator);
  4715. + comparator.min_delta_ns = clockevent_delta2ns(50, &comparator) + 1;
  4716. -static struct sysdev_class timer_class = {
  4717. - .name = "timer",
  4718. -};
  4719. + sysreg_write(COMPARE, 0);
  4720. + timer_irqaction.dev_id = &comparator;
  4721. -static struct sys_device timer_device = {
  4722. - .id = 0,
  4723. - .cls = &timer_class,
  4724. -};
  4725. + ret = setup_irq(0, &timer_irqaction);
  4726. + if (ret)
  4727. + pr_debug("timer: could not request IRQ 0: %d\n", ret);
  4728. + else {
  4729. + clockevents_register_device(&comparator);
  4730. -static int __init init_timer_sysfs(void)
  4731. -{
  4732. - int err = sysdev_class_register(&timer_class);
  4733. - if (!err)
  4734. - err = sysdev_register(&timer_device);
  4735. - return err;
  4736. + pr_info("%s: irq 0, %lu.%03lu MHz\n", comparator.name,
  4737. + ((counter_hz + 500) / 1000) / 1000,
  4738. + ((counter_hz + 500) / 1000) % 1000);
  4739. + }
  4740. }
  4741. -
  4742. -device_initcall(init_timer_sysfs);
  4743. --- a/arch/avr32/lib/io-readsb.S
  4744. +++ b/arch/avr32/lib/io-readsb.S
  4745. @@ -41,7 +41,7 @@
  4746. 2: sub r10, -4
  4747. reteq r12
  4748. -3: ld.uh r8, r12[0]
  4749. +3: ld.ub r8, r12[0]
  4750. sub r10, 1
  4751. st.b r11++, r8
  4752. brne 3b
  4753. --- a/arch/avr32/mach-at32ap/at32ap700x.c
  4754. +++ b/arch/avr32/mach-at32ap/at32ap700x.c
  4755. @@ -6,11 +6,13 @@
  4756. * published by the Free Software Foundation.
  4757. */
  4758. #include <linux/clk.h>
  4759. +#include <linux/delay.h>
  4760. #include <linux/fb.h>
  4761. #include <linux/init.h>
  4762. #include <linux/platform_device.h>
  4763. #include <linux/dma-mapping.h>
  4764. #include <linux/spi/spi.h>
  4765. +#include <linux/usb/atmel_usba_udc.h>
  4766. #include <asm/io.h>
  4767. #include <asm/irq.h>
  4768. @@ -18,6 +20,7 @@
  4769. #include <asm/arch/at32ap700x.h>
  4770. #include <asm/arch/board.h>
  4771. #include <asm/arch/portmux.h>
  4772. +#include <asm/arch/sram.h>
  4773. #include <video/atmel_lcdc.h>
  4774. @@ -91,25 +94,18 @@
  4775. static DEFINE_SPINLOCK(pm_lock);
  4776. -unsigned long at32ap7000_osc_rates[3] = {
  4777. - [0] = 32768,
  4778. - /* FIXME: these are ATSTK1002-specific */
  4779. - [1] = 20000000,
  4780. - [2] = 12000000,
  4781. -};
  4782. +static struct clk osc0;
  4783. +static struct clk osc1;
  4784. static unsigned long osc_get_rate(struct clk *clk)
  4785. {
  4786. - return at32ap7000_osc_rates[clk->index];
  4787. + return at32_board_osc_rates[clk->index];
  4788. }
  4789. static unsigned long pll_get_rate(struct clk *clk, unsigned long control)
  4790. {
  4791. unsigned long div, mul, rate;
  4792. - if (!(control & PM_BIT(PLLEN)))
  4793. - return 0;
  4794. -
  4795. div = PM_BFEXT(PLLDIV, control) + 1;
  4796. mul = PM_BFEXT(PLLMUL, control) + 1;
  4797. @@ -120,6 +116,71 @@
  4798. return rate;
  4799. }
  4800. +static long pll_set_rate(struct clk *clk, unsigned long rate,
  4801. + u32 *pll_ctrl)
  4802. +{
  4803. + unsigned long mul;
  4804. + unsigned long mul_best_fit = 0;
  4805. + unsigned long div;
  4806. + unsigned long div_min;
  4807. + unsigned long div_max;
  4808. + unsigned long div_best_fit = 0;
  4809. + unsigned long base;
  4810. + unsigned long pll_in;
  4811. + unsigned long actual = 0;
  4812. + unsigned long rate_error;
  4813. + unsigned long rate_error_prev = ~0UL;
  4814. + u32 ctrl;
  4815. +
  4816. + /* Rate must be between 80 MHz and 200 Mhz. */
  4817. + if (rate < 80000000UL || rate > 200000000UL)
  4818. + return -EINVAL;
  4819. +
  4820. + ctrl = PM_BF(PLLOPT, 4);
  4821. + base = clk->parent->get_rate(clk->parent);
  4822. +
  4823. + /* PLL input frequency must be between 6 MHz and 32 MHz. */
  4824. + div_min = DIV_ROUND_UP(base, 32000000UL);
  4825. + div_max = base / 6000000UL;
  4826. +
  4827. + if (div_max < div_min)
  4828. + return -EINVAL;
  4829. +
  4830. + for (div = div_min; div <= div_max; div++) {
  4831. + pll_in = (base + div / 2) / div;
  4832. + mul = (rate + pll_in / 2) / pll_in;
  4833. +
  4834. + if (mul == 0)
  4835. + continue;
  4836. +
  4837. + actual = pll_in * mul;
  4838. + rate_error = abs(actual - rate);
  4839. +
  4840. + if (rate_error < rate_error_prev) {
  4841. + mul_best_fit = mul;
  4842. + div_best_fit = div;
  4843. + rate_error_prev = rate_error;
  4844. + }
  4845. +
  4846. + if (rate_error == 0)
  4847. + break;
  4848. + }
  4849. +
  4850. + if (div_best_fit == 0)
  4851. + return -EINVAL;
  4852. +
  4853. + ctrl |= PM_BF(PLLMUL, mul_best_fit - 1);
  4854. + ctrl |= PM_BF(PLLDIV, div_best_fit - 1);
  4855. + ctrl |= PM_BF(PLLCOUNT, 16);
  4856. +
  4857. + if (clk->parent == &osc1)
  4858. + ctrl |= PM_BIT(PLLOSC);
  4859. +
  4860. + *pll_ctrl = ctrl;
  4861. +
  4862. + return actual;
  4863. +}
  4864. +
  4865. static unsigned long pll0_get_rate(struct clk *clk)
  4866. {
  4867. u32 control;
  4868. @@ -129,6 +190,41 @@
  4869. return pll_get_rate(clk, control);
  4870. }
  4871. +static void pll1_mode(struct clk *clk, int enabled)
  4872. +{
  4873. + unsigned long timeout;
  4874. + u32 status;
  4875. + u32 ctrl;
  4876. +
  4877. + ctrl = pm_readl(PLL1);
  4878. +
  4879. + if (enabled) {
  4880. + if (!PM_BFEXT(PLLMUL, ctrl) && !PM_BFEXT(PLLDIV, ctrl)) {
  4881. + pr_debug("clk %s: failed to enable, rate not set\n",
  4882. + clk->name);
  4883. + return;
  4884. + }
  4885. +
  4886. + ctrl |= PM_BIT(PLLEN);
  4887. + pm_writel(PLL1, ctrl);
  4888. +
  4889. + /* Wait for PLL lock. */
  4890. + for (timeout = 10000; timeout; timeout--) {
  4891. + status = pm_readl(ISR);
  4892. + if (status & PM_BIT(LOCK1))
  4893. + break;
  4894. + udelay(10);
  4895. + }
  4896. +
  4897. + if (!(status & PM_BIT(LOCK1)))
  4898. + printk(KERN_ERR "clk %s: timeout waiting for lock\n",
  4899. + clk->name);
  4900. + } else {
  4901. + ctrl &= ~PM_BIT(PLLEN);
  4902. + pm_writel(PLL1, ctrl);
  4903. + }
  4904. +}
  4905. +
  4906. static unsigned long pll1_get_rate(struct clk *clk)
  4907. {
  4908. u32 control;
  4909. @@ -138,6 +234,49 @@
  4910. return pll_get_rate(clk, control);
  4911. }
  4912. +static long pll1_set_rate(struct clk *clk, unsigned long rate, int apply)
  4913. +{
  4914. + u32 ctrl = 0;
  4915. + unsigned long actual_rate;
  4916. +
  4917. + actual_rate = pll_set_rate(clk, rate, &ctrl);
  4918. +
  4919. + if (apply) {
  4920. + if (actual_rate != rate)
  4921. + return -EINVAL;
  4922. + if (clk->users > 0)
  4923. + return -EBUSY;
  4924. + pr_debug(KERN_INFO "clk %s: new rate %lu (actual rate %lu)\n",
  4925. + clk->name, rate, actual_rate);
  4926. + pm_writel(PLL1, ctrl);
  4927. + }
  4928. +
  4929. + return actual_rate;
  4930. +}
  4931. +
  4932. +static int pll1_set_parent(struct clk *clk, struct clk *parent)
  4933. +{
  4934. + u32 ctrl;
  4935. +
  4936. + if (clk->users > 0)
  4937. + return -EBUSY;
  4938. +
  4939. + ctrl = pm_readl(PLL1);
  4940. + WARN_ON(ctrl & PM_BIT(PLLEN));
  4941. +
  4942. + if (parent == &osc0)
  4943. + ctrl &= ~PM_BIT(PLLOSC);
  4944. + else if (parent == &osc1)
  4945. + ctrl |= PM_BIT(PLLOSC);
  4946. + else
  4947. + return -EINVAL;
  4948. +
  4949. + pm_writel(PLL1, ctrl);
  4950. + clk->parent = parent;
  4951. +
  4952. + return 0;
  4953. +}
  4954. +
  4955. /*
  4956. * The AT32AP7000 has five primary clock sources: One 32kHz
  4957. * oscillator, two crystal oscillators and two PLLs.
  4958. @@ -166,7 +305,10 @@
  4959. };
  4960. static struct clk pll1 = {
  4961. .name = "pll1",
  4962. + .mode = pll1_mode,
  4963. .get_rate = pll1_get_rate,
  4964. + .set_rate = pll1_set_rate,
  4965. + .set_parent = pll1_set_parent,
  4966. .parent = &osc0,
  4967. };
  4968. @@ -534,6 +676,14 @@
  4969. .users = 1,
  4970. .index = 3,
  4971. };
  4972. +static struct clk sdramc_clk = {
  4973. + .name = "sdramc_clk",
  4974. + .parent = &pbb_clk,
  4975. + .mode = pbb_clk_mode,
  4976. + .get_rate = pbb_clk_get_rate,
  4977. + .users = 1,
  4978. + .index = 14,
  4979. +};
  4980. static struct resource smc0_resource[] = {
  4981. PBMEM(0xfff03400),
  4982. @@ -605,19 +755,32 @@
  4983. }
  4984. /* --------------------------------------------------------------------
  4985. - * System Timer/Counter (TC)
  4986. + * Timer/Counter (TC)
  4987. * -------------------------------------------------------------------- */
  4988. -static struct resource at32_systc0_resource[] = {
  4989. +
  4990. +static struct resource at32_tcb0_resource[] = {
  4991. PBMEM(0xfff00c00),
  4992. IRQ(22),
  4993. };
  4994. -struct platform_device at32_systc0_device = {
  4995. - .name = "systc",
  4996. +static struct platform_device at32_tcb0_device = {
  4997. + .name = "atmel_tcb",
  4998. .id = 0,
  4999. - .resource = at32_systc0_resource,
  5000. - .num_resources = ARRAY_SIZE(at32_systc0_resource),
  5001. + .resource = at32_tcb0_resource,
  5002. + .num_resources = ARRAY_SIZE(at32_tcb0_resource),
  5003. };
  5004. -DEV_CLK(pclk, at32_systc0, pbb, 3);
  5005. +DEV_CLK(t0_clk, at32_tcb0, pbb, 3);
  5006. +
  5007. +static struct resource at32_tcb1_resource[] = {
  5008. + PBMEM(0xfff01000),
  5009. + IRQ(23),
  5010. +};
  5011. +static struct platform_device at32_tcb1_device = {
  5012. + .name = "atmel_tcb",
  5013. + .id = 1,
  5014. + .resource = at32_tcb1_resource,
  5015. + .num_resources = ARRAY_SIZE(at32_tcb1_resource),
  5016. +};
  5017. +DEV_CLK(t0_clk, at32_tcb1, pbb, 4);
  5018. /* --------------------------------------------------------------------
  5019. * PIO
  5020. @@ -669,7 +832,8 @@
  5021. platform_device_register(&pdc_device);
  5022. platform_device_register(&dmaca0_device);
  5023. - platform_device_register(&at32_systc0_device);
  5024. + platform_device_register(&at32_tcb0_device);
  5025. + platform_device_register(&at32_tcb1_device);
  5026. platform_device_register(&pio0_device);
  5027. platform_device_register(&pio1_device);
  5028. @@ -679,6 +843,81 @@
  5029. }
  5030. /* --------------------------------------------------------------------
  5031. + * PSIF
  5032. + * -------------------------------------------------------------------- */
  5033. +static struct resource atmel_psif0_resource[] __initdata = {
  5034. + {
  5035. + .start = 0xffe03c00,
  5036. + .end = 0xffe03cff,
  5037. + .flags = IORESOURCE_MEM,
  5038. + },
  5039. + IRQ(18),
  5040. +};
  5041. +static struct clk atmel_psif0_pclk = {
  5042. + .name = "pclk",
  5043. + .parent = &pba_clk,
  5044. + .mode = pba_clk_mode,
  5045. + .get_rate = pba_clk_get_rate,
  5046. + .index = 15,
  5047. +};
  5048. +
  5049. +static struct resource atmel_psif1_resource[] __initdata = {
  5050. + {
  5051. + .start = 0xffe03d00,
  5052. + .end = 0xffe03dff,
  5053. + .flags = IORESOURCE_MEM,
  5054. + },
  5055. + IRQ(18),
  5056. +};
  5057. +static struct clk atmel_psif1_pclk = {
  5058. + .name = "pclk",
  5059. + .parent = &pba_clk,
  5060. + .mode = pba_clk_mode,
  5061. + .get_rate = pba_clk_get_rate,
  5062. + .index = 15,
  5063. +};
  5064. +
  5065. +struct platform_device *__init at32_add_device_psif(unsigned int id)
  5066. +{
  5067. + struct platform_device *pdev;
  5068. +
  5069. + if (!(id == 0 || id == 1))
  5070. + return NULL;
  5071. +
  5072. + pdev = platform_device_alloc("atmel_psif", id);
  5073. + if (!pdev)
  5074. + return NULL;
  5075. +
  5076. + switch (id) {
  5077. + case 0:
  5078. + if (platform_device_add_resources(pdev, atmel_psif0_resource,
  5079. + ARRAY_SIZE(atmel_psif0_resource)))
  5080. + goto err_add_resources;
  5081. + atmel_psif0_pclk.dev = &pdev->dev;
  5082. + select_peripheral(PA(8), PERIPH_A, 0); /* CLOCK */
  5083. + select_peripheral(PA(9), PERIPH_A, 0); /* DATA */
  5084. + break;
  5085. + case 1:
  5086. + if (platform_device_add_resources(pdev, atmel_psif1_resource,
  5087. + ARRAY_SIZE(atmel_psif1_resource)))
  5088. + goto err_add_resources;
  5089. + atmel_psif1_pclk.dev = &pdev->dev;
  5090. + select_peripheral(PB(11), PERIPH_A, 0); /* CLOCK */
  5091. + select_peripheral(PB(12), PERIPH_A, 0); /* DATA */
  5092. + break;
  5093. + default:
  5094. + return NULL;
  5095. + }
  5096. +
  5097. + platform_device_add(pdev);
  5098. + return pdev;
  5099. +
  5100. +err_add_resources:
  5101. + platform_device_put(pdev);
  5102. + return NULL;
  5103. +}
  5104. +
  5105. +/* --------------------------------------------------------------------
  5106. * USART
  5107. * -------------------------------------------------------------------- */
  5108. @@ -989,7 +1228,9 @@
  5109. .index = 2,
  5110. };
  5111. -struct platform_device *__init at32_add_device_twi(unsigned int id)
  5112. +struct platform_device *__init at32_add_device_twi(unsigned int id,
  5113. + struct i2c_board_info *b,
  5114. + unsigned int n)
  5115. {
  5116. struct platform_device *pdev;
  5117. @@ -1009,6 +1250,9 @@
  5118. atmel_twi0_pclk.dev = &pdev->dev;
  5119. + if (b)
  5120. + i2c_register_board_info(id, b, n);
  5121. +
  5122. platform_device_add(pdev);
  5123. return pdev;
  5124. @@ -1032,7 +1276,8 @@
  5125. .index = 9,
  5126. };
  5127. -struct platform_device *__init at32_add_device_mci(unsigned int id)
  5128. +struct platform_device *__init
  5129. +at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
  5130. {
  5131. struct platform_device *pdev;
  5132. @@ -1041,11 +1286,15 @@
  5133. pdev = platform_device_alloc("atmel_mci", id);
  5134. if (!pdev)
  5135. - return NULL;
  5136. + goto fail;
  5137. if (platform_device_add_resources(pdev, atmel_mci0_resource,
  5138. ARRAY_SIZE(atmel_mci0_resource)))
  5139. - goto err_add_resources;
  5140. + goto fail;
  5141. +
  5142. + if (data && platform_device_add_data(pdev, data,
  5143. + sizeof(struct mci_platform_data)))
  5144. + goto fail;
  5145. select_peripheral(PA(10), PERIPH_A, 0); /* CLK */
  5146. select_peripheral(PA(11), PERIPH_A, 0); /* CMD */
  5147. @@ -1054,12 +1303,19 @@
  5148. select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */
  5149. select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */
  5150. + if (data) {
  5151. + if (data->detect_pin != GPIO_PIN_NONE)
  5152. + at32_select_gpio(data->detect_pin, 0);
  5153. + if (data->wp_pin != GPIO_PIN_NONE)
  5154. + at32_select_gpio(data->wp_pin, 0);
  5155. + }
  5156. +
  5157. atmel_mci0_pclk.dev = &pdev->dev;
  5158. platform_device_add(pdev);
  5159. return pdev;
  5160. -err_add_resources:
  5161. +fail:
  5162. platform_device_put(pdev);
  5163. return NULL;
  5164. }
  5165. @@ -1097,7 +1353,8 @@
  5166. struct platform_device *__init
  5167. at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
  5168. - unsigned long fbmem_start, unsigned long fbmem_len)
  5169. + unsigned long fbmem_start, unsigned long fbmem_len,
  5170. + unsigned int pin_config)
  5171. {
  5172. struct platform_device *pdev;
  5173. struct atmel_lcdfb_info *info;
  5174. @@ -1124,37 +1381,77 @@
  5175. switch (id) {
  5176. case 0:
  5177. pdev = &atmel_lcdfb0_device;
  5178. - select_peripheral(PC(19), PERIPH_A, 0); /* CC */
  5179. - select_peripheral(PC(20), PERIPH_A, 0); /* HSYNC */
  5180. - select_peripheral(PC(21), PERIPH_A, 0); /* PCLK */
  5181. - select_peripheral(PC(22), PERIPH_A, 0); /* VSYNC */
  5182. - select_peripheral(PC(23), PERIPH_A, 0); /* DVAL */
  5183. - select_peripheral(PC(24), PERIPH_A, 0); /* MODE */
  5184. - select_peripheral(PC(25), PERIPH_A, 0); /* PWR */
  5185. - select_peripheral(PC(26), PERIPH_A, 0); /* DATA0 */
  5186. - select_peripheral(PC(27), PERIPH_A, 0); /* DATA1 */
  5187. - select_peripheral(PC(28), PERIPH_A, 0); /* DATA2 */
  5188. - select_peripheral(PC(29), PERIPH_A, 0); /* DATA3 */
  5189. - select_peripheral(PC(30), PERIPH_A, 0); /* DATA4 */
  5190. - select_peripheral(PC(31), PERIPH_A, 0); /* DATA5 */
  5191. - select_peripheral(PD(0), PERIPH_A, 0); /* DATA6 */
  5192. - select_peripheral(PD(1), PERIPH_A, 0); /* DATA7 */
  5193. - select_peripheral(PD(2), PERIPH_A, 0); /* DATA8 */
  5194. - select_peripheral(PD(3), PERIPH_A, 0); /* DATA9 */
  5195. - select_peripheral(PD(4), PERIPH_A, 0); /* DATA10 */
  5196. - select_peripheral(PD(5), PERIPH_A, 0); /* DATA11 */
  5197. - select_peripheral(PD(6), PERIPH_A, 0); /* DATA12 */
  5198. - select_peripheral(PD(7), PERIPH_A, 0); /* DATA13 */
  5199. - select_peripheral(PD(8), PERIPH_A, 0); /* DATA14 */
  5200. - select_peripheral(PD(9), PERIPH_A, 0); /* DATA15 */
  5201. - select_peripheral(PD(10), PERIPH_A, 0); /* DATA16 */
  5202. - select_peripheral(PD(11), PERIPH_A, 0); /* DATA17 */
  5203. - select_peripheral(PD(12), PERIPH_A, 0); /* DATA18 */
  5204. - select_peripheral(PD(13), PERIPH_A, 0); /* DATA19 */
  5205. - select_peripheral(PD(14), PERIPH_A, 0); /* DATA20 */
  5206. - select_peripheral(PD(15), PERIPH_A, 0); /* DATA21 */
  5207. - select_peripheral(PD(16), PERIPH_A, 0); /* DATA22 */
  5208. - select_peripheral(PD(17), PERIPH_A, 0); /* DATA23 */
  5209. +
  5210. + switch (pin_config) {
  5211. + case 0:
  5212. + select_peripheral(PC(19), PERIPH_A, 0); /* CC */
  5213. + select_peripheral(PC(20), PERIPH_A, 0); /* HSYNC */
  5214. + select_peripheral(PC(21), PERIPH_A, 0); /* PCLK */
  5215. + select_peripheral(PC(22), PERIPH_A, 0); /* VSYNC */
  5216. + select_peripheral(PC(23), PERIPH_A, 0); /* DVAL */
  5217. + select_peripheral(PC(24), PERIPH_A, 0); /* MODE */
  5218. + select_peripheral(PC(25), PERIPH_A, 0); /* PWR */
  5219. + select_peripheral(PC(26), PERIPH_A, 0); /* DATA0 */
  5220. + select_peripheral(PC(27), PERIPH_A, 0); /* DATA1 */
  5221. + select_peripheral(PC(28), PERIPH_A, 0); /* DATA2 */
  5222. + select_peripheral(PC(29), PERIPH_A, 0); /* DATA3 */
  5223. + select_peripheral(PC(30), PERIPH_A, 0); /* DATA4 */
  5224. + select_peripheral(PC(31), PERIPH_A, 0); /* DATA5 */
  5225. + select_peripheral(PD(0), PERIPH_A, 0); /* DATA6 */
  5226. + select_peripheral(PD(1), PERIPH_A, 0); /* DATA7 */
  5227. + select_peripheral(PD(2), PERIPH_A, 0); /* DATA8 */
  5228. + select_peripheral(PD(3), PERIPH_A, 0); /* DATA9 */
  5229. + select_peripheral(PD(4), PERIPH_A, 0); /* DATA10 */
  5230. + select_peripheral(PD(5), PERIPH_A, 0); /* DATA11 */
  5231. + select_peripheral(PD(6), PERIPH_A, 0); /* DATA12 */
  5232. + select_peripheral(PD(7), PERIPH_A, 0); /* DATA13 */
  5233. + select_peripheral(PD(8), PERIPH_A, 0); /* DATA14 */
  5234. + select_peripheral(PD(9), PERIPH_A, 0); /* DATA15 */
  5235. + select_peripheral(PD(10), PERIPH_A, 0); /* DATA16 */
  5236. + select_peripheral(PD(11), PERIPH_A, 0); /* DATA17 */
  5237. + select_peripheral(PD(12), PERIPH_A, 0); /* DATA18 */
  5238. + select_peripheral(PD(13), PERIPH_A, 0); /* DATA19 */
  5239. + select_peripheral(PD(14), PERIPH_A, 0); /* DATA20 */
  5240. + select_peripheral(PD(15), PERIPH_A, 0); /* DATA21 */
  5241. + select_peripheral(PD(16), PERIPH_A, 0); /* DATA22 */
  5242. + select_peripheral(PD(17), PERIPH_A, 0); /* DATA23 */
  5243. + break;
  5244. + case 1:
  5245. + select_peripheral(PE(0), PERIPH_B, 0); /* CC */
  5246. + select_peripheral(PC(20), PERIPH_A, 0); /* HSYNC */
  5247. + select_peripheral(PC(21), PERIPH_A, 0); /* PCLK */
  5248. + select_peripheral(PC(22), PERIPH_A, 0); /* VSYNC */
  5249. + select_peripheral(PE(1), PERIPH_B, 0); /* DVAL */
  5250. + select_peripheral(PE(2), PERIPH_B, 0); /* MODE */
  5251. + select_peripheral(PC(25), PERIPH_A, 0); /* PWR */
  5252. + select_peripheral(PE(3), PERIPH_B, 0); /* DATA0 */
  5253. + select_peripheral(PE(4), PERIPH_B, 0); /* DATA1 */
  5254. + select_peripheral(PE(5), PERIPH_B, 0); /* DATA2 */
  5255. + select_peripheral(PE(6), PERIPH_B, 0); /* DATA3 */
  5256. + select_peripheral(PE(7), PERIPH_B, 0); /* DATA4 */
  5257. + select_peripheral(PC(31), PERIPH_A, 0); /* DATA5 */
  5258. + select_peripheral(PD(0), PERIPH_A, 0); /* DATA6 */
  5259. + select_peripheral(PD(1), PERIPH_A, 0); /* DATA7 */
  5260. + select_peripheral(PE(8), PERIPH_B, 0); /* DATA8 */
  5261. + select_peripheral(PE(9), PERIPH_B, 0); /* DATA9 */
  5262. + select_peripheral(PE(10), PERIPH_B, 0); /* DATA10 */
  5263. + select_peripheral(PE(11), PERIPH_B, 0); /* DATA11 */
  5264. + select_peripheral(PE(12), PERIPH_B, 0); /* DATA12 */
  5265. + select_peripheral(PD(7), PERIPH_A, 0); /* DATA13 */
  5266. + select_peripheral(PD(8), PERIPH_A, 0); /* DATA14 */
  5267. + select_peripheral(PD(9), PERIPH_A, 0); /* DATA15 */
  5268. + select_peripheral(PE(13), PERIPH_B, 0); /* DATA16 */
  5269. + select_peripheral(PE(14), PERIPH_B, 0); /* DATA17 */
  5270. + select_peripheral(PE(15), PERIPH_B, 0); /* DATA18 */
  5271. + select_peripheral(PE(16), PERIPH_B, 0); /* DATA19 */
  5272. + select_peripheral(PE(17), PERIPH_B, 0); /* DATA20 */
  5273. + select_peripheral(PE(18), PERIPH_B, 0); /* DATA21 */
  5274. + select_peripheral(PD(16), PERIPH_A, 0); /* DATA22 */
  5275. + select_peripheral(PD(17), PERIPH_A, 0); /* DATA23 */
  5276. + break;
  5277. + default:
  5278. + goto err_invalid_id;
  5279. + }
  5280. clk_set_parent(&atmel_lcdfb0_pixclk, &pll0);
  5281. clk_set_rate(&atmel_lcdfb0_pixclk, clk_get_rate(&pll0));
  5282. @@ -1351,9 +1648,39 @@
  5283. .index = 6,
  5284. };
  5285. +#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
  5286. + [idx] = { \
  5287. + .name = nam, \
  5288. + .index = idx, \
  5289. + .fifo_size = maxpkt, \
  5290. + .nr_banks = maxbk, \
  5291. + .can_dma = dma, \
  5292. + .can_isoc = isoc, \
  5293. + }
  5294. +
  5295. +static struct usba_ep_data at32_usba_ep[] __initdata = {
  5296. + EP("ep0", 0, 64, 1, 0, 0),
  5297. + EP("ep1", 1, 512, 2, 1, 1),
  5298. + EP("ep2", 2, 512, 2, 1, 1),
  5299. + EP("ep3-int", 3, 64, 3, 1, 0),
  5300. + EP("ep4-int", 4, 64, 3, 1, 0),
  5301. + EP("ep5", 5, 1024, 3, 1, 1),
  5302. + EP("ep6", 6, 1024, 3, 1, 1),
  5303. +};
  5304. +
  5305. +#undef EP
  5306. +
  5307. struct platform_device *__init
  5308. at32_add_device_usba(unsigned int id, struct usba_platform_data *data)
  5309. {
  5310. + /*
  5311. + * pdata doesn't have room for any endpoints, so we need to
  5312. + * append room for the ones we need right after it.
  5313. + */
  5314. + struct {
  5315. + struct usba_platform_data pdata;
  5316. + struct usba_ep_data ep[7];
  5317. + } usba_data;
  5318. struct platform_device *pdev;
  5319. if (id != 0)
  5320. @@ -1367,13 +1694,20 @@
  5321. ARRAY_SIZE(usba0_resource)))
  5322. goto out_free_pdev;
  5323. - if (data) {
  5324. - if (platform_device_add_data(pdev, data, sizeof(*data)))
  5325. - goto out_free_pdev;
  5326. + if (data)
  5327. + usba_data.pdata.vbus_pin = data->vbus_pin;
  5328. + else
  5329. + usba_data.pdata.vbus_pin = -EINVAL;
  5330. - if (data->vbus_pin != GPIO_PIN_NONE)
  5331. - at32_select_gpio(data->vbus_pin, 0);
  5332. - }
  5333. + data = &usba_data.pdata;
  5334. + data->num_ep = ARRAY_SIZE(at32_usba_ep);
  5335. + memcpy(data->ep, at32_usba_ep, sizeof(at32_usba_ep));
  5336. +
  5337. + if (platform_device_add_data(pdev, data, sizeof(usba_data)))
  5338. + goto out_free_pdev;
  5339. +
  5340. + if (data->vbus_pin >= 0)
  5341. + at32_select_gpio(data->vbus_pin, 0);
  5342. usba0_pclk.dev = &pdev->dev;
  5343. usba0_hclk.dev = &pdev->dev;
  5344. @@ -1526,6 +1860,58 @@
  5345. #endif
  5346. /* --------------------------------------------------------------------
  5347. + * NAND Flash / SmartMedia
  5348. + * -------------------------------------------------------------------- */
  5349. +static struct resource smc_cs3_resource[] __initdata = {
  5350. + {
  5351. + .start = 0x0c000000,
  5352. + .end = 0x0fffffff,
  5353. + .flags = IORESOURCE_MEM,
  5354. + }, {
  5355. + .start = 0xfff03c00,
  5356. + .end = 0xfff03fff,
  5357. + .flags = IORESOURCE_MEM,
  5358. + },
  5359. +};
  5360. +
  5361. +struct platform_device *__init
  5362. +at32_add_device_nand(unsigned int id, struct atmel_nand_data *data)
  5363. +{
  5364. + struct platform_device *pdev;
  5365. +
  5366. + if (id != 0 || !data)
  5367. + return NULL;
  5368. +
  5369. + pdev = platform_device_alloc("atmel_nand", id);
  5370. + if (!pdev)
  5371. + goto fail;
  5372. +
  5373. + if (platform_device_add_resources(pdev, smc_cs3_resource,
  5374. + ARRAY_SIZE(smc_cs3_resource)))
  5375. + goto fail;
  5376. +
  5377. + if (platform_device_add_data(pdev, data,
  5378. + sizeof(struct atmel_nand_data)))
  5379. + goto fail;
  5380. +
  5381. + set_ebi_sfr_bits(HMATRIX_BIT(CS3A));
  5382. + if (data->enable_pin)
  5383. + at32_select_gpio(data->enable_pin,
  5384. + AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
  5385. + if (data->rdy_pin)
  5386. + at32_select_gpio(data->rdy_pin, 0);
  5387. + if (data->det_pin)
  5388. + at32_select_gpio(data->det_pin, 0);
  5389. +
  5390. + platform_device_add(pdev);
  5391. + return pdev;
  5392. +
  5393. +fail:
  5394. + platform_device_put(pdev);
  5395. + return NULL;
  5396. +}
  5397. +
  5398. +/* --------------------------------------------------------------------
  5399. * AC97C
  5400. * -------------------------------------------------------------------- */
  5401. static struct resource atmel_ac97c0_resource[] __initdata = {
  5402. @@ -1683,6 +2069,7 @@
  5403. &hmatrix_clk,
  5404. &ebi_clk,
  5405. &hramc_clk,
  5406. + &sdramc_clk,
  5407. &smc0_pclk,
  5408. &smc0_mck,
  5409. &pdc_hclk,
  5410. @@ -1694,7 +2081,10 @@
  5411. &pio2_mck,
  5412. &pio3_mck,
  5413. &pio4_mck,
  5414. - &at32_systc0_pclk,
  5415. + &at32_tcb0_t0_clk,
  5416. + &at32_tcb1_t0_clk,
  5417. + &atmel_psif0_pclk,
  5418. + &atmel_psif1_pclk,
  5419. &atmel_usart0_usart,
  5420. &atmel_usart1_usart,
  5421. &atmel_usart2_usart,
  5422. @@ -1730,16 +2120,7 @@
  5423. };
  5424. unsigned int at32_nr_clocks = ARRAY_SIZE(at32_clock_list);
  5425. -void __init at32_portmux_init(void)
  5426. -{
  5427. - at32_init_pio(&pio0_device);
  5428. - at32_init_pio(&pio1_device);
  5429. - at32_init_pio(&pio2_device);
  5430. - at32_init_pio(&pio3_device);
  5431. - at32_init_pio(&pio4_device);
  5432. -}
  5433. -
  5434. -void __init at32_clock_init(void)
  5435. +void __init setup_platform(void)
  5436. {
  5437. u32 cpu_mask = 0, hsb_mask = 0, pba_mask = 0, pbb_mask = 0;
  5438. int i;
  5439. @@ -1794,4 +2175,36 @@
  5440. pm_writel(HSB_MASK, hsb_mask);
  5441. pm_writel(PBA_MASK, pba_mask);
  5442. pm_writel(PBB_MASK, pbb_mask);
  5443. +
  5444. + /* Initialize the port muxes */
  5445. + at32_init_pio(&pio0_device);
  5446. + at32_init_pio(&pio1_device);
  5447. + at32_init_pio(&pio2_device);
  5448. + at32_init_pio(&pio3_device);
  5449. + at32_init_pio(&pio4_device);
  5450. +}
  5451. +
  5452. +struct gen_pool *sram_pool;
  5453. +
  5454. +static int __init sram_init(void)
  5455. +{
  5456. + struct gen_pool *pool;
  5457. +
  5458. + /* 1KiB granularity */
  5459. + pool = gen_pool_create(10, -1);
  5460. + if (!pool)
  5461. + goto fail;
  5462. +
  5463. + if (gen_pool_add(pool, 0x24000000, 0x8000, -1))
  5464. + goto err_pool_add;
  5465. +
  5466. + sram_pool = pool;
  5467. + return 0;
  5468. +
  5469. +err_pool_add:
  5470. + gen_pool_destroy(pool);
  5471. +fail:
  5472. + pr_err("Failed to create SRAM pool\n");
  5473. + return -ENOMEM;
  5474. }
  5475. +core_initcall(sram_init);
  5476. --- a/arch/avr32/mach-at32ap/at32ap.c
  5477. +++ /dev/null
  5478. @@ -1,56 +0,0 @@
  5479. -/*
  5480. - * Copyright (C) 2006 Atmel Corporation
  5481. - *
  5482. - * This program is free software; you can redistribute it and/or modify
  5483. - * it under the terms of the GNU General Public License version 2 as
  5484. - * published by the Free Software Foundation.
  5485. - */
  5486. -
  5487. -#include <linux/clk.h>
  5488. -#include <linux/err.h>
  5489. -#include <linux/init.h>
  5490. -#include <linux/platform_device.h>
  5491. -
  5492. -#include <asm/arch/init.h>
  5493. -
  5494. -void __init setup_platform(void)
  5495. -{
  5496. - at32_clock_init();
  5497. - at32_portmux_init();
  5498. -}
  5499. -
  5500. -static int __init pdc_probe(struct platform_device *pdev)
  5501. -{
  5502. - struct clk *pclk, *hclk;
  5503. -
  5504. - pclk = clk_get(&pdev->dev, "pclk");
  5505. - if (IS_ERR(pclk)) {
  5506. - dev_err(&pdev->dev, "no pclk defined\n");
  5507. - return PTR_ERR(pclk);
  5508. - }
  5509. - hclk = clk_get(&pdev->dev, "hclk");
  5510. - if (IS_ERR(hclk)) {
  5511. - dev_err(&pdev->dev, "no hclk defined\n");
  5512. - clk_put(pclk);
  5513. - return PTR_ERR(hclk);
  5514. - }
  5515. -
  5516. - clk_enable(pclk);
  5517. - clk_enable(hclk);
  5518. -
  5519. - dev_info(&pdev->dev, "Atmel Peripheral DMA Controller enabled\n");
  5520. - return 0;
  5521. -}
  5522. -
  5523. -static struct platform_driver pdc_driver = {
  5524. - .probe = pdc_probe,
  5525. - .driver = {
  5526. - .name = "pdc",
  5527. - },
  5528. -};
  5529. -
  5530. -static int __init pdc_init(void)
  5531. -{
  5532. - return platform_driver_register(&pdc_driver);
  5533. -}
  5534. -arch_initcall(pdc_init);
  5535. --- a/arch/avr32/mach-at32ap/cpufreq.c
  5536. +++ b/arch/avr32/mach-at32ap/cpufreq.c
  5537. @@ -108,5 +108,4 @@
  5538. {
  5539. return cpufreq_register_driver(&at32_driver);
  5540. }
  5541. -
  5542. -arch_initcall(at32_cpufreq_init);
  5543. +late_initcall(at32_cpufreq_init);
  5544. --- /dev/null
  5545. +++ b/arch/avr32/mach-at32ap/gpio-dev.c
  5546. @@ -0,0 +1,573 @@
  5547. +/*
  5548. + * GPIO /dev and configfs interface
  5549. + *
  5550. + * Copyright (C) 2006-2007 Atmel Corporation
  5551. + *
  5552. + * This program is free software; you can redistribute it and/or modify
  5553. + * it under the terms of the GNU General Public License version 2 as
  5554. + * published by the Free Software Foundation.
  5555. + */
  5556. +#include <linux/kernel.h>
  5557. +#include <linux/configfs.h>
  5558. +#include <linux/cdev.h>
  5559. +#include <linux/device.h>
  5560. +#include <linux/fs.h>
  5561. +#include <linux/interrupt.h>
  5562. +#include <linux/module.h>
  5563. +#include <linux/poll.h>
  5564. +#include <linux/uaccess.h>
  5565. +#include <linux/wait.h>
  5566. +
  5567. +#include <asm/gpio.h>
  5568. +#include <asm/arch/portmux.h>
  5569. +
  5570. +#define GPIO_DEV_MAX 8
  5571. +
  5572. +static struct class *gpio_dev_class;
  5573. +static dev_t gpio_devt;
  5574. +
  5575. +struct gpio_item {
  5576. + spinlock_t lock;
  5577. +
  5578. + int enabled;
  5579. + int initialized;
  5580. + int port;
  5581. + u32 pin_mask;
  5582. + u32 oe_mask;
  5583. +
  5584. + /* Pin state last time we read it (for blocking reads) */
  5585. + u32 pin_state;
  5586. + int changed;
  5587. +
  5588. + wait_queue_head_t change_wq;
  5589. + struct fasync_struct *async_queue;
  5590. +
  5591. + int id;
  5592. + struct class_device *gpio_dev;
  5593. + struct cdev char_dev;
  5594. + struct config_item item;
  5595. +};
  5596. +
  5597. +struct gpio_attribute {
  5598. + struct configfs_attribute attr;
  5599. + ssize_t (*show)(struct gpio_item *, char *);
  5600. + ssize_t (*store)(struct gpio_item *, const char *, size_t);
  5601. +};
  5602. +
  5603. +static irqreturn_t gpio_dev_interrupt(int irq, void *dev_id)
  5604. +{
  5605. + struct gpio_item *gpio = dev_id;
  5606. + u32 old_state, new_state;
  5607. +
  5608. + old_state = gpio->pin_state;
  5609. + new_state = at32_gpio_get_value_multiple(gpio->port, gpio->pin_mask);
  5610. + gpio->pin_state = new_state;
  5611. +
  5612. + if (new_state != old_state) {
  5613. + gpio->changed = 1;
  5614. + wake_up_interruptible(&gpio->change_wq);
  5615. +
  5616. + if (gpio->async_queue)
  5617. + kill_fasync(&gpio->async_queue, SIGIO, POLL_IN);
  5618. + }
  5619. +
  5620. + return IRQ_HANDLED;
  5621. +}
  5622. +
  5623. +static int gpio_dev_open(struct inode *inode, struct file *file)
  5624. +{
  5625. + struct gpio_item *gpio = container_of(inode->i_cdev,
  5626. + struct gpio_item,
  5627. + char_dev);
  5628. + unsigned int irq;
  5629. + unsigned int i;
  5630. + int ret;
  5631. +
  5632. + nonseekable_open(inode, file);
  5633. + config_item_get(&gpio->item);
  5634. + file->private_data = gpio;
  5635. +
  5636. + gpio->pin_state = at32_gpio_get_value_multiple(gpio->port,
  5637. + gpio->pin_mask);
  5638. + gpio->changed = 1;
  5639. +
  5640. + for (i = 0; i < 32; i++) {
  5641. + if (gpio->pin_mask & (1 << i)) {
  5642. + irq = gpio_to_irq(32 * gpio->port + i);
  5643. + ret = request_irq(irq, gpio_dev_interrupt, 0,
  5644. + "gpio-dev", gpio);
  5645. + if (ret)
  5646. + goto err_irq;
  5647. + }
  5648. + }
  5649. +
  5650. + return 0;
  5651. +
  5652. +err_irq:
  5653. + while (i--) {
  5654. + if (gpio->pin_mask & (1 << i)) {
  5655. + irq = gpio_to_irq(32 * gpio->port + i);
  5656. + free_irq(irq, gpio);
  5657. + }
  5658. + }
  5659. +
  5660. + config_item_put(&gpio->item);
  5661. +
  5662. + return ret;
  5663. +}
  5664. +
  5665. +static int gpio_dev_fasync(int fd, struct file *file, int mode)
  5666. +{
  5667. + struct gpio_item *gpio = file->private_data;
  5668. +
  5669. + return fasync_helper(fd, file, mode, &gpio->async_queue);
  5670. +}
  5671. +
  5672. +static int gpio_dev_release(struct inode *inode, struct file *file)
  5673. +{
  5674. + struct gpio_item *gpio = file->private_data;
  5675. + unsigned int irq;
  5676. + unsigned int i;
  5677. +
  5678. + gpio_dev_fasync(-1, file, 0);
  5679. +
  5680. + for (i = 0; i < 32; i++) {
  5681. + if (gpio->pin_mask & (1 << i)) {
  5682. + irq = gpio_to_irq(32 * gpio->port + i);
  5683. + free_irq(irq, gpio);
  5684. + }
  5685. + }
  5686. +
  5687. + config_item_put(&gpio->item);
  5688. +
  5689. + return 0;
  5690. +}
  5691. +
  5692. +static unsigned int gpio_dev_poll(struct file *file, poll_table *wait)
  5693. +{
  5694. + struct gpio_item *gpio = file->private_data;
  5695. + unsigned int mask = 0;
  5696. +
  5697. + poll_wait(file, &gpio->change_wq, wait);
  5698. + if (gpio->changed)
  5699. + mask |= POLLIN | POLLRDNORM;
  5700. +
  5701. + return mask;
  5702. +}
  5703. +
  5704. +static ssize_t gpio_dev_read(struct file *file, char __user *buf,
  5705. + size_t count, loff_t *offset)
  5706. +{
  5707. + struct gpio_item *gpio = file->private_data;
  5708. + u32 value;
  5709. +
  5710. + spin_lock_irq(&gpio->lock);
  5711. + while (!gpio->changed) {
  5712. + spin_unlock_irq(&gpio->lock);
  5713. +
  5714. + if (file->f_flags & O_NONBLOCK)
  5715. + return -EAGAIN;
  5716. +
  5717. + if (wait_event_interruptible(gpio->change_wq, gpio->changed))
  5718. + return -ERESTARTSYS;
  5719. +
  5720. + spin_lock_irq(&gpio->lock);
  5721. + }
  5722. +
  5723. + gpio->changed = 0;
  5724. + value = at32_gpio_get_value_multiple(gpio->port, gpio->pin_mask);
  5725. +
  5726. + spin_unlock_irq(&gpio->lock);
  5727. +
  5728. + count = min(count, (size_t)4);
  5729. + if (copy_to_user(buf, &value, count))
  5730. + return -EFAULT;
  5731. +
  5732. + return count;
  5733. +}
  5734. +
  5735. +static ssize_t gpio_dev_write(struct file *file, const char __user *buf,
  5736. + size_t count, loff_t *offset)
  5737. +{
  5738. + struct gpio_item *gpio = file->private_data;
  5739. + u32 value = 0;
  5740. + u32 mask = ~0UL;
  5741. +
  5742. + count = min(count, (size_t)4);
  5743. + if (copy_from_user(&value, buf, count))
  5744. + return -EFAULT;
  5745. +
  5746. + /* Assuming big endian */
  5747. + mask <<= (4 - count) * 8;
  5748. + mask &= gpio->pin_mask;
  5749. +
  5750. + at32_gpio_set_value_multiple(gpio->port, value, mask);
  5751. +
  5752. + return count;
  5753. +}
  5754. +
  5755. +static struct file_operations gpio_dev_fops = {
  5756. + .owner = THIS_MODULE,
  5757. + .llseek = no_llseek,
  5758. + .open = gpio_dev_open,
  5759. + .release = gpio_dev_release,
  5760. + .fasync = gpio_dev_fasync,
  5761. + .poll = gpio_dev_poll,
  5762. + .read = gpio_dev_read,
  5763. + .write = gpio_dev_write,
  5764. +};
  5765. +
  5766. +static struct gpio_item *to_gpio_item(struct config_item *item)
  5767. +{
  5768. + return item ? container_of(item, struct gpio_item, item) : NULL;
  5769. +}
  5770. +
  5771. +static ssize_t gpio_show_gpio_id(struct gpio_item *gpio, char *page)
  5772. +{
  5773. + return sprintf(page, "%d\n", gpio->port);
  5774. +}
  5775. +
  5776. +static ssize_t gpio_store_gpio_id(struct gpio_item *gpio,
  5777. + const char *page, size_t count)
  5778. +{
  5779. + unsigned long id;
  5780. + char *p = (char *)page;
  5781. + ssize_t ret = -EINVAL;
  5782. +
  5783. + id = simple_strtoul(p, &p, 0);
  5784. + if (!p || (*p && (*p != '\n')))
  5785. + return -EINVAL;
  5786. +
  5787. + /* Switching PIO is not allowed when live... */
  5788. + spin_lock(&gpio->lock);
  5789. + if (!gpio->enabled) {
  5790. + ret = -ENXIO;
  5791. + if (at32_gpio_port_is_valid(id)) {
  5792. + gpio->port = id;
  5793. + ret = count;
  5794. + }
  5795. + }
  5796. + spin_unlock(&gpio->lock);
  5797. +
  5798. + return ret;
  5799. +}
  5800. +
  5801. +static ssize_t gpio_show_pin_mask(struct gpio_item *gpio, char *page)
  5802. +{
  5803. + return sprintf(page, "0x%08x\n", gpio->pin_mask);
  5804. +}
  5805. +
  5806. +static ssize_t gpio_store_pin_mask(struct gpio_item *gpio,
  5807. + const char *page, size_t count)
  5808. +{
  5809. + u32 new_mask;
  5810. + char *p = (char *)page;
  5811. + ssize_t ret = -EINVAL;
  5812. +
  5813. + new_mask = simple_strtoul(p, &p, 0);
  5814. + if (!p || (*p && (*p != '\n')))
  5815. + return -EINVAL;
  5816. +
  5817. + /* Can't update the pin mask while live. */
  5818. + spin_lock(&gpio->lock);
  5819. + if (!gpio->enabled) {
  5820. + gpio->oe_mask &= new_mask;
  5821. + gpio->pin_mask = new_mask;
  5822. + ret = count;
  5823. + }
  5824. + spin_unlock(&gpio->lock);
  5825. +
  5826. + return ret;
  5827. +}
  5828. +
  5829. +static ssize_t gpio_show_oe_mask(struct gpio_item *gpio, char *page)
  5830. +{
  5831. + return sprintf(page, "0x%08x\n", gpio->oe_mask);
  5832. +}
  5833. +
  5834. +static ssize_t gpio_store_oe_mask(struct gpio_item *gpio,
  5835. + const char *page, size_t count)
  5836. +{
  5837. + u32 mask;
  5838. + char *p = (char *)page;
  5839. + ssize_t ret = -EINVAL;
  5840. +
  5841. + mask = simple_strtoul(p, &p, 0);
  5842. + if (!p || (*p && (*p != '\n')))
  5843. + return -EINVAL;
  5844. +
  5845. + spin_lock(&gpio->lock);
  5846. + if (!gpio->enabled) {
  5847. + gpio->oe_mask = mask & gpio->pin_mask;
  5848. + ret = count;
  5849. + }
  5850. + spin_unlock(&gpio->lock);
  5851. +
  5852. + return ret;
  5853. +}
  5854. +
  5855. +static ssize_t gpio_show_enabled(struct gpio_item *gpio, char *page)
  5856. +{
  5857. + return sprintf(page, "%d\n", gpio->enabled);
  5858. +}
  5859. +
  5860. +static ssize_t gpio_store_enabled(struct gpio_item *gpio,
  5861. + const char *page, size_t count)
  5862. +{
  5863. + char *p = (char *)page;
  5864. + int enabled;
  5865. + int ret;
  5866. +
  5867. + enabled = simple_strtoul(p, &p, 0);
  5868. + if (!p || (*p && (*p != '\n')))
  5869. + return -EINVAL;
  5870. +
  5871. + /* make it a boolean value */
  5872. + enabled = !!enabled;
  5873. +
  5874. + if (gpio->enabled == enabled)
  5875. + /* No change; do nothing. */
  5876. + return count;
  5877. +
  5878. + BUG_ON(gpio->id >= GPIO_DEV_MAX);
  5879. +
  5880. + if (!enabled) {
  5881. + class_device_unregister(gpio->gpio_dev);
  5882. + cdev_del(&gpio->char_dev);
  5883. + at32_deselect_pins(gpio->port, gpio->pin_mask);
  5884. + gpio->initialized = 0;
  5885. + } else {
  5886. + if (gpio->port < 0 || !gpio->pin_mask)
  5887. + return -ENODEV;
  5888. + }
  5889. +
  5890. + /* Disallow any updates to gpio_id or pin_mask */
  5891. + spin_lock(&gpio->lock);
  5892. + gpio->enabled = enabled;
  5893. + spin_unlock(&gpio->lock);
  5894. +
  5895. + if (!enabled)
  5896. + return count;
  5897. +
  5898. + /* Now, try to allocate the pins */
  5899. + ret = at32_select_gpio_pins(gpio->port, gpio->pin_mask, gpio->oe_mask);
  5900. + if (ret)
  5901. + goto err_alloc_pins;
  5902. +
  5903. + gpio->initialized = 1;
  5904. +
  5905. + cdev_init(&gpio->char_dev, &gpio_dev_fops);
  5906. + gpio->char_dev.owner = THIS_MODULE;
  5907. + ret = cdev_add(&gpio->char_dev, MKDEV(MAJOR(gpio_devt), gpio->id), 1);
  5908. + if (ret < 0)
  5909. + goto err_cdev_add;
  5910. + gpio->gpio_dev = class_device_create(gpio_dev_class, NULL,
  5911. + MKDEV(MAJOR(gpio_devt), gpio->id),
  5912. + NULL,
  5913. + "gpio%d", gpio->id);
  5914. + if (IS_ERR(gpio->gpio_dev)) {
  5915. + printk(KERN_ERR "failed to create gpio%d\n", gpio->id);
  5916. + ret = PTR_ERR(gpio->gpio_dev);
  5917. + goto err_class_dev;
  5918. + }
  5919. +
  5920. + printk(KERN_INFO "created gpio%d (port%d/0x%08x) as (%d:%d)\n",
  5921. + gpio->id, gpio->port, gpio->pin_mask,
  5922. + MAJOR(gpio->gpio_dev->devt), MINOR(gpio->gpio_dev->devt));
  5923. +
  5924. + return 0;
  5925. +
  5926. +err_class_dev:
  5927. + cdev_del(&gpio->char_dev);
  5928. +err_cdev_add:
  5929. + at32_deselect_pins(gpio->port, gpio->pin_mask);
  5930. + gpio->initialized = 0;
  5931. +err_alloc_pins:
  5932. + spin_lock(&gpio->lock);
  5933. + gpio->enabled = 0;
  5934. + spin_unlock(&gpio->lock);
  5935. +
  5936. + return ret;
  5937. +}
  5938. +
  5939. +static struct gpio_attribute gpio_item_attr_gpio_id = {
  5940. + .attr = {
  5941. + .ca_owner = THIS_MODULE,
  5942. + .ca_name = "gpio_id",
  5943. + .ca_mode = S_IRUGO | S_IWUSR,
  5944. + },
  5945. + .show = gpio_show_gpio_id,
  5946. + .store = gpio_store_gpio_id,
  5947. +};
  5948. +static struct gpio_attribute gpio_item_attr_pin_mask = {
  5949. + .attr = {
  5950. + .ca_owner = THIS_MODULE,
  5951. + .ca_name = "pin_mask",
  5952. + .ca_mode = S_IRUGO | S_IWUSR,
  5953. + },
  5954. + .show = gpio_show_pin_mask,
  5955. + .store = gpio_store_pin_mask,
  5956. +};
  5957. +static struct gpio_attribute gpio_item_attr_oe_mask = {
  5958. + .attr = {
  5959. + .ca_owner = THIS_MODULE,
  5960. + .ca_name = "oe_mask",
  5961. + .ca_mode = S_IRUGO | S_IWUSR,
  5962. + },
  5963. + .show = gpio_show_oe_mask,
  5964. + .store = gpio_store_oe_mask,
  5965. +};
  5966. +static struct gpio_attribute gpio_item_attr_enabled = {
  5967. + .attr = {
  5968. + .ca_owner = THIS_MODULE,
  5969. + .ca_name = "enabled",
  5970. + .ca_mode = S_IRUGO | S_IWUSR,
  5971. + },
  5972. + .show = gpio_show_enabled,
  5973. + .store = gpio_store_enabled,
  5974. +};
  5975. +
  5976. +static struct configfs_attribute *gpio_item_attrs[] = {
  5977. + &gpio_item_attr_gpio_id.attr,
  5978. + &gpio_item_attr_pin_mask.attr,
  5979. + &gpio_item_attr_oe_mask.attr,
  5980. + &gpio_item_attr_enabled.attr,
  5981. + NULL,
  5982. +};
  5983. +
  5984. +static ssize_t gpio_show_attr(struct config_item *item,
  5985. + struct configfs_attribute *attr,
  5986. + char *page)
  5987. +{
  5988. + struct gpio_item *gpio_item = to_gpio_item(item);
  5989. + struct gpio_attribute *gpio_attr
  5990. + = container_of(attr, struct gpio_attribute, attr);
  5991. + ssize_t ret = 0;
  5992. +
  5993. + if (gpio_attr->show)
  5994. + ret = gpio_attr->show(gpio_item, page);
  5995. + return ret;
  5996. +}
  5997. +
  5998. +static ssize_t gpio_store_attr(struct config_item *item,
  5999. + struct configfs_attribute *attr,
  6000. + const char *page, size_t count)
  6001. +{
  6002. + struct gpio_item *gpio_item = to_gpio_item(item);
  6003. + struct gpio_attribute *gpio_attr
  6004. + = container_of(attr, struct gpio_attribute, attr);
  6005. + ssize_t ret = -EINVAL;
  6006. +
  6007. + if (gpio_attr->store)
  6008. + ret = gpio_attr->store(gpio_item, page, count);
  6009. + return ret;
  6010. +}
  6011. +
  6012. +static void gpio_release(struct config_item *item)
  6013. +{
  6014. + kfree(to_gpio_item(item));
  6015. +}
  6016. +
  6017. +static struct configfs_item_operations gpio_item_ops = {
  6018. + .release = gpio_release,
  6019. + .show_attribute = gpio_show_attr,
  6020. + .store_attribute = gpio_store_attr,
  6021. +};
  6022. +
  6023. +static struct config_item_type gpio_item_type = {
  6024. + .ct_item_ops = &gpio_item_ops,
  6025. + .ct_attrs = gpio_item_attrs,
  6026. + .ct_owner = THIS_MODULE,
  6027. +};
  6028. +
  6029. +static struct config_item *gpio_make_item(struct config_group *group,
  6030. + const char *name)
  6031. +{
  6032. + static int next_id;
  6033. + struct gpio_item *gpio;
  6034. +
  6035. + if (next_id >= GPIO_DEV_MAX)
  6036. + return NULL;
  6037. +
  6038. + gpio = kzalloc(sizeof(struct gpio_item), GFP_KERNEL);
  6039. + if (!gpio)
  6040. + return NULL;
  6041. +
  6042. + gpio->id = next_id++;
  6043. + config_item_init_type_name(&gpio->item, name, &gpio_item_type);
  6044. + spin_lock_init(&gpio->lock);
  6045. + init_waitqueue_head(&gpio->change_wq);
  6046. +
  6047. + return &gpio->item;
  6048. +}
  6049. +
  6050. +static void gpio_drop_item(struct config_group *group,
  6051. + struct config_item *item)
  6052. +{
  6053. + struct gpio_item *gpio = to_gpio_item(item);
  6054. +
  6055. + spin_lock(&gpio->lock);
  6056. + if (gpio->enabled) {
  6057. + class_device_unregister(gpio->gpio_dev);
  6058. + cdev_del(&gpio->char_dev);
  6059. + }
  6060. +
  6061. + if (gpio->initialized) {
  6062. + at32_deselect_pins(gpio->port, gpio->pin_mask);
  6063. + gpio->initialized = 0;
  6064. + gpio->enabled = 0;
  6065. + }
  6066. + spin_unlock(&gpio->lock);
  6067. +}
  6068. +
  6069. +static struct configfs_group_operations gpio_group_ops = {
  6070. + .make_item = gpio_make_item,
  6071. + .drop_item = gpio_drop_item,
  6072. +};
  6073. +
  6074. +static struct config_item_type gpio_group_type = {
  6075. + .ct_group_ops = &gpio_group_ops,
  6076. + .ct_owner = THIS_MODULE,
  6077. +};
  6078. +
  6079. +static struct configfs_subsystem gpio_subsys = {
  6080. + .su_group = {
  6081. + .cg_item = {
  6082. + .ci_namebuf = "gpio",
  6083. + .ci_type = &gpio_group_type,
  6084. + },
  6085. + },
  6086. +};
  6087. +
  6088. +static int __init gpio_dev_init(void)
  6089. +{
  6090. + int err;
  6091. +
  6092. + gpio_dev_class = class_create(THIS_MODULE, "gpio-dev");
  6093. + if (IS_ERR(gpio_dev_class)) {
  6094. + err = PTR_ERR(gpio_dev_class);
  6095. + goto err_class_create;
  6096. + }
  6097. +
  6098. + err = alloc_chrdev_region(&gpio_devt, 0, GPIO_DEV_MAX, "gpio");
  6099. + if (err < 0)
  6100. + goto err_alloc_chrdev;
  6101. +
  6102. + /* Configfs initialization */
  6103. + config_group_init(&gpio_subsys.su_group);
  6104. + mutex_init(&gpio_subsys.su_mutex);
  6105. + err = configfs_register_subsystem(&gpio_subsys);
  6106. + if (err)
  6107. + goto err_register_subsys;
  6108. +
  6109. + return 0;
  6110. +
  6111. +err_register_subsys:
  6112. + unregister_chrdev_region(gpio_devt, GPIO_DEV_MAX);
  6113. +err_alloc_chrdev:
  6114. + class_destroy(gpio_dev_class);
  6115. +err_class_create:
  6116. + printk(KERN_WARNING "Failed to initialize gpio /dev interface\n");
  6117. + return err;
  6118. +}
  6119. +late_initcall(gpio_dev_init);
  6120. --- a/arch/avr32/mach-at32ap/hsmc.c
  6121. +++ b/arch/avr32/mach-at32ap/hsmc.c
  6122. @@ -278,4 +278,4 @@
  6123. {
  6124. return platform_driver_register(&hsmc_driver);
  6125. }
  6126. -arch_initcall(hsmc_init);
  6127. +core_initcall(hsmc_init);
  6128. --- a/arch/avr32/mach-at32ap/intc.c
  6129. +++ b/arch/avr32/mach-at32ap/intc.c
  6130. @@ -1,5 +1,5 @@
  6131. /*
  6132. - * Copyright (C) 2006 Atmel Corporation
  6133. + * Copyright (C) 2006, 2008 Atmel Corporation
  6134. *
  6135. * This program is free software; you can redistribute it and/or modify
  6136. * it under the terms of the GNU General Public License version 2 as
  6137. @@ -12,15 +12,20 @@
  6138. #include <linux/interrupt.h>
  6139. #include <linux/irq.h>
  6140. #include <linux/platform_device.h>
  6141. +#include <linux/sysdev.h>
  6142. -#include <asm/intc.h>
  6143. #include <asm/io.h>
  6144. #include "intc.h"
  6145. struct intc {
  6146. - void __iomem *regs;
  6147. - struct irq_chip chip;
  6148. + void __iomem *regs;
  6149. + struct irq_chip chip;
  6150. + struct sys_device sysdev;
  6151. +#ifdef CONFIG_PM
  6152. + unsigned long suspend_ipr;
  6153. + unsigned long saved_ipr[64];
  6154. +#endif
  6155. };
  6156. extern struct platform_device at32_intc0_device;
  6157. @@ -137,6 +142,74 @@
  6158. panic("Interrupt controller initialization failed!\n");
  6159. }
  6160. +#ifdef CONFIG_PM
  6161. +void intc_set_suspend_handler(unsigned long offset)
  6162. +{
  6163. + intc0.suspend_ipr = offset;
  6164. +}
  6165. +
  6166. +static int intc_suspend(struct sys_device *sdev, pm_message_t state)
  6167. +{
  6168. + struct intc *intc = container_of(sdev, struct intc, sysdev);
  6169. + int i;
  6170. +
  6171. + if (unlikely(!irqs_disabled())) {
  6172. + pr_err("intc_suspend: called with interrupts enabled\n");
  6173. + return -EINVAL;
  6174. + }
  6175. +
  6176. + if (unlikely(!intc->suspend_ipr)) {
  6177. + pr_err("intc_suspend: suspend_ipr not initialized\n");
  6178. + return -EINVAL;
  6179. + }
  6180. +
  6181. + for (i = 0; i < 64; i++) {
  6182. + intc->saved_ipr[i] = intc_readl(intc, INTPR0 + 4 * i);
  6183. + intc_writel(intc, INTPR0 + 4 * i, intc->suspend_ipr);
  6184. + }
  6185. +
  6186. + return 0;
  6187. +}
  6188. +
  6189. +static int intc_resume(struct sys_device *sdev)
  6190. +{
  6191. + struct intc *intc = container_of(sdev, struct intc, sysdev);
  6192. + int i;
  6193. +
  6194. + WARN_ON(!irqs_disabled());
  6195. +
  6196. + for (i = 0; i < 64; i++)
  6197. + intc_writel(intc, INTPR0 + 4 * i, intc->saved_ipr[i]);
  6198. +
  6199. + return 0;
  6200. +}
  6201. +#else
  6202. +#define intc_suspend NULL
  6203. +#define intc_resume NULL
  6204. +#endif
  6205. +
  6206. +static struct sysdev_class intc_class = {
  6207. + .name = "intc",
  6208. + .suspend = intc_suspend,
  6209. + .resume = intc_resume,
  6210. +};
  6211. +
  6212. +static int __init intc_init_sysdev(void)
  6213. +{
  6214. + int ret;
  6215. +
  6216. + ret = sysdev_class_register(&intc_class);
  6217. + if (ret)
  6218. + return ret;
  6219. +
  6220. + intc0.sysdev.id = 0;
  6221. + intc0.sysdev.cls = &intc_class;
  6222. + ret = sysdev_register(&intc0.sysdev);
  6223. +
  6224. + return ret;
  6225. +}
  6226. +device_initcall(intc_init_sysdev);
  6227. +
  6228. unsigned long intc_get_pending(unsigned int group)
  6229. {
  6230. return intc_readl(&intc0, INTREQ0 + 4 * group);
  6231. --- a/arch/avr32/mach-at32ap/Kconfig
  6232. +++ b/arch/avr32/mach-at32ap/Kconfig
  6233. @@ -26,6 +26,13 @@
  6234. endchoice
  6235. +config GPIO_DEV
  6236. + bool "GPIO /dev interface"
  6237. + select CONFIGFS_FS
  6238. + default n
  6239. + help
  6240. + Say `Y' to enable a /dev interface to the GPIO pins.
  6241. +
  6242. endmenu
  6243. endif # PLATFORM_AT32AP
  6244. --- a/arch/avr32/mach-at32ap/Makefile
  6245. +++ b/arch/avr32/mach-at32ap/Makefile
  6246. @@ -1,4 +1,9 @@
  6247. -obj-y += at32ap.o clock.o intc.o extint.o pio.o hsmc.o
  6248. -obj-$(CONFIG_CPU_AT32AP700X) += at32ap700x.o
  6249. -obj-$(CONFIG_CPU_AT32AP700X) += time-tc.o
  6250. +obj-y += pdc.o clock.o intc.o extint.o pio.o hsmc.o
  6251. +obj-$(CONFIG_CPU_AT32AP700X) += at32ap700x.o pm-at32ap700x.o
  6252. obj-$(CONFIG_CPU_FREQ_AT32AP) += cpufreq.o
  6253. +obj-$(CONFIG_GPIO_DEV) += gpio-dev.o
  6254. +obj-$(CONFIG_PM) += pm.o
  6255. +
  6256. +ifeq ($(CONFIG_PM_DEBUG),y)
  6257. +CFLAGS_pm.o += -DDEBUG
  6258. +endif
  6259. --- /dev/null
  6260. +++ b/arch/avr32/mach-at32ap/pdc.c
  6261. @@ -0,0 +1,48 @@
  6262. +/*
  6263. + * Copyright (C) 2006 Atmel Corporation
  6264. + *
  6265. + * This program is free software; you can redistribute it and/or modify
  6266. + * it under the terms of the GNU General Public License version 2 as
  6267. + * published by the Free Software Foundation.
  6268. + */
  6269. +
  6270. +#include <linux/clk.h>
  6271. +#include <linux/err.h>
  6272. +#include <linux/init.h>
  6273. +#include <linux/platform_device.h>
  6274. +
  6275. +static int __init pdc_probe(struct platform_device *pdev)
  6276. +{
  6277. + struct clk *pclk, *hclk;
  6278. +
  6279. + pclk = clk_get(&pdev->dev, "pclk");
  6280. + if (IS_ERR(pclk)) {
  6281. + dev_err(&pdev->dev, "no pclk defined\n");
  6282. + return PTR_ERR(pclk);
  6283. + }
  6284. + hclk = clk_get(&pdev->dev, "hclk");
  6285. + if (IS_ERR(hclk)) {
  6286. + dev_err(&pdev->dev, "no hclk defined\n");
  6287. + clk_put(pclk);
  6288. + return PTR_ERR(hclk);
  6289. + }
  6290. +
  6291. + clk_enable(pclk);
  6292. + clk_enable(hclk);
  6293. +
  6294. + dev_info(&pdev->dev, "Atmel Peripheral DMA Controller enabled\n");
  6295. + return 0;
  6296. +}
  6297. +
  6298. +static struct platform_driver pdc_driver = {
  6299. + .probe = pdc_probe,
  6300. + .driver = {
  6301. + .name = "pdc",
  6302. + },
  6303. +};
  6304. +
  6305. +static int __init pdc_init(void)
  6306. +{
  6307. + return platform_driver_register(&pdc_driver);
  6308. +}
  6309. +arch_initcall(pdc_init);
  6310. --- a/arch/avr32/mach-at32ap/pio.c
  6311. +++ b/arch/avr32/mach-at32ap/pio.c
  6312. @@ -157,6 +157,82 @@
  6313. dump_stack();
  6314. }
  6315. +#ifdef CONFIG_GPIO_DEV
  6316. +
  6317. +/* Gang allocators and accessors; used by the GPIO /dev driver */
  6318. +int at32_gpio_port_is_valid(unsigned int port)
  6319. +{
  6320. + return port < MAX_NR_PIO_DEVICES && pio_dev[port].regs != NULL;
  6321. +}
  6322. +
  6323. +int at32_select_gpio_pins(unsigned int port, u32 pins, u32 oe_mask)
  6324. +{
  6325. + struct pio_device *pio;
  6326. + u32 old, new;
  6327. +
  6328. + pio = &pio_dev[port];
  6329. + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs || (oe_mask & ~pins));
  6330. +
  6331. + /* Try to allocate the pins */
  6332. + do {
  6333. + old = pio->pinmux_mask;
  6334. + if (old & pins)
  6335. + return -EBUSY;
  6336. +
  6337. + new = old | pins;
  6338. + } while (cmpxchg(&pio->pinmux_mask, old, new) != old);
  6339. +
  6340. + /* That went well, now configure the port */
  6341. + pio_writel(pio, OER, oe_mask);
  6342. + pio_writel(pio, PER, pins);
  6343. +
  6344. + return 0;
  6345. +}
  6346. +
  6347. +void at32_deselect_pins(unsigned int port, u32 pins)
  6348. +{
  6349. + struct pio_device *pio;
  6350. + u32 old, new;
  6351. +
  6352. + pio = &pio_dev[port];
  6353. + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs);
  6354. +
  6355. + /* Return to a "safe" mux configuration */
  6356. + pio_writel(pio, PUER, pins);
  6357. + pio_writel(pio, ODR, pins);
  6358. +
  6359. + /* Deallocate the pins */
  6360. + do {
  6361. + old = pio->pinmux_mask;
  6362. + new = old & ~pins;
  6363. + } while (cmpxchg(&pio->pinmux_mask, old, new) != old);
  6364. +}
  6365. +
  6366. +u32 at32_gpio_get_value_multiple(unsigned int port, u32 pins)
  6367. +{
  6368. + struct pio_device *pio;
  6369. +
  6370. + pio = &pio_dev[port];
  6371. + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs);
  6372. +
  6373. + return pio_readl(pio, PDSR) & pins;
  6374. +}
  6375. +
  6376. +void at32_gpio_set_value_multiple(unsigned int port, u32 value, u32 mask)
  6377. +{
  6378. + struct pio_device *pio;
  6379. +
  6380. + pio = &pio_dev[port];
  6381. + BUG_ON(port > ARRAY_SIZE(pio_dev) || !pio->regs);
  6382. +
  6383. + /* No atomic updates for now... */
  6384. + pio_writel(pio, CODR, ~value & mask);
  6385. + pio_writel(pio, SODR, value & mask);
  6386. +}
  6387. +
  6388. +#endif /* CONFIG_GPIO_DEV */
  6389. +
  6390. +
  6391. /*--------------------------------------------------------------------------*/
  6392. /* GPIO API */
  6393. @@ -318,6 +394,8 @@
  6394. const char *label;
  6395. label = gpiochip_is_requested(chip, i);
  6396. + if (!label && (imr & mask))
  6397. + label = "[irq]";
  6398. if (!label)
  6399. continue;
  6400. --- /dev/null
  6401. +++ b/arch/avr32/mach-at32ap/pm-at32ap700x.S
  6402. @@ -0,0 +1,174 @@
  6403. +/*
  6404. + * Low-level Power Management code.
  6405. + *
  6406. + * Copyright (C) 2008 Atmel Corporation
  6407. + *
  6408. + * This program is free software; you can redistribute it and/or modify
  6409. + * it under the terms of the GNU General Public License version 2 as
  6410. + * published by the Free Software Foundation.
  6411. + */
  6412. +#include <asm/asm.h>
  6413. +#include <asm/asm-offsets.h>
  6414. +#include <asm/thread_info.h>
  6415. +#include <asm/arch/pm.h>
  6416. +
  6417. +#include "pm.h"
  6418. +#include "sdramc.h"
  6419. +
  6420. +/* Same as 0xfff00000 but fits in a 21 bit signed immediate */
  6421. +#define PM_BASE -0x100000
  6422. +
  6423. + .section .bss, "wa", @nobits
  6424. + .global disable_idle_sleep
  6425. + .type disable_idle_sleep, @object
  6426. +disable_idle_sleep:
  6427. + .int 4
  6428. + .size disable_idle_sleep, . - disable_idle_sleep
  6429. +
  6430. + /* Keep this close to the irq handlers */
  6431. + .section .irq.text, "ax", @progbits
  6432. +
  6433. + /*
  6434. + * void cpu_enter_idle(void)
  6435. + *
  6436. + * Put the CPU into "idle" mode, in which it will consume
  6437. + * significantly less power.
  6438. + *
  6439. + * If an interrupt comes along in the window between
  6440. + * unmask_interrupts and the sleep instruction below, the
  6441. + * interrupt code will adjust the return address so that we
  6442. + * never execute the sleep instruction. This is required
  6443. + * because the AP7000 doesn't unmask interrupts when entering
  6444. + * sleep modes; later CPUs may not need this workaround.
  6445. + */
  6446. + .global cpu_enter_idle
  6447. + .type cpu_enter_idle, @function
  6448. +cpu_enter_idle:
  6449. + mask_interrupts
  6450. + get_thread_info r8
  6451. + ld.w r9, r8[TI_flags]
  6452. + bld r9, TIF_NEED_RESCHED
  6453. + brcs .Lret_from_sleep
  6454. + sbr r9, TIF_CPU_GOING_TO_SLEEP
  6455. + st.w r8[TI_flags], r9
  6456. + unmask_interrupts
  6457. + sleep CPU_SLEEP_IDLE
  6458. + .size cpu_idle_sleep, . - cpu_idle_sleep
  6459. +
  6460. + /*
  6461. + * Common return path for PM functions that don't run from
  6462. + * SRAM.
  6463. + */
  6464. + .global cpu_idle_skip_sleep
  6465. + .type cpu_idle_skip_sleep, @function
  6466. +cpu_idle_skip_sleep:
  6467. + mask_interrupts
  6468. + ld.w r9, r8[TI_flags]
  6469. + cbr r9, TIF_CPU_GOING_TO_SLEEP
  6470. + st.w r8[TI_flags], r9
  6471. +.Lret_from_sleep:
  6472. + unmask_interrupts
  6473. + retal r12
  6474. + .size cpu_idle_skip_sleep, . - cpu_idle_skip_sleep
  6475. +
  6476. +#ifdef CONFIG_PM
  6477. + .section .init.text, "ax", @progbits
  6478. +
  6479. + .global pm_exception
  6480. + .type pm_exception, @function
  6481. +pm_exception:
  6482. + /*
  6483. + * Exceptions are masked when we switch to this handler, so
  6484. + * we'll only get "unrecoverable" exceptions (offset 0.)
  6485. + */
  6486. + sub r12, pc, . - .Lpanic_msg
  6487. + lddpc pc, .Lpanic_addr
  6488. +
  6489. + .align 2
  6490. +.Lpanic_addr:
  6491. + .long panic
  6492. +.Lpanic_msg:
  6493. + .asciz "Unrecoverable exception during suspend\n"
  6494. + .size pm_exception, . - pm_exception
  6495. +
  6496. + .global pm_irq0
  6497. + .type pm_irq0, @function
  6498. +pm_irq0:
  6499. + /* Disable interrupts and return after the sleep instruction */
  6500. + mfsr r9, SYSREG_RSR_INT0
  6501. + mtsr SYSREG_RAR_INT0, r8
  6502. + sbr r9, SYSREG_GM_OFFSET
  6503. + mtsr SYSREG_RSR_INT0, r9
  6504. + rete
  6505. +
  6506. + /*
  6507. + * void cpu_enter_standby(unsigned long sdramc_base)
  6508. + *
  6509. + * Enter PM_SUSPEND_STANDBY mode. At this point, all drivers
  6510. + * are suspended and interrupts are disabled. Interrupts
  6511. + * marked as 'wakeup' event sources may still come along and
  6512. + * get us out of here.
  6513. + *
  6514. + * The SDRAM will be put into self-refresh mode (which does
  6515. + * not require a clock from the CPU), and the CPU will be put
  6516. + * into "frozen" mode (HSB bus stopped). The SDRAM controller
  6517. + * will automatically bring the SDRAM into normal mode on the
  6518. + * first access, and the power manager will automatically
  6519. + * start the HSB and CPU clocks upon a wakeup event.
  6520. + *
  6521. + * This code uses the same "skip sleep" technique as above.
  6522. + * It is very important that we jump directly to
  6523. + * cpu_after_sleep after the sleep instruction since that's
  6524. + * where we'll end up if the interrupt handler decides that we
  6525. + * need to skip the sleep instruction.
  6526. + */
  6527. + .global pm_standby
  6528. + .type pm_standby, @function
  6529. +pm_standby:
  6530. + /*
  6531. + * interrupts are already masked at this point, and EVBA
  6532. + * points to pm_exception above.
  6533. + */
  6534. + ld.w r10, r12[SDRAMC_LPR]
  6535. + sub r8, pc, . - 1f /* return address for irq handler */
  6536. + mov r11, SDRAMC_LPR_LPCB_SELF_RFR
  6537. + bfins r10, r11, 0, 2 /* LPCB <- self Refresh */
  6538. + sync 0 /* flush write buffer */
  6539. + st.w r12[SDRAMC_LPR], r11 /* put SDRAM in self-refresh mode */
  6540. + ld.w r11, r12[SDRAMC_LPR]
  6541. + unmask_interrupts
  6542. + sleep CPU_SLEEP_FROZEN
  6543. +1: mask_interrupts
  6544. + retal r12
  6545. + .size pm_standby, . - pm_standby
  6546. +
  6547. + .global pm_suspend_to_ram
  6548. + .type pm_suspend_to_ram, @function
  6549. +pm_suspend_to_ram:
  6550. + /*
  6551. + * interrupts are already masked at this point, and EVBA
  6552. + * points to pm_exception above.
  6553. + */
  6554. + mov r11, 0
  6555. + cache r11[2], 8 /* clean all dcache lines */
  6556. + sync 0 /* flush write buffer */
  6557. + ld.w r10, r12[SDRAMC_LPR]
  6558. + sub r8, pc, . - 1f /* return address for irq handler */
  6559. + mov r11, SDRAMC_LPR_LPCB_SELF_RFR
  6560. + bfins r10, r11, 0, 2 /* LPCB <- self refresh */
  6561. + st.w r12[SDRAMC_LPR], r10 /* put SDRAM in self-refresh mode */
  6562. + ld.w r11, r12[SDRAMC_LPR]
  6563. +
  6564. + unmask_interrupts
  6565. + sleep CPU_SLEEP_STOP
  6566. +1: mask_interrupts
  6567. +
  6568. + retal r12
  6569. + .size pm_suspend_to_ram, . - pm_suspend_to_ram
  6570. +
  6571. + .global pm_sram_end
  6572. + .type pm_sram_end, @function
  6573. +pm_sram_end:
  6574. + .size pm_sram_end, 0
  6575. +
  6576. +#endif /* CONFIG_PM */
  6577. --- /dev/null
  6578. +++ b/arch/avr32/mach-at32ap/pm.c
  6579. @@ -0,0 +1,245 @@
  6580. +/*
  6581. + * AVR32 AP Power Management
  6582. + *
  6583. + * Copyright (C) 2008 Atmel Corporation
  6584. + *
  6585. + * This program is free software; you can redistribute it and/or
  6586. + * modify it under the terms of the GNU General Public License
  6587. + * version 2 as published by the Free Software Foundation.
  6588. + */
  6589. +#include <linux/io.h>
  6590. +#include <linux/suspend.h>
  6591. +#include <linux/vmalloc.h>
  6592. +
  6593. +#include <asm/cacheflush.h>
  6594. +#include <asm/sysreg.h>
  6595. +
  6596. +#include <asm/arch/pm.h>
  6597. +#include <asm/arch/sram.h>
  6598. +
  6599. +/* FIXME: This is only valid for AP7000 */
  6600. +#define SDRAMC_BASE 0xfff03800
  6601. +
  6602. +#include "sdramc.h"
  6603. +
  6604. +#define SRAM_PAGE_FLAGS (SYSREG_BIT(TLBELO_D) | SYSREG_BF(SZ, 1) \
  6605. + | SYSREG_BF(AP, 3) | SYSREG_BIT(G))
  6606. +
  6607. +
  6608. +static unsigned long pm_sram_start;
  6609. +static size_t pm_sram_size;
  6610. +static struct vm_struct *pm_sram_area;
  6611. +
  6612. +static void (*avr32_pm_enter_standby)(unsigned long sdramc_base);
  6613. +static void (*avr32_pm_enter_str)(unsigned long sdramc_base);
  6614. +
  6615. +/*
  6616. + * Must be called with interrupts disabled. Exceptions will be masked
  6617. + * on return (i.e. all exceptions will be "unrecoverable".)
  6618. + */
  6619. +static void *avr32_pm_map_sram(void)
  6620. +{
  6621. + unsigned long vaddr;
  6622. + unsigned long page_addr;
  6623. + u32 tlbehi;
  6624. + u32 mmucr;
  6625. +
  6626. + vaddr = (unsigned long)pm_sram_area->addr;
  6627. + page_addr = pm_sram_start & PAGE_MASK;
  6628. +
  6629. + /*
  6630. + * Mask exceptions and grab the first TLB entry. We won't be
  6631. + * needing it while sleeping.
  6632. + */
  6633. + asm volatile("ssrf %0" : : "i"(SYSREG_EM_OFFSET) : "memory");
  6634. +
  6635. + mmucr = sysreg_read(MMUCR);
  6636. + tlbehi = sysreg_read(TLBEHI);
  6637. + sysreg_write(MMUCR, SYSREG_BFINS(DRP, 0, mmucr));
  6638. +
  6639. + tlbehi = SYSREG_BF(ASID, SYSREG_BFEXT(ASID, tlbehi));
  6640. + tlbehi |= vaddr & PAGE_MASK;
  6641. + tlbehi |= SYSREG_BIT(TLBEHI_V);
  6642. +
  6643. + sysreg_write(TLBELO, page_addr | SRAM_PAGE_FLAGS);
  6644. + sysreg_write(TLBEHI, tlbehi);
  6645. + __builtin_tlbw();
  6646. +
  6647. + return (void *)(vaddr + pm_sram_start - page_addr);
  6648. +}
  6649. +
  6650. +/*
  6651. + * Must be called with interrupts disabled. Exceptions will be
  6652. + * unmasked on return.
  6653. + */
  6654. +static void avr32_pm_unmap_sram(void)
  6655. +{
  6656. + u32 mmucr;
  6657. + u32 tlbehi;
  6658. + u32 tlbarlo;
  6659. +
  6660. + /* Going to update TLB entry at index 0 */
  6661. + mmucr = sysreg_read(MMUCR);
  6662. + tlbehi = sysreg_read(TLBEHI);
  6663. + sysreg_write(MMUCR, SYSREG_BFINS(DRP, 0, mmucr));
  6664. +
  6665. + /* Clear the "valid" bit */
  6666. + tlbehi = SYSREG_BF(ASID, SYSREG_BFEXT(ASID, tlbehi));
  6667. + sysreg_write(TLBEHI, tlbehi);
  6668. +
  6669. + /* Mark it as "not accessed" */
  6670. + tlbarlo = sysreg_read(TLBARLO);
  6671. + sysreg_write(TLBARLO, tlbarlo | 0x80000000U);
  6672. +
  6673. + /* Update the TLB */
  6674. + __builtin_tlbw();
  6675. +
  6676. + /* Unmask exceptions */
  6677. + asm volatile("csrf %0" : : "i"(SYSREG_EM_OFFSET) : "memory");
  6678. +}
  6679. +
  6680. +static int avr32_pm_valid_state(suspend_state_t state)
  6681. +{
  6682. + switch (state) {
  6683. + case PM_SUSPEND_ON:
  6684. + case PM_SUSPEND_STANDBY:
  6685. + case PM_SUSPEND_MEM:
  6686. + return 1;
  6687. +
  6688. + default:
  6689. + return 0;
  6690. + }
  6691. +}
  6692. +
  6693. +static int avr32_pm_enter(suspend_state_t state)
  6694. +{
  6695. + u32 lpr_saved;
  6696. + u32 evba_saved;
  6697. + void *sram;
  6698. +
  6699. + switch (state) {
  6700. + case PM_SUSPEND_STANDBY:
  6701. + sram = avr32_pm_map_sram();
  6702. +
  6703. + /* Switch to in-sram exception handlers */
  6704. + evba_saved = sysreg_read(EVBA);
  6705. + sysreg_write(EVBA, (unsigned long)sram);
  6706. +
  6707. + /*
  6708. + * Save the LPR register so that we can re-enable
  6709. + * SDRAM Low Power mode on resume.
  6710. + */
  6711. + lpr_saved = sdramc_readl(LPR);
  6712. + pr_debug("%s: Entering standby...\n", __func__);
  6713. + avr32_pm_enter_standby(SDRAMC_BASE);
  6714. + sdramc_writel(LPR, lpr_saved);
  6715. +
  6716. + /* Switch back to regular exception handlers */
  6717. + sysreg_write(EVBA, evba_saved);
  6718. +
  6719. + avr32_pm_unmap_sram();
  6720. + break;
  6721. +
  6722. + case PM_SUSPEND_MEM:
  6723. + sram = avr32_pm_map_sram();
  6724. +
  6725. + /* Switch to in-sram exception handlers */
  6726. + evba_saved = sysreg_read(EVBA);
  6727. + sysreg_write(EVBA, (unsigned long)sram);
  6728. +
  6729. + /*
  6730. + * Save the LPR register so that we can re-enable
  6731. + * SDRAM Low Power mode on resume.
  6732. + */
  6733. + lpr_saved = sdramc_readl(LPR);
  6734. + pr_debug("%s: Entering suspend-to-ram...\n", __func__);
  6735. + avr32_pm_enter_str(SDRAMC_BASE);
  6736. + sdramc_writel(LPR, lpr_saved);
  6737. +
  6738. + /* Switch back to regular exception handlers */
  6739. + sysreg_write(EVBA, evba_saved);
  6740. +
  6741. + avr32_pm_unmap_sram();
  6742. + break;
  6743. +
  6744. + case PM_SUSPEND_ON:
  6745. + pr_debug("%s: Entering idle...\n", __func__);
  6746. + cpu_enter_idle();
  6747. + break;
  6748. +
  6749. + default:
  6750. + pr_debug("%s: Invalid suspend state %d\n", __func__, state);
  6751. + goto out;
  6752. + }
  6753. +
  6754. + pr_debug("%s: wakeup\n", __func__);
  6755. +
  6756. +out:
  6757. + return 0;
  6758. +}
  6759. +
  6760. +static struct platform_suspend_ops avr32_pm_ops = {
  6761. + .valid = avr32_pm_valid_state,
  6762. + .enter = avr32_pm_enter,
  6763. +};
  6764. +
  6765. +static unsigned long avr32_pm_offset(void *symbol)
  6766. +{
  6767. + extern u8 pm_exception[];
  6768. +
  6769. + return (unsigned long)symbol - (unsigned long)pm_exception;
  6770. +}
  6771. +
  6772. +static int __init avr32_pm_init(void)
  6773. +{
  6774. + extern u8 pm_exception[];
  6775. + extern u8 pm_irq0[];
  6776. + extern u8 pm_standby[];
  6777. + extern u8 pm_suspend_to_ram[];
  6778. + extern u8 pm_sram_end[];
  6779. + void *dst;
  6780. +
  6781. + /*
  6782. + * To keep things simple, we depend on not needing more than a
  6783. + * single page.
  6784. + */
  6785. + pm_sram_size = avr32_pm_offset(pm_sram_end);
  6786. + if (pm_sram_size > PAGE_SIZE)
  6787. + goto err;
  6788. +
  6789. + pm_sram_start = sram_alloc(pm_sram_size);
  6790. + if (!pm_sram_start)
  6791. + goto err_alloc_sram;
  6792. +
  6793. + /* Grab a virtual area we can use later on. */
  6794. + pm_sram_area = get_vm_area(pm_sram_size, VM_IOREMAP);
  6795. + if (!pm_sram_area)
  6796. + goto err_vm_area;
  6797. + pm_sram_area->phys_addr = pm_sram_start;
  6798. +
  6799. + local_irq_disable();
  6800. + dst = avr32_pm_map_sram();
  6801. + memcpy(dst, pm_exception, pm_sram_size);
  6802. + flush_dcache_region(dst, pm_sram_size);
  6803. + invalidate_icache_region(dst, pm_sram_size);
  6804. + avr32_pm_unmap_sram();
  6805. + local_irq_enable();
  6806. +
  6807. + avr32_pm_enter_standby = dst + avr32_pm_offset(pm_standby);
  6808. + avr32_pm_enter_str = dst + avr32_pm_offset(pm_suspend_to_ram);
  6809. + intc_set_suspend_handler(avr32_pm_offset(pm_irq0));
  6810. +
  6811. + suspend_set_ops(&avr32_pm_ops);
  6812. +
  6813. + printk("AVR32 AP Power Management enabled\n");
  6814. +
  6815. + return 0;
  6816. +
  6817. +err_vm_area:
  6818. + sram_free(pm_sram_start, pm_sram_size);
  6819. +err_alloc_sram:
  6820. +err:
  6821. + pr_err("AVR32 Power Management initialization failed\n");
  6822. + return -ENOMEM;
  6823. +}
  6824. +arch_initcall(avr32_pm_init);
  6825. --- /dev/null
  6826. +++ b/arch/avr32/mach-at32ap/sdramc.h
  6827. @@ -0,0 +1,76 @@
  6828. +/*
  6829. + * Register definitions for the AT32AP SDRAM Controller
  6830. + *
  6831. + * Copyright (C) 2008 Atmel Corporation
  6832. + *
  6833. + * This program is free software; you can redistribute it and/or
  6834. + * modify it under the terms of the GNU General Public License
  6835. + * version 2 as published by the Free Software Foundation.
  6836. + */
  6837. +
  6838. +/* Register offsets */
  6839. +#define SDRAMC_MR 0x0000
  6840. +#define SDRAMC_TR 0x0004
  6841. +#define SDRAMC_CR 0x0008
  6842. +#define SDRAMC_HSR 0x000c
  6843. +#define SDRAMC_LPR 0x0010
  6844. +#define SDRAMC_IER 0x0014
  6845. +#define SDRAMC_IDR 0x0018
  6846. +#define SDRAMC_IMR 0x001c
  6847. +#define SDRAMC_ISR 0x0020
  6848. +#define SDRAMC_MDR 0x0024
  6849. +
  6850. +/* MR - Mode Register */
  6851. +#define SDRAMC_MR_MODE_NORMAL ( 0 << 0)
  6852. +#define SDRAMC_MR_MODE_NOP ( 1 << 0)
  6853. +#define SDRAMC_MR_MODE_BANKS_PRECHARGE ( 2 << 0)
  6854. +#define SDRAMC_MR_MODE_LOAD_MODE ( 3 << 0)
  6855. +#define SDRAMC_MR_MODE_AUTO_REFRESH ( 4 << 0)
  6856. +#define SDRAMC_MR_MODE_EXT_LOAD_MODE ( 5 << 0)
  6857. +#define SDRAMC_MR_MODE_POWER_DOWN ( 6 << 0)
  6858. +
  6859. +/* CR - Configuration Register */
  6860. +#define SDRAMC_CR_NC_8_BITS ( 0 << 0)
  6861. +#define SDRAMC_CR_NC_9_BITS ( 1 << 0)
  6862. +#define SDRAMC_CR_NC_10_BITS ( 2 << 0)
  6863. +#define SDRAMC_CR_NC_11_BITS ( 3 << 0)
  6864. +#define SDRAMC_CR_NR_11_BITS ( 0 << 2)
  6865. +#define SDRAMC_CR_NR_12_BITS ( 1 << 2)
  6866. +#define SDRAMC_CR_NR_13_BITS ( 2 << 2)
  6867. +#define SDRAMC_CR_NB_2_BANKS ( 0 << 4)
  6868. +#define SDRAMC_CR_NB_4_BANKS ( 1 << 4)
  6869. +#define SDRAMC_CR_CAS(x) ((x) << 5)
  6870. +#define SDRAMC_CR_DBW_32_BITS ( 0 << 7)
  6871. +#define SDRAMC_CR_DBW_16_BITS ( 1 << 7)
  6872. +#define SDRAMC_CR_TWR(x) ((x) << 8)
  6873. +#define SDRAMC_CR_TRC(x) ((x) << 12)
  6874. +#define SDRAMC_CR_TRP(x) ((x) << 16)
  6875. +#define SDRAMC_CR_TRCD(x) ((x) << 20)
  6876. +#define SDRAMC_CR_TRAS(x) ((x) << 24)
  6877. +#define SDRAMC_CR_TXSR(x) ((x) << 28)
  6878. +
  6879. +/* HSR - High Speed Register */
  6880. +#define SDRAMC_HSR_DA ( 1 << 0)
  6881. +
  6882. +/* LPR - Low Power Register */
  6883. +#define SDRAMC_LPR_LPCB_INHIBIT ( 0 << 0)
  6884. +#define SDRAMC_LPR_LPCB_SELF_RFR ( 1 << 0)
  6885. +#define SDRAMC_LPR_LPCB_PDOWN ( 2 << 0)
  6886. +#define SDRAMC_LPR_LPCB_DEEP_PDOWN ( 3 << 0)
  6887. +#define SDRAMC_LPR_PASR(x) ((x) << 4)
  6888. +#define SDRAMC_LPR_TCSR(x) ((x) << 8)
  6889. +#define SDRAMC_LPR_DS(x) ((x) << 10)
  6890. +#define SDRAMC_LPR_TIMEOUT(x) ((x) << 12)
  6891. +
  6892. +/* IER/IDR/IMR/ISR - Interrupt Enable/Disable/Mask/Status Register */
  6893. +#define SDRAMC_ISR_RES ( 1 << 0)
  6894. +
  6895. +/* MDR - Memory Device Register */
  6896. +#define SDRAMC_MDR_MD_SDRAM ( 0 << 0)
  6897. +#define SDRAMC_MDR_MD_LOW_PWR_SDRAM ( 1 << 0)
  6898. +
  6899. +/* Register access macros */
  6900. +#define sdramc_readl(reg) \
  6901. + __raw_readl((void __iomem __force *)SDRAMC_BASE + SDRAMC_##reg)
  6902. +#define sdramc_writel(reg, value) \
  6903. + __raw_writel(value, (void __iomem __force *)SDRAMC_BASE + SDRAMC_##reg)
  6904. --- a/arch/avr32/mach-at32ap/time-tc.c
  6905. +++ /dev/null
  6906. @@ -1,218 +0,0 @@
  6907. -/*
  6908. - * Copyright (C) 2004-2007 Atmel Corporation
  6909. - *
  6910. - * Based on MIPS implementation arch/mips/kernel/time.c
  6911. - * Copyright 2001 MontaVista Software Inc.
  6912. - *
  6913. - * This program is free software; you can redistribute it and/or modify
  6914. - * it under the terms of the GNU General Public License version 2 as
  6915. - * published by the Free Software Foundation.
  6916. - */
  6917. -
  6918. -#include <linux/clk.h>
  6919. -#include <linux/clocksource.h>
  6920. -#include <linux/time.h>
  6921. -#include <linux/module.h>
  6922. -#include <linux/interrupt.h>
  6923. -#include <linux/irq.h>
  6924. -#include <linux/kernel_stat.h>
  6925. -#include <linux/errno.h>
  6926. -#include <linux/init.h>
  6927. -#include <linux/profile.h>
  6928. -#include <linux/sysdev.h>
  6929. -#include <linux/err.h>
  6930. -
  6931. -#include <asm/div64.h>
  6932. -#include <asm/sysreg.h>
  6933. -#include <asm/io.h>
  6934. -#include <asm/sections.h>
  6935. -
  6936. -#include <asm/arch/time.h>
  6937. -
  6938. -/* how many counter cycles in a jiffy? */
  6939. -static u32 cycles_per_jiffy;
  6940. -
  6941. -/* the count value for the next timer interrupt */
  6942. -static u32 expirelo;
  6943. -
  6944. -/* the I/O registers of the TC module */
  6945. -static void __iomem *ioregs;
  6946. -
  6947. -cycle_t read_cycle_count(void)
  6948. -{
  6949. - return (cycle_t)timer_read(ioregs, 0, CV);
  6950. -}
  6951. -
  6952. -struct clocksource clocksource_avr32 = {
  6953. - .name = "avr32",
  6954. - .rating = 342,
  6955. - .read = read_cycle_count,
  6956. - .mask = CLOCKSOURCE_MASK(16),
  6957. - .shift = 16,
  6958. - .flags = CLOCK_SOURCE_IS_CONTINUOUS,
  6959. -};
  6960. -
  6961. -static void avr32_timer_ack(void)
  6962. -{
  6963. - u16 count = expirelo;
  6964. -
  6965. - /* Ack this timer interrupt and set the next one, use a u16
  6966. - * variable so it will wrap around correctly */
  6967. - count += cycles_per_jiffy;
  6968. - expirelo = count;
  6969. - timer_write(ioregs, 0, RC, expirelo);
  6970. -
  6971. - /* Check to see if we have missed any timer interrupts */
  6972. - count = timer_read(ioregs, 0, CV);
  6973. - if ((count - expirelo) < 0x7fff) {
  6974. - expirelo = count + cycles_per_jiffy;
  6975. - timer_write(ioregs, 0, RC, expirelo);
  6976. - }
  6977. -}
  6978. -
  6979. -u32 avr32_hpt_read(void)
  6980. -{
  6981. - return timer_read(ioregs, 0, CV);
  6982. -}
  6983. -
  6984. -static int avr32_timer_calc_div_and_set_jiffies(struct clk *pclk)
  6985. -{
  6986. - unsigned int cycles_max = (clocksource_avr32.mask + 1) / 2;
  6987. - unsigned int divs[] = { 4, 8, 16, 32 };
  6988. - int divs_size = ARRAY_SIZE(divs);
  6989. - int i = 0;
  6990. - unsigned long count_hz;
  6991. - unsigned long shift;
  6992. - unsigned long mult;
  6993. - int clock_div = -1;
  6994. - u64 tmp;
  6995. -
  6996. - shift = clocksource_avr32.shift;
  6997. -
  6998. - do {
  6999. - count_hz = clk_get_rate(pclk) / divs[i];
  7000. - mult = clocksource_hz2mult(count_hz, shift);
  7001. - clocksource_avr32.mult = mult;
  7002. -
  7003. - tmp = TICK_NSEC;
  7004. - tmp <<= shift;
  7005. - tmp += mult / 2;
  7006. - do_div(tmp, mult);
  7007. -
  7008. - cycles_per_jiffy = tmp;
  7009. - } while (cycles_per_jiffy > cycles_max && ++i < divs_size);
  7010. -
  7011. - clock_div = i + 1;
  7012. -
  7013. - if (clock_div > divs_size) {
  7014. - pr_debug("timer: could not calculate clock divider\n");
  7015. - return -EFAULT;
  7016. - }
  7017. -
  7018. - /* Set the clock divider */
  7019. - timer_write(ioregs, 0, CMR, TIMER_BF(CMR_TCCLKS, clock_div));
  7020. -
  7021. - return 0;
  7022. -}
  7023. -
  7024. -int avr32_hpt_init(unsigned int count)
  7025. -{
  7026. - struct resource *regs;
  7027. - struct clk *pclk;
  7028. - int irq = -1;
  7029. - int ret = 0;
  7030. -
  7031. - ret = -ENXIO;
  7032. -
  7033. - irq = platform_get_irq(&at32_systc0_device, 0);
  7034. - if (irq < 0) {
  7035. - pr_debug("timer: could not get irq\n");
  7036. - goto out_error;
  7037. - }
  7038. -
  7039. - pclk = clk_get(&at32_systc0_device.dev, "pclk");
  7040. - if (IS_ERR(pclk)) {
  7041. - pr_debug("timer: could not get clk: %ld\n", PTR_ERR(pclk));
  7042. - goto out_error;
  7043. - }
  7044. - clk_enable(pclk);
  7045. -
  7046. - regs = platform_get_resource(&at32_systc0_device, IORESOURCE_MEM, 0);
  7047. - if (!regs) {
  7048. - pr_debug("timer: could not get resource\n");
  7049. - goto out_error_clk;
  7050. - }
  7051. -
  7052. - ioregs = ioremap(regs->start, regs->end - regs->start + 1);
  7053. - if (!ioregs) {
  7054. - pr_debug("timer: could not get ioregs\n");
  7055. - goto out_error_clk;
  7056. - }
  7057. -
  7058. - ret = avr32_timer_calc_div_and_set_jiffies(pclk);
  7059. - if (ret)
  7060. - goto out_error_io;
  7061. -
  7062. - ret = setup_irq(irq, &timer_irqaction);
  7063. - if (ret) {
  7064. - pr_debug("timer: could not request irq %d: %d\n",
  7065. - irq, ret);
  7066. - goto out_error_io;
  7067. - }
  7068. -
  7069. - expirelo = (timer_read(ioregs, 0, CV) / cycles_per_jiffy + 1)
  7070. - * cycles_per_jiffy;
  7071. -
  7072. - /* Enable clock and interrupts on RC compare */
  7073. - timer_write(ioregs, 0, CCR, TIMER_BIT(CCR_CLKEN));
  7074. - timer_write(ioregs, 0, IER, TIMER_BIT(IER_CPCS));
  7075. - /* Set cycles to first interrupt */
  7076. - timer_write(ioregs, 0, RC, expirelo);
  7077. -
  7078. - printk(KERN_INFO "timer: AT32AP system timer/counter at 0x%p irq %d\n",
  7079. - ioregs, irq);
  7080. -
  7081. - return 0;
  7082. -
  7083. -out_error_io:
  7084. - iounmap(ioregs);
  7085. -out_error_clk:
  7086. - clk_put(pclk);
  7087. -out_error:
  7088. - return ret;
  7089. -}
  7090. -
  7091. -int avr32_hpt_start(void)
  7092. -{
  7093. - timer_write(ioregs, 0, CCR, TIMER_BIT(CCR_SWTRG));
  7094. - return 0;
  7095. -}
  7096. -
  7097. -irqreturn_t timer_interrupt(int irq, void *dev_id)
  7098. -{
  7099. - unsigned int sr = timer_read(ioregs, 0, SR);
  7100. -
  7101. - if (sr & TIMER_BIT(SR_CPCS)) {
  7102. - /* ack timer interrupt and try to set next interrupt */
  7103. - avr32_timer_ack();
  7104. -
  7105. - /*
  7106. - * Call the generic timer interrupt handler
  7107. - */
  7108. - write_seqlock(&xtime_lock);
  7109. - do_timer(1);
  7110. - write_sequnlock(&xtime_lock);
  7111. -
  7112. - /*
  7113. - * In UP mode, we call local_timer_interrupt() to do profiling
  7114. - * and process accounting.
  7115. - *
  7116. - * SMP is not supported yet.
  7117. - */
  7118. - local_timer_interrupt(irq, dev_id);
  7119. -
  7120. - return IRQ_HANDLED;
  7121. - }
  7122. -
  7123. - return IRQ_NONE;
  7124. -}
  7125. --- a/arch/avr32/Makefile
  7126. +++ b/arch/avr32/Makefile
  7127. @@ -32,6 +32,7 @@
  7128. core-y += arch/avr32/kernel/
  7129. core-y += arch/avr32/mm/
  7130. drivers-$(CONFIG_OPROFILE) += arch/avr32/oprofile/
  7131. +drivers-y += arch/avr32/drivers/
  7132. libs-y += arch/avr32/lib/
  7133. archincdir-$(CONFIG_PLATFORM_AT32AP) := arch-at32ap
  7134. --- a/arch/avr32/mm/init.c
  7135. +++ b/arch/avr32/mm/init.c
  7136. @@ -11,6 +11,7 @@
  7137. #include <linux/swap.h>
  7138. #include <linux/init.h>
  7139. #include <linux/mmzone.h>
  7140. +#include <linux/module.h>
  7141. #include <linux/bootmem.h>
  7142. #include <linux/pagemap.h>
  7143. #include <linux/nodemask.h>
  7144. @@ -28,15 +29,13 @@
  7145. pgd_t swapper_pg_dir[PTRS_PER_PGD];
  7146. struct page *empty_zero_page;
  7147. +EXPORT_SYMBOL(empty_zero_page);
  7148. /*
  7149. * Cache of MMU context last used.
  7150. */
  7151. unsigned long mmu_context_cache = NO_CONTEXT;
  7152. -#define START_PFN (NODE_DATA(0)->bdata->node_boot_start >> PAGE_SHIFT)
  7153. -#define MAX_LOW_PFN (NODE_DATA(0)->bdata->node_low_pfn)
  7154. -
  7155. void show_mem(void)
  7156. {
  7157. int total = 0, reserved = 0, cached = 0;
  7158. --- a/arch/avr32/oprofile/op_model_avr32.c
  7159. +++ b/arch/avr32/oprofile/op_model_avr32.c
  7160. @@ -16,7 +16,6 @@
  7161. #include <linux/sched.h>
  7162. #include <linux/types.h>
  7163. -#include <asm/intc.h>
  7164. #include <asm/sysreg.h>
  7165. #include <asm/system.h>
  7166. --- a/drivers/char/Kconfig
  7167. +++ b/drivers/char/Kconfig
  7168. @@ -706,7 +706,7 @@
  7169. config RTC
  7170. tristate "Enhanced Real Time Clock Support"
  7171. - depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390
  7172. + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !AVR32
  7173. ---help---
  7174. If you say Y here and create a character special file /dev/rtc with
  7175. major number 10 and minor number 135 using mknod ("man mknod"), you
  7176. @@ -776,7 +776,7 @@
  7177. config GEN_RTC
  7178. tristate "Generic /dev/rtc emulation"
  7179. - depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH
  7180. + depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH && !AVR32
  7181. ---help---
  7182. If you say Y here and create a character special file /dev/rtc with
  7183. major number 10 and minor number 135 using mknod ("man mknod"), you
  7184. --- a/drivers/char/keyboard.c
  7185. +++ b/drivers/char/keyboard.c
  7186. @@ -1033,7 +1033,8 @@
  7187. #if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\
  7188. defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\
  7189. defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\
  7190. - (defined(CONFIG_ARM) && defined(CONFIG_KEYBOARD_ATKBD) && !defined(CONFIG_ARCH_RPC))
  7191. + (defined(CONFIG_ARM) && defined(CONFIG_KEYBOARD_ATKBD) && !defined(CONFIG_ARCH_RPC)) ||\
  7192. + defined(CONFIG_AVR32)
  7193. #define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\
  7194. ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001))
  7195. --- a/drivers/clocksource/Makefile
  7196. +++ b/drivers/clocksource/Makefile
  7197. @@ -1,3 +1,4 @@
  7198. +obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
  7199. obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o
  7200. obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
  7201. obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o
  7202. --- /dev/null
  7203. +++ b/drivers/clocksource/tcb_clksrc.c
  7204. @@ -0,0 +1,302 @@
  7205. +#include <linux/init.h>
  7206. +#include <linux/clocksource.h>
  7207. +#include <linux/clockchips.h>
  7208. +#include <linux/interrupt.h>
  7209. +#include <linux/irq.h>
  7210. +
  7211. +#include <linux/clk.h>
  7212. +#include <linux/err.h>
  7213. +#include <linux/ioport.h>
  7214. +#include <linux/io.h>
  7215. +#include <linux/platform_device.h>
  7216. +#include <linux/atmel_tc.h>
  7217. +
  7218. +
  7219. +/*
  7220. + * We're configured to use a specific TC block, one that's not hooked
  7221. + * up to external hardware, to provide a time solution:
  7222. + *
  7223. + * - Two channels combine to create a free-running 32 bit counter
  7224. + * with a base rate of 5+ MHz, packaged as a clocksource (with
  7225. + * resolution better than 200 nsec).
  7226. + *
  7227. + * - The third channel may be used to provide a 16-bit clockevent
  7228. + * source, used in either periodic or oneshot mode. This runs
  7229. + * at 32 KiHZ, and can handle delays of up to two seconds.
  7230. + *
  7231. + * A boot clocksource and clockevent source are also currently needed,
  7232. + * unless the relevant platforms (ARM/AT91, AVR32/AT32) are changed so
  7233. + * this code can be used when init_timers() is called, well before most
  7234. + * devices are set up. (Some low end AT91 parts, which can run uClinux,
  7235. + * have only the timers in one TC block... they currently don't support
  7236. + * the tclib code, because of that initialization issue.)
  7237. + *
  7238. + * REVISIT behavior during system suspend states... we should disable
  7239. + * all clocks and save the power. Easily done for clockevent devices,
  7240. + * but clocksources won't necessarily get the needed notifications.
  7241. + * For deeper system sleep states, this will be mandatory...
  7242. + */
  7243. +
  7244. +static void __iomem *tcaddr;
  7245. +
  7246. +static cycle_t tc_get_cycles(void)
  7247. +{
  7248. + unsigned long flags;
  7249. + u32 lower, upper;
  7250. +
  7251. + raw_local_irq_save(flags);
  7252. + do {
  7253. + upper = __raw_readl(tcaddr + ATMEL_TC_REG(1, CV));
  7254. + lower = __raw_readl(tcaddr + ATMEL_TC_REG(0, CV));
  7255. + } while (upper != __raw_readl(tcaddr + ATMEL_TC_REG(1, CV)));
  7256. +
  7257. + raw_local_irq_restore(flags);
  7258. + return (upper << 16) | lower;
  7259. +}
  7260. +
  7261. +static struct clocksource clksrc = {
  7262. + .name = "tcb_clksrc",
  7263. + .rating = 200,
  7264. + .read = tc_get_cycles,
  7265. + .mask = CLOCKSOURCE_MASK(32),
  7266. + .shift = 18,
  7267. + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
  7268. +};
  7269. +
  7270. +#ifdef CONFIG_GENERIC_CLOCKEVENTS
  7271. +
  7272. +struct tc_clkevt_device {
  7273. + struct clock_event_device clkevt;
  7274. + struct clk *clk;
  7275. + void __iomem *regs;
  7276. +};
  7277. +
  7278. +static struct tc_clkevt_device *to_tc_clkevt(struct clock_event_device *clkevt)
  7279. +{
  7280. + return container_of(clkevt, struct tc_clkevt_device, clkevt);
  7281. +}
  7282. +
  7283. +/* For now, we always use the 32K clock ... this optimizes for NO_HZ,
  7284. + * because using one of the divided clocks would usually mean the
  7285. + * tick rate can never be less than several dozen Hz (vs 0.5 Hz).
  7286. + *
  7287. + * A divided clock could be good for high resolution timers, since
  7288. + * 30.5 usec resolution can seem "low".
  7289. + */
  7290. +static u32 timer_clock;
  7291. +
  7292. +static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
  7293. +{
  7294. + struct tc_clkevt_device *tcd = to_tc_clkevt(d);
  7295. + void __iomem *regs = tcd->regs;
  7296. +
  7297. + if (tcd->clkevt.mode == CLOCK_EVT_MODE_PERIODIC
  7298. + || tcd->clkevt.mode == CLOCK_EVT_MODE_ONESHOT) {
  7299. + __raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
  7300. + __raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
  7301. + clk_disable(tcd->clk);
  7302. + }
  7303. +
  7304. + switch (m) {
  7305. +
  7306. + /* By not making the gentime core emulate periodic mode on top
  7307. + * of oneshot, we get lower overhead and improved accuracy.
  7308. + */
  7309. + case CLOCK_EVT_MODE_PERIODIC:
  7310. + clk_enable(tcd->clk);
  7311. +
  7312. + /* slow clock, count up to RC, then irq and restart */
  7313. + __raw_writel(timer_clock
  7314. + | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
  7315. + regs + ATMEL_TC_REG(2, CMR));
  7316. + __raw_writel((32768 + HZ/2) / HZ, tcaddr + ATMEL_TC_REG(2, RC));
  7317. +
  7318. + /* Enable clock and interrupts on RC compare */
  7319. + __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
  7320. +
  7321. + /* go go gadget! */
  7322. + __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
  7323. + regs + ATMEL_TC_REG(2, CCR));
  7324. + break;
  7325. +
  7326. + case CLOCK_EVT_MODE_ONESHOT:
  7327. + clk_enable(tcd->clk);
  7328. +
  7329. + /* slow clock, count up to RC, then irq and stop */
  7330. + __raw_writel(timer_clock | ATMEL_TC_CPCSTOP
  7331. + | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
  7332. + regs + ATMEL_TC_REG(2, CMR));
  7333. + __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
  7334. +
  7335. + /* set_next_event() configures and starts the timer */
  7336. + break;
  7337. +
  7338. + default:
  7339. + break;
  7340. + }
  7341. +}
  7342. +
  7343. +static int tc_next_event(unsigned long delta, struct clock_event_device *d)
  7344. +{
  7345. + __raw_writel(delta, tcaddr + ATMEL_TC_REG(2, RC));
  7346. +
  7347. + /* go go gadget! */
  7348. + __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
  7349. + tcaddr + ATMEL_TC_REG(2, CCR));
  7350. + return 0;
  7351. +}
  7352. +
  7353. +static struct tc_clkevt_device clkevt = {
  7354. + .clkevt = {
  7355. + .name = "tc_clkevt",
  7356. + .features = CLOCK_EVT_FEAT_PERIODIC
  7357. + | CLOCK_EVT_FEAT_ONESHOT,
  7358. + .shift = 32,
  7359. + /* Should be lower than at91rm9200's system timer */
  7360. + .rating = 125,
  7361. + .cpumask = CPU_MASK_CPU0,
  7362. + .set_next_event = tc_next_event,
  7363. + .set_mode = tc_mode,
  7364. + },
  7365. +};
  7366. +
  7367. +static irqreturn_t ch2_irq(int irq, void *handle)
  7368. +{
  7369. + struct tc_clkevt_device *dev = handle;
  7370. + unsigned int sr;
  7371. +
  7372. + sr = __raw_readl(dev->regs + ATMEL_TC_REG(2, SR));
  7373. + if (sr & ATMEL_TC_CPCS) {
  7374. + dev->clkevt.event_handler(&dev->clkevt);
  7375. + return IRQ_HANDLED;
  7376. + }
  7377. +
  7378. + return IRQ_NONE;
  7379. +}
  7380. +
  7381. +static struct irqaction tc_irqaction = {
  7382. + .name = "tc_clkevt",
  7383. + .flags = IRQF_TIMER | IRQF_DISABLED,
  7384. + .handler = ch2_irq,
  7385. +};
  7386. +
  7387. +static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
  7388. +{
  7389. + struct clk *t2_clk = tc->clk[2];
  7390. + int irq = tc->irq[2];
  7391. +
  7392. + clkevt.regs = tc->regs;
  7393. + clkevt.clk = t2_clk;
  7394. + tc_irqaction.dev_id = &clkevt;
  7395. +
  7396. + timer_clock = clk32k_divisor_idx;
  7397. +
  7398. + clkevt.clkevt.mult = div_sc(32768, NSEC_PER_SEC, clkevt.clkevt.shift);
  7399. + clkevt.clkevt.max_delta_ns
  7400. + = clockevent_delta2ns(0xffff, &clkevt.clkevt);
  7401. + clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1;
  7402. +
  7403. + setup_irq(irq, &tc_irqaction);
  7404. +
  7405. + clockevents_register_device(&clkevt.clkevt);
  7406. +}
  7407. +
  7408. +#else /* !CONFIG_GENERIC_CLOCKEVENTS */
  7409. +
  7410. +static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
  7411. +{
  7412. + /* NOTHING */
  7413. +}
  7414. +
  7415. +#endif
  7416. +
  7417. +static int __init tcb_clksrc_init(void)
  7418. +{
  7419. + static char bootinfo[] __initdata
  7420. + = KERN_DEBUG "%s: tc%d at %d.%03d MHz\n";
  7421. +
  7422. + struct platform_device *pdev;
  7423. + struct atmel_tc *tc;
  7424. + struct clk *t0_clk;
  7425. + u32 rate, divided_rate = 0;
  7426. + int best_divisor_idx = -1;
  7427. + int clk32k_divisor_idx = -1;
  7428. + int i;
  7429. +
  7430. + tc = atmel_tc_alloc(CONFIG_ATMEL_TCB_CLKSRC_BLOCK, clksrc.name);
  7431. + if (!tc) {
  7432. + pr_debug("can't alloc TC for clocksource\n");
  7433. + return -ENODEV;
  7434. + }
  7435. + tcaddr = tc->regs;
  7436. + pdev = tc->pdev;
  7437. +
  7438. + t0_clk = tc->clk[0];
  7439. + clk_enable(t0_clk);
  7440. +
  7441. + /* How fast will we be counting? Pick something over 5 MHz. */
  7442. + rate = (u32) clk_get_rate(t0_clk);
  7443. + for (i = 0; i < 5; i++) {
  7444. + unsigned divisor = atmel_tc_divisors[i];
  7445. + unsigned tmp;
  7446. +
  7447. + /* remember 32 KiHz clock for later */
  7448. + if (!divisor) {
  7449. + clk32k_divisor_idx = i;
  7450. + continue;
  7451. + }
  7452. +
  7453. + tmp = rate / divisor;
  7454. + pr_debug("TC: %u / %-3u [%d] --> %u\n", rate, divisor, i, tmp);
  7455. + if (best_divisor_idx > 0) {
  7456. + if (tmp < 5 * 1000 * 1000)
  7457. + continue;
  7458. + }
  7459. + divided_rate = tmp;
  7460. + best_divisor_idx = i;
  7461. + }
  7462. +
  7463. + clksrc.mult = clocksource_hz2mult(divided_rate, clksrc.shift);
  7464. +
  7465. + printk(bootinfo, clksrc.name, CONFIG_ATMEL_TCB_CLKSRC_BLOCK,
  7466. + divided_rate / 1000000,
  7467. + ((divided_rate + 500000) % 1000000) / 1000);
  7468. +
  7469. + /* tclib will give us three clocks no matter what the
  7470. + * underlying platform supports.
  7471. + */
  7472. + clk_enable(tc->clk[1]);
  7473. +
  7474. + /* channel 0: waveform mode, input mclk/8, clock TIOA0 on overflow */
  7475. + __raw_writel(best_divisor_idx /* likely divide-by-8 */
  7476. + | ATMEL_TC_WAVE
  7477. + | ATMEL_TC_WAVESEL_UP /* free-run */
  7478. + | ATMEL_TC_ACPA_SET /* TIOA0 rises at 0 */
  7479. + | ATMEL_TC_ACPC_CLEAR, /* (duty cycle 50%) */
  7480. + tcaddr + ATMEL_TC_REG(0, CMR));
  7481. + __raw_writel(0x0000, tcaddr + ATMEL_TC_REG(0, RA));
  7482. + __raw_writel(0x8000, tcaddr + ATMEL_TC_REG(0, RC));
  7483. + __raw_writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR)); /* no irqs */
  7484. + __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR));
  7485. +
  7486. + /* channel 1: waveform mode, input TIOA0 */
  7487. + __raw_writel(ATMEL_TC_XC1 /* input: TIOA0 */
  7488. + | ATMEL_TC_WAVE
  7489. + | ATMEL_TC_WAVESEL_UP, /* free-run */
  7490. + tcaddr + ATMEL_TC_REG(1, CMR));
  7491. + __raw_writel(0xff, tcaddr + ATMEL_TC_REG(1, IDR)); /* no irqs */
  7492. + __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(1, CCR));
  7493. +
  7494. + /* chain channel 0 to channel 1, then reset all the timers */
  7495. + __raw_writel(ATMEL_TC_TC1XC1S_TIOA0, tcaddr + ATMEL_TC_BMR);
  7496. + __raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);
  7497. +
  7498. + /* and away we go! */
  7499. + clocksource_register(&clksrc);
  7500. +
  7501. + /* channel 2: periodic and oneshot timer support */
  7502. + setup_clkevents(tc, clk32k_divisor_idx);
  7503. +
  7504. + return 0;
  7505. +}
  7506. +arch_initcall(tcb_clksrc_init);
  7507. --- /dev/null
  7508. +++ b/drivers/i2c/busses/i2c-atmeltwi.c
  7509. @@ -0,0 +1,436 @@
  7510. +/*
  7511. + * i2c Support for Atmel's Two-Wire Interface (TWI)
  7512. + *
  7513. + * Based on the work of Copyright (C) 2004 Rick Bronson
  7514. + * Converted to 2.6 by Andrew Victor <andrew at sanpeople.com>
  7515. + * Ported to AVR32 and heavily modified by Espen Krangnes
  7516. + * <ekrangnes at atmel.com>
  7517. + *
  7518. + * Copyright (C) 2006 Atmel Corporation
  7519. + *
  7520. + * Borrowed heavily from the original work by:
  7521. + * Copyright (C) 2000 Philip Edelbrock <phil at stimpy.netroedge.com>
  7522. + *
  7523. + * Partialy rewriten by Karel Hojdar <cmkaho at seznam.cz>
  7524. + * bugs removed, interrupt routine markedly rewritten
  7525. + *
  7526. + * This program is free software; you can redistribute it and/or modify
  7527. + * it under the terms of the GNU General Public License as published by
  7528. + * the Free Software Foundation; either version 2 of the License, or
  7529. + * (at your option) any later version.
  7530. + */
  7531. +#undef VERBOSE_DEBUG
  7532. +
  7533. +#include <linux/module.h>
  7534. +#include <linux/slab.h>
  7535. +#include <linux/i2c.h>
  7536. +#include <linux/init.h>
  7537. +#include <linux/clk.h>
  7538. +#include <linux/err.h>
  7539. +#include <linux/interrupt.h>
  7540. +#include <linux/platform_device.h>
  7541. +#include <linux/completion.h>
  7542. +#include <linux/io.h>
  7543. +
  7544. +#include "i2c-atmeltwi.h"
  7545. +
  7546. +static unsigned int baudrate = 100 * 1000;
  7547. +module_param(baudrate, uint, S_IRUGO);
  7548. +MODULE_PARM_DESC(baudrate, "The TWI baudrate");
  7549. +
  7550. +
  7551. +struct atmel_twi {
  7552. + void __iomem *regs;
  7553. + struct i2c_adapter adapter;
  7554. + struct clk *pclk;
  7555. + struct completion comp;
  7556. + u32 mask;
  7557. + u8 *buf;
  7558. + u16 len;
  7559. + u16 acks_left;
  7560. + int status;
  7561. + unsigned int irq;
  7562. +
  7563. +};
  7564. +#define to_atmel_twi(adap) container_of(adap, struct atmel_twi, adapter)
  7565. +
  7566. +/*
  7567. + * (Re)Initialize the TWI hardware registers.
  7568. + */
  7569. +static int twi_hwinit(struct atmel_twi *twi)
  7570. +{
  7571. + unsigned long cdiv, ckdiv = 0;
  7572. +
  7573. + /* REVISIT: wait till SCL is high before resetting; otherwise,
  7574. + * some versions will wedge forever.
  7575. + */
  7576. +
  7577. + twi_writel(twi, IDR, ~0UL);
  7578. + twi_writel(twi, CR, TWI_BIT(SWRST)); /*Reset peripheral*/
  7579. + twi_readl(twi, SR);
  7580. +
  7581. + cdiv = (clk_get_rate(twi->pclk) / (2 * baudrate)) - 4;
  7582. +
  7583. + while (cdiv > 255) {
  7584. + ckdiv++;
  7585. + cdiv = cdiv >> 1;
  7586. + }
  7587. +
  7588. + /* REVISIT: there are various errata to consider re CDIV and CHDIV
  7589. + * here, at least on at91 parts.
  7590. + */
  7591. +
  7592. + if (ckdiv > 7)
  7593. + return -EINVAL;
  7594. + else
  7595. + twi_writel(twi, CWGR, TWI_BF(CKDIV, ckdiv)
  7596. + | TWI_BF(CHDIV, cdiv)
  7597. + | TWI_BF(CLDIV, cdiv));
  7598. + return 0;
  7599. +}
  7600. +
  7601. +/*
  7602. + * Waits for the i2c status register to set the specified bitmask
  7603. + * Returns 0 if timed out ... ~100ms is much longer than the SMBus
  7604. + * limit, but I2C has no limit at all.
  7605. + */
  7606. +static int twi_complete(struct atmel_twi *twi, u32 mask)
  7607. +{
  7608. + int timeout = msecs_to_jiffies(100);
  7609. +
  7610. + mask |= TWI_BIT(TXCOMP);
  7611. + twi->mask = mask | TWI_BIT(NACK) | TWI_BIT(OVRE);
  7612. + init_completion(&twi->comp);
  7613. +
  7614. + twi_writel(twi, IER, mask);
  7615. +
  7616. + if (!wait_for_completion_timeout(&twi->comp, timeout)) {
  7617. + /* RESET TWI interface */
  7618. + twi_writel(twi, CR, TWI_BIT(SWRST));
  7619. +
  7620. + /* Reinitialize TWI */
  7621. + twi_hwinit(twi);
  7622. +
  7623. + return -ETIMEDOUT;
  7624. + }
  7625. + return 0;
  7626. +}
  7627. +
  7628. +/*
  7629. + * Generic i2c master transfer entrypoint.
  7630. + */
  7631. +static int twi_xfer(struct i2c_adapter *adap, struct i2c_msg *pmsg, int num)
  7632. +{
  7633. + struct atmel_twi *twi = to_atmel_twi(adap);
  7634. + int i;
  7635. +
  7636. + dev_dbg(&adap->dev, "twi_xfer: processing %d messages:\n", num);
  7637. +
  7638. + twi->status = 0;
  7639. + for (i = 0; i < num; i++, pmsg++) {
  7640. + twi->len = pmsg->len;
  7641. + twi->buf = pmsg->buf;
  7642. + twi->acks_left = pmsg->len;
  7643. + twi_writel(twi, MMR, TWI_BF(DADR, pmsg->addr) |
  7644. + (pmsg->flags & I2C_M_RD ? TWI_BIT(MREAD) : 0));
  7645. + twi_writel(twi, IADR, TWI_BF(IADR, pmsg->addr));
  7646. +
  7647. + dev_dbg(&adap->dev,
  7648. + "#%d: %s %d byte%s %s dev 0x%02x\n",
  7649. + i,
  7650. + pmsg->flags & I2C_M_RD ? "reading" : "writing",
  7651. + pmsg->len,
  7652. + pmsg->len > 1 ? "s" : "",
  7653. + pmsg->flags & I2C_M_RD ? "from" : "to", pmsg->addr);
  7654. +
  7655. + /* enable */
  7656. + twi_writel(twi, CR, TWI_BIT(MSEN));
  7657. +
  7658. + if (pmsg->flags & I2C_M_RD) {
  7659. + /* cleanup after previous RX overruns */
  7660. + while (twi_readl(twi, SR) & TWI_BIT(RXRDY))
  7661. + twi_readl(twi, RHR);
  7662. +
  7663. + if (twi->len == 1)
  7664. + twi_writel(twi, CR,
  7665. + TWI_BIT(START) | TWI_BIT(STOP));
  7666. + else
  7667. + twi_writel(twi, CR, TWI_BIT(START));
  7668. +
  7669. + if (twi_complete(twi, TWI_BIT(RXRDY)) == -ETIMEDOUT) {
  7670. + dev_dbg(&adap->dev, "RX[%d] timeout. "
  7671. + "Stopped with %d bytes left\n",
  7672. + i, twi->acks_left);
  7673. + return -ETIMEDOUT;
  7674. + }
  7675. + } else {
  7676. + twi_writel(twi, THR, twi->buf[0]);
  7677. + twi->acks_left--;
  7678. + /* REVISIT: some chips don't start automagically:
  7679. + * twi_writel(twi, CR, TWI_BIT(START));
  7680. + */
  7681. + if (twi_complete(twi, TWI_BIT(TXRDY)) == -ETIMEDOUT) {
  7682. + dev_dbg(&adap->dev, "TX[%d] timeout. "
  7683. + "Stopped with %d bytes left\n",
  7684. + i, twi->acks_left);
  7685. + return -ETIMEDOUT;
  7686. + }
  7687. + /* REVISIT: an erratum workaround may be needed here;
  7688. + * see sam9261 "STOP not generated" (START either).
  7689. + */
  7690. + }
  7691. +
  7692. + /* Disable TWI interface */
  7693. + twi_writel(twi, CR, TWI_BIT(MSDIS));
  7694. +
  7695. + if (twi->status)
  7696. + return twi->status;
  7697. +
  7698. + /* WARNING: This driver lies about properly supporting
  7699. + * repeated start, or it would *ALWAYS* return here. It
  7700. + * has issued a STOP. Continuing is a false claim -- that
  7701. + * a second (or third, etc.) message is part of the same
  7702. + * "combined" (no STOPs between parts) message.
  7703. + */
  7704. +
  7705. + } /* end cur msg */
  7706. +
  7707. + return i;
  7708. +}
  7709. +
  7710. +
  7711. +static irqreturn_t twi_interrupt(int irq, void *dev_id)
  7712. +{
  7713. + struct atmel_twi *twi = dev_id;
  7714. + int status = twi_readl(twi, SR);
  7715. +
  7716. + /* Save state for later debug prints */
  7717. + int old_status = status;
  7718. +
  7719. + if (twi->mask & status) {
  7720. +
  7721. + status &= twi->mask;
  7722. +
  7723. + if (status & TWI_BIT(RXRDY)) {
  7724. + if ((status & TWI_BIT(OVRE)) && twi->acks_left) {
  7725. + /* Note weakness in fault reporting model:
  7726. + * we can't say "the first N of these data
  7727. + * bytes are valid".
  7728. + */
  7729. + dev_err(&twi->adapter.dev,
  7730. + "OVERRUN RX! %04x, lost %d\n",
  7731. + old_status, twi->acks_left);
  7732. + twi->acks_left = 0;
  7733. + twi_writel(twi, CR, TWI_BIT(STOP));
  7734. + twi->status = -EOVERFLOW;
  7735. + } else if (twi->acks_left > 0) {
  7736. + twi->buf[twi->len - twi->acks_left] =
  7737. + twi_readl(twi, RHR);
  7738. + twi->acks_left--;
  7739. + }
  7740. + if (status & TWI_BIT(TXCOMP))
  7741. + goto done;
  7742. + if (twi->acks_left == 1)
  7743. + twi_writel(twi, CR, TWI_BIT(STOP));
  7744. +
  7745. + } else if (status & (TWI_BIT(NACK) | TWI_BIT(TXCOMP))) {
  7746. + goto done;
  7747. +
  7748. + } else if (status & TWI_BIT(TXRDY)) {
  7749. + if (twi->acks_left > 0) {
  7750. + twi_writel(twi, THR,
  7751. + twi->buf[twi->len - twi->acks_left]);
  7752. + twi->acks_left--;
  7753. + } else
  7754. + twi_writel(twi, CR, TWI_BIT(STOP));
  7755. + }
  7756. +
  7757. + if (twi->acks_left == 0)
  7758. + twi_writel(twi, IDR, ~TWI_BIT(TXCOMP));
  7759. + }
  7760. +
  7761. + /* enabling this message helps trigger overruns/underruns ... */
  7762. + dev_vdbg(&twi->adapter.dev,
  7763. + "ISR: SR 0x%04X, mask 0x%04X, acks %i\n",
  7764. + old_status,
  7765. + twi->acks_left ? twi->mask : TWI_BIT(TXCOMP),
  7766. + twi->acks_left);
  7767. +
  7768. + return IRQ_HANDLED;
  7769. +
  7770. +done:
  7771. + /* Note weak fault reporting model: we can't report how many
  7772. + * bytes we sent before the NAK, or let upper layers choose
  7773. + * whether to continue. The I2C stack doesn't allow that...
  7774. + */
  7775. + if (status & TWI_BIT(NACK)) {
  7776. + dev_dbg(&twi->adapter.dev, "NACK received! %d to go\n",
  7777. + twi->acks_left);
  7778. + twi->status = -EPIPE;
  7779. +
  7780. + /* TX underrun morphs automagically into a premature STOP;
  7781. + * we'll probably observe UVRE even when it's not documented.
  7782. + */
  7783. + } else if (twi->acks_left && (twi->mask & TWI_BIT(TXRDY))) {
  7784. + dev_err(&twi->adapter.dev, "UNDERRUN TX! %04x, %d to go\n",
  7785. + old_status, twi->acks_left);
  7786. + twi->status = -ENOSR;
  7787. + }
  7788. +
  7789. + twi_writel(twi, IDR, ~0UL);
  7790. + complete(&twi->comp);
  7791. +
  7792. + dev_dbg(&twi->adapter.dev, "ISR: SR 0x%04X, acks %i --> %d\n",
  7793. + old_status, twi->acks_left, twi->status);
  7794. +
  7795. + return IRQ_HANDLED;
  7796. +}
  7797. +
  7798. +
  7799. +/*
  7800. + * Return list of supported functionality.
  7801. + *
  7802. + * NOTE: see warning above about repeated starts; this driver is falsely
  7803. + * claiming to support "combined" transfers. The mid-message STOPs mean
  7804. + * some slaves will never work with this driver. (Use i2c-gpio...)
  7805. + */
  7806. +static u32 twi_func(struct i2c_adapter *adapter)
  7807. +{
  7808. + return (I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL)
  7809. + & ~I2C_FUNC_SMBUS_QUICK;
  7810. +}
  7811. +
  7812. +static struct i2c_algorithm twi_algorithm = {
  7813. + .master_xfer = twi_xfer,
  7814. + .functionality = twi_func,
  7815. +};
  7816. +
  7817. +/*
  7818. + * Main initialization routine.
  7819. + */
  7820. +static int __init twi_probe(struct platform_device *pdev)
  7821. +{
  7822. + struct atmel_twi *twi;
  7823. + struct resource *regs;
  7824. + struct clk *pclk;
  7825. + struct i2c_adapter *adapter;
  7826. + int rc, irq;
  7827. +
  7828. + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  7829. + if (!regs)
  7830. + return -ENXIO;
  7831. +
  7832. + pclk = clk_get(&pdev->dev, "twi_pclk");
  7833. + if (IS_ERR(pclk))
  7834. + return PTR_ERR(pclk);
  7835. + clk_enable(pclk);
  7836. +
  7837. + rc = -ENOMEM;
  7838. + twi = kzalloc(sizeof(struct atmel_twi), GFP_KERNEL);
  7839. + if (!twi) {
  7840. + dev_dbg(&pdev->dev, "can't allocate interface!\n");
  7841. + goto err_alloc_twi;
  7842. + }
  7843. +
  7844. + twi->pclk = pclk;
  7845. + twi->regs = ioremap(regs->start, regs->end - regs->start + 1);
  7846. + if (!twi->regs)
  7847. + goto err_ioremap;
  7848. +
  7849. + irq = platform_get_irq(pdev, 0);
  7850. + rc = request_irq(irq, twi_interrupt, 0, "twi", twi);
  7851. + if (rc) {
  7852. + dev_dbg(&pdev->dev, "can't bind irq!\n");
  7853. + goto err_irq;
  7854. + }
  7855. + twi->irq = irq;
  7856. +
  7857. + rc = twi_hwinit(twi);
  7858. + if (rc) {
  7859. + dev_err(&pdev->dev, "Unable to set baudrate\n");
  7860. + goto err_hw_init;
  7861. + }
  7862. +
  7863. + adapter = &twi->adapter;
  7864. + sprintf(adapter->name, "TWI");
  7865. + adapter->algo = &twi_algorithm;
  7866. + adapter->class = I2C_CLASS_ALL;
  7867. + adapter->nr = pdev->id;
  7868. + adapter->dev.parent = &pdev->dev;
  7869. +
  7870. + platform_set_drvdata(pdev, twi);
  7871. +
  7872. + rc = i2c_add_numbered_adapter(adapter);
  7873. + if (rc) {
  7874. + dev_dbg(&pdev->dev, "Adapter %s registration failed\n",
  7875. + adapter->name);
  7876. + goto err_register;
  7877. + }
  7878. +
  7879. + dev_info(&pdev->dev,
  7880. + "Atmel TWI/I2C adapter (baudrate %dk) at 0x%08lx.\n",
  7881. + baudrate/1000, (unsigned long)regs->start);
  7882. +
  7883. + return 0;
  7884. +
  7885. +
  7886. +err_register:
  7887. + platform_set_drvdata(pdev, NULL);
  7888. +
  7889. +err_hw_init:
  7890. + free_irq(irq, twi);
  7891. +
  7892. +err_irq:
  7893. + iounmap(twi->regs);
  7894. +
  7895. +err_ioremap:
  7896. + kfree(twi);
  7897. +
  7898. +err_alloc_twi:
  7899. + clk_disable(pclk);
  7900. + clk_put(pclk);
  7901. +
  7902. + return rc;
  7903. +}
  7904. +
  7905. +static int __exit twi_remove(struct platform_device *pdev)
  7906. +{
  7907. + struct atmel_twi *twi = platform_get_drvdata(pdev);
  7908. + int res;
  7909. +
  7910. + platform_set_drvdata(pdev, NULL);
  7911. + res = i2c_del_adapter(&twi->adapter);
  7912. + twi_writel(twi, CR, TWI_BIT(MSDIS));
  7913. + iounmap(twi->regs);
  7914. + clk_disable(twi->pclk);
  7915. + clk_put(twi->pclk);
  7916. + free_irq(twi->irq, twi);
  7917. + kfree(twi);
  7918. +
  7919. + return res;
  7920. +}
  7921. +
  7922. +static struct platform_driver twi_driver = {
  7923. + .remove = __exit_p(twi_remove),
  7924. + .driver = {
  7925. + .name = "atmel_twi",
  7926. + .owner = THIS_MODULE,
  7927. + },
  7928. +};
  7929. +
  7930. +static int __init atmel_twi_init(void)
  7931. +{
  7932. + return platform_driver_probe(&twi_driver, twi_probe);
  7933. +}
  7934. +
  7935. +static void __exit atmel_twi_exit(void)
  7936. +{
  7937. + platform_driver_unregister(&twi_driver);
  7938. +}
  7939. +
  7940. +module_init(atmel_twi_init);
  7941. +module_exit(atmel_twi_exit);
  7942. +
  7943. +MODULE_AUTHOR("Espen Krangnes");
  7944. +MODULE_DESCRIPTION("I2C driver for Atmel TWI");
  7945. +MODULE_LICENSE("GPL");
  7946. --- /dev/null
  7947. +++ b/drivers/i2c/busses/i2c-atmeltwi.h
  7948. @@ -0,0 +1,117 @@
  7949. +/*
  7950. + * Register definitions for the Atmel Two-Wire Interface
  7951. + */
  7952. +
  7953. +#ifndef __ATMELTWI_H__
  7954. +#define __ATMELTWI_H__
  7955. +
  7956. +/* TWI register offsets */
  7957. +#define TWI_CR 0x0000
  7958. +#define TWI_MMR 0x0004
  7959. +#define TWI_SMR 0x0008
  7960. +#define TWI_IADR 0x000c
  7961. +#define TWI_CWGR 0x0010
  7962. +#define TWI_SR 0x0020
  7963. +#define TWI_IER 0x0024
  7964. +#define TWI_IDR 0x0028
  7965. +#define TWI_IMR 0x002c
  7966. +#define TWI_RHR 0x0030
  7967. +#define TWI_THR 0x0034
  7968. +
  7969. +/* Bitfields in CR */
  7970. +#define TWI_START_OFFSET 0
  7971. +#define TWI_START_SIZE 1
  7972. +#define TWI_STOP_OFFSET 1
  7973. +#define TWI_STOP_SIZE 1
  7974. +#define TWI_MSEN_OFFSET 2
  7975. +#define TWI_MSEN_SIZE 1
  7976. +#define TWI_MSDIS_OFFSET 3
  7977. +#define TWI_MSDIS_SIZE 1
  7978. +#define TWI_SVEN_OFFSET 4
  7979. +#define TWI_SVEN_SIZE 1
  7980. +#define TWI_SVDIS_OFFSET 5
  7981. +#define TWI_SVDIS_SIZE 1
  7982. +#define TWI_SWRST_OFFSET 7
  7983. +#define TWI_SWRST_SIZE 1
  7984. +
  7985. +/* Bitfields in MMR */
  7986. +#define TWI_IADRSZ_OFFSET 8
  7987. +#define TWI_IADRSZ_SIZE 2
  7988. +#define TWI_MREAD_OFFSET 12
  7989. +#define TWI_MREAD_SIZE 1
  7990. +#define TWI_DADR_OFFSET 16
  7991. +#define TWI_DADR_SIZE 7
  7992. +
  7993. +/* Bitfields in SMR */
  7994. +#define TWI_SADR_OFFSET 16
  7995. +#define TWI_SADR_SIZE 7
  7996. +
  7997. +/* Bitfields in IADR */
  7998. +#define TWI_IADR_OFFSET 0
  7999. +#define TWI_IADR_SIZE 24
  8000. +
  8001. +/* Bitfields in CWGR */
  8002. +#define TWI_CLDIV_OFFSET 0
  8003. +#define TWI_CLDIV_SIZE 8
  8004. +#define TWI_CHDIV_OFFSET 8
  8005. +#define TWI_CHDIV_SIZE 8
  8006. +#define TWI_CKDIV_OFFSET 16
  8007. +#define TWI_CKDIV_SIZE 3
  8008. +
  8009. +/* Bitfields in SR */
  8010. +#define TWI_TXCOMP_OFFSET 0
  8011. +#define TWI_TXCOMP_SIZE 1
  8012. +#define TWI_RXRDY_OFFSET 1
  8013. +#define TWI_RXRDY_SIZE 1
  8014. +#define TWI_TXRDY_OFFSET 2
  8015. +#define TWI_TXRDY_SIZE 1
  8016. +#define TWI_SVDIR_OFFSET 3
  8017. +#define TWI_SVDIR_SIZE 1
  8018. +#define TWI_SVACC_OFFSET 4
  8019. +#define TWI_SVACC_SIZE 1
  8020. +#define TWI_GCACC_OFFSET 5
  8021. +#define TWI_GCACC_SIZE 1
  8022. +#define TWI_OVRE_OFFSET 6
  8023. +#define TWI_OVRE_SIZE 1
  8024. +#define TWI_UNRE_OFFSET 7
  8025. +#define TWI_UNRE_SIZE 1
  8026. +#define TWI_NACK_OFFSET 8
  8027. +#define TWI_NACK_SIZE 1
  8028. +#define TWI_ARBLST_OFFSET 9
  8029. +#define TWI_ARBLST_SIZE 1
  8030. +
  8031. +/* Bitfields in RHR */
  8032. +#define TWI_RXDATA_OFFSET 0
  8033. +#define TWI_RXDATA_SIZE 8
  8034. +
  8035. +/* Bitfields in THR */
  8036. +#define TWI_TXDATA_OFFSET 0
  8037. +#define TWI_TXDATA_SIZE 8
  8038. +
  8039. +/* Constants for IADRSZ */
  8040. +#define TWI_IADRSZ_NO_ADDR 0
  8041. +#define TWI_IADRSZ_ONE_BYTE 1
  8042. +#define TWI_IADRSZ_TWO_BYTES 2
  8043. +#define TWI_IADRSZ_THREE_BYTES 3
  8044. +
  8045. +/* Bit manipulation macros */
  8046. +#define TWI_BIT(name) \
  8047. + (1 << TWI_##name##_OFFSET)
  8048. +#define TWI_BF(name, value) \
  8049. + (((value) & ((1 << TWI_##name##_SIZE) - 1)) \
  8050. + << TWI_##name##_OFFSET)
  8051. +#define TWI_BFEXT(name, value) \
  8052. + (((value) >> TWI_##name##_OFFSET) \
  8053. + & ((1 << TWI_##name##_SIZE) - 1))
  8054. +#define TWI_BFINS(name, value, old) \
  8055. + (((old) & ~(((1 << TWI_##name##_SIZE) - 1) \
  8056. + << TWI_##name##_OFFSET)) \
  8057. + | TWI_BF(name, (value)))
  8058. +
  8059. +/* Register access macros */
  8060. +#define twi_readl(port, reg) \
  8061. + __raw_readl((port)->regs + TWI_##reg)
  8062. +#define twi_writel(port, reg, value) \
  8063. + __raw_writel((value), (port)->regs + TWI_##reg)
  8064. +
  8065. +#endif /* __ATMELTWI_H__ */
  8066. --- a/drivers/i2c/busses/Kconfig
  8067. +++ b/drivers/i2c/busses/Kconfig
  8068. @@ -88,6 +88,14 @@
  8069. to support combined I2C messages. Use the i2c-gpio driver
  8070. unless your system can cope with those limitations.
  8071. +config I2C_ATMELTWI
  8072. + tristate "Atmel Two-Wire Interface (TWI)"
  8073. + depends on I2C && (ARCH_AT91 || PLATFORM_AT32AP)
  8074. + help
  8075. + Atmel on-chip TWI controller. Say Y if you have an AT32 or
  8076. + AT91-based device and want to use its built-in TWI
  8077. + functionality.
  8078. +
  8079. config I2C_AU1550
  8080. tristate "Au1550/Au1200 SMBus interface"
  8081. depends on SOC_AU1550 || SOC_AU1200
  8082. --- a/drivers/i2c/busses/Makefile
  8083. +++ b/drivers/i2c/busses/Makefile
  8084. @@ -52,6 +52,7 @@
  8085. obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o
  8086. obj-$(CONFIG_SCx200_ACB) += scx200_acb.o
  8087. obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o
  8088. +obj-$(CONFIG_I2C_ATMELTWI) += i2c-atmeltwi.o
  8089. ifeq ($(CONFIG_I2C_DEBUG_BUS),y)
  8090. EXTRA_CFLAGS += -DDEBUG
  8091. --- /dev/null
  8092. +++ b/drivers/input/serio/at32psif.c
  8093. @@ -0,0 +1,351 @@
  8094. +/*
  8095. + * Copyright (C) 2007 Atmel Corporation
  8096. + *
  8097. + * Driver for the AT32AP700X PS/2 controller (PSIF).
  8098. + *
  8099. + * This program is free software; you can redistribute it and/or modify it
  8100. + * under the terms of the GNU General Public License version 2 as published
  8101. + * by the Free Software Foundation.
  8102. + */
  8103. +#include <linux/kernel.h>
  8104. +#include <linux/module.h>
  8105. +#include <linux/device.h>
  8106. +#include <linux/init.h>
  8107. +#include <linux/serio.h>
  8108. +#include <linux/timer.h>
  8109. +#include <linux/interrupt.h>
  8110. +#include <linux/err.h>
  8111. +#include <linux/io.h>
  8112. +#include <linux/clk.h>
  8113. +#include <linux/platform_device.h>
  8114. +
  8115. +#include "at32psif.h"
  8116. +
  8117. +#define PSIF_BUF_SIZE 16
  8118. +
  8119. +#define ring_is_empty(_psif) (_psif->head == _psif->tail)
  8120. +#define ring_next_head(_psif) ((_psif->head + 1) & (PSIF_BUF_SIZE - 1))
  8121. +#define ring_next_tail(_psif) ((_psif->tail + 1) & (PSIF_BUF_SIZE - 1))
  8122. +
  8123. +struct psif {
  8124. + struct platform_device *pdev;
  8125. + struct clk *pclk;
  8126. + struct serio *io;
  8127. + struct timer_list tx_timer;
  8128. + void __iomem *regs;
  8129. + unsigned int irq;
  8130. + unsigned int open;
  8131. + /* Prevent concurrent writes to circular buffer. */
  8132. + spinlock_t lock;
  8133. + unsigned int head;
  8134. + unsigned int tail;
  8135. + unsigned char buffer[PSIF_BUF_SIZE];
  8136. +};
  8137. +
  8138. +static irqreturn_t psif_interrupt(int irq, void *_ptr)
  8139. +{
  8140. + struct psif *psif = _ptr;
  8141. + int retval = IRQ_NONE;
  8142. + unsigned int io_flags = 0;
  8143. + unsigned long status;
  8144. +
  8145. + status = psif_readl(psif, SR);
  8146. +
  8147. + if (status & PSIF_BIT(RXRDY)) {
  8148. + unsigned char val = (unsigned char) psif_readl(psif, RHR);
  8149. +
  8150. + if (status & PSIF_BIT(PARITY))
  8151. + io_flags |= SERIO_PARITY;
  8152. + if (status & PSIF_BIT(OVRUN))
  8153. + dev_err(&psif->pdev->dev, "overrun read error\n");
  8154. +
  8155. + serio_interrupt(psif->io, val, io_flags);
  8156. +
  8157. + retval = IRQ_HANDLED;
  8158. + }
  8159. +
  8160. + spin_lock(&psif->lock);
  8161. +
  8162. + if (status & PSIF_BIT(TXEMPTY)) {
  8163. + if (status & PSIF_BIT(NACK))
  8164. + dev_err(&psif->pdev->dev, "NACK error\n");
  8165. +
  8166. + psif_writel(psif, IDR, PSIF_BIT(TXEMPTY));
  8167. +
  8168. + if (!ring_is_empty(psif))
  8169. + mod_timer(&psif->tx_timer,
  8170. + jiffies + msecs_to_jiffies(1));
  8171. +
  8172. + retval = IRQ_HANDLED;
  8173. + }
  8174. +
  8175. + spin_unlock(&psif->lock);
  8176. +
  8177. + return retval;
  8178. +}
  8179. +
  8180. +static void psif_transmit_data(unsigned long data)
  8181. +{
  8182. + struct psif *psif = (struct psif *)data;
  8183. + unsigned long flags;
  8184. +
  8185. + spin_lock_irqsave(&psif->lock, flags);
  8186. +
  8187. + psif_writel(psif, THR, psif->buffer[psif->tail]);
  8188. + psif->tail = ring_next_tail(psif);
  8189. +
  8190. + if (!ring_is_empty(psif))
  8191. + psif_writel(psif, IER, PSIF_BIT(TXEMPTY));
  8192. +
  8193. + spin_unlock_irqrestore(&psif->lock, flags);
  8194. +}
  8195. +
  8196. +static int psif_write(struct serio *io, unsigned char val)
  8197. +{
  8198. + struct psif *psif = io->port_data;
  8199. + unsigned long flags;
  8200. + unsigned int head;
  8201. +
  8202. + spin_lock_irqsave(&psif->lock, flags);
  8203. +
  8204. + head = ring_next_head(psif);
  8205. +
  8206. + if (head != psif->tail) {
  8207. + psif->buffer[psif->head] = val;
  8208. + psif->head = head;
  8209. + } else {
  8210. + dev_err(&psif->pdev->dev, "underrun write error\n");
  8211. + }
  8212. +
  8213. + spin_unlock_irqrestore(&psif->lock, flags);
  8214. +
  8215. + /* Make sure TXEMPTY interrupt is enabled. */
  8216. + psif_writel(psif, IER, PSIF_BIT(TXEMPTY));
  8217. +
  8218. + return 0;
  8219. +}
  8220. +
  8221. +static int psif_open(struct serio *io)
  8222. +{
  8223. + struct psif *psif = io->port_data;
  8224. + int retval;
  8225. +
  8226. + retval = clk_enable(psif->pclk);
  8227. + if (retval)
  8228. + goto out;
  8229. +
  8230. + psif_writel(psif, CR, PSIF_BIT(CR_TXEN) | PSIF_BIT(CR_RXEN));
  8231. + psif_writel(psif, IER, PSIF_BIT(RXRDY));
  8232. +
  8233. + psif->open = 1;
  8234. +out:
  8235. + return retval;
  8236. +}
  8237. +
  8238. +static void psif_close(struct serio *io)
  8239. +{
  8240. + struct psif *psif = io->port_data;
  8241. +
  8242. + psif->open = 0;
  8243. +
  8244. + psif_writel(psif, IDR, ~0UL);
  8245. + psif_writel(psif, CR, PSIF_BIT(CR_TXDIS) | PSIF_BIT(CR_RXDIS));
  8246. +
  8247. + clk_disable(psif->pclk);
  8248. +}
  8249. +
  8250. +static void psif_set_prescaler(struct psif *psif)
  8251. +{
  8252. + unsigned long prscv;
  8253. + unsigned long rate = clk_get_rate(psif->pclk);
  8254. +
  8255. + /* PRSCV = Pulse length (100 us) * PSIF module frequency. */
  8256. + prscv = 100 * (rate / 1000000UL);
  8257. +
  8258. + if (prscv > ((1<<PSIF_PSR_PRSCV_SIZE) - 1)) {
  8259. + prscv = (1<<PSIF_PSR_PRSCV_SIZE) - 1;
  8260. + dev_dbg(&psif->pdev->dev, "pclk too fast, "
  8261. + "prescaler set to max\n");
  8262. + }
  8263. +
  8264. + clk_enable(psif->pclk);
  8265. + psif_writel(psif, PSR, prscv);
  8266. + clk_disable(psif->pclk);
  8267. +}
  8268. +
  8269. +static int __init psif_probe(struct platform_device *pdev)
  8270. +{
  8271. + struct resource *regs;
  8272. + struct psif *psif;
  8273. + struct serio *io;
  8274. + struct clk *pclk;
  8275. + int irq;
  8276. + int ret;
  8277. +
  8278. + psif = kzalloc(sizeof(struct psif), GFP_KERNEL);
  8279. + if (!psif) {
  8280. + dev_dbg(&pdev->dev, "out of memory\n");
  8281. + ret = -ENOMEM;
  8282. + goto out;
  8283. + }
  8284. + psif->pdev = pdev;
  8285. +
  8286. + io = kzalloc(sizeof(struct serio), GFP_KERNEL);
  8287. + if (!io) {
  8288. + dev_dbg(&pdev->dev, "out of memory\n");
  8289. + ret = -ENOMEM;
  8290. + goto out_free_psif;
  8291. + }
  8292. + psif->io = io;
  8293. +
  8294. + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  8295. + if (!regs) {
  8296. + dev_dbg(&pdev->dev, "no mmio resources defined\n");
  8297. + ret = -ENOMEM;
  8298. + goto out_free_io;
  8299. + }
  8300. +
  8301. + psif->regs = ioremap(regs->start, regs->end - regs->start + 1);
  8302. + if (!psif->regs) {
  8303. + ret = -ENOMEM;
  8304. + dev_dbg(&pdev->dev, "could not map I/O memory\n");
  8305. + goto out_free_io;
  8306. + }
  8307. +
  8308. + pclk = clk_get(&pdev->dev, "pclk");
  8309. + if (IS_ERR(pclk)) {
  8310. + dev_dbg(&pdev->dev, "could not get peripheral clock\n");
  8311. + ret = PTR_ERR(pclk);
  8312. + goto out_iounmap;
  8313. + }
  8314. + psif->pclk = pclk;
  8315. +
  8316. + /* Reset the PSIF to enter at a known state. */
  8317. + ret = clk_enable(pclk);
  8318. + if (ret) {
  8319. + dev_dbg(&pdev->dev, "could not enable pclk\n");
  8320. + goto out_put_clk;
  8321. + }
  8322. + psif_writel(psif, CR, PSIF_BIT(CR_SWRST));
  8323. + clk_disable(pclk);
  8324. +
  8325. + setup_timer(&psif->tx_timer, psif_transmit_data, (unsigned long)psif);
  8326. +
  8327. + irq = platform_get_irq(pdev, 0);
  8328. + if (irq < 0) {
  8329. + dev_dbg(&pdev->dev, "could not get irq\n");
  8330. + ret = -ENXIO;
  8331. + goto out_put_clk;
  8332. + }
  8333. + ret = request_irq(irq, psif_interrupt, IRQF_SHARED, "at32psif", psif);
  8334. + if (ret) {
  8335. + dev_dbg(&pdev->dev, "could not request irq %d\n", irq);
  8336. + goto out_put_clk;
  8337. + }
  8338. + psif->irq = irq;
  8339. +
  8340. + io->id.type = SERIO_8042;
  8341. + io->write = psif_write;
  8342. + io->open = psif_open;
  8343. + io->close = psif_close;
  8344. + strlcpy(io->name, pdev->dev.bus_id, sizeof(io->name));
  8345. + strlcpy(io->phys, pdev->dev.bus_id, sizeof(io->phys));
  8346. + io->port_data = psif;
  8347. + io->dev.parent = &pdev->dev;
  8348. +
  8349. + psif_set_prescaler(psif);
  8350. +
  8351. + spin_lock_init(&psif->lock);
  8352. + serio_register_port(psif->io);
  8353. + platform_set_drvdata(pdev, psif);
  8354. +
  8355. + dev_info(&pdev->dev, "Atmel AVR32 PSIF PS/2 driver on 0x%08x irq %d\n",
  8356. + (int)psif->regs, psif->irq);
  8357. +
  8358. + return 0;
  8359. +
  8360. +out_put_clk:
  8361. + clk_put(psif->pclk);
  8362. +out_iounmap:
  8363. + iounmap(psif->regs);
  8364. +out_free_io:
  8365. + kfree(io);
  8366. +out_free_psif:
  8367. + kfree(psif);
  8368. +out:
  8369. + return ret;
  8370. +}
  8371. +
  8372. +static int __exit psif_remove(struct platform_device *pdev)
  8373. +{
  8374. + struct psif *psif = platform_get_drvdata(pdev);
  8375. +
  8376. + psif_writel(psif, IDR, ~0UL);
  8377. + psif_writel(psif, CR, PSIF_BIT(CR_TXDIS) | PSIF_BIT(CR_RXDIS));
  8378. +
  8379. + serio_unregister_port(psif->io);
  8380. + iounmap(psif->regs);
  8381. + free_irq(psif->irq, psif);
  8382. + clk_put(psif->pclk);
  8383. + kfree(psif);
  8384. +
  8385. + platform_set_drvdata(pdev, NULL);
  8386. +
  8387. + return 0;
  8388. +}
  8389. +
  8390. +#ifdef CONFIG_PM
  8391. +static int psif_suspend(struct platform_device *pdev, pm_message_t state)
  8392. +{
  8393. + struct psif *psif = platform_get_drvdata(pdev);
  8394. +
  8395. + if (psif->open) {
  8396. + psif_writel(psif, CR, PSIF_BIT(CR_RXDIS) | PSIF_BIT(CR_TXDIS));
  8397. + clk_disable(psif->pclk);
  8398. + }
  8399. +
  8400. + return 0;
  8401. +}
  8402. +
  8403. +static int psif_resume(struct platform_device *pdev)
  8404. +{
  8405. + struct psif *psif = platform_get_drvdata(pdev);
  8406. +
  8407. + if (psif->open) {
  8408. + clk_enable(psif->pclk);
  8409. + psif_set_prescaler(psif);
  8410. + psif_writel(psif, CR, PSIF_BIT(CR_RXEN) | PSIF_BIT(CR_TXEN));
  8411. + }
  8412. +
  8413. + return 0;
  8414. +}
  8415. +#else
  8416. +#define psif_suspend NULL
  8417. +#define psif_resume NULL
  8418. +#endif
  8419. +
  8420. +static struct platform_driver psif_driver = {
  8421. + .remove = __exit_p(psif_remove),
  8422. + .driver = {
  8423. + .name = "atmel_psif",
  8424. + },
  8425. + .suspend = psif_suspend,
  8426. + .resume = psif_resume,
  8427. +};
  8428. +
  8429. +static int __init psif_init(void)
  8430. +{
  8431. + return platform_driver_probe(&psif_driver, psif_probe);
  8432. +}
  8433. +
  8434. +static void __exit psif_exit(void)
  8435. +{
  8436. + platform_driver_unregister(&psif_driver);
  8437. +}
  8438. +
  8439. +module_init(psif_init);
  8440. +module_exit(psif_exit);
  8441. +
  8442. +MODULE_AUTHOR("Hans-Christian Egtvedt <[email protected]>");
  8443. +MODULE_DESCRIPTION("Atmel AVR32 PSIF PS/2 driver");
  8444. +MODULE_LICENSE("GPL");
  8445. --- /dev/null
  8446. +++ b/drivers/input/serio/at32psif.h
  8447. @@ -0,0 +1,82 @@
  8448. +/*
  8449. + * Copyright (C) 2007 Atmel Corporation
  8450. + *
  8451. + * Driver for the AT32AP700X PS/2 controller (PSIF).
  8452. + *
  8453. + * This program is free software; you can redistribute it and/or modify it
  8454. + * under the terms of the GNU General Public License version 2 as published
  8455. + * by the Free Software Foundation.
  8456. + */
  8457. +
  8458. +#ifndef _AT32PSIF_H
  8459. +#define _AT32PSIF_H
  8460. +
  8461. +/* PSIF register offsets */
  8462. +#define PSIF_CR 0x00
  8463. +#define PSIF_RHR 0x04
  8464. +#define PSIF_THR 0x08
  8465. +#define PSIF_SR 0x10
  8466. +#define PSIF_IER 0x14
  8467. +#define PSIF_IDR 0x18
  8468. +#define PSIF_IMR 0x1c
  8469. +#define PSIF_PSR 0x24
  8470. +
  8471. +/* Bitfields in control register. */
  8472. +#define PSIF_CR_RXDIS_OFFSET 1
  8473. +#define PSIF_CR_RXDIS_SIZE 1
  8474. +#define PSIF_CR_RXEN_OFFSET 0
  8475. +#define PSIF_CR_RXEN_SIZE 1
  8476. +#define PSIF_CR_SWRST_OFFSET 15
  8477. +#define PSIF_CR_SWRST_SIZE 1
  8478. +#define PSIF_CR_TXDIS_OFFSET 9
  8479. +#define PSIF_CR_TXDIS_SIZE 1
  8480. +#define PSIF_CR_TXEN_OFFSET 8
  8481. +#define PSIF_CR_TXEN_SIZE 1
  8482. +
  8483. +/* Bitfields in interrupt disable, enable, mask and status register. */
  8484. +#define PSIF_NACK_OFFSET 8
  8485. +#define PSIF_NACK_SIZE 1
  8486. +#define PSIF_OVRUN_OFFSET 5
  8487. +#define PSIF_OVRUN_SIZE 1
  8488. +#define PSIF_PARITY_OFFSET 9
  8489. +#define PSIF_PARITY_SIZE 1
  8490. +#define PSIF_RXRDY_OFFSET 4
  8491. +#define PSIF_RXRDY_SIZE 1
  8492. +#define PSIF_TXEMPTY_OFFSET 1
  8493. +#define PSIF_TXEMPTY_SIZE 1
  8494. +#define PSIF_TXRDY_OFFSET 0
  8495. +#define PSIF_TXRDY_SIZE 1
  8496. +
  8497. +/* Bitfields in prescale register. */
  8498. +#define PSIF_PSR_PRSCV_OFFSET 0
  8499. +#define PSIF_PSR_PRSCV_SIZE 12
  8500. +
  8501. +/* Bitfields in receive hold register. */
  8502. +#define PSIF_RHR_RXDATA_OFFSET 0
  8503. +#define PSIF_RHR_RXDATA_SIZE 8
  8504. +
  8505. +/* Bitfields in transmit hold register. */
  8506. +#define PSIF_THR_TXDATA_OFFSET 0
  8507. +#define PSIF_THR_TXDATA_SIZE 8
  8508. +
  8509. +/* Bit manipulation macros */
  8510. +#define PSIF_BIT(name) \
  8511. + (1 << PSIF_##name##_OFFSET)
  8512. +#define PSIF_BF(name, value) \
  8513. + (((value) & ((1 << PSIF_##name##_SIZE) - 1)) \
  8514. + << PSIF_##name##_OFFSET)
  8515. +#define PSIF_BFEXT(name, value)\
  8516. + (((value) >> PSIF_##name##_OFFSET) \
  8517. + & ((1 << PSIF_##name##_SIZE) - 1))
  8518. +#define PSIF_BFINS(name, value, old) \
  8519. + (((old) & ~(((1 << PSIF_##name##_SIZE) - 1) \
  8520. + << PSIF_##name##_OFFSET)) \
  8521. + | PSIF_BF(name, value))
  8522. +
  8523. +/* Register access macros */
  8524. +#define psif_readl(port, reg) \
  8525. + __raw_readl((port)->regs + PSIF_##reg)
  8526. +#define psif_writel(port, reg, value) \
  8527. + __raw_writel((value), (port)->regs + PSIF_##reg)
  8528. +
  8529. +#endif /* _AT32PSIF_H */
  8530. --- a/drivers/input/serio/Kconfig
  8531. +++ b/drivers/input/serio/Kconfig
  8532. @@ -88,6 +88,17 @@
  8533. To compile this driver as a module, choose M here: the
  8534. module will be called rpckbd.
  8535. +config SERIO_AT32PSIF
  8536. + tristate "AVR32 PSIF PS/2 keyboard and mouse controller"
  8537. + depends on AVR32
  8538. + default n
  8539. + help
  8540. + Say Y here if you want to use the PSIF peripheral on AVR32 devices
  8541. + and connect a PS/2 keyboard and/or mouse to it.
  8542. +
  8543. + To compile this driver as a module, choose M here: the module will
  8544. + be called at32psif.
  8545. +
  8546. config SERIO_AMBAKMI
  8547. tristate "AMBA KMI keyboard controller"
  8548. depends on ARM_AMBA
  8549. --- a/drivers/input/serio/Makefile
  8550. +++ b/drivers/input/serio/Makefile
  8551. @@ -12,6 +12,7 @@
  8552. obj-$(CONFIG_SERIO_RPCKBD) += rpckbd.o
  8553. obj-$(CONFIG_SERIO_SA1111) += sa1111ps2.o
  8554. obj-$(CONFIG_SERIO_AMBAKMI) += ambakmi.o
  8555. +obj-$(CONFIG_SERIO_AT32PSIF) += at32psif.o
  8556. obj-$(CONFIG_SERIO_Q40KBD) += q40kbd.o
  8557. obj-$(CONFIG_SERIO_GSCPS2) += gscps2.o
  8558. obj-$(CONFIG_HP_SDC) += hp_sdc.o
  8559. --- /dev/null
  8560. +++ b/drivers/misc/atmel_tclib.c
  8561. @@ -0,0 +1,161 @@
  8562. +#include <linux/atmel_tc.h>
  8563. +#include <linux/clk.h>
  8564. +#include <linux/err.h>
  8565. +#include <linux/init.h>
  8566. +#include <linux/io.h>
  8567. +#include <linux/ioport.h>
  8568. +#include <linux/kernel.h>
  8569. +#include <linux/platform_device.h>
  8570. +
  8571. +/* Number of bytes to reserve for the iomem resource */
  8572. +#define ATMEL_TC_IOMEM_SIZE 256
  8573. +
  8574. +
  8575. +/*
  8576. + * This is a thin library to solve the problem of how to portably allocate
  8577. + * one of the TC blocks. For simplicity, it doesn't currently expect to
  8578. + * share individual timers between different drivers.
  8579. + */
  8580. +
  8581. +#if defined(CONFIG_AVR32)
  8582. +/* AVR32 has these divide PBB */
  8583. +const u8 atmel_tc_divisors[5] = { 0, 4, 8, 16, 32, };
  8584. +EXPORT_SYMBOL(atmel_tc_divisors);
  8585. +
  8586. +#elif defined(CONFIG_ARCH_AT91)
  8587. +/* AT91 has these divide MCK */
  8588. +const u8 atmel_tc_divisors[5] = { 2, 8, 32, 128, 0, };
  8589. +EXPORT_SYMBOL(atmel_tc_divisors);
  8590. +
  8591. +#endif
  8592. +
  8593. +static DEFINE_SPINLOCK(tc_list_lock);
  8594. +static LIST_HEAD(tc_list);
  8595. +
  8596. +/**
  8597. + * atmel_tc_alloc - allocate a specified TC block
  8598. + * @block: which block to allocate
  8599. + * @name: name to be associated with the iomem resource
  8600. + *
  8601. + * Caller allocates a block. If it is available, a pointer to a
  8602. + * pre-initialized struct atmel_tc is returned. The caller can access
  8603. + * the registers directly through the "regs" field.
  8604. + */
  8605. +struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
  8606. +{
  8607. + struct atmel_tc *tc;
  8608. + struct platform_device *pdev = NULL;
  8609. + struct resource *r;
  8610. +
  8611. + spin_lock(&tc_list_lock);
  8612. + list_for_each_entry(tc, &tc_list, node) {
  8613. + if (tc->pdev->id == block) {
  8614. + pdev = tc->pdev;
  8615. + break;
  8616. + }
  8617. + }
  8618. +
  8619. + if (!pdev || tc->iomem)
  8620. + goto fail;
  8621. +
  8622. + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  8623. + r = request_mem_region(r->start, ATMEL_TC_IOMEM_SIZE, name);
  8624. + if (!r)
  8625. + goto fail;
  8626. +
  8627. + tc->regs = ioremap(r->start, ATMEL_TC_IOMEM_SIZE);
  8628. + if (!tc->regs)
  8629. + goto fail_ioremap;
  8630. +
  8631. + tc->iomem = r;
  8632. +
  8633. +out:
  8634. + spin_unlock(&tc_list_lock);
  8635. + return tc;
  8636. +
  8637. +fail_ioremap:
  8638. + release_resource(r);
  8639. +fail:
  8640. + tc = NULL;
  8641. + goto out;
  8642. +}
  8643. +EXPORT_SYMBOL_GPL(atmel_tc_alloc);
  8644. +
  8645. +/**
  8646. + * atmel_tc_free - release a specified TC block
  8647. + * @tc: Timer/counter block that was returned by atmel_tc_alloc()
  8648. + *
  8649. + * This reverses the effect of atmel_tc_alloc(), unmapping the I/O
  8650. + * registers, invalidating the resource returned by that routine and
  8651. + * making the TC available to other drivers.
  8652. + */
  8653. +void atmel_tc_free(struct atmel_tc *tc)
  8654. +{
  8655. + spin_lock(&tc_list_lock);
  8656. + if (tc->regs) {
  8657. + iounmap(tc->regs);
  8658. + release_resource(tc->iomem);
  8659. + tc->regs = NULL;
  8660. + tc->iomem = NULL;
  8661. + }
  8662. + spin_unlock(&tc_list_lock);
  8663. +}
  8664. +EXPORT_SYMBOL_GPL(atmel_tc_free);
  8665. +
  8666. +static int __init tc_probe(struct platform_device *pdev)
  8667. +{
  8668. + struct atmel_tc *tc;
  8669. + struct clk *clk;
  8670. + int irq;
  8671. +
  8672. + if (!platform_get_resource(pdev, IORESOURCE_MEM, 0))
  8673. + return -EINVAL;
  8674. +
  8675. + irq = platform_get_irq(pdev, 0);
  8676. + if (irq < 0)
  8677. + return -EINVAL;
  8678. +
  8679. + tc = kzalloc(sizeof(struct atmel_tc), GFP_KERNEL);
  8680. + if (!tc)
  8681. + return -ENOMEM;
  8682. +
  8683. + tc->pdev = pdev;
  8684. +
  8685. + clk = clk_get(&pdev->dev, "t0_clk");
  8686. + if (IS_ERR(clk)) {
  8687. + kfree(tc);
  8688. + return -EINVAL;
  8689. + }
  8690. +
  8691. + tc->clk[0] = clk;
  8692. + tc->clk[1] = clk_get(&pdev->dev, "t1_clk");
  8693. + if (IS_ERR(tc->clk[1]))
  8694. + tc->clk[1] = clk;
  8695. + tc->clk[2] = clk_get(&pdev->dev, "t2_clk");
  8696. + if (IS_ERR(tc->clk[2]))
  8697. + tc->clk[2] = clk;
  8698. +
  8699. + tc->irq[0] = irq;
  8700. + tc->irq[1] = platform_get_irq(pdev, 1);
  8701. + if (tc->irq[1] < 0)
  8702. + tc->irq[1] = irq;
  8703. + tc->irq[2] = platform_get_irq(pdev, 2);
  8704. + if (tc->irq[2] < 0)
  8705. + tc->irq[2] = irq;
  8706. +
  8707. + spin_lock(&tc_list_lock);
  8708. + list_add_tail(&tc->node, &tc_list);
  8709. + spin_unlock(&tc_list_lock);
  8710. +
  8711. + return 0;
  8712. +}
  8713. +
  8714. +static struct platform_driver tc_driver = {
  8715. + .driver.name = "atmel_tcb",
  8716. +};
  8717. +
  8718. +static int __init tc_init(void)
  8719. +{
  8720. + return platform_driver_probe(&tc_driver, tc_probe);
  8721. +}
  8722. +arch_initcall(tc_init);
  8723. --- a/drivers/misc/Kconfig
  8724. +++ b/drivers/misc/Kconfig
  8725. @@ -22,6 +22,39 @@
  8726. purposes including software controlled power-efficent backlights
  8727. on LCD displays, motor control, and waveform generation.
  8728. +config ATMEL_TCLIB
  8729. + bool "Atmel AT32/AT91 Timer/Counter Library"
  8730. + depends on (AVR32 || ARCH_AT91)
  8731. + help
  8732. + Select this if you want a library to allocate the Timer/Counter
  8733. + blocks found on many Atmel processors. This facilitates using
  8734. + these blocks by different drivers despite processor differences.
  8735. +
  8736. +config ATMEL_TCB_CLKSRC
  8737. + bool "TC Block Clocksource"
  8738. + depends on ATMEL_TCLIB && GENERIC_TIME
  8739. + default y
  8740. + help
  8741. + Select this to get a high precision clocksource based on a
  8742. + TC block with a 5+ MHz base clock rate. Two timer channels
  8743. + are combined to make a single 32-bit timer.
  8744. +
  8745. + When GENERIC_CLOCKEVENTS is defined, the third timer channel
  8746. + may be used as a clock event device supporting oneshot mode
  8747. + (delays of up to two seconds) based on the 32 KiHz clock.
  8748. +
  8749. +config ATMEL_TCB_CLKSRC_BLOCK
  8750. + int
  8751. + depends on ATMEL_TCB_CLKSRC
  8752. + prompt "TC Block" if ARCH_AT91RM9200 || ARCH_AT91SAM9260 || CPU_AT32AP700X
  8753. + default 0
  8754. + range 0 1
  8755. + help
  8756. + Some chips provide more than one TC block, so you have the
  8757. + choice of which one to use for the clock framework. The other
  8758. + TC can be used for other purposes, such as PWM generation and
  8759. + interval timing.
  8760. +
  8761. config IBM_ASM
  8762. tristate "Device driver for IBM RSA service processor"
  8763. depends on X86 && PCI && INPUT && EXPERIMENTAL
  8764. --- a/drivers/misc/Makefile
  8765. +++ b/drivers/misc/Makefile
  8766. @@ -10,6 +10,7 @@
  8767. obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o
  8768. obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o
  8769. obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o
  8770. +obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
  8771. obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
  8772. obj-$(CONFIG_LKDTM) += lkdtm.o
  8773. obj-$(CONFIG_TIFM_CORE) += tifm_core.o
  8774. --- /dev/null
  8775. +++ b/drivers/mmc/host/atmel-mci.c
  8776. @@ -0,0 +1,1220 @@
  8777. +/*
  8778. + * Atmel MultiMedia Card Interface driver
  8779. + *
  8780. + * Copyright (C) 2004-2006 Atmel Corporation
  8781. + *
  8782. + * This program is free software; you can redistribute it and/or modify
  8783. + * it under the terms of the GNU General Public License version 2 as
  8784. + * published by the Free Software Foundation.
  8785. + */
  8786. +#include <linux/blkdev.h>
  8787. +#include <linux/clk.h>
  8788. +#include <linux/device.h>
  8789. +#include <linux/dma-mapping.h>
  8790. +#include <linux/init.h>
  8791. +#include <linux/interrupt.h>
  8792. +#include <linux/ioport.h>
  8793. +#include <linux/module.h>
  8794. +#include <linux/platform_device.h>
  8795. +
  8796. +#include <linux/mmc/host.h>
  8797. +
  8798. +#include <asm/dma-controller.h>
  8799. +#include <asm/io.h>
  8800. +#include <asm/arch/board.h>
  8801. +#include <asm/arch/gpio.h>
  8802. +
  8803. +#include "atmel-mci.h"
  8804. +
  8805. +#define DRIVER_NAME "atmel_mci"
  8806. +
  8807. +#define MCI_DATA_ERROR_FLAGS (MCI_BIT(DCRCE) | MCI_BIT(DTOE) | \
  8808. + MCI_BIT(OVRE) | MCI_BIT(UNRE))
  8809. +
  8810. +enum {
  8811. + EVENT_CMD_COMPLETE = 0,
  8812. + EVENT_DATA_COMPLETE,
  8813. + EVENT_DATA_ERROR,
  8814. + EVENT_STOP_SENT,
  8815. + EVENT_STOP_COMPLETE,
  8816. + EVENT_DMA_COMPLETE,
  8817. + EVENT_DMA_ERROR,
  8818. +};
  8819. +
  8820. +struct atmel_mci_dma {
  8821. + struct dma_request_sg req;
  8822. + unsigned short rx_periph_id;
  8823. + unsigned short tx_periph_id;
  8824. +};
  8825. +
  8826. +struct atmel_mci {
  8827. + struct mmc_host *mmc;
  8828. + void __iomem *regs;
  8829. + struct atmel_mci_dma dma;
  8830. +
  8831. + struct mmc_request *mrq;
  8832. + struct mmc_command *cmd;
  8833. + struct mmc_data *data;
  8834. +
  8835. + u32 cmd_status;
  8836. + u32 data_status;
  8837. + u32 stop_status;
  8838. + u32 stop_cmdr;
  8839. +
  8840. + struct tasklet_struct tasklet;
  8841. + unsigned long pending_events;
  8842. + unsigned long completed_events;
  8843. +
  8844. + int present;
  8845. + int detect_pin;
  8846. + int wp_pin;
  8847. +
  8848. + /* For detect pin debouncing */
  8849. + struct timer_list detect_timer;
  8850. +
  8851. + unsigned long bus_hz;
  8852. + unsigned long mapbase;
  8853. + struct clk *mck;
  8854. + struct platform_device *pdev;
  8855. +
  8856. +#ifdef CONFIG_DEBUG_FS
  8857. + struct dentry *debugfs_root;
  8858. + struct dentry *debugfs_regs;
  8859. + struct dentry *debugfs_req;
  8860. + struct dentry *debugfs_pending_events;
  8861. + struct dentry *debugfs_completed_events;
  8862. +#endif
  8863. +};
  8864. +
  8865. +/* Those printks take an awful lot of time... */
  8866. +#ifndef DEBUG
  8867. +static unsigned int fmax = 15000000U;
  8868. +#else
  8869. +static unsigned int fmax = 1000000U;
  8870. +#endif
  8871. +module_param(fmax, uint, 0444);
  8872. +MODULE_PARM_DESC(fmax, "Max frequency in Hz of the MMC bus clock");
  8873. +
  8874. +/* Test bit macros for completed events */
  8875. +#define mci_cmd_is_complete(host) \
  8876. + test_bit(EVENT_CMD_COMPLETE, &host->completed_events)
  8877. +#define mci_data_is_complete(host) \
  8878. + test_bit(EVENT_DATA_COMPLETE, &host->completed_events)
  8879. +#define mci_data_error_is_complete(host) \
  8880. + test_bit(EVENT_DATA_ERROR, &host->completed_events)
  8881. +#define mci_stop_sent_is_complete(host) \
  8882. + test_bit(EVENT_STOP_SENT, &host->completed_events)
  8883. +#define mci_stop_is_complete(host) \
  8884. + test_bit(EVENT_STOP_COMPLETE, &host->completed_events)
  8885. +#define mci_dma_is_complete(host) \
  8886. + test_bit(EVENT_DMA_COMPLETE, &host->completed_events)
  8887. +#define mci_dma_error_is_complete(host) \
  8888. + test_bit(EVENT_DMA_ERROR, &host->completed_events)
  8889. +
  8890. +/* Test and clear bit macros for pending events */
  8891. +#define mci_clear_cmd_is_pending(host) \
  8892. + test_and_clear_bit(EVENT_CMD_COMPLETE, &host->pending_events)
  8893. +#define mci_clear_data_is_pending(host) \
  8894. + test_and_clear_bit(EVENT_DATA_COMPLETE, &host->pending_events)
  8895. +#define mci_clear_data_error_is_pending(host) \
  8896. + test_and_clear_bit(EVENT_DATA_ERROR, &host->pending_events)
  8897. +#define mci_clear_stop_sent_is_pending(host) \
  8898. + test_and_clear_bit(EVENT_STOP_SENT, &host->pending_events)
  8899. +#define mci_clear_stop_is_pending(host) \
  8900. + test_and_clear_bit(EVENT_STOP_COMPLETE, &host->pending_events)
  8901. +#define mci_clear_dma_error_is_pending(host) \
  8902. + test_and_clear_bit(EVENT_DMA_ERROR, &host->pending_events)
  8903. +
  8904. +/* Test and set bit macros for completed events */
  8905. +#define mci_set_cmd_is_completed(host) \
  8906. + test_and_set_bit(EVENT_CMD_COMPLETE, &host->completed_events)
  8907. +#define mci_set_data_is_completed(host) \
  8908. + test_and_set_bit(EVENT_DATA_COMPLETE, &host->completed_events)
  8909. +#define mci_set_data_error_is_completed(host) \
  8910. + test_and_set_bit(EVENT_DATA_ERROR, &host->completed_events)
  8911. +#define mci_set_stop_sent_is_completed(host) \
  8912. + test_and_set_bit(EVENT_STOP_SENT, &host->completed_events)
  8913. +#define mci_set_stop_is_completed(host) \
  8914. + test_and_set_bit(EVENT_STOP_COMPLETE, &host->completed_events)
  8915. +#define mci_set_dma_error_is_completed(host) \
  8916. + test_and_set_bit(EVENT_DMA_ERROR, &host->completed_events)
  8917. +
  8918. +/* Set bit macros for completed events */
  8919. +#define mci_set_cmd_complete(host) \
  8920. + set_bit(EVENT_CMD_COMPLETE, &host->completed_events)
  8921. +#define mci_set_data_complete(host) \
  8922. + set_bit(EVENT_DATA_COMPLETE, &host->completed_events)
  8923. +#define mci_set_data_error_complete(host) \
  8924. + set_bit(EVENT_DATA_ERROR, &host->completed_events)
  8925. +#define mci_set_stop_sent_complete(host) \
  8926. + set_bit(EVENT_STOP_SENT, &host->completed_events)
  8927. +#define mci_set_stop_complete(host) \
  8928. + set_bit(EVENT_STOP_COMPLETE, &host->completed_events)
  8929. +#define mci_set_dma_complete(host) \
  8930. + set_bit(EVENT_DMA_COMPLETE, &host->completed_events)
  8931. +#define mci_set_dma_error_complete(host) \
  8932. + set_bit(EVENT_DMA_ERROR, &host->completed_events)
  8933. +
  8934. +/* Set bit macros for pending events */
  8935. +#define mci_set_cmd_pending(host) \
  8936. + set_bit(EVENT_CMD_COMPLETE, &host->pending_events)
  8937. +#define mci_set_data_pending(host) \
  8938. + set_bit(EVENT_DATA_COMPLETE, &host->pending_events)
  8939. +#define mci_set_data_error_pending(host) \
  8940. + set_bit(EVENT_DATA_ERROR, &host->pending_events)
  8941. +#define mci_set_stop_sent_pending(host) \
  8942. + set_bit(EVENT_STOP_SENT, &host->pending_events)
  8943. +#define mci_set_stop_pending(host) \
  8944. + set_bit(EVENT_STOP_COMPLETE, &host->pending_events)
  8945. +#define mci_set_dma_error_pending(host) \
  8946. + set_bit(EVENT_DMA_ERROR, &host->pending_events)
  8947. +
  8948. +/* Clear bit macros for pending events */
  8949. +#define mci_clear_cmd_pending(host) \
  8950. + clear_bit(EVENT_CMD_COMPLETE, &host->pending_events)
  8951. +#define mci_clear_data_pending(host) \
  8952. + clear_bit(EVENT_DATA_COMPLETE, &host->pending_events)
  8953. +#define mci_clear_data_error_pending(host) \
  8954. + clear_bit(EVENT_DATA_ERROR, &host->pending_events)
  8955. +#define mci_clear_stop_sent_pending(host) \
  8956. + clear_bit(EVENT_STOP_SENT, &host->pending_events)
  8957. +#define mci_clear_stop_pending(host) \
  8958. + clear_bit(EVENT_STOP_COMPLETE, &host->pending_events)
  8959. +#define mci_clear_dma_error_pending(host) \
  8960. + clear_bit(EVENT_DMA_ERROR, &host->pending_events)
  8961. +
  8962. +
  8963. +#ifdef CONFIG_DEBUG_FS
  8964. +#include <linux/debugfs.h>
  8965. +
  8966. +#define DBG_REQ_BUF_SIZE (4096 - sizeof(unsigned int))
  8967. +
  8968. +struct req_dbg_data {
  8969. + unsigned int nbytes;
  8970. + char str[DBG_REQ_BUF_SIZE];
  8971. +};
  8972. +
  8973. +static int req_dbg_open(struct inode *inode, struct file *file)
  8974. +{
  8975. + struct atmel_mci *host;
  8976. + struct mmc_request *mrq;
  8977. + struct mmc_command *cmd, *stop;
  8978. + struct mmc_data *data;
  8979. + struct req_dbg_data *priv;
  8980. + char *str;
  8981. + unsigned long n = 0;
  8982. +
  8983. + priv = kzalloc(DBG_REQ_BUF_SIZE, GFP_KERNEL);
  8984. + if (!priv)
  8985. + return -ENOMEM;
  8986. + str = priv->str;
  8987. +
  8988. + mutex_lock(&inode->i_mutex);
  8989. + host = inode->i_private;
  8990. +
  8991. + spin_lock_irq(&host->mmc->lock);
  8992. + mrq = host->mrq;
  8993. + if (mrq) {
  8994. + cmd = mrq->cmd;
  8995. + data = mrq->data;
  8996. + stop = mrq->stop;
  8997. + n = snprintf(str, DBG_REQ_BUF_SIZE,
  8998. + "CMD%u(0x%x) %x %x %x %x %x (err %u)\n",
  8999. + cmd->opcode, cmd->arg, cmd->flags,
  9000. + cmd->resp[0], cmd->resp[1], cmd->resp[2],
  9001. + cmd->resp[3], cmd->error);
  9002. + if (n < DBG_REQ_BUF_SIZE && data)
  9003. + n += snprintf(str + n, DBG_REQ_BUF_SIZE - n,
  9004. + "DATA %u * %u (%u) %x (err %u)\n",
  9005. + data->blocks, data->blksz,
  9006. + data->bytes_xfered, data->flags,
  9007. + data->error);
  9008. + if (n < DBG_REQ_BUF_SIZE && stop)
  9009. + n += snprintf(str + n, DBG_REQ_BUF_SIZE - n,
  9010. + "CMD%u(0x%x) %x %x %x %x %x (err %u)\n",
  9011. + stop->opcode, stop->arg, stop->flags,
  9012. + stop->resp[0], stop->resp[1],
  9013. + stop->resp[2], stop->resp[3],
  9014. + stop->error);
  9015. + }
  9016. + spin_unlock_irq(&host->mmc->lock);
  9017. + mutex_unlock(&inode->i_mutex);
  9018. +
  9019. + priv->nbytes = min(n, DBG_REQ_BUF_SIZE);
  9020. + file->private_data = priv;
  9021. +
  9022. + return 0;
  9023. +}
  9024. +
  9025. +static ssize_t req_dbg_read(struct file *file, char __user *buf,
  9026. + size_t nbytes, loff_t *ppos)
  9027. +{
  9028. + struct req_dbg_data *priv = file->private_data;
  9029. +
  9030. + return simple_read_from_buffer(buf, nbytes, ppos,
  9031. + priv->str, priv->nbytes);
  9032. +}
  9033. +
  9034. +static int req_dbg_release(struct inode *inode, struct file *file)
  9035. +{
  9036. + kfree(file->private_data);
  9037. + return 0;
  9038. +}
  9039. +
  9040. +static const struct file_operations req_dbg_fops = {
  9041. + .owner = THIS_MODULE,
  9042. + .open = req_dbg_open,
  9043. + .llseek = no_llseek,
  9044. + .read = req_dbg_read,
  9045. + .release = req_dbg_release,
  9046. +};
  9047. +
  9048. +static int regs_dbg_open(struct inode *inode, struct file *file)
  9049. +{
  9050. + struct atmel_mci *host;
  9051. + unsigned int i;
  9052. + u32 *data;
  9053. + int ret = -ENOMEM;
  9054. +
  9055. + mutex_lock(&inode->i_mutex);
  9056. + host = inode->i_private;
  9057. + data = kmalloc(inode->i_size, GFP_KERNEL);
  9058. + if (!data)
  9059. + goto out;
  9060. +
  9061. + spin_lock_irq(&host->mmc->lock);
  9062. + for (i = 0; i < inode->i_size / 4; i++)
  9063. + data[i] = __raw_readl(host->regs + i * 4);
  9064. + spin_unlock_irq(&host->mmc->lock);
  9065. +
  9066. + file->private_data = data;
  9067. + ret = 0;
  9068. +
  9069. +out:
  9070. + mutex_unlock(&inode->i_mutex);
  9071. +
  9072. + return ret;
  9073. +}
  9074. +
  9075. +static ssize_t regs_dbg_read(struct file *file, char __user *buf,
  9076. + size_t nbytes, loff_t *ppos)
  9077. +{
  9078. + struct inode *inode = file->f_dentry->d_inode;
  9079. + int ret;
  9080. +
  9081. + mutex_lock(&inode->i_mutex);
  9082. + ret = simple_read_from_buffer(buf, nbytes, ppos,
  9083. + file->private_data,
  9084. + file->f_dentry->d_inode->i_size);
  9085. + mutex_unlock(&inode->i_mutex);
  9086. +
  9087. + return ret;
  9088. +}
  9089. +
  9090. +static int regs_dbg_release(struct inode *inode, struct file *file)
  9091. +{
  9092. + kfree(file->private_data);
  9093. + return 0;
  9094. +}
  9095. +
  9096. +static const struct file_operations regs_dbg_fops = {
  9097. + .owner = THIS_MODULE,
  9098. + .open = regs_dbg_open,
  9099. + .llseek = generic_file_llseek,
  9100. + .read = regs_dbg_read,
  9101. + .release = regs_dbg_release,
  9102. +};
  9103. +
  9104. +static void atmci_init_debugfs(struct atmel_mci *host)
  9105. +{
  9106. + struct mmc_host *mmc;
  9107. + struct dentry *root, *regs;
  9108. + struct resource *res;
  9109. +
  9110. + mmc = host->mmc;
  9111. + root = debugfs_create_dir(mmc_hostname(mmc), NULL);
  9112. + if (IS_ERR(root) || !root)
  9113. + goto err_root;
  9114. + host->debugfs_root = root;
  9115. +
  9116. + regs = debugfs_create_file("regs", 0400, root, host, &regs_dbg_fops);
  9117. + if (!regs)
  9118. + goto err_regs;
  9119. +
  9120. + res = platform_get_resource(host->pdev, IORESOURCE_MEM, 0);
  9121. + regs->d_inode->i_size = res->end - res->start + 1;
  9122. + host->debugfs_regs = regs;
  9123. +
  9124. + host->debugfs_req = debugfs_create_file("req", 0400, root,
  9125. + host, &req_dbg_fops);
  9126. + if (!host->debugfs_req)
  9127. + goto err_req;
  9128. +
  9129. + host->debugfs_pending_events
  9130. + = debugfs_create_u32("pending_events", 0400, root,
  9131. + (u32 *)&host->pending_events);
  9132. + if (!host->debugfs_pending_events)
  9133. + goto err_pending_events;
  9134. +
  9135. + host->debugfs_completed_events
  9136. + = debugfs_create_u32("completed_events", 0400, root,
  9137. + (u32 *)&host->completed_events);
  9138. + if (!host->debugfs_completed_events)
  9139. + goto err_completed_events;
  9140. +
  9141. + return;
  9142. +
  9143. +err_completed_events:
  9144. + debugfs_remove(host->debugfs_pending_events);
  9145. +err_pending_events:
  9146. + debugfs_remove(host->debugfs_req);
  9147. +err_req:
  9148. + debugfs_remove(host->debugfs_regs);
  9149. +err_regs:
  9150. + debugfs_remove(host->debugfs_root);
  9151. +err_root:
  9152. + host->debugfs_root = NULL;
  9153. + dev_err(&host->pdev->dev,
  9154. + "failed to initialize debugfs for %s\n",
  9155. + mmc_hostname(mmc));
  9156. +}
  9157. +
  9158. +static void atmci_cleanup_debugfs(struct atmel_mci *host)
  9159. +{
  9160. + if (host->debugfs_root) {
  9161. + debugfs_remove(host->debugfs_completed_events);
  9162. + debugfs_remove(host->debugfs_pending_events);
  9163. + debugfs_remove(host->debugfs_req);
  9164. + debugfs_remove(host->debugfs_regs);
  9165. + debugfs_remove(host->debugfs_root);
  9166. + host->debugfs_root = NULL;
  9167. + }
  9168. +}
  9169. +#else
  9170. +static inline void atmci_init_debugfs(struct atmel_mci *host)
  9171. +{
  9172. +
  9173. +}
  9174. +
  9175. +static inline void atmci_cleanup_debugfs(struct atmel_mci *host)
  9176. +{
  9177. +
  9178. +}
  9179. +#endif /* CONFIG_DEBUG_FS */
  9180. +
  9181. +static inline unsigned int ns_to_clocks(struct atmel_mci *host,
  9182. + unsigned int ns)
  9183. +{
  9184. + return (ns * (host->bus_hz / 1000000) + 999) / 1000;
  9185. +}
  9186. +
  9187. +static void atmci_set_timeout(struct atmel_mci *host,
  9188. + struct mmc_data *data)
  9189. +{
  9190. + static unsigned dtomul_to_shift[] = {
  9191. + 0, 4, 7, 8, 10, 12, 16, 20
  9192. + };
  9193. + unsigned timeout;
  9194. + unsigned dtocyc, dtomul;
  9195. +
  9196. + timeout = ns_to_clocks(host, data->timeout_ns) + data->timeout_clks;
  9197. +
  9198. + for (dtomul = 0; dtomul < 8; dtomul++) {
  9199. + unsigned shift = dtomul_to_shift[dtomul];
  9200. + dtocyc = (timeout + (1 << shift) - 1) >> shift;
  9201. + if (dtocyc < 15)
  9202. + break;
  9203. + }
  9204. +
  9205. + if (dtomul >= 8) {
  9206. + dtomul = 7;
  9207. + dtocyc = 15;
  9208. + }
  9209. +
  9210. + dev_dbg(&host->mmc->class_dev, "setting timeout to %u cycles\n",
  9211. + dtocyc << dtomul_to_shift[dtomul]);
  9212. + mci_writel(host, DTOR, (MCI_BF(DTOMUL, dtomul)
  9213. + | MCI_BF(DTOCYC, dtocyc)));
  9214. +}
  9215. +
  9216. +/*
  9217. + * Return mask with command flags to be enabled for this command.
  9218. + */
  9219. +static u32 atmci_prepare_command(struct mmc_host *mmc,
  9220. + struct mmc_command *cmd)
  9221. +{
  9222. + u32 cmdr;
  9223. +
  9224. + cmd->error = 0;
  9225. +
  9226. + cmdr = MCI_BF(CMDNB, cmd->opcode);
  9227. +
  9228. + if (cmd->flags & MMC_RSP_PRESENT) {
  9229. + if (cmd->flags & MMC_RSP_136)
  9230. + cmdr |= MCI_BF(RSPTYP, MCI_RSPTYP_136_BIT);
  9231. + else
  9232. + cmdr |= MCI_BF(RSPTYP, MCI_RSPTYP_48_BIT);
  9233. + }
  9234. +
  9235. + /*
  9236. + * This should really be MAXLAT_5 for CMD2 and ACMD41, but
  9237. + * it's too difficult to determine whether this is an ACMD or
  9238. + * not. Better make it 64.
  9239. + */
  9240. + cmdr |= MCI_BIT(MAXLAT);
  9241. +
  9242. + if (mmc->ios.bus_mode == MMC_BUSMODE_OPENDRAIN)
  9243. + cmdr |= MCI_BIT(OPDCMD);
  9244. +
  9245. + dev_dbg(&mmc->class_dev,
  9246. + "cmd: op %02x arg %08x flags %08x, cmdflags %08lx\n",
  9247. + cmd->opcode, cmd->arg, cmd->flags, (unsigned long)cmdr);
  9248. +
  9249. + return cmdr;
  9250. +}
  9251. +
  9252. +static void atmci_start_command(struct atmel_mci *host,
  9253. + struct mmc_command *cmd,
  9254. + u32 cmd_flags)
  9255. +{
  9256. + WARN_ON(host->cmd);
  9257. + host->cmd = cmd;
  9258. +
  9259. + mci_writel(host, ARGR, cmd->arg);
  9260. + mci_writel(host, CMDR, cmd_flags);
  9261. +
  9262. + if (cmd->data)
  9263. + dma_start_request(host->dma.req.req.dmac,
  9264. + host->dma.req.req.channel);
  9265. +}
  9266. +
  9267. +/*
  9268. + * Returns a mask of flags to be set in the command register when the
  9269. + * command to start the transfer is to be sent.
  9270. + */
  9271. +static u32 atmci_prepare_data(struct mmc_host *mmc, struct mmc_data *data)
  9272. +{
  9273. + struct atmel_mci *host = mmc_priv(mmc);
  9274. + u32 cmd_flags;
  9275. +
  9276. + WARN_ON(host->data);
  9277. + host->data = data;
  9278. +
  9279. + atmci_set_timeout(host, data);
  9280. + mci_writel(host, BLKR, (MCI_BF(BCNT, data->blocks)
  9281. + | MCI_BF(BLKLEN, data->blksz)));
  9282. + host->dma.req.block_size = data->blksz;
  9283. + host->dma.req.nr_blocks = data->blocks;
  9284. +
  9285. + cmd_flags = MCI_BF(TRCMD, MCI_TRCMD_START_TRANS);
  9286. + if (data->flags & MMC_DATA_STREAM)
  9287. + cmd_flags |= MCI_BF(TRTYP, MCI_TRTYP_STREAM);
  9288. + else if (data->blocks > 1)
  9289. + cmd_flags |= MCI_BF(TRTYP, MCI_TRTYP_MULTI_BLOCK);
  9290. + else
  9291. + cmd_flags |= MCI_BF(TRTYP, MCI_TRTYP_BLOCK);
  9292. +
  9293. + if (data->flags & MMC_DATA_READ) {
  9294. + cmd_flags |= MCI_BIT(TRDIR);
  9295. + host->dma.req.nr_sg
  9296. + = dma_map_sg(&host->pdev->dev, data->sg,
  9297. + data->sg_len, DMA_FROM_DEVICE);
  9298. + host->dma.req.periph_id = host->dma.rx_periph_id;
  9299. + host->dma.req.direction = DMA_DIR_PERIPH_TO_MEM;
  9300. + host->dma.req.data_reg = host->mapbase + MCI_RDR;
  9301. + } else {
  9302. + host->dma.req.nr_sg
  9303. + = dma_map_sg(&host->pdev->dev, data->sg,
  9304. + data->sg_len, DMA_TO_DEVICE);
  9305. + host->dma.req.periph_id = host->dma.tx_periph_id;
  9306. + host->dma.req.direction = DMA_DIR_MEM_TO_PERIPH;
  9307. + host->dma.req.data_reg = host->mapbase + MCI_TDR;
  9308. + }
  9309. + host->dma.req.sg = data->sg;
  9310. +
  9311. + dma_prepare_request_sg(host->dma.req.req.dmac, &host->dma.req);
  9312. +
  9313. + return cmd_flags;
  9314. +}
  9315. +
  9316. +static void atmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
  9317. +{
  9318. + struct atmel_mci *host = mmc_priv(mmc);
  9319. + struct mmc_data *data = mrq->data;
  9320. + u32 iflags;
  9321. + u32 cmdflags = 0;
  9322. +
  9323. + iflags = mci_readl(host, IMR);
  9324. + if (iflags)
  9325. + dev_warn(&mmc->class_dev, "WARNING: IMR=0x%08x\n",
  9326. + mci_readl(host, IMR));
  9327. +
  9328. + WARN_ON(host->mrq != NULL);
  9329. +
  9330. + /*
  9331. + * We may "know" the card is gone even though there's still an
  9332. + * electrical connection. If so, we really need to communicate
  9333. + * this to the MMC core since there won't be any more
  9334. + * interrupts as the card is completely removed. Otherwise,
  9335. + * the MMC core might believe the card is still there even
  9336. + * though the card was just removed very slowly.
  9337. + */
  9338. + if (!host->present) {
  9339. + mrq->cmd->error = -ENOMEDIUM;
  9340. + mmc_request_done(mmc, mrq);
  9341. + return;
  9342. + }
  9343. +
  9344. + host->mrq = mrq;
  9345. + host->pending_events = 0;
  9346. + host->completed_events = 0;
  9347. +
  9348. + iflags = MCI_BIT(CMDRDY);
  9349. + cmdflags = atmci_prepare_command(mmc, mrq->cmd);
  9350. +
  9351. + if (mrq->stop) {
  9352. + WARN_ON(!data);
  9353. +
  9354. + host->stop_cmdr = atmci_prepare_command(mmc, mrq->stop);
  9355. + host->stop_cmdr |= MCI_BF(TRCMD, MCI_TRCMD_STOP_TRANS);
  9356. + if (!(data->flags & MMC_DATA_WRITE))
  9357. + host->stop_cmdr |= MCI_BIT(TRDIR);
  9358. + if (data->flags & MMC_DATA_STREAM)
  9359. + host->stop_cmdr |= MCI_BF(TRTYP, MCI_TRTYP_STREAM);
  9360. + else
  9361. + host->stop_cmdr |= MCI_BF(TRTYP, MCI_TRTYP_MULTI_BLOCK);
  9362. + }
  9363. + if (data) {
  9364. + cmdflags |= atmci_prepare_data(mmc, data);
  9365. + iflags |= MCI_DATA_ERROR_FLAGS;
  9366. + }
  9367. +
  9368. + atmci_start_command(host, mrq->cmd, cmdflags);
  9369. + mci_writel(host, IER, iflags);
  9370. +}
  9371. +
  9372. +static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  9373. +{
  9374. + struct atmel_mci *host = mmc_priv(mmc);
  9375. + u32 mr;
  9376. +
  9377. + if (ios->clock) {
  9378. + u32 clkdiv;
  9379. +
  9380. + /* Set clock rate */
  9381. + clkdiv = DIV_ROUND_UP(host->bus_hz, 2 * ios->clock) - 1;
  9382. + if (clkdiv > 255) {
  9383. + dev_warn(&mmc->class_dev,
  9384. + "clock %u too slow; using %lu\n",
  9385. + ios->clock, host->bus_hz / (2 * 256));
  9386. + clkdiv = 255;
  9387. + }
  9388. +
  9389. + mr = mci_readl(host, MR);
  9390. + mr = MCI_BFINS(CLKDIV, clkdiv, mr)
  9391. + | MCI_BIT(WRPROOF) | MCI_BIT(RDPROOF);
  9392. + mci_writel(host, MR, mr);
  9393. +
  9394. + /* Enable the MCI controller */
  9395. + mci_writel(host, CR, MCI_BIT(MCIEN));
  9396. + } else {
  9397. + /* Disable the MCI controller */
  9398. + mci_writel(host, CR, MCI_BIT(MCIDIS));
  9399. + }
  9400. +
  9401. + switch (ios->bus_width) {
  9402. + case MMC_BUS_WIDTH_1:
  9403. + mci_writel(host, SDCR, 0);
  9404. + break;
  9405. + case MMC_BUS_WIDTH_4:
  9406. + mci_writel(host, SDCR, MCI_BIT(SDCBUS));
  9407. + break;
  9408. + }
  9409. +
  9410. + switch (ios->power_mode) {
  9411. + case MMC_POWER_ON:
  9412. + /* Send init sequence (74 clock cycles) */
  9413. + mci_writel(host, IDR, ~0UL);
  9414. + mci_writel(host, CMDR, MCI_BF(SPCMD, MCI_SPCMD_INIT_CMD));
  9415. + while (!(mci_readl(host, SR) & MCI_BIT(CMDRDY)))
  9416. + cpu_relax();
  9417. + break;
  9418. + default:
  9419. + /*
  9420. + * TODO: None of the currently available AVR32-based
  9421. + * boards allow MMC power to be turned off. Implement
  9422. + * power control when this can be tested properly.
  9423. + */
  9424. + break;
  9425. + }
  9426. +}
  9427. +
  9428. +static int atmci_get_ro(struct mmc_host *mmc)
  9429. +{
  9430. + int read_only = 0;
  9431. + struct atmel_mci *host = mmc_priv(mmc);
  9432. +
  9433. + if (host->wp_pin >= 0) {
  9434. + read_only = gpio_get_value(host->wp_pin);
  9435. + dev_dbg(&mmc->class_dev, "card is %s\n",
  9436. + read_only ? "read-only" : "read-write");
  9437. + } else {
  9438. + dev_dbg(&mmc->class_dev,
  9439. + "no pin for checking read-only switch."
  9440. + " Assuming write-enable.\n");
  9441. + }
  9442. +
  9443. + return read_only;
  9444. +}
  9445. +
  9446. +static struct mmc_host_ops atmci_ops = {
  9447. + .request = atmci_request,
  9448. + .set_ios = atmci_set_ios,
  9449. + .get_ro = atmci_get_ro,
  9450. +};
  9451. +
  9452. +static void atmci_request_end(struct mmc_host *mmc, struct mmc_request *mrq)
  9453. +{
  9454. + struct atmel_mci *host = mmc_priv(mmc);
  9455. +
  9456. + WARN_ON(host->cmd || host->data);
  9457. + host->mrq = NULL;
  9458. +
  9459. + mmc_request_done(mmc, mrq);
  9460. +}
  9461. +
  9462. +static void send_stop_cmd(struct mmc_host *mmc, struct mmc_data *data,
  9463. + u32 flags)
  9464. +{
  9465. + struct atmel_mci *host = mmc_priv(mmc);
  9466. +
  9467. + atmci_start_command(host, data->stop, host->stop_cmdr | flags);
  9468. + mci_writel(host, IER, MCI_BIT(CMDRDY));
  9469. +}
  9470. +
  9471. +static void atmci_data_complete(struct atmel_mci *host, struct mmc_data *data)
  9472. +{
  9473. + host->data = NULL;
  9474. + dma_unmap_sg(&host->pdev->dev, data->sg, host->dma.req.nr_sg,
  9475. + ((data->flags & MMC_DATA_WRITE)
  9476. + ? DMA_TO_DEVICE : DMA_FROM_DEVICE));
  9477. +
  9478. + /*
  9479. + * Data might complete before command for very short transfers
  9480. + * (like READ_SCR)
  9481. + */
  9482. + if (mci_cmd_is_complete(host)
  9483. + && (!data->stop || mci_stop_is_complete(host)))
  9484. + atmci_request_end(host->mmc, data->mrq);
  9485. +}
  9486. +
  9487. +static void atmci_command_complete(struct atmel_mci *host,
  9488. + struct mmc_command *cmd, u32 status)
  9489. +{
  9490. + if (status & MCI_BIT(RTOE))
  9491. + cmd->error = -ETIMEDOUT;
  9492. + else if ((cmd->flags & MMC_RSP_CRC)
  9493. + && (status & MCI_BIT(RCRCE)))
  9494. + cmd->error = -EILSEQ;
  9495. + else if (status & (MCI_BIT(RINDE) | MCI_BIT(RDIRE) | MCI_BIT(RENDE)))
  9496. + cmd->error = -EIO;
  9497. +
  9498. + if (cmd->error) {
  9499. + dev_dbg(&host->mmc->class_dev,
  9500. + "command error: op=0x%x status=0x%08x\n",
  9501. + cmd->opcode, status);
  9502. +
  9503. + if (cmd->data) {
  9504. + dma_stop_request(host->dma.req.req.dmac,
  9505. + host->dma.req.req.channel);
  9506. + mci_writel(host, IDR, MCI_BIT(NOTBUSY)
  9507. + | MCI_DATA_ERROR_FLAGS);
  9508. + host->data = NULL;
  9509. + }
  9510. + }
  9511. +}
  9512. +
  9513. +static void atmci_detect_change(unsigned long data)
  9514. +{
  9515. + struct atmel_mci *host = (struct atmel_mci *)data;
  9516. + struct mmc_request *mrq = host->mrq;
  9517. + int present;
  9518. +
  9519. + /*
  9520. + * atmci_remove() sets detect_pin to -1 before freeing the
  9521. + * interrupt. We must not re-enable the interrupt if it has
  9522. + * been freed.
  9523. + */
  9524. + smp_rmb();
  9525. + if (host->detect_pin < 0)
  9526. + return;
  9527. +
  9528. + enable_irq(gpio_to_irq(host->detect_pin));
  9529. + present = !gpio_get_value(host->detect_pin);
  9530. +
  9531. + dev_vdbg(&host->pdev->dev, "detect change: %d (was %d)\n",
  9532. + present, host->present);
  9533. +
  9534. + if (present != host->present) {
  9535. + dev_dbg(&host->mmc->class_dev, "card %s\n",
  9536. + present ? "inserted" : "removed");
  9537. + host->present = present;
  9538. +
  9539. + /* Reset controller if card is gone */
  9540. + if (!present) {
  9541. + mci_writel(host, CR, MCI_BIT(SWRST));
  9542. + mci_writel(host, IDR, ~0UL);
  9543. + mci_writel(host, CR, MCI_BIT(MCIEN));
  9544. + }
  9545. +
  9546. + /* Clean up queue if present */
  9547. + if (mrq) {
  9548. + if (!mci_cmd_is_complete(host))
  9549. + mrq->cmd->error = -ENOMEDIUM;
  9550. + if (mrq->data && !mci_data_is_complete(host)
  9551. + && !mci_data_error_is_complete(host)) {
  9552. + dma_stop_request(host->dma.req.req.dmac,
  9553. + host->dma.req.req.channel);
  9554. + host->data->error = -ENOMEDIUM;
  9555. + atmci_data_complete(host, host->data);
  9556. + }
  9557. + if (mrq->stop && !mci_stop_is_complete(host))
  9558. + mrq->stop->error = -ENOMEDIUM;
  9559. +
  9560. + host->cmd = NULL;
  9561. + atmci_request_end(host->mmc, mrq);
  9562. + }
  9563. +
  9564. + mmc_detect_change(host->mmc, 0);
  9565. + }
  9566. +}
  9567. +
  9568. +static void atmci_tasklet_func(unsigned long priv)
  9569. +{
  9570. + struct mmc_host *mmc = (struct mmc_host *)priv;
  9571. + struct atmel_mci *host = mmc_priv(mmc);
  9572. + struct mmc_request *mrq = host->mrq;
  9573. + struct mmc_data *data = host->data;
  9574. +
  9575. + dev_vdbg(&mmc->class_dev,
  9576. + "tasklet: pending/completed/mask %lx/%lx/%x\n",
  9577. + host->pending_events, host->completed_events,
  9578. + mci_readl(host, IMR));
  9579. +
  9580. + if (mci_clear_cmd_is_pending(host)) {
  9581. + mci_set_cmd_complete(host);
  9582. + atmci_command_complete(host, mrq->cmd, host->cmd_status);
  9583. + if (!host->data || mci_data_is_complete(host)
  9584. + || mci_data_error_is_complete(host))
  9585. + atmci_request_end(mmc, mrq);
  9586. + }
  9587. + if (mci_clear_stop_is_pending(host)) {
  9588. + mci_set_stop_complete(host);
  9589. + atmci_command_complete(host, mrq->stop, host->stop_status);
  9590. + if (mci_data_is_complete(host)
  9591. + || mci_data_error_is_complete(host))
  9592. + atmci_request_end(mmc, mrq);
  9593. + }
  9594. + if (mci_clear_dma_error_is_pending(host)) {
  9595. + mci_set_dma_error_complete(host);
  9596. + mci_clear_data_pending(host);
  9597. +
  9598. + /* DMA controller got bus error => invalid address */
  9599. + data->error = -EIO;
  9600. +
  9601. + dev_dbg(&mmc->class_dev, "dma error after %u bytes xfered\n",
  9602. + host->data->bytes_xfered);
  9603. +
  9604. + if (data->stop
  9605. + && !mci_set_stop_sent_is_completed(host))
  9606. + /* TODO: Check if card is still present */
  9607. + send_stop_cmd(host->mmc, data, 0);
  9608. +
  9609. + atmci_data_complete(host, data);
  9610. + }
  9611. + if (mci_clear_data_error_is_pending(host)) {
  9612. + u32 status = host->data_status;
  9613. +
  9614. + mci_set_data_error_complete(host);
  9615. + mci_clear_data_pending(host);
  9616. +
  9617. + dma_stop_request(host->dma.req.req.dmac,
  9618. + host->dma.req.req.channel);
  9619. +
  9620. + if (status & MCI_BIT(DCRCE)) {
  9621. + dev_dbg(&mmc->class_dev, "data CRC error\n");
  9622. + data->error = -EILSEQ;
  9623. + } else if (status & MCI_BIT(DTOE)) {
  9624. + dev_dbg(&mmc->class_dev, "data timeout error\n");
  9625. + data->error = -ETIMEDOUT;
  9626. + } else {
  9627. + dev_dbg(&mmc->class_dev, "data FIFO error\n");
  9628. + data->error = -EIO;
  9629. + }
  9630. + dev_dbg(&mmc->class_dev, "bytes xfered: %u\n",
  9631. + data->bytes_xfered);
  9632. +
  9633. + if (data->stop
  9634. + && !mci_set_stop_sent_is_completed(host))
  9635. + /* TODO: Check if card is still present */
  9636. + send_stop_cmd(host->mmc, data, 0);
  9637. +
  9638. + atmci_data_complete(host, data);
  9639. + }
  9640. + if (mci_clear_data_is_pending(host)) {
  9641. + mci_set_data_complete(host);
  9642. + data->bytes_xfered = data->blocks * data->blksz;
  9643. + atmci_data_complete(host, data);
  9644. + }
  9645. +}
  9646. +
  9647. +static void atmci_cmd_interrupt(struct mmc_host *mmc, u32 status)
  9648. +{
  9649. + struct atmel_mci *host = mmc_priv(mmc);
  9650. + struct mmc_command *cmd = host->cmd;
  9651. +
  9652. + /*
  9653. + * Read the response now so that we're free to send a new
  9654. + * command immediately.
  9655. + */
  9656. + cmd->resp[0] = mci_readl(host, RSPR);
  9657. + cmd->resp[1] = mci_readl(host, RSPR);
  9658. + cmd->resp[2] = mci_readl(host, RSPR);
  9659. + cmd->resp[3] = mci_readl(host, RSPR);
  9660. +
  9661. + mci_writel(host, IDR, MCI_BIT(CMDRDY));
  9662. + host->cmd = NULL;
  9663. +
  9664. + if (mci_stop_sent_is_complete(host)) {
  9665. + host->stop_status = status;
  9666. + mci_set_stop_pending(host);
  9667. + } else {
  9668. + struct mmc_request *mrq = host->mrq;
  9669. +
  9670. + if (mrq->stop && mci_dma_is_complete(host)
  9671. + && !mci_set_stop_sent_is_completed(host))
  9672. + send_stop_cmd(host->mmc, mrq->data, 0);
  9673. + host->cmd_status = status;
  9674. + mci_set_cmd_pending(host);
  9675. + }
  9676. +
  9677. + tasklet_schedule(&host->tasklet);
  9678. +}
  9679. +
  9680. +static void atmci_xfer_complete(struct dma_request *_req)
  9681. +{
  9682. + struct dma_request_sg *req = to_dma_request_sg(_req);
  9683. + struct atmel_mci_dma *dma;
  9684. + struct atmel_mci *host;
  9685. + struct mmc_data *data;
  9686. +
  9687. + dma = container_of(req, struct atmel_mci_dma, req);
  9688. + host = container_of(dma, struct atmel_mci, dma);
  9689. + data = host->data;
  9690. +
  9691. + /*
  9692. + * This callback may be called before we see the CMDRDY
  9693. + * interrupt under heavy irq load (possibly caused by other
  9694. + * drivers) or when interrupts are disabled for a long time.
  9695. + */
  9696. + mci_set_dma_complete(host);
  9697. + if (data->stop && mci_cmd_is_complete(host)
  9698. + && !mci_set_stop_sent_is_completed(host))
  9699. + send_stop_cmd(host->mmc, data, 0);
  9700. +
  9701. + /*
  9702. + * Regardless of what the documentation says, we have to wait
  9703. + * for NOTBUSY even after block read operations.
  9704. + *
  9705. + * When the DMA transfer is complete, the controller may still
  9706. + * be reading the CRC from the card, i.e. the data transfer is
  9707. + * still in progress and we haven't seen all the potential
  9708. + * error bits yet.
  9709. + */
  9710. + mci_writel(host, IER, MCI_BIT(NOTBUSY));
  9711. +}
  9712. +
  9713. +static void atmci_dma_error(struct dma_request *_req)
  9714. +{
  9715. + struct dma_request_sg *req = to_dma_request_sg(_req);
  9716. + struct atmel_mci_dma *dma;
  9717. + struct atmel_mci *host;
  9718. +
  9719. + dma = container_of(req, struct atmel_mci_dma, req);
  9720. + host = container_of(dma, struct atmel_mci, dma);
  9721. +
  9722. + mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
  9723. + | MCI_DATA_ERROR_FLAGS));
  9724. +
  9725. + mci_set_dma_error_pending(host);
  9726. + tasklet_schedule(&host->tasklet);
  9727. +}
  9728. +
  9729. +static irqreturn_t atmci_interrupt(int irq, void *dev_id)
  9730. +{
  9731. + struct mmc_host *mmc = dev_id;
  9732. + struct atmel_mci *host = mmc_priv(mmc);
  9733. + u32 status, mask, pending;
  9734. +
  9735. + spin_lock(&mmc->lock);
  9736. +
  9737. + status = mci_readl(host, SR);
  9738. + mask = mci_readl(host, IMR);
  9739. + pending = status & mask;
  9740. +
  9741. + do {
  9742. + if (pending & MCI_DATA_ERROR_FLAGS) {
  9743. + mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
  9744. + | MCI_DATA_ERROR_FLAGS));
  9745. + host->data_status = status;
  9746. + mci_set_data_error_pending(host);
  9747. + tasklet_schedule(&host->tasklet);
  9748. + break;
  9749. + }
  9750. + if (pending & MCI_BIT(CMDRDY))
  9751. + atmci_cmd_interrupt(mmc, status);
  9752. + if (pending & MCI_BIT(NOTBUSY)) {
  9753. + mci_writel(host, IDR, (MCI_BIT(NOTBUSY)
  9754. + | MCI_DATA_ERROR_FLAGS));
  9755. + mci_set_data_pending(host);
  9756. + tasklet_schedule(&host->tasklet);
  9757. + }
  9758. +
  9759. + status = mci_readl(host, SR);
  9760. + mask = mci_readl(host, IMR);
  9761. + pending = status & mask;
  9762. + } while (pending);
  9763. +
  9764. + spin_unlock(&mmc->lock);
  9765. +
  9766. + return IRQ_HANDLED;
  9767. +}
  9768. +
  9769. +static irqreturn_t atmci_detect_interrupt(int irq, void *dev_id)
  9770. +{
  9771. + struct mmc_host *mmc = dev_id;
  9772. + struct atmel_mci *host = mmc_priv(mmc);
  9773. +
  9774. + /*
  9775. + * Disable interrupts until the pin has stabilized and check
  9776. + * the state then. Use mod_timer() since we may be in the
  9777. + * middle of the timer routine when this interrupt triggers.
  9778. + */
  9779. + disable_irq_nosync(irq);
  9780. + mod_timer(&host->detect_timer, jiffies + msecs_to_jiffies(20));
  9781. +
  9782. + return IRQ_HANDLED;
  9783. +}
  9784. +
  9785. +static int __devinit atmci_probe(struct platform_device *pdev)
  9786. +{
  9787. + struct mci_platform_data *board;
  9788. + struct atmel_mci *host;
  9789. + struct mmc_host *mmc;
  9790. + struct resource *regs;
  9791. + int irq;
  9792. + int ret;
  9793. +
  9794. + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  9795. + if (!regs)
  9796. + return -ENXIO;
  9797. + irq = platform_get_irq(pdev, 0);
  9798. + if (irq < 0)
  9799. + return irq;
  9800. +
  9801. + board = pdev->dev.platform_data;
  9802. +
  9803. + mmc = mmc_alloc_host(sizeof(struct atmel_mci), &pdev->dev);
  9804. + if (!mmc)
  9805. + return -ENOMEM;
  9806. +
  9807. + host = mmc_priv(mmc);
  9808. + host->pdev = pdev;
  9809. + host->mmc = mmc;
  9810. + if (board) {
  9811. + host->detect_pin = board->detect_pin;
  9812. + host->wp_pin = board->wp_pin;
  9813. + } else {
  9814. + host->detect_pin = -1;
  9815. + host->wp_pin = -1;
  9816. + }
  9817. +
  9818. + host->mck = clk_get(&pdev->dev, "mci_clk");
  9819. + if (IS_ERR(host->mck)) {
  9820. + ret = PTR_ERR(host->mck);
  9821. + goto out_free_host;
  9822. + }
  9823. + clk_enable(host->mck);
  9824. +
  9825. + ret = -ENOMEM;
  9826. + host->regs = ioremap(regs->start, regs->end - regs->start + 1);
  9827. + if (!host->regs)
  9828. + goto out_disable_clk;
  9829. +
  9830. + host->bus_hz = clk_get_rate(host->mck);
  9831. + host->mapbase = regs->start;
  9832. +
  9833. + mmc->ops = &atmci_ops;
  9834. + mmc->f_min = (host->bus_hz + 511) / 512;
  9835. + mmc->f_max = min((unsigned int)(host->bus_hz / 2), fmax);
  9836. + mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
  9837. + mmc->caps |= MMC_CAP_4_BIT_DATA;
  9838. +
  9839. + tasklet_init(&host->tasklet, atmci_tasklet_func, (unsigned long)mmc);
  9840. +
  9841. + ret = request_irq(irq, atmci_interrupt, 0, "mmci", mmc);
  9842. + if (ret)
  9843. + goto out_unmap;
  9844. +
  9845. + /* Assume card is present if we don't have a detect pin */
  9846. + host->present = 1;
  9847. + if (host->detect_pin >= 0) {
  9848. + if (gpio_request(host->detect_pin, "mmc_detect")) {
  9849. + dev_dbg(&mmc->class_dev, "no detect pin available\n");
  9850. + host->detect_pin = -1;
  9851. + } else {
  9852. + host->present = !gpio_get_value(host->detect_pin);
  9853. + }
  9854. + }
  9855. + if (host->wp_pin >= 0) {
  9856. + if (gpio_request(host->wp_pin, "mmc_wp")) {
  9857. + dev_dbg(&mmc->class_dev, "no WP pin available\n");
  9858. + host->wp_pin = -1;
  9859. + }
  9860. + }
  9861. +
  9862. + /* TODO: Get this information from platform data */
  9863. + ret = -ENOMEM;
  9864. + host->dma.req.req.dmac = find_dma_controller(0);
  9865. + if (!host->dma.req.req.dmac) {
  9866. + dev_dbg(&mmc->class_dev, "no DMA controller available\n");
  9867. + goto out_free_irq;
  9868. + }
  9869. + ret = dma_alloc_channel(host->dma.req.req.dmac);
  9870. + if (ret < 0) {
  9871. + dev_dbg(&mmc->class_dev, "unable to allocate DMA channel\n");
  9872. + goto out_free_irq;
  9873. + }
  9874. + host->dma.req.req.channel = ret;
  9875. + host->dma.req.width = DMA_WIDTH_32BIT;
  9876. + host->dma.req.req.xfer_complete = atmci_xfer_complete;
  9877. + host->dma.req.req.block_complete = NULL; // atmci_block_complete;
  9878. + host->dma.req.req.error = atmci_dma_error;
  9879. + host->dma.rx_periph_id = 0;
  9880. + host->dma.tx_periph_id = 1;
  9881. +
  9882. + mci_writel(host, CR, MCI_BIT(SWRST));
  9883. + mci_writel(host, IDR, ~0UL);
  9884. +
  9885. + platform_set_drvdata(pdev, host);
  9886. +
  9887. + mmc_add_host(mmc);
  9888. +
  9889. + if (host->detect_pin >= 0) {
  9890. + setup_timer(&host->detect_timer, atmci_detect_change,
  9891. + (unsigned long)host);
  9892. +
  9893. + ret = request_irq(gpio_to_irq(host->detect_pin),
  9894. + atmci_detect_interrupt,
  9895. + IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
  9896. + DRIVER_NAME, mmc);
  9897. + if (ret) {
  9898. + dev_dbg(&mmc->class_dev,
  9899. + "could not request IRQ %d for detect pin\n",
  9900. + gpio_to_irq(host->detect_pin));
  9901. + gpio_free(host->detect_pin);
  9902. + host->detect_pin = -1;
  9903. + }
  9904. + }
  9905. +
  9906. + dev_info(&mmc->class_dev, "Atmel MCI controller at 0x%08lx irq %d\n",
  9907. + host->mapbase, irq);
  9908. +
  9909. + atmci_init_debugfs(host);
  9910. +
  9911. + return 0;
  9912. +
  9913. +out_free_irq:
  9914. + if (host->detect_pin >= 0)
  9915. + gpio_free(host->detect_pin);
  9916. + if (host->wp_pin >= 0)
  9917. + gpio_free(host->wp_pin);
  9918. + free_irq(irq, mmc);
  9919. +out_unmap:
  9920. + iounmap(host->regs);
  9921. +out_disable_clk:
  9922. + clk_disable(host->mck);
  9923. + clk_put(host->mck);
  9924. +out_free_host:
  9925. + mmc_free_host(mmc);
  9926. + return ret;
  9927. +}
  9928. +
  9929. +static int __devexit atmci_remove(struct platform_device *pdev)
  9930. +{
  9931. + struct atmel_mci *host = platform_get_drvdata(pdev);
  9932. +
  9933. + platform_set_drvdata(pdev, NULL);
  9934. +
  9935. + if (host) {
  9936. + atmci_cleanup_debugfs(host);
  9937. +
  9938. + if (host->detect_pin >= 0) {
  9939. + int pin = host->detect_pin;
  9940. +
  9941. + /* Make sure our timer doesn't enable the interrupt */
  9942. + host->detect_pin = -1;
  9943. + smp_wmb();
  9944. +
  9945. + free_irq(gpio_to_irq(pin), host->mmc);
  9946. + del_timer_sync(&host->detect_timer);
  9947. + cancel_delayed_work(&host->mmc->detect);
  9948. + gpio_free(pin);
  9949. + }
  9950. +
  9951. + mmc_remove_host(host->mmc);
  9952. +
  9953. + mci_writel(host, IDR, ~0UL);
  9954. + mci_writel(host, CR, MCI_BIT(MCIDIS));
  9955. + mci_readl(host, SR);
  9956. +
  9957. + dma_release_channel(host->dma.req.req.dmac,
  9958. + host->dma.req.req.channel);
  9959. +
  9960. + if (host->wp_pin >= 0)
  9961. + gpio_free(host->wp_pin);
  9962. +
  9963. + free_irq(platform_get_irq(pdev, 0), host->mmc);
  9964. + iounmap(host->regs);
  9965. +
  9966. + clk_disable(host->mck);
  9967. + clk_put(host->mck);
  9968. +
  9969. + mmc_free_host(host->mmc);
  9970. + }
  9971. + return 0;
  9972. +}
  9973. +
  9974. +static struct platform_driver atmci_driver = {
  9975. + .probe = atmci_probe,
  9976. + .remove = __devexit_p(atmci_remove),
  9977. + .driver = {
  9978. + .name = DRIVER_NAME,
  9979. + },
  9980. +};
  9981. +
  9982. +static int __init atmci_init(void)
  9983. +{
  9984. + return platform_driver_register(&atmci_driver);
  9985. +}
  9986. +
  9987. +static void __exit atmci_exit(void)
  9988. +{
  9989. + platform_driver_unregister(&atmci_driver);
  9990. +}
  9991. +
  9992. +module_init(atmci_init);
  9993. +module_exit(atmci_exit);
  9994. +
  9995. +MODULE_DESCRIPTION("Atmel Multimedia Card Interface driver");
  9996. +MODULE_LICENSE("GPL");
  9997. --- /dev/null
  9998. +++ b/drivers/mmc/host/atmel-mci.h
  9999. @@ -0,0 +1,192 @@
  10000. +/*
  10001. + * Atmel MultiMedia Card Interface driver
  10002. + *
  10003. + * Copyright (C) 2004-2006 Atmel Corporation
  10004. + *
  10005. + * This program is free software; you can redistribute it and/or modify
  10006. + * it under the terms of the GNU General Public License version 2 as
  10007. + * published by the Free Software Foundation.
  10008. + */
  10009. +#ifndef __DRIVERS_MMC_ATMEL_MCI_H__
  10010. +#define __DRIVERS_MMC_ATMEL_MCI_H__
  10011. +
  10012. +/* MCI register offsets */
  10013. +#define MCI_CR 0x0000
  10014. +#define MCI_MR 0x0004
  10015. +#define MCI_DTOR 0x0008
  10016. +#define MCI_SDCR 0x000c
  10017. +#define MCI_ARGR 0x0010
  10018. +#define MCI_CMDR 0x0014
  10019. +#define MCI_BLKR 0x0018
  10020. +#define MCI_RSPR 0x0020
  10021. +#define MCI_RSPR1 0x0024
  10022. +#define MCI_RSPR2 0x0028
  10023. +#define MCI_RSPR3 0x002c
  10024. +#define MCI_RDR 0x0030
  10025. +#define MCI_TDR 0x0034
  10026. +#define MCI_SR 0x0040
  10027. +#define MCI_IER 0x0044
  10028. +#define MCI_IDR 0x0048
  10029. +#define MCI_IMR 0x004c
  10030. +
  10031. +/* Bitfields in CR */
  10032. +#define MCI_MCIEN_OFFSET 0
  10033. +#define MCI_MCIEN_SIZE 1
  10034. +#define MCI_MCIDIS_OFFSET 1
  10035. +#define MCI_MCIDIS_SIZE 1
  10036. +#define MCI_PWSEN_OFFSET 2
  10037. +#define MCI_PWSEN_SIZE 1
  10038. +#define MCI_PWSDIS_OFFSET 3
  10039. +#define MCI_PWSDIS_SIZE 1
  10040. +#define MCI_SWRST_OFFSET 7
  10041. +#define MCI_SWRST_SIZE 1
  10042. +
  10043. +/* Bitfields in MR */
  10044. +#define MCI_CLKDIV_OFFSET 0
  10045. +#define MCI_CLKDIV_SIZE 8
  10046. +#define MCI_PWSDIV_OFFSET 8
  10047. +#define MCI_PWSDIV_SIZE 3
  10048. +#define MCI_RDPROOF_OFFSET 11
  10049. +#define MCI_RDPROOF_SIZE 1
  10050. +#define MCI_WRPROOF_OFFSET 12
  10051. +#define MCI_WRPROOF_SIZE 1
  10052. +#define MCI_DMAPADV_OFFSET 14
  10053. +#define MCI_DMAPADV_SIZE 1
  10054. +#define MCI_BLKLEN_OFFSET 16
  10055. +#define MCI_BLKLEN_SIZE 16
  10056. +
  10057. +/* Bitfields in DTOR */
  10058. +#define MCI_DTOCYC_OFFSET 0
  10059. +#define MCI_DTOCYC_SIZE 4
  10060. +#define MCI_DTOMUL_OFFSET 4
  10061. +#define MCI_DTOMUL_SIZE 3
  10062. +
  10063. +/* Bitfields in SDCR */
  10064. +#define MCI_SDCSEL_OFFSET 0
  10065. +#define MCI_SDCSEL_SIZE 4
  10066. +#define MCI_SDCBUS_OFFSET 7
  10067. +#define MCI_SDCBUS_SIZE 1
  10068. +
  10069. +/* Bitfields in ARGR */
  10070. +#define MCI_ARG_OFFSET 0
  10071. +#define MCI_ARG_SIZE 32
  10072. +
  10073. +/* Bitfields in CMDR */
  10074. +#define MCI_CMDNB_OFFSET 0
  10075. +#define MCI_CMDNB_SIZE 6
  10076. +#define MCI_RSPTYP_OFFSET 6
  10077. +#define MCI_RSPTYP_SIZE 2
  10078. +#define MCI_SPCMD_OFFSET 8
  10079. +#define MCI_SPCMD_SIZE 3
  10080. +#define MCI_OPDCMD_OFFSET 11
  10081. +#define MCI_OPDCMD_SIZE 1
  10082. +#define MCI_MAXLAT_OFFSET 12
  10083. +#define MCI_MAXLAT_SIZE 1
  10084. +#define MCI_TRCMD_OFFSET 16
  10085. +#define MCI_TRCMD_SIZE 2
  10086. +#define MCI_TRDIR_OFFSET 18
  10087. +#define MCI_TRDIR_SIZE 1
  10088. +#define MCI_TRTYP_OFFSET 19
  10089. +#define MCI_TRTYP_SIZE 2
  10090. +
  10091. +/* Bitfields in BLKR */
  10092. +#define MCI_BCNT_OFFSET 0
  10093. +#define MCI_BCNT_SIZE 16
  10094. +
  10095. +/* Bitfields in RSPRn */
  10096. +#define MCI_RSP_OFFSET 0
  10097. +#define MCI_RSP_SIZE 32
  10098. +
  10099. +/* Bitfields in SR/IER/IDR/IMR */
  10100. +#define MCI_CMDRDY_OFFSET 0
  10101. +#define MCI_CMDRDY_SIZE 1
  10102. +#define MCI_RXRDY_OFFSET 1
  10103. +#define MCI_RXRDY_SIZE 1
  10104. +#define MCI_TXRDY_OFFSET 2
  10105. +#define MCI_TXRDY_SIZE 1
  10106. +#define MCI_BLKE_OFFSET 3
  10107. +#define MCI_BLKE_SIZE 1
  10108. +#define MCI_DTIP_OFFSET 4
  10109. +#define MCI_DTIP_SIZE 1
  10110. +#define MCI_NOTBUSY_OFFSET 5
  10111. +#define MCI_NOTBUSY_SIZE 1
  10112. +#define MCI_ENDRX_OFFSET 6
  10113. +#define MCI_ENDRX_SIZE 1
  10114. +#define MCI_ENDTX_OFFSET 7
  10115. +#define MCI_ENDTX_SIZE 1
  10116. +#define MCI_RXBUFF_OFFSET 14
  10117. +#define MCI_RXBUFF_SIZE 1
  10118. +#define MCI_TXBUFE_OFFSET 15
  10119. +#define MCI_TXBUFE_SIZE 1
  10120. +#define MCI_RINDE_OFFSET 16
  10121. +#define MCI_RINDE_SIZE 1
  10122. +#define MCI_RDIRE_OFFSET 17
  10123. +#define MCI_RDIRE_SIZE 1
  10124. +#define MCI_RCRCE_OFFSET 18
  10125. +#define MCI_RCRCE_SIZE 1
  10126. +#define MCI_RENDE_OFFSET 19
  10127. +#define MCI_RENDE_SIZE 1
  10128. +#define MCI_RTOE_OFFSET 20
  10129. +#define MCI_RTOE_SIZE 1
  10130. +#define MCI_DCRCE_OFFSET 21
  10131. +#define MCI_DCRCE_SIZE 1
  10132. +#define MCI_DTOE_OFFSET 22
  10133. +#define MCI_DTOE_SIZE 1
  10134. +#define MCI_OVRE_OFFSET 30
  10135. +#define MCI_OVRE_SIZE 1
  10136. +#define MCI_UNRE_OFFSET 31
  10137. +#define MCI_UNRE_SIZE 1
  10138. +
  10139. +/* Constants for DTOMUL */
  10140. +#define MCI_DTOMUL_1_CYCLE 0
  10141. +#define MCI_DTOMUL_16_CYCLES 1
  10142. +#define MCI_DTOMUL_128_CYCLES 2
  10143. +#define MCI_DTOMUL_256_CYCLES 3
  10144. +#define MCI_DTOMUL_1024_CYCLES 4
  10145. +#define MCI_DTOMUL_4096_CYCLES 5
  10146. +#define MCI_DTOMUL_65536_CYCLES 6
  10147. +#define MCI_DTOMUL_1048576_CYCLES 7
  10148. +
  10149. +/* Constants for RSPTYP */
  10150. +#define MCI_RSPTYP_NO_RESP 0
  10151. +#define MCI_RSPTYP_48_BIT 1
  10152. +#define MCI_RSPTYP_136_BIT 2
  10153. +
  10154. +/* Constants for SPCMD */
  10155. +#define MCI_SPCMD_NO_SPEC_CMD 0
  10156. +#define MCI_SPCMD_INIT_CMD 1
  10157. +#define MCI_SPCMD_SYNC_CMD 2
  10158. +#define MCI_SPCMD_INT_CMD 4
  10159. +#define MCI_SPCMD_INT_RESP 5
  10160. +
  10161. +/* Constants for TRCMD */
  10162. +#define MCI_TRCMD_NO_TRANS 0
  10163. +#define MCI_TRCMD_START_TRANS 1
  10164. +#define MCI_TRCMD_STOP_TRANS 2
  10165. +
  10166. +/* Constants for TRTYP */
  10167. +#define MCI_TRTYP_BLOCK 0
  10168. +#define MCI_TRTYP_MULTI_BLOCK 1
  10169. +#define MCI_TRTYP_STREAM 2
  10170. +
  10171. +/* Bit manipulation macros */
  10172. +#define MCI_BIT(name) \
  10173. + (1 << MCI_##name##_OFFSET)
  10174. +#define MCI_BF(name,value) \
  10175. + (((value) & ((1 << MCI_##name##_SIZE) - 1)) \
  10176. + << MCI_##name##_OFFSET)
  10177. +#define MCI_BFEXT(name,value) \
  10178. + (((value) >> MCI_##name##_OFFSET) \
  10179. + & ((1 << MCI_##name##_SIZE) - 1))
  10180. +#define MCI_BFINS(name,value,old) \
  10181. + (((old) & ~(((1 << MCI_##name##_SIZE) - 1) \
  10182. + << MCI_##name##_OFFSET)) \
  10183. + | MCI_BF(name,value))
  10184. +
  10185. +/* Register access macros */
  10186. +#define mci_readl(port,reg) \
  10187. + __raw_readl((port)->regs + MCI_##reg)
  10188. +#define mci_writel(port,reg,value) \
  10189. + __raw_writel((value), (port)->regs + MCI_##reg)
  10190. +
  10191. +#endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */
  10192. --- a/drivers/mmc/host/Kconfig
  10193. +++ b/drivers/mmc/host/Kconfig
  10194. @@ -91,6 +91,16 @@
  10195. If unsure, say N.
  10196. +config MMC_ATMELMCI
  10197. + tristate "Atmel Multimedia Card Interface support"
  10198. + depends on AVR32 && MMC
  10199. + help
  10200. + This selects the Atmel Multimedia Card Interface. If you have
  10201. + a AT91 (ARM) or AT32 (AVR32) platform with a Multimedia Card
  10202. + slot, say Y or M here.
  10203. +
  10204. + If unsure, say N.
  10205. +
  10206. config MMC_IMX
  10207. tristate "Motorola i.MX Multimedia Card Interface support"
  10208. depends on ARCH_IMX
  10209. --- a/drivers/mmc/host/Makefile
  10210. +++ b/drivers/mmc/host/Makefile
  10211. @@ -15,6 +15,7 @@
  10212. obj-$(CONFIG_MMC_AU1X) += au1xmmc.o
  10213. obj-$(CONFIG_MMC_OMAP) += omap.o
  10214. obj-$(CONFIG_MMC_AT91) += at91_mci.o
  10215. +obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o
  10216. obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o
  10217. obj-$(CONFIG_MMC_SPI) += mmc_spi.o
  10218. --- a/drivers/mtd/nand/at91_nand.c
  10219. +++ /dev/null
  10220. @@ -1,236 +0,0 @@
  10221. -/*
  10222. - * drivers/mtd/nand/at91_nand.c
  10223. - *
  10224. - * Copyright (C) 2003 Rick Bronson
  10225. - *
  10226. - * Derived from drivers/mtd/nand/autcpu12.c
  10227. - * Copyright (c) 2001 Thomas Gleixner ([email protected])
  10228. - *
  10229. - * Derived from drivers/mtd/spia.c
  10230. - * Copyright (C) 2000 Steven J. Hill ([email protected])
  10231. - *
  10232. - * This program is free software; you can redistribute it and/or modify
  10233. - * it under the terms of the GNU General Public License version 2 as
  10234. - * published by the Free Software Foundation.
  10235. - *
  10236. - */
  10237. -
  10238. -#include <linux/slab.h>
  10239. -#include <linux/module.h>
  10240. -#include <linux/platform_device.h>
  10241. -#include <linux/mtd/mtd.h>
  10242. -#include <linux/mtd/nand.h>
  10243. -#include <linux/mtd/partitions.h>
  10244. -
  10245. -#include <asm/io.h>
  10246. -#include <asm/sizes.h>
  10247. -
  10248. -#include <asm/hardware.h>
  10249. -#include <asm/arch/board.h>
  10250. -#include <asm/arch/gpio.h>
  10251. -
  10252. -struct at91_nand_host {
  10253. - struct nand_chip nand_chip;
  10254. - struct mtd_info mtd;
  10255. - void __iomem *io_base;
  10256. - struct at91_nand_data *board;
  10257. -};
  10258. -
  10259. -/*
  10260. - * Hardware specific access to control-lines
  10261. - */
  10262. -static void at91_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  10263. -{
  10264. - struct nand_chip *nand_chip = mtd->priv;
  10265. - struct at91_nand_host *host = nand_chip->priv;
  10266. -
  10267. - if (cmd == NAND_CMD_NONE)
  10268. - return;
  10269. -
  10270. - if (ctrl & NAND_CLE)
  10271. - writeb(cmd, host->io_base + (1 << host->board->cle));
  10272. - else
  10273. - writeb(cmd, host->io_base + (1 << host->board->ale));
  10274. -}
  10275. -
  10276. -/*
  10277. - * Read the Device Ready pin.
  10278. - */
  10279. -static int at91_nand_device_ready(struct mtd_info *mtd)
  10280. -{
  10281. - struct nand_chip *nand_chip = mtd->priv;
  10282. - struct at91_nand_host *host = nand_chip->priv;
  10283. -
  10284. - return at91_get_gpio_value(host->board->rdy_pin);
  10285. -}
  10286. -
  10287. -/*
  10288. - * Enable NAND.
  10289. - */
  10290. -static void at91_nand_enable(struct at91_nand_host *host)
  10291. -{
  10292. - if (host->board->enable_pin)
  10293. - at91_set_gpio_value(host->board->enable_pin, 0);
  10294. -}
  10295. -
  10296. -/*
  10297. - * Disable NAND.
  10298. - */
  10299. -static void at91_nand_disable(struct at91_nand_host *host)
  10300. -{
  10301. - if (host->board->enable_pin)
  10302. - at91_set_gpio_value(host->board->enable_pin, 1);
  10303. -}
  10304. -
  10305. -#ifdef CONFIG_MTD_PARTITIONS
  10306. -const char *part_probes[] = { "cmdlinepart", NULL };
  10307. -#endif
  10308. -
  10309. -/*
  10310. - * Probe for the NAND device.
  10311. - */
  10312. -static int __init at91_nand_probe(struct platform_device *pdev)
  10313. -{
  10314. - struct at91_nand_host *host;
  10315. - struct mtd_info *mtd;
  10316. - struct nand_chip *nand_chip;
  10317. - int res;
  10318. -
  10319. -#ifdef CONFIG_MTD_PARTITIONS
  10320. - struct mtd_partition *partitions = NULL;
  10321. - int num_partitions = 0;
  10322. -#endif
  10323. -
  10324. - /* Allocate memory for the device structure (and zero it) */
  10325. - host = kzalloc(sizeof(struct at91_nand_host), GFP_KERNEL);
  10326. - if (!host) {
  10327. - printk(KERN_ERR "at91_nand: failed to allocate device structure.\n");
  10328. - return -ENOMEM;
  10329. - }
  10330. -
  10331. - host->io_base = ioremap(pdev->resource[0].start,
  10332. - pdev->resource[0].end - pdev->resource[0].start + 1);
  10333. - if (host->io_base == NULL) {
  10334. - printk(KERN_ERR "at91_nand: ioremap failed\n");
  10335. - kfree(host);
  10336. - return -EIO;
  10337. - }
  10338. -
  10339. - mtd = &host->mtd;
  10340. - nand_chip = &host->nand_chip;
  10341. - host->board = pdev->dev.platform_data;
  10342. -
  10343. - nand_chip->priv = host; /* link the private data structures */
  10344. - mtd->priv = nand_chip;
  10345. - mtd->owner = THIS_MODULE;
  10346. -
  10347. - /* Set address of NAND IO lines */
  10348. - nand_chip->IO_ADDR_R = host->io_base;
  10349. - nand_chip->IO_ADDR_W = host->io_base;
  10350. - nand_chip->cmd_ctrl = at91_nand_cmd_ctrl;
  10351. -
  10352. - if (host->board->rdy_pin)
  10353. - nand_chip->dev_ready = at91_nand_device_ready;
  10354. -
  10355. - nand_chip->ecc.mode = NAND_ECC_SOFT; /* enable ECC */
  10356. - nand_chip->chip_delay = 20; /* 20us command delay time */
  10357. -
  10358. - if (host->board->bus_width_16) /* 16-bit bus width */
  10359. - nand_chip->options |= NAND_BUSWIDTH_16;
  10360. -
  10361. - platform_set_drvdata(pdev, host);
  10362. - at91_nand_enable(host);
  10363. -
  10364. - if (host->board->det_pin) {
  10365. - if (at91_get_gpio_value(host->board->det_pin)) {
  10366. - printk ("No SmartMedia card inserted.\n");
  10367. - res = ENXIO;
  10368. - goto out;
  10369. - }
  10370. - }
  10371. -
  10372. - /* Scan to find existance of the device */
  10373. - if (nand_scan(mtd, 1)) {
  10374. - res = -ENXIO;
  10375. - goto out;
  10376. - }
  10377. -
  10378. -#ifdef CONFIG_MTD_PARTITIONS
  10379. -#ifdef CONFIG_MTD_CMDLINE_PARTS
  10380. - mtd->name = "at91_nand";
  10381. - num_partitions = parse_mtd_partitions(mtd, part_probes,
  10382. - &partitions, 0);
  10383. -#endif
  10384. - if (num_partitions <= 0 && host->board->partition_info)
  10385. - partitions = host->board->partition_info(mtd->size,
  10386. - &num_partitions);
  10387. -
  10388. - if ((!partitions) || (num_partitions == 0)) {
  10389. - printk(KERN_ERR "at91_nand: No parititions defined, or unsupported device.\n");
  10390. - res = ENXIO;
  10391. - goto release;
  10392. - }
  10393. -
  10394. - res = add_mtd_partitions(mtd, partitions, num_partitions);
  10395. -#else
  10396. - res = add_mtd_device(mtd);
  10397. -#endif
  10398. -
  10399. - if (!res)
  10400. - return res;
  10401. -
  10402. -release:
  10403. - nand_release(mtd);
  10404. -out:
  10405. - at91_nand_disable(host);
  10406. - platform_set_drvdata(pdev, NULL);
  10407. - iounmap(host->io_base);
  10408. - kfree(host);
  10409. - return res;
  10410. -}
  10411. -
  10412. -/*
  10413. - * Remove a NAND device.
  10414. - */
  10415. -static int __devexit at91_nand_remove(struct platform_device *pdev)
  10416. -{
  10417. - struct at91_nand_host *host = platform_get_drvdata(pdev);
  10418. - struct mtd_info *mtd = &host->mtd;
  10419. -
  10420. - nand_release(mtd);
  10421. -
  10422. - at91_nand_disable(host);
  10423. -
  10424. - iounmap(host->io_base);
  10425. - kfree(host);
  10426. -
  10427. - return 0;
  10428. -}
  10429. -
  10430. -static struct platform_driver at91_nand_driver = {
  10431. - .probe = at91_nand_probe,
  10432. - .remove = at91_nand_remove,
  10433. - .driver = {
  10434. - .name = "at91_nand",
  10435. - .owner = THIS_MODULE,
  10436. - },
  10437. -};
  10438. -
  10439. -static int __init at91_nand_init(void)
  10440. -{
  10441. - return platform_driver_register(&at91_nand_driver);
  10442. -}
  10443. -
  10444. -
  10445. -static void __exit at91_nand_exit(void)
  10446. -{
  10447. - platform_driver_unregister(&at91_nand_driver);
  10448. -}
  10449. -
  10450. -
  10451. -module_init(at91_nand_init);
  10452. -module_exit(at91_nand_exit);
  10453. -
  10454. -MODULE_LICENSE("GPL");
  10455. -MODULE_AUTHOR("Rick Bronson");
  10456. -MODULE_DESCRIPTION("NAND/SmartMedia driver for AT91RM9200");
  10457. --- /dev/null
  10458. +++ b/drivers/mtd/nand/atmel_nand.c
  10459. @@ -0,0 +1,650 @@
  10460. +/*
  10461. + * Copyright (C) 2003 Rick Bronson
  10462. + *
  10463. + * Derived from drivers/mtd/nand/autcpu12.c
  10464. + * Copyright (c) 2001 Thomas Gleixner ([email protected])
  10465. + *
  10466. + * Derived from drivers/mtd/spia.c
  10467. + * Copyright (C) 2000 Steven J. Hill ([email protected])
  10468. + *
  10469. + *
  10470. + * Add Hardware ECC support for AT91SAM9260 / AT91SAM9263
  10471. + * Richard Genoud ([email protected]), Adeneo Copyright (C) 2007
  10472. + *
  10473. + * Derived from Das U-Boot source code
  10474. + * (u-boot-1.1.5/board/atmel/at91sam9263ek/nand.c)
  10475. + * (C) Copyright 2006 ATMEL Rousset, Lacressonniere Nicolas
  10476. + *
  10477. + *
  10478. + * This program is free software; you can redistribute it and/or modify
  10479. + * it under the terms of the GNU General Public License version 2 as
  10480. + * published by the Free Software Foundation.
  10481. + *
  10482. + */
  10483. +
  10484. +#include <linux/slab.h>
  10485. +#include <linux/module.h>
  10486. +#include <linux/platform_device.h>
  10487. +#include <linux/mtd/mtd.h>
  10488. +#include <linux/mtd/nand.h>
  10489. +#include <linux/mtd/partitions.h>
  10490. +
  10491. +#include <linux/gpio.h>
  10492. +#include <linux/io.h>
  10493. +
  10494. +#include <asm/arch/board.h>
  10495. +#include <asm/arch/cpu.h>
  10496. +
  10497. +#ifdef CONFIG_MTD_NAND_ATMEL_ECC_HW
  10498. +#define hard_ecc 1
  10499. +#else
  10500. +#define hard_ecc 0
  10501. +#endif
  10502. +
  10503. +#ifdef CONFIG_MTD_NAND_ATMEL_ECC_NONE
  10504. +#define no_ecc 1
  10505. +#else
  10506. +#define no_ecc 0
  10507. +#endif
  10508. +
  10509. +/* Register access macros */
  10510. +#define ecc_readl(add, reg) \
  10511. + __raw_readl(add + ATMEL_ECC_##reg)
  10512. +#define ecc_writel(add, reg, value) \
  10513. + __raw_writel((value), add + ATMEL_ECC_##reg)
  10514. +
  10515. +#include "atmel_nand_ecc.h" /* Hardware ECC registers */
  10516. +
  10517. +/* oob layout for large page size
  10518. + * bad block info is on bytes 0 and 1
  10519. + * the bytes have to be consecutives to avoid
  10520. + * several NAND_CMD_RNDOUT during read
  10521. + */
  10522. +static struct nand_ecclayout atmel_oobinfo_large = {
  10523. + .eccbytes = 4,
  10524. + .eccpos = {60, 61, 62, 63},
  10525. + .oobfree = {
  10526. + {2, 58}
  10527. + },
  10528. +};
  10529. +
  10530. +/* oob layout for small page size
  10531. + * bad block info is on bytes 4 and 5
  10532. + * the bytes have to be consecutives to avoid
  10533. + * several NAND_CMD_RNDOUT during read
  10534. + */
  10535. +static struct nand_ecclayout atmel_oobinfo_small = {
  10536. + .eccbytes = 4,
  10537. + .eccpos = {0, 1, 2, 3},
  10538. + .oobfree = {
  10539. + {6, 10}
  10540. + },
  10541. +};
  10542. +
  10543. +struct atmel_nand_host {
  10544. + struct nand_chip nand_chip;
  10545. + struct mtd_info mtd;
  10546. + void __iomem *io_base;
  10547. + struct atmel_nand_data *board;
  10548. + struct device *dev;
  10549. + void __iomem *ecc;
  10550. +};
  10551. +
  10552. +/*
  10553. + * Enable NAND.
  10554. + */
  10555. +static void atmel_nand_enable(struct atmel_nand_host *host)
  10556. +{
  10557. + if (host->board->enable_pin)
  10558. + gpio_set_value(host->board->enable_pin, 0);
  10559. +}
  10560. +
  10561. +/*
  10562. + * Disable NAND.
  10563. + */
  10564. +static void atmel_nand_disable(struct atmel_nand_host *host)
  10565. +{
  10566. + if (host->board->enable_pin)
  10567. + gpio_set_value(host->board->enable_pin, 1);
  10568. +}
  10569. +
  10570. +/*
  10571. + * Hardware specific access to control-lines
  10572. + */
  10573. +static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  10574. +{
  10575. + struct nand_chip *nand_chip = mtd->priv;
  10576. + struct atmel_nand_host *host = nand_chip->priv;
  10577. +
  10578. + if (ctrl & NAND_CTRL_CHANGE) {
  10579. + if (ctrl & NAND_NCE)
  10580. + atmel_nand_enable(host);
  10581. + else
  10582. + atmel_nand_disable(host);
  10583. + }
  10584. + if (cmd == NAND_CMD_NONE)
  10585. + return;
  10586. +
  10587. + if (ctrl & NAND_CLE)
  10588. + writeb(cmd, host->io_base + (1 << host->board->cle));
  10589. + else
  10590. + writeb(cmd, host->io_base + (1 << host->board->ale));
  10591. +}
  10592. +
  10593. +/*
  10594. + * Read the Device Ready pin.
  10595. + */
  10596. +static int atmel_nand_device_ready(struct mtd_info *mtd)
  10597. +{
  10598. + struct nand_chip *nand_chip = mtd->priv;
  10599. + struct atmel_nand_host *host = nand_chip->priv;
  10600. +
  10601. + return gpio_get_value(host->board->rdy_pin);
  10602. +}
  10603. +
  10604. +/*
  10605. + * Minimal-overhead PIO for data access.
  10606. + */
  10607. +static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
  10608. +{
  10609. + struct nand_chip *nand_chip = mtd->priv;
  10610. +
  10611. + __raw_readsb(nand_chip->IO_ADDR_R, buf, len);
  10612. +}
  10613. +
  10614. +static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
  10615. +{
  10616. + struct nand_chip *nand_chip = mtd->priv;
  10617. +
  10618. + __raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2);
  10619. +}
  10620. +
  10621. +static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
  10622. +{
  10623. + struct nand_chip *nand_chip = mtd->priv;
  10624. +
  10625. + __raw_writesb(nand_chip->IO_ADDR_W, buf, len);
  10626. +}
  10627. +
  10628. +static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len)
  10629. +{
  10630. + struct nand_chip *nand_chip = mtd->priv;
  10631. +
  10632. + __raw_writesw(nand_chip->IO_ADDR_W, buf, len / 2);
  10633. +}
  10634. +
  10635. +/*
  10636. + * write oob for small pages
  10637. + */
  10638. +static int atmel_nand_write_oob_512(struct mtd_info *mtd,
  10639. + struct nand_chip *chip, int page)
  10640. +{
  10641. + int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
  10642. + int eccsize = chip->ecc.size, length = mtd->oobsize;
  10643. + int len, pos, status = 0;
  10644. + const uint8_t *bufpoi = chip->oob_poi;
  10645. +
  10646. + pos = eccsize + chunk;
  10647. +
  10648. + chip->cmdfunc(mtd, NAND_CMD_SEQIN, pos, page);
  10649. + len = min_t(int, length, chunk);
  10650. + chip->write_buf(mtd, bufpoi, len);
  10651. + bufpoi += len;
  10652. + length -= len;
  10653. + if (length > 0)
  10654. + chip->write_buf(mtd, bufpoi, length);
  10655. +
  10656. + chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
  10657. + status = chip->waitfunc(mtd, chip);
  10658. +
  10659. + return status & NAND_STATUS_FAIL ? -EIO : 0;
  10660. +
  10661. +}
  10662. +
  10663. +/*
  10664. + * read oob for small pages
  10665. + */
  10666. +static int atmel_nand_read_oob_512(struct mtd_info *mtd,
  10667. + struct nand_chip *chip, int page, int sndcmd)
  10668. +{
  10669. + if (sndcmd) {
  10670. + chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
  10671. + sndcmd = 0;
  10672. + }
  10673. + chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
  10674. + return sndcmd;
  10675. +}
  10676. +
  10677. +/*
  10678. + * Calculate HW ECC
  10679. + *
  10680. + * function called after a write
  10681. + *
  10682. + * mtd: MTD block structure
  10683. + * dat: raw data (unused)
  10684. + * ecc_code: buffer for ECC
  10685. + */
  10686. +static int atmel_nand_calculate(struct mtd_info *mtd,
  10687. + const u_char *dat, unsigned char *ecc_code)
  10688. +{
  10689. + struct nand_chip *nand_chip = mtd->priv;
  10690. + struct atmel_nand_host *host = nand_chip->priv;
  10691. + uint32_t *eccpos = nand_chip->ecc.layout->eccpos;
  10692. + unsigned int ecc_value;
  10693. +
  10694. + /* get the first 2 ECC bytes */
  10695. + ecc_value = ecc_readl(host->ecc, PR);
  10696. +
  10697. + ecc_code[eccpos[0]] = ecc_value & 0xFF;
  10698. + ecc_code[eccpos[1]] = (ecc_value >> 8) & 0xFF;
  10699. +
  10700. + /* get the last 2 ECC bytes */
  10701. + ecc_value = ecc_readl(host->ecc, NPR) & ATMEL_ECC_NPARITY;
  10702. +
  10703. + ecc_code[eccpos[2]] = ecc_value & 0xFF;
  10704. + ecc_code[eccpos[3]] = (ecc_value >> 8) & 0xFF;
  10705. +
  10706. + return 0;
  10707. +}
  10708. +
  10709. +/*
  10710. + * HW ECC read page function
  10711. + *
  10712. + * mtd: mtd info structure
  10713. + * chip: nand chip info structure
  10714. + * buf: buffer to store read data
  10715. + */
  10716. +static int atmel_nand_read_page(struct mtd_info *mtd,
  10717. + struct nand_chip *chip, uint8_t *buf)
  10718. +{
  10719. + int eccsize = chip->ecc.size;
  10720. + int eccbytes = chip->ecc.bytes;
  10721. + uint32_t *eccpos = chip->ecc.layout->eccpos;
  10722. + uint8_t *p = buf;
  10723. + uint8_t *oob = chip->oob_poi;
  10724. + uint8_t *ecc_pos;
  10725. + int stat;
  10726. +
  10727. + /*
  10728. + * Errata: ALE is incorrectly wired up to the ECC controller
  10729. + * on the AP7000, so it will include the address cycles in the
  10730. + * ECC calculation.
  10731. + *
  10732. + * Workaround: Reset the parity registers before reading the
  10733. + * actual data.
  10734. + */
  10735. + if (cpu_is_at32ap7000()) {
  10736. + struct atmel_nand_host *host = chip->priv;
  10737. + ecc_writel(host->ecc, CR, ATMEL_ECC_RST);
  10738. + }
  10739. +
  10740. + /* read the page */
  10741. + chip->read_buf(mtd, p, eccsize);
  10742. +
  10743. + /* move to ECC position if needed */
  10744. + if (eccpos[0] != 0) {
  10745. + /* This only works on large pages
  10746. + * because the ECC controller waits for
  10747. + * NAND_CMD_RNDOUTSTART after the
  10748. + * NAND_CMD_RNDOUT.
  10749. + * anyway, for small pages, the eccpos[0] == 0
  10750. + */
  10751. + chip->cmdfunc(mtd, NAND_CMD_RNDOUT,
  10752. + mtd->writesize + eccpos[0], -1);
  10753. + }
  10754. +
  10755. + /* the ECC controller needs to read the ECC just after the data */
  10756. + ecc_pos = oob + eccpos[0];
  10757. + chip->read_buf(mtd, ecc_pos, eccbytes);
  10758. +
  10759. + /* check if there's an error */
  10760. + stat = chip->ecc.correct(mtd, p, oob, NULL);
  10761. +
  10762. + if (stat < 0)
  10763. + mtd->ecc_stats.failed++;
  10764. + else
  10765. + mtd->ecc_stats.corrected += stat;
  10766. +
  10767. + /* get back to oob start (end of page) */
  10768. + chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1);
  10769. +
  10770. + /* read the oob */
  10771. + chip->read_buf(mtd, oob, mtd->oobsize);
  10772. +
  10773. + return 0;
  10774. +}
  10775. +
  10776. +/*
  10777. + * HW ECC Correction
  10778. + *
  10779. + * function called after a read
  10780. + *
  10781. + * mtd: MTD block structure
  10782. + * dat: raw data read from the chip
  10783. + * read_ecc: ECC from the chip (unused)
  10784. + * isnull: unused
  10785. + *
  10786. + * Detect and correct a 1 bit error for a page
  10787. + */
  10788. +static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,
  10789. + u_char *read_ecc, u_char *isnull)
  10790. +{
  10791. + struct nand_chip *nand_chip = mtd->priv;
  10792. + struct atmel_nand_host *host = nand_chip->priv;
  10793. + unsigned int ecc_status;
  10794. + unsigned int ecc_word, ecc_bit;
  10795. +
  10796. + /* get the status from the Status Register */
  10797. + ecc_status = ecc_readl(host->ecc, SR);
  10798. +
  10799. + /* if there's no error */
  10800. + if (likely(!(ecc_status & ATMEL_ECC_RECERR)))
  10801. + return 0;
  10802. +
  10803. + /* get error bit offset (4 bits) */
  10804. + ecc_bit = ecc_readl(host->ecc, PR) & ATMEL_ECC_BITADDR;
  10805. + /* get word address (12 bits) */
  10806. + ecc_word = ecc_readl(host->ecc, PR) & ATMEL_ECC_WORDADDR;
  10807. + ecc_word >>= 4;
  10808. +
  10809. + /* if there are multiple errors */
  10810. + if (ecc_status & ATMEL_ECC_MULERR) {
  10811. + /* check if it is a freshly erased block
  10812. + * (filled with 0xff) */
  10813. + if ((ecc_bit == ATMEL_ECC_BITADDR)
  10814. + && (ecc_word == (ATMEL_ECC_WORDADDR >> 4))) {
  10815. + /* the block has just been erased, return OK */
  10816. + return 0;
  10817. + }
  10818. + /* it doesn't seems to be a freshly
  10819. + * erased block.
  10820. + * We can't correct so many errors */
  10821. + dev_dbg(host->dev, "atmel_nand : multiple errors detected."
  10822. + " Unable to correct.\n");
  10823. + return -EIO;
  10824. + }
  10825. +
  10826. + /* if there's a single bit error : we can correct it */
  10827. + if (ecc_status & ATMEL_ECC_ECCERR) {
  10828. + /* there's nothing much to do here.
  10829. + * the bit error is on the ECC itself.
  10830. + */
  10831. + dev_dbg(host->dev, "atmel_nand : one bit error on ECC code."
  10832. + " Nothing to correct\n");
  10833. + return 0;
  10834. + }
  10835. +
  10836. + dev_dbg(host->dev, "atmel_nand : one bit error on data."
  10837. + " (word offset in the page :"
  10838. + " 0x%x bit offset : 0x%x)\n",
  10839. + ecc_word, ecc_bit);
  10840. + /* correct the error */
  10841. + if (nand_chip->options & NAND_BUSWIDTH_16) {
  10842. + /* 16 bits words */
  10843. + ((unsigned short *) dat)[ecc_word] ^= (1 << ecc_bit);
  10844. + } else {
  10845. + /* 8 bits words */
  10846. + dat[ecc_word] ^= (1 << ecc_bit);
  10847. + }
  10848. + dev_dbg(host->dev, "atmel_nand : error corrected\n");
  10849. + return 1;
  10850. +}
  10851. +
  10852. +/*
  10853. + * Enable HW ECC : unused on most chips
  10854. + */
  10855. +static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
  10856. +{
  10857. + if (cpu_is_at32ap7000()) {
  10858. + struct nand_chip *nand_chip = mtd->priv;
  10859. + struct atmel_nand_host *host = nand_chip->priv;
  10860. + ecc_writel(host->ecc, CR, ATMEL_ECC_RST);
  10861. + }
  10862. +}
  10863. +
  10864. +#ifdef CONFIG_MTD_PARTITIONS
  10865. +static const char *part_probes[] = { "cmdlinepart", NULL };
  10866. +#endif
  10867. +
  10868. +/*
  10869. + * Probe for the NAND device.
  10870. + */
  10871. +static int __init atmel_nand_probe(struct platform_device *pdev)
  10872. +{
  10873. + struct atmel_nand_host *host;
  10874. + struct mtd_info *mtd;
  10875. + struct nand_chip *nand_chip;
  10876. + struct resource *regs;
  10877. + struct resource *mem;
  10878. + int res;
  10879. +
  10880. +#ifdef CONFIG_MTD_PARTITIONS
  10881. + struct mtd_partition *partitions = NULL;
  10882. + int num_partitions = 0;
  10883. +#endif
  10884. +
  10885. + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  10886. + if (!mem) {
  10887. + printk(KERN_ERR "atmel_nand: can't get I/O resource mem\n");
  10888. + return -ENXIO;
  10889. + }
  10890. +
  10891. + /* Allocate memory for the device structure (and zero it) */
  10892. + host = kzalloc(sizeof(struct atmel_nand_host), GFP_KERNEL);
  10893. + if (!host) {
  10894. + printk(KERN_ERR "atmel_nand: failed to allocate device structure.\n");
  10895. + return -ENOMEM;
  10896. + }
  10897. +
  10898. + host->io_base = ioremap(mem->start, mem->end - mem->start + 1);
  10899. + if (host->io_base == NULL) {
  10900. + printk(KERN_ERR "atmel_nand: ioremap failed\n");
  10901. + res = -EIO;
  10902. + goto err_nand_ioremap;
  10903. + }
  10904. +
  10905. + mtd = &host->mtd;
  10906. + nand_chip = &host->nand_chip;
  10907. + host->board = pdev->dev.platform_data;
  10908. + host->dev = &pdev->dev;
  10909. +
  10910. + nand_chip->priv = host; /* link the private data structures */
  10911. + mtd->priv = nand_chip;
  10912. + mtd->owner = THIS_MODULE;
  10913. +
  10914. + /* Set address of NAND IO lines */
  10915. + nand_chip->IO_ADDR_R = host->io_base;
  10916. + nand_chip->IO_ADDR_W = host->io_base;
  10917. + nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl;
  10918. +
  10919. + if (host->board->rdy_pin)
  10920. + nand_chip->dev_ready = atmel_nand_device_ready;
  10921. +
  10922. + regs = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  10923. + if (!regs && hard_ecc) {
  10924. + printk(KERN_ERR "atmel_nand: can't get I/O resource "
  10925. + "regs\nFalling back on software ECC\n");
  10926. + }
  10927. +
  10928. + nand_chip->ecc.mode = NAND_ECC_SOFT; /* enable ECC */
  10929. + if (no_ecc)
  10930. + nand_chip->ecc.mode = NAND_ECC_NONE;
  10931. + if (hard_ecc && regs) {
  10932. + host->ecc = ioremap(regs->start, regs->end - regs->start + 1);
  10933. + if (host->ecc == NULL) {
  10934. + printk(KERN_ERR "atmel_nand: ioremap failed\n");
  10935. + res = -EIO;
  10936. + goto err_ecc_ioremap;
  10937. + }
  10938. + nand_chip->ecc.mode = NAND_ECC_HW_SYNDROME;
  10939. + nand_chip->ecc.calculate = atmel_nand_calculate;
  10940. + nand_chip->ecc.correct = atmel_nand_correct;
  10941. + nand_chip->ecc.hwctl = atmel_nand_hwctl;
  10942. + nand_chip->ecc.read_page = atmel_nand_read_page;
  10943. + nand_chip->ecc.bytes = 4;
  10944. + nand_chip->ecc.prepad = 0;
  10945. + nand_chip->ecc.postpad = 0;
  10946. + }
  10947. +
  10948. + nand_chip->chip_delay = 20; /* 20us command delay time */
  10949. +
  10950. + if (host->board->bus_width_16) { /* 16-bit bus width */
  10951. + nand_chip->options |= NAND_BUSWIDTH_16;
  10952. + nand_chip->read_buf = atmel_read_buf16;
  10953. + nand_chip->write_buf = atmel_write_buf16;
  10954. + } else {
  10955. + nand_chip->read_buf = atmel_read_buf;
  10956. + nand_chip->write_buf = atmel_write_buf;
  10957. + }
  10958. +
  10959. + platform_set_drvdata(pdev, host);
  10960. + atmel_nand_enable(host);
  10961. +
  10962. + if (host->board->det_pin) {
  10963. + if (gpio_get_value(host->board->det_pin)) {
  10964. + printk("No SmartMedia card inserted.\n");
  10965. + res = ENXIO;
  10966. + goto err_no_card;
  10967. + }
  10968. + }
  10969. +
  10970. + /* first scan to find the device and get the page size */
  10971. + if (nand_scan_ident(mtd, 1)) {
  10972. + res = -ENXIO;
  10973. + goto err_scan_ident;
  10974. + }
  10975. +
  10976. + if (nand_chip->ecc.mode == NAND_ECC_HW_SYNDROME) {
  10977. + /* ECC is calculated for the whole page (1 step) */
  10978. + nand_chip->ecc.size = mtd->writesize;
  10979. +
  10980. + /* set ECC page size and oob layout */
  10981. + switch (mtd->writesize) {
  10982. + case 512:
  10983. + nand_chip->ecc.layout = &atmel_oobinfo_small;
  10984. + nand_chip->ecc.read_oob = atmel_nand_read_oob_512;
  10985. + nand_chip->ecc.write_oob = atmel_nand_write_oob_512;
  10986. + ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_528);
  10987. + break;
  10988. + case 1024:
  10989. + nand_chip->ecc.layout = &atmel_oobinfo_large;
  10990. + ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_1056);
  10991. + break;
  10992. + case 2048:
  10993. + nand_chip->ecc.layout = &atmel_oobinfo_large;
  10994. + ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_2112);
  10995. + break;
  10996. + case 4096:
  10997. + nand_chip->ecc.layout = &atmel_oobinfo_large;
  10998. + ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_4224);
  10999. + break;
  11000. + default:
  11001. + /* page size not handled by HW ECC */
  11002. + /* switching back to soft ECC */
  11003. + nand_chip->ecc.mode = NAND_ECC_SOFT;
  11004. + nand_chip->ecc.calculate = NULL;
  11005. + nand_chip->ecc.correct = NULL;
  11006. + nand_chip->ecc.hwctl = NULL;
  11007. + nand_chip->ecc.read_page = NULL;
  11008. + nand_chip->ecc.postpad = 0;
  11009. + nand_chip->ecc.prepad = 0;
  11010. + nand_chip->ecc.bytes = 0;
  11011. + break;
  11012. + }
  11013. + }
  11014. +
  11015. + /* second phase scan */
  11016. + if (nand_scan_tail(mtd)) {
  11017. + res = -ENXIO;
  11018. + goto err_scan_tail;
  11019. + }
  11020. +
  11021. +#ifdef CONFIG_MTD_PARTITIONS
  11022. +#ifdef CONFIG_MTD_CMDLINE_PARTS
  11023. + mtd->name = "atmel_nand";
  11024. + num_partitions = parse_mtd_partitions(mtd, part_probes,
  11025. + &partitions, 0);
  11026. +#endif
  11027. + if (num_partitions <= 0 && host->board->partition_info)
  11028. + partitions = host->board->partition_info(mtd->size,
  11029. + &num_partitions);
  11030. +
  11031. + if ((!partitions) || (num_partitions == 0)) {
  11032. + printk(KERN_ERR "atmel_nand: No parititions defined, or unsupported device.\n");
  11033. + res = ENXIO;
  11034. + goto err_no_partitions;
  11035. + }
  11036. +
  11037. + res = add_mtd_partitions(mtd, partitions, num_partitions);
  11038. +#else
  11039. + res = add_mtd_device(mtd);
  11040. +#endif
  11041. +
  11042. + if (!res)
  11043. + return res;
  11044. +
  11045. +#ifdef CONFIG_MTD_PARTITIONS
  11046. +err_no_partitions:
  11047. +#endif
  11048. + nand_release(mtd);
  11049. +err_scan_tail:
  11050. +err_scan_ident:
  11051. +err_no_card:
  11052. + atmel_nand_disable(host);
  11053. + platform_set_drvdata(pdev, NULL);
  11054. + if (host->ecc)
  11055. + iounmap(host->ecc);
  11056. +err_ecc_ioremap:
  11057. + iounmap(host->io_base);
  11058. +err_nand_ioremap:
  11059. + kfree(host);
  11060. + return res;
  11061. +}
  11062. +
  11063. +/*
  11064. + * Remove a NAND device.
  11065. + */
  11066. +static int __exit atmel_nand_remove(struct platform_device *pdev)
  11067. +{
  11068. + struct atmel_nand_host *host = platform_get_drvdata(pdev);
  11069. + struct mtd_info *mtd = &host->mtd;
  11070. +
  11071. + nand_release(mtd);
  11072. +
  11073. + atmel_nand_disable(host);
  11074. +
  11075. + if (host->ecc)
  11076. + iounmap(host->ecc);
  11077. + iounmap(host->io_base);
  11078. + kfree(host);
  11079. +
  11080. + return 0;
  11081. +}
  11082. +
  11083. +static struct platform_driver atmel_nand_driver = {
  11084. + .remove = __exit_p(atmel_nand_remove),
  11085. + .driver = {
  11086. + .name = "atmel_nand",
  11087. + .owner = THIS_MODULE,
  11088. + },
  11089. +};
  11090. +
  11091. +static int __init atmel_nand_init(void)
  11092. +{
  11093. + return platform_driver_probe(&atmel_nand_driver, atmel_nand_probe);
  11094. +}
  11095. +
  11096. +
  11097. +static void __exit atmel_nand_exit(void)
  11098. +{
  11099. + platform_driver_unregister(&atmel_nand_driver);
  11100. +}
  11101. +
  11102. +
  11103. +module_init(atmel_nand_init);
  11104. +module_exit(atmel_nand_exit);
  11105. +
  11106. +MODULE_LICENSE("GPL");
  11107. +MODULE_AUTHOR("Rick Bronson");
  11108. +MODULE_DESCRIPTION("NAND/SmartMedia driver for AT91 / AVR32");
  11109. +MODULE_ALIAS("platform:atmel_nand");
  11110. --- /dev/null
  11111. +++ b/drivers/mtd/nand/atmel_nand_ecc.h
  11112. @@ -0,0 +1,36 @@
  11113. +/*
  11114. + * Error Corrected Code Controller (ECC) - System peripherals regsters.
  11115. + * Based on AT91SAM9260 datasheet revision B.
  11116. + *
  11117. + * This program is free software; you can redistribute it and/or modify it
  11118. + * under the terms of the GNU General Public License as published by the
  11119. + * Free Software Foundation; either version 2 of the License, or (at your
  11120. + * option) any later version.
  11121. + */
  11122. +
  11123. +#ifndef ATMEL_NAND_ECC_H
  11124. +#define ATMEL_NAND_ECC_H
  11125. +
  11126. +#define ATMEL_ECC_CR 0x00 /* Control register */
  11127. +#define ATMEL_ECC_RST (1 << 0) /* Reset parity */
  11128. +
  11129. +#define ATMEL_ECC_MR 0x04 /* Mode register */
  11130. +#define ATMEL_ECC_PAGESIZE (3 << 0) /* Page Size */
  11131. +#define ATMEL_ECC_PAGESIZE_528 (0)
  11132. +#define ATMEL_ECC_PAGESIZE_1056 (1)
  11133. +#define ATMEL_ECC_PAGESIZE_2112 (2)
  11134. +#define ATMEL_ECC_PAGESIZE_4224 (3)
  11135. +
  11136. +#define ATMEL_ECC_SR 0x08 /* Status register */
  11137. +#define ATMEL_ECC_RECERR (1 << 0) /* Recoverable Error */
  11138. +#define ATMEL_ECC_ECCERR (1 << 1) /* ECC Single Bit Error */
  11139. +#define ATMEL_ECC_MULERR (1 << 2) /* Multiple Errors */
  11140. +
  11141. +#define ATMEL_ECC_PR 0x0c /* Parity register */
  11142. +#define ATMEL_ECC_BITADDR (0xf << 0) /* Bit Error Address */
  11143. +#define ATMEL_ECC_WORDADDR (0xfff << 4) /* Word Error Address */
  11144. +
  11145. +#define ATMEL_ECC_NPR 0x10 /* NParity register */
  11146. +#define ATMEL_ECC_NPARITY (0xffff << 0) /* NParity */
  11147. +
  11148. +#endif
  11149. --- a/drivers/mtd/nand/bf5xx_nand.c
  11150. +++ b/drivers/mtd/nand/bf5xx_nand.c
  11151. @@ -803,3 +803,4 @@
  11152. MODULE_LICENSE("GPL");
  11153. MODULE_AUTHOR(DRV_AUTHOR);
  11154. MODULE_DESCRIPTION(DRV_DESC);
  11155. +MODULE_ALIAS("platform:" DRV_NAME);
  11156. --- a/drivers/mtd/nand/Kconfig
  11157. +++ b/drivers/mtd/nand/Kconfig
  11158. @@ -272,12 +272,54 @@
  11159. If you say "m", the module will be called "cs553x_nand.ko".
  11160. -config MTD_NAND_AT91
  11161. - bool "Support for NAND Flash / SmartMedia on AT91"
  11162. - depends on ARCH_AT91
  11163. +config MTD_NAND_ATMEL
  11164. + bool "Support for NAND Flash / SmartMedia on AT91 and AVR32"
  11165. + depends on ARCH_AT91 || AVR32
  11166. help
  11167. Enables support for NAND Flash / Smart Media Card interface
  11168. - on Atmel AT91 processors.
  11169. + on Atmel AT91 and AVR32 processors.
  11170. +choice
  11171. + prompt "ECC management for NAND Flash / SmartMedia on AT91 / AVR32"
  11172. + depends on MTD_NAND_ATMEL
  11173. +
  11174. +config MTD_NAND_ATMEL_ECC_HW
  11175. + bool "Hardware ECC"
  11176. + depends on ARCH_AT91SAM9263 || ARCH_AT91SAM9260 || AVR32
  11177. + help
  11178. + Use hardware ECC instead of software ECC when the chip
  11179. + supports it.
  11180. +
  11181. + The hardware ECC controller is capable of single bit error
  11182. + correction and 2-bit random detection per page.
  11183. +
  11184. + NB : hardware and software ECC schemes are incompatible.
  11185. + If you switch from one to another, you'll have to erase your
  11186. + mtd partition.
  11187. +
  11188. + If unsure, say Y
  11189. +
  11190. +config MTD_NAND_ATMEL_ECC_SOFT
  11191. + bool "Software ECC"
  11192. + help
  11193. + Use software ECC.
  11194. +
  11195. + NB : hardware and software ECC schemes are incompatible.
  11196. + If you switch from one to another, you'll have to erase your
  11197. + mtd partition.
  11198. +
  11199. +config MTD_NAND_ATMEL_ECC_NONE
  11200. + bool "No ECC (testing only, DANGEROUS)"
  11201. + depends on DEBUG_KERNEL
  11202. + help
  11203. + No ECC will be used.
  11204. + It's not a good idea and it should be reserved for testing
  11205. + purpose only.
  11206. +
  11207. + If unsure, say N
  11208. +
  11209. + endchoice
  11210. +
  11211. +endchoice
  11212. config MTD_NAND_CM_X270
  11213. tristate "Support for NAND Flash on CM-X270 modules"
  11214. --- a/drivers/mtd/nand/Makefile
  11215. +++ b/drivers/mtd/nand/Makefile
  11216. @@ -24,7 +24,7 @@
  11217. obj-$(CONFIG_MTD_NAND_NANDSIM) += nandsim.o
  11218. obj-$(CONFIG_MTD_NAND_CS553X) += cs553x_nand.o
  11219. obj-$(CONFIG_MTD_NAND_NDFC) += ndfc.o
  11220. -obj-$(CONFIG_MTD_NAND_AT91) += at91_nand.o
  11221. +obj-$(CONFIG_MTD_NAND_ATMEL) += atmel_nand.o
  11222. obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o
  11223. obj-$(CONFIG_MTD_NAND_BASLER_EXCITE) += excite_nandflash.o
  11224. obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o
  11225. --- a/drivers/mtd/nand/ndfc.c
  11226. +++ b/drivers/mtd/nand/ndfc.c
  11227. @@ -317,3 +317,5 @@
  11228. MODULE_LICENSE("GPL");
  11229. MODULE_AUTHOR("Thomas Gleixner <[email protected]>");
  11230. MODULE_DESCRIPTION("Platform driver for NDFC");
  11231. +MODULE_ALIAS("platform:ndfc-chip");
  11232. +MODULE_ALIAS("platform:ndfc-nand");
  11233. --- a/drivers/mtd/nand/orion_nand.c
  11234. +++ b/drivers/mtd/nand/orion_nand.c
  11235. @@ -169,3 +169,4 @@
  11236. MODULE_LICENSE("GPL");
  11237. MODULE_AUTHOR("Tzachi Perelstein");
  11238. MODULE_DESCRIPTION("NAND glue for Orion platforms");
  11239. +MODULE_ALIAS("platform:orion_nand");
  11240. --- a/drivers/mtd/nand/plat_nand.c
  11241. +++ b/drivers/mtd/nand/plat_nand.c
  11242. @@ -161,3 +161,4 @@
  11243. MODULE_LICENSE("GPL");
  11244. MODULE_AUTHOR("Vitaly Wool");
  11245. MODULE_DESCRIPTION("Simple generic NAND driver");
  11246. +MODULE_ALIAS("platform:gen_nand");
  11247. --- a/drivers/mtd/nand/s3c2410.c
  11248. +++ b/drivers/mtd/nand/s3c2410.c
  11249. @@ -927,3 +927,6 @@
  11250. MODULE_LICENSE("GPL");
  11251. MODULE_AUTHOR("Ben Dooks <[email protected]>");
  11252. MODULE_DESCRIPTION("S3C24XX MTD NAND driver");
  11253. +MODULE_ALIAS("platform:s3c2410-nand");
  11254. +MODULE_ALIAS("platform:s3c2412-nand");
  11255. +MODULE_ALIAS("platform:s3c2440-nand");
  11256. --- a/drivers/net/macb.c
  11257. +++ b/drivers/net/macb.c
  11258. @@ -1277,8 +1277,45 @@
  11259. return 0;
  11260. }
  11261. +#ifdef CONFIG_PM
  11262. +static int macb_suspend(struct platform_device *pdev, pm_message_t state)
  11263. +{
  11264. + struct net_device *netdev = platform_get_drvdata(pdev);
  11265. + struct macb *bp = netdev_priv(netdev);
  11266. +
  11267. + netif_device_detach(netdev);
  11268. +
  11269. +#ifndef CONFIG_ARCH_AT91
  11270. + clk_disable(bp->hclk);
  11271. +#endif
  11272. + clk_disable(bp->pclk);
  11273. +
  11274. + return 0;
  11275. +}
  11276. +
  11277. +static int macb_resume(struct platform_device *pdev)
  11278. +{
  11279. + struct net_device *netdev = platform_get_drvdata(pdev);
  11280. + struct macb *bp = netdev_priv(netdev);
  11281. +
  11282. + clk_enable(bp->pclk);
  11283. +#ifndef CONFIG_ARCH_AT91
  11284. + clk_enable(bp->hclk);
  11285. +#endif
  11286. +
  11287. + netif_device_attach(netdev);
  11288. +
  11289. + return 0;
  11290. +}
  11291. +#else
  11292. +#define macb_suspend NULL
  11293. +#define macb_resume NULL
  11294. +#endif
  11295. +
  11296. static struct platform_driver macb_driver = {
  11297. .remove = __exit_p(macb_remove),
  11298. + .suspend = macb_suspend,
  11299. + .resume = macb_resume,
  11300. .driver = {
  11301. .name = "macb",
  11302. },
  11303. --- a/drivers/parport/Kconfig
  11304. +++ b/drivers/parport/Kconfig
  11305. @@ -36,7 +36,7 @@
  11306. config PARPORT_PC
  11307. tristate "PC-style hardware"
  11308. depends on (!SPARC64 || PCI) && !SPARC32 && !M32R && !FRV && \
  11309. - (!M68K || ISA) && !MN10300
  11310. + (!M68K || ISA) && !MN10300 && !AVR32
  11311. ---help---
  11312. You should say Y here if you have a PC-style parallel port. All
  11313. IBM PC compatible computers and some Alphas have PC-style
  11314. --- /dev/null
  11315. +++ b/drivers/pcmcia/at32_cf.c
  11316. @@ -0,0 +1,533 @@
  11317. +/*
  11318. + * Driver for AVR32 Static Memory Controller: CompactFlash support
  11319. + *
  11320. + * Copyright (C) 2006 Atmel Norway
  11321. + *
  11322. + * This program is free software; you can redistribute it and/or
  11323. + * modify it under the terms of the GNU General Public License as
  11324. + * published by the Free Software Foundation; either version 2 of the
  11325. + * License, or (at your option) any later version.
  11326. + *
  11327. + * This program is distributed in the hope that it will be useful, but
  11328. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  11329. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11330. + * General Public License for more details.
  11331. + *
  11332. + * You should have received a copy of the GNU General Public License
  11333. + * along with this program; if not, write to the Free Software
  11334. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  11335. + * 02111-1307, USA.
  11336. + *
  11337. + * The full GNU General Public License is included in this
  11338. + * distribution in the file called COPYING.
  11339. + */
  11340. +#include <linux/module.h>
  11341. +#include <linux/kernel.h>
  11342. +#include <linux/platform_device.h>
  11343. +#include <linux/init.h>
  11344. +#include <linux/device.h>
  11345. +#include <linux/delay.h>
  11346. +#include <linux/interrupt.h>
  11347. +#include <linux/err.h>
  11348. +#include <linux/clk.h>
  11349. +#include <linux/dma-mapping.h>
  11350. +
  11351. +#include <pcmcia/ss.h>
  11352. +
  11353. +#include <asm/gpio.h>
  11354. +#include <asm/io.h>
  11355. +#include <asm/arch/board.h>
  11356. +
  11357. +#include <asm/arch/smc.h>
  11358. +
  11359. +struct at32_cf_socket {
  11360. + struct pcmcia_socket socket;
  11361. + int detect_pin;
  11362. + int reset_pin;
  11363. + int vcc_pin;
  11364. + int ready_pin;
  11365. + struct resource res_attr;
  11366. + struct resource res_mem;
  11367. + struct resource res_io;
  11368. + struct smc_config smc;
  11369. + unsigned int irq;
  11370. + unsigned int cf_cs;
  11371. + socket_state_t state;
  11372. + unsigned present:1;
  11373. +};
  11374. +#define to_at32_cf(sock) container_of(sock, struct at32_cf_socket, socket)
  11375. +
  11376. +/*
  11377. + * We have the following memory layout relative to the base address:
  11378. + *
  11379. + * Alt IDE Mode: 00e0 0000 -> 00ff ffff
  11380. + * True IDE Mode: 00c0 0000 -> 00df ffff
  11381. + * I/O memory: 0080 0000 -> 00bf ffff
  11382. + * Common memory: 0040 0000 -> 007f ffff
  11383. + * Attribute memory: 0000 0000 -> 003f ffff
  11384. + */
  11385. +#define CF_ATTR_OFFSET 0x00000000
  11386. +#define CF_MEM_OFFSET 0x00400000
  11387. +#define CF_IO_OFFSET 0x00800000
  11388. +#define CF_RES_SIZE 4096
  11389. +
  11390. +#ifdef DEBUG
  11391. +
  11392. +static int pc_debug;
  11393. +module_param(pc_debug, int, 0644);
  11394. +
  11395. +static void at32_cf_debug(struct at32_cf_socket *cf, const char *func,
  11396. + int level, const char *fmt, ...)
  11397. +{
  11398. + va_list args;
  11399. +
  11400. + if (pc_debug > level) {
  11401. + printk(KERN_DEBUG "at32_cf/%u: %s: ", cf->cf_cs, func);
  11402. + va_start(args, fmt);
  11403. + vprintk(fmt, args);
  11404. + va_end(args);
  11405. + }
  11406. +}
  11407. +
  11408. +#define debug(cf, lvl, fmt, arg...) \
  11409. + at32_cf_debug(cf, __func__, lvl, fmt, ##arg)
  11410. +
  11411. +#else
  11412. +#define debug(cf, lvl, fmt, arg...) do { } while (0)
  11413. +#endif
  11414. +
  11415. +static inline int at32_cf_present(struct at32_cf_socket *cf)
  11416. +{
  11417. + int present = 1;
  11418. +
  11419. + /* If we don't have a detect pin, assume the card is present */
  11420. + if (cf->detect_pin >= 0)
  11421. + present = !gpio_get_value(cf->detect_pin);
  11422. +
  11423. + return present;
  11424. +}
  11425. +
  11426. +static irqreturn_t at32_cf_irq(int irq, void *dev_id)
  11427. +{
  11428. + struct at32_cf_socket *cf = dev_id;
  11429. + unsigned int present;
  11430. +
  11431. + present = at32_cf_present(cf);
  11432. + if (present != cf->present) {
  11433. + cf->present = present;
  11434. + debug(cf, 3, "card %s\n", present ? "present" : "gone");
  11435. + pcmcia_parse_events(&cf->socket, SS_DETECT);
  11436. + }
  11437. +
  11438. + return IRQ_HANDLED;
  11439. +}
  11440. +
  11441. +static int at32_cf_get_status(struct pcmcia_socket *sock, u_int *value)
  11442. +{
  11443. + struct at32_cf_socket *cf;
  11444. + u_int status = 0;
  11445. +
  11446. + cf = container_of(sock, struct at32_cf_socket, socket);
  11447. +
  11448. + if (at32_cf_present(cf)) {
  11449. + /* NOTE: gpio on AP7xxx is 3.3V */
  11450. + status = SS_DETECT | SS_3VCARD;
  11451. + if (cf->ready_pin < 0 || gpio_get_value(cf->ready_pin))
  11452. + status |= SS_READY;
  11453. + if (cf->vcc_pin < 0 || gpio_get_value(cf->vcc_pin))
  11454. + status |= SS_POWERON;
  11455. + }
  11456. +
  11457. + *value = status;
  11458. + return 0;
  11459. +}
  11460. +
  11461. +static int at32_cf_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
  11462. +{
  11463. + struct at32_cf_socket *cf = container_of(sock, struct at32_cf_socket, socket);
  11464. +
  11465. + debug(cf, 2, "mask: %s%s%s%s%s%sflags: %s%s%s%s%s%sVcc %d Vpp %d irq %d\n",
  11466. + (state->csc_mask==0)?"<NONE> ":"",
  11467. + (state->csc_mask&SS_DETECT)?"DETECT ":"",
  11468. + (state->csc_mask&SS_READY)?"READY ":"",
  11469. + (state->csc_mask&SS_BATDEAD)?"BATDEAD ":"",
  11470. + (state->csc_mask&SS_BATWARN)?"BATWARN ":"",
  11471. + (state->csc_mask&SS_STSCHG)?"STSCHG ":"",
  11472. + (state->flags==0)?"<NONE> ":"",
  11473. + (state->flags&SS_PWR_AUTO)?"PWR_AUTO ":"",
  11474. + (state->flags&SS_IOCARD)?"IOCARD ":"",
  11475. + (state->flags&SS_RESET)?"RESET ":"",
  11476. + (state->flags&SS_SPKR_ENA)?"SPKR_ENA ":"",
  11477. + (state->flags&SS_OUTPUT_ENA)?"OUTPUT_ENA ":"",
  11478. + state->Vcc, state->Vpp, state->io_irq);
  11479. +
  11480. + /*
  11481. + * TODO: Allow boards to override this in case they have level
  11482. + * converters.
  11483. + */
  11484. + switch (state->Vcc) {
  11485. + case 0:
  11486. + if (cf->vcc_pin >= 0)
  11487. + gpio_set_value(cf->vcc_pin, 0);
  11488. + break;
  11489. + case 33:
  11490. + if (cf->vcc_pin >= 0)
  11491. + gpio_set_value(cf->vcc_pin, 1);
  11492. + break;
  11493. + default:
  11494. + return -EINVAL;
  11495. + }
  11496. +
  11497. + if (cf->reset_pin >= 0)
  11498. + gpio_set_value(cf->reset_pin, state->flags & SS_RESET);
  11499. +
  11500. + cf->state = *state;
  11501. +
  11502. + return 0;
  11503. +}
  11504. +
  11505. +static int at32_cf_socket_init(struct pcmcia_socket *sock)
  11506. +{
  11507. + debug(to_at32_cf(sock), 2, "called\n");
  11508. +
  11509. + return 0;
  11510. +}
  11511. +
  11512. +static int at32_cf_suspend(struct pcmcia_socket *sock)
  11513. +{
  11514. + debug(to_at32_cf(sock), 2, "called\n");
  11515. +
  11516. + at32_cf_set_socket(sock, &dead_socket);
  11517. +
  11518. + return 0;
  11519. +}
  11520. +
  11521. +static int at32_cf_set_io_map(struct pcmcia_socket *sock,
  11522. + struct pccard_io_map *map)
  11523. +{
  11524. + struct at32_cf_socket *cf = container_of(sock, struct at32_cf_socket, socket);
  11525. + int retval;
  11526. +
  11527. + debug(cf, 2, "map %u speed %u start 0x%08x stop 0x%08x\n",
  11528. + map->map, map->speed, map->start, map->stop);
  11529. + debug(cf, 2, "flags: %s%s%s%s%s%s%s%s\n",
  11530. + (map->flags == 0) ? "<NONE>":"",
  11531. + (map->flags & MAP_ACTIVE) ? "ACTIVE " : "",
  11532. + (map->flags & MAP_16BIT) ? "16BIT " : "",
  11533. + (map->flags & MAP_AUTOSZ) ? "AUTOSZ " : "",
  11534. + (map->flags & MAP_0WS) ? "0WS " : "",
  11535. + (map->flags & MAP_WRPROT) ? "WRPROT " : "",
  11536. + (map->flags & MAP_USE_WAIT) ? "USE_WAIT " : "",
  11537. + (map->flags & MAP_PREFETCH) ? "PREFETCH " : "");
  11538. +
  11539. + map->flags &= MAP_ACTIVE | MAP_16BIT | MAP_USE_WAIT;
  11540. +
  11541. + if (map->flags & MAP_16BIT)
  11542. + cf->smc.bus_width = 2;
  11543. + else
  11544. + cf->smc.bus_width = 1;
  11545. +
  11546. + if (map->flags & MAP_USE_WAIT)
  11547. + cf->smc.nwait_mode = 3;
  11548. + else
  11549. + cf->smc.nwait_mode = 0;
  11550. +
  11551. + retval = smc_set_configuration(cf->cf_cs, &cf->smc);
  11552. + if (retval) {
  11553. + printk(KERN_ERR "at32_cf: could not set up SMC for I/O\n");
  11554. + return retval;
  11555. + }
  11556. +
  11557. + map->start = cf->socket.io_offset;
  11558. + map->stop = map->start + CF_RES_SIZE - 1;
  11559. +
  11560. + return 0;
  11561. +}
  11562. +
  11563. +static int
  11564. +at32_cf_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map)
  11565. +{
  11566. + struct at32_cf_socket *cf;
  11567. + struct resource *res;
  11568. + int retval;
  11569. +
  11570. + cf = container_of(sock, struct at32_cf_socket, socket);
  11571. +
  11572. + debug(cf, 2, "map %u speed %u card_start %08x\n",
  11573. + map->map, map->speed, map->card_start);
  11574. + debug(cf, 2, "flags: %s%s%s%s%s%s%s%s\n",
  11575. + (map->flags==0)?"<NONE>":"",
  11576. + (map->flags&MAP_ACTIVE)?"ACTIVE ":"",
  11577. + (map->flags&MAP_16BIT)?"16BIT ":"",
  11578. + (map->flags&MAP_AUTOSZ)?"AUTOSZ ":"",
  11579. + (map->flags&MAP_0WS)?"0WS ":"",
  11580. + (map->flags&MAP_WRPROT)?"WRPROT ":"",
  11581. + (map->flags&MAP_ATTRIB)?"ATTRIB ":"",
  11582. + (map->flags&MAP_USE_WAIT)?"USE_WAIT ":"");
  11583. +
  11584. + if (map->card_start)
  11585. + return -EINVAL;
  11586. +
  11587. + map->flags &= MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT | MAP_USE_WAIT;
  11588. +
  11589. + if (map->flags & MAP_ATTRIB) {
  11590. + res = &cf->res_attr;
  11591. +
  11592. + /* Linksys WCF12 seems to use WAIT when reading CIS */
  11593. + map->flags |= MAP_USE_WAIT;
  11594. + } else {
  11595. + res = &cf->res_mem;
  11596. + }
  11597. +
  11598. + if (map->flags & MAP_USE_WAIT)
  11599. + cf->smc.nwait_mode = 3;
  11600. + else
  11601. + cf->smc.nwait_mode = 0;
  11602. +
  11603. + retval = smc_set_configuration(cf->cf_cs, &cf->smc);
  11604. + if (retval) {
  11605. + printk(KERN_ERR "at32_cf: could not set up SMC for mem\n");
  11606. + return retval;
  11607. + }
  11608. +
  11609. + map->static_start = res->start;
  11610. +
  11611. + return 0;
  11612. +}
  11613. +
  11614. +static struct pccard_operations at32_cf_ops = {
  11615. + .init = at32_cf_socket_init,
  11616. + .suspend = at32_cf_suspend,
  11617. + .get_status = at32_cf_get_status,
  11618. + .set_socket = at32_cf_set_socket,
  11619. + .set_io_map = at32_cf_set_io_map,
  11620. + .set_mem_map = at32_cf_set_mem_map,
  11621. +};
  11622. +
  11623. +static int __init request_pin(struct platform_device *pdev,
  11624. + unsigned int pin, const char *name)
  11625. +{
  11626. + if (gpio_request(pin, name)) {
  11627. + dev_warn(&pdev->dev, "failed to request %s pin\n", name);
  11628. + return -1;
  11629. + }
  11630. +
  11631. + return pin;
  11632. +}
  11633. +
  11634. +static struct smc_timing at32_cf_timing __initdata = {
  11635. + .ncs_read_setup = 30,
  11636. + .nrd_setup = 100,
  11637. + .ncs_write_setup = 30,
  11638. + .nwe_setup = 100,
  11639. +
  11640. + .ncs_read_pulse = 360,
  11641. + .nrd_pulse = 290,
  11642. + .ncs_write_pulse = 360,
  11643. + .nwe_pulse = 290,
  11644. +
  11645. + .read_cycle = 420,
  11646. + .write_cycle = 420,
  11647. +};
  11648. +
  11649. +static int __init at32_cf_probe(struct platform_device *pdev)
  11650. +{
  11651. + struct at32_cf_socket *cf;
  11652. + struct cf_platform_data *board = pdev->dev.platform_data;
  11653. + struct resource *res_skt;
  11654. + int irq;
  11655. + int ret;
  11656. +
  11657. + dev_dbg(&pdev->dev, "probe");
  11658. +
  11659. + if (!board)
  11660. + return -ENXIO;
  11661. +
  11662. + res_skt = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  11663. + if (!res_skt)
  11664. + return -ENXIO;
  11665. +
  11666. + irq = platform_get_irq(pdev, 0);
  11667. + if (irq < 0)
  11668. + return irq;
  11669. +
  11670. + cf = kzalloc(sizeof(struct at32_cf_socket), GFP_KERNEL);
  11671. + if (!cf)
  11672. + return -ENOMEM;
  11673. +
  11674. + cf->detect_pin = -1;
  11675. + cf->reset_pin = -1;
  11676. + cf->vcc_pin = -1;
  11677. + cf->ready_pin = -1;
  11678. + cf->cf_cs = board->cs;
  11679. +
  11680. + if (board->detect_pin != GPIO_PIN_NONE)
  11681. + cf->detect_pin = request_pin(pdev, board->detect_pin,
  11682. + "cf_detect");
  11683. + if (board->reset_pin != GPIO_PIN_NONE)
  11684. + cf->reset_pin = request_pin(pdev, board->reset_pin,
  11685. + "cf_reset");
  11686. + if (board->vcc_pin != GPIO_PIN_NONE)
  11687. + cf->vcc_pin = request_pin(pdev, board->vcc_pin,
  11688. + "cf_vcc");
  11689. + if (board->ready_pin != GPIO_PIN_NONE)
  11690. + /* READY is also used for irq through EIM */
  11691. + cf->ready_pin = board->ready_pin;
  11692. +
  11693. + debug(cf, 2, "pins: detect=%d reset=%d vcc=%d\n",
  11694. + cf->detect_pin, cf->reset_pin, cf->vcc_pin);
  11695. +
  11696. + cf->socket.pci_irq = irq;
  11697. + cf->socket.ops = &at32_cf_ops;
  11698. + cf->socket.resource_ops = &pccard_static_ops;
  11699. + cf->socket.dev.parent = &pdev->dev;
  11700. + cf->socket.owner = THIS_MODULE;
  11701. + cf->socket.features =
  11702. + SS_CAP_MEM_ALIGN | SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
  11703. + cf->socket.map_size = CF_RES_SIZE;
  11704. +
  11705. + cf->res_attr.start = res_skt->start + CF_ATTR_OFFSET;
  11706. + cf->res_attr.end = cf->res_attr.start + CF_RES_SIZE - 1;
  11707. + cf->res_attr.name = "attribute";
  11708. + cf->res_attr.flags = IORESOURCE_MEM;
  11709. + ret = request_resource(res_skt, &cf->res_attr);
  11710. + if (ret)
  11711. + goto err_request_res_attr;
  11712. +
  11713. + cf->res_mem.start = res_skt->start + CF_MEM_OFFSET;
  11714. + cf->res_mem.end = cf->res_mem.start + CF_RES_SIZE - 1;
  11715. + cf->res_mem.name = "memory";
  11716. + cf->res_mem.flags = IORESOURCE_MEM;
  11717. + ret = request_resource(res_skt, &cf->res_mem);
  11718. + if (ret)
  11719. + goto err_request_res_mem;
  11720. +
  11721. + cf->res_io.start = res_skt->start + CF_IO_OFFSET;
  11722. + cf->res_io.end = cf->res_io.start + CF_RES_SIZE - 1;
  11723. + cf->res_io.name = "io";
  11724. + cf->res_io.flags = IORESOURCE_MEM;
  11725. + ret = request_resource(res_skt, &cf->res_io);
  11726. + if (ret)
  11727. + goto err_request_res_io;
  11728. +
  11729. + cf->socket.io_offset = cf->res_io.start;
  11730. +
  11731. + if (cf->detect_pin >= 0) {
  11732. + ret = request_irq(gpio_to_irq(cf->detect_pin), at32_cf_irq,
  11733. + IRQF_SHARED, "cf_detect", cf);
  11734. + if (ret) {
  11735. + debug(cf, 1,
  11736. + "failed to request cf_detect interrupt\n");
  11737. + goto err_detect_irq;
  11738. + }
  11739. + }
  11740. +
  11741. + cf->present = at32_cf_present(cf);
  11742. +
  11743. + /* Setup SMC timings */
  11744. + smc_set_timing(&cf->smc, &at32_cf_timing);
  11745. +
  11746. + cf->smc.bus_width = 2;
  11747. + cf->smc.nrd_controlled = 1;
  11748. + cf->smc.nwe_controlled = 1;
  11749. + cf->smc.nwait_mode = 0;
  11750. + cf->smc.byte_write = 0;
  11751. + cf->smc.tdf_cycles = 8;
  11752. + cf->smc.tdf_mode = 0;
  11753. +
  11754. + ret = smc_set_configuration(cf->cf_cs, &cf->smc);
  11755. + if (ret) {
  11756. + debug(cf, 1, "failed to configure SMC\n", ret);
  11757. + goto err_smc;
  11758. + }
  11759. +
  11760. + ret = pcmcia_register_socket(&cf->socket);
  11761. + if (ret) {
  11762. + debug(cf, 1, "failed to register socket: %d\n", ret);
  11763. + goto err_register_socket;
  11764. + }
  11765. +
  11766. + if (cf->reset_pin >= 0)
  11767. + gpio_direction_output(cf->reset_pin, 0);
  11768. +
  11769. + platform_set_drvdata(pdev, cf);
  11770. +
  11771. + dev_info(&pdev->dev, "Atmel SMC CF interface at 0x%08lx\n",
  11772. + (unsigned long)res_skt->start);
  11773. +
  11774. + return 0;
  11775. +
  11776. +err_register_socket:
  11777. +err_smc:
  11778. + if (cf->detect_pin >= 0)
  11779. + free_irq(gpio_to_irq(cf->detect_pin), cf);
  11780. +err_detect_irq:
  11781. + release_resource(&cf->res_io);
  11782. +err_request_res_io:
  11783. + release_resource(&cf->res_mem);
  11784. +err_request_res_mem:
  11785. + release_resource(&cf->res_attr);
  11786. +err_request_res_attr:
  11787. + if (cf->vcc_pin >= 0)
  11788. + gpio_free(cf->vcc_pin);
  11789. + if (cf->reset_pin >= 0)
  11790. + gpio_free(cf->reset_pin);
  11791. + if (cf->detect_pin >= 0)
  11792. + gpio_free(cf->detect_pin);
  11793. + kfree(cf);
  11794. +
  11795. + return ret;
  11796. +}
  11797. +
  11798. +static int __exit at32_cf_remove(struct platform_device *pdev)
  11799. +{
  11800. + struct at32_cf_socket *cf = platform_get_drvdata(pdev);
  11801. +
  11802. + pcmcia_unregister_socket(&cf->socket);
  11803. + if (cf->detect_pin >= 0) {
  11804. + free_irq(gpio_to_irq(cf->detect_pin), cf);
  11805. + gpio_free(cf->detect_pin);
  11806. + }
  11807. + if (cf->vcc_pin >= 0)
  11808. + gpio_free(cf->vcc_pin);
  11809. + if (cf->reset_pin >= 0)
  11810. + gpio_free(cf->reset_pin);
  11811. +
  11812. + release_resource(&cf->res_io);
  11813. + release_resource(&cf->res_mem);
  11814. + release_resource(&cf->res_attr);
  11815. + kfree(cf);
  11816. + platform_set_drvdata(pdev, NULL);
  11817. +
  11818. + return 0;
  11819. +}
  11820. +
  11821. +static struct platform_driver at32_cf_driver = {
  11822. + .remove = __exit_p(at32_cf_remove),
  11823. + .driver = {
  11824. + .name = "at32_cf",
  11825. + .owner = THIS_MODULE,
  11826. + },
  11827. +};
  11828. +
  11829. +static int __init at32_cf_init(void)
  11830. +{
  11831. + int ret;
  11832. +
  11833. + ret = platform_driver_probe(&at32_cf_driver, at32_cf_probe);
  11834. + if (ret)
  11835. + printk(KERN_ERR "at32_cf: probe failed: %d\n", ret);
  11836. + return ret;
  11837. +}
  11838. +
  11839. +static void __exit at32_cf_exit(void)
  11840. +{
  11841. + platform_driver_unregister(&at32_cf_driver);
  11842. +}
  11843. +
  11844. +module_init(at32_cf_init);
  11845. +module_exit(at32_cf_exit);
  11846. +
  11847. +MODULE_LICENSE("GPL");
  11848. +MODULE_DESCRIPTION("Driver for SMC PCMCIA interface");
  11849. +MODULE_AUTHOR("Hans-Christian Egtvedt <[email protected]>");
  11850. --- a/drivers/pcmcia/Kconfig
  11851. +++ b/drivers/pcmcia/Kconfig
  11852. @@ -277,6 +277,13 @@
  11853. Say Y here to support the CompactFlash controller on the
  11854. PA Semi Electra eval board.
  11855. +config AT32_CF
  11856. + tristate "AT32AP CompactFlash Controller"
  11857. + depends on PCMCIA && AVR32 && PLATFORM_AT32AP
  11858. + help
  11859. + Say Y here to support the CompactFlash controller on AT32 chips.
  11860. + Or choose M to compile the driver as a module named "at32_cf".
  11861. +
  11862. config PCCARD_NONSTATIC
  11863. tristate
  11864. --- a/drivers/pcmcia/Makefile
  11865. +++ b/drivers/pcmcia/Makefile
  11866. @@ -38,6 +38,7 @@
  11867. obj-$(CONFIG_OMAP_CF) += omap_cf.o
  11868. obj-$(CONFIG_AT91_CF) += at91_cf.o
  11869. obj-$(CONFIG_ELECTRA_CF) += electra_cf.o
  11870. +obj-$(CONFIG_AT32_CF) += at32_cf.o
  11871. sa11xx_core-y += soc_common.o sa11xx_base.o
  11872. pxa2xx_core-y += soc_common.o pxa2xx_base.o
  11873. --- a/drivers/serial/atmel_serial.c
  11874. +++ b/drivers/serial/atmel_serial.c
  11875. @@ -1440,6 +1440,15 @@
  11876. };
  11877. #ifdef CONFIG_PM
  11878. +static bool atmel_serial_clk_will_stop(void)
  11879. +{
  11880. +#ifdef CONFIG_ARCH_AT91
  11881. + return at91_suspend_entering_slow_clock();
  11882. +#else
  11883. + return false;
  11884. +#endif
  11885. +}
  11886. +
  11887. static int atmel_serial_suspend(struct platform_device *pdev,
  11888. pm_message_t state)
  11889. {
  11890. @@ -1447,7 +1456,7 @@
  11891. struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
  11892. if (device_may_wakeup(&pdev->dev)
  11893. - && !at91_suspend_entering_slow_clock())
  11894. + && !atmel_serial_clk_will_stop())
  11895. enable_irq_wake(port->irq);
  11896. else {
  11897. uart_suspend_port(&atmel_uart, port);
  11898. --- a/drivers/spi/atmel_spi.c
  11899. +++ b/drivers/spi/atmel_spi.c
  11900. @@ -51,9 +51,7 @@
  11901. u8 stopping;
  11902. struct list_head queue;
  11903. struct spi_transfer *current_transfer;
  11904. - unsigned long current_remaining_bytes;
  11905. - struct spi_transfer *next_transfer;
  11906. - unsigned long next_remaining_bytes;
  11907. + unsigned long remaining_bytes;
  11908. void *buffer;
  11909. dma_addr_t buffer_dma;
  11910. @@ -133,48 +131,6 @@
  11911. gpio_set_value(gpio, !active);
  11912. }
  11913. -static inline int atmel_spi_xfer_is_last(struct spi_message *msg,
  11914. - struct spi_transfer *xfer)
  11915. -{
  11916. - return msg->transfers.prev == &xfer->transfer_list;
  11917. -}
  11918. -
  11919. -static inline int atmel_spi_xfer_can_be_chained(struct spi_transfer *xfer)
  11920. -{
  11921. - return xfer->delay_usecs == 0 && !xfer->cs_change;
  11922. -}
  11923. -
  11924. -static void atmel_spi_next_xfer_data(struct spi_master *master,
  11925. - struct spi_transfer *xfer,
  11926. - dma_addr_t *tx_dma,
  11927. - dma_addr_t *rx_dma,
  11928. - u32 *plen)
  11929. -{
  11930. - struct atmel_spi *as = spi_master_get_devdata(master);
  11931. - u32 len = *plen;
  11932. -
  11933. - /* use scratch buffer only when rx or tx data is unspecified */
  11934. - if (xfer->rx_buf)
  11935. - *rx_dma = xfer->rx_dma + xfer->len - len;
  11936. - else {
  11937. - *rx_dma = as->buffer_dma;
  11938. - if (len > BUFFER_SIZE)
  11939. - len = BUFFER_SIZE;
  11940. - }
  11941. - if (xfer->tx_buf)
  11942. - *tx_dma = xfer->tx_dma + xfer->len - len;
  11943. - else {
  11944. - *tx_dma = as->buffer_dma;
  11945. - if (len > BUFFER_SIZE)
  11946. - len = BUFFER_SIZE;
  11947. - memset(as->buffer, 0, len);
  11948. - dma_sync_single_for_device(&as->pdev->dev,
  11949. - as->buffer_dma, len, DMA_TO_DEVICE);
  11950. - }
  11951. -
  11952. - *plen = len;
  11953. -}
  11954. -
  11955. /*
  11956. * Submit next transfer for DMA.
  11957. * lock is held, spi irq is blocked
  11958. @@ -184,78 +140,53 @@
  11959. {
  11960. struct atmel_spi *as = spi_master_get_devdata(master);
  11961. struct spi_transfer *xfer;
  11962. - u32 len, remaining, total;
  11963. + u32 len;
  11964. dma_addr_t tx_dma, rx_dma;
  11965. - if (!as->current_transfer)
  11966. - xfer = list_entry(msg->transfers.next,
  11967. - struct spi_transfer, transfer_list);
  11968. - else if (!as->next_transfer)
  11969. - xfer = list_entry(as->current_transfer->transfer_list.next,
  11970. - struct spi_transfer, transfer_list);
  11971. - else
  11972. - xfer = NULL;
  11973. -
  11974. - if (xfer) {
  11975. - len = xfer->len;
  11976. - atmel_spi_next_xfer_data(master, xfer, &tx_dma, &rx_dma, &len);
  11977. - remaining = xfer->len - len;
  11978. -
  11979. - spi_writel(as, RPR, rx_dma);
  11980. - spi_writel(as, TPR, tx_dma);
  11981. -
  11982. - if (msg->spi->bits_per_word > 8)
  11983. - len >>= 1;
  11984. - spi_writel(as, RCR, len);
  11985. - spi_writel(as, TCR, len);
  11986. -
  11987. - dev_dbg(&msg->spi->dev,
  11988. - " start xfer %p: len %u tx %p/%08x rx %p/%08x\n",
  11989. - xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
  11990. - xfer->rx_buf, xfer->rx_dma);
  11991. - } else {
  11992. - xfer = as->next_transfer;
  11993. - remaining = as->next_remaining_bytes;
  11994. + xfer = as->current_transfer;
  11995. + if (!xfer || as->remaining_bytes == 0) {
  11996. + if (xfer)
  11997. + xfer = list_entry(xfer->transfer_list.next,
  11998. + struct spi_transfer, transfer_list);
  11999. + else
  12000. + xfer = list_entry(msg->transfers.next,
  12001. + struct spi_transfer, transfer_list);
  12002. + as->remaining_bytes = xfer->len;
  12003. + as->current_transfer = xfer;
  12004. }
  12005. - as->current_transfer = xfer;
  12006. - as->current_remaining_bytes = remaining;
  12007. -
  12008. - if (remaining > 0)
  12009. - len = remaining;
  12010. - else if (!atmel_spi_xfer_is_last(msg, xfer)
  12011. - && atmel_spi_xfer_can_be_chained(xfer)) {
  12012. - xfer = list_entry(xfer->transfer_list.next,
  12013. - struct spi_transfer, transfer_list);
  12014. - len = xfer->len;
  12015. - } else
  12016. - xfer = NULL;
  12017. + len = as->remaining_bytes;
  12018. - as->next_transfer = xfer;
  12019. + tx_dma = xfer->tx_dma + xfer->len - len;
  12020. + rx_dma = xfer->rx_dma + xfer->len - len;
  12021. - if (xfer) {
  12022. - total = len;
  12023. - atmel_spi_next_xfer_data(master, xfer, &tx_dma, &rx_dma, &len);
  12024. - as->next_remaining_bytes = total - len;
  12025. -
  12026. - spi_writel(as, RNPR, rx_dma);
  12027. - spi_writel(as, TNPR, tx_dma);
  12028. -
  12029. - if (msg->spi->bits_per_word > 8)
  12030. - len >>= 1;
  12031. - spi_writel(as, RNCR, len);
  12032. - spi_writel(as, TNCR, len);
  12033. -
  12034. - dev_dbg(&msg->spi->dev,
  12035. - " next xfer %p: len %u tx %p/%08x rx %p/%08x\n",
  12036. - xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
  12037. - xfer->rx_buf, xfer->rx_dma);
  12038. - } else {
  12039. - spi_writel(as, RNCR, 0);
  12040. - spi_writel(as, TNCR, 0);
  12041. + /* use scratch buffer only when rx or tx data is unspecified */
  12042. + if (!xfer->rx_buf) {
  12043. + rx_dma = as->buffer_dma;
  12044. + if (len > BUFFER_SIZE)
  12045. + len = BUFFER_SIZE;
  12046. }
  12047. + if (!xfer->tx_buf) {
  12048. + tx_dma = as->buffer_dma;
  12049. + if (len > BUFFER_SIZE)
  12050. + len = BUFFER_SIZE;
  12051. + memset(as->buffer, 0, len);
  12052. + dma_sync_single_for_device(&as->pdev->dev,
  12053. + as->buffer_dma, len, DMA_TO_DEVICE);
  12054. + }
  12055. +
  12056. + spi_writel(as, RPR, rx_dma);
  12057. + spi_writel(as, TPR, tx_dma);
  12058. - /* REVISIT: We're waiting for ENDRX before we start the next
  12059. + as->remaining_bytes -= len;
  12060. + if (msg->spi->bits_per_word > 8)
  12061. + len >>= 1;
  12062. +
  12063. + /* REVISIT: when xfer->delay_usecs == 0, the PDC "next transfer"
  12064. + * mechanism might help avoid the IRQ latency between transfers
  12065. + * (and improve the nCS0 errata handling on at91rm9200 chips)
  12066. + *
  12067. + * We're also waiting for ENDRX before we start the next
  12068. * transfer because we need to handle some difficult timing
  12069. * issues otherwise. If we wait for ENDTX in one transfer and
  12070. * then starts waiting for ENDRX in the next, it's difficult
  12071. @@ -265,7 +196,17 @@
  12072. *
  12073. * It should be doable, though. Just not now...
  12074. */
  12075. + spi_writel(as, TNCR, 0);
  12076. + spi_writel(as, RNCR, 0);
  12077. spi_writel(as, IER, SPI_BIT(ENDRX) | SPI_BIT(OVRES));
  12078. +
  12079. + dev_dbg(&msg->spi->dev,
  12080. + " start xfer %p: len %u tx %p/%08x rx %p/%08x imr %03x\n",
  12081. + xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
  12082. + xfer->rx_buf, xfer->rx_dma, spi_readl(as, IMR));
  12083. +
  12084. + spi_writel(as, RCR, len);
  12085. + spi_writel(as, TCR, len);
  12086. spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN));
  12087. }
  12088. @@ -363,7 +304,6 @@
  12089. spin_lock(&as->lock);
  12090. as->current_transfer = NULL;
  12091. - as->next_transfer = NULL;
  12092. /* continue if needed */
  12093. if (list_empty(&as->queue) || as->stopping)
  12094. @@ -447,7 +387,7 @@
  12095. spi_writel(as, IDR, pending);
  12096. - if (as->current_remaining_bytes == 0) {
  12097. + if (as->remaining_bytes == 0) {
  12098. msg->actual_length += xfer->len;
  12099. if (!msg->is_dma_mapped)
  12100. @@ -457,7 +397,7 @@
  12101. if (xfer->delay_usecs)
  12102. udelay(xfer->delay_usecs);
  12103. - if (atmel_spi_xfer_is_last(msg, xfer)) {
  12104. + if (msg->transfers.prev == &xfer->transfer_list) {
  12105. /* report completed message */
  12106. atmel_spi_msg_done(master, as, msg, 0,
  12107. xfer->cs_change);
  12108. --- a/drivers/usb/gadget/atmel_usba_udc.c
  12109. +++ b/drivers/usb/gadget/atmel_usba_udc.c
  12110. @@ -18,6 +18,7 @@
  12111. #include <linux/platform_device.h>
  12112. #include <linux/usb/ch9.h>
  12113. #include <linux/usb/gadget.h>
  12114. +#include <linux/usb/atmel_usba_udc.h>
  12115. #include <linux/delay.h>
  12116. #include <asm/gpio.h>
  12117. @@ -27,6 +28,7 @@
  12118. static struct usba_udc the_udc;
  12119. +static struct usba_ep *usba_ep;
  12120. #ifdef CONFIG_USB_GADGET_DEBUG_FS
  12121. #include <linux/debugfs.h>
  12122. @@ -324,53 +326,28 @@
  12123. return 1;
  12124. }
  12125. -static void copy_to_fifo(void __iomem *fifo, const void *buf, int len)
  12126. -{
  12127. - unsigned long tmp;
  12128. +#if defined(CONFIG_AVR32)
  12129. - DBG(DBG_FIFO, "copy to FIFO (len %d):\n", len);
  12130. - for (; len > 0; len -= 4, buf += 4, fifo += 4) {
  12131. - tmp = *(unsigned long *)buf;
  12132. - if (len >= 4) {
  12133. - DBG(DBG_FIFO, " -> %08lx\n", tmp);
  12134. - __raw_writel(tmp, fifo);
  12135. - } else {
  12136. - do {
  12137. - DBG(DBG_FIFO, " -> %02lx\n", tmp >> 24);
  12138. - __raw_writeb(tmp >> 24, fifo);
  12139. - fifo++;
  12140. - tmp <<= 8;
  12141. - } while (--len);
  12142. - break;
  12143. - }
  12144. - }
  12145. +static void toggle_bias(int is_on)
  12146. +{
  12147. }
  12148. -static void copy_from_fifo(void *buf, void __iomem *fifo, int len)
  12149. +#elif defined(CONFIG_ARCH_AT91)
  12150. +
  12151. +#include <asm/arch/at91_pmc.h>
  12152. +
  12153. +static void toggle_bias(int is_on)
  12154. {
  12155. - union {
  12156. - unsigned long *w;
  12157. - unsigned char *b;
  12158. - } p;
  12159. - unsigned long tmp;
  12160. -
  12161. - DBG(DBG_FIFO, "copy from FIFO (len %d):\n", len);
  12162. - for (p.w = buf; len > 0; len -= 4, p.w++, fifo += 4) {
  12163. - if (len >= 4) {
  12164. - tmp = __raw_readl(fifo);
  12165. - *p.w = tmp;
  12166. - DBG(DBG_FIFO, " -> %08lx\n", tmp);
  12167. - } else {
  12168. - do {
  12169. - tmp = __raw_readb(fifo);
  12170. - *p.b = tmp;
  12171. - DBG(DBG_FIFO, " -> %02lx\n", tmp);
  12172. - fifo++, p.b++;
  12173. - } while (--len);
  12174. - }
  12175. - }
  12176. + unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR);
  12177. +
  12178. + if (is_on)
  12179. + at91_sys_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
  12180. + else
  12181. + at91_sys_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
  12182. }
  12183. +#endif /* CONFIG_ARCH_AT91 */
  12184. +
  12185. static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)
  12186. {
  12187. unsigned int transaction_len;
  12188. @@ -387,7 +364,7 @@
  12189. ep->ep.name, req, transaction_len,
  12190. req->last_transaction ? ", done" : "");
  12191. - copy_to_fifo(ep->fifo, req->req.buf + req->req.actual, transaction_len);
  12192. + memcpy_toio(ep->fifo, req->req.buf + req->req.actual, transaction_len);
  12193. usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
  12194. req->req.actual += transaction_len;
  12195. }
  12196. @@ -476,7 +453,7 @@
  12197. bytecount = req->req.length - req->req.actual;
  12198. }
  12199. - copy_from_fifo(req->req.buf + req->req.actual,
  12200. + memcpy_fromio(req->req.buf + req->req.actual,
  12201. ep->fifo, bytecount);
  12202. req->req.actual += bytecount;
  12203. @@ -1029,33 +1006,6 @@
  12204. .set_selfpowered = usba_udc_set_selfpowered,
  12205. };
  12206. -#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
  12207. -{ \
  12208. - .ep = { \
  12209. - .ops = &usba_ep_ops, \
  12210. - .name = nam, \
  12211. - .maxpacket = maxpkt, \
  12212. - }, \
  12213. - .udc = &the_udc, \
  12214. - .queue = LIST_HEAD_INIT(usba_ep[idx].queue), \
  12215. - .fifo_size = maxpkt, \
  12216. - .nr_banks = maxbk, \
  12217. - .index = idx, \
  12218. - .can_dma = dma, \
  12219. - .can_isoc = isoc, \
  12220. -}
  12221. -
  12222. -static struct usba_ep usba_ep[] = {
  12223. - EP("ep0", 0, 64, 1, 0, 0),
  12224. - EP("ep1in-bulk", 1, 512, 2, 1, 1),
  12225. - EP("ep2out-bulk", 2, 512, 2, 1, 1),
  12226. - EP("ep3in-int", 3, 64, 3, 1, 0),
  12227. - EP("ep4out-int", 4, 64, 3, 1, 0),
  12228. - EP("ep5in-iso", 5, 1024, 3, 1, 1),
  12229. - EP("ep6out-iso", 6, 1024, 3, 1, 1),
  12230. -};
  12231. -#undef EP
  12232. -
  12233. static struct usb_endpoint_descriptor usba_ep0_desc = {
  12234. .bLength = USB_DT_ENDPOINT_SIZE,
  12235. .bDescriptorType = USB_DT_ENDPOINT,
  12236. @@ -1074,7 +1024,6 @@
  12237. static struct usba_udc the_udc = {
  12238. .gadget = {
  12239. .ops = &usba_udc_ops,
  12240. - .ep0 = &usba_ep[0].ep,
  12241. .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list),
  12242. .is_dualspeed = 1,
  12243. .name = "atmel_usba_udc",
  12244. @@ -1231,7 +1180,7 @@
  12245. } else {
  12246. usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE);
  12247. usba_writel(udc, TST, USBA_TST_PKT_MODE);
  12248. - copy_to_fifo(ep->fifo, test_packet_buffer,
  12249. + memcpy_toio(ep->fifo, test_packet_buffer,
  12250. sizeof(test_packet_buffer));
  12251. usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
  12252. dev_info(dev, "Entering Test_Packet mode...\n");
  12253. @@ -1530,13 +1479,13 @@
  12254. DBG(DBG_HW, "Packet length: %u\n", pkt_len);
  12255. if (pkt_len != sizeof(crq)) {
  12256. pr_warning("udc: Invalid packet length %u "
  12257. - "(expected %lu)\n", pkt_len, sizeof(crq));
  12258. + "(expected %zu)\n", pkt_len, sizeof(crq));
  12259. set_protocol_stall(udc, ep);
  12260. return;
  12261. }
  12262. DBG(DBG_FIFO, "Copying ctrl request from 0x%p:\n", ep->fifo);
  12263. - copy_from_fifo(crq.data, ep->fifo, sizeof(crq));
  12264. + memcpy_fromio(crq.data, ep->fifo, sizeof(crq));
  12265. /* Free up one bank in the FIFO so that we can
  12266. * generate or receive a reply right away. */
  12267. @@ -1688,6 +1637,7 @@
  12268. DBG(DBG_INT, "irq, status=%#08x\n", status);
  12269. if (status & USBA_DET_SUSPEND) {
  12270. + toggle_bias(0);
  12271. usba_writel(udc, INT_CLR, USBA_DET_SUSPEND);
  12272. DBG(DBG_BUS, "Suspend detected\n");
  12273. if (udc->gadget.speed != USB_SPEED_UNKNOWN
  12274. @@ -1699,6 +1649,7 @@
  12275. }
  12276. if (status & USBA_WAKE_UP) {
  12277. + toggle_bias(1);
  12278. usba_writel(udc, INT_CLR, USBA_WAKE_UP);
  12279. DBG(DBG_BUS, "Wake Up CPU detected\n");
  12280. }
  12281. @@ -1792,12 +1743,14 @@
  12282. vbus = gpio_get_value(udc->vbus_pin);
  12283. if (vbus != udc->vbus_prev) {
  12284. if (vbus) {
  12285. - usba_writel(udc, CTRL, USBA_EN_USBA);
  12286. + toggle_bias(1);
  12287. + usba_writel(udc, CTRL, USBA_ENABLE_MASK);
  12288. usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
  12289. } else {
  12290. udc->gadget.speed = USB_SPEED_UNKNOWN;
  12291. reset_all_endpoints(udc);
  12292. - usba_writel(udc, CTRL, 0);
  12293. + toggle_bias(0);
  12294. + usba_writel(udc, CTRL, USBA_DISABLE_MASK);
  12295. spin_unlock(&udc->lock);
  12296. udc->driver->disconnect(&udc->gadget);
  12297. spin_lock(&udc->lock);
  12298. @@ -1850,7 +1803,8 @@
  12299. /* If Vbus is present, enable the controller and wait for reset */
  12300. spin_lock_irqsave(&udc->lock, flags);
  12301. if (vbus_is_present(udc) && udc->vbus_prev == 0) {
  12302. - usba_writel(udc, CTRL, USBA_EN_USBA);
  12303. + toggle_bias(1);
  12304. + usba_writel(udc, CTRL, USBA_ENABLE_MASK);
  12305. usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
  12306. }
  12307. spin_unlock_irqrestore(&udc->lock, flags);
  12308. @@ -1883,7 +1837,8 @@
  12309. spin_unlock_irqrestore(&udc->lock, flags);
  12310. /* This will also disable the DP pullup */
  12311. - usba_writel(udc, CTRL, 0);
  12312. + toggle_bias(0);
  12313. + usba_writel(udc, CTRL, USBA_DISABLE_MASK);
  12314. driver->unbind(&udc->gadget);
  12315. udc->gadget.dev.driver = NULL;
  12316. @@ -1908,7 +1863,7 @@
  12317. regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
  12318. fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
  12319. - if (!regs || !fifo)
  12320. + if (!regs || !fifo || !pdata)
  12321. return -ENXIO;
  12322. irq = platform_get_irq(pdev, 0);
  12323. @@ -1953,19 +1908,48 @@
  12324. /* Make sure we start from a clean slate */
  12325. clk_enable(pclk);
  12326. - usba_writel(udc, CTRL, 0);
  12327. + toggle_bias(0);
  12328. + usba_writel(udc, CTRL, USBA_DISABLE_MASK);
  12329. clk_disable(pclk);
  12330. + usba_ep = kmalloc(sizeof(struct usba_ep) * pdata->num_ep,
  12331. + GFP_KERNEL);
  12332. + if (!usba_ep)
  12333. + goto err_alloc_ep;
  12334. +
  12335. + the_udc.gadget.ep0 = &usba_ep[0].ep;
  12336. +
  12337. INIT_LIST_HEAD(&usba_ep[0].ep.ep_list);
  12338. usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0);
  12339. usba_ep[0].dma_regs = udc->regs + USBA_DMA_BASE(0);
  12340. usba_ep[0].fifo = udc->fifo + USBA_FIFO_BASE(0);
  12341. - for (i = 1; i < ARRAY_SIZE(usba_ep); i++) {
  12342. + usba_ep[0].ep.ops = &usba_ep_ops;
  12343. + usba_ep[0].ep.name = pdata->ep[0].name;
  12344. + usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size;
  12345. + usba_ep[0].udc = &the_udc;
  12346. + INIT_LIST_HEAD(&usba_ep[0].queue);
  12347. + usba_ep[0].fifo_size = pdata->ep[0].fifo_size;
  12348. + usba_ep[0].nr_banks = pdata->ep[0].nr_banks;
  12349. + usba_ep[0].index = pdata->ep[0].index;
  12350. + usba_ep[0].can_dma = pdata->ep[0].can_dma;
  12351. + usba_ep[0].can_isoc = pdata->ep[0].can_isoc;
  12352. +
  12353. + for (i = 1; i < pdata->num_ep; i++) {
  12354. struct usba_ep *ep = &usba_ep[i];
  12355. ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
  12356. ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
  12357. ep->fifo = udc->fifo + USBA_FIFO_BASE(i);
  12358. + ep->ep.ops = &usba_ep_ops;
  12359. + ep->ep.name = pdata->ep[i].name;
  12360. + ep->ep.maxpacket = pdata->ep[i].fifo_size;
  12361. + ep->udc = &the_udc;
  12362. + INIT_LIST_HEAD(&ep->queue);
  12363. + ep->fifo_size = pdata->ep[i].fifo_size;
  12364. + ep->nr_banks = pdata->ep[i].nr_banks;
  12365. + ep->index = pdata->ep[i].index;
  12366. + ep->can_dma = pdata->ep[i].can_dma;
  12367. + ep->can_isoc = pdata->ep[i].can_isoc;
  12368. list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list);
  12369. }
  12370. @@ -1984,7 +1968,7 @@
  12371. goto err_device_add;
  12372. }
  12373. - if (pdata && pdata->vbus_pin != GPIO_PIN_NONE) {
  12374. + if (pdata->vbus_pin >= 0) {
  12375. if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) {
  12376. udc->vbus_pin = pdata->vbus_pin;
  12377. @@ -2004,7 +1988,7 @@
  12378. }
  12379. usba_init_debugfs(udc);
  12380. - for (i = 1; i < ARRAY_SIZE(usba_ep); i++)
  12381. + for (i = 1; i < pdata->num_ep; i++)
  12382. usba_ep_init_debugfs(udc, &usba_ep[i]);
  12383. return 0;
  12384. @@ -2012,6 +1996,8 @@
  12385. err_device_add:
  12386. free_irq(irq, udc);
  12387. err_request_irq:
  12388. + kfree(usba_ep);
  12389. +err_alloc_ep:
  12390. iounmap(udc->fifo);
  12391. err_map_fifo:
  12392. iounmap(udc->regs);
  12393. @@ -2029,10 +2015,11 @@
  12394. {
  12395. struct usba_udc *udc;
  12396. int i;
  12397. + struct usba_platform_data *pdata = pdev->dev.platform_data;
  12398. udc = platform_get_drvdata(pdev);
  12399. - for (i = 1; i < ARRAY_SIZE(usba_ep); i++)
  12400. + for (i = 1; i < pdata->num_ep; i++)
  12401. usba_ep_cleanup_debugfs(&usba_ep[i]);
  12402. usba_cleanup_debugfs(udc);
  12403. @@ -2040,6 +2027,7 @@
  12404. gpio_free(udc->vbus_pin);
  12405. free_irq(udc->irq, udc);
  12406. + kfree(usba_ep);
  12407. iounmap(udc->fifo);
  12408. iounmap(udc->regs);
  12409. clk_put(udc->hclk);
  12410. --- a/drivers/usb/gadget/atmel_usba_udc.h
  12411. +++ b/drivers/usb/gadget/atmel_usba_udc.h
  12412. @@ -41,6 +41,15 @@
  12413. #define USBA_EN_USBA (1 << 8)
  12414. #define USBA_DETACH (1 << 9)
  12415. #define USBA_REMOTE_WAKE_UP (1 << 10)
  12416. +#define USBA_PULLD_DIS (1 << 11)
  12417. +
  12418. +#if defined(CONFIG_AVR32)
  12419. +#define USBA_ENABLE_MASK USBA_EN_USBA
  12420. +#define USBA_DISABLE_MASK 0
  12421. +#elif defined(CONFIG_ARCH_AT91)
  12422. +#define USBA_ENABLE_MASK (USBA_EN_USBA | USBA_PULLD_DIS)
  12423. +#define USBA_DISABLE_MASK USBA_DETACH
  12424. +#endif /* CONFIG_ARCH_AT91 */
  12425. /* Bitfields in FNUM */
  12426. #define USBA_MICRO_FRAME_NUM_OFFSET 0
  12427. --- a/drivers/usb/gadget/Kconfig
  12428. +++ b/drivers/usb/gadget/Kconfig
  12429. @@ -118,10 +118,10 @@
  12430. config USB_GADGET_ATMEL_USBA
  12431. boolean "Atmel USBA"
  12432. select USB_GADGET_DUALSPEED
  12433. - depends on AVR32
  12434. + depends on AVR32 || ARCH_AT91CAP9
  12435. help
  12436. USBA is the integrated high-speed USB Device controller on
  12437. - the AT32AP700x processors from Atmel.
  12438. + the AT32AP700x and AT91CAP9 processors from Atmel.
  12439. config USB_ATMEL_USBA
  12440. tristate
  12441. --- a/drivers/video/atmel_lcdfb.c
  12442. +++ b/drivers/video/atmel_lcdfb.c
  12443. @@ -38,7 +38,9 @@
  12444. #endif
  12445. #if defined(CONFIG_ARCH_AT91)
  12446. -#define ATMEL_LCDFB_FBINFO_DEFAULT FBINFO_DEFAULT
  12447. +#define ATMEL_LCDFB_FBINFO_DEFAULT (FBINFO_DEFAULT \
  12448. + | FBINFO_PARTIAL_PAN_OK \
  12449. + | FBINFO_HWACCEL_YPAN)
  12450. static inline void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo,
  12451. struct fb_var_screeninfo *var)
  12452. @@ -176,7 +178,7 @@
  12453. .type = FB_TYPE_PACKED_PIXELS,
  12454. .visual = FB_VISUAL_TRUECOLOR,
  12455. .xpanstep = 0,
  12456. - .ypanstep = 0,
  12457. + .ypanstep = 1,
  12458. .ywrapstep = 0,
  12459. .accel = FB_ACCEL_NONE,
  12460. };
  12461. @@ -250,6 +252,8 @@
  12462. return -ENOMEM;
  12463. }
  12464. + memset(info->screen_base, 0, info->fix.smem_len);
  12465. +
  12466. return 0;
  12467. }
  12468. @@ -634,7 +638,6 @@
  12469. struct fb_info *info = sinfo->info;
  12470. int ret = 0;
  12471. - memset_io(info->screen_base, 0, info->fix.smem_len);
  12472. info->var.activate |= FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW;
  12473. dev_info(info->device,
  12474. @@ -764,6 +767,11 @@
  12475. info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
  12476. if (!info->screen_base)
  12477. goto release_intmem;
  12478. +
  12479. + /*
  12480. + * Don't clear the framebuffer -- someone may have set
  12481. + * up a splash image.
  12482. + */
  12483. } else {
  12484. /* alocate memory buffer */
  12485. ret = atmel_lcdfb_alloc_video_memory(sinfo);
  12486. --- a/fs/fs-writeback.c
  12487. +++ b/fs/fs-writeback.c
  12488. @@ -385,8 +385,6 @@
  12489. * WB_SYNC_HOLD is a hack for sys_sync(): reattach the inode to sb->s_dirty so
  12490. * that it can be located for waiting on in __writeback_single_inode().
  12491. *
  12492. - * Called under inode_lock.
  12493. - *
  12494. * If `bdi' is non-zero then we're being asked to writeback a specific queue.
  12495. * This function assumes that the blockdev superblock's inodes are backed by
  12496. * a variety of queues, so all inodes are searched. For other superblocks,
  12497. @@ -402,11 +400,12 @@
  12498. * on the writer throttling path, and we get decent balancing between many
  12499. * throttled threads: we don't want them all piling up on inode_sync_wait.
  12500. */
  12501. -static void
  12502. -sync_sb_inodes(struct super_block *sb, struct writeback_control *wbc)
  12503. +void generic_sync_sb_inodes(struct super_block *sb,
  12504. + struct writeback_control *wbc)
  12505. {
  12506. const unsigned long start = jiffies; /* livelock avoidance */
  12507. + spin_lock(&inode_lock);
  12508. if (!wbc->for_kupdate || list_empty(&sb->s_io))
  12509. queue_io(sb, wbc->older_than_this);
  12510. @@ -485,8 +484,16 @@
  12511. if (!list_empty(&sb->s_more_io))
  12512. wbc->more_io = 1;
  12513. }
  12514. + spin_unlock(&inode_lock);
  12515. return; /* Leave any unwritten inodes on s_io */
  12516. }
  12517. +EXPORT_SYMBOL_GPL(generic_sync_sb_inodes);
  12518. +
  12519. +static void sync_sb_inodes(struct super_block *sb,
  12520. + struct writeback_control *wbc)
  12521. +{
  12522. + generic_sync_sb_inodes(sb, wbc);
  12523. +}
  12524. /*
  12525. * Start writeback of dirty pagecache data against all unlocked inodes.
  12526. @@ -526,11 +533,8 @@
  12527. * be unmounted by the time it is released.
  12528. */
  12529. if (down_read_trylock(&sb->s_umount)) {
  12530. - if (sb->s_root) {
  12531. - spin_lock(&inode_lock);
  12532. + if (sb->s_root)
  12533. sync_sb_inodes(sb, wbc);
  12534. - spin_unlock(&inode_lock);
  12535. - }
  12536. up_read(&sb->s_umount);
  12537. }
  12538. spin_lock(&sb_lock);
  12539. @@ -568,9 +572,7 @@
  12540. (inodes_stat.nr_inodes - inodes_stat.nr_unused) +
  12541. nr_dirty + nr_unstable;
  12542. wbc.nr_to_write += wbc.nr_to_write / 2; /* Bit more for luck */
  12543. - spin_lock(&inode_lock);
  12544. sync_sb_inodes(sb, &wbc);
  12545. - spin_unlock(&inode_lock);
  12546. }
  12547. /*
  12548. --- a/include/asm-avr32/arch-at32ap/board.h
  12549. +++ b/include/asm-avr32/arch-at32ap/board.h
  12550. @@ -8,6 +8,12 @@
  12551. #define GPIO_PIN_NONE (-1)
  12552. +/*
  12553. + * Clock rates for various on-board oscillators. The number of entries
  12554. + * in this array is chip-dependent.
  12555. + */
  12556. +extern unsigned long at32_board_osc_rates[];
  12557. +
  12558. /* Add basic devices: system manager, interrupt controller, portmuxes, etc. */
  12559. void at32_add_system_devices(void);
  12560. @@ -36,11 +42,10 @@
  12561. struct atmel_lcdfb_info;
  12562. struct platform_device *
  12563. at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
  12564. - unsigned long fbmem_start, unsigned long fbmem_len);
  12565. + unsigned long fbmem_start, unsigned long fbmem_len,
  12566. + unsigned int pin_config);
  12567. -struct usba_platform_data {
  12568. - int vbus_pin;
  12569. -};
  12570. +struct usba_platform_data;
  12571. struct platform_device *
  12572. at32_add_device_usba(unsigned int id, struct usba_platform_data *data);
  12573. @@ -68,8 +73,17 @@
  12574. struct platform_device *
  12575. at32_add_device_ssc(unsigned int id, unsigned int flags);
  12576. -struct platform_device *at32_add_device_twi(unsigned int id);
  12577. -struct platform_device *at32_add_device_mci(unsigned int id);
  12578. +struct i2c_board_info;
  12579. +struct platform_device *at32_add_device_twi(unsigned int id,
  12580. + struct i2c_board_info *b,
  12581. + unsigned int n);
  12582. +
  12583. +struct mci_platform_data {
  12584. + int detect_pin;
  12585. + int wp_pin;
  12586. +};
  12587. +struct platform_device *
  12588. +at32_add_device_mci(unsigned int id, struct mci_platform_data *data);
  12589. struct platform_device *at32_add_device_ac97c(unsigned int id);
  12590. struct platform_device *at32_add_device_abdac(unsigned int id);
  12591. @@ -84,4 +98,20 @@
  12592. at32_add_device_cf(unsigned int id, unsigned int extint,
  12593. struct cf_platform_data *data);
  12594. +struct platform_device *
  12595. +at32_add_device_psif(unsigned int id);
  12596. +
  12597. +/* NAND / SmartMedia */
  12598. +struct atmel_nand_data {
  12599. + int enable_pin; /* chip enable */
  12600. + int det_pin; /* card detect */
  12601. + int rdy_pin; /* ready/busy */
  12602. + u8 ale; /* address line number connected to ALE */
  12603. + u8 cle; /* address line number connected to CLE */
  12604. + u8 bus_width_16; /* buswidth is 16 bit */
  12605. + struct mtd_partition *(*partition_info)(int size, int *num_partitions);
  12606. +};
  12607. +struct platform_device *
  12608. +at32_add_device_nand(unsigned int id, struct atmel_nand_data *data);
  12609. +
  12610. #endif /* __ASM_ARCH_BOARD_H */
  12611. --- a/include/asm-avr32/arch-at32ap/init.h
  12612. +++ b/include/asm-avr32/arch-at32ap/init.h
  12613. @@ -13,10 +13,6 @@
  12614. void setup_platform(void);
  12615. void setup_board(void);
  12616. -/* Called by setup_platform */
  12617. -void at32_clock_init(void);
  12618. -void at32_portmux_init(void);
  12619. -
  12620. void at32_setup_serial_console(unsigned int usart_id);
  12621. #endif /* __ASM_AVR32_AT32AP_INIT_H__ */
  12622. --- /dev/null
  12623. +++ b/include/asm-avr32/arch-at32ap/pm.h
  12624. @@ -0,0 +1,51 @@
  12625. +/*
  12626. + * AVR32 AP Power Management.
  12627. + *
  12628. + * Copyright (C) 2008 Atmel Corporation
  12629. + *
  12630. + * This program is free software; you can redistribute it and/or modify
  12631. + * it under the terms of the GNU General Public License version 2 as
  12632. + * published by the Free Software Foundation.
  12633. + */
  12634. +#ifndef __ASM_AVR32_ARCH_PM_H
  12635. +#define __ASM_AVR32_ARCH_PM_H
  12636. +
  12637. +/* Possible arguments to the "sleep" instruction */
  12638. +#define CPU_SLEEP_IDLE 0
  12639. +#define CPU_SLEEP_FROZEN 1
  12640. +#define CPU_SLEEP_STANDBY 2
  12641. +#define CPU_SLEEP_STOP 3
  12642. +#define CPU_SLEEP_STATIC 5
  12643. +
  12644. +#ifndef __ASSEMBLY__
  12645. +extern void cpu_enter_idle(void);
  12646. +extern void cpu_enter_standby(unsigned long sdramc_base);
  12647. +
  12648. +extern bool disable_idle_sleep;
  12649. +
  12650. +static inline void cpu_disable_idle_sleep(void)
  12651. +{
  12652. + disable_idle_sleep = true;
  12653. +}
  12654. +
  12655. +static inline void cpu_enable_idle_sleep(void)
  12656. +{
  12657. + disable_idle_sleep = false;
  12658. +}
  12659. +
  12660. +static inline void cpu_idle_sleep(void)
  12661. +{
  12662. + /*
  12663. + * If we're using the COUNT and COMPARE registers for
  12664. + * timekeeping, we can't use the IDLE state.
  12665. + */
  12666. + if (disable_idle_sleep)
  12667. + cpu_relax();
  12668. + else
  12669. + cpu_enter_idle();
  12670. +}
  12671. +
  12672. +void intc_set_suspend_handler(unsigned long offset);
  12673. +#endif
  12674. +
  12675. +#endif /* __ASM_AVR32_ARCH_PM_H */
  12676. --- a/include/asm-avr32/arch-at32ap/portmux.h
  12677. +++ b/include/asm-avr32/arch-at32ap/portmux.h
  12678. @@ -26,4 +26,16 @@
  12679. void at32_select_gpio(unsigned int pin, unsigned long flags);
  12680. void at32_reserve_pin(unsigned int pin);
  12681. +#ifdef CONFIG_GPIO_DEV
  12682. +
  12683. +/* Gang allocators and accessors; used by the GPIO /dev driver */
  12684. +int at32_gpio_port_is_valid(unsigned int port);
  12685. +int at32_select_gpio_pins(unsigned int port, u32 pins, u32 oe_mask);
  12686. +void at32_deselect_pins(unsigned int port, u32 pins);
  12687. +
  12688. +u32 at32_gpio_get_value_multiple(unsigned int port, u32 pins);
  12689. +void at32_gpio_set_value_multiple(unsigned int port, u32 value, u32 mask);
  12690. +
  12691. +#endif /* CONFIG_GPIO_DEV */
  12692. +
  12693. #endif /* __ASM_ARCH_PORTMUX_H__ */
  12694. --- /dev/null
  12695. +++ b/include/asm-avr32/arch-at32ap/sram.h
  12696. @@ -0,0 +1,30 @@
  12697. +/*
  12698. + * Simple SRAM allocator
  12699. + *
  12700. + * Copyright (C) 2008 Atmel Corporation
  12701. + *
  12702. + * This program is free software; you can redistribute it and/or modify
  12703. + * it under the terms of the GNU General Public License version 2 as
  12704. + * published by the Free Software Foundation.
  12705. + */
  12706. +#ifndef __ASM_AVR32_ARCH_SRAM_H
  12707. +#define __ASM_AVR32_ARCH_SRAM_H
  12708. +
  12709. +#include <linux/genalloc.h>
  12710. +
  12711. +extern struct gen_pool *sram_pool;
  12712. +
  12713. +static inline unsigned long sram_alloc(size_t len)
  12714. +{
  12715. + if (!sram_pool)
  12716. + return 0UL;
  12717. +
  12718. + return gen_pool_alloc(sram_pool, len);
  12719. +}
  12720. +
  12721. +static inline void sram_free(unsigned long addr, size_t len)
  12722. +{
  12723. + return gen_pool_free(sram_pool, addr, len);
  12724. +}
  12725. +
  12726. +#endif /* __ASM_AVR32_ARCH_SRAM_H */
  12727. --- a/include/asm-avr32/arch-at32ap/time.h
  12728. +++ /dev/null
  12729. @@ -1,112 +0,0 @@
  12730. -/*
  12731. - * Copyright (C) 2007 Atmel Corporation
  12732. - *
  12733. - * This program is free software; you can redistribute it and/or modify
  12734. - * it under the terms of the GNU General Public License version 2 as
  12735. - * published by the Free Software Foundation.
  12736. - */
  12737. -
  12738. -#ifndef _ASM_AVR32_ARCH_AT32AP_TIME_H
  12739. -#define _ASM_AVR32_ARCH_AT32AP_TIME_H
  12740. -
  12741. -#include <linux/platform_device.h>
  12742. -
  12743. -extern struct irqaction timer_irqaction;
  12744. -extern struct platform_device at32_systc0_device;
  12745. -extern void local_timer_interrupt(int irq, void *dev_id);
  12746. -
  12747. -#define TIMER_BCR 0x000000c0
  12748. -#define TIMER_BCR_SYNC 0
  12749. -#define TIMER_BMR 0x000000c4
  12750. -#define TIMER_BMR_TC0XC0S 0
  12751. -#define TIMER_BMR_TC1XC1S 2
  12752. -#define TIMER_BMR_TC2XC2S 4
  12753. -#define TIMER_CCR 0x00000000
  12754. -#define TIMER_CCR_CLKDIS 1
  12755. -#define TIMER_CCR_CLKEN 0
  12756. -#define TIMER_CCR_SWTRG 2
  12757. -#define TIMER_CMR 0x00000004
  12758. -#define TIMER_CMR_ABETRG 10
  12759. -#define TIMER_CMR_ACPA 16
  12760. -#define TIMER_CMR_ACPC 18
  12761. -#define TIMER_CMR_AEEVT 20
  12762. -#define TIMER_CMR_ASWTRG 22
  12763. -#define TIMER_CMR_BCPB 24
  12764. -#define TIMER_CMR_BCPC 26
  12765. -#define TIMER_CMR_BEEVT 28
  12766. -#define TIMER_CMR_BSWTRG 30
  12767. -#define TIMER_CMR_BURST 4
  12768. -#define TIMER_CMR_CLKI 3
  12769. -#define TIMER_CMR_CPCDIS 7
  12770. -#define TIMER_CMR_CPCSTOP 6
  12771. -#define TIMER_CMR_CPCTRG 14
  12772. -#define TIMER_CMR_EEVT 10
  12773. -#define TIMER_CMR_EEVTEDG 8
  12774. -#define TIMER_CMR_ENETRG 12
  12775. -#define TIMER_CMR_ETRGEDG 8
  12776. -#define TIMER_CMR_LDBDIS 7
  12777. -#define TIMER_CMR_LDBSTOP 6
  12778. -#define TIMER_CMR_LDRA 16
  12779. -#define TIMER_CMR_LDRB 18
  12780. -#define TIMER_CMR_TCCLKS 0
  12781. -#define TIMER_CMR_WAVE 15
  12782. -#define TIMER_CMR_WAVSEL 13
  12783. -#define TIMER_CV 0x00000010
  12784. -#define TIMER_CV_CV 0
  12785. -#define TIMER_IDR 0x00000028
  12786. -#define TIMER_IDR_COVFS 0
  12787. -#define TIMER_IDR_CPAS 2
  12788. -#define TIMER_IDR_CPBS 3
  12789. -#define TIMER_IDR_CPCS 4
  12790. -#define TIMER_IDR_ETRGS 7
  12791. -#define TIMER_IDR_LDRAS 5
  12792. -#define TIMER_IDR_LDRBS 6
  12793. -#define TIMER_IDR_LOVRS 1
  12794. -#define TIMER_IER 0x00000024
  12795. -#define TIMER_IER_COVFS 0
  12796. -#define TIMER_IER_CPAS 2
  12797. -#define TIMER_IER_CPBS 3
  12798. -#define TIMER_IER_CPCS 4
  12799. -#define TIMER_IER_ETRGS 7
  12800. -#define TIMER_IER_LDRAS 5
  12801. -#define TIMER_IER_LDRBS 6
  12802. -#define TIMER_IER_LOVRS 1
  12803. -#define TIMER_IMR 0x0000002c
  12804. -#define TIMER_IMR_COVFS 0
  12805. -#define TIMER_IMR_CPAS 2
  12806. -#define TIMER_IMR_CPBS 3
  12807. -#define TIMER_IMR_CPCS 4
  12808. -#define TIMER_IMR_ETRGS 7
  12809. -#define TIMER_IMR_LDRAS 5
  12810. -#define TIMER_IMR_LDRBS 6
  12811. -#define TIMER_IMR_LOVRS 1
  12812. -#define TIMER_RA 0x00000014
  12813. -#define TIMER_RA_RA 0
  12814. -#define TIMER_RB 0x00000018
  12815. -#define TIMER_RB_RB 0
  12816. -#define TIMER_RC 0x0000001c
  12817. -#define TIMER_RC_RC 0
  12818. -#define TIMER_SR 0x00000020
  12819. -#define TIMER_SR_CLKSTA 16
  12820. -#define TIMER_SR_COVFS 0
  12821. -#define TIMER_SR_CPAS 2
  12822. -#define TIMER_SR_CPBS 3
  12823. -#define TIMER_SR_CPCS 4
  12824. -#define TIMER_SR_ETRGS 7
  12825. -#define TIMER_SR_LDRAS 5
  12826. -#define TIMER_SR_LDRBS 6
  12827. -#define TIMER_SR_LOVRS 1
  12828. -#define TIMER_SR_MTIOA 17
  12829. -#define TIMER_SR_MTIOB 18
  12830. -
  12831. -/* Bit manipulation macros */
  12832. -#define TIMER_BIT(name) (1 << TIMER_##name)
  12833. -#define TIMER_BF(name,value) ((value) << TIMER_##name)
  12834. -
  12835. -/* Register access macros */
  12836. -#define timer_read(port,instance,reg) \
  12837. - __raw_readl(port + (0x40 * instance) + TIMER_##reg)
  12838. -#define timer_write(port,instance,reg,value) \
  12839. - __raw_writel((value), port + (0x40 * instance) + TIMER_##reg)
  12840. -
  12841. -#endif /* _ASM_AVR32_ARCH_AT32AP_TIME_H */
  12842. --- a/include/asm-avr32/asm.h
  12843. +++ b/include/asm-avr32/asm.h
  12844. @@ -12,10 +12,10 @@
  12845. #include <asm/asm-offsets.h>
  12846. #include <asm/thread_info.h>
  12847. -#define mask_interrupts ssrf SR_GM_BIT
  12848. -#define mask_exceptions ssrf SR_EM_BIT
  12849. -#define unmask_interrupts csrf SR_GM_BIT
  12850. -#define unmask_exceptions csrf SR_EM_BIT
  12851. +#define mask_interrupts ssrf SYSREG_GM_OFFSET
  12852. +#define mask_exceptions ssrf SYSREG_EM_OFFSET
  12853. +#define unmask_interrupts csrf SYSREG_GM_OFFSET
  12854. +#define unmask_exceptions csrf SYSREG_EM_OFFSET
  12855. #ifdef CONFIG_FRAME_POINTER
  12856. .macro save_fp
  12857. --- /dev/null
  12858. +++ b/include/asm-avr32/dma-controller.h
  12859. @@ -0,0 +1,166 @@
  12860. +/*
  12861. + * Copyright (C) 2005-2006 Atmel Corporation
  12862. + *
  12863. + * This program is free software; you can redistribute it and/or modify
  12864. + * it under the terms of the GNU General Public License version 2 as
  12865. + * published by the Free Software Foundation.
  12866. + */
  12867. +#ifndef __ASM_AVR32_DMA_CONTROLLER_H
  12868. +#define __ASM_AVR32_DMA_CONTROLLER_H
  12869. +
  12870. +#include <linux/device.h>
  12871. +
  12872. +#define DMA_DIR_MEM_TO_MEM 0x0000
  12873. +#define DMA_DIR_MEM_TO_PERIPH 0x0001
  12874. +#define DMA_DIR_PERIPH_TO_MEM 0x0002
  12875. +#define DMA_DIR_PERIPH_TO_PERIPH 0x0003
  12876. +
  12877. +#define DMA_WIDTH_8BIT 0
  12878. +#define DMA_WIDTH_16BIT 1
  12879. +#define DMA_WIDTH_32BIT 2
  12880. +
  12881. +struct dma_request {
  12882. + struct dma_controller *dmac;
  12883. + struct list_head list;
  12884. +
  12885. + unsigned short channel;
  12886. +
  12887. + void (*xfer_complete)(struct dma_request *req);
  12888. + void (*block_complete)(struct dma_request *req);
  12889. + void (*error)(struct dma_request *req);
  12890. +};
  12891. +
  12892. +struct dma_request_sg {
  12893. + struct dma_request req;
  12894. +
  12895. + int nr_sg;
  12896. + struct scatterlist *sg;
  12897. + unsigned long block_size;
  12898. + unsigned int nr_blocks;
  12899. +
  12900. + dma_addr_t data_reg;
  12901. + unsigned short periph_id;
  12902. +
  12903. + unsigned char direction;
  12904. + unsigned char width;
  12905. +};
  12906. +#define to_dma_request_sg(_req) \
  12907. + container_of(_req, struct dma_request_sg, req)
  12908. +
  12909. +struct dma_request_cyclic {
  12910. + struct dma_request req;
  12911. +
  12912. + int periods;
  12913. + unsigned long buffer_size;
  12914. +
  12915. + dma_addr_t buffer_start;
  12916. + dma_addr_t data_reg;
  12917. +
  12918. + unsigned short periph_id;
  12919. + unsigned char direction;
  12920. + unsigned char width;
  12921. +
  12922. + void *dev_id;
  12923. +};
  12924. +#define to_dma_request_cyclic(_req) \
  12925. + container_of(_req, struct dma_request_cyclic, req)
  12926. +
  12927. +struct dma_request_memcpy {
  12928. + struct dma_request req;
  12929. +
  12930. + dma_addr_t src_addr;
  12931. + unsigned int src_width;
  12932. + unsigned int src_stride;
  12933. +
  12934. + dma_addr_t dst_addr;
  12935. + unsigned int dst_width;
  12936. + unsigned int dst_stride;
  12937. +
  12938. + size_t length;
  12939. +
  12940. + unsigned short src_reverse:1;
  12941. + unsigned short dst_reverse:1;
  12942. +};
  12943. +#define to_dma_request_memcpy(_req) \
  12944. + container_of(_req, struct dma_request_memcpy, req)
  12945. +
  12946. +struct dma_controller {
  12947. + struct list_head list;
  12948. + int id;
  12949. + struct device *dev;
  12950. +
  12951. + int (*alloc_channel)(struct dma_controller *dmac);
  12952. + void (*release_channel)(struct dma_controller *dmac,
  12953. + int channel);
  12954. + int (*prepare_request_sg)(struct dma_controller *dmac,
  12955. + struct dma_request_sg *req);
  12956. + int (*prepare_request_cyclic)(struct dma_controller *dmac,
  12957. + struct dma_request_cyclic *req);
  12958. + int (*prepare_request_memcpy)(struct dma_controller *dmac,
  12959. + struct dma_request_memcpy *req);
  12960. + int (*start_request)(struct dma_controller *dmac,
  12961. + unsigned int channel);
  12962. + int (*stop_request)(struct dma_controller *dmac,
  12963. + unsigned int channel);
  12964. + dma_addr_t (*get_current_pos)(struct dma_controller *dmac,
  12965. + unsigned int channel);
  12966. +};
  12967. +
  12968. +static inline int
  12969. +dma_alloc_channel(struct dma_controller *dmac)
  12970. +{
  12971. + return dmac->alloc_channel(dmac);
  12972. +}
  12973. +
  12974. +static inline void
  12975. +dma_release_channel(struct dma_controller *dmac, int chan)
  12976. +{
  12977. + dmac->release_channel(dmac, chan);
  12978. +}
  12979. +
  12980. +static inline int
  12981. +dma_prepare_request_sg(struct dma_controller *dmac,
  12982. + struct dma_request_sg *req)
  12983. +{
  12984. + return dmac->prepare_request_sg(dmac, req);
  12985. +}
  12986. +
  12987. +static inline int
  12988. +dma_prepare_request_cyclic(struct dma_controller *dmac,
  12989. + struct dma_request_cyclic *req)
  12990. +{
  12991. + return dmac->prepare_request_cyclic(dmac, req);
  12992. +}
  12993. +
  12994. +static inline int
  12995. +dma_prepare_request_memcpy(struct dma_controller *dmac,
  12996. + struct dma_request_memcpy *req)
  12997. +{
  12998. + return dmac->prepare_request_memcpy(dmac, req);
  12999. +}
  13000. +
  13001. +static inline int
  13002. +dma_start_request(struct dma_controller *dmac,
  13003. + unsigned int channel)
  13004. +{
  13005. + return dmac->start_request(dmac, channel);
  13006. +}
  13007. +
  13008. +static inline int
  13009. +dma_stop_request(struct dma_controller *dmac,
  13010. + unsigned int channel)
  13011. +{
  13012. + return dmac->stop_request(dmac, channel);
  13013. +}
  13014. +
  13015. +static inline dma_addr_t
  13016. +dma_get_current_pos(struct dma_controller *dmac,
  13017. + unsigned int channel)
  13018. +{
  13019. + return dmac->get_current_pos(dmac, channel);
  13020. +}
  13021. +
  13022. +extern int register_dma_controller(struct dma_controller *dmac);
  13023. +extern struct dma_controller *find_dma_controller(int id);
  13024. +
  13025. +#endif /* __ASM_AVR32_DMA_CONTROLLER_H */
  13026. --- a/include/asm-avr32/intc.h
  13027. +++ /dev/null
  13028. @@ -1,128 +0,0 @@
  13029. -#ifndef __ASM_AVR32_INTC_H
  13030. -#define __ASM_AVR32_INTC_H
  13031. -
  13032. -#include <linux/sysdev.h>
  13033. -#include <linux/interrupt.h>
  13034. -
  13035. -struct irq_controller;
  13036. -struct irqaction;
  13037. -struct pt_regs;
  13038. -
  13039. -struct platform_device;
  13040. -
  13041. -/* Information about the internal interrupt controller */
  13042. -struct intc_device {
  13043. - /* ioremapped address of configuration block */
  13044. - void __iomem *regs;
  13045. -
  13046. - /* the physical device */
  13047. - struct platform_device *pdev;
  13048. -
  13049. - /* Number of interrupt lines per group. */
  13050. - unsigned int irqs_per_group;
  13051. -
  13052. - /* The highest group ID + 1 */
  13053. - unsigned int nr_groups;
  13054. -
  13055. - /*
  13056. - * Bitfield indicating which groups are actually in use. The
  13057. - * size of the array is
  13058. - * ceil(group_max / (8 * sizeof(unsigned int))).
  13059. - */
  13060. - unsigned int group_mask[];
  13061. -};
  13062. -
  13063. -struct irq_controller_class {
  13064. - /*
  13065. - * A short name identifying this kind of controller.
  13066. - */
  13067. - const char *typename;
  13068. - /*
  13069. - * Handle the IRQ. Must do any necessary acking and masking.
  13070. - */
  13071. - irqreturn_t (*handle)(int irq, void *dev_id, struct pt_regs *regs);
  13072. - /*
  13073. - * Register a new IRQ handler.
  13074. - */
  13075. - int (*setup)(struct irq_controller *ctrl, unsigned int irq,
  13076. - struct irqaction *action);
  13077. - /*
  13078. - * Unregister a IRQ handler.
  13079. - */
  13080. - void (*free)(struct irq_controller *ctrl, unsigned int irq,
  13081. - void *dev_id);
  13082. - /*
  13083. - * Mask the IRQ in the interrupt controller.
  13084. - */
  13085. - void (*mask)(struct irq_controller *ctrl, unsigned int irq);
  13086. - /*
  13087. - * Unmask the IRQ in the interrupt controller.
  13088. - */
  13089. - void (*unmask)(struct irq_controller *ctrl, unsigned int irq);
  13090. - /*
  13091. - * Set the type of the IRQ. See below for possible types.
  13092. - * Return -EINVAL if a given type is not supported
  13093. - */
  13094. - int (*set_type)(struct irq_controller *ctrl, unsigned int irq,
  13095. - unsigned int type);
  13096. - /*
  13097. - * Return the IRQ type currently set
  13098. - */
  13099. - unsigned int (*get_type)(struct irq_controller *ctrl, unsigned int irq);
  13100. -};
  13101. -
  13102. -struct irq_controller {
  13103. - struct irq_controller_class *class;
  13104. - unsigned int irq_group;
  13105. - unsigned int first_irq;
  13106. - unsigned int nr_irqs;
  13107. - struct list_head list;
  13108. -};
  13109. -
  13110. -struct intc_group_desc {
  13111. - struct irq_controller *ctrl;
  13112. - irqreturn_t (*handle)(int, void *, struct pt_regs *);
  13113. - unsigned long flags;
  13114. - void *dev_id;
  13115. - const char *devname;
  13116. -};
  13117. -
  13118. -/*
  13119. - * The internal interrupt controller. Defined in board/part-specific
  13120. - * devices.c.
  13121. - * TODO: Should probably be defined per-cpu.
  13122. - */
  13123. -extern struct intc_device intc;
  13124. -
  13125. -extern int request_internal_irq(unsigned int irq,
  13126. - irqreturn_t (*handler)(int, void *, struct pt_regs *),
  13127. - unsigned long irqflags,
  13128. - const char *devname, void *dev_id);
  13129. -extern void free_internal_irq(unsigned int irq);
  13130. -
  13131. -/* Only used by time_init() */
  13132. -extern int setup_internal_irq(unsigned int irq, struct intc_group_desc *desc);
  13133. -
  13134. -/*
  13135. - * Set interrupt priority for a given group. `group' can be found by
  13136. - * using irq_to_group(irq). Priority can be from 0 (lowest) to 3
  13137. - * (highest). Higher-priority interrupts will preempt lower-priority
  13138. - * interrupts (unless interrupts are masked globally).
  13139. - *
  13140. - * This function does not check for conflicts within a group.
  13141. - */
  13142. -extern int intc_set_priority(unsigned int group,
  13143. - unsigned int priority);
  13144. -
  13145. -/*
  13146. - * Returns a bitmask of pending interrupts in a group.
  13147. - */
  13148. -extern unsigned long intc_get_pending(unsigned int group);
  13149. -
  13150. -/*
  13151. - * Register a new external interrupt controller. Returns the first
  13152. - * external IRQ number that is assigned to the new controller.
  13153. - */
  13154. -extern int intc_register_controller(struct irq_controller *ctrl);
  13155. -
  13156. -#endif /* __ASM_AVR32_INTC_H */
  13157. --- a/include/asm-avr32/irq.h
  13158. +++ b/include/asm-avr32/irq.h
  13159. @@ -14,6 +14,11 @@
  13160. #ifndef __ASSEMBLER__
  13161. int nmi_enable(void);
  13162. void nmi_disable(void);
  13163. +
  13164. +/*
  13165. + * Returns a bitmask of pending interrupts in a group.
  13166. + */
  13167. +extern unsigned long intc_get_pending(unsigned int group);
  13168. #endif
  13169. #endif /* __ASM_AVR32_IOCTLS_H */
  13170. --- a/include/asm-avr32/page.h
  13171. +++ b/include/asm-avr32/page.h
  13172. @@ -8,13 +8,11 @@
  13173. #ifndef __ASM_AVR32_PAGE_H
  13174. #define __ASM_AVR32_PAGE_H
  13175. +#include <linux/const.h>
  13176. +
  13177. /* PAGE_SHIFT determines the page size */
  13178. #define PAGE_SHIFT 12
  13179. -#ifdef __ASSEMBLY__
  13180. -#define PAGE_SIZE (1 << PAGE_SHIFT)
  13181. -#else
  13182. -#define PAGE_SIZE (1UL << PAGE_SHIFT)
  13183. -#endif
  13184. +#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
  13185. #define PAGE_MASK (~(PAGE_SIZE-1))
  13186. #define PTE_MASK PAGE_MASK
  13187. --- a/include/asm-avr32/pci.h
  13188. +++ b/include/asm-avr32/pci.h
  13189. @@ -5,4 +5,6 @@
  13190. #define PCI_DMA_BUS_IS_PHYS (1)
  13191. +#include <asm-generic/pci-dma-compat.h>
  13192. +
  13193. #endif /* __ASM_AVR32_PCI_H__ */
  13194. --- /dev/null
  13195. +++ b/include/asm-avr32/serial.h
  13196. @@ -0,0 +1,13 @@
  13197. +#ifndef _ASM_SERIAL_H
  13198. +#define _ASM_SERIAL_H
  13199. +
  13200. +/*
  13201. + * This assumes you have a 1.8432 MHz clock for your UART.
  13202. + *
  13203. + * It'd be nice if someone built a serial card with a 24.576 MHz
  13204. + * clock, since the 16550A is capable of handling a top speed of 1.5
  13205. + * megabits/second; but this requires the faster clock.
  13206. + */
  13207. +#define BASE_BAUD (1843200 / 16)
  13208. +
  13209. +#endif /* _ASM_SERIAL_H */
  13210. --- a/include/asm-avr32/thread_info.h
  13211. +++ b/include/asm-avr32/thread_info.h
  13212. @@ -88,6 +88,7 @@
  13213. #define TIF_MEMDIE 6
  13214. #define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */
  13215. #define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */
  13216. +#define TIF_FREEZE 29
  13217. #define TIF_DEBUG 30 /* debugging enabled */
  13218. #define TIF_USERSPACE 31 /* true if FS sets userspace */
  13219. --- /dev/null
  13220. +++ b/include/asm-avr32/xor.h
  13221. @@ -0,0 +1,6 @@
  13222. +#ifndef _ASM_XOR_H
  13223. +#define _ASM_XOR_H
  13224. +
  13225. +#include <asm-generic/xor.h>
  13226. +
  13227. +#endif
  13228. --- /dev/null
  13229. +++ b/include/linux/atmel_tc.h
  13230. @@ -0,0 +1,252 @@
  13231. +/*
  13232. + * Timer/Counter Unit (TC) registers.
  13233. + *
  13234. + * This program is free software; you can redistribute it and/or modify
  13235. + * it under the terms of the GNU General Public License as published by
  13236. + * the Free Software Foundation; either version 2 of the License, or
  13237. + * (at your option) any later version.
  13238. + */
  13239. +
  13240. +#ifndef ATMEL_TC_H
  13241. +#define ATMEL_TC_H
  13242. +
  13243. +#include <linux/compiler.h>
  13244. +#include <linux/list.h>
  13245. +
  13246. +/*
  13247. + * Many 32-bit Atmel SOCs include one or more TC blocks, each of which holds
  13248. + * three general-purpose 16-bit timers. These timers share one register bank.
  13249. + * Depending on the SOC, each timer may have its own clock and IRQ, or those
  13250. + * may be shared by the whole TC block.
  13251. + *
  13252. + * These TC blocks may have up to nine external pins: TCLK0..2 signals for
  13253. + * clocks or clock gates, and per-timer TIOA and TIOB signals used for PWM
  13254. + * or triggering. Those pins need to be set up for use with the TC block,
  13255. + * else they will be used as GPIOs or for a different controller.
  13256. + *
  13257. + * Although we expect each TC block to have a platform_device node, those
  13258. + * nodes are not what drivers bind to. Instead, they ask for a specific
  13259. + * TC block, by number ... which is a common approach on systems with many
  13260. + * timers. Then they use clk_get() and platform_get_irq() to get clock and
  13261. + * IRQ resources.
  13262. + */
  13263. +
  13264. +struct clk;
  13265. +
  13266. +/**
  13267. + * struct atmel_tc - information about a Timer/Counter Block
  13268. + * @pdev: physical device
  13269. + * @iomem: resource associated with the I/O register
  13270. + * @regs: mapping through which the I/O registers can be accessed
  13271. + * @irq: irq for each of the three channels
  13272. + * @clk: internal clock source for each of the three channels
  13273. + * @node: list node, for tclib internal use
  13274. + *
  13275. + * On some platforms, each TC channel has its own clocks and IRQs,
  13276. + * while on others, all TC channels share the same clock and IRQ.
  13277. + * Drivers should clk_enable() all the clocks they need even though
  13278. + * all the entries in @clk may point to the same physical clock.
  13279. + * Likewise, drivers should request irqs independently for each
  13280. + * channel, but they must use IRQF_SHARED in case some of the entries
  13281. + * in @irq are actually the same IRQ.
  13282. + */
  13283. +struct atmel_tc {
  13284. + struct platform_device *pdev;
  13285. + struct resource *iomem;
  13286. + void __iomem *regs;
  13287. + int irq[3];
  13288. + struct clk *clk[3];
  13289. + struct list_head node;
  13290. +};
  13291. +
  13292. +extern struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name);
  13293. +extern void atmel_tc_free(struct atmel_tc *tc);
  13294. +
  13295. +/* platform-specific ATMEL_TC_TIMER_CLOCKx divisors (0 means 32KiHz) */
  13296. +extern const u8 atmel_tc_divisors[5];
  13297. +
  13298. +
  13299. +/*
  13300. + * Two registers have block-wide controls. These are: configuring the three
  13301. + * "external" clocks (or event sources) used by the timer channels; and
  13302. + * synchronizing the timers by resetting them all at once.
  13303. + *
  13304. + * "External" can mean "external to chip" using the TCLK0, TCLK1, or TCLK2
  13305. + * signals. Or, it can mean "external to timer", using the TIOA output from
  13306. + * one of the other two timers that's being run in waveform mode.
  13307. + */
  13308. +
  13309. +#define ATMEL_TC_BCR 0xc0 /* TC Block Control Register */
  13310. +#define ATMEL_TC_SYNC (1 << 0) /* synchronize timers */
  13311. +
  13312. +#define ATMEL_TC_BMR 0xc4 /* TC Block Mode Register */
  13313. +#define ATMEL_TC_TC0XC0S (3 << 0) /* external clock 0 source */
  13314. +#define ATMEL_TC_TC0XC0S_TCLK0 (0 << 0)
  13315. +#define ATMEL_TC_TC0XC0S_NONE (1 << 0)
  13316. +#define ATMEL_TC_TC0XC0S_TIOA1 (2 << 0)
  13317. +#define ATMEL_TC_TC0XC0S_TIOA2 (3 << 0)
  13318. +#define ATMEL_TC_TC1XC1S (3 << 2) /* external clock 1 source */
  13319. +#define ATMEL_TC_TC1XC1S_TCLK1 (0 << 2)
  13320. +#define ATMEL_TC_TC1XC1S_NONE (1 << 2)
  13321. +#define ATMEL_TC_TC1XC1S_TIOA0 (2 << 2)
  13322. +#define ATMEL_TC_TC1XC1S_TIOA2 (3 << 2)
  13323. +#define ATMEL_TC_TC2XC2S (3 << 4) /* external clock 2 source */
  13324. +#define ATMEL_TC_TC2XC2S_TCLK2 (0 << 4)
  13325. +#define ATMEL_TC_TC2XC2S_NONE (1 << 4)
  13326. +#define ATMEL_TC_TC2XC2S_TIOA0 (2 << 4)
  13327. +#define ATMEL_TC_TC2XC2S_TIOA1 (3 << 4)
  13328. +
  13329. +
  13330. +/*
  13331. + * Each TC block has three "channels", each with one counter and controls.
  13332. + *
  13333. + * Note that the semantics of ATMEL_TC_TIMER_CLOCKx (input clock selection
  13334. + * when it's not "external") is silicon-specific. AT91 platforms use one
  13335. + * set of definitions; AVR32 platforms use a different set. Don't hard-wire
  13336. + * such knowledge into your code, use the global "atmel_tc_divisors" ...
  13337. + * where index N is the divisor for clock N+1, else zero to indicate it uses
  13338. + * the 32 KiHz clock.
  13339. + *
  13340. + * The timers can be chained in various ways, and operated in "waveform"
  13341. + * generation mode (including PWM) or "capture" mode (to time events). In
  13342. + * both modes, behavior can be configured in many ways.
  13343. + *
  13344. + * Each timer has two I/O pins, TIOA and TIOB. Waveform mode uses TIOA as a
  13345. + * PWM output, and TIOB as either another PWM or as a trigger. Capture mode
  13346. + * uses them only as inputs.
  13347. + */
  13348. +#define ATMEL_TC_CHAN(idx) ((idx)*0x40)
  13349. +#define ATMEL_TC_REG(idx, reg) (ATMEL_TC_CHAN(idx) + ATMEL_TC_ ## reg)
  13350. +
  13351. +#define ATMEL_TC_CCR 0x00 /* Channel Control Register */
  13352. +#define ATMEL_TC_CLKEN (1 << 0) /* clock enable */
  13353. +#define ATMEL_TC_CLKDIS (1 << 1) /* clock disable */
  13354. +#define ATMEL_TC_SWTRG (1 << 2) /* software trigger */
  13355. +
  13356. +#define ATMEL_TC_CMR 0x04 /* Channel Mode Register */
  13357. +
  13358. +/* Both modes share some CMR bits */
  13359. +#define ATMEL_TC_TCCLKS (7 << 0) /* clock source */
  13360. +#define ATMEL_TC_TIMER_CLOCK1 (0 << 0)
  13361. +#define ATMEL_TC_TIMER_CLOCK2 (1 << 0)
  13362. +#define ATMEL_TC_TIMER_CLOCK3 (2 << 0)
  13363. +#define ATMEL_TC_TIMER_CLOCK4 (3 << 0)
  13364. +#define ATMEL_TC_TIMER_CLOCK5 (4 << 0)
  13365. +#define ATMEL_TC_XC0 (5 << 0)
  13366. +#define ATMEL_TC_XC1 (6 << 0)
  13367. +#define ATMEL_TC_XC2 (7 << 0)
  13368. +#define ATMEL_TC_CLKI (1 << 3) /* clock invert */
  13369. +#define ATMEL_TC_BURST (3 << 4) /* clock gating */
  13370. +#define ATMEL_TC_GATE_NONE (0 << 4)
  13371. +#define ATMEL_TC_GATE_XC0 (1 << 4)
  13372. +#define ATMEL_TC_GATE_XC1 (2 << 4)
  13373. +#define ATMEL_TC_GATE_XC2 (3 << 4)
  13374. +#define ATMEL_TC_WAVE (1 << 15) /* true = Waveform mode */
  13375. +
  13376. +/* CAPTURE mode CMR bits */
  13377. +#define ATMEL_TC_LDBSTOP (1 << 6) /* counter stops on RB load */
  13378. +#define ATMEL_TC_LDBDIS (1 << 7) /* counter disable on RB load */
  13379. +#define ATMEL_TC_ETRGEDG (3 << 8) /* external trigger edge */
  13380. +#define ATMEL_TC_ETRGEDG_NONE (0 << 8)
  13381. +#define ATMEL_TC_ETRGEDG_RISING (1 << 8)
  13382. +#define ATMEL_TC_ETRGEDG_FALLING (2 << 8)
  13383. +#define ATMEL_TC_ETRGEDG_BOTH (3 << 8)
  13384. +#define ATMEL_TC_ABETRG (1 << 10) /* external trigger is TIOA? */
  13385. +#define ATMEL_TC_CPCTRG (1 << 14) /* RC compare trigger enable */
  13386. +#define ATMEL_TC_LDRA (3 << 16) /* RA loading edge (of TIOA) */
  13387. +#define ATMEL_TC_LDRA_NONE (0 << 16)
  13388. +#define ATMEL_TC_LDRA_RISING (1 << 16)
  13389. +#define ATMEL_TC_LDRA_FALLING (2 << 16)
  13390. +#define ATMEL_TC_LDRA_BOTH (3 << 16)
  13391. +#define ATMEL_TC_LDRB (3 << 18) /* RB loading edge (of TIOA) */
  13392. +#define ATMEL_TC_LDRB_NONE (0 << 18)
  13393. +#define ATMEL_TC_LDRB_RISING (1 << 18)
  13394. +#define ATMEL_TC_LDRB_FALLING (2 << 18)
  13395. +#define ATMEL_TC_LDRB_BOTH (3 << 18)
  13396. +
  13397. +/* WAVEFORM mode CMR bits */
  13398. +#define ATMEL_TC_CPCSTOP (1 << 6) /* RC compare stops counter */
  13399. +#define ATMEL_TC_CPCDIS (1 << 7) /* RC compare disables counter */
  13400. +#define ATMEL_TC_EEVTEDG (3 << 8) /* external event edge */
  13401. +#define ATMEL_TC_EEVTEDG_NONE (0 << 8)
  13402. +#define ATMEL_TC_EEVTEDG_RISING (1 << 8)
  13403. +#define ATMEL_TC_EEVTEDG_FALLING (2 << 8)
  13404. +#define ATMEL_TC_EEVTEDG_BOTH (3 << 8)
  13405. +#define ATMEL_TC_EEVT (3 << 10) /* external event source */
  13406. +#define ATMEL_TC_EEVT_TIOB (0 << 10)
  13407. +#define ATMEL_TC_EEVT_XC0 (1 << 10)
  13408. +#define ATMEL_TC_EEVT_XC1 (2 << 10)
  13409. +#define ATMEL_TC_EEVT_XC2 (3 << 10)
  13410. +#define ATMEL_TC_ENETRG (1 << 12) /* external event is trigger */
  13411. +#define ATMEL_TC_WAVESEL (3 << 13) /* waveform type */
  13412. +#define ATMEL_TC_WAVESEL_UP (0 << 13)
  13413. +#define ATMEL_TC_WAVESEL_UPDOWN (1 << 13)
  13414. +#define ATMEL_TC_WAVESEL_UP_AUTO (2 << 13)
  13415. +#define ATMEL_TC_WAVESEL_UPDOWN_AUTO (3 << 13)
  13416. +#define ATMEL_TC_ACPA (3 << 16) /* RA compare changes TIOA */
  13417. +#define ATMEL_TC_ACPA_NONE (0 << 16)
  13418. +#define ATMEL_TC_ACPA_SET (1 << 16)
  13419. +#define ATMEL_TC_ACPA_CLEAR (2 << 16)
  13420. +#define ATMEL_TC_ACPA_TOGGLE (3 << 16)
  13421. +#define ATMEL_TC_ACPC (3 << 18) /* RC compare changes TIOA */
  13422. +#define ATMEL_TC_ACPC_NONE (0 << 18)
  13423. +#define ATMEL_TC_ACPC_SET (1 << 18)
  13424. +#define ATMEL_TC_ACPC_CLEAR (2 << 18)
  13425. +#define ATMEL_TC_ACPC_TOGGLE (3 << 18)
  13426. +#define ATMEL_TC_AEEVT (3 << 20) /* external event changes TIOA */
  13427. +#define ATMEL_TC_AEEVT_NONE (0 << 20)
  13428. +#define ATMEL_TC_AEEVT_SET (1 << 20)
  13429. +#define ATMEL_TC_AEEVT_CLEAR (2 << 20)
  13430. +#define ATMEL_TC_AEEVT_TOGGLE (3 << 20)
  13431. +#define ATMEL_TC_ASWTRG (3 << 22) /* software trigger changes TIOA */
  13432. +#define ATMEL_TC_ASWTRG_NONE (0 << 22)
  13433. +#define ATMEL_TC_ASWTRG_SET (1 << 22)
  13434. +#define ATMEL_TC_ASWTRG_CLEAR (2 << 22)
  13435. +#define ATMEL_TC_ASWTRG_TOGGLE (3 << 22)
  13436. +#define ATMEL_TC_BCPB (3 << 24) /* RB compare changes TIOB */
  13437. +#define ATMEL_TC_BCPB_NONE (0 << 24)
  13438. +#define ATMEL_TC_BCPB_SET (1 << 24)
  13439. +#define ATMEL_TC_BCPB_CLEAR (2 << 24)
  13440. +#define ATMEL_TC_BCPB_TOGGLE (3 << 24)
  13441. +#define ATMEL_TC_BCPC (3 << 26) /* RC compare changes TIOB */
  13442. +#define ATMEL_TC_BCPC_NONE (0 << 26)
  13443. +#define ATMEL_TC_BCPC_SET (1 << 26)
  13444. +#define ATMEL_TC_BCPC_CLEAR (2 << 26)
  13445. +#define ATMEL_TC_BCPC_TOGGLE (3 << 26)
  13446. +#define ATMEL_TC_BEEVT (3 << 28) /* external event changes TIOB */
  13447. +#define ATMEL_TC_BEEVT_NONE (0 << 28)
  13448. +#define ATMEL_TC_BEEVT_SET (1 << 28)
  13449. +#define ATMEL_TC_BEEVT_CLEAR (2 << 28)
  13450. +#define ATMEL_TC_BEEVT_TOGGLE (3 << 28)
  13451. +#define ATMEL_TC_BSWTRG (3 << 30) /* software trigger changes TIOB */
  13452. +#define ATMEL_TC_BSWTRG_NONE (0 << 30)
  13453. +#define ATMEL_TC_BSWTRG_SET (1 << 30)
  13454. +#define ATMEL_TC_BSWTRG_CLEAR (2 << 30)
  13455. +#define ATMEL_TC_BSWTRG_TOGGLE (3 << 30)
  13456. +
  13457. +#define ATMEL_TC_CV 0x10 /* counter Value */
  13458. +#define ATMEL_TC_RA 0x14 /* register A */
  13459. +#define ATMEL_TC_RB 0x18 /* register B */
  13460. +#define ATMEL_TC_RC 0x1c /* register C */
  13461. +
  13462. +#define ATMEL_TC_SR 0x20 /* status (read-only) */
  13463. +/* Status-only flags */
  13464. +#define ATMEL_TC_CLKSTA (1 << 16) /* clock enabled */
  13465. +#define ATMEL_TC_MTIOA (1 << 17) /* TIOA mirror */
  13466. +#define ATMEL_TC_MTIOB (1 << 18) /* TIOB mirror */
  13467. +
  13468. +#define ATMEL_TC_IER 0x24 /* interrupt enable (write-only) */
  13469. +#define ATMEL_TC_IDR 0x28 /* interrupt disable (write-only) */
  13470. +#define ATMEL_TC_IMR 0x2c /* interrupt mask (read-only) */
  13471. +
  13472. +/* Status and IRQ flags */
  13473. +#define ATMEL_TC_COVFS (1 << 0) /* counter overflow */
  13474. +#define ATMEL_TC_LOVRS (1 << 1) /* load overrun */
  13475. +#define ATMEL_TC_CPAS (1 << 2) /* RA compare */
  13476. +#define ATMEL_TC_CPBS (1 << 3) /* RB compare */
  13477. +#define ATMEL_TC_CPCS (1 << 4) /* RC compare */
  13478. +#define ATMEL_TC_LDRAS (1 << 5) /* RA loading */
  13479. +#define ATMEL_TC_LDRBS (1 << 6) /* RB loading */
  13480. +#define ATMEL_TC_ETRGS (1 << 7) /* external trigger */
  13481. +
  13482. +#endif
  13483. --- a/include/linux/fs.h
  13484. +++ b/include/linux/fs.h
  13485. @@ -1691,6 +1691,8 @@
  13486. extern int invalidate_inode_pages2(struct address_space *mapping);
  13487. extern int invalidate_inode_pages2_range(struct address_space *mapping,
  13488. pgoff_t start, pgoff_t end);
  13489. +extern void generic_sync_sb_inodes(struct super_block *sb,
  13490. + struct writeback_control *wbc);
  13491. extern int write_inode_now(struct inode *, int);
  13492. extern int filemap_fdatawrite(struct address_space *);
  13493. extern int filemap_flush(struct address_space *);
  13494. --- /dev/null
  13495. +++ b/include/linux/usb/atmel_usba_udc.h
  13496. @@ -0,0 +1,22 @@
  13497. +/*
  13498. + * Platform data definitions for Atmel USBA gadget driver.
  13499. + */
  13500. +#ifndef __LINUX_USB_USBA_H
  13501. +#define __LINUX_USB_USBA_H
  13502. +
  13503. +struct usba_ep_data {
  13504. + char *name;
  13505. + int index;
  13506. + int fifo_size;
  13507. + int nr_banks;
  13508. + int can_dma;
  13509. + int can_isoc;
  13510. +};
  13511. +
  13512. +struct usba_platform_data {
  13513. + int vbus_pin;
  13514. + int num_ep;
  13515. + struct usba_ep_data ep[0];
  13516. +};
  13517. +
  13518. +#endif /* __LINUX_USB_USBA_H */
  13519. --- a/include/mtd/Kbuild
  13520. +++ b/include/mtd/Kbuild
  13521. @@ -3,5 +3,4 @@
  13522. header-y += mtd-abi.h
  13523. header-y += mtd-user.h
  13524. header-y += nftl-user.h
  13525. -header-y += ubi-header.h
  13526. header-y += ubi-user.h
  13527. --- a/include/mtd/ubi-header.h
  13528. +++ /dev/null
  13529. @@ -1,372 +0,0 @@
  13530. -/*
  13531. - * Copyright (c) International Business Machines Corp., 2006
  13532. - *
  13533. - * This program is free software; you can redistribute it and/or modify
  13534. - * it under the terms of the GNU General Public License as published by
  13535. - * the Free Software Foundation; either version 2 of the License, or
  13536. - * (at your option) any later version.
  13537. - *
  13538. - * This program is distributed in the hope that it will be useful,
  13539. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13540. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  13541. - * the GNU General Public License for more details.
  13542. - *
  13543. - * You should have received a copy of the GNU General Public License
  13544. - * along with this program; if not, write to the Free Software
  13545. - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  13546. - *
  13547. - * Authors: Artem Bityutskiy (Битюцкий Артём)
  13548. - * Thomas Gleixner
  13549. - * Frank Haverkamp
  13550. - * Oliver Lohmann
  13551. - * Andreas Arnez
  13552. - */
  13553. -
  13554. -/*
  13555. - * This file defines the layout of UBI headers and all the other UBI on-flash
  13556. - * data structures. May be included by user-space.
  13557. - */
  13558. -
  13559. -#ifndef __UBI_HEADER_H__
  13560. -#define __UBI_HEADER_H__
  13561. -
  13562. -#include <asm/byteorder.h>
  13563. -
  13564. -/* The version of UBI images supported by this implementation */
  13565. -#define UBI_VERSION 1
  13566. -
  13567. -/* The highest erase counter value supported by this implementation */
  13568. -#define UBI_MAX_ERASECOUNTER 0x7FFFFFFF
  13569. -
  13570. -/* The initial CRC32 value used when calculating CRC checksums */
  13571. -#define UBI_CRC32_INIT 0xFFFFFFFFU
  13572. -
  13573. -/* Erase counter header magic number (ASCII "UBI#") */
  13574. -#define UBI_EC_HDR_MAGIC 0x55424923
  13575. -/* Volume identifier header magic number (ASCII "UBI!") */
  13576. -#define UBI_VID_HDR_MAGIC 0x55424921
  13577. -
  13578. -/*
  13579. - * Volume type constants used in the volume identifier header.
  13580. - *
  13581. - * @UBI_VID_DYNAMIC: dynamic volume
  13582. - * @UBI_VID_STATIC: static volume
  13583. - */
  13584. -enum {
  13585. - UBI_VID_DYNAMIC = 1,
  13586. - UBI_VID_STATIC = 2
  13587. -};
  13588. -
  13589. -/*
  13590. - * Volume flags used in the volume table record.
  13591. - *
  13592. - * @UBI_VTBL_AUTORESIZE_FLG: auto-resize this volume
  13593. - *
  13594. - * %UBI_VTBL_AUTORESIZE_FLG flag can be set only for one volume in the volume
  13595. - * table. UBI automatically re-sizes the volume which has this flag and makes
  13596. - * the volume to be of largest possible size. This means that if after the
  13597. - * initialization UBI finds out that there are available physical eraseblocks
  13598. - * present on the device, it automatically appends all of them to the volume
  13599. - * (the physical eraseblocks reserved for bad eraseblocks handling and other
  13600. - * reserved physical eraseblocks are not taken). So, if there is a volume with
  13601. - * the %UBI_VTBL_AUTORESIZE_FLG flag set, the amount of available logical
  13602. - * eraseblocks will be zero after UBI is loaded, because all of them will be
  13603. - * reserved for this volume. Note, the %UBI_VTBL_AUTORESIZE_FLG bit is cleared
  13604. - * after the volume had been initialized.
  13605. - *
  13606. - * The auto-resize feature is useful for device production purposes. For
  13607. - * example, different NAND flash chips may have different amount of initial bad
  13608. - * eraseblocks, depending of particular chip instance. Manufacturers of NAND
  13609. - * chips usually guarantee that the amount of initial bad eraseblocks does not
  13610. - * exceed certain percent, e.g. 2%. When one creates an UBI image which will be
  13611. - * flashed to the end devices in production, he does not know the exact amount
  13612. - * of good physical eraseblocks the NAND chip on the device will have, but this
  13613. - * number is required to calculate the volume sized and put them to the volume
  13614. - * table of the UBI image. In this case, one of the volumes (e.g., the one
  13615. - * which will store the root file system) is marked as "auto-resizable", and
  13616. - * UBI will adjust its size on the first boot if needed.
  13617. - *
  13618. - * Note, first UBI reserves some amount of physical eraseblocks for bad
  13619. - * eraseblock handling, and then re-sizes the volume, not vice-versa. This
  13620. - * means that the pool of reserved physical eraseblocks will always be present.
  13621. - */
  13622. -enum {
  13623. - UBI_VTBL_AUTORESIZE_FLG = 0x01,
  13624. -};
  13625. -
  13626. -/*
  13627. - * Compatibility constants used by internal volumes.
  13628. - *
  13629. - * @UBI_COMPAT_DELETE: delete this internal volume before anything is written
  13630. - * to the flash
  13631. - * @UBI_COMPAT_RO: attach this device in read-only mode
  13632. - * @UBI_COMPAT_PRESERVE: preserve this internal volume - do not touch its
  13633. - * physical eraseblocks, don't allow the wear-leveling unit to move them
  13634. - * @UBI_COMPAT_REJECT: reject this UBI image
  13635. - */
  13636. -enum {
  13637. - UBI_COMPAT_DELETE = 1,
  13638. - UBI_COMPAT_RO = 2,
  13639. - UBI_COMPAT_PRESERVE = 4,
  13640. - UBI_COMPAT_REJECT = 5
  13641. -};
  13642. -
  13643. -/* Sizes of UBI headers */
  13644. -#define UBI_EC_HDR_SIZE sizeof(struct ubi_ec_hdr)
  13645. -#define UBI_VID_HDR_SIZE sizeof(struct ubi_vid_hdr)
  13646. -
  13647. -/* Sizes of UBI headers without the ending CRC */
  13648. -#define UBI_EC_HDR_SIZE_CRC (UBI_EC_HDR_SIZE - sizeof(__be32))
  13649. -#define UBI_VID_HDR_SIZE_CRC (UBI_VID_HDR_SIZE - sizeof(__be32))
  13650. -
  13651. -/**
  13652. - * struct ubi_ec_hdr - UBI erase counter header.
  13653. - * @magic: erase counter header magic number (%UBI_EC_HDR_MAGIC)
  13654. - * @version: version of UBI implementation which is supposed to accept this
  13655. - * UBI image
  13656. - * @padding1: reserved for future, zeroes
  13657. - * @ec: the erase counter
  13658. - * @vid_hdr_offset: where the VID header starts
  13659. - * @data_offset: where the user data start
  13660. - * @padding2: reserved for future, zeroes
  13661. - * @hdr_crc: erase counter header CRC checksum
  13662. - *
  13663. - * The erase counter header takes 64 bytes and has a plenty of unused space for
  13664. - * future usage. The unused fields are zeroed. The @version field is used to
  13665. - * indicate the version of UBI implementation which is supposed to be able to
  13666. - * work with this UBI image. If @version is greater then the current UBI
  13667. - * version, the image is rejected. This may be useful in future if something
  13668. - * is changed radically. This field is duplicated in the volume identifier
  13669. - * header.
  13670. - *
  13671. - * The @vid_hdr_offset and @data_offset fields contain the offset of the the
  13672. - * volume identifier header and user data, relative to the beginning of the
  13673. - * physical eraseblock. These values have to be the same for all physical
  13674. - * eraseblocks.
  13675. - */
  13676. -struct ubi_ec_hdr {
  13677. - __be32 magic;
  13678. - __u8 version;
  13679. - __u8 padding1[3];
  13680. - __be64 ec; /* Warning: the current limit is 31-bit anyway! */
  13681. - __be32 vid_hdr_offset;
  13682. - __be32 data_offset;
  13683. - __u8 padding2[36];
  13684. - __be32 hdr_crc;
  13685. -} __attribute__ ((packed));
  13686. -
  13687. -/**
  13688. - * struct ubi_vid_hdr - on-flash UBI volume identifier header.
  13689. - * @magic: volume identifier header magic number (%UBI_VID_HDR_MAGIC)
  13690. - * @version: UBI implementation version which is supposed to accept this UBI
  13691. - * image (%UBI_VERSION)
  13692. - * @vol_type: volume type (%UBI_VID_DYNAMIC or %UBI_VID_STATIC)
  13693. - * @copy_flag: if this logical eraseblock was copied from another physical
  13694. - * eraseblock (for wear-leveling reasons)
  13695. - * @compat: compatibility of this volume (%0, %UBI_COMPAT_DELETE,
  13696. - * %UBI_COMPAT_IGNORE, %UBI_COMPAT_PRESERVE, or %UBI_COMPAT_REJECT)
  13697. - * @vol_id: ID of this volume
  13698. - * @lnum: logical eraseblock number
  13699. - * @leb_ver: version of this logical eraseblock (IMPORTANT: obsolete, to be
  13700. - * removed, kept only for not breaking older UBI users)
  13701. - * @data_size: how many bytes of data this logical eraseblock contains
  13702. - * @used_ebs: total number of used logical eraseblocks in this volume
  13703. - * @data_pad: how many bytes at the end of this physical eraseblock are not
  13704. - * used
  13705. - * @data_crc: CRC checksum of the data stored in this logical eraseblock
  13706. - * @padding1: reserved for future, zeroes
  13707. - * @sqnum: sequence number
  13708. - * @padding2: reserved for future, zeroes
  13709. - * @hdr_crc: volume identifier header CRC checksum
  13710. - *
  13711. - * The @sqnum is the value of the global sequence counter at the time when this
  13712. - * VID header was created. The global sequence counter is incremented each time
  13713. - * UBI writes a new VID header to the flash, i.e. when it maps a logical
  13714. - * eraseblock to a new physical eraseblock. The global sequence counter is an
  13715. - * unsigned 64-bit integer and we assume it never overflows. The @sqnum
  13716. - * (sequence number) is used to distinguish between older and newer versions of
  13717. - * logical eraseblocks.
  13718. - *
  13719. - * There are 2 situations when there may be more then one physical eraseblock
  13720. - * corresponding to the same logical eraseblock, i.e., having the same @vol_id
  13721. - * and @lnum values in the volume identifier header. Suppose we have a logical
  13722. - * eraseblock L and it is mapped to the physical eraseblock P.
  13723. - *
  13724. - * 1. Because UBI may erase physical eraseblocks asynchronously, the following
  13725. - * situation is possible: L is asynchronously erased, so P is scheduled for
  13726. - * erasure, then L is written to,i.e. mapped to another physical eraseblock P1,
  13727. - * so P1 is written to, then an unclean reboot happens. Result - there are 2
  13728. - * physical eraseblocks P and P1 corresponding to the same logical eraseblock
  13729. - * L. But P1 has greater sequence number, so UBI picks P1 when it attaches the
  13730. - * flash.
  13731. - *
  13732. - * 2. From time to time UBI moves logical eraseblocks to other physical
  13733. - * eraseblocks for wear-leveling reasons. If, for example, UBI moves L from P
  13734. - * to P1, and an unclean reboot happens before P is physically erased, there
  13735. - * are two physical eraseblocks P and P1 corresponding to L and UBI has to
  13736. - * select one of them when the flash is attached. The @sqnum field says which
  13737. - * PEB is the original (obviously P will have lower @sqnum) and the copy. But
  13738. - * it is not enough to select the physical eraseblock with the higher sequence
  13739. - * number, because the unclean reboot could have happen in the middle of the
  13740. - * copying process, so the data in P is corrupted. It is also not enough to
  13741. - * just select the physical eraseblock with lower sequence number, because the
  13742. - * data there may be old (consider a case if more data was added to P1 after
  13743. - * the copying). Moreover, the unclean reboot may happen when the erasure of P
  13744. - * was just started, so it result in unstable P, which is "mostly" OK, but
  13745. - * still has unstable bits.
  13746. - *
  13747. - * UBI uses the @copy_flag field to indicate that this logical eraseblock is a
  13748. - * copy. UBI also calculates data CRC when the data is moved and stores it at
  13749. - * the @data_crc field of the copy (P1). So when UBI needs to pick one physical
  13750. - * eraseblock of two (P or P1), the @copy_flag of the newer one (P1) is
  13751. - * examined. If it is cleared, the situation* is simple and the newer one is
  13752. - * picked. If it is set, the data CRC of the copy (P1) is examined. If the CRC
  13753. - * checksum is correct, this physical eraseblock is selected (P1). Otherwise
  13754. - * the older one (P) is selected.
  13755. - *
  13756. - * Note, there is an obsolete @leb_ver field which was used instead of @sqnum
  13757. - * in the past. But it is not used anymore and we keep it in order to be able
  13758. - * to deal with old UBI images. It will be removed at some point.
  13759. - *
  13760. - * There are 2 sorts of volumes in UBI: user volumes and internal volumes.
  13761. - * Internal volumes are not seen from outside and are used for various internal
  13762. - * UBI purposes. In this implementation there is only one internal volume - the
  13763. - * layout volume. Internal volumes are the main mechanism of UBI extensions.
  13764. - * For example, in future one may introduce a journal internal volume. Internal
  13765. - * volumes have their own reserved range of IDs.
  13766. - *
  13767. - * The @compat field is only used for internal volumes and contains the "degree
  13768. - * of their compatibility". It is always zero for user volumes. This field
  13769. - * provides a mechanism to introduce UBI extensions and to be still compatible
  13770. - * with older UBI binaries. For example, if someone introduced a journal in
  13771. - * future, he would probably use %UBI_COMPAT_DELETE compatibility for the
  13772. - * journal volume. And in this case, older UBI binaries, which know nothing
  13773. - * about the journal volume, would just delete this volume and work perfectly
  13774. - * fine. This is similar to what Ext2fs does when it is fed by an Ext3fs image
  13775. - * - it just ignores the Ext3fs journal.
  13776. - *
  13777. - * The @data_crc field contains the CRC checksum of the contents of the logical
  13778. - * eraseblock if this is a static volume. In case of dynamic volumes, it does
  13779. - * not contain the CRC checksum as a rule. The only exception is when the
  13780. - * data of the physical eraseblock was moved by the wear-leveling unit, then
  13781. - * the wear-leveling unit calculates the data CRC and stores it in the
  13782. - * @data_crc field. And of course, the @copy_flag is %in this case.
  13783. - *
  13784. - * The @data_size field is used only for static volumes because UBI has to know
  13785. - * how many bytes of data are stored in this eraseblock. For dynamic volumes,
  13786. - * this field usually contains zero. The only exception is when the data of the
  13787. - * physical eraseblock was moved to another physical eraseblock for
  13788. - * wear-leveling reasons. In this case, UBI calculates CRC checksum of the
  13789. - * contents and uses both @data_crc and @data_size fields. In this case, the
  13790. - * @data_size field contains data size.
  13791. - *
  13792. - * The @used_ebs field is used only for static volumes and indicates how many
  13793. - * eraseblocks the data of the volume takes. For dynamic volumes this field is
  13794. - * not used and always contains zero.
  13795. - *
  13796. - * The @data_pad is calculated when volumes are created using the alignment
  13797. - * parameter. So, effectively, the @data_pad field reduces the size of logical
  13798. - * eraseblocks of this volume. This is very handy when one uses block-oriented
  13799. - * software (say, cramfs) on top of the UBI volume.
  13800. - */
  13801. -struct ubi_vid_hdr {
  13802. - __be32 magic;
  13803. - __u8 version;
  13804. - __u8 vol_type;
  13805. - __u8 copy_flag;
  13806. - __u8 compat;
  13807. - __be32 vol_id;
  13808. - __be32 lnum;
  13809. - __be32 leb_ver; /* obsolete, to be removed, don't use */
  13810. - __be32 data_size;
  13811. - __be32 used_ebs;
  13812. - __be32 data_pad;
  13813. - __be32 data_crc;
  13814. - __u8 padding1[4];
  13815. - __be64 sqnum;
  13816. - __u8 padding2[12];
  13817. - __be32 hdr_crc;
  13818. -} __attribute__ ((packed));
  13819. -
  13820. -/* Internal UBI volumes count */
  13821. -#define UBI_INT_VOL_COUNT 1
  13822. -
  13823. -/*
  13824. - * Starting ID of internal volumes. There is reserved room for 4096 internal
  13825. - * volumes.
  13826. - */
  13827. -#define UBI_INTERNAL_VOL_START (0x7FFFFFFF - 4096)
  13828. -
  13829. -/* The layout volume contains the volume table */
  13830. -
  13831. -#define UBI_LAYOUT_VOLUME_ID UBI_INTERNAL_VOL_START
  13832. -#define UBI_LAYOUT_VOLUME_TYPE UBI_VID_DYNAMIC
  13833. -#define UBI_LAYOUT_VOLUME_ALIGN 1
  13834. -#define UBI_LAYOUT_VOLUME_EBS 2
  13835. -#define UBI_LAYOUT_VOLUME_NAME "layout volume"
  13836. -#define UBI_LAYOUT_VOLUME_COMPAT UBI_COMPAT_REJECT
  13837. -
  13838. -/* The maximum number of volumes per one UBI device */
  13839. -#define UBI_MAX_VOLUMES 128
  13840. -
  13841. -/* The maximum volume name length */
  13842. -#define UBI_VOL_NAME_MAX 127
  13843. -
  13844. -/* Size of the volume table record */
  13845. -#define UBI_VTBL_RECORD_SIZE sizeof(struct ubi_vtbl_record)
  13846. -
  13847. -/* Size of the volume table record without the ending CRC */
  13848. -#define UBI_VTBL_RECORD_SIZE_CRC (UBI_VTBL_RECORD_SIZE - sizeof(__be32))
  13849. -
  13850. -/**
  13851. - * struct ubi_vtbl_record - a record in the volume table.
  13852. - * @reserved_pebs: how many physical eraseblocks are reserved for this volume
  13853. - * @alignment: volume alignment
  13854. - * @data_pad: how many bytes are unused at the end of the each physical
  13855. - * eraseblock to satisfy the requested alignment
  13856. - * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
  13857. - * @upd_marker: if volume update was started but not finished
  13858. - * @name_len: volume name length
  13859. - * @name: the volume name
  13860. - * @flags: volume flags (%UBI_VTBL_AUTORESIZE_FLG)
  13861. - * @padding: reserved, zeroes
  13862. - * @crc: a CRC32 checksum of the record
  13863. - *
  13864. - * The volume table records are stored in the volume table, which is stored in
  13865. - * the layout volume. The layout volume consists of 2 logical eraseblock, each
  13866. - * of which contains a copy of the volume table (i.e., the volume table is
  13867. - * duplicated). The volume table is an array of &struct ubi_vtbl_record
  13868. - * objects indexed by the volume ID.
  13869. - *
  13870. - * If the size of the logical eraseblock is large enough to fit
  13871. - * %UBI_MAX_VOLUMES records, the volume table contains %UBI_MAX_VOLUMES
  13872. - * records. Otherwise, it contains as many records as it can fit (i.e., size of
  13873. - * logical eraseblock divided by sizeof(struct ubi_vtbl_record)).
  13874. - *
  13875. - * The @upd_marker flag is used to implement volume update. It is set to %1
  13876. - * before update and set to %0 after the update. So if the update operation was
  13877. - * interrupted, UBI knows that the volume is corrupted.
  13878. - *
  13879. - * The @alignment field is specified when the volume is created and cannot be
  13880. - * later changed. It may be useful, for example, when a block-oriented file
  13881. - * system works on top of UBI. The @data_pad field is calculated using the
  13882. - * logical eraseblock size and @alignment. The alignment must be multiple to the
  13883. - * minimal flash I/O unit. If @alignment is 1, all the available space of
  13884. - * the physical eraseblocks is used.
  13885. - *
  13886. - * Empty records contain all zeroes and the CRC checksum of those zeroes.
  13887. - */
  13888. -struct ubi_vtbl_record {
  13889. - __be32 reserved_pebs;
  13890. - __be32 alignment;
  13891. - __be32 data_pad;
  13892. - __u8 vol_type;
  13893. - __u8 upd_marker;
  13894. - __be16 name_len;
  13895. - __u8 name[UBI_VOL_NAME_MAX+1];
  13896. - __u8 flags;
  13897. - __u8 padding[23];
  13898. - __be32 crc;
  13899. -} __attribute__ ((packed));
  13900. -
  13901. -#endif /* !__UBI_HEADER_H__ */
  13902. --- a/init/do_mounts.c
  13903. +++ b/init/do_mounts.c
  13904. @@ -126,8 +126,14 @@
  13905. static int __init rootwait_setup(char *str)
  13906. {
  13907. - if (*str)
  13908. + if (*str && *str != '=')
  13909. return 0;
  13910. +
  13911. + if (*str)
  13912. + printk(KERN_WARNING
  13913. + "WARNING: \"rootwait=1\" is deprecated, "
  13914. + "use \"rootwait\" instead.\n");
  13915. +
  13916. root_wait = 1;
  13917. return 1;
  13918. }
  13919. @@ -347,7 +353,8 @@
  13920. if (saved_root_name[0]) {
  13921. root_device_name = saved_root_name;
  13922. - if (!strncmp(root_device_name, "mtd", 3)) {
  13923. + if (!strncmp(root_device_name, "mtd", 3) ||
  13924. + !strncmp(root_device_name, "ubi", 3)) {
  13925. mount_block_root(root_device_name, root_mountflags);
  13926. goto out;
  13927. }
  13928. --- /dev/null
  13929. +++ b/localversion-atmel
  13930. @@ -0,0 +1 @@
  13931. +.atmel.1
  13932. --- /dev/null
  13933. +++ b/sound/avr32/ac97c.c
  13934. @@ -0,0 +1,914 @@
  13935. +/*
  13936. + * Driver for the Atmel AC97 controller
  13937. + *
  13938. + * Copyright (C) 2005-2007 Atmel Corporation
  13939. + *
  13940. + * This program is free software; you can redistribute it and/or modify it
  13941. + * under the terms of the GNU General Public License version 2 as published by
  13942. + * the Free Software Foundation.
  13943. + */
  13944. +#include <linux/clk.h>
  13945. +#include <linux/delay.h>
  13946. +#include <linux/dma-mapping.h>
  13947. +#include <linux/init.h>
  13948. +#include <linux/interrupt.h>
  13949. +#include <linux/module.h>
  13950. +#include <linux/platform_device.h>
  13951. +#include <linux/mutex.h>
  13952. +#include <linux/io.h>
  13953. +
  13954. +#include <sound/driver.h>
  13955. +#include <sound/core.h>
  13956. +#include <sound/initval.h>
  13957. +#include <sound/pcm.h>
  13958. +#include <sound/pcm_params.h>
  13959. +#include <sound/ac97_codec.h>
  13960. +#include <sound/memalloc.h>
  13961. +
  13962. +#include <asm/dma-controller.h>
  13963. +
  13964. +#include "ac97c.h"
  13965. +
  13966. +/* Serialize access to opened */
  13967. +static DEFINE_MUTEX(opened_mutex);
  13968. +
  13969. +struct atmel_ac97_dma_info {
  13970. + struct dma_request_cyclic req_tx;
  13971. + struct dma_request_cyclic req_rx;
  13972. + unsigned short rx_periph_id;
  13973. + unsigned short tx_periph_id;
  13974. +};
  13975. +
  13976. +struct atmel_ac97 {
  13977. + /* Serialize access to opened */
  13978. + spinlock_t lock;
  13979. + void __iomem *regs;
  13980. + struct snd_pcm_substream *playback_substream;
  13981. + struct snd_pcm_substream *capture_substream;
  13982. + struct snd_card *card;
  13983. + struct snd_pcm *pcm;
  13984. + struct snd_ac97 *ac97;
  13985. + struct snd_ac97_bus *ac97_bus;
  13986. + int opened;
  13987. + int period;
  13988. + u64 cur_format;
  13989. + unsigned int cur_rate;
  13990. + struct clk *mck;
  13991. + struct platform_device *pdev;
  13992. + struct atmel_ac97_dma_info dma;
  13993. +};
  13994. +
  13995. +#define get_chip(card) ((struct atmel_ac97 *)(card)->private_data)
  13996. +
  13997. +#define ac97c_writel(chip, reg, val) \
  13998. + __raw_writel((val), (chip)->regs + AC97C_##reg)
  13999. +#define ac97c_readl(chip, reg) \
  14000. + __raw_readl((chip)->regs + AC97C_##reg)
  14001. +
  14002. +/*
  14003. + * PCM part
  14004. + */
  14005. +static struct snd_pcm_hardware snd_atmel_ac97_playback_hw = {
  14006. + .info = (SNDRV_PCM_INFO_INTERLEAVED
  14007. + | SNDRV_PCM_INFO_MMAP
  14008. + | SNDRV_PCM_INFO_MMAP_VALID
  14009. + | SNDRV_PCM_INFO_BLOCK_TRANSFER
  14010. + | SNDRV_PCM_INFO_JOINT_DUPLEX),
  14011. + .formats = (SNDRV_PCM_FMTBIT_S16_BE
  14012. + | SNDRV_PCM_FMTBIT_S16_LE),
  14013. + .rates = (SNDRV_PCM_RATE_CONTINUOUS),
  14014. + .rate_min = 4000,
  14015. + .rate_max = 48000,
  14016. + .channels_min = 1,
  14017. + .channels_max = 6,
  14018. + .buffer_bytes_max = 64*1024,
  14019. + .period_bytes_min = 512,
  14020. + .period_bytes_max = 4095,
  14021. + .periods_min = 8,
  14022. + .periods_max = 1024,
  14023. +};
  14024. +
  14025. +static struct snd_pcm_hardware snd_atmel_ac97_capture_hw = {
  14026. + .info = (SNDRV_PCM_INFO_INTERLEAVED
  14027. + | SNDRV_PCM_INFO_MMAP
  14028. + | SNDRV_PCM_INFO_MMAP_VALID
  14029. + | SNDRV_PCM_INFO_BLOCK_TRANSFER
  14030. + | SNDRV_PCM_INFO_JOINT_DUPLEX),
  14031. + .formats = (SNDRV_PCM_FMTBIT_S16_BE
  14032. + | SNDRV_PCM_FMTBIT_S16_LE),
  14033. + .rates = (SNDRV_PCM_RATE_CONTINUOUS),
  14034. + .rate_min = 4000,
  14035. + .rate_max = 48000,
  14036. + .channels_min = 1,
  14037. + .channels_max = 2,
  14038. + .buffer_bytes_max = 64*1024,
  14039. + .period_bytes_min = 512,
  14040. + .period_bytes_max = 4095,
  14041. + .periods_min = 8,
  14042. + .periods_max = 1024,
  14043. +};
  14044. +
  14045. +/*
  14046. + * PCM functions
  14047. + */
  14048. +static int
  14049. +snd_atmel_ac97_playback_open(struct snd_pcm_substream *substream)
  14050. +{
  14051. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14052. + struct snd_pcm_runtime *runtime = substream->runtime;
  14053. +
  14054. + mutex_lock(&opened_mutex);
  14055. + chip->opened++;
  14056. + runtime->hw = snd_atmel_ac97_playback_hw;
  14057. + if (chip->cur_rate) {
  14058. + runtime->hw.rate_min = chip->cur_rate;
  14059. + runtime->hw.rate_max = chip->cur_rate;
  14060. + }
  14061. + if (chip->cur_format)
  14062. + runtime->hw.formats = (1ULL << chip->cur_format);
  14063. + mutex_unlock(&opened_mutex);
  14064. + chip->playback_substream = substream;
  14065. + chip->period = 0;
  14066. + return 0;
  14067. +}
  14068. +
  14069. +static int
  14070. +snd_atmel_ac97_capture_open(struct snd_pcm_substream *substream)
  14071. +{
  14072. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14073. + struct snd_pcm_runtime *runtime = substream->runtime;
  14074. +
  14075. + mutex_lock(&opened_mutex);
  14076. + chip->opened++;
  14077. + runtime->hw = snd_atmel_ac97_capture_hw;
  14078. + if (chip->cur_rate) {
  14079. + runtime->hw.rate_min = chip->cur_rate;
  14080. + runtime->hw.rate_max = chip->cur_rate;
  14081. + }
  14082. + if (chip->cur_format)
  14083. + runtime->hw.formats = (1ULL << chip->cur_format);
  14084. + mutex_unlock(&opened_mutex);
  14085. + chip->capture_substream = substream;
  14086. + chip->period = 0;
  14087. + return 0;
  14088. +}
  14089. +
  14090. +static int snd_atmel_ac97_playback_close(struct snd_pcm_substream *substream)
  14091. +{
  14092. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14093. + mutex_lock(&opened_mutex);
  14094. + chip->opened--;
  14095. + if (!chip->opened) {
  14096. + chip->cur_rate = 0;
  14097. + chip->cur_format = 0;
  14098. + }
  14099. + mutex_unlock(&opened_mutex);
  14100. + return 0;
  14101. +}
  14102. +
  14103. +static int snd_atmel_ac97_capture_close(struct snd_pcm_substream *substream)
  14104. +{
  14105. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14106. + mutex_lock(&opened_mutex);
  14107. + chip->opened--;
  14108. + if (!chip->opened) {
  14109. + chip->cur_rate = 0;
  14110. + chip->cur_format = 0;
  14111. + }
  14112. + mutex_unlock(&opened_mutex);
  14113. + return 0;
  14114. +}
  14115. +
  14116. +static int
  14117. +snd_atmel_ac97_playback_hw_params(struct snd_pcm_substream *substream,
  14118. + struct snd_pcm_hw_params *hw_params)
  14119. +{
  14120. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14121. + int err;
  14122. +
  14123. + err = snd_pcm_lib_malloc_pages(substream,
  14124. + params_buffer_bytes(hw_params));
  14125. + if (err < 0)
  14126. + return err;
  14127. +
  14128. + /* Set restrictions to params */
  14129. + mutex_lock(&opened_mutex);
  14130. + chip->cur_rate = params_rate(hw_params);
  14131. + chip->cur_format = params_format(hw_params);
  14132. + mutex_unlock(&opened_mutex);
  14133. +
  14134. + return 0;
  14135. +}
  14136. +
  14137. +static int
  14138. +snd_atmel_ac97_capture_hw_params(struct snd_pcm_substream *substream,
  14139. + struct snd_pcm_hw_params *hw_params)
  14140. +{
  14141. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14142. + int err;
  14143. +
  14144. + err = snd_pcm_lib_malloc_pages(substream,
  14145. + params_buffer_bytes(hw_params));
  14146. + if (err < 0)
  14147. + return err;
  14148. +
  14149. + /* Set restrictions to params */
  14150. + mutex_lock(&opened_mutex);
  14151. + chip->cur_rate = params_rate(hw_params);
  14152. + chip->cur_format = params_format(hw_params);
  14153. + mutex_unlock(&opened_mutex);
  14154. +
  14155. + return 0;
  14156. +}
  14157. +
  14158. +static int snd_atmel_ac97_playback_hw_free(struct snd_pcm_substream *substream)
  14159. +{
  14160. + return snd_pcm_lib_free_pages(substream);
  14161. +}
  14162. +
  14163. +static int snd_atmel_ac97_capture_hw_free(struct snd_pcm_substream *substream)
  14164. +{
  14165. +
  14166. + return snd_pcm_lib_free_pages(substream);
  14167. +}
  14168. +
  14169. +static int snd_atmel_ac97_playback_prepare(struct snd_pcm_substream *substream)
  14170. +{
  14171. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14172. + struct platform_device *pdev = chip->pdev;
  14173. + struct snd_pcm_runtime *runtime = substream->runtime;
  14174. + int block_size = frames_to_bytes(runtime, runtime->period_size);
  14175. + unsigned long word = 0;
  14176. + unsigned long buffer_size = 0;
  14177. +
  14178. + dma_sync_single_for_device(&pdev->dev, runtime->dma_addr,
  14179. + block_size * 2, DMA_TO_DEVICE);
  14180. +
  14181. + /* Assign slots to channels */
  14182. + switch (substream->runtime->channels) {
  14183. + case 1:
  14184. + word |= AC97C_CH_ASSIGN(PCM_LEFT, A);
  14185. + break;
  14186. + case 2:
  14187. + /* Assign Left and Right slot to Channel A */
  14188. + word |= AC97C_CH_ASSIGN(PCM_LEFT, A)
  14189. + | AC97C_CH_ASSIGN(PCM_RIGHT, A);
  14190. + break;
  14191. + default:
  14192. + /* TODO: support more than two channels */
  14193. + return -EINVAL;
  14194. + break;
  14195. + }
  14196. + ac97c_writel(chip, OCA, word);
  14197. +
  14198. + /* Configure sample format and size */
  14199. + word = AC97C_CMR_PDCEN | AC97C_CMR_SIZE_16;
  14200. +
  14201. + switch (runtime->format) {
  14202. + case SNDRV_PCM_FORMAT_S16_LE:
  14203. + word |= AC97C_CMR_CEM_LITTLE;
  14204. + break;
  14205. + case SNDRV_PCM_FORMAT_S16_BE: /* fall through */
  14206. + default:
  14207. + word &= ~AC97C_CMR_CEM_LITTLE;
  14208. + break;
  14209. + }
  14210. +
  14211. + ac97c_writel(chip, CAMR, word);
  14212. +
  14213. + /* Set variable rate if needed */
  14214. + if (runtime->rate != 48000) {
  14215. + word = ac97c_readl(chip, MR);
  14216. + word |= AC97C_MR_VRA;
  14217. + ac97c_writel(chip, MR, word);
  14218. + } else {
  14219. + /* Clear Variable Rate Bit */
  14220. + word = ac97c_readl(chip, MR);
  14221. + word &= ~AC97C_MR_VRA;
  14222. + ac97c_writel(chip, MR, word);
  14223. + }
  14224. +
  14225. + /* Set rate */
  14226. + snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate);
  14227. +
  14228. + buffer_size = frames_to_bytes(runtime, runtime->period_size) *
  14229. + runtime->periods;
  14230. +
  14231. + chip->dma.req_tx.buffer_size = buffer_size;
  14232. + chip->dma.req_tx.periods = runtime->periods;
  14233. +
  14234. + BUG_ON(chip->dma.req_tx.buffer_size !=
  14235. + (chip->dma.req_tx.periods *
  14236. + frames_to_bytes(runtime, runtime->period_size)));
  14237. +
  14238. + chip->dma.req_tx.buffer_start = runtime->dma_addr;
  14239. + chip->dma.req_tx.data_reg = (dma_addr_t)(chip->regs + AC97C_CATHR + 2);
  14240. + chip->dma.req_tx.periph_id = chip->dma.tx_periph_id;
  14241. + chip->dma.req_tx.direction = DMA_DIR_MEM_TO_PERIPH;
  14242. + chip->dma.req_tx.width = DMA_WIDTH_16BIT;
  14243. + chip->dma.req_tx.dev_id = chip;
  14244. +
  14245. + return 0;
  14246. +}
  14247. +
  14248. +static int snd_atmel_ac97_capture_prepare(struct snd_pcm_substream *substream)
  14249. +{
  14250. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14251. + struct platform_device *pdev = chip->pdev;
  14252. + struct snd_pcm_runtime *runtime = substream->runtime;
  14253. + int block_size = frames_to_bytes(runtime, runtime->period_size);
  14254. + unsigned long word = 0;
  14255. + unsigned long buffer_size = 0;
  14256. +
  14257. + dma_sync_single_for_device(&pdev->dev, runtime->dma_addr,
  14258. + block_size * 2, DMA_FROM_DEVICE);
  14259. +
  14260. + /* Assign slots to channels */
  14261. + switch (substream->runtime->channels) {
  14262. + case 1:
  14263. + word |= AC97C_CH_ASSIGN(PCM_LEFT, A);
  14264. + break;
  14265. + case 2:
  14266. + /* Assign Left and Right slot to Channel A */
  14267. + word |= AC97C_CH_ASSIGN(PCM_LEFT, A)
  14268. + | AC97C_CH_ASSIGN(PCM_RIGHT, A);
  14269. + break;
  14270. + default:
  14271. + /* TODO: support more than two channels */
  14272. + return -EINVAL;
  14273. + break;
  14274. + }
  14275. + ac97c_writel(chip, ICA, word);
  14276. +
  14277. + /* Configure sample format and size */
  14278. + word = AC97C_CMR_PDCEN | AC97C_CMR_SIZE_16;
  14279. +
  14280. + switch (runtime->format) {
  14281. + case SNDRV_PCM_FORMAT_S16_LE:
  14282. + word |= AC97C_CMR_CEM_LITTLE;
  14283. + break;
  14284. + case SNDRV_PCM_FORMAT_S16_BE:
  14285. + default:
  14286. + word &= ~(AC97C_CMR_CEM_LITTLE);
  14287. + break;
  14288. + }
  14289. +
  14290. + ac97c_writel(chip, CAMR, word);
  14291. +
  14292. + /* Set variable rate if needed */
  14293. + if (runtime->rate != 48000) {
  14294. + word = ac97c_readl(chip, MR);
  14295. + word |= AC97C_MR_VRA;
  14296. + ac97c_writel(chip, MR, word);
  14297. + } else {
  14298. + /* Clear Variable Rate Bit */
  14299. + word = ac97c_readl(chip, MR);
  14300. + word &= ~(AC97C_MR_VRA);
  14301. + ac97c_writel(chip, MR, word);
  14302. + }
  14303. +
  14304. + /* Set rate */
  14305. + snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate);
  14306. +
  14307. + buffer_size = frames_to_bytes(runtime, runtime->period_size) *
  14308. + runtime->periods;
  14309. +
  14310. + chip->dma.req_rx.buffer_size = buffer_size;
  14311. + chip->dma.req_rx.periods = runtime->periods;
  14312. +
  14313. + BUG_ON(chip->dma.req_rx.buffer_size !=
  14314. + (chip->dma.req_rx.periods *
  14315. + frames_to_bytes(runtime, runtime->period_size)));
  14316. +
  14317. + chip->dma.req_rx.buffer_start = runtime->dma_addr;
  14318. + chip->dma.req_rx.data_reg = (dma_addr_t)(chip->regs + AC97C_CARHR + 2);
  14319. + chip->dma.req_rx.periph_id = chip->dma.rx_periph_id;
  14320. + chip->dma.req_rx.direction = DMA_DIR_PERIPH_TO_MEM;
  14321. + chip->dma.req_rx.width = DMA_WIDTH_16BIT;
  14322. + chip->dma.req_rx.dev_id = chip;
  14323. +
  14324. + return 0;
  14325. +}
  14326. +
  14327. + static int
  14328. +snd_atmel_ac97_playback_trigger(struct snd_pcm_substream *substream, int cmd)
  14329. +{
  14330. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14331. + unsigned long camr;
  14332. + int flags, err = 0;
  14333. +
  14334. + spin_lock_irqsave(&chip->lock, flags);
  14335. + camr = ac97c_readl(chip, CAMR);
  14336. +
  14337. + switch (cmd) {
  14338. + case SNDRV_PCM_TRIGGER_START:
  14339. + err = dma_prepare_request_cyclic(chip->dma.req_tx.req.dmac,
  14340. + &chip->dma.req_tx);
  14341. + dma_start_request(chip->dma.req_tx.req.dmac,
  14342. + chip->dma.req_tx.req.channel);
  14343. + camr |= AC97C_CMR_CENA;
  14344. + break;
  14345. + case SNDRV_PCM_TRIGGER_STOP:
  14346. + err = dma_stop_request(chip->dma.req_tx.req.dmac,
  14347. + chip->dma.req_tx.req.channel);
  14348. + if (chip->opened <= 1)
  14349. + camr &= ~AC97C_CMR_CENA;
  14350. + break;
  14351. + default:
  14352. + err = -EINVAL;
  14353. + break;
  14354. + }
  14355. +
  14356. + ac97c_writel(chip, CAMR, camr);
  14357. +
  14358. + spin_unlock_irqrestore(&chip->lock, flags);
  14359. + return err;
  14360. +}
  14361. +
  14362. + static int
  14363. +snd_atmel_ac97_capture_trigger(struct snd_pcm_substream *substream, int cmd)
  14364. +{
  14365. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14366. + unsigned long camr;
  14367. + int flags, err = 0;
  14368. +
  14369. + spin_lock_irqsave(&chip->lock, flags);
  14370. + camr = ac97c_readl(chip, CAMR);
  14371. +
  14372. + switch (cmd) {
  14373. + case SNDRV_PCM_TRIGGER_START:
  14374. + err = dma_prepare_request_cyclic(chip->dma.req_rx.req.dmac,
  14375. + &chip->dma.req_rx);
  14376. + dma_start_request(chip->dma.req_rx.req.dmac,
  14377. + chip->dma.req_rx.req.channel);
  14378. + camr |= AC97C_CMR_CENA;
  14379. + break;
  14380. + case SNDRV_PCM_TRIGGER_STOP:
  14381. + err = dma_stop_request(chip->dma.req_rx.req.dmac,
  14382. + chip->dma.req_rx.req.channel);
  14383. + mutex_lock(&opened_mutex);
  14384. + if (chip->opened <= 1)
  14385. + camr &= ~AC97C_CMR_CENA;
  14386. + mutex_unlock(&opened_mutex);
  14387. + break;
  14388. + default:
  14389. + err = -EINVAL;
  14390. + break;
  14391. + }
  14392. +
  14393. + ac97c_writel(chip, CAMR, camr);
  14394. +
  14395. + spin_unlock_irqrestore(&chip->lock, flags);
  14396. + return err;
  14397. +}
  14398. +
  14399. + static snd_pcm_uframes_t
  14400. +snd_atmel_ac97_playback_pointer(struct snd_pcm_substream *substream)
  14401. +{
  14402. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14403. + struct snd_pcm_runtime *runtime = substream->runtime;
  14404. + snd_pcm_uframes_t pos;
  14405. + unsigned long bytes;
  14406. +
  14407. + bytes = (dma_get_current_pos
  14408. + (chip->dma.req_tx.req.dmac,
  14409. + chip->dma.req_tx.req.channel) - runtime->dma_addr);
  14410. + pos = bytes_to_frames(runtime, bytes);
  14411. + if (pos >= runtime->buffer_size)
  14412. + pos -= runtime->buffer_size;
  14413. +
  14414. + return pos;
  14415. +}
  14416. +
  14417. + static snd_pcm_uframes_t
  14418. +snd_atmel_ac97_capture_pointer(struct snd_pcm_substream *substream)
  14419. +{
  14420. + struct atmel_ac97 *chip = snd_pcm_substream_chip(substream);
  14421. + struct snd_pcm_runtime *runtime = substream->runtime;
  14422. + snd_pcm_uframes_t pos;
  14423. + unsigned long bytes;
  14424. +
  14425. + bytes = (dma_get_current_pos
  14426. + (chip->dma.req_rx.req.dmac,
  14427. + chip->dma.req_rx.req.channel)
  14428. + - runtime->dma_addr);
  14429. + pos = bytes_to_frames(runtime, bytes);
  14430. + if (pos >= runtime->buffer_size)
  14431. + pos -= runtime->buffer_size;
  14432. +
  14433. +
  14434. + return pos;
  14435. +}
  14436. +
  14437. +static struct snd_pcm_ops atmel_ac97_playback_ops = {
  14438. + .open = snd_atmel_ac97_playback_open,
  14439. + .close = snd_atmel_ac97_playback_close,
  14440. + .ioctl = snd_pcm_lib_ioctl,
  14441. + .hw_params = snd_atmel_ac97_playback_hw_params,
  14442. + .hw_free = snd_atmel_ac97_playback_hw_free,
  14443. + .prepare = snd_atmel_ac97_playback_prepare,
  14444. + .trigger = snd_atmel_ac97_playback_trigger,
  14445. + .pointer = snd_atmel_ac97_playback_pointer,
  14446. +};
  14447. +
  14448. +static struct snd_pcm_ops atmel_ac97_capture_ops = {
  14449. + .open = snd_atmel_ac97_capture_open,
  14450. + .close = snd_atmel_ac97_capture_close,
  14451. + .ioctl = snd_pcm_lib_ioctl,
  14452. + .hw_params = snd_atmel_ac97_capture_hw_params,
  14453. + .hw_free = snd_atmel_ac97_capture_hw_free,
  14454. + .prepare = snd_atmel_ac97_capture_prepare,
  14455. + .trigger = snd_atmel_ac97_capture_trigger,
  14456. + .pointer = snd_atmel_ac97_capture_pointer,
  14457. +};
  14458. +
  14459. +static struct ac97_pcm atmel_ac97_pcm_defs[] __devinitdata = {
  14460. + /* Playback */
  14461. + {
  14462. + .exclusive = 1,
  14463. + .r = { {
  14464. + .slots = ((1 << AC97_SLOT_PCM_LEFT)
  14465. + | (1 << AC97_SLOT_PCM_RIGHT)
  14466. + | (1 << AC97_SLOT_PCM_CENTER)
  14467. + | (1 << AC97_SLOT_PCM_SLEFT)
  14468. + | (1 << AC97_SLOT_PCM_SRIGHT)
  14469. + | (1 << AC97_SLOT_LFE)),
  14470. + } }
  14471. + },
  14472. + /* PCM in */
  14473. + {
  14474. + .stream = 1,
  14475. + .exclusive = 1,
  14476. + .r = { {
  14477. + .slots = ((1 << AC97_SLOT_PCM_LEFT)
  14478. + | (1 << AC97_SLOT_PCM_RIGHT)),
  14479. + } }
  14480. + },
  14481. + /* Mic in */
  14482. + {
  14483. + .stream = 1,
  14484. + .exclusive = 1,
  14485. + .r = { {
  14486. + .slots = (1<<AC97_SLOT_MIC),
  14487. + } }
  14488. + },
  14489. +};
  14490. +
  14491. +static int __devinit snd_atmel_ac97_pcm_new(struct atmel_ac97 *chip)
  14492. +{
  14493. + struct snd_pcm *pcm;
  14494. + int err;
  14495. +
  14496. + err = snd_ac97_pcm_assign(chip->ac97_bus,
  14497. + ARRAY_SIZE(atmel_ac97_pcm_defs),
  14498. + atmel_ac97_pcm_defs);
  14499. + if (err)
  14500. + return err;
  14501. +
  14502. + err = snd_pcm_new(chip->card, "Atmel-AC97", 0, 1, 1, &pcm);
  14503. + if (err)
  14504. + return err;
  14505. +
  14506. + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
  14507. + &atmel_ac97_playback_ops);
  14508. +
  14509. + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
  14510. + &atmel_ac97_capture_ops);
  14511. +
  14512. + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
  14513. + &chip->pdev->dev,
  14514. + 128 * 1024, 128 * 1024);
  14515. +
  14516. + pcm->private_data = chip;
  14517. + pcm->info_flags = 0;
  14518. + strcpy(pcm->name, "Atmel-AC97");
  14519. + chip->pcm = pcm;
  14520. +
  14521. + return 0;
  14522. +}
  14523. +
  14524. +/*
  14525. + * Mixer part.
  14526. + */
  14527. +static int snd_atmel_ac97_mixer_new(struct atmel_ac97 *chip)
  14528. +{
  14529. + int err;
  14530. + struct snd_ac97_template template;
  14531. +
  14532. + memset(&template, 0, sizeof(template));
  14533. + template.private_data = chip;
  14534. + err = snd_ac97_mixer(chip->ac97_bus, &template, &chip->ac97);
  14535. +
  14536. + return err;
  14537. +}
  14538. +
  14539. +static void atmel_ac97_error(struct dma_request *_req)
  14540. +{
  14541. + struct dma_request_cyclic *req = to_dma_request_cyclic(_req);
  14542. + struct atmel_ac97 *chip = req->dev_id;
  14543. +
  14544. + dev_dbg(&chip->pdev->dev, "DMA Controller error, channel %d\n",
  14545. + req->req.channel);
  14546. +}
  14547. +
  14548. +static void atmel_ac97_block_complete(struct dma_request *_req)
  14549. +{
  14550. + struct dma_request_cyclic *req = to_dma_request_cyclic(_req);
  14551. + struct atmel_ac97 *chip = req->dev_id;
  14552. + if (req->periph_id == chip->dma.tx_periph_id)
  14553. + snd_pcm_period_elapsed(chip->playback_substream);
  14554. + else
  14555. + snd_pcm_period_elapsed(chip->capture_substream);
  14556. +}
  14557. +
  14558. +/*
  14559. + * Codec part.
  14560. + */
  14561. +static void snd_atmel_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
  14562. + unsigned short val)
  14563. +{
  14564. + struct atmel_ac97 *chip = get_chip(ac97);
  14565. + unsigned long word;
  14566. + int timeout = 40;
  14567. +
  14568. + word = (reg & 0x7f) << 16 | val;
  14569. +
  14570. + do {
  14571. + if (ac97c_readl(chip, COSR) & AC97C_CSR_TXRDY) {
  14572. + ac97c_writel(chip, COTHR, word);
  14573. + return;
  14574. + }
  14575. + udelay(1);
  14576. + } while (--timeout);
  14577. +
  14578. + dev_dbg(&chip->pdev->dev, "codec write timeout\n");
  14579. +}
  14580. +
  14581. +static unsigned short snd_atmel_ac97_read(struct snd_ac97 *ac97,
  14582. + unsigned short reg)
  14583. +{
  14584. + struct atmel_ac97 *chip = get_chip(ac97);
  14585. + unsigned long word;
  14586. + int timeout = 40;
  14587. + int write = 10;
  14588. +
  14589. + word = (0x80 | (reg & 0x7f)) << 16;
  14590. +
  14591. + if ((ac97c_readl(chip, COSR) & AC97C_CSR_RXRDY) != 0)
  14592. + ac97c_readl(chip, CORHR);
  14593. +
  14594. +retry_write:
  14595. + timeout = 40;
  14596. +
  14597. + do {
  14598. + if ((ac97c_readl(chip, COSR) & AC97C_CSR_TXRDY) != 0) {
  14599. + ac97c_writel(chip, COTHR, word);
  14600. + goto read_reg;
  14601. + }
  14602. + udelay(10);
  14603. + } while (--timeout);
  14604. +
  14605. + if (!--write)
  14606. + goto timed_out;
  14607. + goto retry_write;
  14608. +
  14609. +read_reg:
  14610. + do {
  14611. + if ((ac97c_readl(chip, COSR) & AC97C_CSR_RXRDY) != 0) {
  14612. + unsigned short val = ac97c_readl(chip, CORHR);
  14613. + return val;
  14614. + }
  14615. + udelay(10);
  14616. + } while (--timeout);
  14617. +
  14618. + if (!--write)
  14619. + goto timed_out;
  14620. + goto retry_write;
  14621. +
  14622. +timed_out:
  14623. + dev_dbg(&chip->pdev->dev, "codec read timeout\n");
  14624. + return 0xffff;
  14625. +}
  14626. +
  14627. +static void snd_atmel_ac97_reset(struct atmel_ac97 *chip)
  14628. +{
  14629. + ac97c_writel(chip, MR, AC97C_MR_WRST);
  14630. + mdelay(1);
  14631. + ac97c_writel(chip, MR, AC97C_MR_ENA);
  14632. +}
  14633. +
  14634. +static void snd_atmel_ac97_destroy(struct snd_card *card)
  14635. +{
  14636. + struct atmel_ac97 *chip = get_chip(card);
  14637. +
  14638. + if (chip->regs)
  14639. + iounmap(chip->regs);
  14640. +
  14641. + if (chip->mck) {
  14642. + clk_disable(chip->mck);
  14643. + clk_put(chip->mck);
  14644. + }
  14645. +
  14646. + if (chip->dma.req_tx.req.dmac) {
  14647. + dma_release_channel(chip->dma.req_tx.req.dmac,
  14648. + chip->dma.req_tx.req.channel);
  14649. + }
  14650. + if (chip->dma.req_rx.req.dmac) {
  14651. + dma_release_channel(chip->dma.req_rx.req.dmac,
  14652. + chip->dma.req_rx.req.channel);
  14653. + }
  14654. +}
  14655. +
  14656. +static int __devinit snd_atmel_ac97_create(struct snd_card *card,
  14657. + struct platform_device *pdev)
  14658. +{
  14659. + static struct snd_ac97_bus_ops ops = {
  14660. + .write = snd_atmel_ac97_write,
  14661. + .read = snd_atmel_ac97_read,
  14662. + };
  14663. + struct atmel_ac97 *chip = get_chip(card);
  14664. + struct resource *regs;
  14665. + struct clk *mck;
  14666. + int err;
  14667. +
  14668. + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  14669. + if (!regs)
  14670. + return -ENXIO;
  14671. +
  14672. + mck = clk_get(&pdev->dev, "pclk");
  14673. + if (IS_ERR(mck))
  14674. + return PTR_ERR(mck);
  14675. + clk_enable(mck);
  14676. + chip->mck = mck;
  14677. +
  14678. + card->private_free = snd_atmel_ac97_destroy;
  14679. +
  14680. + spin_lock_init(&chip->lock);
  14681. + chip->card = card;
  14682. + chip->pdev = pdev;
  14683. +
  14684. + chip->regs = ioremap(regs->start, regs->end - regs->start + 1);
  14685. + if (!chip->regs)
  14686. + return -ENOMEM;
  14687. +
  14688. + snd_card_set_dev(card, &pdev->dev);
  14689. +
  14690. + err = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus);
  14691. +
  14692. + return err;
  14693. +}
  14694. +
  14695. +static int __devinit snd_atmel_ac97_probe(struct platform_device *pdev)
  14696. +{
  14697. + static int dev;
  14698. + struct snd_card *card;
  14699. + struct atmel_ac97 *chip;
  14700. + int err;
  14701. + int ch;
  14702. +
  14703. + mutex_init(&opened_mutex);
  14704. +
  14705. + err = -ENOMEM;
  14706. + card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
  14707. + THIS_MODULE, sizeof(struct atmel_ac97));
  14708. + if (!card)
  14709. + goto out;
  14710. + chip = get_chip(card);
  14711. +
  14712. + err = snd_atmel_ac97_create(card, pdev);
  14713. + if (err)
  14714. + goto out_free_card;
  14715. +
  14716. + snd_atmel_ac97_reset(chip);
  14717. +
  14718. + err = snd_atmel_ac97_mixer_new(chip);
  14719. + if (err)
  14720. + goto out_free_card;
  14721. +
  14722. + err = snd_atmel_ac97_pcm_new(chip);
  14723. + if (err)
  14724. + goto out_free_card;
  14725. +
  14726. + /* TODO: Get this information from the platform device */
  14727. + chip->dma.req_tx.req.dmac = find_dma_controller(0);
  14728. + if (!chip->dma.req_tx.req.dmac) {
  14729. + dev_dbg(&chip->pdev->dev, "DMA controller for TX missing\n");
  14730. + err = -ENODEV;
  14731. + goto out_free_card;
  14732. + }
  14733. + chip->dma.req_rx.req.dmac = find_dma_controller(0);
  14734. + if (!chip->dma.req_rx.req.dmac) {
  14735. + dev_dbg(&chip->pdev->dev, "DMA controller for RX missing\n");
  14736. + err = -ENODEV;
  14737. + goto out_free_card;
  14738. + }
  14739. +
  14740. + chip->dma.rx_periph_id = 3;
  14741. + chip->dma.tx_periph_id = 4;
  14742. +
  14743. + ch = dma_alloc_channel(chip->dma.req_tx.req.dmac);
  14744. + if (ch < 0) {
  14745. + dev_dbg(&chip->pdev->dev,
  14746. + "could not allocate TX DMA channel\n");
  14747. + err = ch;
  14748. + goto out_free_card;
  14749. + }
  14750. + chip->dma.req_tx.req.channel = ch;
  14751. + chip->dma.req_tx.width = DMA_WIDTH_16BIT;
  14752. + chip->dma.req_tx.req.block_complete = atmel_ac97_block_complete;
  14753. + chip->dma.req_tx.req.error = atmel_ac97_error;
  14754. +
  14755. + ch = dma_alloc_channel(chip->dma.req_rx.req.dmac);
  14756. + if (ch < 0) {
  14757. + dev_dbg(&chip->pdev->dev,
  14758. + "could not allocate RX DMA channel\n");
  14759. + err = ch;
  14760. + goto out_free_card;
  14761. + }
  14762. + chip->dma.req_rx.req.channel = ch;
  14763. + chip->dma.req_rx.width = DMA_WIDTH_16BIT;
  14764. + chip->dma.req_rx.req.block_complete = atmel_ac97_block_complete;
  14765. + chip->dma.req_rx.req.error = atmel_ac97_error;
  14766. +
  14767. + strcpy(card->driver, "atmel_ac97c");
  14768. + strcpy(card->shortname, "atmel_ac97c");
  14769. + sprintf(card->longname, "Atmel AVR32 AC97 controller");
  14770. +
  14771. + err = snd_card_register(card);
  14772. + if (err)
  14773. + goto out_free_card;
  14774. +
  14775. + platform_set_drvdata(pdev, card);
  14776. + dev++;
  14777. +
  14778. + dev_info(&pdev->dev, "Atmel AVR32 AC97 controller at 0x%p\n",
  14779. + chip->regs);
  14780. +
  14781. + return 0;
  14782. +
  14783. +out_free_card:
  14784. + snd_card_free(card);
  14785. +out:
  14786. + return err;
  14787. +}
  14788. +
  14789. +#ifdef CONFIG_PM
  14790. + static int
  14791. +snd_atmel_ac97_suspend(struct platform_device *pdev, pm_message_t msg)
  14792. +{
  14793. + struct snd_card *card = platform_get_drvdata(pdev);
  14794. + struct atmel_ac97 *chip = card->private_data;
  14795. +
  14796. + clk_disable(chip->mck);
  14797. +
  14798. + return 0;
  14799. +}
  14800. +
  14801. +static int snd_atmel_ac97_resume(struct platform_device *pdev)
  14802. +{
  14803. + struct snd_card *card = dev_get_drvdata(pdev);
  14804. + struct atmel_ac97 *chip = card->private_data;
  14805. +
  14806. + clk_enable(chip->mck);
  14807. +
  14808. + return 0;
  14809. +}
  14810. +#else
  14811. +#define snd_atmel_ac97_suspend NULL
  14812. +#define snd_atmel_ac97_resume NULL
  14813. +#endif
  14814. +
  14815. +static int __devexit snd_atmel_ac97_remove(struct platform_device *pdev)
  14816. +{
  14817. + struct snd_card *card = platform_get_drvdata(pdev);
  14818. +
  14819. + snd_card_free(card);
  14820. + platform_set_drvdata(pdev, NULL);
  14821. + return 0;
  14822. +}
  14823. +
  14824. +static struct platform_driver atmel_ac97_driver = {
  14825. + .remove = __devexit_p(snd_atmel_ac97_remove),
  14826. + .driver = {
  14827. + .name = "atmel_ac97c",
  14828. + },
  14829. + .suspend = snd_atmel_ac97_suspend,
  14830. + .resume = snd_atmel_ac97_resume,
  14831. +};
  14832. +
  14833. +static int __init atmel_ac97_init(void)
  14834. +{
  14835. + return platform_driver_probe(&atmel_ac97_driver,
  14836. + snd_atmel_ac97_probe);
  14837. +}
  14838. +module_init(atmel_ac97_init);
  14839. +
  14840. +static void __exit atmel_ac97_exit(void)
  14841. +{
  14842. + platform_driver_unregister(&atmel_ac97_driver);
  14843. +}
  14844. +module_exit(atmel_ac97_exit);
  14845. +
  14846. +MODULE_LICENSE("GPL");
  14847. +MODULE_DESCRIPTION("Driver for Atmel AC97 Controller");
  14848. +MODULE_AUTHOR("Haavard Skinnemoen <[email protected]>");
  14849. --- /dev/null
  14850. +++ b/sound/avr32/ac97c.h
  14851. @@ -0,0 +1,71 @@
  14852. +/*
  14853. + * Register definitions for the Atmel AC97 Controller.
  14854. + *
  14855. + * Copyright (C) 2005-2006 Atmel Corporation
  14856. + *
  14857. + * This program is free software; you can redistribute it and/or modify
  14858. + * it under the terms of the GNU General Public License version 2 as
  14859. + * published by the Free Software Foundation.
  14860. + */
  14861. +#ifndef __SOUND_AVR32_AC97C_H
  14862. +#define __SOUND_AVR32_AC97C_H
  14863. +
  14864. +#define AC97C_MR 0x08
  14865. +#define AC97C_ICA 0x10
  14866. +#define AC97C_OCA 0x14
  14867. +#define AC97C_CARHR 0x20
  14868. +#define AC97C_CATHR 0x24
  14869. +#define AC97C_CASR 0x28
  14870. +#define AC97C_CAMR 0x2c
  14871. +#define AC97C_CBRHR 0x30
  14872. +#define AC97C_CBTHR 0x34
  14873. +#define AC97C_CBSR 0x38
  14874. +#define AC97C_CBMR 0x3c
  14875. +#define AC97C_CORHR 0x40
  14876. +#define AC97C_COTHR 0x44
  14877. +#define AC97C_COSR 0x48
  14878. +#define AC97C_COMR 0x4c
  14879. +#define AC97C_SR 0x50
  14880. +#define AC97C_IER 0x54
  14881. +#define AC97C_IDR 0x58
  14882. +#define AC97C_IMR 0x5c
  14883. +#define AC97C_VERSION 0xfc
  14884. +
  14885. +#define AC97C_CATPR PDC_TPR
  14886. +#define AC97C_CATCR PDC_TCR
  14887. +#define AC97C_CATNPR PDC_TNPR
  14888. +#define AC97C_CATNCR PDC_TNCR
  14889. +#define AC97C_CARPR PDC_RPR
  14890. +#define AC97C_CARCR PDC_RCR
  14891. +#define AC97C_CARNPR PDC_RNPR
  14892. +#define AC97C_CARNCR PDC_RNCR
  14893. +#define AC97C_PTCR PDC_PTCR
  14894. +
  14895. +#define AC97C_MR_ENA (1 << 0)
  14896. +#define AC97C_MR_WRST (1 << 1)
  14897. +#define AC97C_MR_VRA (1 << 2)
  14898. +
  14899. +#define AC97C_CSR_TXRDY (1 << 0)
  14900. +#define AC97C_CSR_UNRUN (1 << 2)
  14901. +#define AC97C_CSR_RXRDY (1 << 4)
  14902. +#define AC97C_CSR_ENDTX (1 << 10)
  14903. +#define AC97C_CSR_ENDRX (1 << 14)
  14904. +
  14905. +#define AC97C_CMR_SIZE_20 (0 << 16)
  14906. +#define AC97C_CMR_SIZE_18 (1 << 16)
  14907. +#define AC97C_CMR_SIZE_16 (2 << 16)
  14908. +#define AC97C_CMR_SIZE_10 (3 << 16)
  14909. +#define AC97C_CMR_CEM_LITTLE (1 << 18)
  14910. +#define AC97C_CMR_CEM_BIG (0 << 18)
  14911. +#define AC97C_CMR_CENA (1 << 21)
  14912. +#define AC97C_CMR_PDCEN (1 << 22)
  14913. +
  14914. +#define AC97C_SR_CAEVT (1 << 3)
  14915. +
  14916. +#define AC97C_CH_ASSIGN(slot, channel) \
  14917. + (AC97C_CHANNEL_##channel << (3 * (AC97_SLOT_##slot - 3)))
  14918. +#define AC97C_CHANNEL_NONE 0x0
  14919. +#define AC97C_CHANNEL_A 0x1
  14920. +#define AC97C_CHANNEL_B 0x2
  14921. +
  14922. +#endif /* __SOUND_AVR32_AC97C_H */
  14923. --- /dev/null
  14924. +++ b/sound/avr32/Kconfig
  14925. @@ -0,0 +1,11 @@
  14926. +menu "AVR32 devices"
  14927. + depends on SND != n && AVR32
  14928. +
  14929. +config SND_ATMEL_AC97
  14930. + tristate "Atmel AC97 Controller Driver"
  14931. + select SND_PCM
  14932. + select SND_AC97_CODEC
  14933. + help
  14934. + ALSA sound driver for the Atmel AC97 controller.
  14935. +
  14936. +endmenu
  14937. --- /dev/null
  14938. +++ b/sound/avr32/Makefile
  14939. @@ -0,0 +1,3 @@
  14940. +snd-atmel-ac97-objs := ac97c.o
  14941. +
  14942. +obj-$(CONFIG_SND_ATMEL_AC97) += snd-atmel-ac97.o
  14943. --- a/sound/Kconfig
  14944. +++ b/sound/Kconfig
  14945. @@ -63,6 +63,8 @@
  14946. source "sound/arm/Kconfig"
  14947. +source "sound/avr32/Kconfig"
  14948. +
  14949. if SPI
  14950. source "sound/spi/Kconfig"
  14951. endif
  14952. --- a/sound/Makefile
  14953. +++ b/sound/Makefile
  14954. @@ -6,7 +6,7 @@
  14955. obj-$(CONFIG_SOUND_PRIME) += oss/
  14956. obj-$(CONFIG_DMASOUND) += oss/
  14957. obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ \
  14958. - sparc/ spi/ parisc/ pcmcia/ mips/ soc/
  14959. + sparc/ spi/ parisc/ pcmcia/ mips/ soc/ avr32/
  14960. obj-$(CONFIG_SND_AOA) += aoa/
  14961. # This one must be compilable even if sound is configured out
  14962. --- /dev/null
  14963. +++ b/sound/oss/at32_abdac.c
  14964. @@ -0,0 +1,722 @@
  14965. +/*
  14966. + * OSS Sound Driver for the Atmel AT32 on-chip DAC.
  14967. + *
  14968. + * Copyright (C) 2006 Atmel Corporation
  14969. + *
  14970. + * This program is free software; you can redistribute it and/or modify
  14971. + * it under the terms of the GNU General Public License version 2 as
  14972. + * published by the Free Software Foundation.
  14973. + */
  14974. +#include <linux/clk.h>
  14975. +#include <linux/dma-mapping.h>
  14976. +#include <linux/fs.h>
  14977. +#include <linux/init.h>
  14978. +#include <linux/interrupt.h>
  14979. +#include <linux/kernel.h>
  14980. +#include <linux/module.h>
  14981. +#include <linux/platform_device.h>
  14982. +#include <linux/sound.h>
  14983. +#include <linux/soundcard.h>
  14984. +
  14985. +#include <asm/byteorder.h>
  14986. +#include <asm/dma-controller.h>
  14987. +#include <asm/io.h>
  14988. +#include <asm/uaccess.h>
  14989. +
  14990. +/* We want to use the "bizarre" swap-bytes-in-each-halfword macro */
  14991. +#include <linux/byteorder/swabb.h>
  14992. +
  14993. +#include "at32_abdac.h"
  14994. +
  14995. +#define DMA_BUFFER_SIZE 32768
  14996. +#define DMA_PERIOD_SHIFT 10
  14997. +#define DMA_PERIOD_SIZE (1 << DMA_PERIOD_SHIFT)
  14998. +#define DMA_WRITE_THRESHOLD DMA_PERIOD_SIZE
  14999. +
  15000. +struct sound_settings {
  15001. + unsigned int format;
  15002. + unsigned int channels;
  15003. + unsigned int sample_rate;
  15004. + /* log2(bytes per sample) */
  15005. + unsigned int input_order;
  15006. +};
  15007. +
  15008. +struct at32_dac {
  15009. + spinlock_t lock;
  15010. + void __iomem *regs;
  15011. +
  15012. + /* head and tail refer to number of words */
  15013. + struct {
  15014. + u32 *buf;
  15015. + int head;
  15016. + int tail;
  15017. + } dma;
  15018. +
  15019. + struct semaphore sem;
  15020. + wait_queue_head_t write_wait;
  15021. +
  15022. + /*
  15023. + * Read at most ucount bytes from ubuf, translate to 2-channel
  15024. + * signed 16-bit big endian format and write to the DMA buffer
  15025. + * as long as there is room left. Return the number of bytes
  15026. + * successfully copied from ubuf, or -EFAULT if the first
  15027. + * sample from ubuf couldn't be read. This function is not
  15028. + * called unless there is room for at least one sample (4
  15029. + * bytes) in the DMA buffer.
  15030. + */
  15031. + ssize_t (*trans)(struct at32_dac *dac, const char __user *ubuf,
  15032. + size_t ucount);
  15033. +
  15034. + struct sound_settings dsp_settings;
  15035. + struct dma_request_cyclic req;
  15036. +
  15037. + struct clk *mck;
  15038. + struct clk *sample_clk;
  15039. + struct platform_device *pdev;
  15040. + int busy;
  15041. + int playing;
  15042. + int dev_dsp;
  15043. +};
  15044. +static struct at32_dac *the_dac;
  15045. +
  15046. +static inline unsigned int abdac_get_head(struct at32_dac *dac)
  15047. +{
  15048. + return dac->dma.head & ((DMA_BUFFER_SIZE / 4) - 1);
  15049. +}
  15050. +
  15051. +static inline unsigned int abdac_get_tail(struct at32_dac *dac)
  15052. +{
  15053. + return dac->dma.tail & ((DMA_BUFFER_SIZE / 4) - 1);
  15054. +}
  15055. +
  15056. +static inline unsigned int abdac_dma_space(struct at32_dac *dac)
  15057. +{
  15058. + unsigned int space;
  15059. +
  15060. + space = ((dac->dma.tail - dac->dma.head - 1)
  15061. + & ((DMA_BUFFER_SIZE / 4) - 1));
  15062. + return space;
  15063. +}
  15064. +
  15065. +static void abdac_update_dma_tail(struct at32_dac *dac)
  15066. +{
  15067. + dma_addr_t dma_addr;
  15068. + unsigned int new_tail;
  15069. +
  15070. + if (dac->playing) {
  15071. + dma_addr = dma_get_current_pos(dac->req.req.dmac,
  15072. + dac->req.req.channel);
  15073. + new_tail = (dma_addr - dac->req.buffer_start) / 4;
  15074. + if (new_tail >= dac->dma.head
  15075. + && (dac->dma.tail < dac->dma.head
  15076. + || dac->dma.tail > new_tail))
  15077. + dev_notice(&dac->pdev->dev, "DMA underrun detected!\n");
  15078. + dac->dma.tail = new_tail;
  15079. + dev_dbg(&dac->pdev->dev, "update tail: 0x%x - 0x%x = %u\n",
  15080. + dma_addr, dac->req.buffer_start, dac->dma.tail);
  15081. + }
  15082. +}
  15083. +
  15084. +static int abdac_start(struct at32_dac *dac)
  15085. +{
  15086. + int ret;
  15087. +
  15088. + if (dac->playing)
  15089. + return 0;
  15090. +
  15091. + memset(dac->dma.buf, 0, DMA_BUFFER_SIZE);
  15092. +
  15093. + clk_enable(dac->sample_clk);
  15094. +
  15095. + ret = dma_prepare_request_cyclic(dac->req.req.dmac, &dac->req);
  15096. + if (ret)
  15097. + goto out_stop_clock;
  15098. +
  15099. + dev_dbg(&dac->pdev->dev, "starting DMA...\n");
  15100. + ret = dma_start_request(dac->req.req.dmac, dac->req.req.channel);
  15101. + if (ret)
  15102. + goto out_stop_request;
  15103. +
  15104. + dac_writel(dac, CTRL, DAC_BIT(EN));
  15105. + dac->playing = 1;
  15106. +
  15107. + return 0;
  15108. +
  15109. +out_stop_request:
  15110. + dma_stop_request(dac->req.req.dmac,
  15111. + dac->req.req.channel);
  15112. +out_stop_clock:
  15113. + clk_disable(dac->sample_clk);
  15114. + return ret;
  15115. +}
  15116. +
  15117. +static int abdac_stop(struct at32_dac *dac)
  15118. +{
  15119. + if (dac->playing) {
  15120. + dma_stop_request(dac->req.req.dmac, dac->req.req.channel);
  15121. + dac_writel(dac, DATA, 0);
  15122. + dac_writel(dac, CTRL, 0);
  15123. + dac->playing = 0;
  15124. + clk_disable(dac->sample_clk);
  15125. + }
  15126. +
  15127. + return 0;
  15128. +}
  15129. +
  15130. +static int abdac_dma_prepare(struct at32_dac *dac)
  15131. +{
  15132. + dac->dma.buf = dma_alloc_coherent(&dac->pdev->dev, DMA_BUFFER_SIZE,
  15133. + &dac->req.buffer_start, GFP_KERNEL);
  15134. + if (!dac->dma.buf)
  15135. + return -ENOMEM;
  15136. +
  15137. + dac->dma.head = dac->dma.tail = 0;
  15138. + dac->req.periods = DMA_BUFFER_SIZE / DMA_PERIOD_SIZE;
  15139. + dac->req.buffer_size = DMA_BUFFER_SIZE;
  15140. +
  15141. + return 0;
  15142. +}
  15143. +
  15144. +static void abdac_dma_cleanup(struct at32_dac *dac)
  15145. +{
  15146. + if (dac->dma.buf)
  15147. + dma_free_coherent(&dac->pdev->dev, DMA_BUFFER_SIZE,
  15148. + dac->dma.buf, dac->req.buffer_start);
  15149. + dac->dma.buf = NULL;
  15150. +}
  15151. +
  15152. +static void abdac_dma_block_complete(struct dma_request *req)
  15153. +{
  15154. + struct dma_request_cyclic *creq = to_dma_request_cyclic(req);
  15155. + struct at32_dac *dac = container_of(creq, struct at32_dac, req);
  15156. +
  15157. + wake_up(&dac->write_wait);
  15158. +}
  15159. +
  15160. +static void abdac_dma_error(struct dma_request *req)
  15161. +{
  15162. + struct dma_request_cyclic *creq = to_dma_request_cyclic(req);
  15163. + struct at32_dac *dac = container_of(creq, struct at32_dac, req);
  15164. +
  15165. + dev_err(&dac->pdev->dev, "DMA error\n");
  15166. +}
  15167. +
  15168. +static irqreturn_t abdac_interrupt(int irq, void *dev_id)
  15169. +{
  15170. + struct at32_dac *dac = dev_id;
  15171. + u32 status;
  15172. +
  15173. + status = dac_readl(dac, INT_STATUS);
  15174. + if (status & DAC_BIT(UNDERRUN)) {
  15175. + dev_err(&dac->pdev->dev, "Underrun detected!\n");
  15176. + dac_writel(dac, INT_CLR, DAC_BIT(UNDERRUN));
  15177. + } else {
  15178. + dev_err(&dac->pdev->dev, "Spurious interrupt (status=0x%x)\n",
  15179. + status);
  15180. + dac_writel(dac, INT_CLR, status);
  15181. + }
  15182. +
  15183. + return IRQ_HANDLED;
  15184. +}
  15185. +
  15186. +static ssize_t trans_s16be(struct at32_dac *dac, const char __user *ubuf,
  15187. + size_t ucount)
  15188. +{
  15189. + ssize_t ret;
  15190. +
  15191. + if (dac->dsp_settings.channels == 2) {
  15192. + const u32 __user *up = (const u32 __user *)ubuf;
  15193. + u32 sample;
  15194. +
  15195. + for (ret = 0; ret < (ssize_t)(ucount - 3); ret += 4) {
  15196. + if (!abdac_dma_space(dac))
  15197. + break;
  15198. +
  15199. + if (unlikely(__get_user(sample, up++))) {
  15200. + if (ret == 0)
  15201. + ret = -EFAULT;
  15202. + break;
  15203. + }
  15204. + dac->dma.buf[abdac_get_head(dac)] = sample;
  15205. + dac->dma.head++;
  15206. + }
  15207. + } else {
  15208. + const u16 __user *up = (const u16 __user *)ubuf;
  15209. + u16 sample;
  15210. +
  15211. + for (ret = 0; ret < (ssize_t)(ucount - 1); ret += 2) {
  15212. + if (!abdac_dma_space(dac))
  15213. + break;
  15214. +
  15215. + if (unlikely(__get_user(sample, up++))) {
  15216. + if (ret == 0)
  15217. + ret = -EFAULT;
  15218. + break;
  15219. + }
  15220. + dac->dma.buf[abdac_get_head(dac)]
  15221. + = (sample << 16) | sample;
  15222. + dac->dma.head++;
  15223. + }
  15224. + }
  15225. +
  15226. + return ret;
  15227. +}
  15228. +
  15229. +static ssize_t trans_s16le(struct at32_dac *dac, const char __user *ubuf,
  15230. + size_t ucount)
  15231. +{
  15232. + ssize_t ret;
  15233. +
  15234. + if (dac->dsp_settings.channels == 2) {
  15235. + const u32 __user *up = (const u32 __user *)ubuf;
  15236. + u32 sample;
  15237. +
  15238. + for (ret = 0; ret < (ssize_t)(ucount - 3); ret += 4) {
  15239. + if (!abdac_dma_space(dac))
  15240. + break;
  15241. +
  15242. + if (unlikely(__get_user(sample, up++))) {
  15243. + if (ret == 0)
  15244. + ret = -EFAULT;
  15245. + break;
  15246. + }
  15247. + /* Swap bytes in each halfword */
  15248. + dac->dma.buf[abdac_get_head(dac)] = swahb32(sample);
  15249. + dac->dma.head++;
  15250. + }
  15251. + } else {
  15252. + const u16 __user *up = (const u16 __user *)ubuf;
  15253. + u16 sample;
  15254. +
  15255. + for (ret = 0; ret < (ssize_t)(ucount - 1); ret += 2) {
  15256. + if (!abdac_dma_space(dac))
  15257. + break;
  15258. +
  15259. + if (unlikely(__get_user(sample, up++))) {
  15260. + if (ret == 0)
  15261. + ret = -EFAULT;
  15262. + break;
  15263. + }
  15264. + sample = swab16(sample);
  15265. + dac->dma.buf[abdac_get_head(dac)]
  15266. + = (sample << 16) | sample;
  15267. + dac->dma.head++;
  15268. + }
  15269. + }
  15270. +
  15271. + return ret;
  15272. +}
  15273. +
  15274. +static ssize_t abdac_dma_translate_from_user(struct at32_dac *dac,
  15275. + const char __user *buffer,
  15276. + size_t count)
  15277. +{
  15278. + /* At least one buffer must be available at this point */
  15279. + dev_dbg(&dac->pdev->dev, "copying %zu bytes from user...\n", count);
  15280. +
  15281. + return dac->trans(dac, buffer, count);
  15282. +}
  15283. +
  15284. +static int abdac_set_format(struct at32_dac *dac, int format)
  15285. +{
  15286. + unsigned int order;
  15287. +
  15288. + switch (format) {
  15289. + case AFMT_S16_BE:
  15290. + order = 1;
  15291. + dac->trans = trans_s16be;
  15292. + break;
  15293. + case AFMT_S16_LE:
  15294. + order = 1;
  15295. + dac->trans = trans_s16le;
  15296. + break;
  15297. + default:
  15298. + dev_dbg(&dac->pdev->dev, "unsupported format: %d\n", format);
  15299. + return -EINVAL;
  15300. + }
  15301. +
  15302. + if (dac->dsp_settings.channels == 2)
  15303. + order++;
  15304. +
  15305. + dac->dsp_settings.input_order = order;
  15306. + dac->dsp_settings.format = format;
  15307. + return 0;
  15308. +}
  15309. +
  15310. +static int abdac_set_sample_rate(struct at32_dac *dac, unsigned long rate)
  15311. +{
  15312. + unsigned long new_rate;
  15313. + int ret;
  15314. +
  15315. + ret = clk_set_rate(dac->sample_clk, 256 * rate);
  15316. + if (ret < 0)
  15317. + return ret;
  15318. +
  15319. + /* TODO: mplayer seems to have a problem with this */
  15320. +#if 0
  15321. + new_rate = clk_get_rate(dac->sample_clk);
  15322. + dac->dsp_settings.sample_rate = new_rate / 256;
  15323. +#else
  15324. + dac->dsp_settings.sample_rate = rate;
  15325. +#endif
  15326. +
  15327. + return 0;
  15328. +}
  15329. +
  15330. +static ssize_t abdac_dsp_write(struct file *file,
  15331. + const char __user *buffer,
  15332. + size_t count, loff_t *ppos)
  15333. +{
  15334. + struct at32_dac *dac = file->private_data;
  15335. + DECLARE_WAITQUEUE(wait, current);
  15336. + unsigned int avail;
  15337. + ssize_t copied;
  15338. + ssize_t ret;
  15339. +
  15340. + /* Avoid address space checking in the translation functions */
  15341. + if (!access_ok(buffer, count, VERIFY_READ))
  15342. + return -EFAULT;
  15343. +
  15344. + down(&dac->sem);
  15345. +
  15346. + if (!dac->dma.buf) {
  15347. + ret = abdac_dma_prepare(dac);
  15348. + if (ret)
  15349. + goto out;
  15350. + }
  15351. +
  15352. + add_wait_queue(&dac->write_wait, &wait);
  15353. + ret = 0;
  15354. + while (count > 0) {
  15355. + do {
  15356. + abdac_update_dma_tail(dac);
  15357. + avail = abdac_dma_space(dac);
  15358. + set_current_state(TASK_INTERRUPTIBLE);
  15359. + if (avail >= DMA_WRITE_THRESHOLD)
  15360. + break;
  15361. +
  15362. + if (file->f_flags & O_NONBLOCK) {
  15363. + if (!ret)
  15364. + ret = -EAGAIN;
  15365. + goto out;
  15366. + }
  15367. +
  15368. + pr_debug("Going to wait (avail = %u, count = %zu)\n",
  15369. + avail, count);
  15370. +
  15371. + up(&dac->sem);
  15372. + schedule();
  15373. + if (signal_pending(current)) {
  15374. + if (!ret)
  15375. + ret = -ERESTARTSYS;
  15376. + goto out_nosem;
  15377. + }
  15378. + down(&dac->sem);
  15379. + } while (1);
  15380. +
  15381. + copied = abdac_dma_translate_from_user(dac, buffer, count);
  15382. + if (copied < 0) {
  15383. + if (!ret)
  15384. + ret = -EFAULT;
  15385. + goto out;
  15386. + }
  15387. +
  15388. + abdac_start(dac);
  15389. +
  15390. + count -= copied;
  15391. + ret += copied;
  15392. + }
  15393. +
  15394. +out:
  15395. + up(&dac->sem);
  15396. +out_nosem:
  15397. + remove_wait_queue(&dac->write_wait, &wait);
  15398. + set_current_state(TASK_RUNNING);
  15399. + return ret;
  15400. +}
  15401. +
  15402. +static int abdac_dsp_ioctl(struct inode *inode, struct file *file,
  15403. + unsigned int cmd, unsigned long arg)
  15404. +{
  15405. + struct at32_dac *dac = file->private_data;
  15406. + int __user *up = (int __user *)arg;
  15407. + struct audio_buf_info abinfo;
  15408. + int val, ret;
  15409. +
  15410. + switch (cmd) {
  15411. + case OSS_GETVERSION:
  15412. + return put_user(SOUND_VERSION, up);
  15413. +
  15414. + case SNDCTL_DSP_SPEED:
  15415. + if (get_user(val, up))
  15416. + return -EFAULT;
  15417. + if (val >= 0) {
  15418. + abdac_stop(dac);
  15419. + ret = abdac_set_sample_rate(dac, val);
  15420. + if (ret)
  15421. + return ret;
  15422. + }
  15423. + return put_user(dac->dsp_settings.sample_rate, up);
  15424. +
  15425. + case SNDCTL_DSP_STEREO:
  15426. + if (get_user(val, up))
  15427. + return -EFAULT;
  15428. + abdac_stop(dac);
  15429. + if (val && dac->dsp_settings.channels == 1)
  15430. + dac->dsp_settings.input_order++;
  15431. + else if (!val && dac->dsp_settings.channels != 1)
  15432. + dac->dsp_settings.input_order--;
  15433. + dac->dsp_settings.channels = val ? 2 : 1;
  15434. + return 0;
  15435. +
  15436. + case SNDCTL_DSP_CHANNELS:
  15437. + if (get_user(val, up))
  15438. + return -EFAULT;
  15439. +
  15440. + if (val) {
  15441. + if (val < 0 || val > 2)
  15442. + return -EINVAL;
  15443. +
  15444. + abdac_stop(dac);
  15445. + dac->dsp_settings.input_order
  15446. + += val - dac->dsp_settings.channels;
  15447. + dac->dsp_settings.channels = val;
  15448. + }
  15449. + return put_user(val, (int *)arg);
  15450. +
  15451. + case SNDCTL_DSP_GETFMTS:
  15452. + return put_user(AFMT_S16_BE | AFMT_S16_BE, up);
  15453. +
  15454. + case SNDCTL_DSP_SETFMT:
  15455. + if (get_user(val, up))
  15456. + return -EFAULT;
  15457. +
  15458. + if (val == AFMT_QUERY) {
  15459. + val = dac->dsp_settings.format;
  15460. + } else {
  15461. + ret = abdac_set_format(dac, val);
  15462. + if (ret)
  15463. + return ret;
  15464. + }
  15465. + return put_user(val, up);
  15466. +
  15467. + case SNDCTL_DSP_GETOSPACE:
  15468. + abdac_update_dma_tail(dac);
  15469. + abinfo.fragsize = ((1 << dac->dsp_settings.input_order)
  15470. + * (DMA_PERIOD_SIZE / 4));
  15471. + abinfo.bytes = (abdac_dma_space(dac)
  15472. + << dac->dsp_settings.input_order);
  15473. + abinfo.fragstotal = ((DMA_BUFFER_SIZE * 4)
  15474. + >> (DMA_PERIOD_SHIFT
  15475. + + dac->dsp_settings.input_order));
  15476. + abinfo.fragments = ((abinfo.bytes
  15477. + >> dac->dsp_settings.input_order)
  15478. + / (DMA_PERIOD_SIZE / 4));
  15479. + pr_debug("fragments=%d fragstotal=%d fragsize=%d bytes=%d\n",
  15480. + abinfo.fragments, abinfo.fragstotal, abinfo.fragsize,
  15481. + abinfo.bytes);
  15482. + return copy_to_user(up, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
  15483. +
  15484. + default:
  15485. + dev_dbg(&dac->pdev->dev, "Unimplemented ioctl cmd: 0x%x\n", cmd);
  15486. + return -EINVAL;
  15487. + }
  15488. +}
  15489. +
  15490. +static int abdac_dsp_open(struct inode *inode, struct file *file)
  15491. +{
  15492. + struct at32_dac *dac = the_dac;
  15493. + int ret;
  15494. +
  15495. + if (file->f_mode & FMODE_READ)
  15496. + return -ENXIO;
  15497. +
  15498. + down(&dac->sem);
  15499. + ret = -EBUSY;
  15500. + if (dac->busy)
  15501. + goto out;
  15502. +
  15503. + dac->dma.head = dac->dma.tail = 0;
  15504. +
  15505. + /* FIXME: What are the correct defaults? */
  15506. + dac->dsp_settings.channels = 2;
  15507. + abdac_set_format(dac, AFMT_S16_BE);
  15508. + ret = abdac_set_sample_rate(dac, 8000);
  15509. + if (ret)
  15510. + goto out;
  15511. +
  15512. + file->private_data = dac;
  15513. + dac->busy = 1;
  15514. +
  15515. + ret = 0;
  15516. +
  15517. +out:
  15518. + up(&dac->sem);
  15519. + return ret;
  15520. +}
  15521. +
  15522. +static int abdac_dsp_release(struct inode *inode, struct file *file)
  15523. +{
  15524. + struct at32_dac *dac = file->private_data;
  15525. +
  15526. + down(&dac->sem);
  15527. +
  15528. + abdac_stop(dac);
  15529. + abdac_dma_cleanup(dac);
  15530. + dac->busy = 0;
  15531. +
  15532. + up(&dac->sem);
  15533. +
  15534. + return 0;
  15535. +}
  15536. +
  15537. +static struct file_operations abdac_dsp_fops = {
  15538. + .owner = THIS_MODULE,
  15539. + .llseek = no_llseek,
  15540. + .write = abdac_dsp_write,
  15541. + .ioctl = abdac_dsp_ioctl,
  15542. + .open = abdac_dsp_open,
  15543. + .release = abdac_dsp_release,
  15544. +};
  15545. +
  15546. +static int __init abdac_probe(struct platform_device *pdev)
  15547. +{
  15548. + struct at32_dac *dac;
  15549. + struct resource *regs;
  15550. + struct clk *mck;
  15551. + struct clk *sample_clk;
  15552. + int irq;
  15553. + int ret;
  15554. +
  15555. + if (the_dac)
  15556. + return -EBUSY;
  15557. +
  15558. + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  15559. + if (!regs)
  15560. + return -ENXIO;
  15561. + irq = platform_get_irq(pdev, 0);
  15562. + if (irq < 0)
  15563. + return irq;
  15564. +
  15565. + mck = clk_get(&pdev->dev, "pclk");
  15566. + if (IS_ERR(mck))
  15567. + return PTR_ERR(mck);
  15568. + sample_clk = clk_get(&pdev->dev, "sample_clk");
  15569. + if (IS_ERR(sample_clk)) {
  15570. + ret = PTR_ERR(sample_clk);
  15571. + goto out_put_mck;
  15572. + }
  15573. + clk_enable(mck);
  15574. +
  15575. + ret = -ENOMEM;
  15576. + dac = kzalloc(sizeof(struct at32_dac), GFP_KERNEL);
  15577. + if (!dac)
  15578. + goto out_disable_clk;
  15579. +
  15580. + spin_lock_init(&dac->lock);
  15581. + init_MUTEX(&dac->sem);
  15582. + init_waitqueue_head(&dac->write_wait);
  15583. + dac->pdev = pdev;
  15584. + dac->mck = mck;
  15585. + dac->sample_clk = sample_clk;
  15586. +
  15587. + dac->regs = ioremap(regs->start, regs->end - regs->start + 1);
  15588. + if (!dac->regs)
  15589. + goto out_free_dac;
  15590. +
  15591. + ret = request_irq(irq, abdac_interrupt, 0, "dac", dac);
  15592. + if (ret)
  15593. + goto out_unmap_regs;
  15594. +
  15595. + /* FIXME */
  15596. + dac->req.req.dmac = find_dma_controller(0);
  15597. + if (!dac->req.req.dmac)
  15598. + goto out_free_irq;
  15599. +
  15600. + ret = dma_alloc_channel(dac->req.req.dmac);
  15601. + if (ret < 0)
  15602. + goto out_free_irq;
  15603. +
  15604. + dac->req.req.channel = ret;
  15605. + dac->req.req.block_complete = abdac_dma_block_complete;
  15606. + dac->req.req.error = abdac_dma_error;
  15607. + dac->req.data_reg = regs->start + DAC_DATA;
  15608. + dac->req.periph_id = 2; /* FIXME */
  15609. + dac->req.direction = DMA_DIR_MEM_TO_PERIPH;
  15610. + dac->req.width = DMA_WIDTH_32BIT;
  15611. +
  15612. + /* Make sure the DAC is silent and disabled */
  15613. + dac_writel(dac, DATA, 0);
  15614. + dac_writel(dac, CTRL, 0);
  15615. +
  15616. + ret = register_sound_dsp(&abdac_dsp_fops, -1);
  15617. + if (ret < 0)
  15618. + goto out_free_dma;
  15619. + dac->dev_dsp = ret;
  15620. +
  15621. + /* TODO: Register mixer */
  15622. +
  15623. + the_dac = dac;
  15624. + platform_set_drvdata(pdev, dac);
  15625. +
  15626. + return 0;
  15627. +
  15628. +out_free_dma:
  15629. + dma_release_channel(dac->req.req.dmac, dac->req.req.channel);
  15630. +out_free_irq:
  15631. + free_irq(irq, dac);
  15632. +out_unmap_regs:
  15633. + iounmap(dac->regs);
  15634. +out_free_dac:
  15635. + kfree(dac);
  15636. +out_disable_clk:
  15637. + clk_disable(mck);
  15638. + clk_put(sample_clk);
  15639. +out_put_mck:
  15640. + clk_put(mck);
  15641. + return ret;
  15642. +}
  15643. +
  15644. +static int __exit abdac_remove(struct platform_device *pdev)
  15645. +{
  15646. + struct at32_dac *dac;
  15647. +
  15648. + dac = platform_get_drvdata(pdev);
  15649. + if (dac) {
  15650. + unregister_sound_dsp(dac->dev_dsp);
  15651. + dma_release_channel(dac->req.req.dmac, dac->req.req.channel);
  15652. + free_irq(platform_get_irq(pdev, 0), dac);
  15653. + iounmap(dac->regs);
  15654. + clk_disable(dac->mck);
  15655. + clk_put(dac->sample_clk);
  15656. + clk_put(dac->mck);
  15657. + kfree(dac);
  15658. + platform_set_drvdata(pdev, NULL);
  15659. + the_dac = NULL;
  15660. + }
  15661. +
  15662. + return 0;
  15663. +}
  15664. +
  15665. +static struct platform_driver abdac_driver = {
  15666. + .remove = __exit_p(abdac_remove),
  15667. + .driver = {
  15668. + .name = "abdac",
  15669. + },
  15670. +};
  15671. +
  15672. +static int __init abdac_init(void)
  15673. +{
  15674. + return platform_driver_probe(&abdac_driver, abdac_probe);
  15675. +}
  15676. +module_init(abdac_init);
  15677. +
  15678. +static void __exit abdac_exit(void)
  15679. +{
  15680. + platform_driver_unregister(&abdac_driver);
  15681. +}
  15682. +module_exit(abdac_exit);
  15683. +
  15684. +MODULE_AUTHOR("Haavard Skinnemoen <[email protected]>");
  15685. +MODULE_DESCRIPTION("Sound Driver for the Atmel AT32 ABDAC");
  15686. +MODULE_LICENSE("GPL");
  15687. --- /dev/null
  15688. +++ b/sound/oss/at32_abdac.h
  15689. @@ -0,0 +1,59 @@
  15690. +/*
  15691. + * Register definitions for the Atmel AT32 on-chip DAC.
  15692. + *
  15693. + * Copyright (C) 2006 Atmel Corporation
  15694. + *
  15695. + * This program is free software; you can redistribute it and/or modify
  15696. + * it under the terms of the GNU General Public License version 2 as
  15697. + * published by the Free Software Foundation.
  15698. + */
  15699. +#ifndef __SOUND_OSS_AT32_ABDAC_H__
  15700. +#define __SOUND_OSS_AT32_ABDAC_H__
  15701. +
  15702. +/* DAC register offsets */
  15703. +#define DAC_DATA 0x0000
  15704. +#define DAC_CTRL 0x0008
  15705. +#define DAC_INT_MASK 0x000c
  15706. +#define DAC_INT_EN 0x0010
  15707. +#define DAC_INT_DIS 0x0014
  15708. +#define DAC_INT_CLR 0x0018
  15709. +#define DAC_INT_STATUS 0x001c
  15710. +#define DAC_PDC_DATA 0x0020
  15711. +
  15712. +/* Bitfields in CTRL */
  15713. +#define DAC_SWAP_OFFSET 30
  15714. +#define DAC_SWAP_SIZE 1
  15715. +#define DAC_EN_OFFSET 31
  15716. +#define DAC_EN_SIZE 1
  15717. +
  15718. +/* Bitfields in INT_MASK/INT_EN/INT_DIS/INT_STATUS/INT_CLR */
  15719. +#define DAC_UNDERRUN_OFFSET 28
  15720. +#define DAC_UNDERRUN_SIZE 1
  15721. +#define DAC_TX_READY_OFFSET 29
  15722. +#define DAC_TX_READY_SIZE 1
  15723. +#define DAC_TX_BUFFER_EMPTY_OFFSET 30
  15724. +#define DAC_TX_BUFFER_EMPTY_SIZE 1
  15725. +#define DAC_CHANNEL_TX_END_OFFSET 31
  15726. +#define DAC_CHANNEL_TX_END_SIZE 1
  15727. +
  15728. +/* Bit manipulation macros */
  15729. +#define DAC_BIT(name) \
  15730. + (1 << DAC_##name##_OFFSET)
  15731. +#define DAC_BF(name, value) \
  15732. + (((value) & ((1 << DAC_##name##_SIZE) - 1)) \
  15733. + << DAC_##name##_OFFSET)
  15734. +#define DAC_BFEXT(name, value) \
  15735. + (((value) >> DAC_##name##_OFFSET) \
  15736. + & ((1 << DAC_##name##_SIZE) - 1))
  15737. +#define DAC_BFINS(name, value, old) \
  15738. + (((old) & ~(((1 << DAC_##name##_SIZE) - 1) \
  15739. + << DAC_##name##_OFFSET)) \
  15740. + | DAC_BF(name,value))
  15741. +
  15742. +/* Register access macros */
  15743. +#define dac_readl(port, reg) \
  15744. + __raw_readl((port)->regs + DAC_##reg)
  15745. +#define dac_writel(port, reg, value) \
  15746. + __raw_writel((value), (port)->regs + DAC_##reg)
  15747. +
  15748. +#endif /* __SOUND_OSS_AT32_ABDAC_H__ */
  15749. --- a/sound/oss/Kconfig
  15750. +++ b/sound/oss/Kconfig
  15751. @@ -654,3 +654,7 @@
  15752. int "DAC channel"
  15753. default "1"
  15754. depends on SOUND_SH_DAC_AUDIO
  15755. +
  15756. +config SOUND_AT32_ABDAC
  15757. + tristate "Atmel AT32 Audio Bitstream DAC (ABDAC) support"
  15758. + depends on SOUND_PRIME && AVR32
  15759. --- a/sound/oss/Makefile
  15760. +++ b/sound/oss/Makefile
  15761. @@ -9,6 +9,7 @@
  15762. # Please leave it as is, cause the link order is significant !
  15763. +obj-$(CONFIG_SOUND_AT32_ABDAC) += at32_abdac.o
  15764. obj-$(CONFIG_SOUND_SH_DAC_AUDIO) += sh_dac_audio.o
  15765. obj-$(CONFIG_SOUND_HAL2) += hal2.o
  15766. obj-$(CONFIG_SOUND_AEDSP16) += aedsp16.o
  15767. --- a/sound/spi/at73c213.c
  15768. +++ b/sound/spi/at73c213.c
  15769. @@ -737,7 +737,7 @@
  15770. /*
  15771. * Device functions
  15772. */
  15773. -static int snd_at73c213_ssc_init(struct snd_at73c213 *chip)
  15774. +static int __devinit snd_at73c213_ssc_init(struct snd_at73c213 *chip)
  15775. {
  15776. /*
  15777. * Continuous clock output.
  15778. @@ -767,7 +767,7 @@
  15779. return 0;
  15780. }
  15781. -static int snd_at73c213_chip_init(struct snd_at73c213 *chip)
  15782. +static int __devinit snd_at73c213_chip_init(struct snd_at73c213 *chip)
  15783. {
  15784. int retval;
  15785. unsigned char dac_ctrl = 0;
  15786. @@ -933,7 +933,7 @@
  15787. return retval;
  15788. }
  15789. -static int snd_at73c213_probe(struct spi_device *spi)
  15790. +static int __devinit snd_at73c213_probe(struct spi_device *spi)
  15791. {
  15792. struct snd_card *card;
  15793. struct snd_at73c213 *chip;