ar71xx.patch 968 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219
  1. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/ar71xx.c linux-2.6.35.7/arch/mips/ar71xx/ar71xx.c
  2. --- linux-2.6.35.7.orig/arch/mips/ar71xx/ar71xx.c 1970-01-01 01:00:00.000000000 +0100
  3. +++ linux-2.6.35.7/arch/mips/ar71xx/ar71xx.c 2010-10-14 20:27:55.855601218 +0200
  4. @@ -0,0 +1,177 @@
  5. +/*
  6. + * AR71xx SoC routines
  7. + *
  8. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  9. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  10. + *
  11. + * This program is free software; you can redistribute it and/or modify it
  12. + * under the terms of the GNU General Public License version 2 as published
  13. + * by the Free Software Foundation.
  14. + */
  15. +
  16. +#include <linux/kernel.h>
  17. +#include <linux/module.h>
  18. +#include <linux/types.h>
  19. +#include <linux/mutex.h>
  20. +
  21. +#include <asm/mach-ar71xx/ar71xx.h>
  22. +
  23. +static DEFINE_MUTEX(ar71xx_flash_mutex);
  24. +
  25. +void __iomem *ar71xx_ddr_base;
  26. +EXPORT_SYMBOL_GPL(ar71xx_ddr_base);
  27. +
  28. +void __iomem *ar71xx_pll_base;
  29. +EXPORT_SYMBOL_GPL(ar71xx_pll_base);
  30. +
  31. +void __iomem *ar71xx_reset_base;
  32. +EXPORT_SYMBOL_GPL(ar71xx_reset_base);
  33. +
  34. +void __iomem *ar71xx_gpio_base;
  35. +EXPORT_SYMBOL_GPL(ar71xx_gpio_base);
  36. +
  37. +void __iomem *ar71xx_usb_ctrl_base;
  38. +EXPORT_SYMBOL_GPL(ar71xx_usb_ctrl_base);
  39. +
  40. +void ar71xx_device_stop(u32 mask)
  41. +{
  42. + unsigned long flags;
  43. + u32 mask_inv;
  44. + u32 t;
  45. +
  46. + switch (ar71xx_soc) {
  47. + case AR71XX_SOC_AR7130:
  48. + case AR71XX_SOC_AR7141:
  49. + case AR71XX_SOC_AR7161:
  50. + local_irq_save(flags);
  51. + t = ar71xx_reset_rr(AR71XX_RESET_REG_RESET_MODULE);
  52. + ar71xx_reset_wr(AR71XX_RESET_REG_RESET_MODULE, t | mask);
  53. + local_irq_restore(flags);
  54. + break;
  55. +
  56. + case AR71XX_SOC_AR7240:
  57. + case AR71XX_SOC_AR7241:
  58. + case AR71XX_SOC_AR7242:
  59. + mask_inv = mask & RESET_MODULE_USB_OHCI_DLL_7240;
  60. + local_irq_save(flags);
  61. + t = ar71xx_reset_rr(AR724X_RESET_REG_RESET_MODULE);
  62. + t |= mask;
  63. + t &= ~mask_inv;
  64. + ar71xx_reset_wr(AR724X_RESET_REG_RESET_MODULE, t);
  65. + local_irq_restore(flags);
  66. + break;
  67. +
  68. + case AR71XX_SOC_AR9130:
  69. + case AR71XX_SOC_AR9132:
  70. + local_irq_save(flags);
  71. + t = ar71xx_reset_rr(AR91XX_RESET_REG_RESET_MODULE);
  72. + ar71xx_reset_wr(AR91XX_RESET_REG_RESET_MODULE, t | mask);
  73. + local_irq_restore(flags);
  74. + break;
  75. +
  76. + default:
  77. + BUG();
  78. + }
  79. +}
  80. +EXPORT_SYMBOL_GPL(ar71xx_device_stop);
  81. +
  82. +void ar71xx_device_start(u32 mask)
  83. +{
  84. + unsigned long flags;
  85. + u32 mask_inv;
  86. + u32 t;
  87. +
  88. + switch (ar71xx_soc) {
  89. + case AR71XX_SOC_AR7130:
  90. + case AR71XX_SOC_AR7141:
  91. + case AR71XX_SOC_AR7161:
  92. + local_irq_save(flags);
  93. + t = ar71xx_reset_rr(AR71XX_RESET_REG_RESET_MODULE);
  94. + ar71xx_reset_wr(AR71XX_RESET_REG_RESET_MODULE, t & ~mask);
  95. + local_irq_restore(flags);
  96. + break;
  97. +
  98. + case AR71XX_SOC_AR7240:
  99. + case AR71XX_SOC_AR7241:
  100. + case AR71XX_SOC_AR7242:
  101. + mask_inv = mask & RESET_MODULE_USB_OHCI_DLL_7240;
  102. + local_irq_save(flags);
  103. + t = ar71xx_reset_rr(AR724X_RESET_REG_RESET_MODULE);
  104. + t &= ~mask;
  105. + t |= mask_inv;
  106. + ar71xx_reset_wr(AR724X_RESET_REG_RESET_MODULE, t);
  107. + local_irq_restore(flags);
  108. + break;
  109. +
  110. + case AR71XX_SOC_AR9130:
  111. + case AR71XX_SOC_AR9132:
  112. + local_irq_save(flags);
  113. + t = ar71xx_reset_rr(AR91XX_RESET_REG_RESET_MODULE);
  114. + ar71xx_reset_wr(AR91XX_RESET_REG_RESET_MODULE, t & ~mask);
  115. + local_irq_restore(flags);
  116. + break;
  117. +
  118. + default:
  119. + BUG();
  120. + }
  121. +}
  122. +EXPORT_SYMBOL_GPL(ar71xx_device_start);
  123. +
  124. +int ar71xx_device_stopped(u32 mask)
  125. +{
  126. + unsigned long flags;
  127. + u32 t;
  128. +
  129. + switch (ar71xx_soc) {
  130. + case AR71XX_SOC_AR7130:
  131. + case AR71XX_SOC_AR7141:
  132. + case AR71XX_SOC_AR7161:
  133. + local_irq_save(flags);
  134. + t = ar71xx_reset_rr(AR71XX_RESET_REG_RESET_MODULE);
  135. + local_irq_restore(flags);
  136. + break;
  137. +
  138. + case AR71XX_SOC_AR7240:
  139. + case AR71XX_SOC_AR7241:
  140. + case AR71XX_SOC_AR7242:
  141. + local_irq_save(flags);
  142. + t = ar71xx_reset_rr(AR724X_RESET_REG_RESET_MODULE);
  143. + local_irq_restore(flags);
  144. + break;
  145. +
  146. + case AR71XX_SOC_AR9130:
  147. + case AR71XX_SOC_AR9132:
  148. + local_irq_save(flags);
  149. + t = ar71xx_reset_rr(AR91XX_RESET_REG_RESET_MODULE);
  150. + local_irq_restore(flags);
  151. + break;
  152. +
  153. + default:
  154. + BUG();
  155. + }
  156. +
  157. + return ((t & mask) == mask);
  158. +}
  159. +EXPORT_SYMBOL_GPL(ar71xx_device_stopped);
  160. +
  161. +void ar71xx_ddr_flush(u32 reg)
  162. +{
  163. + ar71xx_ddr_wr(reg, 1);
  164. + while ((ar71xx_ddr_rr(reg) & 0x1));
  165. +
  166. + ar71xx_ddr_wr(reg, 1);
  167. + while ((ar71xx_ddr_rr(reg) & 0x1));
  168. +}
  169. +EXPORT_SYMBOL_GPL(ar71xx_ddr_flush);
  170. +
  171. +void ar71xx_flash_acquire(void)
  172. +{
  173. + mutex_lock(&ar71xx_flash_mutex);
  174. +}
  175. +EXPORT_SYMBOL_GPL(ar71xx_flash_acquire);
  176. +
  177. +void ar71xx_flash_release(void)
  178. +{
  179. + mutex_unlock(&ar71xx_flash_mutex);
  180. +}
  181. +EXPORT_SYMBOL_GPL(ar71xx_flash_release);
  182. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap91-eth.c linux-2.6.35.7/arch/mips/ar71xx/dev-ap91-eth.c
  183. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap91-eth.c 1970-01-01 01:00:00.000000000 +0100
  184. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-ap91-eth.c 2010-10-14 20:27:55.876851074 +0200
  185. @@ -0,0 +1,70 @@
  186. +/*
  187. + * Atheros AP91 reference board ethernet initialization
  188. + *
  189. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  190. + *
  191. + * This program is free software; you can redistribute it and/or modify it
  192. + * under the terms of the GNU General Public License version 2 as published
  193. + * by the Free Software Foundation.
  194. + */
  195. +
  196. +#include "devices.h"
  197. +#include "dev-dsa.h"
  198. +#include "dev-ap91-eth.h"
  199. +
  200. +static struct dsa_chip_data ap91_dsa_chip = {
  201. + .port_names[0] = "cpu",
  202. + .port_names[1] = "lan1",
  203. + .port_names[2] = "lan2",
  204. + .port_names[3] = "lan3",
  205. + .port_names[4] = "lan4",
  206. +};
  207. +
  208. +static struct dsa_platform_data ap91_dsa_data = {
  209. + .nr_chips = 1,
  210. + .chip = &ap91_dsa_chip,
  211. +};
  212. +
  213. +static void ap91_eth_set_port_name(unsigned port, const char *name)
  214. +{
  215. + if (port < 1 || port > 5)
  216. + return;
  217. +
  218. + if (name)
  219. + ap91_dsa_chip.port_names[port] = (char *) name;
  220. +}
  221. +
  222. +void __init ap91_eth_init(u8 *mac_addr, const char *port_names[])
  223. +{
  224. + if (mac_addr)
  225. + ar71xx_set_mac_base(mac_addr);
  226. +
  227. + if (port_names) {
  228. + int i;
  229. +
  230. + for (i = 0; i < AP91_ETH_NUM_PORT_NAMES; i++)
  231. + ap91_eth_set_port_name(i + 1, port_names[i]);
  232. + }
  233. +
  234. + /* WAN port */
  235. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  236. + ar71xx_eth0_data.speed = SPEED_100;
  237. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  238. + ar71xx_eth0_data.fifo_cfg1 = 0x0fff0000;
  239. + ar71xx_eth0_data.fifo_cfg2 = 0x00001fff;
  240. + ar71xx_eth0_data.fifo_cfg3 = 0x008001ff;
  241. +
  242. + /* LAN ports */
  243. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  244. + ar71xx_eth1_data.speed = SPEED_1000;
  245. + ar71xx_eth1_data.duplex = DUPLEX_FULL;
  246. + ar71xx_eth1_data.fifo_cfg1 = 0x0fff0000;
  247. + ar71xx_eth1_data.fifo_cfg2 = 0x00001fff;
  248. + ar71xx_eth1_data.fifo_cfg3 = 0x008001ff;
  249. +
  250. + ar71xx_add_device_mdio(0x0);
  251. + ar71xx_add_device_eth(1);
  252. + ar71xx_add_device_eth(0);
  253. +
  254. + ar71xx_add_device_dsa(1, &ap91_dsa_data);
  255. +}
  256. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap91-eth.h linux-2.6.35.7/arch/mips/ar71xx/dev-ap91-eth.h
  257. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap91-eth.h 1970-01-01 01:00:00.000000000 +0100
  258. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-ap91-eth.h 2010-10-14 20:27:55.918101097 +0200
  259. @@ -0,0 +1,23 @@
  260. +/*
  261. + * Atheros AP91 reference board ethernet initialization
  262. + *
  263. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  264. + *
  265. + * This program is free software; you can redistribute it and/or modify it
  266. + * under the terms of the GNU General Public License version 2 as published
  267. + * by the Free Software Foundation.
  268. + */
  269. +
  270. +#ifndef _AR71XX_DEV_AP91_ETH_H
  271. +#define _AR71XX_DEV_AP91_ETH_H
  272. +
  273. +#define AP91_ETH_NUM_PORT_NAMES 4
  274. +
  275. +#if defined(CONFIG_AR71XX_DEV_AP91_ETH)
  276. +void ap91_eth_init(u8 *mac_addr, const char *port_names[]) __init;
  277. +#else
  278. +static inline void ap91_eth_init(u8 *mac_addr) { }
  279. +#endif
  280. +
  281. +#endif /* _AR71XX_DEV_AP91_ETH_H */
  282. +
  283. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap91-pci.c linux-2.6.35.7/arch/mips/ar71xx/dev-ap91-pci.c
  284. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap91-pci.c 1970-01-01 01:00:00.000000000 +0100
  285. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-ap91-pci.c 2010-10-14 20:27:55.964356595 +0200
  286. @@ -0,0 +1,114 @@
  287. +/*
  288. + * Atheros AP91 reference board PCI initialization
  289. + *
  290. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  291. + *
  292. + * This program is free software; you can redistribute it and/or modify it
  293. + * under the terms of the GNU General Public License version 2 as published
  294. + * by the Free Software Foundation.
  295. + */
  296. +
  297. +#include <linux/pci.h>
  298. +#include <linux/ath9k_platform.h>
  299. +#include <linux/delay.h>
  300. +
  301. +#include <asm/mach-ar71xx/ar71xx.h>
  302. +#include <asm/mach-ar71xx/pci.h>
  303. +
  304. +#include "dev-ap91-pci.h"
  305. +
  306. +static struct ath9k_platform_data ap91_wmac_data;
  307. +static char ap91_wmac_mac[6];
  308. +static int ap91_pci_fixup_enabled;
  309. +
  310. +static struct ar71xx_pci_irq ap91_pci_irqs[] __initdata = {
  311. + {
  312. + .slot = 0,
  313. + .pin = 1,
  314. + .irq = AR71XX_PCI_IRQ_DEV0,
  315. + }
  316. +};
  317. +
  318. +static int ap91_pci_plat_dev_init(struct pci_dev *dev)
  319. +{
  320. + switch(PCI_SLOT(dev->devfn)) {
  321. + case 0:
  322. + dev->dev.platform_data = &ap91_wmac_data;
  323. + break;
  324. + }
  325. +
  326. + return 0;
  327. +}
  328. +
  329. +static void ap91_pci_fixup(struct pci_dev *dev)
  330. +{
  331. + void __iomem *mem;
  332. + u16 *cal_data;
  333. + u16 cmd;
  334. + u32 val;
  335. +
  336. + if (!ap91_pci_fixup_enabled)
  337. + return;
  338. +
  339. + printk(KERN_INFO "PCI: fixup device %s\n", pci_name(dev));
  340. +
  341. + cal_data = ap91_wmac_data.eeprom_data;
  342. + if (*cal_data != 0xa55a) {
  343. + printk(KERN_ERR "PCI: no calibration data found for %s\n",
  344. + pci_name(dev));
  345. + return;
  346. + }
  347. +
  348. + mem = ioremap(AR71XX_PCI_MEM_BASE, 0x10000);
  349. + if (!mem) {
  350. + printk(KERN_ERR "PCI: ioremap error for device %s\n",
  351. + pci_name(dev));
  352. + return;
  353. + }
  354. +
  355. + /* Setup the PCI device to allow access to the internal registers */
  356. + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, 0xffff);
  357. + pci_read_config_word(dev, PCI_COMMAND, &cmd);
  358. + cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  359. + pci_write_config_word(dev, PCI_COMMAND, cmd);
  360. +
  361. + /* set pointer to first reg address */
  362. + cal_data += 3;
  363. + while (*cal_data != 0xffff) {
  364. + u32 reg;
  365. + reg = *cal_data++;
  366. + val = *cal_data++;
  367. + val |= (*cal_data++) << 16;
  368. +
  369. + __raw_writel(val, mem + reg);
  370. + udelay(100);
  371. + }
  372. +
  373. + pci_read_config_dword(dev, PCI_VENDOR_ID, &val);
  374. + dev->vendor = val & 0xffff;
  375. + dev->device = (val >> 16) & 0xffff;
  376. +
  377. + pci_read_config_dword(dev, PCI_CLASS_REVISION, &val);
  378. + dev->revision = val & 0xff;
  379. + dev->class = val >> 8; /* upper 3 bytes */
  380. +
  381. + iounmap(mem);
  382. +}
  383. +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID, ap91_pci_fixup);
  384. +
  385. +void __init ap91_pci_init(u8 *cal_data, u8 *mac_addr)
  386. +{
  387. + if (cal_data)
  388. + memcpy(ap91_wmac_data.eeprom_data, cal_data,
  389. + sizeof(ap91_wmac_data.eeprom_data));
  390. +
  391. + if (mac_addr) {
  392. + memcpy(ap91_wmac_mac, mac_addr, sizeof(ap91_wmac_mac));
  393. + ap91_wmac_data.macaddr = ap91_wmac_mac;
  394. + }
  395. +
  396. + ar71xx_pci_plat_dev_init = ap91_pci_plat_dev_init;
  397. + ar71xx_pci_init(ARRAY_SIZE(ap91_pci_irqs), ap91_pci_irqs);
  398. +
  399. + ap91_pci_fixup_enabled = 1;
  400. +}
  401. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap91-pci.h linux-2.6.35.7/arch/mips/ar71xx/dev-ap91-pci.h
  402. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap91-pci.h 1970-01-01 01:00:00.000000000 +0100
  403. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-ap91-pci.h 2010-10-14 20:27:56.005601094 +0200
  404. @@ -0,0 +1,21 @@
  405. +/*
  406. + * Atheros AP91 reference board PCI initialization
  407. + *
  408. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  409. + *
  410. + * This program is free software; you can redistribute it and/or modify it
  411. + * under the terms of the GNU General Public License version 2 as published
  412. + * by the Free Software Foundation.
  413. + */
  414. +
  415. +#ifndef _AR71XX_DEV_AP91_PCI_H
  416. +#define _AR71XX_DEV_AP91_PCI_H
  417. +
  418. +#if defined(CONFIG_AR71XX_DEV_AP91_PCI)
  419. +void ap91_pci_init(u8 *cal_data, u8 *mac_addr) __init;
  420. +#else
  421. +static inline void ap91_pci_init(u8 *cal_data, u8 *mac_addr) { }
  422. +#endif
  423. +
  424. +#endif /* _AR71XX_DEV_AP91_PCI_H */
  425. +
  426. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap94-pci.c linux-2.6.35.7/arch/mips/ar71xx/dev-ap94-pci.c
  427. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap94-pci.c 1970-01-01 01:00:00.000000000 +0100
  428. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-ap94-pci.c 2010-10-14 20:27:56.056135764 +0200
  429. @@ -0,0 +1,159 @@
  430. +/*
  431. + * Atheros AP94 reference board PCI initialization
  432. + *
  433. + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  434. + *
  435. + * This program is free software; you can redistribute it and/or modify it
  436. + * under the terms of the GNU General Public License version 2 as published
  437. + * by the Free Software Foundation.
  438. + */
  439. +
  440. +#include <linux/pci.h>
  441. +#include <linux/ath9k_platform.h>
  442. +#include <linux/delay.h>
  443. +
  444. +#include <asm/mach-ar71xx/ar71xx.h>
  445. +#include <asm/mach-ar71xx/pci.h>
  446. +
  447. +#include "dev-ap94-pci.h"
  448. +
  449. +static struct ath9k_platform_data ap94_wmac0_data;
  450. +static struct ath9k_platform_data ap94_wmac1_data;
  451. +static char ap94_wmac0_mac[6];
  452. +static char ap94_wmac1_mac[6];
  453. +static int ap94_pci_fixup_enabled;
  454. +
  455. +static struct ar71xx_pci_irq ap94_pci_irqs[] __initdata = {
  456. + {
  457. + .slot = 0,
  458. + .pin = 1,
  459. + .irq = AR71XX_PCI_IRQ_DEV0,
  460. + }, {
  461. + .slot = 1,
  462. + .pin = 1,
  463. + .irq = AR71XX_PCI_IRQ_DEV1,
  464. + }
  465. +};
  466. +
  467. +static int ap94_pci_plat_dev_init(struct pci_dev *dev)
  468. +{
  469. + switch(PCI_SLOT(dev->devfn)) {
  470. + case 17:
  471. + dev->dev.platform_data = &ap94_wmac0_data;
  472. + break;
  473. +
  474. + case 18:
  475. + dev->dev.platform_data = &ap94_wmac1_data;
  476. + break;
  477. + }
  478. +
  479. + return 0;
  480. +}
  481. +
  482. +static void ap94_pci_fixup(struct pci_dev *dev)
  483. +{
  484. + void __iomem *mem;
  485. + u16 *cal_data;
  486. + u16 cmd;
  487. + u32 bar0;
  488. + u32 val;
  489. +
  490. + if (!ap94_pci_fixup_enabled)
  491. + return;
  492. +
  493. + switch (PCI_SLOT(dev->devfn)) {
  494. + case 17:
  495. + cal_data = ap94_wmac0_data.eeprom_data;
  496. + break;
  497. + case 18:
  498. + cal_data = ap94_wmac1_data.eeprom_data;
  499. + break;
  500. + default:
  501. + return;
  502. + }
  503. +
  504. + if (*cal_data != 0xa55a) {
  505. + printk(KERN_ERR "PCI: no calibration data found for %s\n",
  506. + pci_name(dev));
  507. + return;
  508. + }
  509. +
  510. + mem = ioremap(AR71XX_PCI_MEM_BASE, 0x10000);
  511. + if (!mem) {
  512. + printk(KERN_ERR "PCI: ioremap error for device %s\n",
  513. + pci_name(dev));
  514. + return;
  515. + }
  516. +
  517. + printk(KERN_INFO "PCI: fixup device %s\n", pci_name(dev));
  518. +
  519. + pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar0);
  520. +
  521. + /* Setup the PCI device to allow access to the internal registers */
  522. + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, AR71XX_PCI_MEM_BASE);
  523. + pci_read_config_word(dev, PCI_COMMAND, &cmd);
  524. + cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  525. + pci_write_config_word(dev, PCI_COMMAND, cmd);
  526. +
  527. + /* set pointer to first reg address */
  528. + cal_data += 3;
  529. + while (*cal_data != 0xffff) {
  530. + u32 reg;
  531. + reg = *cal_data++;
  532. + val = *cal_data++;
  533. + val |= (*cal_data++) << 16;
  534. +
  535. + __raw_writel(val, mem + reg);
  536. + udelay(100);
  537. + }
  538. +
  539. + pci_read_config_dword(dev, PCI_VENDOR_ID, &val);
  540. + dev->vendor = val & 0xffff;
  541. + dev->device = (val >> 16) & 0xffff;
  542. +
  543. + pci_read_config_dword(dev, PCI_CLASS_REVISION, &val);
  544. + dev->revision = val & 0xff;
  545. + dev->class = val >> 8; /* upper 3 bytes */
  546. +
  547. + pci_read_config_word(dev, PCI_COMMAND, &cmd);
  548. + cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
  549. + pci_write_config_word(dev, PCI_COMMAND, cmd);
  550. +
  551. + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, bar0);
  552. +
  553. + iounmap(mem);
  554. +}
  555. +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID, ap94_pci_fixup);
  556. +
  557. +void __init ap94_pci_enable_quirk_wndr3700(void)
  558. +{
  559. + ap94_wmac0_data.quirk_wndr3700 = 1;
  560. + ap94_wmac1_data.quirk_wndr3700 = 1;
  561. +}
  562. +
  563. +void __init ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
  564. + u8 *cal_data1, u8 *mac_addr1)
  565. +{
  566. + if (cal_data0)
  567. + memcpy(ap94_wmac0_data.eeprom_data, cal_data0,
  568. + sizeof(ap94_wmac0_data.eeprom_data));
  569. +
  570. + if (cal_data1)
  571. + memcpy(ap94_wmac1_data.eeprom_data, cal_data1,
  572. + sizeof(ap94_wmac1_data.eeprom_data));
  573. +
  574. + if (mac_addr0) {
  575. + memcpy(ap94_wmac0_mac, mac_addr0, sizeof(ap94_wmac0_mac));
  576. + ap94_wmac0_data.macaddr = ap94_wmac0_mac;
  577. + }
  578. +
  579. + if (mac_addr1) {
  580. + memcpy(ap94_wmac1_mac, mac_addr1, sizeof(ap94_wmac1_mac));
  581. + ap94_wmac1_data.macaddr = ap94_wmac1_mac;
  582. + }
  583. +
  584. + ar71xx_pci_plat_dev_init = ap94_pci_plat_dev_init;
  585. + ar71xx_pci_init(ARRAY_SIZE(ap94_pci_irqs), ap94_pci_irqs);
  586. +
  587. + ap94_pci_fixup_enabled = 1;
  588. +}
  589. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap94-pci.h linux-2.6.35.7/arch/mips/ar71xx/dev-ap94-pci.h
  590. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ap94-pci.h 1970-01-01 01:00:00.000000000 +0100
  591. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-ap94-pci.h 2010-10-14 20:27:56.105939718 +0200
  592. @@ -0,0 +1,28 @@
  593. +/*
  594. + * Atheros AP94 reference board PCI initialization
  595. + *
  596. + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  597. + *
  598. + * This program is free software; you can redistribute it and/or modify it
  599. + * under the terms of the GNU General Public License version 2 as published
  600. + * by the Free Software Foundation.
  601. + */
  602. +
  603. +#ifndef _AR71XX_DEV_AP94_PCI_H
  604. +#define _AR71XX_DEV_AP94_PCI_H
  605. +
  606. +#if defined(CONFIG_AR71XX_DEV_AP94_PCI)
  607. +void ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
  608. + u8 *cal_data1, u8 *mac_addr1) __init;
  609. +
  610. +void ap94_pci_enable_quirk_wndr3700(void) __init;
  611. +
  612. +#else
  613. +static inline void ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
  614. + u8 *cal_data1, u8 *mac_addr1) {}
  615. +
  616. +static inline void ap94_pci_enable_quirk_wndr3700(void) {}
  617. +#endif
  618. +
  619. +#endif /* _AR71XX_DEV_AP94_PCI_H */
  620. +
  621. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ar913x-wmac.c linux-2.6.35.7/arch/mips/ar71xx/dev-ar913x-wmac.c
  622. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ar913x-wmac.c 1970-01-01 01:00:00.000000000 +0100
  623. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-ar913x-wmac.c 2010-10-14 20:27:56.154378236 +0200
  624. @@ -0,0 +1,68 @@
  625. +/*
  626. + * Atheros AR913x SoC built-in WMAC device support
  627. + *
  628. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  629. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  630. + *
  631. + * Parts of this file are based on Atheros' 2.6.15 BSP
  632. + *
  633. + * This program is free software; you can redistribute it and/or modify it
  634. + * under the terms of the GNU General Public License version 2 as published
  635. + * by the Free Software Foundation.
  636. + */
  637. +
  638. +#include <linux/kernel.h>
  639. +#include <linux/init.h>
  640. +#include <linux/delay.h>
  641. +#include <linux/etherdevice.h>
  642. +#include <linux/platform_device.h>
  643. +#include <linux/ath9k_platform.h>
  644. +
  645. +#include <asm/mach-ar71xx/ar71xx.h>
  646. +
  647. +#include "dev-ar913x-wmac.h"
  648. +
  649. +static struct ath9k_platform_data ar913x_wmac_data;
  650. +static char ar913x_wmac_mac[6];
  651. +
  652. +static struct resource ar913x_wmac_resources[] = {
  653. + {
  654. + .start = AR91XX_WMAC_BASE,
  655. + .end = AR91XX_WMAC_BASE + AR91XX_WMAC_SIZE - 1,
  656. + .flags = IORESOURCE_MEM,
  657. + }, {
  658. + .start = AR71XX_CPU_IRQ_IP2,
  659. + .end = AR71XX_CPU_IRQ_IP2,
  660. + .flags = IORESOURCE_IRQ,
  661. + },
  662. +};
  663. +
  664. +static struct platform_device ar913x_wmac_device = {
  665. + .name = "ath9k",
  666. + .id = -1,
  667. + .resource = ar913x_wmac_resources,
  668. + .num_resources = ARRAY_SIZE(ar913x_wmac_resources),
  669. + .dev = {
  670. + .platform_data = &ar913x_wmac_data,
  671. + },
  672. +};
  673. +
  674. +void __init ar913x_add_device_wmac(u8 *cal_data, u8 *mac_addr)
  675. +{
  676. + if (cal_data)
  677. + memcpy(ar913x_wmac_data.eeprom_data, cal_data,
  678. + sizeof(ar913x_wmac_data.eeprom_data));
  679. +
  680. + if (mac_addr) {
  681. + memcpy(ar913x_wmac_mac, mac_addr, sizeof(ar913x_wmac_mac));
  682. + ar913x_wmac_data.macaddr = ar913x_wmac_mac;
  683. + }
  684. +
  685. + ar71xx_device_stop(RESET_MODULE_AMBA2WMAC);
  686. + mdelay(10);
  687. +
  688. + ar71xx_device_start(RESET_MODULE_AMBA2WMAC);
  689. + mdelay(10);
  690. +
  691. + platform_device_register(&ar913x_wmac_device);
  692. +}
  693. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ar913x-wmac.h linux-2.6.35.7/arch/mips/ar71xx/dev-ar913x-wmac.h
  694. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-ar913x-wmac.h 1970-01-01 01:00:00.000000000 +0100
  695. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-ar913x-wmac.h 2010-10-14 20:27:56.205590855 +0200
  696. @@ -0,0 +1,19 @@
  697. +/*
  698. + * Atheros AR913x SoC built-in WMAC device support
  699. + *
  700. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  701. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  702. + *
  703. + * Parts of this file are based on Atheros' 2.6.15 BSP
  704. + *
  705. + * This program is free software; you can redistribute it and/or modify it
  706. + * under the terms of the GNU General Public License version 2 as published
  707. + * by the Free Software Foundation.
  708. + */
  709. +
  710. +#ifndef _AR71XX_DEV_AR913X_WMAC_H
  711. +#define _AR71XX_DEV_AR913X_WMAC_H
  712. +
  713. +void ar913x_add_device_wmac(u8 *cal_data, u8 *mac_addr) __init;
  714. +
  715. +#endif /* _AR71XX_DEV_AR913X_WMAC_H */
  716. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-dsa.c linux-2.6.35.7/arch/mips/ar71xx/dev-dsa.c
  717. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-dsa.c 1970-01-01 01:00:00.000000000 +0100
  718. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-dsa.c 2010-10-14 20:27:56.255387205 +0200
  719. @@ -0,0 +1,50 @@
  720. +/*
  721. + * Atheros AR71xx DSA switch device support
  722. + *
  723. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  724. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  725. + *
  726. + * This program is free software; you can redistribute it and/or modify it
  727. + * under the terms of the GNU General Public License version 2 as published
  728. + * by the Free Software Foundation.
  729. + */
  730. +
  731. +#include <linux/init.h>
  732. +#include <linux/platform_device.h>
  733. +
  734. +#include <asm/mach-ar71xx/ar71xx.h>
  735. +
  736. +#include "devices.h"
  737. +#include "dev-dsa.h"
  738. +
  739. +static struct platform_device ar71xx_dsa_switch_device = {
  740. + .name = "dsa",
  741. + .id = 0,
  742. +};
  743. +
  744. +void __init ar71xx_add_device_dsa(unsigned int id,
  745. + struct dsa_platform_data *d)
  746. +{
  747. + int i;
  748. +
  749. + switch (id) {
  750. + case 0:
  751. + d->netdev = &ar71xx_eth0_device.dev;
  752. + break;
  753. + case 1:
  754. + d->netdev = &ar71xx_eth1_device.dev;
  755. + break;
  756. + default:
  757. + printk(KERN_ERR
  758. + "ar71xx: invalid ethernet id %d for DSA switch\n",
  759. + id);
  760. + return;
  761. + }
  762. +
  763. + for (i = 0; i < d->nr_chips; i++)
  764. + d->chip[i].mii_bus = &ar71xx_mdio_device.dev;
  765. +
  766. + ar71xx_dsa_switch_device.dev.platform_data = d;
  767. +
  768. + platform_device_register(&ar71xx_dsa_switch_device);
  769. +}
  770. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-dsa.h linux-2.6.35.7/arch/mips/ar71xx/dev-dsa.h
  771. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-dsa.h 1970-01-01 01:00:00.000000000 +0100
  772. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-dsa.h 2010-10-14 20:27:56.305200658 +0200
  773. @@ -0,0 +1,20 @@
  774. +/*
  775. + * Atheros AR71xx DSA switch device support
  776. + *
  777. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  778. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  779. + *
  780. + * This program is free software; you can redistribute it and/or modify it
  781. + * under the terms of the GNU General Public License version 2 as published
  782. + * by the Free Software Foundation.
  783. + */
  784. +
  785. +#ifndef _AR71XX_DEV_DSA_H
  786. +#define _AR71XX_DEV_DSA_H
  787. +
  788. +#include <net/dsa.h>
  789. +
  790. +void ar71xx_add_device_dsa(unsigned int id,
  791. + struct dsa_platform_data *d) __init;
  792. +
  793. +#endif /* _AR71XX_DEV_DSA_H */
  794. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-gpio-buttons.c linux-2.6.35.7/arch/mips/ar71xx/dev-gpio-buttons.c
  795. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-gpio-buttons.c 1970-01-01 01:00:00.000000000 +0100
  796. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-gpio-buttons.c 2010-10-14 20:27:56.355043092 +0200
  797. @@ -0,0 +1,58 @@
  798. +/*
  799. + * Atheros AR71xx GPIO button support
  800. + *
  801. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  802. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  803. + *
  804. + * This program is free software; you can redistribute it and/or modify it
  805. + * under the terms of the GNU General Public License version 2 as published
  806. + * by the Free Software Foundation.
  807. + */
  808. +
  809. +#include "linux/init.h"
  810. +#include <linux/platform_device.h>
  811. +
  812. +#include "dev-gpio-buttons.h"
  813. +
  814. +void __init ar71xx_add_device_gpio_buttons(int id,
  815. + unsigned poll_interval,
  816. + unsigned nbuttons,
  817. + struct gpio_button *buttons)
  818. +{
  819. + struct platform_device *pdev;
  820. + struct gpio_buttons_platform_data pdata;
  821. + struct gpio_button *p;
  822. + int err;
  823. +
  824. + p = kmalloc(nbuttons * sizeof(*p), GFP_KERNEL);
  825. + if (!p)
  826. + return;
  827. +
  828. + memcpy(p, buttons, nbuttons * sizeof(*p));
  829. +
  830. + pdev = platform_device_alloc("gpio-buttons", id);
  831. + if (!pdev)
  832. + goto err_free_buttons;
  833. +
  834. + memset(&pdata, 0, sizeof(pdata));
  835. + pdata.poll_interval = poll_interval;
  836. + pdata.nbuttons = nbuttons;
  837. + pdata.buttons = p;
  838. +
  839. + err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
  840. + if (err)
  841. + goto err_put_pdev;
  842. +
  843. +
  844. + err = platform_device_add(pdev);
  845. + if (err)
  846. + goto err_put_pdev;
  847. +
  848. + return;
  849. +
  850. +err_put_pdev:
  851. + platform_device_put(pdev);
  852. +
  853. +err_free_buttons:
  854. + kfree(p);
  855. +}
  856. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-gpio-buttons.h linux-2.6.35.7/arch/mips/ar71xx/dev-gpio-buttons.h
  857. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-gpio-buttons.h 1970-01-01 01:00:00.000000000 +0100
  858. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-gpio-buttons.h 2010-10-14 20:27:56.404843567 +0200
  859. @@ -0,0 +1,25 @@
  860. +/*
  861. + * Atheros AR71xx GPIO button support
  862. + *
  863. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  864. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  865. + *
  866. + * This program is free software; you can redistribute it and/or modify it
  867. + * under the terms of the GNU General Public License version 2 as published
  868. + * by the Free Software Foundation.
  869. + */
  870. +
  871. +#ifndef _AR71XX_DEV_GPIO_BUTTONS_H
  872. +#define _AR71XX_DEV_GPIO_BUTTONS_H
  873. +
  874. +#include <linux/input.h>
  875. +#include <linux/gpio_buttons.h>
  876. +
  877. +#include <asm/mach-ar71xx/platform.h>
  878. +
  879. +void ar71xx_add_device_gpio_buttons(int id,
  880. + unsigned poll_interval,
  881. + unsigned nbuttons,
  882. + struct gpio_button *buttons) __init;
  883. +
  884. +#endif /* _AR71XX_DEV_GPIO_BUTTONS_H */
  885. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/devices.c linux-2.6.35.7/arch/mips/ar71xx/devices.c
  886. --- linux-2.6.35.7.orig/arch/mips/ar71xx/devices.c 1970-01-01 01:00:00.000000000 +0100
  887. +++ linux-2.6.35.7/arch/mips/ar71xx/devices.c 2010-10-14 20:27:56.454649960 +0200
  888. @@ -0,0 +1,575 @@
  889. +/*
  890. + * Atheros AR71xx SoC platform devices
  891. + *
  892. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  893. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  894. + *
  895. + * Parts of this file are based on Atheros' 2.6.15 BSP
  896. + *
  897. + * This program is free software; you can redistribute it and/or modify it
  898. + * under the terms of the GNU General Public License version 2 as published
  899. + * by the Free Software Foundation.
  900. + */
  901. +
  902. +#include <linux/kernel.h>
  903. +#include <linux/init.h>
  904. +#include <linux/delay.h>
  905. +#include <linux/etherdevice.h>
  906. +#include <linux/platform_device.h>
  907. +#include <linux/serial_8250.h>
  908. +
  909. +#include <asm/mach-ar71xx/ar71xx.h>
  910. +
  911. +#include "devices.h"
  912. +
  913. +static u8 ar71xx_mac_base[ETH_ALEN] __initdata;
  914. +
  915. +static struct resource ar71xx_uart_resources[] = {
  916. + {
  917. + .start = AR71XX_UART_BASE,
  918. + .end = AR71XX_UART_BASE + AR71XX_UART_SIZE - 1,
  919. + .flags = IORESOURCE_MEM,
  920. + },
  921. +};
  922. +
  923. +#define AR71XX_UART_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP)
  924. +static struct plat_serial8250_port ar71xx_uart_data[] = {
  925. + {
  926. + .mapbase = AR71XX_UART_BASE,
  927. + .irq = AR71XX_MISC_IRQ_UART,
  928. + .flags = AR71XX_UART_FLAGS,
  929. + .iotype = UPIO_MEM32,
  930. + .regshift = 2,
  931. + }, {
  932. + /* terminating entry */
  933. + }
  934. +};
  935. +
  936. +static struct platform_device ar71xx_uart_device = {
  937. + .name = "serial8250",
  938. + .id = PLAT8250_DEV_PLATFORM,
  939. + .resource = ar71xx_uart_resources,
  940. + .num_resources = ARRAY_SIZE(ar71xx_uart_resources),
  941. + .dev = {
  942. + .platform_data = ar71xx_uart_data
  943. + },
  944. +};
  945. +
  946. +void __init ar71xx_add_device_uart(void)
  947. +{
  948. + ar71xx_uart_data[0].uartclk = ar71xx_ahb_freq;
  949. + platform_device_register(&ar71xx_uart_device);
  950. +}
  951. +
  952. +static struct resource ar71xx_mdio_resources[] = {
  953. + {
  954. + .name = "mdio_base",
  955. + .flags = IORESOURCE_MEM,
  956. + .start = AR71XX_GE0_BASE,
  957. + .end = AR71XX_GE0_BASE + 0x200 - 1,
  958. + }
  959. +};
  960. +
  961. +static struct ag71xx_mdio_platform_data ar71xx_mdio_data;
  962. +
  963. +struct platform_device ar71xx_mdio_device = {
  964. + .name = "ag71xx-mdio",
  965. + .id = -1,
  966. + .resource = ar71xx_mdio_resources,
  967. + .num_resources = ARRAY_SIZE(ar71xx_mdio_resources),
  968. + .dev = {
  969. + .platform_data = &ar71xx_mdio_data,
  970. + },
  971. +};
  972. +
  973. +void __init ar71xx_add_device_mdio(u32 phy_mask)
  974. +{
  975. + switch (ar71xx_soc) {
  976. + case AR71XX_SOC_AR7240:
  977. + case AR71XX_SOC_AR7241:
  978. + case AR71XX_SOC_AR7242:
  979. + ar71xx_mdio_data.is_ar7240 = 1;
  980. + break;
  981. + default:
  982. + break;
  983. + }
  984. +
  985. + ar71xx_mdio_data.phy_mask = phy_mask;
  986. +
  987. + platform_device_register(&ar71xx_mdio_device);
  988. +}
  989. +
  990. +static void ar71xx_set_pll(u32 cfg_reg, u32 pll_reg, u32 pll_val, u32 shift)
  991. +{
  992. + void __iomem *base;
  993. + u32 t;
  994. +
  995. + base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  996. +
  997. + t = __raw_readl(base + cfg_reg);
  998. + t &= ~(3 << shift);
  999. + t |= (2 << shift);
  1000. + __raw_writel(t, base + cfg_reg);
  1001. + udelay(100);
  1002. +
  1003. + __raw_writel(pll_val, base + pll_reg);
  1004. +
  1005. + t |= (3 << shift);
  1006. + __raw_writel(t, base + cfg_reg);
  1007. + udelay(100);
  1008. +
  1009. + t &= ~(3 << shift);
  1010. + __raw_writel(t, base + cfg_reg);
  1011. + udelay(100);
  1012. +
  1013. + printk(KERN_DEBUG "ar71xx: pll_reg %#x: %#x\n",
  1014. + (unsigned int)(base + pll_reg), __raw_readl(base + pll_reg));
  1015. +
  1016. + iounmap(base);
  1017. +}
  1018. +
  1019. +struct ar71xx_eth_pll_data ar71xx_eth0_pll_data;
  1020. +struct ar71xx_eth_pll_data ar71xx_eth1_pll_data;
  1021. +
  1022. +static u32 ar71xx_get_eth_pll(unsigned int mac, int speed)
  1023. +{
  1024. + struct ar71xx_eth_pll_data *pll_data;
  1025. + u32 pll_val;
  1026. +
  1027. + switch (mac) {
  1028. + case 0:
  1029. + pll_data = &ar71xx_eth0_pll_data;
  1030. + break;
  1031. + case 1:
  1032. + pll_data = &ar71xx_eth1_pll_data;
  1033. + break;
  1034. + default:
  1035. + BUG();
  1036. + }
  1037. +
  1038. + switch (speed) {
  1039. + case SPEED_10:
  1040. + pll_val = pll_data->pll_10;
  1041. + break;
  1042. + case SPEED_100:
  1043. + pll_val = pll_data->pll_100;
  1044. + break;
  1045. + case SPEED_1000:
  1046. + pll_val = pll_data->pll_1000;
  1047. + break;
  1048. + default:
  1049. + BUG();
  1050. + }
  1051. +
  1052. + return pll_val;
  1053. +}
  1054. +
  1055. +static void ar71xx_set_pll_ge0(int speed)
  1056. +{
  1057. + u32 val = ar71xx_get_eth_pll(0, speed);
  1058. +
  1059. + ar71xx_set_pll(AR71XX_PLL_REG_SEC_CONFIG, AR71XX_PLL_REG_ETH0_INT_CLOCK,
  1060. + val, AR71XX_ETH0_PLL_SHIFT);
  1061. +}
  1062. +
  1063. +static void ar71xx_set_pll_ge1(int speed)
  1064. +{
  1065. + u32 val = ar71xx_get_eth_pll(1, speed);
  1066. +
  1067. + ar71xx_set_pll(AR71XX_PLL_REG_SEC_CONFIG, AR71XX_PLL_REG_ETH1_INT_CLOCK,
  1068. + val, AR71XX_ETH1_PLL_SHIFT);
  1069. +}
  1070. +
  1071. +static void ar724x_set_pll_ge0(int speed)
  1072. +{
  1073. + /* TODO */
  1074. +}
  1075. +
  1076. +static void ar724x_set_pll_ge1(int speed)
  1077. +{
  1078. + /* TODO */
  1079. +}
  1080. +
  1081. +static void ar91xx_set_pll_ge0(int speed)
  1082. +{
  1083. + u32 val = ar71xx_get_eth_pll(0, speed);
  1084. +
  1085. + ar71xx_set_pll(AR91XX_PLL_REG_ETH_CONFIG, AR91XX_PLL_REG_ETH0_INT_CLOCK,
  1086. + val, AR91XX_ETH0_PLL_SHIFT);
  1087. +}
  1088. +
  1089. +static void ar91xx_set_pll_ge1(int speed)
  1090. +{
  1091. + u32 val = ar71xx_get_eth_pll(1, speed);
  1092. +
  1093. + ar71xx_set_pll(AR91XX_PLL_REG_ETH_CONFIG, AR91XX_PLL_REG_ETH1_INT_CLOCK,
  1094. + val, AR91XX_ETH1_PLL_SHIFT);
  1095. +}
  1096. +
  1097. +static void ar71xx_ddr_flush_ge0(void)
  1098. +{
  1099. + ar71xx_ddr_flush(AR71XX_DDR_REG_FLUSH_GE0);
  1100. +}
  1101. +
  1102. +static void ar71xx_ddr_flush_ge1(void)
  1103. +{
  1104. + ar71xx_ddr_flush(AR71XX_DDR_REG_FLUSH_GE1);
  1105. +}
  1106. +
  1107. +static void ar724x_ddr_flush_ge0(void)
  1108. +{
  1109. + ar71xx_ddr_flush(AR724X_DDR_REG_FLUSH_GE0);
  1110. +}
  1111. +
  1112. +static void ar724x_ddr_flush_ge1(void)
  1113. +{
  1114. + ar71xx_ddr_flush(AR724X_DDR_REG_FLUSH_GE1);
  1115. +}
  1116. +
  1117. +static void ar91xx_ddr_flush_ge0(void)
  1118. +{
  1119. + ar71xx_ddr_flush(AR91XX_DDR_REG_FLUSH_GE0);
  1120. +}
  1121. +
  1122. +static void ar91xx_ddr_flush_ge1(void)
  1123. +{
  1124. + ar71xx_ddr_flush(AR91XX_DDR_REG_FLUSH_GE1);
  1125. +}
  1126. +
  1127. +static struct resource ar71xx_eth0_resources[] = {
  1128. + {
  1129. + .name = "mac_base",
  1130. + .flags = IORESOURCE_MEM,
  1131. + .start = AR71XX_GE0_BASE,
  1132. + .end = AR71XX_GE0_BASE + 0x200 - 1,
  1133. + }, {
  1134. + .name = "mii_ctrl",
  1135. + .flags = IORESOURCE_MEM,
  1136. + .start = AR71XX_MII_BASE + MII_REG_MII0_CTRL,
  1137. + .end = AR71XX_MII_BASE + MII_REG_MII0_CTRL + 3,
  1138. + }, {
  1139. + .name = "mac_irq",
  1140. + .flags = IORESOURCE_IRQ,
  1141. + .start = AR71XX_CPU_IRQ_GE0,
  1142. + .end = AR71XX_CPU_IRQ_GE0,
  1143. + },
  1144. +};
  1145. +
  1146. +struct ag71xx_platform_data ar71xx_eth0_data = {
  1147. + .reset_bit = RESET_MODULE_GE0_MAC,
  1148. +};
  1149. +
  1150. +struct platform_device ar71xx_eth0_device = {
  1151. + .name = "ag71xx",
  1152. + .id = 0,
  1153. + .resource = ar71xx_eth0_resources,
  1154. + .num_resources = ARRAY_SIZE(ar71xx_eth0_resources),
  1155. + .dev = {
  1156. + .platform_data = &ar71xx_eth0_data,
  1157. + },
  1158. +};
  1159. +
  1160. +static struct resource ar71xx_eth1_resources[] = {
  1161. + {
  1162. + .name = "mac_base",
  1163. + .flags = IORESOURCE_MEM,
  1164. + .start = AR71XX_GE1_BASE,
  1165. + .end = AR71XX_GE1_BASE + 0x200 - 1,
  1166. + }, {
  1167. + .name = "mii_ctrl",
  1168. + .flags = IORESOURCE_MEM,
  1169. + .start = AR71XX_MII_BASE + MII_REG_MII1_CTRL,
  1170. + .end = AR71XX_MII_BASE + MII_REG_MII1_CTRL + 3,
  1171. + }, {
  1172. + .name = "mac_irq",
  1173. + .flags = IORESOURCE_IRQ,
  1174. + .start = AR71XX_CPU_IRQ_GE1,
  1175. + .end = AR71XX_CPU_IRQ_GE1,
  1176. + },
  1177. +};
  1178. +
  1179. +struct ag71xx_platform_data ar71xx_eth1_data = {
  1180. + .reset_bit = RESET_MODULE_GE1_MAC,
  1181. +};
  1182. +
  1183. +struct platform_device ar71xx_eth1_device = {
  1184. + .name = "ag71xx",
  1185. + .id = 1,
  1186. + .resource = ar71xx_eth1_resources,
  1187. + .num_resources = ARRAY_SIZE(ar71xx_eth1_resources),
  1188. + .dev = {
  1189. + .platform_data = &ar71xx_eth1_data,
  1190. + },
  1191. +};
  1192. +
  1193. +#define AR71XX_PLL_VAL_1000 0x00110000
  1194. +#define AR71XX_PLL_VAL_100 0x00001099
  1195. +#define AR71XX_PLL_VAL_10 0x00991099
  1196. +
  1197. +#define AR724X_PLL_VAL_1000 0x00110000
  1198. +#define AR724X_PLL_VAL_100 0x00001099
  1199. +#define AR724X_PLL_VAL_10 0x00991099
  1200. +
  1201. +#define AR91XX_PLL_VAL_1000 0x1a000000
  1202. +#define AR91XX_PLL_VAL_100 0x13000a44
  1203. +#define AR91XX_PLL_VAL_10 0x00441099
  1204. +
  1205. +static void __init ar71xx_init_eth_pll_data(unsigned int id)
  1206. +{
  1207. + struct ar71xx_eth_pll_data *pll_data;
  1208. + u32 pll_10, pll_100, pll_1000;
  1209. +
  1210. + switch (id) {
  1211. + case 0:
  1212. + pll_data = &ar71xx_eth0_pll_data;
  1213. + break;
  1214. + case 1:
  1215. + pll_data = &ar71xx_eth1_pll_data;
  1216. + break;
  1217. + default:
  1218. + BUG();
  1219. + }
  1220. +
  1221. + switch (ar71xx_soc) {
  1222. + case AR71XX_SOC_AR7130:
  1223. + case AR71XX_SOC_AR7141:
  1224. + case AR71XX_SOC_AR7161:
  1225. + pll_10 = AR71XX_PLL_VAL_10;
  1226. + pll_100 = AR71XX_PLL_VAL_100;
  1227. + pll_1000 = AR71XX_PLL_VAL_1000;
  1228. + break;
  1229. +
  1230. + case AR71XX_SOC_AR7240:
  1231. + case AR71XX_SOC_AR7241:
  1232. + case AR71XX_SOC_AR7242:
  1233. + pll_10 = AR724X_PLL_VAL_10;
  1234. + pll_100 = AR724X_PLL_VAL_100;
  1235. + pll_1000 = AR724X_PLL_VAL_1000;
  1236. + break;
  1237. +
  1238. + case AR71XX_SOC_AR9130:
  1239. + case AR71XX_SOC_AR9132:
  1240. + pll_10 = AR91XX_PLL_VAL_10;
  1241. + pll_100 = AR91XX_PLL_VAL_100;
  1242. + pll_1000 = AR91XX_PLL_VAL_1000;
  1243. + break;
  1244. + default:
  1245. + BUG();
  1246. + }
  1247. +
  1248. + if (!pll_data->pll_10)
  1249. + pll_data->pll_10 = pll_10;
  1250. +
  1251. + if (!pll_data->pll_100)
  1252. + pll_data->pll_100 = pll_100;
  1253. +
  1254. + if (!pll_data->pll_1000)
  1255. + pll_data->pll_1000 = pll_1000;
  1256. +}
  1257. +
  1258. +static int ar71xx_eth_instance __initdata;
  1259. +void __init ar71xx_add_device_eth(unsigned int id)
  1260. +{
  1261. + struct platform_device *pdev;
  1262. + struct ag71xx_platform_data *pdata;
  1263. +
  1264. + ar71xx_init_eth_pll_data(id);
  1265. +
  1266. + switch (id) {
  1267. + case 0:
  1268. + switch (ar71xx_eth0_data.phy_if_mode) {
  1269. + case PHY_INTERFACE_MODE_MII:
  1270. + ar71xx_eth0_data.mii_if = MII0_CTRL_IF_MII;
  1271. + break;
  1272. + case PHY_INTERFACE_MODE_GMII:
  1273. + ar71xx_eth0_data.mii_if = MII0_CTRL_IF_GMII;
  1274. + break;
  1275. + case PHY_INTERFACE_MODE_RGMII:
  1276. + ar71xx_eth0_data.mii_if = MII0_CTRL_IF_RGMII;
  1277. + break;
  1278. + case PHY_INTERFACE_MODE_RMII:
  1279. + ar71xx_eth0_data.mii_if = MII0_CTRL_IF_RMII;
  1280. + break;
  1281. + default:
  1282. + printk(KERN_ERR "ar71xx: invalid PHY interface mode "
  1283. + "for eth0\n");
  1284. + return;
  1285. + }
  1286. + pdev = &ar71xx_eth0_device;
  1287. + break;
  1288. + case 1:
  1289. + switch (ar71xx_eth1_data.phy_if_mode) {
  1290. + case PHY_INTERFACE_MODE_RMII:
  1291. + ar71xx_eth1_data.mii_if = MII1_CTRL_IF_RMII;
  1292. + break;
  1293. + case PHY_INTERFACE_MODE_RGMII:
  1294. + ar71xx_eth1_data.mii_if = MII1_CTRL_IF_RGMII;
  1295. + break;
  1296. + default:
  1297. + printk(KERN_ERR "ar71xx: invalid PHY interface mode "
  1298. + "for eth1\n");
  1299. + return;
  1300. + }
  1301. + pdev = &ar71xx_eth1_device;
  1302. + break;
  1303. + default:
  1304. + printk(KERN_ERR "ar71xx: invalid ethernet id %d\n", id);
  1305. + return;
  1306. + }
  1307. +
  1308. + pdata = pdev->dev.platform_data;
  1309. +
  1310. + switch (ar71xx_soc) {
  1311. + case AR71XX_SOC_AR7130:
  1312. + pdata->ddr_flush = id ? ar71xx_ddr_flush_ge1
  1313. + : ar71xx_ddr_flush_ge0;
  1314. + pdata->set_pll = id ? ar71xx_set_pll_ge1
  1315. + : ar71xx_set_pll_ge0;
  1316. + break;
  1317. +
  1318. + case AR71XX_SOC_AR7141:
  1319. + case AR71XX_SOC_AR7161:
  1320. + pdata->ddr_flush = id ? ar71xx_ddr_flush_ge1
  1321. + : ar71xx_ddr_flush_ge0;
  1322. + pdata->set_pll = id ? ar71xx_set_pll_ge1
  1323. + : ar71xx_set_pll_ge0;
  1324. + pdata->has_gbit = 1;
  1325. + break;
  1326. +
  1327. + case AR71XX_SOC_AR7241:
  1328. + case AR71XX_SOC_AR7242:
  1329. + ar71xx_eth0_data.reset_bit |= AR724X_RESET_GE0_MDIO;
  1330. + ar71xx_eth1_data.reset_bit |= AR724X_RESET_GE1_MDIO;
  1331. + /* fall through */
  1332. + case AR71XX_SOC_AR7240:
  1333. + pdata->ddr_flush = id ? ar724x_ddr_flush_ge1
  1334. + : ar724x_ddr_flush_ge0;
  1335. + pdata->set_pll = id ? ar724x_set_pll_ge1
  1336. + : ar724x_set_pll_ge0;
  1337. + pdata->is_ar724x = 1;
  1338. + break;
  1339. +
  1340. + case AR71XX_SOC_AR9130:
  1341. + pdata->ddr_flush = id ? ar91xx_ddr_flush_ge1
  1342. + : ar91xx_ddr_flush_ge0;
  1343. + pdata->set_pll = id ? ar91xx_set_pll_ge1
  1344. + : ar91xx_set_pll_ge0;
  1345. + pdata->is_ar91xx = 1;
  1346. + break;
  1347. +
  1348. + case AR71XX_SOC_AR9132:
  1349. + pdata->ddr_flush = id ? ar91xx_ddr_flush_ge1
  1350. + : ar91xx_ddr_flush_ge0;
  1351. + pdata->set_pll = id ? ar91xx_set_pll_ge1
  1352. + : ar91xx_set_pll_ge0;
  1353. + pdata->is_ar91xx = 1;
  1354. + pdata->has_gbit = 1;
  1355. + break;
  1356. +
  1357. + default:
  1358. + BUG();
  1359. + }
  1360. +
  1361. + switch (pdata->phy_if_mode) {
  1362. + case PHY_INTERFACE_MODE_GMII:
  1363. + case PHY_INTERFACE_MODE_RGMII:
  1364. + if (!pdata->has_gbit) {
  1365. + printk(KERN_ERR "ar71xx: no gbit available on eth%d\n",
  1366. + id);
  1367. + return;
  1368. + }
  1369. + /* fallthrough */
  1370. + default:
  1371. + break;
  1372. + }
  1373. +
  1374. + if (is_valid_ether_addr(ar71xx_mac_base)) {
  1375. + memcpy(pdata->mac_addr, ar71xx_mac_base, ETH_ALEN);
  1376. + pdata->mac_addr[5] += ar71xx_eth_instance;
  1377. + } else {
  1378. + random_ether_addr(pdata->mac_addr);
  1379. + printk(KERN_DEBUG
  1380. + "ar71xx: using random MAC address for eth%d\n",
  1381. + ar71xx_eth_instance);
  1382. + }
  1383. +
  1384. + if (pdata->mii_bus_dev == NULL)
  1385. + pdata->mii_bus_dev = &ar71xx_mdio_device.dev;
  1386. +
  1387. + /* Reset the device */
  1388. + ar71xx_device_stop(pdata->reset_bit);
  1389. + mdelay(100);
  1390. +
  1391. + ar71xx_device_start(pdata->reset_bit);
  1392. + mdelay(100);
  1393. +
  1394. + platform_device_register(pdev);
  1395. + ar71xx_eth_instance++;
  1396. +}
  1397. +
  1398. +static struct resource ar71xx_spi_resources[] = {
  1399. + [0] = {
  1400. + .start = AR71XX_SPI_BASE,
  1401. + .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
  1402. + .flags = IORESOURCE_MEM,
  1403. + },
  1404. +};
  1405. +
  1406. +static struct platform_device ar71xx_spi_device = {
  1407. + .name = "ar71xx-spi",
  1408. + .id = -1,
  1409. + .resource = ar71xx_spi_resources,
  1410. + .num_resources = ARRAY_SIZE(ar71xx_spi_resources),
  1411. +};
  1412. +
  1413. +void __init ar71xx_add_device_spi(struct ar71xx_spi_platform_data *pdata,
  1414. + struct spi_board_info const *info,
  1415. + unsigned n)
  1416. +{
  1417. + spi_register_board_info(info, n);
  1418. + ar71xx_spi_device.dev.platform_data = pdata;
  1419. + platform_device_register(&ar71xx_spi_device);
  1420. +}
  1421. +
  1422. +void __init ar71xx_add_device_wdt(void)
  1423. +{
  1424. + platform_device_register_simple("ar71xx-wdt", -1, NULL, 0);
  1425. +}
  1426. +
  1427. +void __init ar71xx_set_mac_base(unsigned char *mac)
  1428. +{
  1429. + memcpy(ar71xx_mac_base, mac, ETH_ALEN);
  1430. +}
  1431. +
  1432. +void __init ar71xx_parse_mac_addr(char *mac_str)
  1433. +{
  1434. + u8 tmp[ETH_ALEN];
  1435. + int t;
  1436. +
  1437. + t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
  1438. + &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]);
  1439. +
  1440. + if (t != ETH_ALEN)
  1441. + t = sscanf(mac_str, "%02hhx.%02hhx.%02hhx.%02hhx.%02hhx.%02hhx",
  1442. + &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]);
  1443. +
  1444. + if (t == ETH_ALEN)
  1445. + ar71xx_set_mac_base(tmp);
  1446. + else
  1447. + printk(KERN_DEBUG "ar71xx: failed to parse mac address "
  1448. + "\"%s\"\n", mac_str);
  1449. +}
  1450. +
  1451. +static int __init ar71xx_ethaddr_setup(char *str)
  1452. +{
  1453. + ar71xx_parse_mac_addr(str);
  1454. + return 1;
  1455. +}
  1456. +__setup("ethaddr=", ar71xx_ethaddr_setup);
  1457. +
  1458. +static int __init ar71xx_kmac_setup(char *str)
  1459. +{
  1460. + ar71xx_parse_mac_addr(str);
  1461. + return 1;
  1462. +}
  1463. +__setup("kmac=", ar71xx_kmac_setup);
  1464. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/devices.h linux-2.6.35.7/arch/mips/ar71xx/devices.h
  1465. --- linux-2.6.35.7.orig/arch/mips/ar71xx/devices.h 1970-01-01 01:00:00.000000000 +0100
  1466. +++ linux-2.6.35.7/arch/mips/ar71xx/devices.h 2010-10-14 20:27:56.504463432 +0200
  1467. @@ -0,0 +1,48 @@
  1468. +/*
  1469. + * Atheros AR71xx SoC device definitions
  1470. + *
  1471. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  1472. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  1473. + *
  1474. + * This program is free software; you can redistribute it and/or modify it
  1475. + * under the terms of the GNU General Public License version 2 as published
  1476. + * by the Free Software Foundation.
  1477. + */
  1478. +
  1479. +#ifndef __AR71XX_DEVICES_H
  1480. +#define __AR71XX_DEVICES_H
  1481. +
  1482. +#include <asm/mach-ar71xx/platform.h>
  1483. +
  1484. +struct platform_device;
  1485. +
  1486. +void ar71xx_add_device_spi(struct ar71xx_spi_platform_data *pdata,
  1487. + struct spi_board_info const *info,
  1488. + unsigned n) __init;
  1489. +
  1490. +void ar71xx_set_mac_base(unsigned char *mac) __init;
  1491. +void ar71xx_parse_mac_addr(char *mac_str) __init;
  1492. +
  1493. +struct ar71xx_eth_pll_data {
  1494. + u32 pll_10;
  1495. + u32 pll_100;
  1496. + u32 pll_1000;
  1497. +};
  1498. +
  1499. +extern struct ar71xx_eth_pll_data ar71xx_eth0_pll_data;
  1500. +extern struct ar71xx_eth_pll_data ar71xx_eth1_pll_data;
  1501. +
  1502. +extern struct ag71xx_platform_data ar71xx_eth0_data;
  1503. +extern struct ag71xx_platform_data ar71xx_eth1_data;
  1504. +extern struct platform_device ar71xx_eth0_device;
  1505. +extern struct platform_device ar71xx_eth1_device;
  1506. +void ar71xx_add_device_eth(unsigned int id) __init;
  1507. +
  1508. +extern struct platform_device ar71xx_mdio_device;
  1509. +void ar71xx_add_device_mdio(u32 phy_mask) __init;
  1510. +
  1511. +void ar71xx_add_device_uart(void) __init;
  1512. +
  1513. +void ar71xx_add_device_wdt(void) __init;
  1514. +
  1515. +#endif /* __AR71XX_DEVICES_H */
  1516. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-leds-gpio.c linux-2.6.35.7/arch/mips/ar71xx/dev-leds-gpio.c
  1517. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-leds-gpio.c 1970-01-01 01:00:00.000000000 +0100
  1518. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-leds-gpio.c 2010-10-14 20:27:56.545601257 +0200
  1519. @@ -0,0 +1,57 @@
  1520. +/*
  1521. + * Atheros AR71xx GPIO LED device support
  1522. + *
  1523. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  1524. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  1525. + *
  1526. + * Parts of this file are based on Atheros' 2.6.15 BSP
  1527. + *
  1528. + * This program is free software; you can redistribute it and/or modify it
  1529. + * under the terms of the GNU General Public License version 2 as published
  1530. + * by the Free Software Foundation.
  1531. + */
  1532. +
  1533. +#include <linux/init.h>
  1534. +#include <linux/platform_device.h>
  1535. +#include <linux/slab.h>
  1536. +
  1537. +#include "dev-leds-gpio.h"
  1538. +
  1539. +void __init ar71xx_add_device_leds_gpio(int id, unsigned num_leds,
  1540. + struct gpio_led *leds)
  1541. +{
  1542. + struct platform_device *pdev;
  1543. + struct gpio_led_platform_data pdata;
  1544. + struct gpio_led *p;
  1545. + int err;
  1546. +
  1547. + p = kmalloc(num_leds * sizeof(*p), GFP_KERNEL);
  1548. + if (!p)
  1549. + return;
  1550. +
  1551. + memcpy(p, leds, num_leds * sizeof(*p));
  1552. +
  1553. + pdev = platform_device_alloc("leds-gpio", id);
  1554. + if (!pdev)
  1555. + goto err_free_leds;
  1556. +
  1557. + memset(&pdata, 0, sizeof(pdata));
  1558. + pdata.num_leds = num_leds;
  1559. + pdata.leds = p;
  1560. +
  1561. + err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
  1562. + if (err)
  1563. + goto err_put_pdev;
  1564. +
  1565. + err = platform_device_add(pdev);
  1566. + if (err)
  1567. + goto err_put_pdev;
  1568. +
  1569. + return;
  1570. +
  1571. +err_put_pdev:
  1572. + platform_device_put(pdev);
  1573. +
  1574. +err_free_leds:
  1575. + kfree(p);
  1576. +}
  1577. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-leds-gpio.h linux-2.6.35.7/arch/mips/ar71xx/dev-leds-gpio.h
  1578. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-leds-gpio.h 1970-01-01 01:00:00.000000000 +0100
  1579. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-leds-gpio.h 2010-10-14 20:27:56.595814317 +0200
  1580. @@ -0,0 +1,21 @@
  1581. +/*
  1582. + * Atheros AR71xx GPIO LED device support
  1583. + *
  1584. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  1585. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  1586. + *
  1587. + * This program is free software; you can redistribute it and/or modify it
  1588. + * under the terms of the GNU General Public License version 2 as published
  1589. + * by the Free Software Foundation.
  1590. + */
  1591. +
  1592. +#ifndef _AR71XX_DEV_LEDS_GPIO_H
  1593. +#define _AR71XX_DEV_LEDS_GPIO_H
  1594. +
  1595. +#include <linux/leds.h>
  1596. +
  1597. +void ar71xx_add_device_leds_gpio(int id,
  1598. + unsigned num_leds,
  1599. + struct gpio_led *leds) __init;
  1600. +
  1601. +#endif /* _AR71XX_DEV_LEDS_GPIO_H */
  1602. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-m25p80.c linux-2.6.35.7/arch/mips/ar71xx/dev-m25p80.c
  1603. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-m25p80.c 1970-01-01 01:00:00.000000000 +0100
  1604. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-m25p80.c 2010-10-14 20:27:56.645623230 +0200
  1605. @@ -0,0 +1,30 @@
  1606. +/*
  1607. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  1608. + *
  1609. + * This program is free software; you can redistribute it and/or modify it
  1610. + * under the terms of the GNU General Public License version 2 as published
  1611. + * by the Free Software Foundation.
  1612. + */
  1613. +
  1614. +#include <linux/init.h>
  1615. +#include <linux/spi/spi.h>
  1616. +#include <linux/spi/flash.h>
  1617. +
  1618. +#include "devices.h"
  1619. +#include "dev-m25p80.h"
  1620. +
  1621. +static struct spi_board_info ar71xx_spi_info[] = {
  1622. + {
  1623. + .bus_num = 0,
  1624. + .chip_select = 0,
  1625. + .max_speed_hz = 25000000,
  1626. + .modalias = "m25p80",
  1627. + }
  1628. +};
  1629. +
  1630. +void __init ar71xx_add_device_m25p80(struct flash_platform_data *pdata)
  1631. +{
  1632. + ar71xx_spi_info[0].platform_data = pdata;
  1633. + ar71xx_add_device_spi(NULL, ar71xx_spi_info,
  1634. + ARRAY_SIZE(ar71xx_spi_info));
  1635. +}
  1636. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-m25p80.h linux-2.6.35.7/arch/mips/ar71xx/dev-m25p80.h
  1637. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-m25p80.h 1970-01-01 01:00:00.000000000 +0100
  1638. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-m25p80.h 2010-10-14 20:27:56.695412366 +0200
  1639. @@ -0,0 +1,16 @@
  1640. +/*
  1641. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  1642. + *
  1643. + * This program is free software; you can redistribute it and/or modify it
  1644. + * under the terms of the GNU General Public License version 2 as published
  1645. + * by the Free Software Foundation.
  1646. + */
  1647. +
  1648. +#ifndef _AR71XX_DEV_M25P80_H
  1649. +#define _AR71XX_DEV_M25P80_H
  1650. +
  1651. +#include <linux/spi/flash.h>
  1652. +
  1653. +void ar71xx_add_device_m25p80(struct flash_platform_data *pdata) __init;
  1654. +
  1655. +#endif /* _AR71XX_DEV_M25P80_H */
  1656. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-pb42-pci.c linux-2.6.35.7/arch/mips/ar71xx/dev-pb42-pci.c
  1657. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-pb42-pci.c 1970-01-01 01:00:00.000000000 +0100
  1658. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-pb42-pci.c 2010-10-14 20:27:56.745266514 +0200
  1659. @@ -0,0 +1,40 @@
  1660. +/*
  1661. + * Atheros PB42 reference board PCI initialization
  1662. + *
  1663. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  1664. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  1665. + *
  1666. + * Parts of this file are based on Atheros' 2.6.15 BSP
  1667. + *
  1668. + * This program is free software; you can redistribute it and/or modify it
  1669. + * under the terms of the GNU General Public License version 2 as published
  1670. + * by the Free Software Foundation.
  1671. + */
  1672. +
  1673. +#include <linux/pci.h>
  1674. +
  1675. +#include <asm/mach-ar71xx/ar71xx.h>
  1676. +#include <asm/mach-ar71xx/pci.h>
  1677. +
  1678. +#include "dev-pb42-pci.h"
  1679. +
  1680. +static struct ar71xx_pci_irq pb42_pci_irqs[] __initdata = {
  1681. + {
  1682. + .slot = 0,
  1683. + .pin = 1,
  1684. + .irq = AR71XX_PCI_IRQ_DEV0,
  1685. + }, {
  1686. + .slot = 1,
  1687. + .pin = 1,
  1688. + .irq = AR71XX_PCI_IRQ_DEV1,
  1689. + }, {
  1690. + .slot = 2,
  1691. + .pin = 1,
  1692. + .irq = AR71XX_PCI_IRQ_DEV2,
  1693. + }
  1694. +};
  1695. +
  1696. +void __init pb42_pci_init(void)
  1697. +{
  1698. + ar71xx_pci_init(ARRAY_SIZE(pb42_pci_irqs), pb42_pci_irqs);
  1699. +}
  1700. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-pb42-pci.h linux-2.6.35.7/arch/mips/ar71xx/dev-pb42-pci.h
  1701. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-pb42-pci.h 1970-01-01 01:00:00.000000000 +0100
  1702. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-pb42-pci.h 2010-10-14 20:27:56.795082429 +0200
  1703. @@ -0,0 +1,21 @@
  1704. +/*
  1705. + * Atheros PB42 reference board PCI initialization
  1706. + *
  1707. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  1708. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  1709. + *
  1710. + * This program is free software; you can redistribute it and/or modify it
  1711. + * under the terms of the GNU General Public License version 2 as published
  1712. + * by the Free Software Foundation.
  1713. + */
  1714. +
  1715. +#ifndef _AR71XX_DEV_PB42_PCI_H
  1716. +#define _AR71XX_DEV_PB42_PCI_H
  1717. +
  1718. +#if defined(CONFIG_AR71XX_DEV_PB42_PCI)
  1719. +void pb42_pci_init(void) __init;
  1720. +#else
  1721. +static inline void pb42_pci_init(void) { }
  1722. +#endif
  1723. +
  1724. +#endif /* _AR71XX_DEV_PB42_PCI_H */
  1725. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-pb9x-pci.c linux-2.6.35.7/arch/mips/ar71xx/dev-pb9x-pci.c
  1726. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-pb9x-pci.c 1970-01-01 01:00:00.000000000 +0100
  1727. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-pb9x-pci.c 2010-10-14 20:27:56.844918541 +0200
  1728. @@ -0,0 +1,33 @@
  1729. +/*
  1730. + * Atheros PB9x reference board PCI initialization
  1731. + *
  1732. + * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
  1733. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  1734. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  1735. + *
  1736. + * Parts of this file are based on Atheros' 2.6.15 BSP
  1737. + *
  1738. + * This program is free software; you can redistribute it and/or modify it
  1739. + * under the terms of the GNU General Public License version 2 as published
  1740. + * by the Free Software Foundation.
  1741. + */
  1742. +
  1743. +#include <linux/pci.h>
  1744. +
  1745. +#include <asm/mach-ar71xx/ar71xx.h>
  1746. +#include <asm/mach-ar71xx/pci.h>
  1747. +
  1748. +#include "dev-pb9x-pci.h"
  1749. +
  1750. +static struct ar71xx_pci_irq pb9x_pci_irqs[] __initdata = {
  1751. + {
  1752. + .slot = 0,
  1753. + .pin = 1,
  1754. + .irq = AR71XX_PCI_IRQ_DEV0,
  1755. + }
  1756. +};
  1757. +
  1758. +void __init pb9x_pci_init(void)
  1759. +{
  1760. + ar71xx_pci_init(ARRAY_SIZE(pb9x_pci_irqs), pb9x_pci_irqs);
  1761. +}
  1762. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-pb9x-pci.h linux-2.6.35.7/arch/mips/ar71xx/dev-pb9x-pci.h
  1763. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-pb9x-pci.h 1970-01-01 01:00:00.000000000 +0100
  1764. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-pb9x-pci.h 2010-10-14 20:27:56.894720777 +0200
  1765. @@ -0,0 +1,22 @@
  1766. +/*
  1767. + * Atheros PB9x reference board PCI initialization
  1768. + *
  1769. + * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
  1770. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  1771. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  1772. + *
  1773. + * This program is free software; you can redistribute it and/or modify it
  1774. + * under the terms of the GNU General Public License version 2 as published
  1775. + * by the Free Software Foundation.
  1776. + */
  1777. +
  1778. +#ifndef _AR71XX_DEV_PB9X_PCI_H
  1779. +#define _AR71XX_DEV_PB9X_PCI_H
  1780. +
  1781. +#if defined(CONFIG_AR71XX_DEV_PB9X_PCI)
  1782. +void pb9x_pci_init(void) __init;
  1783. +#else
  1784. +static inline void pb9x_pci_init(void) { }
  1785. +#endif
  1786. +
  1787. +#endif /* _AR71XX_DEV_PB9X_PCI_H */
  1788. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-usb.c linux-2.6.35.7/arch/mips/ar71xx/dev-usb.c
  1789. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-usb.c 1970-01-01 01:00:00.000000000 +0100
  1790. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-usb.c 2010-10-14 20:27:56.944533864 +0200
  1791. @@ -0,0 +1,181 @@
  1792. +/*
  1793. + * Atheros AR71xx USB host device support
  1794. + *
  1795. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  1796. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  1797. + *
  1798. + * Parts of this file are based on Atheros' 2.6.15 BSP
  1799. + *
  1800. + * This program is free software; you can redistribute it and/or modify it
  1801. + * under the terms of the GNU General Public License version 2 as published
  1802. + * by the Free Software Foundation.
  1803. + */
  1804. +
  1805. +#include <linux/kernel.h>
  1806. +#include <linux/init.h>
  1807. +#include <linux/delay.h>
  1808. +#include <linux/dma-mapping.h>
  1809. +#include <linux/platform_device.h>
  1810. +
  1811. +#include <asm/mach-ar71xx/ar71xx.h>
  1812. +#include <asm/mach-ar71xx/platform.h>
  1813. +
  1814. +#include "dev-usb.h"
  1815. +
  1816. +/*
  1817. + * OHCI (USB full speed host controller)
  1818. + */
  1819. +static struct resource ar71xx_ohci_resources[] = {
  1820. + [0] = {
  1821. + .start = AR71XX_OHCI_BASE,
  1822. + .end = AR71XX_OHCI_BASE + AR71XX_OHCI_SIZE - 1,
  1823. + .flags = IORESOURCE_MEM,
  1824. + },
  1825. + [1] = {
  1826. + .start = AR71XX_MISC_IRQ_OHCI,
  1827. + .end = AR71XX_MISC_IRQ_OHCI,
  1828. + .flags = IORESOURCE_IRQ,
  1829. + },
  1830. +};
  1831. +
  1832. +static struct resource ar7240_ohci_resources[] = {
  1833. + [0] = {
  1834. + .start = AR7240_OHCI_BASE,
  1835. + .end = AR7240_OHCI_BASE + AR7240_OHCI_SIZE - 1,
  1836. + .flags = IORESOURCE_MEM,
  1837. + },
  1838. + [1] = {
  1839. + .start = AR71XX_CPU_IRQ_USB,
  1840. + .end = AR71XX_CPU_IRQ_USB,
  1841. + .flags = IORESOURCE_IRQ,
  1842. + },
  1843. +};
  1844. +
  1845. +static u64 ar71xx_ohci_dmamask = DMA_BIT_MASK(32);
  1846. +static struct platform_device ar71xx_ohci_device = {
  1847. + .name = "ar71xx-ohci",
  1848. + .id = -1,
  1849. + .resource = ar71xx_ohci_resources,
  1850. + .num_resources = ARRAY_SIZE(ar71xx_ohci_resources),
  1851. + .dev = {
  1852. + .dma_mask = &ar71xx_ohci_dmamask,
  1853. + .coherent_dma_mask = DMA_BIT_MASK(32),
  1854. + },
  1855. +};
  1856. +
  1857. +/*
  1858. + * EHCI (USB full speed host controller)
  1859. + */
  1860. +static struct resource ar71xx_ehci_resources[] = {
  1861. + [0] = {
  1862. + .start = AR71XX_EHCI_BASE,
  1863. + .end = AR71XX_EHCI_BASE + AR71XX_EHCI_SIZE - 1,
  1864. + .flags = IORESOURCE_MEM,
  1865. + },
  1866. + [1] = {
  1867. + .start = AR71XX_CPU_IRQ_USB,
  1868. + .end = AR71XX_CPU_IRQ_USB,
  1869. + .flags = IORESOURCE_IRQ,
  1870. + },
  1871. +};
  1872. +
  1873. +static u64 ar71xx_ehci_dmamask = DMA_BIT_MASK(32);
  1874. +static struct ar71xx_ehci_platform_data ar71xx_ehci_data;
  1875. +
  1876. +static struct platform_device ar71xx_ehci_device = {
  1877. + .name = "ar71xx-ehci",
  1878. + .id = -1,
  1879. + .resource = ar71xx_ehci_resources,
  1880. + .num_resources = ARRAY_SIZE(ar71xx_ehci_resources),
  1881. + .dev = {
  1882. + .dma_mask = &ar71xx_ehci_dmamask,
  1883. + .coherent_dma_mask = DMA_BIT_MASK(32),
  1884. + .platform_data = &ar71xx_ehci_data,
  1885. + },
  1886. +};
  1887. +
  1888. +#define AR71XX_USB_RESET_MASK \
  1889. + (RESET_MODULE_USB_HOST | RESET_MODULE_USB_PHY \
  1890. + | RESET_MODULE_USB_OHCI_DLL)
  1891. +
  1892. +#define AR7240_USB_RESET_MASK \
  1893. + (RESET_MODULE_USB_HOST | RESET_MODULE_USB_OHCI_DLL_7240)
  1894. +
  1895. +static void __init ar71xx_usb_setup(void)
  1896. +{
  1897. + ar71xx_device_stop(AR71XX_USB_RESET_MASK);
  1898. + mdelay(1000);
  1899. + ar71xx_device_start(AR71XX_USB_RESET_MASK);
  1900. +
  1901. + /* Turning on the Buff and Desc swap bits */
  1902. + ar71xx_usb_ctrl_wr(USB_CTRL_REG_CONFIG, 0xf0000);
  1903. +
  1904. + /* WAR for HW bug. Here it adjusts the duration between two SOFS */
  1905. + ar71xx_usb_ctrl_wr(USB_CTRL_REG_FLADJ, 0x20c00);
  1906. +
  1907. + mdelay(900);
  1908. +
  1909. + platform_device_register(&ar71xx_ohci_device);
  1910. + platform_device_register(&ar71xx_ehci_device);
  1911. +}
  1912. +
  1913. +static void __init ar7240_usb_setup(void)
  1914. +{
  1915. + ar71xx_device_stop(AR7240_USB_RESET_MASK);
  1916. + mdelay(1000);
  1917. + ar71xx_device_start(AR7240_USB_RESET_MASK);
  1918. +
  1919. + /* WAR for HW bug. Here it adjusts the duration between two SOFS */
  1920. + ar71xx_usb_ctrl_wr(USB_CTRL_REG_FLADJ, 0x3);
  1921. +
  1922. + if (ar71xx_soc == AR71XX_SOC_AR7241 || ar71xx_soc == AR71XX_SOC_AR7242) {
  1923. + ar71xx_ehci_data.is_ar91xx = 1;
  1924. + ar71xx_ehci_device.resource = ar7240_ohci_resources;
  1925. + ar71xx_ehci_device.num_resources = ARRAY_SIZE(ar7240_ohci_resources);
  1926. + platform_device_register(&ar71xx_ehci_device);
  1927. + } else {
  1928. + ar71xx_ohci_device.resource = ar7240_ohci_resources;
  1929. + ar71xx_ohci_device.num_resources = ARRAY_SIZE(ar7240_ohci_resources);
  1930. + platform_device_register(&ar71xx_ohci_device);
  1931. + }
  1932. +}
  1933. +
  1934. +static void __init ar91xx_usb_setup(void)
  1935. +{
  1936. + ar71xx_device_stop(RESET_MODULE_USBSUS_OVERRIDE);
  1937. + mdelay(10);
  1938. +
  1939. + ar71xx_device_start(RESET_MODULE_USB_HOST);
  1940. + mdelay(10);
  1941. +
  1942. + ar71xx_device_start(RESET_MODULE_USB_PHY);
  1943. + mdelay(10);
  1944. +
  1945. + ar71xx_ehci_data.is_ar91xx = 1;
  1946. + platform_device_register(&ar71xx_ehci_device);
  1947. +}
  1948. +
  1949. +void __init ar71xx_add_device_usb(void)
  1950. +{
  1951. + switch (ar71xx_soc) {
  1952. + case AR71XX_SOC_AR7240:
  1953. + case AR71XX_SOC_AR7241:
  1954. + case AR71XX_SOC_AR7242:
  1955. + ar7240_usb_setup();
  1956. + break;
  1957. +
  1958. + case AR71XX_SOC_AR7130:
  1959. + case AR71XX_SOC_AR7141:
  1960. + case AR71XX_SOC_AR7161:
  1961. + ar71xx_usb_setup();
  1962. + break;
  1963. +
  1964. + case AR71XX_SOC_AR9130:
  1965. + case AR71XX_SOC_AR9132:
  1966. + ar91xx_usb_setup();
  1967. + break;
  1968. +
  1969. + default:
  1970. + BUG();
  1971. + }
  1972. +}
  1973. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/dev-usb.h linux-2.6.35.7/arch/mips/ar71xx/dev-usb.h
  1974. --- linux-2.6.35.7.orig/arch/mips/ar71xx/dev-usb.h 1970-01-01 01:00:00.000000000 +0100
  1975. +++ linux-2.6.35.7/arch/mips/ar71xx/dev-usb.h 2010-10-14 20:27:56.994353425 +0200
  1976. @@ -0,0 +1,17 @@
  1977. +/*
  1978. + * Atheros AR71xx USB host device support
  1979. + *
  1980. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  1981. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  1982. + *
  1983. + * This program is free software; you can redistribute it and/or modify it
  1984. + * under the terms of the GNU General Public License version 2 as published
  1985. + * by the Free Software Foundation.
  1986. + */
  1987. +
  1988. +#ifndef _AR71XX_DEV_USB_H
  1989. +#define _AR71XX_DEV_USB_H
  1990. +
  1991. +void ar71xx_add_device_usb(void) __init;
  1992. +
  1993. +#endif /* _AR71XX_DEV_USB_H */
  1994. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/early_printk.c linux-2.6.35.7/arch/mips/ar71xx/early_printk.c
  1995. --- linux-2.6.35.7.orig/arch/mips/ar71xx/early_printk.c 1970-01-01 01:00:00.000000000 +0100
  1996. +++ linux-2.6.35.7/arch/mips/ar71xx/early_printk.c 2010-10-14 20:27:57.044356938 +0200
  1997. @@ -0,0 +1,30 @@
  1998. +/*
  1999. + * Atheros AR71xx SoC early printk support
  2000. + *
  2001. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  2002. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  2003. + *
  2004. + * This program is free software; you can redistribute it and/or modify it
  2005. + * under the terms of the GNU General Public License version 2 as published
  2006. + * by the Free Software Foundation.
  2007. + */
  2008. +
  2009. +#include <linux/io.h>
  2010. +#include <linux/serial_reg.h>
  2011. +#include <asm/addrspace.h>
  2012. +
  2013. +#include <asm/mach-ar71xx/ar71xx.h>
  2014. +
  2015. +#define UART_READ(r) \
  2016. + __raw_readl((void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE) + 4 * (r)))
  2017. +
  2018. +#define UART_WRITE(r, v) \
  2019. + __raw_writel((v), (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE) + 4*(r)))
  2020. +
  2021. +void prom_putchar(unsigned char ch)
  2022. +{
  2023. + while (((UART_READ(UART_LSR)) & UART_LSR_THRE) == 0);
  2024. + UART_WRITE(UART_TX, ch);
  2025. + while (((UART_READ(UART_LSR)) & UART_LSR_THRE) == 0);
  2026. +}
  2027. +
  2028. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/gpio.c linux-2.6.35.7/arch/mips/ar71xx/gpio.c
  2029. --- linux-2.6.35.7.orig/arch/mips/ar71xx/gpio.c 1970-01-01 01:00:00.000000000 +0100
  2030. +++ linux-2.6.35.7/arch/mips/ar71xx/gpio.c 2010-10-14 20:27:57.084356695 +0200
  2031. @@ -0,0 +1,182 @@
  2032. +/*
  2033. + * Atheros AR71xx SoC GPIO API support
  2034. + *
  2035. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  2036. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  2037. + *
  2038. + * This program is free software; you can redistribute it and/or modify it
  2039. + * under the terms of the GNU General Public License version 2 as published
  2040. + * by the Free Software Foundation.
  2041. + */
  2042. +
  2043. +#include <linux/kernel.h>
  2044. +#include <linux/init.h>
  2045. +#include <linux/module.h>
  2046. +#include <linux/types.h>
  2047. +#include <linux/spinlock.h>
  2048. +#include <linux/io.h>
  2049. +#include <linux/ioport.h>
  2050. +#include <linux/gpio.h>
  2051. +
  2052. +#include <asm/mach-ar71xx/ar71xx.h>
  2053. +
  2054. +static DEFINE_SPINLOCK(ar71xx_gpio_lock);
  2055. +
  2056. +unsigned long ar71xx_gpio_count;
  2057. +EXPORT_SYMBOL(ar71xx_gpio_count);
  2058. +
  2059. +void __ar71xx_gpio_set_value(unsigned gpio, int value)
  2060. +{
  2061. + void __iomem *base = ar71xx_gpio_base;
  2062. +
  2063. + if (value)
  2064. + __raw_writel(1 << gpio, base + GPIO_REG_SET);
  2065. + else
  2066. + __raw_writel(1 << gpio, base + GPIO_REG_CLEAR);
  2067. +}
  2068. +EXPORT_SYMBOL(__ar71xx_gpio_set_value);
  2069. +
  2070. +int __ar71xx_gpio_get_value(unsigned gpio)
  2071. +{
  2072. + return (__raw_readl(ar71xx_gpio_base + GPIO_REG_IN) >> gpio) & 1;
  2073. +}
  2074. +EXPORT_SYMBOL(__ar71xx_gpio_get_value);
  2075. +
  2076. +static int ar71xx_gpio_get_value(struct gpio_chip *chip, unsigned offset)
  2077. +{
  2078. + return __ar71xx_gpio_get_value(offset);
  2079. +}
  2080. +
  2081. +static void ar71xx_gpio_set_value(struct gpio_chip *chip,
  2082. + unsigned offset, int value)
  2083. +{
  2084. + __ar71xx_gpio_set_value(offset, value);
  2085. +}
  2086. +
  2087. +static int ar71xx_gpio_direction_input(struct gpio_chip *chip,
  2088. + unsigned offset)
  2089. +{
  2090. + void __iomem *base = ar71xx_gpio_base;
  2091. + unsigned long flags;
  2092. +
  2093. + spin_lock_irqsave(&ar71xx_gpio_lock, flags);
  2094. +
  2095. + __raw_writel(__raw_readl(base + GPIO_REG_OE) & ~(1 << offset),
  2096. + base + GPIO_REG_OE);
  2097. +
  2098. + spin_unlock_irqrestore(&ar71xx_gpio_lock, flags);
  2099. +
  2100. + return 0;
  2101. +}
  2102. +
  2103. +static int ar71xx_gpio_direction_output(struct gpio_chip *chip,
  2104. + unsigned offset, int value)
  2105. +{
  2106. + void __iomem *base = ar71xx_gpio_base;
  2107. + unsigned long flags;
  2108. +
  2109. + spin_lock_irqsave(&ar71xx_gpio_lock, flags);
  2110. +
  2111. + if (value)
  2112. + __raw_writel(1 << offset, base + GPIO_REG_SET);
  2113. + else
  2114. + __raw_writel(1 << offset, base + GPIO_REG_CLEAR);
  2115. +
  2116. + __raw_writel(__raw_readl(base + GPIO_REG_OE) | (1 << offset),
  2117. + base + GPIO_REG_OE);
  2118. +
  2119. + spin_unlock_irqrestore(&ar71xx_gpio_lock, flags);
  2120. +
  2121. + return 0;
  2122. +}
  2123. +
  2124. +static struct gpio_chip ar71xx_gpio_chip = {
  2125. + .label = "ar71xx",
  2126. + .get = ar71xx_gpio_get_value,
  2127. + .set = ar71xx_gpio_set_value,
  2128. + .direction_input = ar71xx_gpio_direction_input,
  2129. + .direction_output = ar71xx_gpio_direction_output,
  2130. + .base = 0,
  2131. + .ngpio = AR71XX_GPIO_COUNT,
  2132. +};
  2133. +
  2134. +void ar71xx_gpio_function_enable(u32 mask)
  2135. +{
  2136. + void __iomem *base = ar71xx_gpio_base;
  2137. + unsigned long flags;
  2138. +
  2139. + spin_lock_irqsave(&ar71xx_gpio_lock, flags);
  2140. +
  2141. + __raw_writel(__raw_readl(base + GPIO_REG_FUNC) | mask,
  2142. + base + GPIO_REG_FUNC);
  2143. + /* flush write */
  2144. + (void) __raw_readl(base + GPIO_REG_FUNC);
  2145. +
  2146. + spin_unlock_irqrestore(&ar71xx_gpio_lock, flags);
  2147. +}
  2148. +
  2149. +void ar71xx_gpio_function_disable(u32 mask)
  2150. +{
  2151. + void __iomem *base = ar71xx_gpio_base;
  2152. + unsigned long flags;
  2153. +
  2154. + spin_lock_irqsave(&ar71xx_gpio_lock, flags);
  2155. +
  2156. + __raw_writel(__raw_readl(base + GPIO_REG_FUNC) & ~mask,
  2157. + base + GPIO_REG_FUNC);
  2158. + /* flush write */
  2159. + (void) __raw_readl(base + GPIO_REG_FUNC);
  2160. +
  2161. + spin_unlock_irqrestore(&ar71xx_gpio_lock, flags);
  2162. +}
  2163. +
  2164. +void ar71xx_gpio_function_setup(u32 set, u32 clear)
  2165. +{
  2166. + void __iomem *base = ar71xx_gpio_base;
  2167. + unsigned long flags;
  2168. +
  2169. + spin_lock_irqsave(&ar71xx_gpio_lock, flags);
  2170. +
  2171. + __raw_writel((__raw_readl(base + GPIO_REG_FUNC) & ~clear) | set,
  2172. + base + GPIO_REG_FUNC);
  2173. + /* flush write */
  2174. + (void) __raw_readl(base + GPIO_REG_FUNC);
  2175. +
  2176. + spin_unlock_irqrestore(&ar71xx_gpio_lock, flags);
  2177. +}
  2178. +EXPORT_SYMBOL(ar71xx_gpio_function_setup);
  2179. +
  2180. +void __init ar71xx_gpio_init(void)
  2181. +{
  2182. + int err;
  2183. +
  2184. + if (!request_mem_region(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE,
  2185. + "AR71xx GPIO controller"))
  2186. + panic("cannot allocate AR71xx GPIO registers page");
  2187. +
  2188. + switch (ar71xx_soc) {
  2189. + case AR71XX_SOC_AR7130:
  2190. + case AR71XX_SOC_AR7141:
  2191. + case AR71XX_SOC_AR7161:
  2192. + ar71xx_gpio_chip.ngpio = AR71XX_GPIO_COUNT;
  2193. + break;
  2194. +
  2195. + case AR71XX_SOC_AR7240:
  2196. + case AR71XX_SOC_AR7241:
  2197. + case AR71XX_SOC_AR7242:
  2198. + ar71xx_gpio_chip.ngpio = AR724X_GPIO_COUNT;
  2199. + break;
  2200. +
  2201. + case AR71XX_SOC_AR9130:
  2202. + case AR71XX_SOC_AR9132:
  2203. + ar71xx_gpio_chip.ngpio = AR91XX_GPIO_COUNT;
  2204. + break;
  2205. +
  2206. + default:
  2207. + BUG();
  2208. + }
  2209. +
  2210. + err = gpiochip_add(&ar71xx_gpio_chip);
  2211. + if (err)
  2212. + panic("cannot add AR71xx GPIO chip, error=%d", err);
  2213. +}
  2214. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/irq.c linux-2.6.35.7/arch/mips/ar71xx/irq.c
  2215. --- linux-2.6.35.7.orig/arch/mips/ar71xx/irq.c 1970-01-01 01:00:00.000000000 +0100
  2216. +++ linux-2.6.35.7/arch/mips/ar71xx/irq.c 2010-10-14 20:27:57.135484452 +0200
  2217. @@ -0,0 +1,295 @@
  2218. +/*
  2219. + * Atheros AR71xx SoC specific interrupt handling
  2220. + *
  2221. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  2222. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  2223. + *
  2224. + * Parts of this file are based on Atheros' 2.6.15 BSP
  2225. + *
  2226. + * This program is free software; you can redistribute it and/or modify it
  2227. + * under the terms of the GNU General Public License version 2 as published
  2228. + * by the Free Software Foundation.
  2229. + */
  2230. +
  2231. +#include <linux/kernel.h>
  2232. +#include <linux/init.h>
  2233. +#include <linux/interrupt.h>
  2234. +#include <linux/irq.h>
  2235. +
  2236. +#include <asm/irq_cpu.h>
  2237. +#include <asm/mipsregs.h>
  2238. +
  2239. +#include <asm/mach-ar71xx/ar71xx.h>
  2240. +
  2241. +static int ip2_flush_reg;
  2242. +
  2243. +static void ar71xx_gpio_irq_dispatch(void)
  2244. +{
  2245. + void __iomem *base = ar71xx_gpio_base;
  2246. + u32 pending;
  2247. +
  2248. + pending = __raw_readl(base + GPIO_REG_INT_PENDING) &
  2249. + __raw_readl(base + GPIO_REG_INT_ENABLE);
  2250. +
  2251. + if (pending)
  2252. + do_IRQ(AR71XX_GPIO_IRQ_BASE + fls(pending) - 1);
  2253. + else
  2254. + spurious_interrupt();
  2255. +}
  2256. +
  2257. +static void ar71xx_gpio_irq_unmask(unsigned int irq)
  2258. +{
  2259. + void __iomem *base = ar71xx_gpio_base;
  2260. + u32 t;
  2261. +
  2262. + irq -= AR71XX_GPIO_IRQ_BASE;
  2263. +
  2264. + t = __raw_readl(base + GPIO_REG_INT_ENABLE);
  2265. + __raw_writel(t | (1 << irq), base + GPIO_REG_INT_ENABLE);
  2266. +
  2267. + /* flush write */
  2268. + (void) __raw_readl(base + GPIO_REG_INT_ENABLE);
  2269. +}
  2270. +
  2271. +static void ar71xx_gpio_irq_mask(unsigned int irq)
  2272. +{
  2273. + void __iomem *base = ar71xx_gpio_base;
  2274. + u32 t;
  2275. +
  2276. + irq -= AR71XX_GPIO_IRQ_BASE;
  2277. +
  2278. + t = __raw_readl(base + GPIO_REG_INT_ENABLE);
  2279. + __raw_writel(t & ~(1 << irq), base + GPIO_REG_INT_ENABLE);
  2280. +
  2281. + /* flush write */
  2282. + (void) __raw_readl(base + GPIO_REG_INT_ENABLE);
  2283. +}
  2284. +
  2285. +#if 0
  2286. +static int ar71xx_gpio_irq_set_type(unsigned int irq, unsigned int flow_type)
  2287. +{
  2288. + /* TODO: implement */
  2289. + return 0;
  2290. +}
  2291. +#else
  2292. +#define ar71xx_gpio_irq_set_type NULL
  2293. +#endif
  2294. +
  2295. +static struct irq_chip ar71xx_gpio_irq_chip = {
  2296. + .name = "AR71XX GPIO",
  2297. + .unmask = ar71xx_gpio_irq_unmask,
  2298. + .mask = ar71xx_gpio_irq_mask,
  2299. + .mask_ack = ar71xx_gpio_irq_mask,
  2300. + .set_type = ar71xx_gpio_irq_set_type,
  2301. +};
  2302. +
  2303. +static struct irqaction ar71xx_gpio_irqaction = {
  2304. + .handler = no_action,
  2305. + .name = "cascade [AR71XX GPIO]",
  2306. +};
  2307. +
  2308. +#define GPIO_IRQ_INIT_STATUS (IRQ_LEVEL | IRQ_TYPE_LEVEL_HIGH | IRQ_DISABLED)
  2309. +#define GPIO_INT_ALL 0xffff
  2310. +
  2311. +static void __init ar71xx_gpio_irq_init(void)
  2312. +{
  2313. + void __iomem *base = ar71xx_gpio_base;
  2314. + int i;
  2315. +
  2316. + __raw_writel(0, base + GPIO_REG_INT_ENABLE);
  2317. + __raw_writel(0, base + GPIO_REG_INT_PENDING);
  2318. +
  2319. + /* setup type of all GPIO interrupts to level sensitive */
  2320. + __raw_writel(GPIO_INT_ALL, base + GPIO_REG_INT_TYPE);
  2321. +
  2322. + /* setup polarity of all GPIO interrupts to active high */
  2323. + __raw_writel(GPIO_INT_ALL, base + GPIO_REG_INT_POLARITY);
  2324. +
  2325. + for (i = AR71XX_GPIO_IRQ_BASE;
  2326. + i < AR71XX_GPIO_IRQ_BASE + AR71XX_GPIO_IRQ_COUNT; i++) {
  2327. + irq_desc[i].status = GPIO_IRQ_INIT_STATUS;
  2328. + set_irq_chip_and_handler(i, &ar71xx_gpio_irq_chip,
  2329. + handle_level_irq);
  2330. + }
  2331. +
  2332. + setup_irq(AR71XX_MISC_IRQ_GPIO, &ar71xx_gpio_irqaction);
  2333. +}
  2334. +
  2335. +static void ar71xx_misc_irq_dispatch(void)
  2336. +{
  2337. + u32 pending;
  2338. +
  2339. + pending = ar71xx_reset_rr(AR71XX_RESET_REG_MISC_INT_STATUS)
  2340. + & ar71xx_reset_rr(AR71XX_RESET_REG_MISC_INT_ENABLE);
  2341. +
  2342. + if (pending & MISC_INT_UART)
  2343. + do_IRQ(AR71XX_MISC_IRQ_UART);
  2344. +
  2345. + else if (pending & MISC_INT_DMA)
  2346. + do_IRQ(AR71XX_MISC_IRQ_DMA);
  2347. +
  2348. + else if (pending & MISC_INT_PERFC)
  2349. + do_IRQ(AR71XX_MISC_IRQ_PERFC);
  2350. +
  2351. + else if (pending & MISC_INT_TIMER)
  2352. + do_IRQ(AR71XX_MISC_IRQ_TIMER);
  2353. +
  2354. + else if (pending & MISC_INT_OHCI)
  2355. + do_IRQ(AR71XX_MISC_IRQ_OHCI);
  2356. +
  2357. + else if (pending & MISC_INT_ERROR)
  2358. + do_IRQ(AR71XX_MISC_IRQ_ERROR);
  2359. +
  2360. + else if (pending & MISC_INT_GPIO)
  2361. + ar71xx_gpio_irq_dispatch();
  2362. +
  2363. + else if (pending & MISC_INT_WDOG)
  2364. + do_IRQ(AR71XX_MISC_IRQ_WDOG);
  2365. +
  2366. + else
  2367. + spurious_interrupt();
  2368. +}
  2369. +
  2370. +static void ar71xx_misc_irq_unmask(unsigned int irq)
  2371. +{
  2372. + void __iomem *base = ar71xx_reset_base;
  2373. + u32 t;
  2374. +
  2375. + irq -= AR71XX_MISC_IRQ_BASE;
  2376. +
  2377. + t = __raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
  2378. + __raw_writel(t | (1 << irq), base + AR71XX_RESET_REG_MISC_INT_ENABLE);
  2379. +
  2380. + /* flush write */
  2381. + (void) __raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
  2382. +}
  2383. +
  2384. +static void ar71xx_misc_irq_mask(unsigned int irq)
  2385. +{
  2386. + void __iomem *base = ar71xx_reset_base;
  2387. + u32 t;
  2388. +
  2389. + irq -= AR71XX_MISC_IRQ_BASE;
  2390. +
  2391. + t = __raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
  2392. + __raw_writel(t & ~(1 << irq), base + AR71XX_RESET_REG_MISC_INT_ENABLE);
  2393. +
  2394. + /* flush write */
  2395. + (void) __raw_readl(base + AR71XX_RESET_REG_MISC_INT_ENABLE);
  2396. +}
  2397. +
  2398. +static void ar724x_misc_irq_ack(unsigned int irq)
  2399. +{
  2400. + void __iomem *base = ar71xx_reset_base;
  2401. + u32 t;
  2402. +
  2403. + irq -= AR71XX_MISC_IRQ_BASE;
  2404. +
  2405. + t = __raw_readl(base + AR71XX_RESET_REG_MISC_INT_STATUS);
  2406. + __raw_writel(t & ~(1 << irq), base + AR71XX_RESET_REG_MISC_INT_STATUS);
  2407. +
  2408. + /* flush write */
  2409. + (void) __raw_readl(base + AR71XX_RESET_REG_MISC_INT_STATUS);
  2410. +}
  2411. +
  2412. +static struct irq_chip ar71xx_misc_irq_chip = {
  2413. + .name = "AR71XX MISC",
  2414. + .unmask = ar71xx_misc_irq_unmask,
  2415. + .mask = ar71xx_misc_irq_mask,
  2416. +};
  2417. +
  2418. +static struct irqaction ar71xx_misc_irqaction = {
  2419. + .handler = no_action,
  2420. + .name = "cascade [AR71XX MISC]",
  2421. +};
  2422. +
  2423. +static void __init ar71xx_misc_irq_init(void)
  2424. +{
  2425. + void __iomem *base = ar71xx_reset_base;
  2426. + int i;
  2427. +
  2428. + __raw_writel(0, base + AR71XX_RESET_REG_MISC_INT_ENABLE);
  2429. + __raw_writel(0, base + AR71XX_RESET_REG_MISC_INT_STATUS);
  2430. +
  2431. + switch (ar71xx_soc) {
  2432. + case AR71XX_SOC_AR7240:
  2433. + case AR71XX_SOC_AR7241:
  2434. + case AR71XX_SOC_AR7242:
  2435. + ar71xx_misc_irq_chip.ack = ar724x_misc_irq_ack;
  2436. + break;
  2437. + default:
  2438. + ar71xx_misc_irq_chip.mask_ack = ar71xx_misc_irq_mask;
  2439. + break;
  2440. + }
  2441. +
  2442. + for (i = AR71XX_MISC_IRQ_BASE;
  2443. + i < AR71XX_MISC_IRQ_BASE + AR71XX_MISC_IRQ_COUNT; i++) {
  2444. + irq_desc[i].status = IRQ_DISABLED;
  2445. + set_irq_chip_and_handler(i, &ar71xx_misc_irq_chip,
  2446. + handle_level_irq);
  2447. + }
  2448. +
  2449. + setup_irq(AR71XX_CPU_IRQ_MISC, &ar71xx_misc_irqaction);
  2450. +}
  2451. +
  2452. +asmlinkage void plat_irq_dispatch(void)
  2453. +{
  2454. + unsigned long pending;
  2455. +
  2456. + pending = read_c0_status() & read_c0_cause() & ST0_IM;
  2457. +
  2458. + if (pending & STATUSF_IP7)
  2459. + do_IRQ(AR71XX_CPU_IRQ_TIMER);
  2460. +
  2461. + else if (pending & STATUSF_IP2) {
  2462. + /*
  2463. + * This IRQ is meant for a PCI device. Drivers for PCI devices
  2464. + * typically allocate coherent DMA memory for the descriptor
  2465. + * ring, however the DMA controller may still have some
  2466. + * unsynchronized data in the FIFO.
  2467. + * Issue a flush here to ensure that the driver sees the update.
  2468. + */
  2469. + ar71xx_ddr_flush(ip2_flush_reg);
  2470. + do_IRQ(AR71XX_CPU_IRQ_IP2);
  2471. + }
  2472. +
  2473. + else if (pending & STATUSF_IP4)
  2474. + do_IRQ(AR71XX_CPU_IRQ_GE0);
  2475. +
  2476. + else if (pending & STATUSF_IP5)
  2477. + do_IRQ(AR71XX_CPU_IRQ_GE1);
  2478. +
  2479. + else if (pending & STATUSF_IP3)
  2480. + do_IRQ(AR71XX_CPU_IRQ_USB);
  2481. +
  2482. + else if (pending & STATUSF_IP6)
  2483. + ar71xx_misc_irq_dispatch();
  2484. +
  2485. + else
  2486. + spurious_interrupt();
  2487. +}
  2488. +
  2489. +void __init arch_init_irq(void)
  2490. +{
  2491. + switch(ar71xx_soc) {
  2492. + case AR71XX_SOC_AR7240:
  2493. + case AR71XX_SOC_AR7241:
  2494. + case AR71XX_SOC_AR7242:
  2495. + ip2_flush_reg = AR724X_DDR_REG_FLUSH_PCIE;
  2496. + break;
  2497. + case AR71XX_SOC_AR9130:
  2498. + case AR71XX_SOC_AR9132:
  2499. + ip2_flush_reg = AR91XX_DDR_REG_FLUSH_WMAC;
  2500. + break;
  2501. + default:
  2502. + ip2_flush_reg = AR71XX_DDR_REG_FLUSH_PCI;
  2503. + break;
  2504. + }
  2505. + mips_cpu_irq_init();
  2506. +
  2507. + ar71xx_misc_irq_init();
  2508. +
  2509. + cp0_perfcount_irq = AR71XX_MISC_IRQ_PERFC;
  2510. +
  2511. + ar71xx_gpio_irq_init();
  2512. +}
  2513. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/Kconfig linux-2.6.35.7/arch/mips/ar71xx/Kconfig
  2514. --- linux-2.6.35.7.orig/arch/mips/ar71xx/Kconfig 1970-01-01 01:00:00.000000000 +0100
  2515. +++ linux-2.6.35.7/arch/mips/ar71xx/Kconfig 2010-10-14 20:27:57.185337757 +0200
  2516. @@ -0,0 +1,264 @@
  2517. +if ATHEROS_AR71XX
  2518. +
  2519. +menu "Atheros AR71xx machine selection"
  2520. +
  2521. +config AR71XX_MACH_AP81
  2522. + bool "Atheros AP81 board support"
  2523. + select AR71XX_DEV_M25P80
  2524. + select AR71XX_DEV_AR913X_WMAC
  2525. + select AR71XX_DEV_GPIO_BUTTONS
  2526. + select AR71XX_DEV_LEDS_GPIO
  2527. + select AR71XX_DEV_USB
  2528. + default n
  2529. +
  2530. +config AR71XX_MACH_AP83
  2531. + bool "Atheros AP83 board support"
  2532. + select AR71XX_DEV_AR913X_WMAC
  2533. + select AR71XX_DEV_GPIO_BUTTONS
  2534. + select AR71XX_DEV_LEDS_GPIO
  2535. + select AR71XX_DEV_USB
  2536. + default n
  2537. +
  2538. +config AR71XX_MACH_DIR_600_A1
  2539. + bool "D-Link DIR-600 rev. A1 support"
  2540. + select AR71XX_DEV_AP91_ETH
  2541. + select AR71XX_DEV_AP91_PCI if PCI
  2542. + select AR71XX_DEV_M25P80
  2543. + select AR71XX_DEV_GPIO_BUTTONS
  2544. + select AR71XX_DEV_LEDS_GPIO
  2545. + select AR71XX_NVRAM
  2546. + default n
  2547. +
  2548. +config AR71XX_MACH_DIR_615_C1
  2549. + bool "D-Link DIR-615 rev. C1 support"
  2550. + select AR71XX_DEV_M25P80
  2551. + select AR71XX_DEV_AR913X_WMAC
  2552. + select AR71XX_DEV_GPIO_BUTTONS
  2553. + select AR71XX_DEV_LEDS_GPIO
  2554. + select AR71XX_NVRAM
  2555. + default n
  2556. +
  2557. +config AR71XX_MACH_DIR_825_B1
  2558. + bool "D-Link DIR-825 rev. B1 board support"
  2559. + select AR71XX_DEV_M25P80
  2560. + select AR71XX_DEV_AP94_PCI if PCI
  2561. + select AR71XX_DEV_GPIO_BUTTONS
  2562. + select AR71XX_DEV_LEDS_GPIO
  2563. + select AR71XX_DEV_USB
  2564. + default n
  2565. +
  2566. +config AR71XX_MACH_PB42
  2567. + bool "Atheros PB42 board support"
  2568. + select AR71XX_DEV_M25P80
  2569. + select AR71XX_DEV_GPIO_BUTTONS
  2570. + select AR71XX_DEV_PB42_PCI if PCI
  2571. + default n
  2572. +
  2573. +config AR71XX_MACH_PB44
  2574. + bool "Atheros PB44 board support"
  2575. + select AR71XX_DEV_GPIO_BUTTONS
  2576. + select AR71XX_DEV_PB42_PCI if PCI
  2577. + select AR71XX_DEV_LEDS_GPIO
  2578. + select AR71XX_DEV_USB
  2579. + default n
  2580. +
  2581. +config AR71XX_MACH_PB92
  2582. + bool "Atheros PB92 board support"
  2583. + select AR71XX_DEV_GPIO_BUTTONS
  2584. + select AR71XX_DEV_PB9X_PCI if PCI
  2585. + select AR71XX_DEV_LEDS_GPIO
  2586. + select AR71XX_DEV_USB
  2587. + default n
  2588. +
  2589. +config AR71XX_MACH_AW_NR580
  2590. + bool "AzureWave AW-NR580 board support"
  2591. + select AR71XX_DEV_M25P80
  2592. + select AR71XX_DEV_GPIO_BUTTONS
  2593. + select AR71XX_DEV_PB42_PCI if PCI
  2594. + select AR71XX_DEV_LEDS_GPIO
  2595. + default n
  2596. +
  2597. +config AR71XX_MACH_WZR_HP_G300NH
  2598. + bool "Buffalo WZR-HP-G300NH board support"
  2599. + select AR71XX_DEV_AR913X_WMAC
  2600. + select AR71XX_DEV_GPIO_BUTTONS
  2601. + select AR71XX_DEV_LEDS_GPIO
  2602. + select AR71XX_DEV_USB
  2603. + default y
  2604. +
  2605. +config AR71XX_MACH_WP543
  2606. + bool "Compex WP543/WPJ543 board support"
  2607. + select MYLOADER
  2608. + select AR71XX_DEV_M25P80
  2609. + select AR71XX_DEV_GPIO_BUTTONS
  2610. + select AR71XX_DEV_PB42_PCI if PCI
  2611. + select AR71XX_DEV_LEDS_GPIO
  2612. + select AR71XX_DEV_USB
  2613. + default n
  2614. +
  2615. +config AR71XX_MACH_WRT160NL
  2616. + bool "Linksys WRT160NL board support"
  2617. + select AR71XX_DEV_M25P80
  2618. + select AR71XX_DEV_AR913X_WMAC
  2619. + select AR71XX_DEV_GPIO_BUTTONS
  2620. + select AR71XX_DEV_LEDS_GPIO
  2621. + select AR71XX_DEV_USB
  2622. + select AR71XX_NVRAM
  2623. + default n
  2624. +
  2625. +config AR71XX_MACH_WRT400N
  2626. + bool "Linksys WRT400N board support"
  2627. + select AR71XX_DEV_AP94_PCI if PCI
  2628. + select AR71XX_DEV_M25P80
  2629. + select AR71XX_DEV_GPIO_BUTTONS
  2630. + select AR71XX_DEV_LEDS_GPIO
  2631. + default n
  2632. +
  2633. +config AR71XX_MACH_RB4XX
  2634. + bool "MikroTik RouterBOARD 4xx series support"
  2635. + select AR71XX_DEV_GPIO_BUTTONS
  2636. + select AR71XX_DEV_LEDS_GPIO
  2637. + select AR71XX_DEV_USB
  2638. + default n
  2639. +
  2640. +config AR71XX_MACH_RB750
  2641. + bool "MikroTik RouterBOARD 750 support"
  2642. + select AR71XX_DEV_AP91_ETH
  2643. + default n
  2644. +
  2645. +config AR71XX_MACH_WNDR3700
  2646. + bool "NETGEAR WNDR3700 board support"
  2647. + select AR71XX_DEV_M25P80
  2648. + select AR71XX_DEV_AP94_PCI if PCI
  2649. + select AR71XX_DEV_GPIO_BUTTONS
  2650. + select AR71XX_DEV_LEDS_GPIO
  2651. + select AR71XX_DEV_USB
  2652. + default n
  2653. +
  2654. +config AR71XX_MACH_WNR2000
  2655. + bool "NETGEAR WNR2000 board support"
  2656. + select AR71XX_DEV_M25P80
  2657. + select AR71XX_DEV_AR913X_WMAC
  2658. + select AR71XX_DEV_GPIO_BUTTONS
  2659. + select AR71XX_DEV_LEDS_GPIO
  2660. + default n
  2661. +
  2662. +config AR71XX_MACH_MZK_W04NU
  2663. + bool "Planex MZK-W04NU board support"
  2664. + select AR71XX_DEV_M25P80
  2665. + select AR71XX_DEV_AR913X_WMAC
  2666. + select AR71XX_DEV_GPIO_BUTTONS
  2667. + select AR71XX_DEV_LEDS_GPIO
  2668. + select AR71XX_DEV_USB
  2669. + default n
  2670. +
  2671. +config AR71XX_MACH_MZK_W300NH
  2672. + bool "Planex MZK-W300NH board support"
  2673. + select AR71XX_DEV_M25P80
  2674. + select AR71XX_DEV_AR913X_WMAC
  2675. + select AR71XX_DEV_GPIO_BUTTONS
  2676. + select AR71XX_DEV_LEDS_GPIO
  2677. + default n
  2678. +
  2679. +config AR71XX_MACH_NBG460N
  2680. + bool "Zyxel NBG460N/550N/550NH board support"
  2681. + select AR71XX_DEV_M25P80
  2682. + select AR71XX_DEV_AR913X_WMAC
  2683. + select AR71XX_DEV_GPIO_BUTTONS
  2684. + select AR71XX_DEV_LEDS_GPIO
  2685. + default n
  2686. +
  2687. +config AR71XX_MACH_TL_WR741ND
  2688. + bool "TP-LINK TL-WR741ND support"
  2689. + select AR71XX_DEV_M25P80
  2690. + select AR71XX_DEV_AP91_ETH
  2691. + select AR71XX_DEV_AP91_PCI if PCI
  2692. + select AR71XX_DEV_GPIO_BUTTONS
  2693. + select AR71XX_DEV_LEDS_GPIO
  2694. + default n
  2695. +
  2696. +config AR71XX_MACH_TL_WR841N_V1
  2697. + bool "TP-LINK TL-WR841N v1 support"
  2698. + select AR71XX_DEV_M25P80
  2699. + select AR71XX_DEV_PB42_PCI if PCI
  2700. + select AR71XX_DEV_DSA
  2701. + select AR71XX_DEV_GPIO_BUTTONS
  2702. + select AR71XX_DEV_LEDS_GPIO
  2703. + default n
  2704. +
  2705. +config AR71XX_MACH_TL_WR941ND
  2706. + bool "TP-LINK TL-WR941ND support"
  2707. + select AR71XX_DEV_M25P80
  2708. + select AR71XX_DEV_AR913X_WMAC
  2709. + select AR71XX_DEV_DSA
  2710. + select AR71XX_DEV_GPIO_BUTTONS
  2711. + select AR71XX_DEV_LEDS_GPIO
  2712. + default n
  2713. +
  2714. +config AR71XX_MACH_TL_WR1043ND
  2715. + bool "TP-LINK TL-WR1043ND support"
  2716. + select AR71XX_DEV_M25P80
  2717. + select AR71XX_DEV_AR913X_WMAC
  2718. + select AR71XX_DEV_GPIO_BUTTONS
  2719. + select AR71XX_DEV_LEDS_GPIO
  2720. + select AR71XX_DEV_USB
  2721. + default n
  2722. +
  2723. +config AR71XX_MACH_TEW_632BRP
  2724. + bool "TRENDnet TEW-632BRP support"
  2725. + select AR71XX_DEV_M25P80
  2726. + select AR71XX_DEV_AR913X_WMAC
  2727. + select AR71XX_DEV_GPIO_BUTTONS
  2728. + select AR71XX_DEV_LEDS_GPIO
  2729. + select AR71XX_NVRAM
  2730. + default n
  2731. +
  2732. +config AR71XX_MACH_UBNT
  2733. + bool "Ubiquiti AR71xx based boards support"
  2734. + select AR71XX_DEV_M25P80
  2735. + select AR71XX_DEV_AP91_PCI if PCI
  2736. + select AR71XX_DEV_GPIO_BUTTONS
  2737. + select AR71XX_DEV_LEDS_GPIO
  2738. + select AR71XX_DEV_PB42_PCI if PCI
  2739. + select AR71XX_DEV_USB
  2740. + default n
  2741. +
  2742. +endmenu
  2743. +
  2744. +config AR71XX_DEV_M25P80
  2745. + def_bool n
  2746. +
  2747. +config AR71XX_DEV_AP91_PCI
  2748. + def_bool n
  2749. +
  2750. +config AR71XX_DEV_AP91_ETH
  2751. + def_bool n
  2752. +
  2753. +config AR71XX_DEV_AP94_PCI
  2754. + def_bool n
  2755. +
  2756. +config AR71XX_DEV_AR913X_WMAC
  2757. + def_bool n
  2758. +
  2759. +config AR71XX_DEV_DSA
  2760. + def_bool n
  2761. +
  2762. +config AR71XX_DEV_GPIO_BUTTONS
  2763. + def_bool n
  2764. +
  2765. +config AR71XX_DEV_LEDS_GPIO
  2766. + def_bool n
  2767. +
  2768. +config AR71XX_DEV_PB42_PCI
  2769. + def_bool n
  2770. +
  2771. +config AR71XX_DEV_PB9X_PCI
  2772. + def_bool n
  2773. +
  2774. +config AR71XX_DEV_USB
  2775. + def_bool n
  2776. +
  2777. +config AR71XX_NVRAM
  2778. + def_bool n
  2779. +
  2780. +endif
  2781. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-ap81.c linux-2.6.35.7/arch/mips/ar71xx/mach-ap81.c
  2782. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-ap81.c 1970-01-01 01:00:00.000000000 +0100
  2783. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-ap81.c 2010-10-14 20:27:57.235141599 +0200
  2784. @@ -0,0 +1,140 @@
  2785. +/*
  2786. + * Atheros AP81 board support
  2787. + *
  2788. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  2789. + * Copyright (C) 2009 Imre Kaloz <kaloz@openwrt.org>
  2790. + *
  2791. + * This program is free software; you can redistribute it and/or modify it
  2792. + * under the terms of the GNU General Public License version 2 as published
  2793. + * by the Free Software Foundation.
  2794. + */
  2795. +
  2796. +#include <linux/mtd/mtd.h>
  2797. +#include <linux/mtd/partitions.h>
  2798. +
  2799. +#include <asm/mach-ar71xx/ar71xx.h>
  2800. +
  2801. +#include "machtype.h"
  2802. +#include "devices.h"
  2803. +#include "dev-m25p80.h"
  2804. +#include "dev-ar913x-wmac.h"
  2805. +#include "dev-gpio-buttons.h"
  2806. +#include "dev-leds-gpio.h"
  2807. +#include "dev-usb.h"
  2808. +
  2809. +#define AP81_GPIO_LED_STATUS 1
  2810. +#define AP81_GPIO_LED_AOSS 3
  2811. +#define AP81_GPIO_LED_WLAN 6
  2812. +#define AP81_GPIO_LED_POWER 14
  2813. +
  2814. +#define AP81_GPIO_BTN_SW4 12
  2815. +#define AP81_GPIO_BTN_SW1 21
  2816. +
  2817. +#define AP81_BUTTONS_POLL_INTERVAL 20
  2818. +
  2819. +#ifdef CONFIG_MTD_PARTITIONS
  2820. +static struct mtd_partition ap81_partitions[] = {
  2821. + {
  2822. + .name = "u-boot",
  2823. + .offset = 0,
  2824. + .size = 0x040000,
  2825. + .mask_flags = MTD_WRITEABLE,
  2826. + } , {
  2827. + .name = "u-boot-env",
  2828. + .offset = 0x040000,
  2829. + .size = 0x010000,
  2830. + } , {
  2831. + .name = "rootfs",
  2832. + .offset = 0x050000,
  2833. + .size = 0x500000,
  2834. + } , {
  2835. + .name = "uImage",
  2836. + .offset = 0x550000,
  2837. + .size = 0x100000,
  2838. + } , {
  2839. + .name = "ART",
  2840. + .offset = 0x650000,
  2841. + .size = 0x1b0000,
  2842. + .mask_flags = MTD_WRITEABLE,
  2843. + }
  2844. +};
  2845. +#endif /* CONFIG_MTD_PARTITIONS */
  2846. +
  2847. +static struct flash_platform_data ap81_flash_data = {
  2848. +#ifdef CONFIG_MTD_PARTITIONS
  2849. + .parts = ap81_partitions,
  2850. + .nr_parts = ARRAY_SIZE(ap81_partitions),
  2851. +#endif
  2852. +};
  2853. +
  2854. +static struct gpio_led ap81_leds_gpio[] __initdata = {
  2855. + {
  2856. + .name = "ap81:green:status",
  2857. + .gpio = AP81_GPIO_LED_STATUS,
  2858. + .active_low = 1,
  2859. + }, {
  2860. + .name = "ap81:amber:aoss",
  2861. + .gpio = AP81_GPIO_LED_AOSS,
  2862. + .active_low = 1,
  2863. + }, {
  2864. + .name = "ap81:green:wlan",
  2865. + .gpio = AP81_GPIO_LED_WLAN,
  2866. + .active_low = 1,
  2867. + }, {
  2868. + .name = "ap81:green:power",
  2869. + .gpio = AP81_GPIO_LED_POWER,
  2870. + .active_low = 1,
  2871. + }
  2872. +};
  2873. +
  2874. +static struct gpio_button ap81_gpio_buttons[] __initdata = {
  2875. + {
  2876. + .desc = "sw1",
  2877. + .type = EV_KEY,
  2878. + .code = BTN_0,
  2879. + .threshold = 3,
  2880. + .gpio = AP81_GPIO_BTN_SW1,
  2881. + .active_low = 1,
  2882. + } , {
  2883. + .desc = "sw4",
  2884. + .type = EV_KEY,
  2885. + .code = BTN_1,
  2886. + .threshold = 3,
  2887. + .gpio = AP81_GPIO_BTN_SW4,
  2888. + .active_low = 1,
  2889. + }
  2890. +};
  2891. +
  2892. +static void __init ap81_setup(void)
  2893. +{
  2894. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  2895. +
  2896. + ar71xx_set_mac_base(eeprom);
  2897. + ar71xx_add_device_mdio(0x0);
  2898. +
  2899. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  2900. + ar71xx_eth0_data.speed = SPEED_100;
  2901. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  2902. + ar71xx_eth0_data.has_ar8216 = 1;
  2903. +
  2904. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  2905. + ar71xx_eth1_data.phy_mask = 0x10;
  2906. +
  2907. + ar71xx_add_device_eth(0);
  2908. + ar71xx_add_device_eth(1);
  2909. +
  2910. + ar71xx_add_device_usb();
  2911. +
  2912. + ar71xx_add_device_m25p80(&ap81_flash_data);
  2913. +
  2914. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap81_leds_gpio),
  2915. + ap81_leds_gpio);
  2916. +
  2917. + ar71xx_add_device_gpio_buttons(-1, AP81_BUTTONS_POLL_INTERVAL,
  2918. + ARRAY_SIZE(ap81_gpio_buttons),
  2919. + ap81_gpio_buttons);
  2920. +
  2921. + ar913x_add_device_wmac(eeprom, NULL);
  2922. +}
  2923. +
  2924. +MIPS_MACHINE(AR71XX_MACH_AP81, "AP81", "Atheros AP81", ap81_setup);
  2925. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-ap83.c linux-2.6.35.7/arch/mips/ar71xx/mach-ap83.c
  2926. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-ap83.c 1970-01-01 01:00:00.000000000 +0100
  2927. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-ap83.c 2010-10-14 20:27:57.284350521 +0200
  2928. @@ -0,0 +1,266 @@
  2929. +/*
  2930. + * Atheros AP83 board support
  2931. + *
  2932. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  2933. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  2934. + *
  2935. + * This program is free software; you can redistribute it and/or modify it
  2936. + * under the terms of the GNU General Public License version 2 as published
  2937. + * by the Free Software Foundation.
  2938. + */
  2939. +
  2940. +#include <linux/delay.h>
  2941. +#include <linux/platform_device.h>
  2942. +#include <linux/mtd/mtd.h>
  2943. +#include <linux/mtd/partitions.h>
  2944. +#include <linux/spi/spi.h>
  2945. +#include <linux/spi/spi_gpio.h>
  2946. +#include <linux/spi/vsc7385.h>
  2947. +
  2948. +#include <asm/mach-ar71xx/ar71xx.h>
  2949. +#include <asm/mach-ar71xx/ar91xx_flash.h>
  2950. +
  2951. +#include "machtype.h"
  2952. +#include "devices.h"
  2953. +#include "dev-ar913x-wmac.h"
  2954. +#include "dev-gpio-buttons.h"
  2955. +#include "dev-leds-gpio.h"
  2956. +#include "dev-usb.h"
  2957. +
  2958. +#define AP83_GPIO_LED_WLAN 6
  2959. +#define AP83_GPIO_LED_POWER 14
  2960. +#define AP83_GPIO_LED_JUMPSTART 15
  2961. +#define AP83_GPIO_BTN_JUMPSTART 12
  2962. +#define AP83_GPIO_BTN_RESET 21
  2963. +
  2964. +#define AP83_050_GPIO_VSC7385_CS 1
  2965. +#define AP83_050_GPIO_VSC7385_MISO 3
  2966. +#define AP83_050_GPIO_VSC7385_MOSI 16
  2967. +#define AP83_050_GPIO_VSC7385_SCK 17
  2968. +
  2969. +#define AP83_BUTTONS_POLL_INTERVAL 20
  2970. +
  2971. +#ifdef CONFIG_MTD_PARTITIONS
  2972. +static struct mtd_partition ap83_flash_partitions[] = {
  2973. + {
  2974. + .name = "u-boot",
  2975. + .offset = 0,
  2976. + .size = 0x040000,
  2977. + .mask_flags = MTD_WRITEABLE,
  2978. + } , {
  2979. + .name = "u-boot-env",
  2980. + .offset = 0x040000,
  2981. + .size = 0x020000,
  2982. + .mask_flags = MTD_WRITEABLE,
  2983. + } , {
  2984. + .name = "kernel",
  2985. + .offset = 0x060000,
  2986. + .size = 0x140000,
  2987. + } , {
  2988. + .name = "rootfs",
  2989. + .offset = 0x1a0000,
  2990. + .size = 0x650000,
  2991. + } , {
  2992. + .name = "art",
  2993. + .offset = 0x7f0000,
  2994. + .size = 0x010000,
  2995. + .mask_flags = MTD_WRITEABLE,
  2996. + } , {
  2997. + .name = "firmware",
  2998. + .offset = 0x060000,
  2999. + .size = 0x790000,
  3000. + }
  3001. +};
  3002. +#endif /* CONFIG_MTD_PARTITIONS */
  3003. +
  3004. +static struct ar91xx_flash_platform_data ap83_flash_data = {
  3005. + .width = 2,
  3006. +#ifdef CONFIG_MTD_PARTITIONS
  3007. + .parts = ap83_flash_partitions,
  3008. + .nr_parts = ARRAY_SIZE(ap83_flash_partitions),
  3009. +#endif
  3010. +};
  3011. +
  3012. +static struct resource ap83_flash_resources[] = {
  3013. + [0] = {
  3014. + .start = AR71XX_SPI_BASE,
  3015. + .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
  3016. + .flags = IORESOURCE_MEM,
  3017. + },
  3018. +};
  3019. +
  3020. +static struct platform_device ap83_flash_device = {
  3021. + .name = "ar91xx-flash",
  3022. + .id = -1,
  3023. + .resource = ap83_flash_resources,
  3024. + .num_resources = ARRAY_SIZE(ap83_flash_resources),
  3025. + .dev = {
  3026. + .platform_data = &ap83_flash_data,
  3027. + }
  3028. +};
  3029. +
  3030. +static struct gpio_led ap83_leds_gpio[] __initdata = {
  3031. + {
  3032. + .name = "ap83:green:jumpstart",
  3033. + .gpio = AP83_GPIO_LED_JUMPSTART,
  3034. + .active_low = 0,
  3035. + }, {
  3036. + .name = "ap83:green:power",
  3037. + .gpio = AP83_GPIO_LED_POWER,
  3038. + .active_low = 0,
  3039. + }, {
  3040. + .name = "ap83:green:wlan",
  3041. + .gpio = AP83_GPIO_LED_WLAN,
  3042. + .active_low = 0,
  3043. + },
  3044. +};
  3045. +
  3046. +static struct gpio_button ap83_gpio_buttons[] __initdata = {
  3047. + {
  3048. + .desc = "soft_reset",
  3049. + .type = EV_KEY,
  3050. + .code = KEY_RESTART,
  3051. + .threshold = 3,
  3052. + .gpio = AP83_GPIO_BTN_RESET,
  3053. + .active_low = 1,
  3054. + } , {
  3055. + .desc = "jumpstart",
  3056. + .type = EV_KEY,
  3057. + .code = KEY_WPS_BUTTON,
  3058. + .threshold = 3,
  3059. + .gpio = AP83_GPIO_BTN_JUMPSTART,
  3060. + .active_low = 1,
  3061. + }
  3062. +};
  3063. +
  3064. +static struct resource ap83_040_spi_resources[] = {
  3065. + [0] = {
  3066. + .start = AR71XX_SPI_BASE,
  3067. + .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
  3068. + .flags = IORESOURCE_MEM,
  3069. + },
  3070. +};
  3071. +
  3072. +static struct platform_device ap83_040_spi_device = {
  3073. + .name = "ap83-spi",
  3074. + .id = 0,
  3075. + .resource = ap83_040_spi_resources,
  3076. + .num_resources = ARRAY_SIZE(ap83_040_spi_resources),
  3077. +};
  3078. +
  3079. +static struct spi_gpio_platform_data ap83_050_spi_data = {
  3080. + .miso = AP83_050_GPIO_VSC7385_MISO,
  3081. + .mosi = AP83_050_GPIO_VSC7385_MOSI,
  3082. + .sck = AP83_050_GPIO_VSC7385_SCK,
  3083. + .num_chipselect = 1,
  3084. +};
  3085. +
  3086. +static struct platform_device ap83_050_spi_device = {
  3087. + .name = "spi_gpio",
  3088. + .id = 0,
  3089. + .dev = {
  3090. + .platform_data = &ap83_050_spi_data,
  3091. + }
  3092. +};
  3093. +
  3094. +static void ap83_vsc7385_reset(void)
  3095. +{
  3096. + ar71xx_device_stop(RESET_MODULE_GE1_PHY);
  3097. + udelay(10);
  3098. + ar71xx_device_start(RESET_MODULE_GE1_PHY);
  3099. + mdelay(50);
  3100. +}
  3101. +
  3102. +static struct vsc7385_platform_data ap83_vsc7385_data = {
  3103. + .reset = ap83_vsc7385_reset,
  3104. + .ucode_name = "vsc7385_ucode_ap83.bin",
  3105. + .mac_cfg = {
  3106. + .tx_ipg = 6,
  3107. + .bit2 = 0,
  3108. + .clk_sel = 3,
  3109. + },
  3110. +};
  3111. +
  3112. +static struct spi_board_info ap83_spi_info[] = {
  3113. + {
  3114. + .bus_num = 0,
  3115. + .chip_select = 0,
  3116. + .max_speed_hz = 25000000,
  3117. + .modalias = "spi-vsc7385",
  3118. + .platform_data = &ap83_vsc7385_data,
  3119. + .controller_data = (void *) AP83_050_GPIO_VSC7385_CS,
  3120. + }
  3121. +};
  3122. +
  3123. +static void __init ap83_generic_setup(void)
  3124. +{
  3125. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  3126. +
  3127. + ar71xx_set_mac_base(eeprom);
  3128. +
  3129. + ar71xx_add_device_mdio(0xfffffffe);
  3130. +
  3131. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  3132. + ar71xx_eth0_data.phy_mask = 0x1;
  3133. +
  3134. + ar71xx_add_device_eth(0);
  3135. +
  3136. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  3137. + ar71xx_eth1_data.speed = SPEED_1000;
  3138. + ar71xx_eth1_data.duplex = DUPLEX_FULL;
  3139. +
  3140. + ar71xx_eth1_pll_data.pll_1000 = 0x1f000000;
  3141. +
  3142. + ar71xx_add_device_eth(1);
  3143. +
  3144. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap83_leds_gpio),
  3145. + ap83_leds_gpio);
  3146. +
  3147. + ar71xx_add_device_gpio_buttons(-1, AP83_BUTTONS_POLL_INTERVAL,
  3148. + ARRAY_SIZE(ap83_gpio_buttons),
  3149. + ap83_gpio_buttons);
  3150. +
  3151. + ar71xx_add_device_usb();
  3152. +
  3153. + ar913x_add_device_wmac(eeprom, NULL);
  3154. +
  3155. + platform_device_register(&ap83_flash_device);
  3156. +
  3157. + spi_register_board_info(ap83_spi_info, ARRAY_SIZE(ap83_spi_info));
  3158. +}
  3159. +
  3160. +static void __init ap83_040_setup(void)
  3161. +{
  3162. + ap83_flash_data.is_shared=1;
  3163. + ap83_generic_setup();
  3164. + platform_device_register(&ap83_040_spi_device);
  3165. +}
  3166. +
  3167. +static void __init ap83_050_setup(void)
  3168. +{
  3169. + ap83_generic_setup();
  3170. + platform_device_register(&ap83_050_spi_device);
  3171. +}
  3172. +
  3173. +static void __init ap83_setup(void)
  3174. +{
  3175. + u8 *board_id = (u8 *) KSEG1ADDR(0x1fff1244);
  3176. + unsigned int board_version;
  3177. +
  3178. + board_version = (unsigned int)(board_id[0] - '0');
  3179. + board_version += ((unsigned int)(board_id[1] - '0')) * 10;
  3180. +
  3181. + switch (board_version) {
  3182. + case 40:
  3183. + ap83_040_setup();
  3184. + break;
  3185. + case 50:
  3186. + ap83_050_setup();
  3187. + break;
  3188. + default:
  3189. + printk(KERN_WARNING "AP83-%03u board is not yet supported\n",
  3190. + board_version);
  3191. + }
  3192. +}
  3193. +
  3194. +MIPS_MACHINE(AR71XX_MACH_AP83, "AP83", "Atheros AP83", ap83_setup);
  3195. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-aw-nr580.c linux-2.6.35.7/arch/mips/ar71xx/mach-aw-nr580.c
  3196. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-aw-nr580.c 1970-01-01 01:00:00.000000000 +0100
  3197. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-aw-nr580.c 2010-10-14 20:27:57.334787684 +0200
  3198. @@ -0,0 +1,101 @@
  3199. +/*
  3200. + * AzureWave AW-NR580 board support
  3201. + *
  3202. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  3203. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  3204. + *
  3205. + * This program is free software; you can redistribute it and/or modify it
  3206. + * under the terms of the GNU General Public License version 2 as published
  3207. + * by the Free Software Foundation.
  3208. + */
  3209. +
  3210. +#include <linux/mtd/mtd.h>
  3211. +#include <linux/mtd/partitions.h>
  3212. +
  3213. +#include <asm/mips_machine.h>
  3214. +#include <asm/mach-ar71xx/ar71xx.h>
  3215. +
  3216. +#include "machtype.h"
  3217. +#include "devices.h"
  3218. +#include "dev-m25p80.h"
  3219. +#include "dev-gpio-buttons.h"
  3220. +#include "dev-pb42-pci.h"
  3221. +#include "dev-leds-gpio.h"
  3222. +
  3223. +#define AW_NR580_GPIO_LED_READY_RED 0
  3224. +#define AW_NR580_GPIO_LED_WLAN 1
  3225. +#define AW_NR580_GPIO_LED_READY_GREEN 2
  3226. +#define AW_NR580_GPIO_LED_WPS_GREEN 4
  3227. +#define AW_NR580_GPIO_LED_WPS_AMBER 5
  3228. +
  3229. +#define AW_NR580_GPIO_BTN_WPS 3
  3230. +#define AW_NR580_GPIO_BTN_RESET 11
  3231. +
  3232. +#define AW_NR580_BUTTONS_POLL_INTERVAL 20
  3233. +
  3234. +static struct gpio_led aw_nr580_leds_gpio[] __initdata = {
  3235. + {
  3236. + .name = "aw-nr580:red:ready",
  3237. + .gpio = AW_NR580_GPIO_LED_READY_RED,
  3238. + .active_low = 0,
  3239. + }, {
  3240. + .name = "aw-nr580:green:ready",
  3241. + .gpio = AW_NR580_GPIO_LED_READY_GREEN,
  3242. + .active_low = 0,
  3243. + }, {
  3244. + .name = "aw-nr580:green:wps",
  3245. + .gpio = AW_NR580_GPIO_LED_WPS_GREEN,
  3246. + .active_low = 0,
  3247. + }, {
  3248. + .name = "aw-nr580:amber:wps",
  3249. + .gpio = AW_NR580_GPIO_LED_WPS_AMBER,
  3250. + .active_low = 0,
  3251. + }, {
  3252. + .name = "aw-nr580:green:wlan",
  3253. + .gpio = AW_NR580_GPIO_LED_WLAN,
  3254. + .active_low = 0,
  3255. + }
  3256. +};
  3257. +
  3258. +static struct gpio_button aw_nr580_gpio_buttons[] __initdata = {
  3259. + {
  3260. + .desc = "reset",
  3261. + .type = EV_KEY,
  3262. + .code = KEY_RESTART,
  3263. + .threshold = 3,
  3264. + .gpio = AW_NR580_GPIO_BTN_RESET,
  3265. + .active_low = 1,
  3266. + }, {
  3267. + .desc = "wps",
  3268. + .type = EV_KEY,
  3269. + .code = KEY_WPS_BUTTON,
  3270. + .threshold = 3,
  3271. + .gpio = AW_NR580_GPIO_BTN_WPS,
  3272. + .active_low = 1,
  3273. + }
  3274. +};
  3275. +
  3276. +static void __init aw_nr580_setup(void)
  3277. +{
  3278. + ar71xx_add_device_mdio(0x0);
  3279. +
  3280. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  3281. + ar71xx_eth0_data.speed = SPEED_100;
  3282. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  3283. +
  3284. + ar71xx_add_device_eth(0);
  3285. +
  3286. + pb42_pci_init();
  3287. +
  3288. + ar71xx_add_device_m25p80(NULL);
  3289. +
  3290. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(aw_nr580_leds_gpio),
  3291. + aw_nr580_leds_gpio);
  3292. +
  3293. + ar71xx_add_device_gpio_buttons(-1, AW_NR580_BUTTONS_POLL_INTERVAL,
  3294. + ARRAY_SIZE(aw_nr580_gpio_buttons),
  3295. + aw_nr580_gpio_buttons);
  3296. +}
  3297. +
  3298. +MIPS_MACHINE(AR71XX_MACH_AW_NR580, "AW-NR580", "AzureWave AW-NR580",
  3299. + aw_nr580_setup);
  3300. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-dir-600-a1.c linux-2.6.35.7/arch/mips/ar71xx/mach-dir-600-a1.c
  3301. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-dir-600-a1.c 1970-01-01 01:00:00.000000000 +0100
  3302. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-dir-600-a1.c 2010-10-14 20:27:57.384602615 +0200
  3303. @@ -0,0 +1,138 @@
  3304. +/*
  3305. + * D-Link DIR-600 rev. A1 board support
  3306. + *
  3307. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  3308. + *
  3309. + * This program is free software; you can redistribute it and/or modify it
  3310. + * under the terms of the GNU General Public License version 2 as published
  3311. + * by the Free Software Foundation.
  3312. + */
  3313. +
  3314. +#include <linux/mtd/mtd.h>
  3315. +#include <linux/mtd/partitions.h>
  3316. +
  3317. +#include <asm/mach-ar71xx/ar71xx.h>
  3318. +
  3319. +#include "machtype.h"
  3320. +#include "devices.h"
  3321. +#include "dev-m25p80.h"
  3322. +#include "dev-ap91-eth.h"
  3323. +#include "dev-ap91-pci.h"
  3324. +#include "dev-gpio-buttons.h"
  3325. +#include "dev-leds-gpio.h"
  3326. +#include "nvram.h"
  3327. +
  3328. +#define DIR_600_A1_GPIO_LED_WPS 0
  3329. +#define DIR_600_A1_GPIO_LED_POWER_AMBER 1
  3330. +#define DIR_600_A1_GPIO_LED_POWER_GREEN 6
  3331. +
  3332. +#define DIR_600_A1_GPIO_BTN_RESET 8
  3333. +#define DIR_600_A1_GPIO_BTN_WPS 12
  3334. +
  3335. +#define DIR_600_A1_BUTTONS_POLL_INTERVAL 20
  3336. +
  3337. +#define DIR_600_A1_NVRAM_ADDR 0x1f030000
  3338. +#define DIR_600_A1_NVRAM_SIZE 0x10000
  3339. +
  3340. +#ifdef CONFIG_MTD_PARTITIONS
  3341. +static struct mtd_partition dir_600_a1_partitions[] = {
  3342. + {
  3343. + .name = "u-boot",
  3344. + .offset = 0,
  3345. + .size = 0x030000,
  3346. + .mask_flags = MTD_WRITEABLE,
  3347. + }, {
  3348. + .name = "nvram",
  3349. + .offset = 0x030000,
  3350. + .size = 0x010000,
  3351. + }, {
  3352. + .name = "kernel",
  3353. + .offset = 0x040000,
  3354. + .size = 0x0e0000,
  3355. + }, {
  3356. + .name = "rootfs",
  3357. + .offset = 0x120000,
  3358. + .size = 0x2c0000,
  3359. + }, {
  3360. + .name = "mac",
  3361. + .offset = 0x3e0000,
  3362. + .size = 0x010000,
  3363. + .mask_flags = MTD_WRITEABLE,
  3364. + }, {
  3365. + .name = "art",
  3366. + .offset = 0x3f0000,
  3367. + .size = 0x010000,
  3368. + .mask_flags = MTD_WRITEABLE,
  3369. + }, {
  3370. + .name = "firmware",
  3371. + .offset = 0x040000,
  3372. + .size = 0x3a0000,
  3373. + }
  3374. +};
  3375. +#endif /* CONFIG_MTD_PARTITIONS */
  3376. +
  3377. +static struct flash_platform_data dir_600_a1_flash_data = {
  3378. +#ifdef CONFIG_MTD_PARTITIONS
  3379. + .parts = dir_600_a1_partitions,
  3380. + .nr_parts = ARRAY_SIZE(dir_600_a1_partitions),
  3381. +#endif
  3382. +};
  3383. +
  3384. +static struct gpio_led dir_600_a1_leds_gpio[] __initdata = {
  3385. + {
  3386. + .name = "dir-600-a1:green:power",
  3387. + .gpio = DIR_600_A1_GPIO_LED_POWER_GREEN,
  3388. + }, {
  3389. + .name = "dir-600-a1:amber:power",
  3390. + .gpio = DIR_600_A1_GPIO_LED_POWER_AMBER,
  3391. + }, {
  3392. + .name = "dir-600-a1:blue:wps",
  3393. + .gpio = DIR_600_A1_GPIO_LED_WPS,
  3394. + .active_low = 1,
  3395. + }
  3396. +};
  3397. +
  3398. +static struct gpio_button dir_600_a1_gpio_buttons[] __initdata = {
  3399. + {
  3400. + .desc = "reset",
  3401. + .type = EV_KEY,
  3402. + .code = KEY_RESTART,
  3403. + .threshold = 3,
  3404. + .gpio = DIR_600_A1_GPIO_BTN_RESET,
  3405. + .active_low = 1,
  3406. + }, {
  3407. + .desc = "wps",
  3408. + .type = EV_KEY,
  3409. + .code = KEY_WPS_BUTTON,
  3410. + .threshold = 3,
  3411. + .gpio = DIR_600_A1_GPIO_BTN_WPS,
  3412. + .active_low = 1,
  3413. + }
  3414. +};
  3415. +
  3416. +static void __init dir_600_a1_setup(void)
  3417. +{
  3418. + const char *nvram = (char *) KSEG1ADDR(DIR_600_A1_NVRAM_ADDR);
  3419. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  3420. + u8 mac_buff[6];
  3421. + u8 *mac = NULL;
  3422. +
  3423. + if (nvram_parse_mac_addr(nvram, DIR_600_A1_NVRAM_SIZE,
  3424. + "lan_mac=", mac_buff) == 0)
  3425. + mac = mac_buff;
  3426. +
  3427. + ar71xx_add_device_m25p80(&dir_600_a1_flash_data);
  3428. +
  3429. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_600_a1_leds_gpio),
  3430. + dir_600_a1_leds_gpio);
  3431. +
  3432. + ar71xx_add_device_gpio_buttons(-1, DIR_600_A1_BUTTONS_POLL_INTERVAL,
  3433. + ARRAY_SIZE(dir_600_a1_gpio_buttons),
  3434. + dir_600_a1_gpio_buttons);
  3435. +
  3436. + ap91_eth_init(mac, NULL);
  3437. + ap91_pci_init(ee, mac);
  3438. +}
  3439. +
  3440. +MIPS_MACHINE(AR71XX_MACH_DIR_600_A1, "DIR-600-A1", "D-Link DIR-600 rev. A1",
  3441. + dir_600_a1_setup);
  3442. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-dir-615-c1.c linux-2.6.35.7/arch/mips/ar71xx/mach-dir-615-c1.c
  3443. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-dir-615-c1.c 1970-01-01 01:00:00.000000000 +0100
  3444. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-dir-615-c1.c 2010-10-14 20:27:57.434406850 +0200
  3445. @@ -0,0 +1,173 @@
  3446. +/*
  3447. + * D-Link DIR-615 rev C1 board support
  3448. + *
  3449. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  3450. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  3451. + *
  3452. + * This program is free software; you can redistribute it and/or modify it
  3453. + * under the terms of the GNU General Public License version 2 as published
  3454. + * by the Free Software Foundation.
  3455. + */
  3456. +
  3457. +#include <linux/mtd/mtd.h>
  3458. +#include <linux/mtd/partitions.h>
  3459. +
  3460. +#include <asm/mach-ar71xx/ar71xx.h>
  3461. +
  3462. +#include "machtype.h"
  3463. +#include "devices.h"
  3464. +#include "dev-m25p80.h"
  3465. +#include "dev-ar913x-wmac.h"
  3466. +#include "dev-gpio-buttons.h"
  3467. +#include "dev-leds-gpio.h"
  3468. +#include "nvram.h"
  3469. +
  3470. +#define DIR_615C1_GPIO_LED_ORANGE_STATUS 1 /* ORANGE:STATUS:TRICOLOR */
  3471. +#define DIR_615C1_GPIO_LED_BLUE_WPS 3 /* BLUE:WPS */
  3472. +#define DIR_615C1_GPIO_LED_GREEN_WAN 4 /* GREEN:WAN:TRICOLOR */
  3473. +#define DIR_615C1_GPIO_LED_GREEN_WANCPU 5 /* GREEN:WAN:CPU:TRICOLOR */
  3474. +#define DIR_615C1_GPIO_LED_GREEN_WLAN 6 /* GREEN:WLAN */
  3475. +#define DIR_615C1_GPIO_LED_GREEN_STATUS 14 /* GREEN:STATUS:TRICOLOR */
  3476. +#define DIR_615C1_GPIO_LED_ORANGE_WAN 15 /* ORANGE:WAN:TRICOLOR */
  3477. +
  3478. +/* buttons may need refinement */
  3479. +
  3480. +#define DIR_615C1_GPIO_BTN_WPS 12
  3481. +#define DIR_615C1_GPIO_BTN_RESET 21
  3482. +
  3483. +#define DIR_615C1_BUTTONS_POLL_INTERVAL 20
  3484. +
  3485. +#define DIR_615C1_CONFIG_ADDR 0x1f020000
  3486. +#define DIR_615C1_CONFIG_SIZE 0x10000
  3487. +
  3488. +#ifdef CONFIG_MTD_PARTITIONS
  3489. +static struct mtd_partition dir_615c1_partitions[] = {
  3490. + {
  3491. + .name = "u-boot",
  3492. + .offset = 0,
  3493. + .size = 0x020000,
  3494. + .mask_flags = MTD_WRITEABLE,
  3495. + } , {
  3496. + .name = "config",
  3497. + .offset = 0x020000,
  3498. + .size = 0x010000,
  3499. + } , {
  3500. + .name = "kernel",
  3501. + .offset = 0x030000,
  3502. + .size = 0x0d0000,
  3503. + } , {
  3504. + .name = "rootfs",
  3505. + .offset = 0x100000,
  3506. + .size = 0x2f0000,
  3507. + } , {
  3508. + .name = "art",
  3509. + .offset = 0x3f0000,
  3510. + .size = 0x010000,
  3511. + .mask_flags = MTD_WRITEABLE,
  3512. + } , {
  3513. + .name = "firmware",
  3514. + .offset = 0x030000,
  3515. + .size = 0x3c0000,
  3516. + }
  3517. +};
  3518. +#endif /* CONFIG_MTD_PARTITIONS */
  3519. +
  3520. +static struct flash_platform_data dir_615c1_flash_data = {
  3521. +#ifdef CONFIG_MTD_PARTITIONS
  3522. + .parts = dir_615c1_partitions,
  3523. + .nr_parts = ARRAY_SIZE(dir_615c1_partitions),
  3524. +#endif
  3525. +};
  3526. +
  3527. +static struct gpio_led dir_615c1_leds_gpio[] __initdata = {
  3528. + {
  3529. + .name = "dir-615c1:orange:status",
  3530. + .gpio = DIR_615C1_GPIO_LED_ORANGE_STATUS,
  3531. + .active_low = 1,
  3532. + }, {
  3533. + .name = "dir-615c1:blue:wps",
  3534. + .gpio = DIR_615C1_GPIO_LED_BLUE_WPS,
  3535. + .active_low = 1,
  3536. + }, {
  3537. + .name = "dir-615c1:green:wan",
  3538. + .gpio = DIR_615C1_GPIO_LED_GREEN_WAN,
  3539. + .active_low = 1,
  3540. + }, {
  3541. + .name = "dir-615c1:green:wancpu",
  3542. + .gpio = DIR_615C1_GPIO_LED_GREEN_WANCPU,
  3543. + .active_low = 1,
  3544. + }, {
  3545. + .name = "dir-615c1:green:wlan",
  3546. + .gpio = DIR_615C1_GPIO_LED_GREEN_WLAN,
  3547. + .active_low = 1,
  3548. + }, {
  3549. + .name = "dir-615c1:green:status",
  3550. + .gpio = DIR_615C1_GPIO_LED_GREEN_STATUS,
  3551. + .active_low = 1,
  3552. + }, {
  3553. + .name = "dir-615c1:orange:wan",
  3554. + .gpio = DIR_615C1_GPIO_LED_ORANGE_WAN,
  3555. + .active_low = 1,
  3556. + }
  3557. +
  3558. +};
  3559. +
  3560. +static struct gpio_button dir_615c1_gpio_buttons[] __initdata = {
  3561. + {
  3562. + .desc = "reset",
  3563. + .type = EV_KEY,
  3564. + .code = KEY_RESTART,
  3565. + .threshold = 3,
  3566. + .gpio = DIR_615C1_GPIO_BTN_RESET,
  3567. + }, {
  3568. + .desc = "wps",
  3569. + .type = EV_KEY,
  3570. + .code = KEY_WPS_BUTTON,
  3571. + .threshold = 3,
  3572. + .gpio = DIR_615C1_GPIO_BTN_WPS,
  3573. + }
  3574. +};
  3575. +
  3576. +#define DIR_615C1_LAN_PHYMASK BIT(0)
  3577. +#define DIR_615C1_WAN_PHYMASK BIT(4)
  3578. +#define DIR_615C1_MDIO_MASK (~(DIR_615C1_LAN_PHYMASK | \
  3579. + DIR_615C1_WAN_PHYMASK))
  3580. +
  3581. +static void __init dir_615c1_setup(void)
  3582. +{
  3583. + const char *config = (char *) KSEG1ADDR(DIR_615C1_CONFIG_ADDR);
  3584. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  3585. + u8 mac[6];
  3586. + u8 *wlan_mac = NULL;
  3587. +
  3588. + if (nvram_parse_mac_addr(config, DIR_615C1_CONFIG_SIZE,
  3589. + "lan_mac=", mac) == 0) {
  3590. + ar71xx_set_mac_base(mac);
  3591. + wlan_mac = mac;
  3592. + }
  3593. +
  3594. + ar71xx_add_device_mdio(DIR_615C1_MDIO_MASK);
  3595. +
  3596. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  3597. + ar71xx_eth0_data.phy_mask = DIR_615C1_LAN_PHYMASK;
  3598. +
  3599. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  3600. + ar71xx_eth1_data.phy_mask = DIR_615C1_WAN_PHYMASK;
  3601. +
  3602. + ar71xx_add_device_eth(0);
  3603. + ar71xx_add_device_eth(1);
  3604. +
  3605. + ar71xx_add_device_m25p80(&dir_615c1_flash_data);
  3606. +
  3607. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_615c1_leds_gpio),
  3608. + dir_615c1_leds_gpio);
  3609. +
  3610. + ar71xx_add_device_gpio_buttons(-1, DIR_615C1_BUTTONS_POLL_INTERVAL,
  3611. + ARRAY_SIZE(dir_615c1_gpio_buttons),
  3612. + dir_615c1_gpio_buttons);
  3613. +
  3614. + ar913x_add_device_wmac(eeprom, wlan_mac);
  3615. +}
  3616. +
  3617. +MIPS_MACHINE(AR71XX_MACH_DIR_615_C1, "DIR-615-C1", "D-Link DIR-615 rev. C1",
  3618. + dir_615c1_setup);
  3619. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-dir-825-b1.c linux-2.6.35.7/arch/mips/ar71xx/mach-dir-825-b1.c
  3620. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-dir-825-b1.c 1970-01-01 01:00:00.000000000 +0100
  3621. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-dir-825-b1.c 2010-10-14 20:27:57.478101111 +0200
  3622. @@ -0,0 +1,192 @@
  3623. +/*
  3624. + * D-Link DIR-825 rev. B1 board support
  3625. + *
  3626. + * Copyright (C) 2009 Lukas Kuna, Evkanet, s.r.o.
  3627. + *
  3628. + * based on mach-wndr3700.c
  3629. + *
  3630. + * This program is free software; you can redistribute it and/or modify it
  3631. + * under the terms of the GNU General Public License version 2 as published
  3632. + * by the Free Software Foundation.
  3633. + */
  3634. +
  3635. +#include <linux/platform_device.h>
  3636. +#include <linux/mtd/mtd.h>
  3637. +#include <linux/mtd/partitions.h>
  3638. +#include <linux/delay.h>
  3639. +#include <linux/rtl8366s.h>
  3640. +
  3641. +#include <asm/mach-ar71xx/ar71xx.h>
  3642. +
  3643. +#include "machtype.h"
  3644. +#include "devices.h"
  3645. +#include "dev-m25p80.h"
  3646. +#include "dev-ap94-pci.h"
  3647. +#include "dev-gpio-buttons.h"
  3648. +#include "dev-leds-gpio.h"
  3649. +#include "dev-usb.h"
  3650. +
  3651. +#define DIR825B1_GPIO_LED_BLUE_USB 0
  3652. +#define DIR825B1_GPIO_LED_ORANGE_POWER 1
  3653. +#define DIR825B1_GPIO_LED_BLUE_POWER 2
  3654. +#define DIR825B1_GPIO_LED_BLUE_POWERSAVE 4
  3655. +#define DIR825B1_GPIO_LED_ORANGE_PLANET 6
  3656. +#define DIR825B1_GPIO_LED_BLUE_PLANET 11
  3657. +
  3658. +#define DIR825B1_GPIO_BTN_RESET 3
  3659. +#define DIR825B1_GPIO_BTN_POWERSAVE 8
  3660. +
  3661. +#define DIR825B1_GPIO_RTL8366_SDA 5
  3662. +#define DIR825B1_GPIO_RTL8366_SCK 7
  3663. +
  3664. +#define DIR825B1_BUTTONS_POLL_INTERVAL 20
  3665. +
  3666. +#define DIR825B1_CAL_LOCATION_0 0x1f661000
  3667. +#define DIR825B1_CAL_LOCATION_1 0x1f665000
  3668. +
  3669. +#define DIR825B1_MAC_LOCATION_0 0x2ffa81b8
  3670. +#define DIR825B1_MAC_LOCATION_1 0x2ffa8370
  3671. +
  3672. +#ifdef CONFIG_MTD_PARTITIONS
  3673. +static struct mtd_partition dir825b1_partitions[] = {
  3674. + {
  3675. + .name = "uboot",
  3676. + .offset = 0,
  3677. + .size = 0x040000,
  3678. + .mask_flags = MTD_WRITEABLE,
  3679. + } , {
  3680. + .name = "config",
  3681. + .offset = 0x040000,
  3682. + .size = 0x010000,
  3683. + .mask_flags = MTD_WRITEABLE,
  3684. + } , {
  3685. + .name = "firmware",
  3686. + .offset = 0x050000,
  3687. + .size = 0x610000,
  3688. + } , {
  3689. + .name = "caldata",
  3690. + .offset = 0x660000,
  3691. + .size = 0x010000,
  3692. + .mask_flags = MTD_WRITEABLE,
  3693. + } , {
  3694. + .name = "unknown",
  3695. + .offset = 0x670000,
  3696. + .size = 0x190000,
  3697. + .mask_flags = MTD_WRITEABLE,
  3698. + }
  3699. +};
  3700. +#endif /* CONFIG_MTD_PARTITIONS */
  3701. +
  3702. +static struct flash_platform_data dir825b1_flash_data = {
  3703. +#ifdef CONFIG_MTD_PARTITIONS
  3704. + .parts = dir825b1_partitions,
  3705. + .nr_parts = ARRAY_SIZE(dir825b1_partitions),
  3706. +#endif
  3707. +};
  3708. +
  3709. +static struct gpio_led dir825b1_leds_gpio[] __initdata = {
  3710. + {
  3711. + .name = "dir825b1:blue:usb",
  3712. + .gpio = DIR825B1_GPIO_LED_BLUE_USB,
  3713. + .active_low = 1,
  3714. + }, {
  3715. + .name = "dir825b1:orange:power",
  3716. + .gpio = DIR825B1_GPIO_LED_ORANGE_POWER,
  3717. + .active_low = 1,
  3718. + }, {
  3719. + .name = "dir825b1:blue:power",
  3720. + .gpio = DIR825B1_GPIO_LED_BLUE_POWER,
  3721. + .active_low = 1,
  3722. + }, {
  3723. + .name = "dir825b1:blue:powersave",
  3724. + .gpio = DIR825B1_GPIO_LED_BLUE_POWERSAVE,
  3725. + .active_low = 1,
  3726. + }, {
  3727. + .name = "dir825b1:orange:planet",
  3728. + .gpio = DIR825B1_GPIO_LED_ORANGE_PLANET,
  3729. + .active_low = 1,
  3730. + }, {
  3731. + .name = "dir825b1:blue:planet",
  3732. + .gpio = DIR825B1_GPIO_LED_BLUE_PLANET,
  3733. + .active_low = 1,
  3734. + }
  3735. +};
  3736. +
  3737. +static struct gpio_button dir825b1_gpio_buttons[] __initdata = {
  3738. + {
  3739. + .desc = "reset",
  3740. + .type = EV_KEY,
  3741. + .code = KEY_RESTART,
  3742. + .threshold = 3,
  3743. + .gpio = DIR825B1_GPIO_BTN_RESET,
  3744. + .active_low = 1,
  3745. + } , {
  3746. + .desc = "powersave",
  3747. + .type = EV_KEY,
  3748. + .code = BTN_1,
  3749. + .threshold = 3,
  3750. + .gpio = DIR825B1_GPIO_BTN_POWERSAVE,
  3751. + .active_low = 1,
  3752. + }
  3753. +};
  3754. +
  3755. +static struct rtl8366s_platform_data dir825b1_rtl8366s_data = {
  3756. + .gpio_sda = DIR825B1_GPIO_RTL8366_SDA,
  3757. + .gpio_sck = DIR825B1_GPIO_RTL8366_SCK,
  3758. +};
  3759. +
  3760. +static struct platform_device dir825b1_rtl8366s_device = {
  3761. + .name = RTL8366S_DRIVER_NAME,
  3762. + .id = -1,
  3763. + .dev = {
  3764. + .platform_data = &dir825b1_rtl8366s_data,
  3765. + }
  3766. +};
  3767. +
  3768. +static void __init dir825b1_setup(void)
  3769. +{
  3770. + u8 mac[6], i;
  3771. +
  3772. + memcpy(mac, (u8*)KSEG1ADDR(DIR825B1_MAC_LOCATION_1), 6);
  3773. + for(i = 5; i >= 3; i--)
  3774. + if(++mac[i] != 0x00) break;
  3775. +
  3776. + ar71xx_set_mac_base(mac);
  3777. +
  3778. + ar71xx_add_device_mdio(0x0);
  3779. +
  3780. + ar71xx_eth0_data.mii_bus_dev = &dir825b1_rtl8366s_device.dev;
  3781. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  3782. + ar71xx_eth0_data.speed = SPEED_1000;
  3783. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  3784. + ar71xx_eth0_pll_data.pll_1000 = 0x11110000;
  3785. +
  3786. + ar71xx_eth1_data.mii_bus_dev = &dir825b1_rtl8366s_device.dev;
  3787. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  3788. + ar71xx_eth1_data.phy_mask = 0x10;
  3789. + ar71xx_eth1_pll_data.pll_1000 = 0x11110000;
  3790. +
  3791. + ar71xx_add_device_eth(0);
  3792. + ar71xx_add_device_eth(1);
  3793. +
  3794. + ar71xx_add_device_m25p80(&dir825b1_flash_data);
  3795. +
  3796. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir825b1_leds_gpio),
  3797. + dir825b1_leds_gpio);
  3798. +
  3799. + ar71xx_add_device_gpio_buttons(-1, DIR825B1_BUTTONS_POLL_INTERVAL,
  3800. + ARRAY_SIZE(dir825b1_gpio_buttons),
  3801. + dir825b1_gpio_buttons);
  3802. +
  3803. + ar71xx_add_device_usb();
  3804. +
  3805. + platform_device_register(&dir825b1_rtl8366s_device);
  3806. +
  3807. + ap94_pci_init((u8 *) KSEG1ADDR(DIR825B1_CAL_LOCATION_0),
  3808. + (u8 *) KSEG1ADDR(DIR825B1_MAC_LOCATION_0),
  3809. + (u8 *) KSEG1ADDR(DIR825B1_CAL_LOCATION_1),
  3810. + (u8 *) KSEG1ADDR(DIR825B1_MAC_LOCATION_1));
  3811. +}
  3812. +
  3813. +MIPS_MACHINE(AR71XX_MACH_DIR_825_B1, "DIR-825-B1", "D-Link DIR-825 rev. B1",
  3814. + dir825b1_setup);
  3815. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-mzk-w04nu.c linux-2.6.35.7/arch/mips/ar71xx/mach-mzk-w04nu.c
  3816. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-mzk-w04nu.c 1970-01-01 01:00:00.000000000 +0100
  3817. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-mzk-w04nu.c 2010-10-14 20:27:57.518101300 +0200
  3818. @@ -0,0 +1,165 @@
  3819. +/*
  3820. + * Planex MZK-W04NU board support
  3821. + *
  3822. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  3823. + *
  3824. + * This program is free software; you can redistribute it and/or modify it
  3825. + * under the terms of the GNU General Public License version 2 as published
  3826. + * by the Free Software Foundation.
  3827. + */
  3828. +
  3829. +#include <linux/mtd/mtd.h>
  3830. +#include <linux/mtd/partitions.h>
  3831. +
  3832. +#include <asm/mach-ar71xx/ar71xx.h>
  3833. +
  3834. +#include "machtype.h"
  3835. +#include "devices.h"
  3836. +#include "dev-ar913x-wmac.h"
  3837. +#include "dev-gpio-buttons.h"
  3838. +#include "dev-leds-gpio.h"
  3839. +#include "dev-m25p80.h"
  3840. +#include "dev-usb.h"
  3841. +
  3842. +#define MZK_W04NU_GPIO_LED_USB 0
  3843. +#define MZK_W04NU_GPIO_LED_STATUS 1
  3844. +#define MZK_W04NU_GPIO_LED_WPS 3
  3845. +#define MZK_W04NU_GPIO_LED_WLAN 6
  3846. +#define MZK_W04NU_GPIO_LED_AP 15
  3847. +#define MZK_W04NU_GPIO_LED_ROUTER 16
  3848. +
  3849. +#define MZK_W04NU_GPIO_BTN_APROUTER 5
  3850. +#define MZK_W04NU_GPIO_BTN_WPS 12
  3851. +#define MZK_W04NU_GPIO_BTN_RESET 21
  3852. +
  3853. +#define MZK_W04NU_BUTTONS_POLL_INTERVAL 20
  3854. +
  3855. +#ifdef CONFIG_MTD_PARTITIONS
  3856. +static struct mtd_partition mzk_w04nu_partitions[] = {
  3857. + {
  3858. + .name = "u-boot",
  3859. + .offset = 0,
  3860. + .size = 0x040000,
  3861. + .mask_flags = MTD_WRITEABLE,
  3862. + } , {
  3863. + .name = "u-boot-env",
  3864. + .offset = 0x040000,
  3865. + .size = 0x010000,
  3866. + } , {
  3867. + .name = "kernel",
  3868. + .offset = 0x050000,
  3869. + .size = 0x160000,
  3870. + } , {
  3871. + .name = "rootfs",
  3872. + .offset = 0x1b0000,
  3873. + .size = 0x630000,
  3874. + } , {
  3875. + .name = "art",
  3876. + .offset = 0x7e0000,
  3877. + .size = 0x020000,
  3878. + .mask_flags = MTD_WRITEABLE,
  3879. + } , {
  3880. + .name = "firmware",
  3881. + .offset = 0x050000,
  3882. + .size = 0x790000,
  3883. + }
  3884. +};
  3885. +#endif /* CONFIG_MTD_PARTITIONS */
  3886. +
  3887. +static struct flash_platform_data mzk_w04nu_flash_data = {
  3888. +#ifdef CONFIG_MTD_PARTITIONS
  3889. + .parts = mzk_w04nu_partitions,
  3890. + .nr_parts = ARRAY_SIZE(mzk_w04nu_partitions),
  3891. +#endif
  3892. +};
  3893. +
  3894. +static struct gpio_led mzk_w04nu_leds_gpio[] __initdata = {
  3895. + {
  3896. + .name = "mzk-w04nu:green:status",
  3897. + .gpio = MZK_W04NU_GPIO_LED_STATUS,
  3898. + .active_low = 1,
  3899. + }, {
  3900. + .name = "mzk-w04nu:blue:wps",
  3901. + .gpio = MZK_W04NU_GPIO_LED_WPS,
  3902. + .active_low = 1,
  3903. + }, {
  3904. + .name = "mzk-w04nu:green:wlan",
  3905. + .gpio = MZK_W04NU_GPIO_LED_WLAN,
  3906. + .active_low = 1,
  3907. + }, {
  3908. + .name = "mzk-w04nu:green:usb",
  3909. + .gpio = MZK_W04NU_GPIO_LED_USB,
  3910. + .active_low = 1,
  3911. + }, {
  3912. + .name = "mzk-w04nu:green:ap",
  3913. + .gpio = MZK_W04NU_GPIO_LED_AP,
  3914. + .active_low = 1,
  3915. + }, {
  3916. + .name = "mzk-w04nu:green:router",
  3917. + .gpio = MZK_W04NU_GPIO_LED_ROUTER,
  3918. + .active_low = 1,
  3919. + }
  3920. +};
  3921. +
  3922. +static struct gpio_button mzk_w04nu_gpio_buttons[] __initdata = {
  3923. + {
  3924. + .desc = "reset",
  3925. + .type = EV_KEY,
  3926. + .code = KEY_RESTART,
  3927. + .threshold = 3,
  3928. + .gpio = MZK_W04NU_GPIO_BTN_RESET,
  3929. + .active_low = 1,
  3930. + }, {
  3931. + .desc = "wps",
  3932. + .type = EV_KEY,
  3933. + .code = KEY_WPS_BUTTON,
  3934. + .threshold = 3,
  3935. + .gpio = MZK_W04NU_GPIO_BTN_WPS,
  3936. + .active_low = 1,
  3937. + }, {
  3938. + .desc = "aprouter",
  3939. + .type = EV_KEY,
  3940. + .code = BTN_2,
  3941. + .threshold = 3,
  3942. + .gpio = MZK_W04NU_GPIO_BTN_APROUTER,
  3943. + .active_low = 0,
  3944. + }
  3945. +};
  3946. +
  3947. +#define MZK_W04NU_WAN_PHYMASK BIT(4)
  3948. +#define MZK_W04NU_MDIO_MASK (~MZK_W04NU_WAN_PHYMASK)
  3949. +
  3950. +static void __init mzk_w04nu_setup(void)
  3951. +{
  3952. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  3953. +
  3954. + ar71xx_set_mac_base(eeprom);
  3955. +
  3956. + ar71xx_add_device_mdio(MZK_W04NU_MDIO_MASK);
  3957. +
  3958. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  3959. + ar71xx_eth0_data.speed = SPEED_100;
  3960. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  3961. + ar71xx_eth0_data.has_ar8216 = 1;
  3962. +
  3963. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  3964. + ar71xx_eth1_data.phy_mask = MZK_W04NU_WAN_PHYMASK;
  3965. +
  3966. + ar71xx_add_device_eth(0);
  3967. + ar71xx_add_device_eth(1);
  3968. +
  3969. + ar71xx_add_device_m25p80(&mzk_w04nu_flash_data);
  3970. +
  3971. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(mzk_w04nu_leds_gpio),
  3972. + mzk_w04nu_leds_gpio);
  3973. +
  3974. + ar71xx_add_device_gpio_buttons(-1, MZK_W04NU_BUTTONS_POLL_INTERVAL,
  3975. + ARRAY_SIZE(mzk_w04nu_gpio_buttons),
  3976. + mzk_w04nu_gpio_buttons);
  3977. + ar71xx_add_device_usb();
  3978. +
  3979. + ar913x_add_device_wmac(eeprom, NULL);
  3980. +}
  3981. +
  3982. +MIPS_MACHINE(AR71XX_MACH_MZK_W04NU, "MZK-W04NU", "Planex MZK-W04NU",
  3983. + mzk_w04nu_setup);
  3984. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-mzk-w300nh.c linux-2.6.35.7/arch/mips/ar71xx/mach-mzk-w300nh.c
  3985. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-mzk-w300nh.c 1970-01-01 01:00:00.000000000 +0100
  3986. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-mzk-w300nh.c 2010-10-14 20:27:57.565601159 +0200
  3987. @@ -0,0 +1,158 @@
  3988. +/*
  3989. + * Planex MZK-W300NH board support
  3990. + *
  3991. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  3992. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  3993. + *
  3994. + * This program is free software; you can redistribute it and/or modify it
  3995. + * under the terms of the GNU General Public License version 2 as published
  3996. + * by the Free Software Foundation.
  3997. + */
  3998. +
  3999. +#include <linux/mtd/mtd.h>
  4000. +#include <linux/mtd/partitions.h>
  4001. +
  4002. +#include <asm/mach-ar71xx/ar71xx.h>
  4003. +
  4004. +#include "machtype.h"
  4005. +#include "devices.h"
  4006. +#include "dev-m25p80.h"
  4007. +#include "dev-ar913x-wmac.h"
  4008. +#include "dev-gpio-buttons.h"
  4009. +#include "dev-leds-gpio.h"
  4010. +
  4011. +#define MZK_W300NH_GPIO_LED_STATUS 1
  4012. +#define MZK_W300NH_GPIO_LED_WPS 3
  4013. +#define MZK_W300NH_GPIO_LED_WLAN 6
  4014. +#define MZK_W300NH_GPIO_LED_AP 15
  4015. +#define MZK_W300NH_GPIO_LED_ROUTER 16
  4016. +
  4017. +#define MZK_W300NH_GPIO_BTN_APROUTER 5
  4018. +#define MZK_W300NH_GPIO_BTN_WPS 12
  4019. +#define MZK_W300NH_GPIO_BTN_RESET 21
  4020. +
  4021. +#define MZK_W04NU_BUTTONS_POLL_INTERVAL 20
  4022. +
  4023. +#ifdef CONFIG_MTD_PARTITIONS
  4024. +static struct mtd_partition mzk_w300nh_partitions[] = {
  4025. + {
  4026. + .name = "u-boot",
  4027. + .offset = 0,
  4028. + .size = 0x040000,
  4029. + .mask_flags = MTD_WRITEABLE,
  4030. + } , {
  4031. + .name = "u-boot-env",
  4032. + .offset = 0x040000,
  4033. + .size = 0x010000,
  4034. + } , {
  4035. + .name = "kernel",
  4036. + .offset = 0x050000,
  4037. + .size = 0x160000,
  4038. + } , {
  4039. + .name = "rootfs",
  4040. + .offset = 0x1b0000,
  4041. + .size = 0x630000,
  4042. + } , {
  4043. + .name = "art",
  4044. + .offset = 0x7e0000,
  4045. + .size = 0x020000,
  4046. + .mask_flags = MTD_WRITEABLE,
  4047. + } , {
  4048. + .name = "firmware",
  4049. + .offset = 0x050000,
  4050. + .size = 0x790000,
  4051. + }
  4052. +};
  4053. +#endif /* CONFIG_MTD_PARTITIONS */
  4054. +
  4055. +static struct flash_platform_data mzk_w300nh_flash_data = {
  4056. +#ifdef CONFIG_MTD_PARTITIONS
  4057. + .parts = mzk_w300nh_partitions,
  4058. + .nr_parts = ARRAY_SIZE(mzk_w300nh_partitions),
  4059. +#endif
  4060. +};
  4061. +
  4062. +static struct gpio_led mzk_w300nh_leds_gpio[] __initdata = {
  4063. + {
  4064. + .name = "mzk-w300nh:green:status",
  4065. + .gpio = MZK_W300NH_GPIO_LED_STATUS,
  4066. + .active_low = 1,
  4067. + }, {
  4068. + .name = "mzk-w300nh:blue:wps",
  4069. + .gpio = MZK_W300NH_GPIO_LED_WPS,
  4070. + .active_low = 1,
  4071. + }, {
  4072. + .name = "mzk-w300nh:green:wlan",
  4073. + .gpio = MZK_W300NH_GPIO_LED_WLAN,
  4074. + .active_low = 1,
  4075. + }, {
  4076. + .name = "mzk-w300nh:green:ap",
  4077. + .gpio = MZK_W300NH_GPIO_LED_AP,
  4078. + .active_low = 1,
  4079. + }, {
  4080. + .name = "mzk-w300nh:green:router",
  4081. + .gpio = MZK_W300NH_GPIO_LED_ROUTER,
  4082. + .active_low = 1,
  4083. + }
  4084. +};
  4085. +
  4086. +static struct gpio_button mzk_w300nh_gpio_buttons[] __initdata = {
  4087. + {
  4088. + .desc = "reset",
  4089. + .type = EV_KEY,
  4090. + .code = KEY_RESTART,
  4091. + .threshold = 3,
  4092. + .gpio = MZK_W300NH_GPIO_BTN_RESET,
  4093. + .active_low = 1,
  4094. + }, {
  4095. + .desc = "wps",
  4096. + .type = EV_KEY,
  4097. + .code = KEY_WPS_BUTTON,
  4098. + .threshold = 3,
  4099. + .gpio = MZK_W300NH_GPIO_BTN_WPS,
  4100. + .active_low = 1,
  4101. + }, {
  4102. + .desc = "aprouter",
  4103. + .type = EV_KEY,
  4104. + .code = BTN_2,
  4105. + .threshold = 3,
  4106. + .gpio = MZK_W300NH_GPIO_BTN_APROUTER,
  4107. + .active_low = 0,
  4108. + }
  4109. +};
  4110. +
  4111. +#define MZK_W300NH_WAN_PHYMASK BIT(4)
  4112. +#define MZK_W300NH_MDIO_MASK (~MZK_W300NH_WAN_PHYMASK)
  4113. +
  4114. +static void __init mzk_w300nh_setup(void)
  4115. +{
  4116. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  4117. +
  4118. + ar71xx_set_mac_base(eeprom);
  4119. +
  4120. + ar71xx_add_device_mdio(MZK_W300NH_MDIO_MASK);
  4121. +
  4122. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  4123. + ar71xx_eth0_data.speed = SPEED_100;
  4124. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  4125. + ar71xx_eth0_data.has_ar8216 = 1;
  4126. +
  4127. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  4128. + ar71xx_eth1_data.phy_mask = MZK_W300NH_WAN_PHYMASK;
  4129. +
  4130. + ar71xx_add_device_eth(0);
  4131. + ar71xx_add_device_eth(1);
  4132. +
  4133. + ar71xx_add_device_m25p80(&mzk_w300nh_flash_data);
  4134. +
  4135. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(mzk_w300nh_leds_gpio),
  4136. + mzk_w300nh_leds_gpio);
  4137. +
  4138. + ar71xx_add_device_gpio_buttons(-1, MZK_W04NU_BUTTONS_POLL_INTERVAL,
  4139. + ARRAY_SIZE(mzk_w300nh_gpio_buttons),
  4140. + mzk_w300nh_gpio_buttons);
  4141. + ar913x_add_device_wmac(eeprom, NULL);
  4142. +}
  4143. +
  4144. +MIPS_MACHINE(AR71XX_MACH_MZK_W300NH, "MZK-W300NH", "Planex MZK-W300NH",
  4145. + mzk_w300nh_setup);
  4146. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-nbg460n.c linux-2.6.35.7/arch/mips/ar71xx/mach-nbg460n.c
  4147. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-nbg460n.c 1970-01-01 01:00:00.000000000 +0100
  4148. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-nbg460n.c 2010-10-14 20:27:57.617104398 +0200
  4149. @@ -0,0 +1,222 @@
  4150. +/*
  4151. + * Zyxel NBG 460N/550N/550NH board support
  4152. + *
  4153. + * Copyright (C) 2010 Michael Kurz <michi.kurz@googlemail.com>
  4154. + *
  4155. + * based on mach-tl-wr1043nd.c
  4156. + *
  4157. + * This program is free software; you can redistribute it and/or modify it
  4158. + * under the terms of the GNU General Public License version 2 as published
  4159. + * by the Free Software Foundation.
  4160. + */
  4161. +
  4162. +#include <linux/platform_device.h>
  4163. +#include <linux/mtd/mtd.h>
  4164. +#include <linux/mtd/partitions.h>
  4165. +#include <linux/delay.h>
  4166. +#include <linux/rtl8366s.h>
  4167. +
  4168. +#include <linux/i2c.h>
  4169. +#include <linux/i2c-algo-bit.h>
  4170. +#include <linux/i2c-gpio.h>
  4171. +
  4172. +#include <asm/mach-ar71xx/ar71xx.h>
  4173. +
  4174. +#include "machtype.h"
  4175. +#include "devices.h"
  4176. +#include "dev-m25p80.h"
  4177. +#include "dev-ar913x-wmac.h"
  4178. +#include "dev-gpio-buttons.h"
  4179. +#include "dev-leds-gpio.h"
  4180. +
  4181. +/* LEDs */
  4182. +#define NBG460N_GPIO_LED_WPS 3
  4183. +#define NBG460N_GPIO_LED_WAN 6
  4184. +#define NBG460N_GPIO_LED_POWER 14
  4185. +#define NBG460N_GPIO_LED_WLAN 15
  4186. +
  4187. +/* Buttons */
  4188. +#define NBG460N_GPIO_BTN_WPS 12
  4189. +#define NBG460N_GPIO_BTN_RESET 21
  4190. +#define NBG460N_BUTTONS_POLL_INTERVAL 20
  4191. +
  4192. +/* RTC chip PCF8563 I2C interface */
  4193. +#define NBG460N_GPIO_PCF8563_SDA 8
  4194. +#define NBG460N_GPIO_PCF8563_SCK 7
  4195. +
  4196. +/* Switch configuration I2C interface */
  4197. +#define NBG460N_GPIO_RTL8366_SDA 16
  4198. +#define NBG460N_GPIO_RTL8366_SCK 18
  4199. +
  4200. +#ifdef CONFIG_MTD_PARTITIONS
  4201. +static struct mtd_partition nbg460n_partitions[] = {
  4202. + {
  4203. + .name = "Bootbase",
  4204. + .offset = 0,
  4205. + .size = 0x010000,
  4206. + .mask_flags = MTD_WRITEABLE,
  4207. + } , {
  4208. + .name = "U-Boot Config",
  4209. + .offset = 0x010000,
  4210. + .size = 0x030000,
  4211. + } , {
  4212. + .name = "U-Boot",
  4213. + .offset = 0x040000,
  4214. + .size = 0x030000,
  4215. + } , {
  4216. + .name = "linux",
  4217. + .offset = 0x070000,
  4218. + .size = 0x0e0000,
  4219. + } , {
  4220. + .name = "rootfs",
  4221. + .offset = 0x150000,
  4222. + .size = 0x2a0000,
  4223. + } , {
  4224. + .name = "CalibData",
  4225. + .offset = 0x3f0000,
  4226. + .size = 0x010000,
  4227. + .mask_flags = MTD_WRITEABLE,
  4228. + } , {
  4229. + .name = "firmware",
  4230. + .offset = 0x070000,
  4231. + .size = 0x380000,
  4232. + }
  4233. +};
  4234. +#endif /* CONFIG_MTD_PARTITIONS */
  4235. +
  4236. +static struct flash_platform_data nbg460n_flash_data = {
  4237. +#ifdef CONFIG_MTD_PARTITIONS
  4238. + .parts = nbg460n_partitions,
  4239. + .nr_parts = ARRAY_SIZE(nbg460n_partitions),
  4240. +#endif
  4241. +};
  4242. +
  4243. +static struct gpio_led nbg460n_leds_gpio[] __initdata = {
  4244. + {
  4245. + .name = "nbg460n:green:power",
  4246. + .gpio = NBG460N_GPIO_LED_POWER,
  4247. + .active_low = 0,
  4248. + .default_trigger = "default-on",
  4249. + }, {
  4250. + .name = "nbg460n:green:wps",
  4251. + .gpio = NBG460N_GPIO_LED_WPS,
  4252. + .active_low = 0,
  4253. + }, {
  4254. + .name = "nbg460n:green:wlan",
  4255. + .gpio = NBG460N_GPIO_LED_WLAN,
  4256. + .active_low = 0,
  4257. + }, {
  4258. + /* Not really for controlling the LED,
  4259. + when set low the LED blinks uncontrollable */
  4260. + .name = "nbg460n:green:wan",
  4261. + .gpio = NBG460N_GPIO_LED_WAN,
  4262. + .active_low = 0,
  4263. + }
  4264. +};
  4265. +
  4266. +static struct gpio_button nbg460n_gpio_buttons[] __initdata = {
  4267. + {
  4268. + .desc = "reset",
  4269. + .type = EV_KEY,
  4270. + .code = KEY_RESTART,
  4271. + .threshold = 3,
  4272. + .gpio = NBG460N_GPIO_BTN_RESET,
  4273. + .active_low = 1,
  4274. + }, {
  4275. + .desc = "wps",
  4276. + .type = EV_KEY,
  4277. + .code = KEY_WPS_BUTTON,
  4278. + .threshold = 3,
  4279. + .gpio = NBG460N_GPIO_BTN_WPS,
  4280. + .active_low = 1,
  4281. + }
  4282. +};
  4283. +
  4284. +static struct i2c_gpio_platform_data nbg460n_i2c_device_platdata = {
  4285. + .sda_pin = NBG460N_GPIO_PCF8563_SDA,
  4286. + .scl_pin = NBG460N_GPIO_PCF8563_SCK,
  4287. + .udelay = 10,
  4288. +};
  4289. +
  4290. +static struct platform_device nbg460n_i2c_device = {
  4291. + .name = "i2c-gpio",
  4292. + .id = -1,
  4293. + .num_resources = 0,
  4294. + .resource = NULL,
  4295. + .dev = {
  4296. + .platform_data = &nbg460n_i2c_device_platdata,
  4297. + },
  4298. +};
  4299. +
  4300. +static struct i2c_board_info nbg460n_i2c_devs[] __initdata = {
  4301. + {
  4302. + I2C_BOARD_INFO("pcf8563", 0x51),
  4303. + },
  4304. +};
  4305. +
  4306. +static void __devinit nbg460n_i2c_init(void)
  4307. +{
  4308. + /* The gpio interface */
  4309. + platform_device_register(&nbg460n_i2c_device);
  4310. + /* I2C devices */
  4311. + i2c_register_board_info(0, nbg460n_i2c_devs,
  4312. + ARRAY_SIZE(nbg460n_i2c_devs));
  4313. +}
  4314. +
  4315. +
  4316. +static struct rtl8366s_platform_data nbg460n_rtl8366s_data = {
  4317. + .gpio_sda = NBG460N_GPIO_RTL8366_SDA,
  4318. + .gpio_sck = NBG460N_GPIO_RTL8366_SCK,
  4319. +};
  4320. +
  4321. +static struct platform_device nbg460n_rtl8366s_device = {
  4322. + .name = RTL8366S_DRIVER_NAME,
  4323. + .id = -1,
  4324. + .dev = {
  4325. + .platform_data = &nbg460n_rtl8366s_data,
  4326. + }
  4327. +};
  4328. +
  4329. +static void __init nbg460n_setup(void)
  4330. +{
  4331. + /* end of bootloader sector contains mac address*/
  4332. + u8 *mac = (u8 *) KSEG1ADDR(0x1fc0fff8);
  4333. + /* last sector contains wlan calib data */
  4334. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  4335. +
  4336. + ar71xx_set_mac_base(mac);
  4337. +
  4338. + /* LAN Port */
  4339. + ar71xx_eth0_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev;
  4340. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  4341. + ar71xx_eth0_data.speed = SPEED_1000;
  4342. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  4343. +
  4344. + /* WAN Port */
  4345. + ar71xx_eth1_data.mii_bus_dev = &nbg460n_rtl8366s_device.dev;
  4346. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  4347. + ar71xx_eth1_data.phy_mask = 0x10;
  4348. +
  4349. + ar71xx_add_device_eth(0);
  4350. + ar71xx_add_device_eth(1);
  4351. +
  4352. + /* register the switch phy */
  4353. + platform_device_register(&nbg460n_rtl8366s_device);
  4354. +
  4355. + /* register flash */
  4356. + ar71xx_add_device_m25p80(&nbg460n_flash_data);
  4357. +
  4358. + ar913x_add_device_wmac(eeprom, mac);
  4359. +
  4360. + /* register RTC chip */
  4361. + nbg460n_i2c_init();
  4362. +
  4363. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(nbg460n_leds_gpio),
  4364. + nbg460n_leds_gpio);
  4365. +
  4366. + ar71xx_add_device_gpio_buttons(-1, NBG460N_BUTTONS_POLL_INTERVAL,
  4367. + ARRAY_SIZE(nbg460n_gpio_buttons),
  4368. + nbg460n_gpio_buttons);
  4369. +}
  4370. +
  4371. +MIPS_MACHINE(AR71XX_MACH_NBG460N, "NBG460N", "Zyxel NBG460N/550N/550NH", nbg460n_setup);
  4372. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-pb42.c linux-2.6.35.7/arch/mips/ar71xx/mach-pb42.c
  4373. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-pb42.c 1970-01-01 01:00:00.000000000 +0100
  4374. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-pb42.c 2010-10-14 20:27:57.665601166 +0200
  4375. @@ -0,0 +1,71 @@
  4376. +/*
  4377. + * Atheros PB42 board support
  4378. + *
  4379. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  4380. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  4381. + *
  4382. + * This program is free software; you can redistribute it and/or modify it
  4383. + * under the terms of the GNU General Public License version 2 as published
  4384. + * by the Free Software Foundation.
  4385. + */
  4386. +
  4387. +#include <asm/mach-ar71xx/ar71xx.h>
  4388. +
  4389. +#include "machtype.h"
  4390. +#include "devices.h"
  4391. +#include "dev-m25p80.h"
  4392. +#include "dev-gpio-buttons.h"
  4393. +#include "dev-pb42-pci.h"
  4394. +#include "dev-usb.h"
  4395. +
  4396. +#define PB42_BUTTONS_POLL_INTERVAL 20
  4397. +
  4398. +#define PB42_GPIO_BTN_SW4 8
  4399. +#define PB42_GPIO_BTN_SW5 3
  4400. +
  4401. +static struct gpio_button pb42_gpio_buttons[] __initdata = {
  4402. + {
  4403. + .desc = "sw4",
  4404. + .type = EV_KEY,
  4405. + .code = BTN_0,
  4406. + .threshold = 3,
  4407. + .gpio = PB42_GPIO_BTN_SW4,
  4408. + .active_low = 1,
  4409. + } , {
  4410. + .desc = "sw5",
  4411. + .type = EV_KEY,
  4412. + .code = BTN_1,
  4413. + .threshold = 3,
  4414. + .gpio = PB42_GPIO_BTN_SW5,
  4415. + .active_low = 1,
  4416. + }
  4417. +};
  4418. +
  4419. +#define PB42_WAN_PHYMASK BIT(20)
  4420. +#define PB42_LAN_PHYMASK (BIT(16) | BIT(17) | BIT(18) | BIT(19))
  4421. +#define PB42_MDIO_PHYMASK (PB42_LAN_PHYMASK | PB42_WAN_PHYMASK)
  4422. +
  4423. +static void __init pb42_init(void)
  4424. +{
  4425. + ar71xx_add_device_m25p80(NULL);
  4426. +
  4427. + ar71xx_add_device_mdio(~PB42_MDIO_PHYMASK);
  4428. +
  4429. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  4430. + ar71xx_eth0_data.phy_mask = PB42_WAN_PHYMASK;
  4431. +
  4432. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  4433. + ar71xx_eth1_data.speed = SPEED_100;
  4434. + ar71xx_eth1_data.duplex = DUPLEX_FULL;
  4435. +
  4436. + ar71xx_add_device_eth(0);
  4437. + ar71xx_add_device_eth(1);
  4438. +
  4439. + ar71xx_add_device_gpio_buttons(-1, PB42_BUTTONS_POLL_INTERVAL,
  4440. + ARRAY_SIZE(pb42_gpio_buttons),
  4441. + pb42_gpio_buttons);
  4442. +
  4443. + pb42_pci_init();
  4444. +}
  4445. +
  4446. +MIPS_MACHINE(AR71XX_MACH_PB42, "PB42", "Atheros PB42", pb42_init);
  4447. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-pb44.c linux-2.6.35.7/arch/mips/ar71xx/mach-pb44.c
  4448. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-pb44.c 1970-01-01 01:00:00.000000000 +0100
  4449. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-pb44.c 2010-10-14 20:27:57.725015448 +0200
  4450. @@ -0,0 +1,207 @@
  4451. +/*
  4452. + * Atheros PB44 board support
  4453. + *
  4454. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  4455. + *
  4456. + * This program is free software; you can redistribute it and/or modify it
  4457. + * under the terms of the GNU General Public License version 2 as published
  4458. + * by the Free Software Foundation.
  4459. + */
  4460. +
  4461. +#include <linux/init.h>
  4462. +#include <linux/bitops.h>
  4463. +#include <linux/delay.h>
  4464. +#include <linux/platform_device.h>
  4465. +#include <linux/spi/spi.h>
  4466. +#include <linux/spi/flash.h>
  4467. +#include <linux/spi/vsc7385.h>
  4468. +#include <linux/i2c.h>
  4469. +#include <linux/i2c-gpio.h>
  4470. +#include <linux/i2c/pcf857x.h>
  4471. +
  4472. +#include <asm/mach-ar71xx/ar71xx.h>
  4473. +
  4474. +#include "machtype.h"
  4475. +#include "devices.h"
  4476. +#include "dev-pb42-pci.h"
  4477. +#include "dev-gpio-buttons.h"
  4478. +#include "dev-leds-gpio.h"
  4479. +#include "dev-usb.h"
  4480. +
  4481. +#define PB44_PCF8757_VSC7395_CS 0
  4482. +#define PB44_PCF8757_STEREO_CS 1
  4483. +#define PB44_PCF8757_SLIC_CS0 2
  4484. +#define PB44_PCF8757_SLIC_TEST 3
  4485. +#define PB44_PCF8757_SLIC_INT0 4
  4486. +#define PB44_PCF8757_SLIC_INT1 5
  4487. +#define PB44_PCF8757_SW_RESET 6
  4488. +#define PB44_PCF8757_SW_JUMP 8
  4489. +#define PB44_PCF8757_LED_JUMP1 9
  4490. +#define PB44_PCF8757_LED_JUMP2 10
  4491. +#define PB44_PCF8757_TP24 11
  4492. +#define PB44_PCF8757_TP25 12
  4493. +#define PB44_PCF8757_TP26 13
  4494. +#define PB44_PCF8757_TP27 14
  4495. +#define PB44_PCF8757_TP28 15
  4496. +
  4497. +#define PB44_GPIO_I2C_SCL 0
  4498. +#define PB44_GPIO_I2C_SDA 1
  4499. +
  4500. +#define PB44_GPIO_EXP_BASE 16
  4501. +#define PB44_GPIO_VSC7395_CS (PB44_GPIO_EXP_BASE + PB44_PCF8757_VSC7395_CS)
  4502. +#define PB44_GPIO_SW_RESET (PB44_GPIO_EXP_BASE + PB44_PCF8757_SW_RESET)
  4503. +#define PB44_GPIO_SW_JUMP (PB44_GPIO_EXP_BASE + PB44_PCF8757_SW_JUMP)
  4504. +#define PB44_GPIO_LED_JUMP1 (PB44_GPIO_EXP_BASE + PB44_PCF8757_LED_JUMP1)
  4505. +#define PB44_GPIO_LED_JUMP2 (PB44_GPIO_EXP_BASE + PB44_PCF8757_LED_JUMP2)
  4506. +
  4507. +static struct i2c_gpio_platform_data pb44_i2c_gpio_data = {
  4508. + .sda_pin = PB44_GPIO_I2C_SDA,
  4509. + .scl_pin = PB44_GPIO_I2C_SCL,
  4510. +};
  4511. +
  4512. +static struct platform_device pb44_i2c_gpio_device = {
  4513. + .name = "i2c-gpio",
  4514. + .id = 0,
  4515. + .dev = {
  4516. + .platform_data = &pb44_i2c_gpio_data,
  4517. + }
  4518. +};
  4519. +
  4520. +static struct pcf857x_platform_data pb44_pcf857x_data = {
  4521. + .gpio_base = PB44_GPIO_EXP_BASE,
  4522. +};
  4523. +
  4524. +static struct i2c_board_info pb44_i2c_board_info[] __initdata = {
  4525. + {
  4526. + I2C_BOARD_INFO("pcf8575", 0x20),
  4527. + .platform_data = &pb44_pcf857x_data,
  4528. + },
  4529. +};
  4530. +
  4531. +static struct gpio_led pb44_leds_gpio[] __initdata = {
  4532. + {
  4533. + .name = "pb44:amber:jump1",
  4534. + .gpio = PB44_GPIO_LED_JUMP1,
  4535. + .active_low = 1,
  4536. + }, {
  4537. + .name = "pb44:green:jump2",
  4538. + .gpio = PB44_GPIO_LED_JUMP2,
  4539. + .active_low = 1,
  4540. + },
  4541. +};
  4542. +
  4543. +static struct gpio_button pb44_gpio_buttons[] __initdata = {
  4544. + {
  4545. + .desc = "soft_reset",
  4546. + .type = EV_KEY,
  4547. + .code = KEY_RESTART,
  4548. + .threshold = 3,
  4549. + .gpio = PB44_GPIO_SW_RESET,
  4550. + .active_low = 1,
  4551. + } , {
  4552. + .desc = "jumpstart",
  4553. + .type = EV_KEY,
  4554. + .code = KEY_WPS_BUTTON,
  4555. + .threshold = 3,
  4556. + .gpio = PB44_GPIO_SW_JUMP,
  4557. + .active_low = 1,
  4558. + }
  4559. +};
  4560. +
  4561. +static void pb44_vsc7395_reset(void)
  4562. +{
  4563. + ar71xx_device_stop(RESET_MODULE_GE1_PHY);
  4564. + udelay(10);
  4565. + ar71xx_device_start(RESET_MODULE_GE1_PHY);
  4566. + mdelay(50);
  4567. +}
  4568. +
  4569. +static struct vsc7385_platform_data pb44_vsc7395_data = {
  4570. + .reset = pb44_vsc7395_reset,
  4571. + .ucode_name = "vsc7395_ucode_pb44.bin",
  4572. + .mac_cfg = {
  4573. + .tx_ipg = 6,
  4574. + .bit2 = 1,
  4575. + .clk_sel = 0,
  4576. + },
  4577. +};
  4578. +
  4579. +static struct spi_board_info pb44_spi_info[] = {
  4580. + {
  4581. + .bus_num = 0,
  4582. + .chip_select = 0,
  4583. + .max_speed_hz = 25000000,
  4584. + .modalias = "m25p80",
  4585. + }, {
  4586. + .bus_num = 0,
  4587. + .chip_select = 1,
  4588. + .max_speed_hz = 25000000,
  4589. + .modalias = "spi-vsc7385",
  4590. + .platform_data = &pb44_vsc7395_data,
  4591. + .controller_data = (void *) PB44_GPIO_VSC7395_CS,
  4592. + },
  4593. +};
  4594. +
  4595. +static struct resource pb44_spi_resources[] = {
  4596. + [0] = {
  4597. + .start = AR71XX_SPI_BASE,
  4598. + .end = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
  4599. + .flags = IORESOURCE_MEM,
  4600. + },
  4601. +};
  4602. +
  4603. +static struct ar71xx_spi_platform_data pb44_spi_data = {
  4604. + .bus_num = 0,
  4605. + .num_chipselect = 2,
  4606. +};
  4607. +
  4608. +static struct platform_device pb44_spi_device = {
  4609. + .name = "pb44-spi",
  4610. + .id = -1,
  4611. + .resource = pb44_spi_resources,
  4612. + .num_resources = ARRAY_SIZE(pb44_spi_resources),
  4613. + .dev = {
  4614. + .platform_data = &pb44_spi_data,
  4615. + },
  4616. +};
  4617. +
  4618. +#define PB44_WAN_PHYMASK BIT(0)
  4619. +#define PB44_LAN_PHYMASK 0
  4620. +#define PB44_MDIO_PHYMASK (PB44_LAN_PHYMASK | PB44_WAN_PHYMASK)
  4621. +
  4622. +static void __init pb44_init(void)
  4623. +{
  4624. + ar71xx_add_device_mdio(~PB44_MDIO_PHYMASK);
  4625. +
  4626. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  4627. + ar71xx_eth0_data.phy_mask = PB44_WAN_PHYMASK;
  4628. +
  4629. + ar71xx_add_device_eth(0);
  4630. +
  4631. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  4632. + ar71xx_eth1_data.speed = SPEED_1000;
  4633. + ar71xx_eth1_data.duplex = DUPLEX_FULL;
  4634. + ar71xx_eth1_pll_data.pll_1000 = 0x110000;
  4635. +
  4636. + ar71xx_add_device_eth(1);
  4637. +
  4638. + ar71xx_add_device_usb();
  4639. +
  4640. + pb42_pci_init();
  4641. +
  4642. + i2c_register_board_info(0, pb44_i2c_board_info,
  4643. + ARRAY_SIZE(pb44_i2c_board_info));
  4644. +
  4645. + platform_device_register(&pb44_i2c_gpio_device);
  4646. +
  4647. + spi_register_board_info(pb44_spi_info, ARRAY_SIZE(pb44_spi_info));
  4648. + platform_device_register(&pb44_spi_device);
  4649. +
  4650. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio),
  4651. + pb44_leds_gpio);
  4652. +
  4653. + ar71xx_add_device_gpio_buttons(-1, 20, ARRAY_SIZE(pb44_gpio_buttons),
  4654. + pb44_gpio_buttons);
  4655. +}
  4656. +
  4657. +MIPS_MACHINE(AR71XX_MACH_PB44, "PB44", "Atheros PB44", pb44_init);
  4658. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-pb92.c linux-2.6.35.7/arch/mips/ar71xx/mach-pb92.c
  4659. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-pb92.c 1970-01-01 01:00:00.000000000 +0100
  4660. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-pb92.c 2010-10-14 20:27:57.774807434 +0200
  4661. @@ -0,0 +1,109 @@
  4662. +/*
  4663. + * Atheros PB92 board support
  4664. + *
  4665. + * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
  4666. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  4667. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  4668. + *
  4669. + * This program is free software; you can redistribute it and/or modify it
  4670. + * under the terms of the GNU General Public License version 2 as published
  4671. + * by the Free Software Foundation.
  4672. + */
  4673. +
  4674. +#include <linux/mtd/mtd.h>
  4675. +#include <linux/mtd/partitions.h>
  4676. +#include <asm/mach-ar71xx/ar71xx.h>
  4677. +
  4678. +#include "machtype.h"
  4679. +#include "devices.h"
  4680. +#include "dev-m25p80.h"
  4681. +#include "dev-gpio-buttons.h"
  4682. +#include "dev-pb9x-pci.h"
  4683. +#include "dev-usb.h"
  4684. +
  4685. +#ifdef CONFIG_MTD_PARTITIONS
  4686. +static struct mtd_partition pb92_partitions[] = {
  4687. + {
  4688. + .name = "u-boot",
  4689. + .offset = 0,
  4690. + .size = 0x040000,
  4691. + .mask_flags = MTD_WRITEABLE,
  4692. + } , {
  4693. + .name = "u-boot-env",
  4694. + .offset = 0x040000,
  4695. + .size = 0x010000,
  4696. + } , {
  4697. + .name = "rootfs",
  4698. + .offset = 0x050000,
  4699. + .size = 0x2b0000,
  4700. + } , {
  4701. + .name = "uImage",
  4702. + .offset = 0x300000,
  4703. + .size = 0x0e0000,
  4704. + } , {
  4705. + .name = "ART",
  4706. + .offset = 0x3e0000,
  4707. + .size = 0x020000,
  4708. + .mask_flags = MTD_WRITEABLE,
  4709. + }
  4710. +};
  4711. +#endif /* CONFIG_MTD_PARTITIONS */
  4712. +
  4713. +static struct flash_platform_data pb92_flash_data = {
  4714. +#ifdef CONFIG_MTD_PARTITIONS
  4715. + .parts = pb92_partitions,
  4716. + .nr_parts = ARRAY_SIZE(pb92_partitions),
  4717. +#endif
  4718. +};
  4719. +
  4720. +
  4721. +#define PB92_BUTTONS_POLL_INTERVAL 20
  4722. +
  4723. +#define PB92_GPIO_BTN_SW4 8
  4724. +#define PB92_GPIO_BTN_SW5 3
  4725. +
  4726. +static struct gpio_button pb92_gpio_buttons[] __initdata = {
  4727. + {
  4728. + .desc = "sw4",
  4729. + .type = EV_KEY,
  4730. + .code = BTN_0,
  4731. + .threshold = 3,
  4732. + .gpio = PB92_GPIO_BTN_SW4,
  4733. + .active_low = 1,
  4734. + } , {
  4735. + .desc = "sw5",
  4736. + .type = EV_KEY,
  4737. + .code = BTN_1,
  4738. + .threshold = 3,
  4739. + .gpio = PB92_GPIO_BTN_SW5,
  4740. + .active_low = 1,
  4741. + }
  4742. +};
  4743. +
  4744. +static void __init pb92_init(void)
  4745. +{
  4746. + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
  4747. +
  4748. + ar71xx_set_mac_base(mac);
  4749. + ar71xx_add_device_m25p80(&pb92_flash_data);
  4750. +
  4751. + ar71xx_add_device_mdio(~0);
  4752. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  4753. + ar71xx_eth0_data.speed = SPEED_1000;
  4754. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  4755. +
  4756. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  4757. + ar71xx_eth1_data.speed = SPEED_1000;
  4758. + ar71xx_eth1_data.duplex = DUPLEX_FULL;
  4759. +
  4760. + ar71xx_add_device_eth(0);
  4761. + ar71xx_add_device_eth(1);
  4762. +
  4763. + ar71xx_add_device_gpio_buttons(-1, PB92_BUTTONS_POLL_INTERVAL,
  4764. + ARRAY_SIZE(pb92_gpio_buttons),
  4765. + pb92_gpio_buttons);
  4766. +
  4767. + pb9x_pci_init();
  4768. +}
  4769. +
  4770. +MIPS_MACHINE(AR71XX_MACH_PB92, "PB92", "Atheros PB92", pb92_init);
  4771. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-rb4xx.c linux-2.6.35.7/arch/mips/ar71xx/mach-rb4xx.c
  4772. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-rb4xx.c 1970-01-01 01:00:00.000000000 +0100
  4773. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-rb4xx.c 2010-10-14 20:27:57.824611115 +0200
  4774. @@ -0,0 +1,290 @@
  4775. +/*
  4776. + * MikroTik RouterBOARD 4xx series support
  4777. + *
  4778. + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
  4779. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  4780. + *
  4781. + * This program is free software; you can redistribute it and/or modify it
  4782. + * under the terms of the GNU General Public License version 2 as published
  4783. + * by the Free Software Foundation.
  4784. + */
  4785. +
  4786. +#include <linux/platform_device.h>
  4787. +#include <linux/irq.h>
  4788. +#include <linux/mmc/host.h>
  4789. +#include <linux/spi/spi.h>
  4790. +#include <linux/spi/flash.h>
  4791. +#include <linux/spi/mmc_spi.h>
  4792. +
  4793. +#include <asm/mach-ar71xx/ar71xx.h>
  4794. +#include <asm/mach-ar71xx/pci.h>
  4795. +
  4796. +#include "machtype.h"
  4797. +#include "devices.h"
  4798. +#include "dev-gpio-buttons.h"
  4799. +#include "dev-leds-gpio.h"
  4800. +#include "dev-usb.h"
  4801. +
  4802. +#define RB4XX_GPIO_USER_LED 4
  4803. +#define RB4XX_GPIO_RESET_SWITCH 7
  4804. +
  4805. +#define RB4XX_BUTTONS_POLL_INTERVAL 20
  4806. +
  4807. +static struct gpio_led rb4xx_leds_gpio[] __initdata = {
  4808. + {
  4809. + .name = "rb4xx:yellow:user",
  4810. + .gpio = RB4XX_GPIO_USER_LED,
  4811. + .active_low = 0,
  4812. + },
  4813. +};
  4814. +
  4815. +static struct gpio_button rb4xx_gpio_buttons[] __initdata = {
  4816. + {
  4817. + .desc = "reset_switch",
  4818. + .type = EV_KEY,
  4819. + .code = KEY_RESTART,
  4820. + .threshold = 3,
  4821. + .gpio = RB4XX_GPIO_RESET_SWITCH,
  4822. + .active_low = 1,
  4823. + }
  4824. +};
  4825. +
  4826. +static struct platform_device rb4xx_nand_device = {
  4827. + .name = "rb4xx-nand",
  4828. + .id = -1,
  4829. +};
  4830. +
  4831. +static struct ar71xx_pci_irq rb4xx_pci_irqs[] __initdata = {
  4832. + {
  4833. + .slot = 0,
  4834. + .pin = 1,
  4835. + .irq = AR71XX_PCI_IRQ_DEV2,
  4836. + }, {
  4837. + .slot = 1,
  4838. + .pin = 1,
  4839. + .irq = AR71XX_PCI_IRQ_DEV0,
  4840. + }, {
  4841. + .slot = 1,
  4842. + .pin = 2,
  4843. + .irq = AR71XX_PCI_IRQ_DEV1,
  4844. + }, {
  4845. + .slot = 2,
  4846. + .pin = 1,
  4847. + .irq = AR71XX_PCI_IRQ_DEV1,
  4848. + }, {
  4849. + .slot = 3,
  4850. + .pin = 1,
  4851. + .irq = AR71XX_PCI_IRQ_DEV2,
  4852. + }
  4853. +};
  4854. +
  4855. +#if 0
  4856. +/*
  4857. + * SPI device support is experimental
  4858. + */
  4859. +static struct flash_platform_data rb4xx_flash_data = {
  4860. + .type = "pm25lv512",
  4861. +};
  4862. +
  4863. +static struct spi_board_info rb4xx_spi_info[] = {
  4864. + {
  4865. + .bus_num = 0,
  4866. + .chip_select = 0,
  4867. + .max_speed_hz = 25000000,
  4868. + .modalias = "m25p80",
  4869. + .platform_data = &rb4xx_flash_data,
  4870. + }
  4871. +};
  4872. +
  4873. +static struct mmc_spi_platform_data rb433_mmc_data = {
  4874. + .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  4875. +};
  4876. +
  4877. +static struct spi_board_info rb433_spi_info[] = {
  4878. + {
  4879. + .bus_num = 0,
  4880. + .chip_select = 0,
  4881. + .max_speed_hz = 25000000,
  4882. + .modalias = "m25p80",
  4883. + .platform_data = &rb433_flash_data,
  4884. + }, {
  4885. + .bus_num = 0,
  4886. + .chip_select = 2,
  4887. + .max_speed_hz = 25000000,
  4888. + .modalias = "mmc_spi",
  4889. + .platform_data = &rb433_mmc_data,
  4890. + }
  4891. +};
  4892. +
  4893. +static u32 rb433_spi_get_ioc_base(u8 chip_select, int cs_high, int is_on)
  4894. +{
  4895. + u32 ret;
  4896. +
  4897. + if (is_on == AR71XX_SPI_CS_INACTIVE) {
  4898. + ret = SPI_IOC_CS0 | SPI_IOC_CS1;
  4899. + } else {
  4900. + if (cs_high) {
  4901. + ret = SPI_IOC_CS0 | SPI_IOC_CS1;
  4902. + } else {
  4903. + if ((chip_select ^ 2) == 0)
  4904. + ret = SPI_IOC_CS1 ^ (SPI_IOC_CS0 | SPI_IOC_CS1);
  4905. + else
  4906. + ret = SPI_IOC_CS0 ^ (SPI_IOC_CS0 | SPI_IOC_CS1);
  4907. + }
  4908. + }
  4909. +
  4910. + return ret;
  4911. +}
  4912. +
  4913. +struct ar71xx_spi_platform_data rb433_spi_data = {
  4914. + .bus_num = 0,
  4915. + .num_chipselect = 3,
  4916. + .get_ioc_base = rb433_spi_get_ioc_base,
  4917. +};
  4918. +
  4919. +static void rb4xx_add_device_spi(void)
  4920. +{
  4921. + ar71xx_add_device_spi(NULL, rb4xx_spi_info, ARRAY_SIZE(rb4xx_spi_info));
  4922. +}
  4923. +
  4924. +static void rb433_add_device_spi(void)
  4925. +{
  4926. + ar71xx_add_device_spi(&rb433_spi_data, rb433_spi_info,
  4927. + ARRAY_SIZE(rb433_spi_info));
  4928. +}
  4929. +#else
  4930. +static inline void rb4xx_add_device_spi(void) {}
  4931. +static inline void rb433_add_device_spi(void) {}
  4932. +#endif
  4933. +
  4934. +static void __init rb4xx_generic_setup(void)
  4935. +{
  4936. + ar71xx_gpio_function_enable(AR71XX_GPIO_FUNC_SPI_CS1_EN |
  4937. + AR71XX_GPIO_FUNC_SPI_CS2_EN);
  4938. +
  4939. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(rb4xx_leds_gpio),
  4940. + rb4xx_leds_gpio);
  4941. +
  4942. + ar71xx_add_device_gpio_buttons(-1, RB4XX_BUTTONS_POLL_INTERVAL,
  4943. + ARRAY_SIZE(rb4xx_gpio_buttons),
  4944. + rb4xx_gpio_buttons);
  4945. +
  4946. + platform_device_register(&rb4xx_nand_device);
  4947. +}
  4948. +
  4949. +static void __init rb411_setup(void)
  4950. +{
  4951. + rb4xx_generic_setup();
  4952. + rb4xx_add_device_spi();
  4953. +
  4954. + ar71xx_add_device_mdio(0xfffffffc);
  4955. +
  4956. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  4957. + ar71xx_eth0_data.phy_mask = 0x00000003;
  4958. +
  4959. + ar71xx_add_device_eth(0);
  4960. +
  4961. + ar71xx_pci_init(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
  4962. +}
  4963. +
  4964. +MIPS_MACHINE(AR71XX_MACH_RB_411, "411", "MikroTik RouterBOARD 411/A/AH",
  4965. + rb411_setup);
  4966. +
  4967. +static void __init rb411u_setup(void)
  4968. +{
  4969. + rb411_setup();
  4970. + ar71xx_add_device_usb();
  4971. +}
  4972. +
  4973. +MIPS_MACHINE(AR71XX_MACH_RB_411U, "411U", "MikroTik RouterBOARD 411U",
  4974. + rb411u_setup);
  4975. +
  4976. +static void __init rb433_setup(void)
  4977. +{
  4978. + rb4xx_generic_setup();
  4979. + rb433_add_device_spi();
  4980. +
  4981. + ar71xx_add_device_mdio(0xffffffe9);
  4982. +
  4983. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  4984. + ar71xx_eth0_data.speed = SPEED_100;
  4985. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  4986. +
  4987. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  4988. + ar71xx_eth1_data.phy_mask = 0x00000010;
  4989. +
  4990. + ar71xx_add_device_eth(1);
  4991. + ar71xx_add_device_eth(0);
  4992. +
  4993. + ar71xx_pci_init(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
  4994. +}
  4995. +
  4996. +MIPS_MACHINE(AR71XX_MACH_RB_433, "433", "MikroTik RouterBOARD 433/AH",
  4997. + rb433_setup);
  4998. +
  4999. +static void __init rb433u_setup(void)
  5000. +{
  5001. + rb433_setup();
  5002. + ar71xx_add_device_usb();
  5003. +}
  5004. +
  5005. +MIPS_MACHINE(AR71XX_MACH_RB_433U, "433U", "MikroTik RouterBOARD 433UAH",
  5006. + rb433u_setup);
  5007. +
  5008. +static void __init rb450_generic_setup(int gige)
  5009. +{
  5010. + rb4xx_generic_setup();
  5011. + rb4xx_add_device_spi();
  5012. +
  5013. + ar71xx_add_device_mdio(0xffffffe0);
  5014. +
  5015. + ar71xx_eth0_data.phy_if_mode = (gige) ? PHY_INTERFACE_MODE_RGMII : PHY_INTERFACE_MODE_MII;
  5016. + ar71xx_eth0_data.phy_mask = (gige) ? (1 << 0) : 0;
  5017. + ar71xx_eth0_data.speed = (gige) ? SPEED_1000 : SPEED_100;
  5018. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  5019. +
  5020. + ar71xx_eth1_data.phy_if_mode = (gige) ? PHY_INTERFACE_MODE_RGMII : PHY_INTERFACE_MODE_RMII;
  5021. + ar71xx_eth1_data.phy_mask = 0x00000010;
  5022. +
  5023. + ar71xx_add_device_eth(1);
  5024. + ar71xx_add_device_eth(0);
  5025. +}
  5026. +
  5027. +static void __init rb450_setup(void)
  5028. +{
  5029. + rb450_generic_setup(0);
  5030. +}
  5031. +
  5032. +MIPS_MACHINE(AR71XX_MACH_RB_450, "450", "MikroTik RouterBOARD 450",
  5033. + rb450_setup);
  5034. +
  5035. +static void __init rb450g_setup(void)
  5036. +{
  5037. + rb450_generic_setup(1);
  5038. +}
  5039. +
  5040. +MIPS_MACHINE(AR71XX_MACH_RB_450G, "450G", "MikroTik RouterBOARD 450G",
  5041. + rb450g_setup);
  5042. +
  5043. +static void __init rb493_setup(void)
  5044. +{
  5045. + rb4xx_generic_setup();
  5046. + rb4xx_add_device_spi();
  5047. +
  5048. + ar71xx_add_device_mdio(0x3fffff00);
  5049. +
  5050. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  5051. + ar71xx_eth0_data.speed = SPEED_100;
  5052. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  5053. +
  5054. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  5055. + ar71xx_eth1_data.phy_mask = 0x00000001;
  5056. +
  5057. + ar71xx_add_device_eth(0);
  5058. + ar71xx_add_device_eth(1);
  5059. +
  5060. + ar71xx_pci_init(ARRAY_SIZE(rb4xx_pci_irqs), rb4xx_pci_irqs);
  5061. +}
  5062. +
  5063. +MIPS_MACHINE(AR71XX_MACH_RB_493, "493", "MikroTik RouterBOARD 493/AH",
  5064. + rb493_setup);
  5065. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-rb750.c linux-2.6.35.7/arch/mips/ar71xx/mach-rb750.c
  5066. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-rb750.c 1970-01-01 01:00:00.000000000 +0100
  5067. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-rb750.c 2010-10-14 20:27:57.874416755 +0200
  5068. @@ -0,0 +1,133 @@
  5069. +/*
  5070. + * MikroTik RouterBOARD 750 support
  5071. + *
  5072. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  5073. + *
  5074. + * This program is free software; you can redistribute it and/or modify it
  5075. + * under the terms of the GNU General Public License version 2 as published
  5076. + * by the Free Software Foundation.
  5077. + */
  5078. +
  5079. +#include <linux/platform_device.h>
  5080. +#include <asm/mach-ar71xx/ar71xx.h>
  5081. +#include <asm/mach-ar71xx/mach-rb750.h>
  5082. +
  5083. +#include "machtype.h"
  5084. +#include "dev-ap91-eth.h"
  5085. +
  5086. +static struct rb750_led_data rb750_leds[] = {
  5087. + {
  5088. + .name = "rb750:green:act",
  5089. + .mask = RB750_LED_ACT,
  5090. + .active_low = 1,
  5091. + }, {
  5092. + .name = "rb750:green:port1",
  5093. + .mask = RB750_LED_PORT5,
  5094. + .active_low = 1,
  5095. + }, {
  5096. + .name = "rb750:green:port2",
  5097. + .mask = RB750_LED_PORT4,
  5098. + .active_low = 1,
  5099. + }, {
  5100. + .name = "rb750:green:port3",
  5101. + .mask = RB750_LED_PORT3,
  5102. + .active_low = 1,
  5103. + }, {
  5104. + .name = "rb750:green:port4",
  5105. + .mask = RB750_LED_PORT2,
  5106. + .active_low = 1,
  5107. + }, {
  5108. + .name = "rb750:green:port5",
  5109. + .mask = RB750_LED_PORT1,
  5110. + .active_low = 1,
  5111. + }
  5112. +};
  5113. +
  5114. +static struct rb750_led_platform_data rb750_leds_data = {
  5115. + .num_leds = ARRAY_SIZE(rb750_leds),
  5116. + .leds = rb750_leds,
  5117. +};
  5118. +
  5119. +static struct platform_device rb750_leds_device = {
  5120. + .name = "leds-rb750",
  5121. + .dev = {
  5122. + .platform_data = &rb750_leds_data,
  5123. + }
  5124. +};
  5125. +
  5126. +static const char *rb750_port_names[AP91_ETH_NUM_PORT_NAMES] __initdata = {
  5127. + "port5",
  5128. + "port4",
  5129. + "port3",
  5130. + "port2",
  5131. +};
  5132. +
  5133. +static struct platform_device rb750_nand_device = {
  5134. + .name = "rb750-nand",
  5135. + .id = -1,
  5136. +};
  5137. +
  5138. +int rb750_latch_change(u32 mask_clr, u32 mask_set)
  5139. +{
  5140. + static DEFINE_SPINLOCK(lock);
  5141. + static u32 latch_set = RB750_LED_BITS | RB750_LVC573_LE;
  5142. + static u32 latch_oe;
  5143. + static u32 latch_clr;
  5144. + unsigned long flags;
  5145. + u32 t;
  5146. + int ret = 0;
  5147. +
  5148. + spin_lock_irqsave(&lock, flags);
  5149. +
  5150. + if ((mask_clr & BIT(31)) != 0 &&
  5151. + (latch_set & RB750_LVC573_LE) == 0) {
  5152. + goto unlock;
  5153. + }
  5154. +
  5155. + latch_set = (latch_set | mask_set) & ~mask_clr;
  5156. + latch_clr = (latch_clr | mask_clr) & ~mask_set;
  5157. +
  5158. + if (latch_oe == 0)
  5159. + latch_oe = __raw_readl(ar71xx_gpio_base + GPIO_REG_OE);
  5160. +
  5161. + if (likely(latch_set & RB750_LVC573_LE)) {
  5162. + void __iomem *base = ar71xx_gpio_base;
  5163. +
  5164. + t = __raw_readl(base + GPIO_REG_OE);
  5165. + t |= mask_clr | latch_oe | mask_set;
  5166. +
  5167. + __raw_writel(t, base + GPIO_REG_OE);
  5168. + __raw_writel(latch_clr, base + GPIO_REG_CLEAR);
  5169. + __raw_writel(latch_set, base + GPIO_REG_SET);
  5170. + } else if (mask_clr & RB750_LVC573_LE) {
  5171. + void __iomem *base = ar71xx_gpio_base;
  5172. +
  5173. + latch_oe = __raw_readl(base + GPIO_REG_OE);
  5174. + __raw_writel(RB750_LVC573_LE, base + GPIO_REG_CLEAR);
  5175. + /* flush write */
  5176. + __raw_readl(base + GPIO_REG_CLEAR);
  5177. + }
  5178. +
  5179. + ret = 1;
  5180. +
  5181. + unlock:
  5182. + spin_unlock_irqrestore(&lock, flags);
  5183. + return ret;
  5184. +}
  5185. +EXPORT_SYMBOL_GPL(rb750_latch_change);
  5186. +
  5187. +static void __init rb750_setup(void)
  5188. +{
  5189. + ar71xx_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  5190. + AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  5191. + AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  5192. + AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  5193. + AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  5194. +
  5195. + ap91_eth_init(NULL, rb750_port_names);
  5196. + platform_device_register(&rb750_leds_device);
  5197. + platform_device_register(&rb750_nand_device);
  5198. +}
  5199. +
  5200. +MIPS_MACHINE(AR71XX_MACH_RB_750, "750i", "MikroTik RouterBOARD 750",
  5201. + rb750_setup);
  5202. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-tew-632brp.c linux-2.6.35.7/arch/mips/ar71xx/mach-tew-632brp.c
  5203. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-tew-632brp.c 1970-01-01 01:00:00.000000000 +0100
  5204. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-tew-632brp.c 2010-10-14 20:27:57.916006386 +0200
  5205. @@ -0,0 +1,149 @@
  5206. +/*
  5207. + * TrendNET TEW-632BRP board support
  5208. + *
  5209. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  5210. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  5211. + *
  5212. + * This program is free software; you can redistribute it and/or modify it
  5213. + * under the terms of the GNU General Public License version 2 as published
  5214. + * by the Free Software Foundation.
  5215. + */
  5216. +
  5217. +#include <linux/mtd/mtd.h>
  5218. +#include <linux/mtd/partitions.h>
  5219. +
  5220. +#include <asm/mach-ar71xx/ar71xx.h>
  5221. +
  5222. +#include "machtype.h"
  5223. +#include "devices.h"
  5224. +#include "dev-m25p80.h"
  5225. +#include "dev-ar913x-wmac.h"
  5226. +#include "dev-gpio-buttons.h"
  5227. +#include "dev-leds-gpio.h"
  5228. +#include "nvram.h"
  5229. +
  5230. +#define TEW_632BRP_GPIO_LED_STATUS 1
  5231. +#define TEW_632BRP_GPIO_LED_WPS 3
  5232. +#define TEW_632BRP_GPIO_LED_WLAN 6
  5233. +#define TEW_632BRP_GPIO_BTN_WPS 12
  5234. +#define TEW_632BRP_GPIO_BTN_RESET 21
  5235. +
  5236. +#define TEW_632BRP_BUTTONS_POLL_INTERVAL 20
  5237. +
  5238. +#define TEW_632BRP_CONFIG_ADDR 0x1f020000
  5239. +#define TEW_632BRP_CONFIG_SIZE 0x10000
  5240. +
  5241. +#ifdef CONFIG_MTD_PARTITIONS
  5242. +static struct mtd_partition tew_632brp_partitions[] = {
  5243. + {
  5244. + .name = "u-boot",
  5245. + .offset = 0,
  5246. + .size = 0x020000,
  5247. + .mask_flags = MTD_WRITEABLE,
  5248. + } , {
  5249. + .name = "config",
  5250. + .offset = 0x020000,
  5251. + .size = 0x010000,
  5252. + } , {
  5253. + .name = "kernel",
  5254. + .offset = 0x030000,
  5255. + .size = 0x0d0000,
  5256. + } , {
  5257. + .name = "rootfs",
  5258. + .offset = 0x100000,
  5259. + .size = 0x2f0000,
  5260. + } , {
  5261. + .name = "art",
  5262. + .offset = 0x3f0000,
  5263. + .size = 0x010000,
  5264. + .mask_flags = MTD_WRITEABLE,
  5265. + } , {
  5266. + .name = "firmware",
  5267. + .offset = 0x030000,
  5268. + .size = 0x3c0000,
  5269. + }
  5270. +};
  5271. +#endif /* CONFIG_MTD_PARTITIONS */
  5272. +
  5273. +static struct flash_platform_data tew_632brp_flash_data = {
  5274. +#ifdef CONFIG_MTD_PARTITIONS
  5275. + .parts = tew_632brp_partitions,
  5276. + .nr_parts = ARRAY_SIZE(tew_632brp_partitions),
  5277. +#endif
  5278. +};
  5279. +
  5280. +static struct gpio_led tew_632brp_leds_gpio[] __initdata = {
  5281. + {
  5282. + .name = "tew-632brp:green:status",
  5283. + .gpio = TEW_632BRP_GPIO_LED_STATUS,
  5284. + .active_low = 1,
  5285. + }, {
  5286. + .name = "tew-632brp:blue:wps",
  5287. + .gpio = TEW_632BRP_GPIO_LED_WPS,
  5288. + .active_low = 1,
  5289. + }, {
  5290. + .name = "tew-632brp:green:wlan",
  5291. + .gpio = TEW_632BRP_GPIO_LED_WLAN,
  5292. + .active_low = 1,
  5293. + }
  5294. +};
  5295. +
  5296. +static struct gpio_button tew_632brp_gpio_buttons[] __initdata = {
  5297. + {
  5298. + .desc = "reset",
  5299. + .type = EV_KEY,
  5300. + .code = KEY_RESTART,
  5301. + .threshold = 3,
  5302. + .gpio = TEW_632BRP_GPIO_BTN_RESET,
  5303. + }, {
  5304. + .desc = "wps",
  5305. + .type = EV_KEY,
  5306. + .code = KEY_WPS_BUTTON,
  5307. + .threshold = 3,
  5308. + .gpio = TEW_632BRP_GPIO_BTN_WPS,
  5309. + }
  5310. +};
  5311. +
  5312. +#define TEW_632BRP_LAN_PHYMASK BIT(0)
  5313. +#define TEW_632BRP_WAN_PHYMASK BIT(4)
  5314. +#define TEW_632BRP_MDIO_MASK (~(TEW_632BRP_LAN_PHYMASK | \
  5315. + TEW_632BRP_WAN_PHYMASK))
  5316. +
  5317. +static void __init tew_632brp_setup(void)
  5318. +{
  5319. + const char *config = (char *) KSEG1ADDR(TEW_632BRP_CONFIG_ADDR);
  5320. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  5321. + u8 mac[6];
  5322. + u8 *wlan_mac = NULL;
  5323. +
  5324. + if (nvram_parse_mac_addr(config, TEW_632BRP_CONFIG_SIZE,
  5325. + "lan_mac=", mac) == 0) {
  5326. + ar71xx_set_mac_base(mac);
  5327. + wlan_mac = mac;
  5328. + }
  5329. +
  5330. + ar71xx_add_device_mdio(TEW_632BRP_MDIO_MASK);
  5331. +
  5332. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  5333. + ar71xx_eth0_data.phy_mask = TEW_632BRP_LAN_PHYMASK;
  5334. +
  5335. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  5336. + ar71xx_eth1_data.phy_mask = TEW_632BRP_WAN_PHYMASK;
  5337. +
  5338. + ar71xx_add_device_eth(0);
  5339. + ar71xx_add_device_eth(1);
  5340. +
  5341. + ar71xx_add_device_m25p80(&tew_632brp_flash_data);
  5342. +
  5343. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tew_632brp_leds_gpio),
  5344. + tew_632brp_leds_gpio);
  5345. +
  5346. + ar71xx_add_device_gpio_buttons(-1, TEW_632BRP_BUTTONS_POLL_INTERVAL,
  5347. + ARRAY_SIZE(tew_632brp_gpio_buttons),
  5348. + tew_632brp_gpio_buttons);
  5349. +
  5350. + ar913x_add_device_wmac(eeprom, wlan_mac);
  5351. +}
  5352. +
  5353. +MIPS_MACHINE(AR71XX_MACH_TEW_632BRP, "TEW-632BRP", "TRENDnet TEW-632BRP",
  5354. + tew_632brp_setup);
  5355. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-tl-wr1043nd.c linux-2.6.35.7/arch/mips/ar71xx/mach-tl-wr1043nd.c
  5356. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-tl-wr1043nd.c 1970-01-01 01:00:00.000000000 +0100
  5357. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-tl-wr1043nd.c 2010-10-14 20:27:57.964353043 +0200
  5358. @@ -0,0 +1,156 @@
  5359. +/*
  5360. + * TP-LINK TL-WR1043ND board support
  5361. + *
  5362. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  5363. + *
  5364. + * This program is free software; you can redistribute it and/or modify it
  5365. + * under the terms of the GNU General Public License version 2 as published
  5366. + * by the Free Software Foundation.
  5367. + */
  5368. +
  5369. +#include <linux/mtd/mtd.h>
  5370. +#include <linux/mtd/partitions.h>
  5371. +#include <linux/platform_device.h>
  5372. +#include <linux/rtl8366rb.h>
  5373. +#include <asm/mach-ar71xx/ar71xx.h>
  5374. +
  5375. +#include "machtype.h"
  5376. +#include "devices.h"
  5377. +#include "dev-m25p80.h"
  5378. +#include "dev-ar913x-wmac.h"
  5379. +#include "dev-gpio-buttons.h"
  5380. +#include "dev-leds-gpio.h"
  5381. +#include "dev-usb.h"
  5382. +
  5383. +#define TL_WR1043ND_GPIO_LED_USB 1
  5384. +#define TL_WR1043ND_GPIO_LED_SYSTEM 2
  5385. +#define TL_WR1043ND_GPIO_LED_QSS 5
  5386. +#define TL_WR1043ND_GPIO_LED_WLAN 9
  5387. +
  5388. +#define TL_WR1043ND_GPIO_BTN_RESET 3
  5389. +#define TL_WR1043ND_GPIO_BTN_QSS 7
  5390. +
  5391. +#define TL_WR1043ND_GPIO_RTL8366_SDA 18
  5392. +#define TL_WR1043ND_GPIO_RTL8366_SCK 19
  5393. +
  5394. +#define TL_WR1043ND_BUTTONS_POLL_INTERVAL 20
  5395. +
  5396. +#ifdef CONFIG_MTD_PARTITIONS
  5397. +static struct mtd_partition tl_wr1043nd_partitions[] = {
  5398. + {
  5399. + .name = "u-boot",
  5400. + .offset = 0,
  5401. + .size = 0x020000,
  5402. + .mask_flags = MTD_WRITEABLE,
  5403. + } , {
  5404. + .name = "kernel",
  5405. + .offset = 0x020000,
  5406. + .size = 0x140000,
  5407. + } , {
  5408. + .name = "rootfs",
  5409. + .offset = 0x160000,
  5410. + .size = 0x690000,
  5411. + } , {
  5412. + .name = "art",
  5413. + .offset = 0x7f0000,
  5414. + .size = 0x010000,
  5415. + .mask_flags = MTD_WRITEABLE,
  5416. + } , {
  5417. + .name = "firmware",
  5418. + .offset = 0x020000,
  5419. + .size = 0x7d0000,
  5420. + }
  5421. +};
  5422. +#endif /* CONFIG_MTD_PARTITIONS */
  5423. +
  5424. +static struct flash_platform_data tl_wr1043nd_flash_data = {
  5425. +#ifdef CONFIG_MTD_PARTITIONS
  5426. + .parts = tl_wr1043nd_partitions,
  5427. + .nr_parts = ARRAY_SIZE(tl_wr1043nd_partitions),
  5428. +#endif
  5429. +};
  5430. +
  5431. +static struct gpio_led tl_wr1043nd_leds_gpio[] __initdata = {
  5432. + {
  5433. + .name = "tl-wr1043nd:green:usb",
  5434. + .gpio = TL_WR1043ND_GPIO_LED_USB,
  5435. + .active_low = 1,
  5436. + }, {
  5437. + .name = "tl-wr1043nd:green:system",
  5438. + .gpio = TL_WR1043ND_GPIO_LED_SYSTEM,
  5439. + .active_low = 1,
  5440. + }, {
  5441. + .name = "tl-wr1043nd:green:qss",
  5442. + .gpio = TL_WR1043ND_GPIO_LED_QSS,
  5443. + .active_low = 0,
  5444. + }, {
  5445. + .name = "tl-wr1043nd:green:wlan",
  5446. + .gpio = TL_WR1043ND_GPIO_LED_WLAN,
  5447. + .active_low = 1,
  5448. + }
  5449. +};
  5450. +
  5451. +static struct gpio_button tl_wr1043nd_gpio_buttons[] __initdata = {
  5452. + {
  5453. + .desc = "reset",
  5454. + .type = EV_KEY,
  5455. + .code = KEY_RESTART,
  5456. + .threshold = 3,
  5457. + .gpio = TL_WR1043ND_GPIO_BTN_RESET,
  5458. + .active_low = 1,
  5459. + }, {
  5460. + .desc = "qss",
  5461. + .type = EV_KEY,
  5462. + .code = KEY_WPS_BUTTON,
  5463. + .threshold = 3,
  5464. + .gpio = TL_WR1043ND_GPIO_BTN_QSS,
  5465. + .active_low = 1,
  5466. + }
  5467. +};
  5468. +
  5469. +static struct rtl8366rb_platform_data tl_wr1043nd_rtl8366rb_data = {
  5470. + .gpio_sda = TL_WR1043ND_GPIO_RTL8366_SDA,
  5471. + .gpio_sck = TL_WR1043ND_GPIO_RTL8366_SCK,
  5472. +};
  5473. +
  5474. +static struct platform_device tl_wr1043nd_rtl8366rb_device = {
  5475. + .name = RTL8366RB_DRIVER_NAME,
  5476. + .id = -1,
  5477. + .dev = {
  5478. + .platform_data = &tl_wr1043nd_rtl8366rb_data,
  5479. + }
  5480. +};
  5481. +
  5482. +static void __init tl_wr1043nd_setup(void)
  5483. +{
  5484. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  5485. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  5486. +
  5487. + ar71xx_set_mac_base(mac);
  5488. +
  5489. + ar71xx_eth0_data.mii_bus_dev = &tl_wr1043nd_rtl8366rb_device.dev;
  5490. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  5491. + ar71xx_eth0_data.speed = SPEED_1000;
  5492. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  5493. + ar71xx_eth0_pll_data.pll_1000 = 0x1a000000;
  5494. +
  5495. + ar71xx_add_device_eth(0);
  5496. +
  5497. + ar71xx_add_device_usb();
  5498. +
  5499. + ar71xx_add_device_m25p80(&tl_wr1043nd_flash_data);
  5500. +
  5501. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr1043nd_leds_gpio),
  5502. + tl_wr1043nd_leds_gpio);
  5503. +
  5504. + platform_device_register(&tl_wr1043nd_rtl8366rb_device);
  5505. +
  5506. + ar71xx_add_device_gpio_buttons(-1, TL_WR1043ND_BUTTONS_POLL_INTERVAL,
  5507. + ARRAY_SIZE(tl_wr1043nd_gpio_buttons),
  5508. + tl_wr1043nd_gpio_buttons);
  5509. +
  5510. + ar913x_add_device_wmac(eeprom, mac);
  5511. +}
  5512. +
  5513. +MIPS_MACHINE(AR71XX_MACH_TL_WR1043ND, "TL-WR1043ND", "TP-LINK TL-WR1043ND",
  5514. + tl_wr1043nd_setup);
  5515. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-tl-wr741nd.c linux-2.6.35.7/arch/mips/ar71xx/mach-tl-wr741nd.c
  5516. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-tl-wr741nd.c 1970-01-01 01:00:00.000000000 +0100
  5517. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-tl-wr741nd.c 2010-10-14 20:27:58.005601016 +0200
  5518. @@ -0,0 +1,115 @@
  5519. +/*
  5520. + * TP-LINK TL-WR741ND board support
  5521. + *
  5522. + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  5523. + *
  5524. + * This program is free software; you can redistribute it and/or modify it
  5525. + * under the terms of the GNU General Public License version 2 as published
  5526. + * by the Free Software Foundation.
  5527. + */
  5528. +
  5529. +#include <linux/mtd/mtd.h>
  5530. +#include <linux/mtd/partitions.h>
  5531. +
  5532. +#include <asm/mach-ar71xx/ar71xx.h>
  5533. +
  5534. +#include "machtype.h"
  5535. +#include "devices.h"
  5536. +#include "dev-m25p80.h"
  5537. +#include "dev-ap91-eth.h"
  5538. +#include "dev-ap91-pci.h"
  5539. +#include "dev-gpio-buttons.h"
  5540. +#include "dev-leds-gpio.h"
  5541. +
  5542. +#define TL_WR741ND_GPIO_LED_QSS 0
  5543. +#define TL_WR741ND_GPIO_LED_SYSTEM 1
  5544. +
  5545. +#define TL_WR741ND_GPIO_BTN_RESET 11
  5546. +#define TL_WR741ND_GPIO_BTN_QSS 12
  5547. +
  5548. +#define TL_WR741ND_BUTTONS_POLL_INTERVAL 20
  5549. +
  5550. +#ifdef CONFIG_MTD_PARTITIONS
  5551. +static struct mtd_partition tl_wr741nd_partitions[] = {
  5552. + {
  5553. + .name = "u-boot",
  5554. + .offset = 0,
  5555. + .size = 0x020000,
  5556. + .mask_flags = MTD_WRITEABLE,
  5557. + } , {
  5558. + .name = "kernel",
  5559. + .offset = 0x020000,
  5560. + .size = 0x140000,
  5561. + } , {
  5562. + .name = "rootfs",
  5563. + .offset = 0x160000,
  5564. + .size = 0x290000,
  5565. + } , {
  5566. + .name = "art",
  5567. + .offset = 0x3f0000,
  5568. + .size = 0x010000,
  5569. + .mask_flags = MTD_WRITEABLE,
  5570. + } , {
  5571. + .name = "firmware",
  5572. + .offset = 0x020000,
  5573. + .size = 0x3d0000,
  5574. + }
  5575. +};
  5576. +#endif /* CONFIG_MTD_PARTITIONS */
  5577. +
  5578. +static struct flash_platform_data tl_wr741nd_flash_data = {
  5579. +#ifdef CONFIG_MTD_PARTITIONS
  5580. + .parts = tl_wr741nd_partitions,
  5581. + .nr_parts = ARRAY_SIZE(tl_wr741nd_partitions),
  5582. +#endif
  5583. +};
  5584. +
  5585. +static struct gpio_led tl_wr741nd_leds_gpio[] __initdata = {
  5586. + {
  5587. + .name = "tl-wr741nd:green:system",
  5588. + .gpio = TL_WR741ND_GPIO_LED_SYSTEM,
  5589. + .active_low = 1,
  5590. + }, {
  5591. + .name = "tl-wr741nd:green:qss",
  5592. + .gpio = TL_WR741ND_GPIO_LED_QSS,
  5593. + .active_low = 1,
  5594. + }
  5595. +};
  5596. +
  5597. +static struct gpio_button tl_wr741nd_gpio_buttons[] __initdata = {
  5598. + {
  5599. + .desc = "reset",
  5600. + .type = EV_KEY,
  5601. + .code = KEY_RESTART,
  5602. + .threshold = 3,
  5603. + .gpio = TL_WR741ND_GPIO_BTN_RESET,
  5604. + .active_low = 1,
  5605. + }, {
  5606. + .desc = "qss",
  5607. + .type = EV_KEY,
  5608. + .code = KEY_WPS_BUTTON,
  5609. + .threshold = 3,
  5610. + .gpio = TL_WR741ND_GPIO_BTN_QSS,
  5611. + .active_low = 1,
  5612. + }
  5613. +};
  5614. +
  5615. +static void __init tl_wr741nd_setup(void)
  5616. +{
  5617. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  5618. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  5619. +
  5620. + ar71xx_add_device_m25p80(&tl_wr741nd_flash_data);
  5621. +
  5622. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr741nd_leds_gpio),
  5623. + tl_wr741nd_leds_gpio);
  5624. +
  5625. + ar71xx_add_device_gpio_buttons(-1, TL_WR741ND_BUTTONS_POLL_INTERVAL,
  5626. + ARRAY_SIZE(tl_wr741nd_gpio_buttons),
  5627. + tl_wr741nd_gpio_buttons);
  5628. +
  5629. + ap91_eth_init(mac, NULL);
  5630. + ap91_pci_init(ee, mac);
  5631. +}
  5632. +MIPS_MACHINE(AR71XX_MACH_TL_WR741ND, "TL-WR741ND", "TP-LINK TL-WR741ND",
  5633. + tl_wr741nd_setup);
  5634. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-tl-wr841n.c linux-2.6.35.7/arch/mips/ar71xx/mach-tl-wr841n.c
  5635. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-tl-wr841n.c 1970-01-01 01:00:00.000000000 +0100
  5636. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-tl-wr841n.c 2010-10-14 20:27:58.057141646 +0200
  5637. @@ -0,0 +1,143 @@
  5638. +/*
  5639. + * TP-LINK TL-WR841N board support
  5640. + *
  5641. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  5642. + *
  5643. + * This program is free software; you can redistribute it and/or modify it
  5644. + * under the terms of the GNU General Public License version 2 as published
  5645. + * by the Free Software Foundation.
  5646. + */
  5647. +
  5648. +#include <linux/mtd/mtd.h>
  5649. +#include <linux/mtd/partitions.h>
  5650. +
  5651. +#include <asm/mach-ar71xx/ar71xx.h>
  5652. +
  5653. +#include "machtype.h"
  5654. +#include "devices.h"
  5655. +#include "dev-dsa.h"
  5656. +#include "dev-m25p80.h"
  5657. +#include "dev-gpio-buttons.h"
  5658. +#include "dev-pb42-pci.h"
  5659. +#include "dev-leds-gpio.h"
  5660. +
  5661. +#define TL_WR841ND_V1_GPIO_LED_SYSTEM 2
  5662. +#define TL_WR841ND_V1_GPIO_LED_QSS_GREEN 4
  5663. +#define TL_WR841ND_V1_GPIO_LED_QSS_RED 5
  5664. +
  5665. +#define TL_WR841ND_V1_GPIO_BTN_RESET 3
  5666. +#define TL_WR841ND_V1_GPIO_BTN_QSS 7
  5667. +
  5668. +#define TL_WR841ND_V1_BUTTONS_POLL_INTERVAL 20
  5669. +
  5670. +#ifdef CONFIG_MTD_PARTITIONS
  5671. +static struct mtd_partition tl_wr841n_v1_partitions[] = {
  5672. + {
  5673. + .name = "redboot",
  5674. + .offset = 0,
  5675. + .size = 0x020000,
  5676. + .mask_flags = MTD_WRITEABLE,
  5677. + } , {
  5678. + .name = "kernel",
  5679. + .offset = 0x020000,
  5680. + .size = 0x140000,
  5681. + } , {
  5682. + .name = "rootfs",
  5683. + .offset = 0x160000,
  5684. + .size = 0x280000,
  5685. + } , {
  5686. + .name = "config",
  5687. + .offset = 0x3e0000,
  5688. + .size = 0x020000,
  5689. + .mask_flags = MTD_WRITEABLE,
  5690. + } , {
  5691. + .name = "firmware",
  5692. + .offset = 0x020000,
  5693. + .size = 0x3c0000,
  5694. + }
  5695. +};
  5696. +#endif /* CONFIG_MTD_PARTITIONS */
  5697. +
  5698. +static struct flash_platform_data tl_wr841n_v1_flash_data = {
  5699. +#ifdef CONFIG_MTD_PARTITIONS
  5700. + .parts = tl_wr841n_v1_partitions,
  5701. + .nr_parts = ARRAY_SIZE(tl_wr841n_v1_partitions),
  5702. +#endif
  5703. +};
  5704. +
  5705. +static struct gpio_led tl_wr841n_v1_leds_gpio[] __initdata = {
  5706. + {
  5707. + .name = "tl-wr841n:green:system",
  5708. + .gpio = TL_WR841ND_V1_GPIO_LED_SYSTEM,
  5709. + .active_low = 1,
  5710. + }, {
  5711. + .name = "tl-wr841n:red:qss",
  5712. + .gpio = TL_WR841ND_V1_GPIO_LED_QSS_RED,
  5713. + }, {
  5714. + .name = "tl-wr841n:green:qss",
  5715. + .gpio = TL_WR841ND_V1_GPIO_LED_QSS_GREEN,
  5716. + }
  5717. +};
  5718. +
  5719. +static struct gpio_button tl_wr841n_v1_gpio_buttons[] __initdata = {
  5720. + {
  5721. + .desc = "reset",
  5722. + .type = EV_KEY,
  5723. + .code = KEY_RESTART,
  5724. + .threshold = 3,
  5725. + .gpio = TL_WR841ND_V1_GPIO_BTN_RESET,
  5726. + .active_low = 1,
  5727. + }, {
  5728. + .desc = "qss",
  5729. + .type = EV_KEY,
  5730. + .code = KEY_WPS_BUTTON,
  5731. + .threshold = 3,
  5732. + .gpio = TL_WR841ND_V1_GPIO_BTN_QSS,
  5733. + .active_low = 1,
  5734. + }
  5735. +};
  5736. +
  5737. +static struct dsa_chip_data tl_wr841n_v1_dsa_chip = {
  5738. + .port_names[0] = "wan",
  5739. + .port_names[1] = "lan1",
  5740. + .port_names[2] = "lan2",
  5741. + .port_names[3] = "lan3",
  5742. + .port_names[4] = "lan4",
  5743. + .port_names[5] = "cpu",
  5744. +};
  5745. +
  5746. +static struct dsa_platform_data tl_wr841n_v1_dsa_data = {
  5747. + .nr_chips = 1,
  5748. + .chip = &tl_wr841n_v1_dsa_chip,
  5749. +};
  5750. +
  5751. +static void __init tl_wr841n_v1_setup(void)
  5752. +{
  5753. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  5754. +
  5755. + ar71xx_set_mac_base(mac);
  5756. +
  5757. + ar71xx_add_device_mdio(0x0);
  5758. +
  5759. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  5760. + ar71xx_eth0_data.speed = SPEED_100;
  5761. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  5762. +
  5763. + ar71xx_add_device_eth(0);
  5764. +
  5765. + ar71xx_add_device_dsa(0, &tl_wr841n_v1_dsa_data);
  5766. +
  5767. + ar71xx_add_device_m25p80(&tl_wr841n_v1_flash_data);
  5768. +
  5769. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v1_leds_gpio),
  5770. + tl_wr841n_v1_leds_gpio);
  5771. +
  5772. + ar71xx_add_device_gpio_buttons(-1, TL_WR841ND_V1_BUTTONS_POLL_INTERVAL,
  5773. + ARRAY_SIZE(tl_wr841n_v1_gpio_buttons),
  5774. + tl_wr841n_v1_gpio_buttons);
  5775. +
  5776. + pb42_pci_init();
  5777. +}
  5778. +
  5779. +MIPS_MACHINE(AR71XX_MACH_TL_WR841N_V1, "TL-WR841N-v1.5", "TP-LINK TL-WR841N v1",
  5780. + tl_wr841n_v1_setup);
  5781. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-tl-wr941nd.c linux-2.6.35.7/arch/mips/ar71xx/mach-tl-wr941nd.c
  5782. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-tl-wr941nd.c 1970-01-01 01:00:00.000000000 +0100
  5783. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-tl-wr941nd.c 2010-10-14 20:27:58.095601080 +0200
  5784. @@ -0,0 +1,142 @@
  5785. +/*
  5786. + * TP-LINK TL-WR941ND board support
  5787. + *
  5788. + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  5789. + *
  5790. + * This program is free software; you can redistribute it and/or modify it
  5791. + * under the terms of the GNU General Public License version 2 as published
  5792. + * by the Free Software Foundation.
  5793. + */
  5794. +
  5795. +#include <linux/mtd/mtd.h>
  5796. +#include <linux/mtd/partitions.h>
  5797. +
  5798. +#include <asm/mach-ar71xx/ar71xx.h>
  5799. +
  5800. +#include "machtype.h"
  5801. +#include "devices.h"
  5802. +#include "dev-dsa.h"
  5803. +#include "dev-m25p80.h"
  5804. +#include "dev-ar913x-wmac.h"
  5805. +#include "dev-gpio-buttons.h"
  5806. +#include "dev-leds-gpio.h"
  5807. +
  5808. +#define TL_WR941ND_GPIO_LED_SYSTEM 2
  5809. +#define TL_WR941ND_GPIO_LED_QSS_RED 4
  5810. +#define TL_WR941ND_GPIO_LED_QSS_GREEN 5
  5811. +
  5812. +#define TL_WR941ND_GPIO_BTN_RESET 3
  5813. +#define TL_WR941ND_GPIO_BTN_QSS 7
  5814. +
  5815. +#define TL_WR941ND_BUTTONS_POLL_INTERVAL 20
  5816. +
  5817. +#ifdef CONFIG_MTD_PARTITIONS
  5818. +static struct mtd_partition tl_wr941nd_partitions[] = {
  5819. + {
  5820. + .name = "u-boot",
  5821. + .offset = 0,
  5822. + .size = 0x020000,
  5823. + .mask_flags = MTD_WRITEABLE,
  5824. + } , {
  5825. + .name = "kernel",
  5826. + .offset = 0x020000,
  5827. + .size = 0x140000,
  5828. + } , {
  5829. + .name = "rootfs",
  5830. + .offset = 0x160000,
  5831. + .size = 0x290000,
  5832. + } , {
  5833. + .name = "art",
  5834. + .offset = 0x3f0000,
  5835. + .size = 0x010000,
  5836. + .mask_flags = MTD_WRITEABLE,
  5837. + } , {
  5838. + .name = "firmware",
  5839. + .offset = 0x020000,
  5840. + .size = 0x3d0000,
  5841. + }
  5842. +};
  5843. +#endif /* CONFIG_MTD_PARTITIONS */
  5844. +
  5845. +static struct flash_platform_data tl_wr941nd_flash_data = {
  5846. +#ifdef CONFIG_MTD_PARTITIONS
  5847. + .parts = tl_wr941nd_partitions,
  5848. + .nr_parts = ARRAY_SIZE(tl_wr941nd_partitions),
  5849. +#endif
  5850. +};
  5851. +
  5852. +static struct gpio_led tl_wr941nd_leds_gpio[] __initdata = {
  5853. + {
  5854. + .name = "tl-wr941nd:green:system",
  5855. + .gpio = TL_WR941ND_GPIO_LED_SYSTEM,
  5856. + .active_low = 1,
  5857. + }, {
  5858. + .name = "tl-wr941nd:red:qss",
  5859. + .gpio = TL_WR941ND_GPIO_LED_QSS_RED,
  5860. + }, {
  5861. + .name = "tl-wr941nd:green:qss",
  5862. + .gpio = TL_WR941ND_GPIO_LED_QSS_GREEN,
  5863. + }
  5864. +};
  5865. +
  5866. +static struct gpio_button tl_wr941nd_gpio_buttons[] __initdata = {
  5867. + {
  5868. + .desc = "reset",
  5869. + .type = EV_KEY,
  5870. + .code = KEY_RESTART,
  5871. + .threshold = 3,
  5872. + .gpio = TL_WR941ND_GPIO_BTN_RESET,
  5873. + .active_low = 1,
  5874. + }, {
  5875. + .desc = "qss",
  5876. + .type = EV_KEY,
  5877. + .code = KEY_WPS_BUTTON,
  5878. + .threshold = 3,
  5879. + .gpio = TL_WR941ND_GPIO_BTN_QSS,
  5880. + .active_low = 1,
  5881. + }
  5882. +};
  5883. +
  5884. +static struct dsa_chip_data tl_wr941nd_dsa_chip = {
  5885. + .port_names[0] = "wan",
  5886. + .port_names[1] = "lan1",
  5887. + .port_names[2] = "lan2",
  5888. + .port_names[3] = "lan3",
  5889. + .port_names[4] = "lan4",
  5890. + .port_names[5] = "cpu",
  5891. +};
  5892. +
  5893. +static struct dsa_platform_data tl_wr941nd_dsa_data = {
  5894. + .nr_chips = 1,
  5895. + .chip = &tl_wr941nd_dsa_chip,
  5896. +};
  5897. +
  5898. +static void __init tl_wr941nd_setup(void)
  5899. +{
  5900. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  5901. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  5902. +
  5903. + ar71xx_set_mac_base(mac);
  5904. +
  5905. + ar71xx_add_device_mdio(0x0);
  5906. +
  5907. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  5908. + ar71xx_eth0_data.speed = SPEED_100;
  5909. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  5910. +
  5911. + ar71xx_add_device_eth(0);
  5912. + ar71xx_add_device_dsa(0, &tl_wr941nd_dsa_data);
  5913. +
  5914. + ar71xx_add_device_m25p80(&tl_wr941nd_flash_data);
  5915. +
  5916. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr941nd_leds_gpio),
  5917. + tl_wr941nd_leds_gpio);
  5918. +
  5919. + ar71xx_add_device_gpio_buttons(-1, TL_WR941ND_BUTTONS_POLL_INTERVAL,
  5920. + ARRAY_SIZE(tl_wr941nd_gpio_buttons),
  5921. + tl_wr941nd_gpio_buttons);
  5922. + ar913x_add_device_wmac(eeprom, mac);
  5923. +}
  5924. +
  5925. +MIPS_MACHINE(AR71XX_MACH_TL_WR941ND, "TL-WR941ND", "TP-LINK TL-WR941ND",
  5926. + tl_wr941nd_setup);
  5927. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/machtype.h linux-2.6.35.7/arch/mips/ar71xx/machtype.h
  5928. --- linux-2.6.35.7.orig/arch/mips/ar71xx/machtype.h 1970-01-01 01:00:00.000000000 +0100
  5929. +++ linux-2.6.35.7/arch/mips/ar71xx/machtype.h 2010-10-14 20:27:58.135601194 +0200
  5930. @@ -0,0 +1,60 @@
  5931. +/*
  5932. + * Atheros AR71xx machine type definitions
  5933. + *
  5934. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  5935. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  5936. + *
  5937. + * This program is free software; you can redistribute it and/or modify it
  5938. + * under the terms of the GNU General Public License version 2 as published
  5939. + * by the Free Software Foundation.
  5940. + */
  5941. +
  5942. +#ifndef _AR71XX_MACHTYPE_H
  5943. +#define _AR71XX_MACHTYPE_H
  5944. +
  5945. +#include <asm/mips_machine.h>
  5946. +
  5947. +enum ar71xx_mach_type {
  5948. + AR71XX_MACH_GENERIC = 0,
  5949. + AR71XX_MACH_AP81, /* Atheros AP81 */
  5950. + AR71XX_MACH_AP83, /* Atheros AP83 */
  5951. + AR71XX_MACH_AW_NR580, /* AzureWave AW-NR580 */
  5952. + AR71XX_MACH_DIR_600_A1, /* D-Link DIR-600 rev. A1 */
  5953. + AR71XX_MACH_DIR_615_C1, /* D-Link DIR-615 rev. C1 */
  5954. + AR71XX_MACH_DIR_825_B1, /* D-Link DIR-825 rev. B1 */
  5955. + AR71XX_MACH_RB_411, /* MikroTik RouterBOARD 411/411A/411AH */
  5956. + AR71XX_MACH_RB_411U, /* MikroTik RouterBOARD 411U */
  5957. + AR71XX_MACH_RB_433, /* MikroTik RouterBOARD 433/433AH */
  5958. + AR71XX_MACH_RB_433U, /* MikroTik RouterBOARD 433UAH */
  5959. + AR71XX_MACH_RB_450, /* MikroTik RouterBOARD 450 */
  5960. + AR71XX_MACH_RB_450G, /* MikroTik RouterBOARD 450G */
  5961. + AR71XX_MACH_RB_493, /* Mikrotik RouterBOARD 493/493AH */
  5962. + AR71XX_MACH_RB_750, /* MikroTik RouterBOARD 750 */
  5963. + AR71XX_MACH_PB42, /* Atheros PB42 */
  5964. + AR71XX_MACH_PB44, /* Atheros PB44 */
  5965. + AR71XX_MACH_PB92, /* Atheros PB92 */
  5966. + AR71XX_MACH_MZK_W04NU, /* Planex MZK-W04NU */
  5967. + AR71XX_MACH_MZK_W300NH, /* Planex MZK-W300NH */
  5968. + AR71XX_MACH_NBG460N, /* Zyxel NBG460N/550N/550NH */
  5969. + AR71XX_MACH_TEW_632BRP, /* TRENDnet TEW-632BRP */
  5970. + AR71XX_MACH_TL_WR741ND, /* TP-LINK TL-WR741ND */
  5971. + AR71XX_MACH_TL_WR841N_V1, /* TP-LINK TL-WR841N v1 */
  5972. + AR71XX_MACH_TL_WR941ND, /* TP-LINK TL-WR941ND */
  5973. + AR71XX_MACH_TL_WR1043ND, /* TP-LINK TL-WR1041ND */
  5974. + AR71XX_MACH_UBNT_LSSR71, /* Ubiquiti LS-SR71 */
  5975. + AR71XX_MACH_UBNT_LSX, /* Ubiquiti LSX */
  5976. + AR71XX_MACH_UBNT_RS, /* Ubiquiti RouterStation */
  5977. + AR71XX_MACH_UBNT_AR71XX, /* Ubiquiti AR71xx-based board */
  5978. + AR71XX_MACH_UBNT_RSPRO, /* Ubiquiti RouterStation Pro */
  5979. + AR71XX_MACH_UBNT_BULLET_M, /* Ubiquiti Bullet M */
  5980. + AR71XX_MACH_UBNT_ROCKET_M, /* Ubiquiti Rocket M */
  5981. + AR71XX_MACH_UBNT_NANO_M, /* Ubiquiti NanoStation M */
  5982. + AR71XX_MACH_WNDR3700, /* NETGEAR WNDR3700 */
  5983. + AR71XX_MACH_WNR2000, /* NETGEAR WNR2000 */
  5984. + AR71XX_MACH_WP543, /* Compex WP543 */
  5985. + AR71XX_MACH_WRT160NL, /* Linksys WRT160NL */
  5986. + AR71XX_MACH_WRT400N, /* Linksys WRT400N */
  5987. + AR71XX_MACH_WZR_HP_G300NH, /* Buffalo WZR-HP-G300NH */
  5988. +};
  5989. +
  5990. +#endif /* _AR71XX_MACHTYPE_H */
  5991. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-ubnt.c linux-2.6.35.7/arch/mips/ar71xx/mach-ubnt.c
  5992. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-ubnt.c 1970-01-01 01:00:00.000000000 +0100
  5993. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-ubnt.c 2010-10-14 20:27:58.190029906 +0200
  5994. @@ -0,0 +1,281 @@
  5995. +/*
  5996. + * Ubiquiti RouterStation support
  5997. + *
  5998. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  5999. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  6000. + * Copyright (C) 2008 Ubiquiti <support@ubnt.com>
  6001. + *
  6002. + * This program is free software; you can redistribute it and/or modify it
  6003. + * under the terms of the GNU General Public License version 2 as published
  6004. + * by the Free Software Foundation.
  6005. + */
  6006. +
  6007. +#include <asm/mach-ar71xx/ar71xx.h>
  6008. +
  6009. +#include "machtype.h"
  6010. +#include "devices.h"
  6011. +#include "dev-m25p80.h"
  6012. +#include "dev-ap91-pci.h"
  6013. +#include "dev-gpio-buttons.h"
  6014. +#include "dev-pb42-pci.h"
  6015. +#include "dev-leds-gpio.h"
  6016. +#include "dev-usb.h"
  6017. +
  6018. +#define UBNT_RS_GPIO_LED_RF 2
  6019. +#define UBNT_RS_GPIO_SW4 8
  6020. +
  6021. +#define UBNT_LS_SR71_GPIO_LED_D25 0
  6022. +#define UBNT_LS_SR71_GPIO_LED_D26 1
  6023. +#define UBNT_LS_SR71_GPIO_LED_D24 2
  6024. +#define UBNT_LS_SR71_GPIO_LED_D23 4
  6025. +#define UBNT_LS_SR71_GPIO_LED_D22 5
  6026. +#define UBNT_LS_SR71_GPIO_LED_D27 6
  6027. +#define UBNT_LS_SR71_GPIO_LED_D28 7
  6028. +
  6029. +#define UBNT_M_GPIO_LED_L1 0
  6030. +#define UBNT_M_GPIO_LED_L2 1
  6031. +#define UBNT_M_GPIO_LED_L3 11
  6032. +#define UBNT_M_GPIO_LED_L4 7
  6033. +#define UBNT_M_GPIO_BTN_RESET 12
  6034. +
  6035. +#define UBNT_BUTTONS_POLL_INTERVAL 20
  6036. +
  6037. +static struct gpio_led ubnt_rs_leds_gpio[] __initdata = {
  6038. + {
  6039. + .name = "ubnt:green:rf",
  6040. + .gpio = UBNT_RS_GPIO_LED_RF,
  6041. + .active_low = 0,
  6042. + }
  6043. +};
  6044. +
  6045. +static struct gpio_led ubnt_ls_sr71_leds_gpio[] __initdata = {
  6046. + {
  6047. + .name = "ubnt:green:d22",
  6048. + .gpio = UBNT_LS_SR71_GPIO_LED_D22,
  6049. + .active_low = 0,
  6050. + }, {
  6051. + .name = "ubnt:green:d23",
  6052. + .gpio = UBNT_LS_SR71_GPIO_LED_D23,
  6053. + .active_low = 0,
  6054. + }, {
  6055. + .name = "ubnt:green:d24",
  6056. + .gpio = UBNT_LS_SR71_GPIO_LED_D24,
  6057. + .active_low = 0,
  6058. + }, {
  6059. + .name = "ubnt:red:d25",
  6060. + .gpio = UBNT_LS_SR71_GPIO_LED_D25,
  6061. + .active_low = 0,
  6062. + }, {
  6063. + .name = "ubnt:red:d26",
  6064. + .gpio = UBNT_LS_SR71_GPIO_LED_D26,
  6065. + .active_low = 0,
  6066. + }, {
  6067. + .name = "ubnt:green:d27",
  6068. + .gpio = UBNT_LS_SR71_GPIO_LED_D27,
  6069. + .active_low = 0,
  6070. + }, {
  6071. + .name = "ubnt:green:d28",
  6072. + .gpio = UBNT_LS_SR71_GPIO_LED_D28,
  6073. + .active_low = 0,
  6074. + }
  6075. +};
  6076. +
  6077. +static struct gpio_led ubnt_m_leds_gpio[] __initdata = {
  6078. + {
  6079. + .name = "ubnt:red:link1",
  6080. + .gpio = UBNT_M_GPIO_LED_L1,
  6081. + .active_low = 0,
  6082. + }, {
  6083. + .name = "ubnt:orange:link2",
  6084. + .gpio = UBNT_M_GPIO_LED_L2,
  6085. + .active_low = 0,
  6086. + }, {
  6087. + .name = "ubnt:green:link3",
  6088. + .gpio = UBNT_M_GPIO_LED_L3,
  6089. + .active_low = 0,
  6090. + }, {
  6091. + .name = "ubnt:green:link4",
  6092. + .gpio = UBNT_M_GPIO_LED_L4,
  6093. + .active_low = 0,
  6094. + }
  6095. +};
  6096. +
  6097. +static struct gpio_button ubnt_gpio_buttons[] __initdata = {
  6098. + {
  6099. + .desc = "sw4",
  6100. + .type = EV_KEY,
  6101. + .code = KEY_RESTART,
  6102. + .threshold = 3,
  6103. + .gpio = UBNT_RS_GPIO_SW4,
  6104. + .active_low = 1,
  6105. + }
  6106. +};
  6107. +
  6108. +static struct gpio_button ubnt_m_gpio_buttons[] __initdata = {
  6109. + {
  6110. + .desc = "reset",
  6111. + .type = EV_KEY,
  6112. + .code = KEY_RESTART,
  6113. + .threshold = 3,
  6114. + .gpio = UBNT_M_GPIO_BTN_RESET,
  6115. + .active_low = 1,
  6116. + }
  6117. +};
  6118. +
  6119. +static void __init ubnt_generic_setup(void)
  6120. +{
  6121. + ar71xx_add_device_m25p80(NULL);
  6122. +
  6123. + ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL,
  6124. + ARRAY_SIZE(ubnt_gpio_buttons),
  6125. + ubnt_gpio_buttons);
  6126. +
  6127. + pb42_pci_init();
  6128. +}
  6129. +
  6130. +#define UBNT_RS_WAN_PHYMASK (1 << 20)
  6131. +#define UBNT_RS_LAN_PHYMASK ((1 << 16) | (1 << 17) | (1 << 18) | (1 << 19))
  6132. +
  6133. +static void __init ubnt_rs_setup(void)
  6134. +{
  6135. + ubnt_generic_setup();
  6136. +
  6137. + ar71xx_add_device_mdio(~(UBNT_RS_WAN_PHYMASK | UBNT_RS_LAN_PHYMASK));
  6138. +
  6139. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  6140. + ar71xx_eth0_data.phy_mask = UBNT_RS_WAN_PHYMASK;
  6141. +
  6142. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  6143. + ar71xx_eth1_data.speed = SPEED_100;
  6144. + ar71xx_eth1_data.duplex = DUPLEX_FULL;
  6145. +
  6146. + ar71xx_add_device_eth(0);
  6147. + ar71xx_add_device_eth(1);
  6148. +
  6149. + ar71xx_add_device_usb();
  6150. +
  6151. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
  6152. + ubnt_rs_leds_gpio);
  6153. +}
  6154. +
  6155. +MIPS_MACHINE(AR71XX_MACH_UBNT_RS, "UBNT-RS", "Ubiquiti RouterStation",
  6156. + ubnt_rs_setup);
  6157. +
  6158. +MIPS_MACHINE(AR71XX_MACH_UBNT_AR71XX, "Ubiquiti AR71xx-based board",
  6159. + "Ubiquiti RouterStation", ubnt_rs_setup);
  6160. +
  6161. +#define UBNT_RSPRO_WAN_PHYMASK (1 << 4)
  6162. +#define UBNT_RSPRO_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3))
  6163. +
  6164. +static void __init ubnt_rspro_setup(void)
  6165. +{
  6166. + ubnt_generic_setup();
  6167. +
  6168. + ar71xx_add_device_mdio(~(UBNT_RSPRO_WAN_PHYMASK | UBNT_RSPRO_LAN_PHYMASK));
  6169. +
  6170. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  6171. + ar71xx_eth0_data.phy_mask = UBNT_RSPRO_WAN_PHYMASK;
  6172. +
  6173. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  6174. + ar71xx_eth1_data.phy_mask = UBNT_RSPRO_LAN_PHYMASK;
  6175. + ar71xx_eth1_data.speed = SPEED_1000;
  6176. + ar71xx_eth1_data.duplex = DUPLEX_FULL;
  6177. +
  6178. + ar71xx_add_device_eth(0);
  6179. + ar71xx_add_device_eth(1);
  6180. +
  6181. + ar71xx_add_device_usb();
  6182. +
  6183. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
  6184. + ubnt_rs_leds_gpio);
  6185. +}
  6186. +
  6187. +MIPS_MACHINE(AR71XX_MACH_UBNT_RSPRO, "UBNT-RSPRO", "Ubiquiti RouterStation Pro",
  6188. + ubnt_rspro_setup);
  6189. +
  6190. +static void __init ubnt_lsx_setup(void)
  6191. +{
  6192. + ubnt_generic_setup();
  6193. +}
  6194. +
  6195. +MIPS_MACHINE(AR71XX_MACH_UBNT_LSX, "UBNT-LSX", "Ubiquiti LSX", ubnt_lsx_setup);
  6196. +
  6197. +#define UBNT_LSSR71_PHY_MASK (1 << 1)
  6198. +
  6199. +static void __init ubnt_lssr71_setup(void)
  6200. +{
  6201. + ubnt_generic_setup();
  6202. +
  6203. + ar71xx_add_device_mdio(~UBNT_LSSR71_PHY_MASK);
  6204. +
  6205. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  6206. + ar71xx_eth0_data.phy_mask = UBNT_LSSR71_PHY_MASK;
  6207. +
  6208. + ar71xx_add_device_eth(0);
  6209. +
  6210. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_ls_sr71_leds_gpio),
  6211. + ubnt_ls_sr71_leds_gpio);
  6212. +}
  6213. +
  6214. +MIPS_MACHINE(AR71XX_MACH_UBNT_LSSR71, "UBNT-LS-SR71", "Ubiquiti LS-SR71",
  6215. + ubnt_lssr71_setup);
  6216. +
  6217. +static void __init ubnt_m_setup(void)
  6218. +{
  6219. + u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
  6220. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  6221. +
  6222. + ar71xx_set_mac_base(mac);
  6223. +
  6224. + ar71xx_add_device_m25p80(NULL);
  6225. +
  6226. + ar71xx_add_device_mdio(~0);
  6227. +
  6228. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  6229. + ar71xx_eth0_data.speed = SPEED_100;
  6230. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  6231. + ar71xx_eth0_data.fifo_cfg1 = 0x0010ffff;
  6232. + ar71xx_eth0_data.fifo_cfg2 = 0x015500aa;
  6233. + ar71xx_eth0_data.fifo_cfg3 = 0x01f00140;
  6234. +
  6235. + ar71xx_add_device_eth(0);
  6236. +
  6237. + ap91_pci_init(ee, NULL);
  6238. +
  6239. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_m_leds_gpio),
  6240. + ubnt_m_leds_gpio);
  6241. +
  6242. + ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL,
  6243. + ARRAY_SIZE(ubnt_m_gpio_buttons),
  6244. + ubnt_m_gpio_buttons);
  6245. +}
  6246. +
  6247. +static void __init ubnt_rocket_m_setup(void)
  6248. +{
  6249. + ubnt_m_setup();
  6250. + ar71xx_add_device_usb();
  6251. +}
  6252. +
  6253. +MIPS_MACHINE(AR71XX_MACH_UBNT_BULLET_M, "UBNT-BM", "Ubiquiti Bullet M",
  6254. + ubnt_m_setup);
  6255. +MIPS_MACHINE(AR71XX_MACH_UBNT_ROCKET_M, "UBNT-RM", "Ubiquiti Rocket M",
  6256. + ubnt_rocket_m_setup);
  6257. +
  6258. +/* TODO detect the second ethernet port and use one
  6259. + init function for all Ubiquiti MIMO series products */
  6260. +static void __init ubnt_nano_m_setup(void)
  6261. +{
  6262. + ubnt_m_setup();
  6263. +
  6264. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  6265. + ar71xx_eth1_data.speed = SPEED_1000;
  6266. + ar71xx_eth1_data.duplex = DUPLEX_FULL;
  6267. + ar71xx_eth1_data.fifo_cfg1 = 0x0010ffff;
  6268. + ar71xx_eth1_data.fifo_cfg2 = 0x015500aa;
  6269. + ar71xx_eth1_data.fifo_cfg3 = 0x01f00140;
  6270. +
  6271. + ar71xx_add_device_eth(1);
  6272. +}
  6273. +
  6274. +MIPS_MACHINE(AR71XX_MACH_UBNT_NANO_M, "UBNT-NM", "Ubiquiti Nanostation M",
  6275. + ubnt_nano_m_setup);
  6276. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wndr3700.c linux-2.6.35.7/arch/mips/ar71xx/mach-wndr3700.c
  6277. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wndr3700.c 1970-01-01 01:00:00.000000000 +0100
  6278. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-wndr3700.c 2010-10-14 20:27:58.228101285 +0200
  6279. @@ -0,0 +1,209 @@
  6280. +/*
  6281. + * Netgear WNDR3700 board support
  6282. + *
  6283. + * Copyright (C) 2009 Marco Porsch
  6284. + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  6285. + *
  6286. + * This program is free software; you can redistribute it and/or modify it
  6287. + * under the terms of the GNU General Public License version 2 as published
  6288. + * by the Free Software Foundation.
  6289. + */
  6290. +
  6291. +#include <linux/platform_device.h>
  6292. +#include <linux/mtd/mtd.h>
  6293. +#include <linux/mtd/partitions.h>
  6294. +#include <linux/delay.h>
  6295. +#include <linux/rtl8366s.h>
  6296. +
  6297. +#include <asm/mach-ar71xx/ar71xx.h>
  6298. +
  6299. +#include "machtype.h"
  6300. +#include "devices.h"
  6301. +#include "dev-m25p80.h"
  6302. +#include "dev-ap94-pci.h"
  6303. +#include "dev-gpio-buttons.h"
  6304. +#include "dev-leds-gpio.h"
  6305. +#include "dev-usb.h"
  6306. +
  6307. +#define WNDR3700_GPIO_LED_WPS_ORANGE 0
  6308. +#define WNDR3700_GPIO_LED_POWER_ORANGE 1
  6309. +#define WNDR3700_GPIO_LED_POWER_GREEN 2
  6310. +#define WNDR3700_GPIO_LED_WPS_GREEN 4
  6311. +#define WNDR3700_GPIO_LED_WAN_GREEN 6
  6312. +
  6313. +#define WNDR3700_GPIO_BTN_WPS 3
  6314. +#define WNDR3700_GPIO_BTN_RESET 8
  6315. +#define WNDR3700_GPIO_BTN_WIFI 11
  6316. +
  6317. +#define WNDR3700_GPIO_RTL8366_SDA 5
  6318. +#define WNDR3700_GPIO_RTL8366_SCK 7
  6319. +
  6320. +#define WNDR3700_BUTTONS_POLL_INTERVAL 20
  6321. +
  6322. +#define WNDR3700_WMAC0_MAC_OFFSET 0
  6323. +#define WNDR3700_WMAC1_MAC_OFFSET 0xc
  6324. +#define WNDR3700_CALDATA0_OFFSET 0x1000
  6325. +#define WNDR3700_CALDATA1_OFFSET 0x5000
  6326. +
  6327. +#ifdef CONFIG_MTD_PARTITIONS
  6328. +static struct mtd_partition wndr3700_partitions[] = {
  6329. + {
  6330. + .name = "uboot",
  6331. + .offset = 0,
  6332. + .size = 0x050000,
  6333. + .mask_flags = MTD_WRITEABLE,
  6334. + } , {
  6335. + .name = "env",
  6336. + .offset = 0x050000,
  6337. + .size = 0x020000,
  6338. + .mask_flags = MTD_WRITEABLE,
  6339. + } , {
  6340. + .name = "rootfs",
  6341. + .offset = 0x070000,
  6342. + .size = 0x720000,
  6343. + } , {
  6344. + .name = "config",
  6345. + .offset = 0x790000,
  6346. + .size = 0x010000,
  6347. + .mask_flags = MTD_WRITEABLE,
  6348. + } , {
  6349. + .name = "config_bak",
  6350. + .offset = 0x7a0000,
  6351. + .size = 0x010000,
  6352. + .mask_flags = MTD_WRITEABLE,
  6353. + } , {
  6354. + .name = "pot",
  6355. + .offset = 0x7b0000,
  6356. + .size = 0x010000,
  6357. + .mask_flags = MTD_WRITEABLE,
  6358. + } , {
  6359. + .name = "traffic_meter",
  6360. + .offset = 0x7c0000,
  6361. + .size = 0x010000,
  6362. + .mask_flags = MTD_WRITEABLE,
  6363. + } , {
  6364. + .name = "language",
  6365. + .offset = 0x7d0000,
  6366. + .size = 0x020000,
  6367. + .mask_flags = MTD_WRITEABLE,
  6368. + } , {
  6369. + .name = "caldata",
  6370. + .offset = 0x7f0000,
  6371. + .size = 0x010000,
  6372. + .mask_flags = MTD_WRITEABLE,
  6373. + }
  6374. +};
  6375. +#endif /* CONFIG_MTD_PARTITIONS */
  6376. +
  6377. +static struct flash_platform_data wndr3700_flash_data = {
  6378. +#ifdef CONFIG_MTD_PARTITIONS
  6379. + .parts = wndr3700_partitions,
  6380. + .nr_parts = ARRAY_SIZE(wndr3700_partitions),
  6381. +#endif
  6382. +};
  6383. +
  6384. +static struct gpio_led wndr3700_leds_gpio[] __initdata = {
  6385. + {
  6386. + .name = "wndr3700:green:power",
  6387. + .gpio = WNDR3700_GPIO_LED_POWER_GREEN,
  6388. + .active_low = 1,
  6389. + }, {
  6390. + .name = "wndr3700:orange:power",
  6391. + .gpio = WNDR3700_GPIO_LED_POWER_ORANGE,
  6392. + .active_low = 1,
  6393. + }, {
  6394. + .name = "wndr3700:green:wps",
  6395. + .gpio = WNDR3700_GPIO_LED_WPS_GREEN,
  6396. + .active_low = 1,
  6397. + }, {
  6398. + .name = "wndr3700:orange:wps",
  6399. + .gpio = WNDR3700_GPIO_LED_WPS_ORANGE,
  6400. + .active_low = 1,
  6401. + }, {
  6402. + .name = "wndr3700:green:wan",
  6403. + .gpio = WNDR3700_GPIO_LED_WAN_GREEN,
  6404. + .active_low = 1,
  6405. + }
  6406. +};
  6407. +
  6408. +static struct gpio_button wndr3700_gpio_buttons[] __initdata = {
  6409. + {
  6410. + .desc = "reset",
  6411. + .type = EV_KEY,
  6412. + .code = KEY_RESTART,
  6413. + .threshold = 3,
  6414. + .gpio = WNDR3700_GPIO_BTN_RESET,
  6415. + .active_low = 1,
  6416. + }, {
  6417. + .desc = "wps",
  6418. + .type = EV_KEY,
  6419. + .code = KEY_WPS_BUTTON,
  6420. + .threshold = 3,
  6421. + .gpio = WNDR3700_GPIO_BTN_WPS,
  6422. + .active_low = 1,
  6423. + } , {
  6424. + .desc = "wifi",
  6425. + .type = EV_KEY,
  6426. + .code = BTN_2,
  6427. + .threshold = 3,
  6428. + .gpio = WNDR3700_GPIO_BTN_WIFI,
  6429. + .active_low = 1,
  6430. + }
  6431. +};
  6432. +
  6433. +static struct rtl8366s_platform_data wndr3700_rtl8366s_data = {
  6434. + .gpio_sda = WNDR3700_GPIO_RTL8366_SDA,
  6435. + .gpio_sck = WNDR3700_GPIO_RTL8366_SCK,
  6436. +};
  6437. +
  6438. +static struct platform_device wndr3700_rtl8366s_device = {
  6439. + .name = RTL8366S_DRIVER_NAME,
  6440. + .id = -1,
  6441. + .dev = {
  6442. + .platform_data = &wndr3700_rtl8366s_data,
  6443. + }
  6444. +};
  6445. +
  6446. +static void __init wndr3700_setup(void)
  6447. +{
  6448. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  6449. +
  6450. + ar71xx_set_mac_base(art);
  6451. +
  6452. + ar71xx_eth0_pll_data.pll_1000 = 0x11110000;
  6453. + ar71xx_eth0_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev;
  6454. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  6455. + ar71xx_eth0_data.speed = SPEED_1000;
  6456. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  6457. +
  6458. + ar71xx_eth1_pll_data.pll_1000 = 0x11110000;
  6459. + ar71xx_eth1_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev;
  6460. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  6461. + ar71xx_eth1_data.phy_mask = 0x10;
  6462. +
  6463. + ar71xx_add_device_eth(0);
  6464. + ar71xx_add_device_eth(1);
  6465. +
  6466. + ar71xx_add_device_usb();
  6467. +
  6468. + ar71xx_add_device_m25p80(&wndr3700_flash_data);
  6469. +
  6470. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wndr3700_leds_gpio),
  6471. + wndr3700_leds_gpio);
  6472. +
  6473. + ar71xx_add_device_gpio_buttons(-1, WNDR3700_BUTTONS_POLL_INTERVAL,
  6474. + ARRAY_SIZE(wndr3700_gpio_buttons),
  6475. + wndr3700_gpio_buttons);
  6476. +
  6477. + platform_device_register(&wndr3700_rtl8366s_device);
  6478. + platform_device_register_simple("wndr3700-led-usb", -1, NULL, 0);
  6479. +
  6480. + ap94_pci_enable_quirk_wndr3700();
  6481. + ap94_pci_init(art + WNDR3700_CALDATA0_OFFSET,
  6482. + art + WNDR3700_WMAC0_MAC_OFFSET,
  6483. + art + WNDR3700_CALDATA1_OFFSET,
  6484. + art + WNDR3700_WMAC1_MAC_OFFSET);
  6485. +}
  6486. +
  6487. +MIPS_MACHINE(AR71XX_MACH_WNDR3700, "WNDR3700", "NETGEAR WNDR3700",
  6488. + wndr3700_setup);
  6489. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wnr2000.c linux-2.6.35.7/arch/mips/ar71xx/mach-wnr2000.c
  6490. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wnr2000.c 1970-01-01 01:00:00.000000000 +0100
  6491. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-wnr2000.c 2010-10-14 20:27:58.268101150 +0200
  6492. @@ -0,0 +1,148 @@
  6493. +/*
  6494. + * NETGEAR WNR2000 board support
  6495. + *
  6496. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  6497. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  6498. + * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
  6499. + *
  6500. + * This program is free software; you can redistribute it and/or modify it
  6501. + * under the terms of the GNU General Public License version 2 as published
  6502. + * by the Free Software Foundation.
  6503. + */
  6504. +
  6505. +#include <linux/mtd/mtd.h>
  6506. +#include <linux/mtd/partitions.h>
  6507. +
  6508. +#include <asm/mach-ar71xx/ar71xx.h>
  6509. +
  6510. +#include "machtype.h"
  6511. +#include "devices.h"
  6512. +#include "dev-m25p80.h"
  6513. +#include "dev-ar913x-wmac.h"
  6514. +#include "dev-gpio-buttons.h"
  6515. +#include "dev-leds-gpio.h"
  6516. +
  6517. +#define WNR2000_GPIO_LED_PWR_GREEN 14
  6518. +#define WNR2000_GPIO_LED_PWR_AMBER 7
  6519. +#define WNR2000_GPIO_LED_WPS 4
  6520. +#define WNR2000_GPIO_LED_WLAN 6
  6521. +#define WNR2000_GPIO_BTN_RESET 21
  6522. +#define WNR2000_GPIO_BTN_WPS 8
  6523. +
  6524. +#define WNR2000_BUTTONS_POLL_INTERVAL 20
  6525. +
  6526. +#ifdef CONFIG_MTD_PARTITIONS
  6527. +static struct mtd_partition wnr2000_partitions[] = {
  6528. + {
  6529. + .name = "u-boot",
  6530. + .offset = 0,
  6531. + .size = 0x040000,
  6532. + .mask_flags = MTD_WRITEABLE,
  6533. + } , {
  6534. + .name = "u-boot-env",
  6535. + .offset = 0x040000,
  6536. + .size = 0x010000,
  6537. + } , {
  6538. + .name = "rootfs",
  6539. + .offset = 0x050000,
  6540. + .size = 0x240000,
  6541. + } , {
  6542. + .name = "user-config",
  6543. + .offset = 0x290000,
  6544. + .size = 0x010000,
  6545. + } , {
  6546. + .name = "uImage",
  6547. + .offset = 0x2a0000,
  6548. + .size = 0x120000,
  6549. + } , {
  6550. + .name = "language_table",
  6551. + .offset = 0x3c0000,
  6552. + .size = 0x020000,
  6553. + } , {
  6554. + .name = "rootfs_checksum",
  6555. + .offset = 0x3e0000,
  6556. + .size = 0x010000,
  6557. + } , {
  6558. + .name = "art",
  6559. + .offset = 0x3f0000,
  6560. + .size = 0x010000,
  6561. + .mask_flags = MTD_WRITEABLE,
  6562. + }
  6563. +};
  6564. +#endif /* CONFIG_MTD_PARTITIONS */
  6565. +
  6566. +static struct flash_platform_data wnr2000_flash_data = {
  6567. +#ifdef CONFIG_MTD_PARTITIONS
  6568. + .parts = wnr2000_partitions,
  6569. + .nr_parts = ARRAY_SIZE(wnr2000_partitions),
  6570. +#endif
  6571. +};
  6572. +
  6573. +static struct gpio_led wnr2000_leds_gpio[] __initdata = {
  6574. + {
  6575. + .name = "wnr2000:green:power",
  6576. + .gpio = WNR2000_GPIO_LED_PWR_GREEN,
  6577. + .active_low = 1,
  6578. + }, {
  6579. + .name = "wnr2000:amber:power",
  6580. + .gpio = WNR2000_GPIO_LED_PWR_AMBER,
  6581. + .active_low = 1,
  6582. + }, {
  6583. + .name = "wnr2000:green:wps",
  6584. + .gpio = WNR2000_GPIO_LED_WPS,
  6585. + .active_low = 1,
  6586. + }, {
  6587. + .name = "wnr2000:blue:wlan",
  6588. + .gpio = WNR2000_GPIO_LED_WLAN,
  6589. + .active_low = 1,
  6590. + }
  6591. +};
  6592. +
  6593. +static struct gpio_button wnr2000_gpio_buttons[] __initdata = {
  6594. + {
  6595. + .desc = "reset",
  6596. + .type = EV_KEY,
  6597. + .code = KEY_RESTART,
  6598. + .threshold = 3,
  6599. + .gpio = WNR2000_GPIO_BTN_RESET,
  6600. + }, {
  6601. + .desc = "wps",
  6602. + .type = EV_KEY,
  6603. + .code = KEY_WPS_BUTTON,
  6604. + .threshold = 3,
  6605. + .gpio = WNR2000_GPIO_BTN_WPS,
  6606. + }
  6607. +};
  6608. +
  6609. +static void __init wnr2000_setup(void)
  6610. +{
  6611. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  6612. +
  6613. + ar71xx_set_mac_base(eeprom);
  6614. + ar71xx_add_device_mdio(0x0);
  6615. +
  6616. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  6617. + ar71xx_eth0_data.speed = SPEED_100;
  6618. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  6619. + ar71xx_eth0_data.has_ar8216 = 1;
  6620. +
  6621. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  6622. + ar71xx_eth1_data.phy_mask = 0x10;
  6623. +
  6624. + ar71xx_add_device_eth(0);
  6625. + ar71xx_add_device_eth(1);
  6626. +
  6627. + ar71xx_add_device_m25p80(&wnr2000_flash_data);
  6628. +
  6629. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wnr2000_leds_gpio),
  6630. + wnr2000_leds_gpio);
  6631. +
  6632. + ar71xx_add_device_gpio_buttons(-1, WNR2000_BUTTONS_POLL_INTERVAL,
  6633. + ARRAY_SIZE(wnr2000_gpio_buttons),
  6634. + wnr2000_gpio_buttons);
  6635. +
  6636. +
  6637. + ar913x_add_device_wmac(eeprom, NULL);
  6638. +}
  6639. +
  6640. +MIPS_MACHINE(AR71XX_MACH_WNR2000, "WNR2000", "NETGEAR WNR2000", wnr2000_setup);
  6641. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wp543.c linux-2.6.35.7/arch/mips/ar71xx/mach-wp543.c
  6642. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wp543.c 1970-01-01 01:00:00.000000000 +0100
  6643. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-wp543.c 2010-10-14 20:27:58.314545632 +0200
  6644. @@ -0,0 +1,99 @@
  6645. +/*
  6646. + * Compex WP543/WPJ543 board support
  6647. + *
  6648. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  6649. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  6650. + *
  6651. + * This program is free software; you can redistribute it and/or modify it
  6652. + * under the terms of the GNU General Public License version 2 as published
  6653. + * by the Free Software Foundation.
  6654. + */
  6655. +
  6656. +#include <linux/mtd/mtd.h>
  6657. +#include <linux/mtd/partitions.h>
  6658. +
  6659. +#include <asm/mach-ar71xx/ar71xx.h>
  6660. +
  6661. +#include "machtype.h"
  6662. +#include "devices.h"
  6663. +#include "dev-m25p80.h"
  6664. +#include "dev-pb42-pci.h"
  6665. +#include "dev-gpio-buttons.h"
  6666. +#include "dev-leds-gpio.h"
  6667. +#include "dev-usb.h"
  6668. +
  6669. +#define WP543_GPIO_SW6 2
  6670. +#define WP543_GPIO_LED_1 3
  6671. +#define WP543_GPIO_LED_2 4
  6672. +#define WP543_GPIO_LED_WLAN 5
  6673. +#define WP543_GPIO_LED_CONN 6
  6674. +#define WP543_GPIO_LED_DIAG 7
  6675. +#define WP543_GPIO_SW4 8
  6676. +
  6677. +#define WP543_BUTTONS_POLL_INTERVAL 20
  6678. +
  6679. +static struct gpio_led wp543_leds_gpio[] __initdata = {
  6680. + {
  6681. + .name = "wp543:green:led1",
  6682. + .gpio = WP543_GPIO_LED_1,
  6683. + .active_low = 1,
  6684. + }, {
  6685. + .name = "wp543:green:led2",
  6686. + .gpio = WP543_GPIO_LED_2,
  6687. + .active_low = 1,
  6688. + }, {
  6689. + .name = "wp543:green:wlan",
  6690. + .gpio = WP543_GPIO_LED_WLAN,
  6691. + .active_low = 1,
  6692. + }, {
  6693. + .name = "wp543:green:conn",
  6694. + .gpio = WP543_GPIO_LED_CONN,
  6695. + .active_low = 1,
  6696. + }, {
  6697. + .name = "wp543:green:diag",
  6698. + .gpio = WP543_GPIO_LED_DIAG,
  6699. + .active_low = 1,
  6700. + }
  6701. +};
  6702. +
  6703. +static struct gpio_button wp543_gpio_buttons[] __initdata = {
  6704. + {
  6705. + .desc = "sw6",
  6706. + .type = EV_KEY,
  6707. + .code = BTN_0,
  6708. + .threshold = 3,
  6709. + .gpio = WP543_GPIO_SW6,
  6710. + }, {
  6711. + .desc = "sw4",
  6712. + .type = EV_KEY,
  6713. + .code = BTN_1,
  6714. + .threshold = 3,
  6715. + .gpio = WP543_GPIO_SW4,
  6716. + }
  6717. +};
  6718. +
  6719. +static void __init wp543_setup(void)
  6720. +{
  6721. + ar71xx_add_device_m25p80(NULL);
  6722. +
  6723. + ar71xx_add_device_mdio(0xfffffff7);
  6724. +
  6725. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  6726. + ar71xx_eth0_data.phy_mask = 0x08;
  6727. + ar71xx_eth0_data.reset_bit = RESET_MODULE_GE0_MAC |
  6728. + RESET_MODULE_GE0_PHY;
  6729. + ar71xx_add_device_eth(0);
  6730. +
  6731. + ar71xx_add_device_usb();
  6732. +
  6733. + pb42_pci_init();
  6734. +
  6735. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wp543_leds_gpio),
  6736. + wp543_leds_gpio);
  6737. +
  6738. + ar71xx_add_device_gpio_buttons(-1, WP543_BUTTONS_POLL_INTERVAL,
  6739. + ARRAY_SIZE(wp543_gpio_buttons),
  6740. + wp543_gpio_buttons);
  6741. +}
  6742. +
  6743. +MIPS_MACHINE(AR71XX_MACH_WP543, "WP543", "Compex WP543", wp543_setup);
  6744. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wrt160nl.c linux-2.6.35.7/arch/mips/ar71xx/mach-wrt160nl.c
  6745. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wrt160nl.c 1970-01-01 01:00:00.000000000 +0100
  6746. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-wrt160nl.c 2010-10-14 20:27:58.364348612 +0200
  6747. @@ -0,0 +1,158 @@
  6748. +/*
  6749. + * Linksys WRT160NL board support
  6750. + *
  6751. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  6752. + *
  6753. + * This program is free software; you can redistribute it and/or modify it
  6754. + * under the terms of the GNU General Public License version 2 as published
  6755. + * by the Free Software Foundation.
  6756. + */
  6757. +
  6758. +#include <linux/mtd/mtd.h>
  6759. +#include <linux/mtd/partitions.h>
  6760. +
  6761. +#include <asm/mach-ar71xx/ar71xx.h>
  6762. +
  6763. +#include "machtype.h"
  6764. +#include "devices.h"
  6765. +#include "dev-m25p80.h"
  6766. +#include "dev-ar913x-wmac.h"
  6767. +#include "dev-gpio-buttons.h"
  6768. +#include "dev-leds-gpio.h"
  6769. +#include "dev-usb.h"
  6770. +#include "nvram.h"
  6771. +
  6772. +#define WRT160NL_GPIO_LED_POWER 14
  6773. +#define WRT160NL_GPIO_LED_WPS_AMBER 9
  6774. +#define WRT160NL_GPIO_LED_WPS_BLUE 8
  6775. +#define WRT160NL_GPIO_LED_WLAN 6
  6776. +
  6777. +#define WRT160NL_GPIO_BTN_WPS 7
  6778. +#define WRT160NL_GPIO_BTN_RESET 21
  6779. +
  6780. +#define WRT160NL_BUTTONS_POLL_INTERVAL 20
  6781. +
  6782. +#define WRT160NL_NVRAM_ADDR 0x1f7e0000
  6783. +#define WRT160NL_NVRAM_SIZE 0x10000
  6784. +
  6785. +#ifdef CONFIG_MTD_PARTITIONS
  6786. +static struct mtd_partition wrt160nl_partitions[] = {
  6787. + {
  6788. + .name = "u-boot",
  6789. + .offset = 0,
  6790. + .size = 0x040000,
  6791. + .mask_flags = MTD_WRITEABLE,
  6792. + } , {
  6793. + .name = "kernel",
  6794. + .offset = 0x040000,
  6795. + .size = 0x0e0000,
  6796. + } , {
  6797. + .name = "filesytem",
  6798. + .offset = 0x120000,
  6799. + .size = 0x6c0000,
  6800. + } , {
  6801. + .name = "nvram",
  6802. + .offset = 0x7e0000,
  6803. + .size = 0x010000,
  6804. + .mask_flags = MTD_WRITEABLE,
  6805. + } , {
  6806. + .name = "ART",
  6807. + .offset = 0x7f0000,
  6808. + .size = 0x010000,
  6809. + .mask_flags = MTD_WRITEABLE,
  6810. + } , {
  6811. + .name = "firmware",
  6812. + .offset = 0x040000,
  6813. + .size = 0x7a0000,
  6814. + }
  6815. +};
  6816. +#endif /* CONFIG_MTD_PARTITIONS */
  6817. +
  6818. +static struct flash_platform_data wrt160nl_flash_data = {
  6819. +#ifdef CONFIG_MTD_PARTITIONS
  6820. + .parts = wrt160nl_partitions,
  6821. + .nr_parts = ARRAY_SIZE(wrt160nl_partitions),
  6822. +#endif
  6823. +};
  6824. +
  6825. +static struct gpio_led wrt160nl_leds_gpio[] __initdata = {
  6826. + {
  6827. + .name = "wrt160nl:blue:power",
  6828. + .gpio = WRT160NL_GPIO_LED_POWER,
  6829. + .active_low = 1,
  6830. + .default_trigger = "default-on",
  6831. + }, {
  6832. + .name = "wrt160nl:amber:wps",
  6833. + .gpio = WRT160NL_GPIO_LED_WPS_AMBER,
  6834. + .active_low = 1,
  6835. + }, {
  6836. + .name = "wrt160nl:blue:wps",
  6837. + .gpio = WRT160NL_GPIO_LED_WPS_BLUE,
  6838. + .active_low = 1,
  6839. + }, {
  6840. + .name = "wrt160nl:blue:wlan",
  6841. + .gpio = WRT160NL_GPIO_LED_WLAN,
  6842. + .active_low = 1,
  6843. + }
  6844. +};
  6845. +
  6846. +static struct gpio_button wrt160nl_gpio_buttons[] __initdata = {
  6847. + {
  6848. + .desc = "reset",
  6849. + .type = EV_KEY,
  6850. + .code = KEY_RESTART,
  6851. + .threshold = 3,
  6852. + .gpio = WRT160NL_GPIO_BTN_RESET,
  6853. + .active_low = 1,
  6854. + }, {
  6855. + .desc = "wps",
  6856. + .type = EV_KEY,
  6857. + .code = KEY_WPS_BUTTON,
  6858. + .threshold = 3,
  6859. + .gpio = WRT160NL_GPIO_BTN_WPS,
  6860. + .active_low = 1,
  6861. + }
  6862. +};
  6863. +
  6864. +static void __init wrt160nl_setup(void)
  6865. +{
  6866. + const char *nvram = (char *) KSEG1ADDR(WRT160NL_NVRAM_ADDR);
  6867. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  6868. + u8 mac[6];
  6869. +
  6870. + if (nvram_parse_mac_addr(nvram, WRT160NL_NVRAM_SIZE,
  6871. + "lan_hwaddr=", mac) == 0)
  6872. + ar71xx_set_mac_base(mac);
  6873. +
  6874. + ar71xx_add_device_mdio(0x0);
  6875. +
  6876. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  6877. + ar71xx_eth0_data.phy_mask = 0x01;
  6878. +
  6879. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  6880. + ar71xx_eth1_data.phy_mask = 0x10;
  6881. +
  6882. + ar71xx_add_device_eth(0);
  6883. + ar71xx_add_device_eth(1);
  6884. +
  6885. + ar71xx_add_device_m25p80(&wrt160nl_flash_data);
  6886. +
  6887. + ar71xx_add_device_usb();
  6888. +
  6889. + if (nvram_parse_mac_addr(nvram, WRT160NL_NVRAM_SIZE,
  6890. + "wl0_hwaddr=", mac) == 0)
  6891. + ar913x_add_device_wmac(eeprom, mac);
  6892. + else
  6893. + ar913x_add_device_wmac(eeprom, NULL);
  6894. +
  6895. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wrt160nl_leds_gpio),
  6896. + wrt160nl_leds_gpio);
  6897. +
  6898. + ar71xx_add_device_gpio_buttons(-1, WRT160NL_BUTTONS_POLL_INTERVAL,
  6899. + ARRAY_SIZE(wrt160nl_gpio_buttons),
  6900. + wrt160nl_gpio_buttons);
  6901. +
  6902. +}
  6903. +
  6904. +MIPS_MACHINE(AR71XX_MACH_WRT160NL, "WRT160NL", "Linksys WRT160NL",
  6905. + wrt160nl_setup);
  6906. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wrt400n.c linux-2.6.35.7/arch/mips/ar71xx/mach-wrt400n.c
  6907. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wrt400n.c 1970-01-01 01:00:00.000000000 +0100
  6908. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-wrt400n.c 2010-10-14 20:27:58.414355031 +0200
  6909. @@ -0,0 +1,168 @@
  6910. +/*
  6911. + * Linksys WRT400N board support
  6912. + *
  6913. + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  6914. + * Copyright (C) 2009 Imre Kaloz <kaloz@openwrt.org>
  6915. + *
  6916. + * This program is free software; you can redistribute it and/or modify it
  6917. + * under the terms of the GNU General Public License version 2 as published
  6918. + * by the Free Software Foundation.
  6919. + */
  6920. +
  6921. +#include <linux/mtd/mtd.h>
  6922. +#include <linux/mtd/partitions.h>
  6923. +
  6924. +#include <asm/mach-ar71xx/ar71xx.h>
  6925. +
  6926. +#include "machtype.h"
  6927. +#include "devices.h"
  6928. +#include "dev-ap94-pci.h"
  6929. +#include "dev-m25p80.h"
  6930. +#include "dev-gpio-buttons.h"
  6931. +#include "dev-leds-gpio.h"
  6932. +
  6933. +#define WRT400N_GPIO_LED_ORANGE 5
  6934. +#define WRT400N_GPIO_LED_GREEN 4
  6935. +#define WRT400N_GPIO_LED_POWER 1
  6936. +#define WRT400N_GPIO_LED_WLAN 0
  6937. +
  6938. +#define WRT400N_GPIO_BTN_RESET 8
  6939. +#define WRT400N_GPIO_BTN_WLSEC 3
  6940. +
  6941. +#define WRT400N_BUTTONS_POLL_INTERVAL 20
  6942. +
  6943. +#define WRT400N_MAC_ADDR_OFFSET 0x120c
  6944. +#define WRT400N_CALDATA0_OFFSET 0x1000
  6945. +#define WRT400N_CALDATA1_OFFSET 0x5000
  6946. +
  6947. +#ifdef CONFIG_MTD_PARTITIONS
  6948. +static struct mtd_partition wrt400n_partitions[] = {
  6949. + {
  6950. + .name = "uboot",
  6951. + .offset = 0,
  6952. + .size = 0x030000,
  6953. + .mask_flags = MTD_WRITEABLE,
  6954. + } , {
  6955. + .name = "env",
  6956. + .offset = 0x030000,
  6957. + .size = 0x010000,
  6958. + .mask_flags = MTD_WRITEABLE,
  6959. + } , {
  6960. + .name = "linux",
  6961. + .offset = 0x040000,
  6962. + .size = 0x140000,
  6963. + } , {
  6964. + .name = "rootfs",
  6965. + .offset = 0x180000,
  6966. + .size = 0x630000,
  6967. + } , {
  6968. + .name = "nvram",
  6969. + .offset = 0x7b0000,
  6970. + .size = 0x010000,
  6971. + .mask_flags = MTD_WRITEABLE,
  6972. + } , {
  6973. + .name = "factory",
  6974. + .offset = 0x7c0000,
  6975. + .size = 0x010000,
  6976. + .mask_flags = MTD_WRITEABLE,
  6977. + } , {
  6978. + .name = "language",
  6979. + .offset = 0x7d0000,
  6980. + .size = 0x020000,
  6981. + .mask_flags = MTD_WRITEABLE,
  6982. + } , {
  6983. + .name = "caldata",
  6984. + .offset = 0x7f0000,
  6985. + .size = 0x010000,
  6986. + .mask_flags = MTD_WRITEABLE,
  6987. + } , {
  6988. + .name = "firmware",
  6989. + .offset = 0x040000,
  6990. + .size = 0x770000,
  6991. + }
  6992. +};
  6993. +#endif /* CONFIG_MTD_PARTITIONS */
  6994. +
  6995. +static struct flash_platform_data wrt400n_flash_data = {
  6996. +#ifdef CONFIG_MTD_PARTITIONS
  6997. + .parts = wrt400n_partitions,
  6998. + .nr_parts = ARRAY_SIZE(wrt400n_partitions),
  6999. +#endif
  7000. +};
  7001. +
  7002. +static struct gpio_led wrt400n_leds_gpio[] __initdata = {
  7003. + {
  7004. + .name = "wrt400n:green:status",
  7005. + .gpio = WRT400N_GPIO_LED_GREEN,
  7006. + .active_low = 1,
  7007. + }, {
  7008. + .name = "wrt400n:amber:aoss",
  7009. + .gpio = WRT400N_GPIO_LED_ORANGE,
  7010. + .active_low = 1,
  7011. + }, {
  7012. + .name = "wrt400n:green:wlan",
  7013. + .gpio = WRT400N_GPIO_LED_WLAN,
  7014. + .active_low = 1,
  7015. + }, {
  7016. + .name = "wrt400n:green:power",
  7017. + .gpio = WRT400N_GPIO_LED_POWER,
  7018. + .active_low = 1,
  7019. + }
  7020. +};
  7021. +
  7022. +static struct gpio_button wrt400n_gpio_buttons[] __initdata = {
  7023. + {
  7024. + .desc = "reset",
  7025. + .type = EV_KEY,
  7026. + .code = KEY_RESTART,
  7027. + .threshold = 3,
  7028. + .gpio = WRT400N_GPIO_BTN_RESET,
  7029. + .active_low = 1,
  7030. + } , {
  7031. + .desc = "wlsec",
  7032. + .type = EV_KEY,
  7033. + .code = KEY_WPS_BUTTON,
  7034. + .threshold = 3,
  7035. + .gpio = WRT400N_GPIO_BTN_WLSEC,
  7036. + .active_low = 1,
  7037. + }
  7038. +};
  7039. +
  7040. +static void __init wrt400n_setup(void)
  7041. +{
  7042. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  7043. + u8 mac[6];
  7044. + int i;
  7045. +
  7046. + memcpy(mac, art + WRT400N_MAC_ADDR_OFFSET, 6);
  7047. + for (i = 5; i >= 3; i--)
  7048. + if (++mac[i] != 0x00) break;
  7049. +
  7050. + ar71xx_set_mac_base(mac);
  7051. +
  7052. + ar71xx_add_device_mdio(0x0);
  7053. +
  7054. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  7055. + ar71xx_eth0_data.speed = SPEED_100;
  7056. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  7057. +
  7058. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  7059. + ar71xx_eth1_data.phy_mask = 0x10;
  7060. +
  7061. + ar71xx_add_device_eth(0);
  7062. + ar71xx_add_device_eth(1);
  7063. +
  7064. + ar71xx_add_device_m25p80(&wrt400n_flash_data);
  7065. +
  7066. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wrt400n_leds_gpio),
  7067. + wrt400n_leds_gpio);
  7068. +
  7069. + ar71xx_add_device_gpio_buttons(-1, WRT400N_BUTTONS_POLL_INTERVAL,
  7070. + ARRAY_SIZE(wrt400n_gpio_buttons),
  7071. + wrt400n_gpio_buttons);
  7072. +
  7073. + ap94_pci_init(art + WRT400N_CALDATA0_OFFSET, NULL,
  7074. + art + WRT400N_CALDATA1_OFFSET, NULL);
  7075. +}
  7076. +
  7077. +MIPS_MACHINE(AR71XX_MACH_WRT400N, "WRT400N", "Linksys WRT400N", wrt400n_setup);
  7078. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wzr-hp-g300nh.c linux-2.6.35.7/arch/mips/ar71xx/mach-wzr-hp-g300nh.c
  7079. --- linux-2.6.35.7.orig/arch/mips/ar71xx/mach-wzr-hp-g300nh.c 1970-01-01 01:00:00.000000000 +0100
  7080. +++ linux-2.6.35.7/arch/mips/ar71xx/mach-wzr-hp-g300nh.c 2010-10-14 20:27:58.455673598 +0200
  7081. @@ -0,0 +1,265 @@
  7082. +/*
  7083. + * Buffalo WZR-HP-G300NH board support
  7084. + *
  7085. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  7086. + *
  7087. + * This program is free software; you can redistribute it and/or modify it
  7088. + * under the terms of the GNU General Public License version 2 as published
  7089. + * by the Free Software Foundation.
  7090. + */
  7091. +
  7092. +#include <linux/platform_device.h>
  7093. +#include <linux/mtd/mtd.h>
  7094. +#include <linux/mtd/partitions.h>
  7095. +#include <linux/nxp_74hc153.h>
  7096. +#include <linux/rtl8366s.h>
  7097. +
  7098. +#include <asm/mips_machine.h>
  7099. +#include <asm/mach-ar71xx/ar71xx.h>
  7100. +#include <asm/mach-ar71xx/ar91xx_flash.h>
  7101. +
  7102. +#include "machtype.h"
  7103. +#include "devices.h"
  7104. +#include "dev-ar913x-wmac.h"
  7105. +#include "dev-gpio-buttons.h"
  7106. +#include "dev-leds-gpio.h"
  7107. +#include "dev-usb.h"
  7108. +
  7109. +#define WZRHPG300NH_GPIO_LED_USB 0
  7110. +#define WZRHPG300NH_GPIO_LED_DIAG 1
  7111. +#define WZRHPG300NH_GPIO_LED_WIRELESS 6
  7112. +#define WZRHPG300NH_GPIO_LED_SECURITY 17
  7113. +#define WZRHPG300NH_GPIO_LED_ROUTER 18
  7114. +
  7115. +#define WZRHPG300NH_GPIO_RTL8366_SDA 19
  7116. +#define WZRHPG300NH_GPIO_RTL8366_SCK 20
  7117. +
  7118. +#define WZRHPG300NH_GPIO_74HC153_S0 9
  7119. +#define WZRHPG300NH_GPIO_74HC153_S1 11
  7120. +#define WZRHPG300NH_GPIO_74HC153_1Y 12
  7121. +#define WZRHPG300NH_GPIO_74HC153_2Y 14
  7122. +
  7123. +#define WZRHPG300NH_GPIO_EXP_BASE 32
  7124. +#define WZRHPG300NH_GPIO_BTN_AOSS (WZRHPG300NH_GPIO_EXP_BASE + 0)
  7125. +#define WZRHPG300NH_GPIO_BTN_RESET (WZRHPG300NH_GPIO_EXP_BASE + 1)
  7126. +#define WZRHPG300NH_GPIO_BTN_ROUTER_ON (WZRHPG300NH_GPIO_EXP_BASE + 2)
  7127. +#define WZRHPG300NH_GPIO_BTN_QOS_ON (WZRHPG300NH_GPIO_EXP_BASE + 3)
  7128. +#define WZRHPG300NH_GPIO_BTN_USB (WZRHPG300NH_GPIO_EXP_BASE + 5)
  7129. +#define WZRHPG300NH_GPIO_BTN_ROUTER_AUTO (WZRHPG300NH_GPIO_EXP_BASE + 6)
  7130. +#define WZRHPG300NH_GPIO_BTN_QOS_OFF (WZRHPG300NH_GPIO_EXP_BASE + 7)
  7131. +
  7132. +#define WZRHPG300NH_BUTTONS_POLL_INTERVAL 20
  7133. +
  7134. +#define WZRHPG300NH_MAC_OFFSET 0x20c
  7135. +
  7136. +#ifdef CONFIG_MTD_PARTITIONS
  7137. +static struct mtd_partition wzrhpg300nh_flash_partitions[] = {
  7138. + {
  7139. + .name = "u-boot",
  7140. + .offset = 0,
  7141. + .size = 0x0040000,
  7142. + .mask_flags = MTD_WRITEABLE,
  7143. + }, {
  7144. + .name = "u-boot-env",
  7145. + .offset = 0x0040000,
  7146. + .size = 0x0020000,
  7147. + .mask_flags = MTD_WRITEABLE,
  7148. + }, {
  7149. + .name = "kernel",
  7150. + .offset = 0x0060000,
  7151. + .size = 0x0100000,
  7152. + }, {
  7153. + .name = "rootfs",
  7154. + .offset = 0x0160000,
  7155. + .size = 0x1e60000,
  7156. + }, {
  7157. + .name = "user_property",
  7158. + .offset = 0x1fc0000,
  7159. + .size = 0x0020000,
  7160. + .mask_flags = MTD_WRITEABLE,
  7161. + }, {
  7162. + .name = "art",
  7163. + .offset = 0x1fe0000,
  7164. + .size = 0x0020000,
  7165. + .mask_flags = MTD_WRITEABLE,
  7166. + }, {
  7167. + .name = "firmware",
  7168. + .offset = 0x0060000,
  7169. + .size = 0x1f60000,
  7170. + }
  7171. +};
  7172. +#endif /* CONFIG_MTD_PARTITIONS */
  7173. +
  7174. +static struct ar91xx_flash_platform_data wzrhpg300nh_flash_data = {
  7175. + .width = 2,
  7176. +#ifdef CONFIG_MTD_PARTITIONS
  7177. + .parts = wzrhpg300nh_flash_partitions,
  7178. + .nr_parts = ARRAY_SIZE(wzrhpg300nh_flash_partitions),
  7179. +#endif
  7180. +};
  7181. +
  7182. +#define WZRHPG300NH_FLASH_BASE 0x1e000000
  7183. +#define WZRHPG300NH_FLASH_SIZE (32 * 1024 * 1024)
  7184. +
  7185. +static struct resource wzrhpg300nh_flash_resources[] = {
  7186. + [0] = {
  7187. + .start = WZRHPG300NH_FLASH_BASE,
  7188. + .end = WZRHPG300NH_FLASH_BASE + WZRHPG300NH_FLASH_SIZE - 1,
  7189. + .flags = IORESOURCE_MEM,
  7190. + },
  7191. +};
  7192. +
  7193. +static struct platform_device wzrhpg300nh_flash_device = {
  7194. + .name = "ar91xx-flash",
  7195. + .id = -1,
  7196. + .resource = wzrhpg300nh_flash_resources,
  7197. + .num_resources = ARRAY_SIZE(wzrhpg300nh_flash_resources),
  7198. + .dev = {
  7199. + .platform_data = &wzrhpg300nh_flash_data,
  7200. + }
  7201. +};
  7202. +
  7203. +static struct gpio_led wzrhpg300nh_leds_gpio[] __initdata = {
  7204. + {
  7205. + .name = "wzr-hp-g300nh:orange:security",
  7206. + .gpio = WZRHPG300NH_GPIO_LED_SECURITY,
  7207. + .active_low = 1,
  7208. + }, {
  7209. + .name = "wzr-hp-g300nh:green:wireless",
  7210. + .gpio = WZRHPG300NH_GPIO_LED_WIRELESS,
  7211. + .active_low = 1,
  7212. + }, {
  7213. + .name = "wzr-hp-g300nh:green:router",
  7214. + .gpio = WZRHPG300NH_GPIO_LED_ROUTER,
  7215. + .active_low = 1,
  7216. + }, {
  7217. + .name = "wzr-hp-g300nh:red:diag",
  7218. + .gpio = WZRHPG300NH_GPIO_LED_DIAG,
  7219. + .active_low = 1,
  7220. + }, {
  7221. + .name = "wzr-hp-g300nh:blue:usb",
  7222. + .gpio = WZRHPG300NH_GPIO_LED_USB,
  7223. + .active_low = 1,
  7224. + }
  7225. +};
  7226. +
  7227. +static struct gpio_button wzrhpg300nh_gpio_buttons[] __initdata = {
  7228. + {
  7229. + .desc = "reset",
  7230. + .type = EV_KEY,
  7231. + .code = KEY_RESTART,
  7232. + .threshold = 3,
  7233. + .gpio = WZRHPG300NH_GPIO_BTN_RESET,
  7234. + .active_low = 1,
  7235. + }, {
  7236. + .desc = "aoss",
  7237. + .type = EV_KEY,
  7238. + .code = KEY_WPS_BUTTON,
  7239. + .threshold = 3,
  7240. + .gpio = WZRHPG300NH_GPIO_BTN_AOSS,
  7241. + .active_low = 1,
  7242. + }, {
  7243. + .desc = "usb",
  7244. + .type = EV_KEY,
  7245. + .code = BTN_2,
  7246. + .threshold = 3,
  7247. + .gpio = WZRHPG300NH_GPIO_BTN_USB,
  7248. + .active_low = 1,
  7249. + }, {
  7250. + .desc = "qos_on",
  7251. + .type = EV_KEY,
  7252. + .code = BTN_3,
  7253. + .threshold = 3,
  7254. + .gpio = WZRHPG300NH_GPIO_BTN_QOS_ON,
  7255. + .active_low = 0,
  7256. + }, {
  7257. + .desc = "qos_off",
  7258. + .type = EV_KEY,
  7259. + .code = BTN_4,
  7260. + .threshold = 3,
  7261. + .gpio = WZRHPG300NH_GPIO_BTN_QOS_OFF,
  7262. + .active_low = 0,
  7263. + }, {
  7264. + .desc = "router_on",
  7265. + .type = EV_KEY,
  7266. + .code = BTN_5,
  7267. + .threshold = 3,
  7268. + .gpio = WZRHPG300NH_GPIO_BTN_ROUTER_ON,
  7269. + .active_low = 0,
  7270. + }, {
  7271. + .desc = "router_auto",
  7272. + .type = EV_KEY,
  7273. + .code = BTN_6,
  7274. + .threshold = 3,
  7275. + .gpio = WZRHPG300NH_GPIO_BTN_ROUTER_AUTO,
  7276. + .active_low = 0,
  7277. + }
  7278. +};
  7279. +
  7280. +static struct nxp_74hc153_platform_data wzrhpg300nh_74hc153_data = {
  7281. + .gpio_base = WZRHPG300NH_GPIO_EXP_BASE,
  7282. + .gpio_pin_s0 = WZRHPG300NH_GPIO_74HC153_S0,
  7283. + .gpio_pin_s1 = WZRHPG300NH_GPIO_74HC153_S1,
  7284. + .gpio_pin_1y = WZRHPG300NH_GPIO_74HC153_1Y,
  7285. + .gpio_pin_2y = WZRHPG300NH_GPIO_74HC153_2Y,
  7286. +};
  7287. +
  7288. +static struct platform_device wzrhpg300nh_74hc153_device = {
  7289. + .name = NXP_74HC153_DRIVER_NAME,
  7290. + .id = -1,
  7291. + .dev = {
  7292. + .platform_data = &wzrhpg300nh_74hc153_data,
  7293. + }
  7294. +};
  7295. +
  7296. +static struct rtl8366s_platform_data wzrhpg300nh_rtl8366s_data = {
  7297. + .gpio_sda = WZRHPG300NH_GPIO_RTL8366_SDA,
  7298. + .gpio_sck = WZRHPG300NH_GPIO_RTL8366_SCK,
  7299. +};
  7300. +
  7301. +static struct platform_device wzrhpg300nh_rtl8366s_device = {
  7302. + .name = RTL8366S_DRIVER_NAME,
  7303. + .id = -1,
  7304. + .dev = {
  7305. + .platform_data = &wzrhpg300nh_rtl8366s_data,
  7306. + }
  7307. +};
  7308. +
  7309. +static void __init wzrhpg300nh_setup(void)
  7310. +{
  7311. + u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  7312. +
  7313. + ar71xx_set_mac_base(eeprom + WZRHPG300NH_MAC_OFFSET);
  7314. +
  7315. + ar71xx_eth0_pll_data.pll_1000 = 0x1e000100;
  7316. + ar71xx_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev;
  7317. + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  7318. + ar71xx_eth0_data.speed = SPEED_1000;
  7319. + ar71xx_eth0_data.duplex = DUPLEX_FULL;
  7320. +
  7321. + ar71xx_eth1_pll_data.pll_1000 = 0x1e000100;
  7322. + ar71xx_eth1_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev;
  7323. + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  7324. + ar71xx_eth1_data.phy_mask = 0x10;
  7325. +
  7326. + ar71xx_add_device_eth(0);
  7327. + ar71xx_add_device_eth(1);
  7328. +
  7329. + ar71xx_add_device_usb();
  7330. + ar913x_add_device_wmac(eeprom, NULL);
  7331. +
  7332. + platform_device_register(&wzrhpg300nh_74hc153_device);
  7333. + platform_device_register(&wzrhpg300nh_flash_device);
  7334. + platform_device_register(&wzrhpg300nh_rtl8366s_device);
  7335. +
  7336. + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh_leds_gpio),
  7337. + wzrhpg300nh_leds_gpio);
  7338. +
  7339. + ar71xx_add_device_gpio_buttons(-1, WZRHPG300NH_BUTTONS_POLL_INTERVAL,
  7340. + ARRAY_SIZE(wzrhpg300nh_gpio_buttons),
  7341. + wzrhpg300nh_gpio_buttons);
  7342. +
  7343. +}
  7344. +
  7345. +MIPS_MACHINE(AR71XX_MACH_WZR_HP_G300NH, "WZR-HP-G300NH",
  7346. + "Buffalo WZR-HP-G300NH", wzrhpg300nh_setup);
  7347. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/Makefile linux-2.6.35.7/arch/mips/ar71xx/Makefile
  7348. --- linux-2.6.35.7.orig/arch/mips/ar71xx/Makefile 1970-01-01 01:00:00.000000000 +0100
  7349. +++ linux-2.6.35.7/arch/mips/ar71xx/Makefile 2010-10-14 20:27:58.505507309 +0200
  7350. @@ -0,0 +1,54 @@
  7351. +#
  7352. +# Makefile for the Atheros AR71xx SoC specific parts of the kernel
  7353. +#
  7354. +# Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  7355. +# Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  7356. +#
  7357. +# This program is free software; you can redistribute it and/or modify it
  7358. +# under the terms of the GNU General Public License version 2 as published
  7359. +# by the Free Software Foundation.
  7360. +
  7361. +obj-y := prom.o irq.o setup.o devices.o gpio.o ar71xx.o
  7362. +
  7363. +obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
  7364. +obj-$(CONFIG_PCI) += pci.o
  7365. +
  7366. +obj-$(CONFIG_AR71XX_DEV_AP91_ETH) += dev-ap91-eth.o
  7367. +obj-$(CONFIG_AR71XX_DEV_AP91_PCI) += dev-ap91-pci.o
  7368. +obj-$(CONFIG_AR71XX_DEV_AP94_PCI) += dev-ap94-pci.o
  7369. +obj-$(CONFIG_AR71XX_DEV_AR913X_WMAC) += dev-ar913x-wmac.o
  7370. +obj-$(CONFIG_AR71XX_DEV_DSA) += dev-dsa.o
  7371. +obj-$(CONFIG_AR71XX_DEV_GPIO_BUTTONS) += dev-gpio-buttons.o
  7372. +obj-$(CONFIG_AR71XX_DEV_LEDS_GPIO) += dev-leds-gpio.o
  7373. +obj-$(CONFIG_AR71XX_DEV_M25P80) += dev-m25p80.o
  7374. +obj-$(CONFIG_AR71XX_DEV_PB42_PCI) += dev-pb42-pci.o
  7375. +obj-$(CONFIG_AR71XX_DEV_PB9X_PCI) += dev-pb9x-pci.o
  7376. +obj-$(CONFIG_AR71XX_DEV_USB) += dev-usb.o
  7377. +
  7378. +obj-$(CONFIG_AR71XX_NVRAM) += nvram.o
  7379. +
  7380. +obj-$(CONFIG_AR71XX_MACH_AP81) += mach-ap81.o
  7381. +obj-$(CONFIG_AR71XX_MACH_AP83) += mach-ap83.o
  7382. +obj-$(CONFIG_AR71XX_MACH_AW_NR580) += mach-aw-nr580.o
  7383. +obj-$(CONFIG_AR71XX_MACH_DIR_600_A1) += mach-dir-600-a1.o
  7384. +obj-$(CONFIG_AR71XX_MACH_DIR_615_C1) += mach-dir-615-c1.o
  7385. +obj-$(CONFIG_AR71XX_MACH_DIR_825_B1) += mach-dir-825-b1.o
  7386. +obj-$(CONFIG_AR71XX_MACH_MZK_W04NU) += mach-mzk-w04nu.o
  7387. +obj-$(CONFIG_AR71XX_MACH_MZK_W300NH) += mach-mzk-w300nh.o
  7388. +obj-$(CONFIG_AR71XX_MACH_NBG460N) += mach-nbg460n.o
  7389. +obj-$(CONFIG_AR71XX_MACH_PB42) += mach-pb42.o
  7390. +obj-$(CONFIG_AR71XX_MACH_PB44) += mach-pb44.o
  7391. +obj-$(CONFIG_AR71XX_MACH_PB92) += mach-pb92.o
  7392. +obj-$(CONFIG_AR71XX_MACH_RB4XX) += mach-rb4xx.o
  7393. +obj-$(CONFIG_AR71XX_MACH_RB750) += mach-rb750.o
  7394. +obj-$(CONFIG_AR71XX_MACH_TEW_632BRP) += mach-tew-632brp.o
  7395. +obj-$(CONFIG_AR71XX_MACH_TL_WR741ND) += mach-tl-wr741nd.o
  7396. +obj-$(CONFIG_AR71XX_MACH_TL_WR841N_V1) += mach-tl-wr841n.o
  7397. +obj-$(CONFIG_AR71XX_MACH_TL_WR941ND) += mach-tl-wr941nd.o
  7398. +obj-$(CONFIG_AR71XX_MACH_TL_WR1043ND) += mach-tl-wr1043nd.o
  7399. +obj-$(CONFIG_AR71XX_MACH_UBNT) += mach-ubnt.o
  7400. +obj-$(CONFIG_AR71XX_MACH_WNDR3700) += mach-wndr3700.o
  7401. +obj-$(CONFIG_AR71XX_MACH_WNR2000) += mach-wnr2000.o
  7402. +obj-$(CONFIG_AR71XX_MACH_WP543) += mach-wp543.o
  7403. +obj-$(CONFIG_AR71XX_MACH_WRT160NL) += mach-wrt160nl.o
  7404. +obj-$(CONFIG_AR71XX_MACH_WRT400N) += mach-wrt400n.o
  7405. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/nvram.c linux-2.6.35.7/arch/mips/ar71xx/nvram.c
  7406. --- linux-2.6.35.7.orig/arch/mips/ar71xx/nvram.c 1970-01-01 01:00:00.000000000 +0100
  7407. +++ linux-2.6.35.7/arch/mips/ar71xx/nvram.c 2010-10-14 20:27:58.555317270 +0200
  7408. @@ -0,0 +1,75 @@
  7409. +/*
  7410. + * Atheros AR71xx minimal nvram support
  7411. + *
  7412. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  7413. + *
  7414. + * This program is free software; you can redistribute it and/or modify it
  7415. + * under the terms of the GNU General Public License version 2 as published
  7416. + * by the Free Software Foundation.
  7417. + */
  7418. +
  7419. +#include <linux/kernel.h>
  7420. +#include <linux/vmalloc.h>
  7421. +#include <linux/errno.h>
  7422. +#include <linux/init.h>
  7423. +#include <linux/string.h>
  7424. +
  7425. +#include "nvram.h"
  7426. +
  7427. +char *nvram_find_var(const char *name, const char *buf, unsigned buf_len)
  7428. +{
  7429. + unsigned len = strlen(name);
  7430. + char *cur, *last;
  7431. +
  7432. + if (buf_len == 0 || len == 0)
  7433. + return NULL;
  7434. +
  7435. + if (buf_len < len)
  7436. + return NULL;
  7437. +
  7438. + if (len == 1)
  7439. + return memchr(buf, (int) *name, buf_len);
  7440. +
  7441. + last = (char *) buf + buf_len - len;
  7442. + for (cur = (char *) buf; cur <= last; cur++)
  7443. + if (cur[0] == name[0] && memcmp(cur, name, len) == 0)
  7444. + return cur + len;
  7445. +
  7446. + return NULL;
  7447. +}
  7448. +
  7449. +int nvram_parse_mac_addr(const char *nvram, unsigned nvram_len,
  7450. + const char *name, char *mac)
  7451. +{
  7452. + char *buf;
  7453. + char *mac_str;
  7454. + int ret;
  7455. + int t;
  7456. +
  7457. + buf = vmalloc(nvram_len);
  7458. + if (!buf)
  7459. + return -ENOMEM;
  7460. +
  7461. + memcpy(buf, nvram, nvram_len);
  7462. + buf[nvram_len - 1] = '\0';
  7463. +
  7464. + mac_str = nvram_find_var(name, buf, nvram_len);
  7465. + if (!mac_str) {
  7466. + ret = -EINVAL;
  7467. + goto free;
  7468. + }
  7469. +
  7470. + t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
  7471. + &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
  7472. +
  7473. + if (t != 6) {
  7474. + ret = -EINVAL;
  7475. + goto free;
  7476. + }
  7477. +
  7478. + ret = 0;
  7479. +
  7480. + free:
  7481. + vfree(buf);
  7482. + return ret;
  7483. +}
  7484. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/nvram.h linux-2.6.35.7/arch/mips/ar71xx/nvram.h
  7485. --- linux-2.6.35.7.orig/arch/mips/ar71xx/nvram.h 1970-01-01 01:00:00.000000000 +0100
  7486. +++ linux-2.6.35.7/arch/mips/ar71xx/nvram.h 2010-10-14 20:27:58.608101134 +0200
  7487. @@ -0,0 +1,19 @@
  7488. +/*
  7489. + * Atheros AR71xx minimal nvram support
  7490. + *
  7491. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  7492. + *
  7493. + * This program is free software; you can redistribute it and/or modify it
  7494. + * under the terms of the GNU General Public License version 2 as published
  7495. + * by the Free Software Foundation.
  7496. + */
  7497. +
  7498. +#ifndef _AR71XX_NVRAM_H
  7499. +#define _AR71XX_NVRAM_H
  7500. +
  7501. +char *nvram_find_var(const char *name, const char *buf,
  7502. + unsigned buf_len) __init;
  7503. +int nvram_parse_mac_addr(const char *nvram, unsigned nvram_len,
  7504. + const char *name, char *mac) __init;
  7505. +
  7506. +#endif /* _AR71XX_NVRAM_H */
  7507. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/pci.c linux-2.6.35.7/arch/mips/ar71xx/pci.c
  7508. --- linux-2.6.35.7.orig/arch/mips/ar71xx/pci.c 1970-01-01 01:00:00.000000000 +0100
  7509. +++ linux-2.6.35.7/arch/mips/ar71xx/pci.c 2010-10-14 20:27:58.654350228 +0200
  7510. @@ -0,0 +1,93 @@
  7511. +/*
  7512. + * Atheros AR71xx PCI setup code
  7513. + *
  7514. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  7515. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  7516. + *
  7517. + * Parts of this file are based on Atheros' 2.6.15 BSP
  7518. + *
  7519. + * This program is free software; you can redistribute it and/or modify it
  7520. + * under the terms of the GNU General Public License version 2 as published
  7521. + * by the Free Software Foundation.
  7522. + */
  7523. +
  7524. +#include <linux/kernel.h>
  7525. +
  7526. +#include <asm/traps.h>
  7527. +
  7528. +#include <asm/mach-ar71xx/ar71xx.h>
  7529. +#include <asm/mach-ar71xx/pci.h>
  7530. +
  7531. +unsigned ar71xx_pci_nr_irqs __initdata;
  7532. +struct ar71xx_pci_irq *ar71xx_pci_irq_map __initdata;
  7533. +
  7534. +int (*ar71xx_pci_plat_dev_init)(struct pci_dev *dev);
  7535. +
  7536. +static int ar71xx_be_handler(struct pt_regs *regs, int is_fixup)
  7537. +{
  7538. + int err = 0;
  7539. +
  7540. + err = ar71xx_pci_be_handler(is_fixup);
  7541. +
  7542. + return (is_fixup && !err) ? MIPS_BE_FIXUP : MIPS_BE_FATAL;
  7543. +}
  7544. +
  7545. +int pcibios_plat_dev_init(struct pci_dev *dev)
  7546. +{
  7547. + if (ar71xx_pci_plat_dev_init)
  7548. + return ar71xx_pci_plat_dev_init(dev);
  7549. +
  7550. + return 0;
  7551. +}
  7552. +
  7553. +int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
  7554. +{
  7555. + int ret = 0;
  7556. +
  7557. + switch (ar71xx_soc) {
  7558. + case AR71XX_SOC_AR7130:
  7559. + case AR71XX_SOC_AR7141:
  7560. + case AR71XX_SOC_AR7161:
  7561. + ret = ar71xx_pcibios_map_irq(dev, slot, pin);
  7562. + break;
  7563. +
  7564. + case AR71XX_SOC_AR7240:
  7565. + case AR71XX_SOC_AR7241:
  7566. + case AR71XX_SOC_AR7242:
  7567. + ret = ar724x_pcibios_map_irq(dev, slot, pin);
  7568. + break;
  7569. +
  7570. + default:
  7571. + break;
  7572. + }
  7573. +
  7574. + return ret;
  7575. +}
  7576. +
  7577. +int __init ar71xx_pci_init(unsigned nr_irqs, struct ar71xx_pci_irq *map)
  7578. +{
  7579. + int ret = 0;
  7580. +
  7581. + switch (ar71xx_soc) {
  7582. + case AR71XX_SOC_AR7130:
  7583. + case AR71XX_SOC_AR7141:
  7584. + case AR71XX_SOC_AR7161:
  7585. + board_be_handler = ar71xx_be_handler;
  7586. + ret = ar71xx_pcibios_init();
  7587. + break;
  7588. +
  7589. + case AR71XX_SOC_AR7240:
  7590. + case AR71XX_SOC_AR7241:
  7591. + case AR71XX_SOC_AR7242:
  7592. + ret = ar724x_pcibios_init();
  7593. + break;
  7594. +
  7595. + default:
  7596. + return 0;
  7597. + }
  7598. +
  7599. + ar71xx_pci_nr_irqs = nr_irqs;
  7600. + ar71xx_pci_irq_map = map;
  7601. +
  7602. + return ret;
  7603. +}
  7604. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/prom.c linux-2.6.35.7/arch/mips/ar71xx/prom.c
  7605. --- linux-2.6.35.7.orig/arch/mips/ar71xx/prom.c 1970-01-01 01:00:00.000000000 +0100
  7606. +++ linux-2.6.35.7/arch/mips/ar71xx/prom.c 2010-10-14 20:27:58.704773879 +0200
  7607. @@ -0,0 +1,105 @@
  7608. +/*
  7609. + * Atheros AR71xx SoC specific prom routines
  7610. + *
  7611. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  7612. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  7613. + *
  7614. + * This program is free software; you can redistribute it and/or modify it
  7615. + * under the terms of the GNU General Public License version 2 as published
  7616. + * by the Free Software Foundation.
  7617. + */
  7618. +
  7619. +#include <linux/kernel.h>
  7620. +#include <linux/init.h>
  7621. +#include <linux/io.h>
  7622. +#include <linux/string.h>
  7623. +
  7624. +#include <asm/bootinfo.h>
  7625. +#include <asm/addrspace.h>
  7626. +
  7627. +#include <asm/mach-ar71xx/ar71xx.h>
  7628. +
  7629. +static inline int is_valid_ram_addr(void *addr)
  7630. +{
  7631. + if (((u32) addr > KSEG0) &&
  7632. + ((u32) addr < (KSEG0 + AR71XX_MEM_SIZE_MAX)))
  7633. + return 1;
  7634. +
  7635. + if (((u32) addr > KSEG1) &&
  7636. + ((u32) addr < (KSEG1 + AR71XX_MEM_SIZE_MAX)))
  7637. + return 1;
  7638. +
  7639. + return 0;
  7640. +}
  7641. +
  7642. +static void __init ar71xx_prom_append_cmdline(const char *name,
  7643. + const char *value)
  7644. +{
  7645. + char buf[COMMAND_LINE_SIZE];
  7646. +
  7647. + snprintf(buf, sizeof(buf), " %s=%s", name, value);
  7648. + strlcat(arcs_cmdline, buf, sizeof(arcs_cmdline));
  7649. +}
  7650. +
  7651. +static void __init ar71xx_prom_find_env(char **envp, const char *name)
  7652. +{
  7653. + int len = strlen(name);
  7654. + char **p;
  7655. +
  7656. + if (!is_valid_ram_addr(envp))
  7657. + return;
  7658. +
  7659. + for (p = envp; is_valid_ram_addr(*p); p++) {
  7660. + if (strncmp(name, *p, len) == 0 && (*p)[len] == '=') {
  7661. + ar71xx_prom_append_cmdline(name, *p + len + 1);
  7662. + break;
  7663. + }
  7664. +
  7665. + /* RedBoot env comes in pointer pairs - key, value */
  7666. + if (strncmp(name, *p, len) == 0 && (*p)[len] == 0)
  7667. + if (is_valid_ram_addr(*(++p))) {
  7668. + ar71xx_prom_append_cmdline(name, *p);
  7669. + break;
  7670. + }
  7671. + }
  7672. +}
  7673. +
  7674. +static int inline ar71xx_use__image_cmdline(void) { return 0; }
  7675. +
  7676. +static __init void ar71xx_prom_init_cmdline(int argc, char **argv)
  7677. +{
  7678. + int i;
  7679. +
  7680. + if (ar71xx_use__image_cmdline())
  7681. + return;
  7682. +
  7683. + if (!is_valid_ram_addr(argv))
  7684. + return;
  7685. +
  7686. + for (i = 0; i < argc; i++)
  7687. + if (is_valid_ram_addr(argv[i])) {
  7688. + strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline));
  7689. + strlcat(arcs_cmdline, argv[i], sizeof(arcs_cmdline));
  7690. + }
  7691. +}
  7692. +
  7693. +void __init prom_init(void)
  7694. +{
  7695. + char **envp;
  7696. +
  7697. + printk(KERN_DEBUG "prom: fw_arg0=%08x, fw_arg1=%08x, "
  7698. + "fw_arg2=%08x, fw_arg3=%08x\n",
  7699. + (unsigned int)fw_arg0, (unsigned int)fw_arg1,
  7700. + (unsigned int)fw_arg2, (unsigned int)fw_arg3);
  7701. +
  7702. +
  7703. + ar71xx_prom_init_cmdline(fw_arg0, (char **)fw_arg1);
  7704. +
  7705. + envp = (char **)fw_arg2;
  7706. + ar71xx_prom_find_env(envp, "board");
  7707. +}
  7708. +
  7709. +void __init prom_free_prom_memory(void)
  7710. +{
  7711. + /* We do not have to prom memory to free */
  7712. +}
  7713. diff -Nur linux-2.6.35.7.orig/arch/mips/ar71xx/setup.c linux-2.6.35.7/arch/mips/ar71xx/setup.c
  7714. --- linux-2.6.35.7.orig/arch/mips/ar71xx/setup.c 1970-01-01 01:00:00.000000000 +0100
  7715. +++ linux-2.6.35.7/arch/mips/ar71xx/setup.c 2010-10-14 20:27:58.754579813 +0200
  7716. @@ -0,0 +1,310 @@
  7717. +/*
  7718. + * Atheros AR71xx SoC specific setup
  7719. + *
  7720. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  7721. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  7722. + *
  7723. + * Parts of this file are based on Atheros' 2.6.15 BSP
  7724. + *
  7725. + * This program is free software; you can redistribute it and/or modify it
  7726. + * under the terms of the GNU General Public License version 2 as published
  7727. + * by the Free Software Foundation.
  7728. + */
  7729. +
  7730. +#include <linux/kernel.h>
  7731. +#include <linux/init.h>
  7732. +#include <linux/bootmem.h>
  7733. +
  7734. +#include <asm/bootinfo.h>
  7735. +#include <asm/time.h> /* for mips_hpt_frequency */
  7736. +#include <asm/reboot.h> /* for _machine_{restart,halt} */
  7737. +#include <asm/mips_machine.h>
  7738. +
  7739. +#include <asm/mach-ar71xx/ar71xx.h>
  7740. +
  7741. +#include "machtype.h"
  7742. +#include "devices.h"
  7743. +
  7744. +#define AR71XX_SYS_TYPE_LEN 64
  7745. +#define AR71XX_BASE_FREQ 40000000
  7746. +#define AR91XX_BASE_FREQ 5000000
  7747. +#define AR724X_BASE_FREQ 5000000
  7748. +
  7749. +u32 ar71xx_cpu_freq;
  7750. +EXPORT_SYMBOL_GPL(ar71xx_cpu_freq);
  7751. +
  7752. +u32 ar71xx_ahb_freq;
  7753. +EXPORT_SYMBOL_GPL(ar71xx_ahb_freq);
  7754. +
  7755. +u32 ar71xx_ddr_freq;
  7756. +EXPORT_SYMBOL_GPL(ar71xx_ddr_freq);
  7757. +
  7758. +enum ar71xx_soc_type ar71xx_soc;
  7759. +EXPORT_SYMBOL_GPL(ar71xx_soc);
  7760. +
  7761. +static char ar71xx_sys_type[AR71XX_SYS_TYPE_LEN];
  7762. +
  7763. +static void ar71xx_restart(char *command)
  7764. +{
  7765. + ar71xx_device_stop(RESET_MODULE_FULL_CHIP);
  7766. + for (;;)
  7767. + if (cpu_wait)
  7768. + cpu_wait();
  7769. +}
  7770. +
  7771. +static void ar71xx_halt(void)
  7772. +{
  7773. + while (1)
  7774. + cpu_wait();
  7775. +}
  7776. +
  7777. +static void __init ar71xx_detect_mem_size(void)
  7778. +{
  7779. + unsigned long size;
  7780. +
  7781. + for (size = AR71XX_MEM_SIZE_MIN; size < AR71XX_MEM_SIZE_MAX;
  7782. + size <<= 1 ) {
  7783. + if (!memcmp(ar71xx_detect_mem_size,
  7784. + ar71xx_detect_mem_size + size, 1024))
  7785. + break;
  7786. + }
  7787. +
  7788. + add_memory_region(0, size, BOOT_MEM_RAM);
  7789. +}
  7790. +
  7791. +static void __init ar71xx_detect_sys_type(void)
  7792. +{
  7793. + char *chip = "????";
  7794. + u32 id;
  7795. + u32 major;
  7796. + u32 minor;
  7797. + u32 rev = 0;
  7798. +
  7799. + id = ar71xx_reset_rr(AR71XX_RESET_REG_REV_ID);
  7800. + major = id & REV_ID_MAJOR_MASK;
  7801. +
  7802. + switch (major) {
  7803. + case REV_ID_MAJOR_AR71XX:
  7804. + minor = id & AR71XX_REV_ID_MINOR_MASK;
  7805. + rev = id >> AR71XX_REV_ID_REVISION_SHIFT;
  7806. + rev &= AR71XX_REV_ID_REVISION_MASK;
  7807. + switch (minor) {
  7808. + case AR71XX_REV_ID_MINOR_AR7130:
  7809. + ar71xx_soc = AR71XX_SOC_AR7130;
  7810. + chip = "7130";
  7811. + break;
  7812. +
  7813. + case AR71XX_REV_ID_MINOR_AR7141:
  7814. + ar71xx_soc = AR71XX_SOC_AR7141;
  7815. + chip = "7141";
  7816. + break;
  7817. +
  7818. + case AR71XX_REV_ID_MINOR_AR7161:
  7819. + ar71xx_soc = AR71XX_SOC_AR7161;
  7820. + chip = "7161";
  7821. + break;
  7822. + }
  7823. + break;
  7824. +
  7825. + case REV_ID_MAJOR_AR7240:
  7826. + ar71xx_soc = AR71XX_SOC_AR7240;
  7827. + chip = "7240";
  7828. + rev = (id & AR724X_REV_ID_REVISION_MASK);
  7829. + break;
  7830. +
  7831. + case REV_ID_MAJOR_AR7241:
  7832. + ar71xx_soc = AR71XX_SOC_AR7241;
  7833. + chip = "7241";
  7834. + rev = (id & AR724X_REV_ID_REVISION_MASK);
  7835. + break;
  7836. +
  7837. + case REV_ID_MAJOR_AR7242:
  7838. + ar71xx_soc = AR71XX_SOC_AR7242;
  7839. + chip = "7242";
  7840. + rev = (id & AR724X_REV_ID_REVISION_MASK);
  7841. + break;
  7842. +
  7843. + case REV_ID_MAJOR_AR913X:
  7844. + minor = id & AR91XX_REV_ID_MINOR_MASK;
  7845. + rev = id >> AR91XX_REV_ID_REVISION_SHIFT;
  7846. + rev &= AR91XX_REV_ID_REVISION_MASK;
  7847. + switch (minor) {
  7848. + case AR91XX_REV_ID_MINOR_AR9130:
  7849. + ar71xx_soc = AR71XX_SOC_AR9130;
  7850. + chip = "9130";
  7851. + break;
  7852. +
  7853. + case AR91XX_REV_ID_MINOR_AR9132:
  7854. + ar71xx_soc = AR71XX_SOC_AR9132;
  7855. + chip = "9132";
  7856. + break;
  7857. + }
  7858. + break;
  7859. +
  7860. + default:
  7861. + panic("ar71xx: unknown chip id:0x%08x\n", id);
  7862. + }
  7863. +
  7864. + sprintf(ar71xx_sys_type, "Atheros AR%s rev %u", chip, rev);
  7865. +}
  7866. +
  7867. +static void __init ar91xx_detect_sys_frequency(void)
  7868. +{
  7869. + u32 pll;
  7870. + u32 freq;
  7871. + u32 div;
  7872. +
  7873. + pll = ar71xx_pll_rr(AR91XX_PLL_REG_CPU_CONFIG);
  7874. +
  7875. + div = ((pll >> AR91XX_PLL_DIV_SHIFT) & AR91XX_PLL_DIV_MASK);
  7876. + freq = div * AR91XX_BASE_FREQ;
  7877. +
  7878. + ar71xx_cpu_freq = freq;
  7879. +
  7880. + div = ((pll >> AR91XX_DDR_DIV_SHIFT) & AR91XX_DDR_DIV_MASK) + 1;
  7881. + ar71xx_ddr_freq = freq / div;
  7882. +
  7883. + div = (((pll >> AR91XX_AHB_DIV_SHIFT) & AR91XX_AHB_DIV_MASK) + 1) * 2;
  7884. + ar71xx_ahb_freq = ar71xx_cpu_freq / div;
  7885. +}
  7886. +
  7887. +static void __init ar71xx_detect_sys_frequency(void)
  7888. +{
  7889. + u32 pll;
  7890. + u32 freq;
  7891. + u32 div;
  7892. +
  7893. + pll = ar71xx_pll_rr(AR71XX_PLL_REG_CPU_CONFIG);
  7894. +
  7895. + div = ((pll >> AR71XX_PLL_DIV_SHIFT) & AR71XX_PLL_DIV_MASK) + 1;
  7896. + freq = div * AR71XX_BASE_FREQ;
  7897. +
  7898. + div = ((pll >> AR71XX_CPU_DIV_SHIFT) & AR71XX_CPU_DIV_MASK) + 1;
  7899. + ar71xx_cpu_freq = freq / div;
  7900. +
  7901. + div = ((pll >> AR71XX_DDR_DIV_SHIFT) & AR71XX_DDR_DIV_MASK) + 1;
  7902. + ar71xx_ddr_freq = freq / div;
  7903. +
  7904. + div = (((pll >> AR71XX_AHB_DIV_SHIFT) & AR71XX_AHB_DIV_MASK) + 1) * 2;
  7905. + ar71xx_ahb_freq = ar71xx_cpu_freq / div;
  7906. +}
  7907. +
  7908. +static void __init ar724x_detect_sys_frequency(void)
  7909. +{
  7910. + u32 pll;
  7911. + u32 freq;
  7912. + u32 div;
  7913. +
  7914. + pll = ar71xx_pll_rr(AR724X_PLL_REG_CPU_CONFIG);
  7915. +
  7916. + div = ((pll >> AR724X_PLL_DIV_SHIFT) & AR724X_PLL_DIV_MASK);
  7917. + freq = div * AR724X_BASE_FREQ;
  7918. +
  7919. + div = ((pll >> AR724X_PLL_REF_DIV_SHIFT) & AR724X_PLL_REF_DIV_MASK);
  7920. + freq *= div;
  7921. +
  7922. + ar71xx_cpu_freq = freq;
  7923. +
  7924. + div = ((pll >> AR724X_DDR_DIV_SHIFT) & AR724X_DDR_DIV_MASK) + 1;
  7925. + ar71xx_ddr_freq = freq / div;
  7926. +
  7927. + div = (((pll >> AR724X_AHB_DIV_SHIFT) & AR724X_AHB_DIV_MASK) + 1) * 2;
  7928. + ar71xx_ahb_freq = ar71xx_cpu_freq / div;
  7929. +}
  7930. +
  7931. +static void __init detect_sys_frequency(void)
  7932. +{
  7933. + switch (ar71xx_soc) {
  7934. + case AR71XX_SOC_AR7130:
  7935. + case AR71XX_SOC_AR7141:
  7936. + case AR71XX_SOC_AR7161:
  7937. + ar71xx_detect_sys_frequency();
  7938. + break;
  7939. +
  7940. + case AR71XX_SOC_AR7240:
  7941. + case AR71XX_SOC_AR7241:
  7942. + case AR71XX_SOC_AR7242:
  7943. + ar724x_detect_sys_frequency();
  7944. + break;
  7945. +
  7946. + case AR71XX_SOC_AR9130:
  7947. + case AR71XX_SOC_AR9132:
  7948. + ar91xx_detect_sys_frequency();
  7949. + break;
  7950. +
  7951. + default:
  7952. + BUG();
  7953. + }
  7954. +}
  7955. +
  7956. +const char *get_system_type(void)
  7957. +{
  7958. + return ar71xx_sys_type;
  7959. +}
  7960. +
  7961. +unsigned int __cpuinit get_c0_compare_irq(void)
  7962. +{
  7963. + return CP0_LEGACY_COMPARE_IRQ;
  7964. +}
  7965. +
  7966. +void __init plat_mem_setup(void)
  7967. +{
  7968. + set_io_port_base(KSEG1);
  7969. +
  7970. + ar71xx_ddr_base = ioremap_nocache(AR71XX_DDR_CTRL_BASE,
  7971. + AR71XX_DDR_CTRL_SIZE);
  7972. +
  7973. + ar71xx_pll_base = ioremap_nocache(AR71XX_PLL_BASE,
  7974. + AR71XX_PLL_SIZE);
  7975. +
  7976. + ar71xx_reset_base = ioremap_nocache(AR71XX_RESET_BASE,
  7977. + AR71XX_RESET_SIZE);
  7978. +
  7979. + ar71xx_gpio_base = ioremap_nocache(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE);
  7980. +
  7981. + ar71xx_usb_ctrl_base = ioremap_nocache(AR71XX_USB_CTRL_BASE,
  7982. + AR71XX_USB_CTRL_SIZE);
  7983. +
  7984. + ar71xx_detect_mem_size();
  7985. + ar71xx_detect_sys_type();
  7986. + detect_sys_frequency();
  7987. +
  7988. + printk(KERN_INFO
  7989. + "%s, CPU:%u.%03u MHz, AHB:%u.%03u MHz, DDR:%u.%03u MHz\n",
  7990. + ar71xx_sys_type,
  7991. + ar71xx_cpu_freq / 1000000, (ar71xx_cpu_freq / 1000) % 1000,
  7992. + ar71xx_ahb_freq / 1000000, (ar71xx_ahb_freq / 1000) % 1000,
  7993. + ar71xx_ddr_freq / 1000000, (ar71xx_ddr_freq / 1000) % 1000);
  7994. +
  7995. + _machine_restart = ar71xx_restart;
  7996. + _machine_halt = ar71xx_halt;
  7997. + pm_power_off = ar71xx_halt;
  7998. +}
  7999. +
  8000. +void __init plat_time_init(void)
  8001. +{
  8002. + mips_hpt_frequency = ar71xx_cpu_freq / 2;
  8003. +}
  8004. +
  8005. +__setup("board=", mips_machtype_setup);
  8006. +
  8007. +static int __init ar71xx_machine_setup(void)
  8008. +{
  8009. + ar71xx_gpio_init();
  8010. +
  8011. + ar71xx_add_device_uart();
  8012. + ar71xx_add_device_wdt();
  8013. +
  8014. + mips_machine_setup();
  8015. + return 0;
  8016. +}
  8017. +
  8018. +arch_initcall(ar71xx_machine_setup);
  8019. +
  8020. +static void __init ar71xx_generic_init(void)
  8021. +{
  8022. + /* Nothing to do */
  8023. +}
  8024. +
  8025. +MIPS_MACHINE(AR71XX_MACH_GENERIC, "Generic", "Generic AR71xx board",
  8026. + ar71xx_generic_init);
  8027. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/ar71xx.h linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/ar71xx.h
  8028. --- linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/ar71xx.h 1970-01-01 01:00:00.000000000 +0100
  8029. +++ linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/ar71xx.h 2010-10-14 20:27:58.804410665 +0200
  8030. @@ -0,0 +1,514 @@
  8031. +/*
  8032. + * Atheros AR71xx SoC specific definitions
  8033. + *
  8034. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  8035. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  8036. + *
  8037. + * Parts of this file are based on Atheros' 2.6.15 BSP
  8038. + *
  8039. + * This program is free software; you can redistribute it and/or modify it
  8040. + * under the terms of the GNU General Public License version 2 as published
  8041. + * by the Free Software Foundation.
  8042. + */
  8043. +
  8044. +#ifndef __ASM_MACH_AR71XX_H
  8045. +#define __ASM_MACH_AR71XX_H
  8046. +
  8047. +#include <linux/types.h>
  8048. +#include <linux/init.h>
  8049. +#include <linux/io.h>
  8050. +#include <linux/bitops.h>
  8051. +
  8052. +#ifndef __ASSEMBLER__
  8053. +
  8054. +#define AR71XX_PCI_MEM_BASE 0x10000000
  8055. +#define AR71XX_PCI_MEM_SIZE 0x08000000
  8056. +#define AR71XX_APB_BASE 0x18000000
  8057. +#define AR71XX_GE0_BASE 0x19000000
  8058. +#define AR71XX_GE0_SIZE 0x01000000
  8059. +#define AR71XX_GE1_BASE 0x1a000000
  8060. +#define AR71XX_GE1_SIZE 0x01000000
  8061. +#define AR71XX_EHCI_BASE 0x1b000000
  8062. +#define AR71XX_EHCI_SIZE 0x01000000
  8063. +#define AR71XX_OHCI_BASE 0x1c000000
  8064. +#define AR71XX_OHCI_SIZE 0x01000000
  8065. +#define AR7240_OHCI_BASE 0x1b000000
  8066. +#define AR7240_OHCI_SIZE 0x01000000
  8067. +#define AR71XX_SPI_BASE 0x1f000000
  8068. +#define AR71XX_SPI_SIZE 0x01000000
  8069. +
  8070. +#define AR71XX_DDR_CTRL_BASE (AR71XX_APB_BASE + 0x00000000)
  8071. +#define AR71XX_DDR_CTRL_SIZE 0x10000
  8072. +#define AR71XX_CPU_BASE (AR71XX_APB_BASE + 0x00010000)
  8073. +#define AR71XX_UART_BASE (AR71XX_APB_BASE + 0x00020000)
  8074. +#define AR71XX_UART_SIZE 0x10000
  8075. +#define AR71XX_USB_CTRL_BASE (AR71XX_APB_BASE + 0x00030000)
  8076. +#define AR71XX_USB_CTRL_SIZE 0x10000
  8077. +#define AR71XX_GPIO_BASE (AR71XX_APB_BASE + 0x00040000)
  8078. +#define AR71XX_GPIO_SIZE 0x10000
  8079. +#define AR71XX_PLL_BASE (AR71XX_APB_BASE + 0x00050000)
  8080. +#define AR71XX_PLL_SIZE 0x10000
  8081. +#define AR71XX_RESET_BASE (AR71XX_APB_BASE + 0x00060000)
  8082. +#define AR71XX_RESET_SIZE 0x10000
  8083. +#define AR71XX_MII_BASE (AR71XX_APB_BASE + 0x00070000)
  8084. +#define AR71XX_MII_SIZE 0x10000
  8085. +#define AR71XX_SLIC_BASE (AR71XX_APB_BASE + 0x00090000)
  8086. +#define AR71XX_SLIC_SIZE 0x10000
  8087. +#define AR71XX_DMA_BASE (AR71XX_APB_BASE + 0x000A0000)
  8088. +#define AR71XX_DMA_SIZE 0x10000
  8089. +#define AR71XX_STEREO_BASE (AR71XX_APB_BASE + 0x000B0000)
  8090. +#define AR71XX_STEREO_SIZE 0x10000
  8091. +
  8092. +#define AR724X_PCI_CRP_BASE (AR71XX_APB_BASE + 0x000C0000)
  8093. +#define AR724X_PCI_CRP_SIZE 0x100
  8094. +
  8095. +#define AR724X_PCI_CTRL_BASE (AR71XX_APB_BASE + 0x000F0000)
  8096. +#define AR724X_PCI_CTRL_SIZE 0x100
  8097. +
  8098. +#define AR91XX_WMAC_BASE (AR71XX_APB_BASE + 0x000C0000)
  8099. +#define AR91XX_WMAC_SIZE 0x30000
  8100. +
  8101. +#define AR71XX_MEM_SIZE_MIN 0x0200000
  8102. +#define AR71XX_MEM_SIZE_MAX 0x10000000
  8103. +
  8104. +#define AR71XX_CPU_IRQ_BASE 0
  8105. +#define AR71XX_MISC_IRQ_BASE 8
  8106. +#define AR71XX_MISC_IRQ_COUNT 8
  8107. +#define AR71XX_GPIO_IRQ_BASE 16
  8108. +#define AR71XX_GPIO_IRQ_COUNT 32
  8109. +#define AR71XX_PCI_IRQ_BASE 48
  8110. +#define AR71XX_PCI_IRQ_COUNT 8
  8111. +
  8112. +#define AR71XX_CPU_IRQ_IP2 (AR71XX_CPU_IRQ_BASE + 2)
  8113. +#define AR71XX_CPU_IRQ_USB (AR71XX_CPU_IRQ_BASE + 3)
  8114. +#define AR71XX_CPU_IRQ_GE0 (AR71XX_CPU_IRQ_BASE + 4)
  8115. +#define AR71XX_CPU_IRQ_GE1 (AR71XX_CPU_IRQ_BASE + 5)
  8116. +#define AR71XX_CPU_IRQ_MISC (AR71XX_CPU_IRQ_BASE + 6)
  8117. +#define AR71XX_CPU_IRQ_TIMER (AR71XX_CPU_IRQ_BASE + 7)
  8118. +
  8119. +#define AR71XX_MISC_IRQ_TIMER (AR71XX_MISC_IRQ_BASE + 0)
  8120. +#define AR71XX_MISC_IRQ_ERROR (AR71XX_MISC_IRQ_BASE + 1)
  8121. +#define AR71XX_MISC_IRQ_GPIO (AR71XX_MISC_IRQ_BASE + 2)
  8122. +#define AR71XX_MISC_IRQ_UART (AR71XX_MISC_IRQ_BASE + 3)
  8123. +#define AR71XX_MISC_IRQ_WDOG (AR71XX_MISC_IRQ_BASE + 4)
  8124. +#define AR71XX_MISC_IRQ_PERFC (AR71XX_MISC_IRQ_BASE + 5)
  8125. +#define AR71XX_MISC_IRQ_OHCI (AR71XX_MISC_IRQ_BASE + 6)
  8126. +#define AR71XX_MISC_IRQ_DMA (AR71XX_MISC_IRQ_BASE + 7)
  8127. +
  8128. +#define AR71XX_GPIO_IRQ(_x) (AR71XX_GPIO_IRQ_BASE + (_x))
  8129. +
  8130. +#define AR71XX_PCI_IRQ_DEV0 (AR71XX_PCI_IRQ_BASE + 0)
  8131. +#define AR71XX_PCI_IRQ_DEV1 (AR71XX_PCI_IRQ_BASE + 1)
  8132. +#define AR71XX_PCI_IRQ_DEV2 (AR71XX_PCI_IRQ_BASE + 2)
  8133. +#define AR71XX_PCI_IRQ_CORE (AR71XX_PCI_IRQ_BASE + 4)
  8134. +
  8135. +extern u32 ar71xx_ahb_freq;
  8136. +extern u32 ar71xx_cpu_freq;
  8137. +extern u32 ar71xx_ddr_freq;
  8138. +
  8139. +enum ar71xx_soc_type {
  8140. + AR71XX_SOC_UNKNOWN,
  8141. + AR71XX_SOC_AR7130,
  8142. + AR71XX_SOC_AR7141,
  8143. + AR71XX_SOC_AR7161,
  8144. + AR71XX_SOC_AR7240,
  8145. + AR71XX_SOC_AR7241,
  8146. + AR71XX_SOC_AR7242,
  8147. + AR71XX_SOC_AR9130,
  8148. + AR71XX_SOC_AR9132
  8149. +};
  8150. +
  8151. +extern enum ar71xx_soc_type ar71xx_soc;
  8152. +
  8153. +/*
  8154. + * PLL block
  8155. + */
  8156. +#define AR71XX_PLL_REG_CPU_CONFIG 0x00
  8157. +#define AR71XX_PLL_REG_SEC_CONFIG 0x04
  8158. +#define AR71XX_PLL_REG_ETH0_INT_CLOCK 0x10
  8159. +#define AR71XX_PLL_REG_ETH1_INT_CLOCK 0x14
  8160. +
  8161. +#define AR71XX_PLL_DIV_SHIFT 3
  8162. +#define AR71XX_PLL_DIV_MASK 0x1f
  8163. +#define AR71XX_CPU_DIV_SHIFT 16
  8164. +#define AR71XX_CPU_DIV_MASK 0x3
  8165. +#define AR71XX_DDR_DIV_SHIFT 18
  8166. +#define AR71XX_DDR_DIV_MASK 0x3
  8167. +#define AR71XX_AHB_DIV_SHIFT 20
  8168. +#define AR71XX_AHB_DIV_MASK 0x7
  8169. +
  8170. +#define AR71XX_ETH0_PLL_SHIFT 17
  8171. +#define AR71XX_ETH1_PLL_SHIFT 19
  8172. +
  8173. +#define AR724X_PLL_REG_CPU_CONFIG 0x00
  8174. +#define AR724X_PLL_REG_PCIE_CONFIG 0x18
  8175. +
  8176. +#define AR724X_PLL_DIV_SHIFT 0
  8177. +#define AR724X_PLL_DIV_MASK 0x3ff
  8178. +#define AR724X_PLL_REF_DIV_SHIFT 10
  8179. +#define AR724X_PLL_REF_DIV_MASK 0xf
  8180. +#define AR724X_AHB_DIV_SHIFT 19
  8181. +#define AR724X_AHB_DIV_MASK 0x1
  8182. +#define AR724X_DDR_DIV_SHIFT 22
  8183. +#define AR724X_DDR_DIV_MASK 0x3
  8184. +
  8185. +#define AR91XX_PLL_REG_CPU_CONFIG 0x00
  8186. +#define AR91XX_PLL_REG_ETH_CONFIG 0x04
  8187. +#define AR91XX_PLL_REG_ETH0_INT_CLOCK 0x14
  8188. +#define AR91XX_PLL_REG_ETH1_INT_CLOCK 0x18
  8189. +
  8190. +#define AR91XX_PLL_DIV_SHIFT 0
  8191. +#define AR91XX_PLL_DIV_MASK 0x3ff
  8192. +#define AR91XX_DDR_DIV_SHIFT 22
  8193. +#define AR91XX_DDR_DIV_MASK 0x3
  8194. +#define AR91XX_AHB_DIV_SHIFT 19
  8195. +#define AR91XX_AHB_DIV_MASK 0x1
  8196. +
  8197. +#define AR91XX_ETH0_PLL_SHIFT 20
  8198. +#define AR91XX_ETH1_PLL_SHIFT 22
  8199. +
  8200. +extern void __iomem *ar71xx_pll_base;
  8201. +
  8202. +static inline void ar71xx_pll_wr(unsigned reg, u32 val)
  8203. +{
  8204. + __raw_writel(val, ar71xx_pll_base + reg);
  8205. +}
  8206. +
  8207. +static inline u32 ar71xx_pll_rr(unsigned reg)
  8208. +{
  8209. + return __raw_readl(ar71xx_pll_base + reg);
  8210. +}
  8211. +
  8212. +/*
  8213. + * USB_CONFIG block
  8214. + */
  8215. +#define USB_CTRL_REG_FLADJ 0x00
  8216. +#define USB_CTRL_REG_CONFIG 0x04
  8217. +
  8218. +extern void __iomem *ar71xx_usb_ctrl_base;
  8219. +
  8220. +static inline void ar71xx_usb_ctrl_wr(unsigned reg, u32 val)
  8221. +{
  8222. + __raw_writel(val, ar71xx_usb_ctrl_base + reg);
  8223. +}
  8224. +
  8225. +static inline u32 ar71xx_usb_ctrl_rr(unsigned reg)
  8226. +{
  8227. + return __raw_readl(ar71xx_usb_ctrl_base + reg);
  8228. +}
  8229. +
  8230. +/*
  8231. + * GPIO block
  8232. + */
  8233. +#define GPIO_REG_OE 0x00
  8234. +#define GPIO_REG_IN 0x04
  8235. +#define GPIO_REG_OUT 0x08
  8236. +#define GPIO_REG_SET 0x0c
  8237. +#define GPIO_REG_CLEAR 0x10
  8238. +#define GPIO_REG_INT_MODE 0x14
  8239. +#define GPIO_REG_INT_TYPE 0x18
  8240. +#define GPIO_REG_INT_POLARITY 0x1c
  8241. +#define GPIO_REG_INT_PENDING 0x20
  8242. +#define GPIO_REG_INT_ENABLE 0x24
  8243. +#define GPIO_REG_FUNC 0x28
  8244. +
  8245. +#define AR71XX_GPIO_FUNC_STEREO_EN BIT(17)
  8246. +#define AR71XX_GPIO_FUNC_SLIC_EN BIT(16)
  8247. +#define AR71XX_GPIO_FUNC_SPI_CS2_EN BIT(13)
  8248. +#define AR71XX_GPIO_FUNC_SPI_CS1_EN BIT(12)
  8249. +#define AR71XX_GPIO_FUNC_UART_EN BIT(8)
  8250. +#define AR71XX_GPIO_FUNC_USB_OC_EN BIT(4)
  8251. +#define AR71XX_GPIO_FUNC_USB_CLK_EN BIT(0)
  8252. +
  8253. +#define AR71XX_GPIO_COUNT 16
  8254. +
  8255. +#define AR724X_GPIO_FUNC_GE0_MII_CLK_EN BIT(19)
  8256. +#define AR724X_GPIO_FUNC_SPI_EN BIT(18)
  8257. +#define AR724X_GPIO_FUNC_SPI_CS_EN2 BIT(14)
  8258. +#define AR724X_GPIO_FUNC_SPI_CS_EN1 BIT(13)
  8259. +#define AR724X_GPIO_FUNC_CLK_OBS5_EN BIT(12)
  8260. +#define AR724X_GPIO_FUNC_CLK_OBS4_EN BIT(11)
  8261. +#define AR724X_GPIO_FUNC_CLK_OBS3_EN BIT(10)
  8262. +#define AR724X_GPIO_FUNC_CLK_OBS2_EN BIT(9)
  8263. +#define AR724X_GPIO_FUNC_CLK_OBS1_EN BIT(8)
  8264. +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN BIT(7)
  8265. +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN BIT(6)
  8266. +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN BIT(5)
  8267. +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN BIT(4)
  8268. +#define AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN BIT(3)
  8269. +#define AR724X_GPIO_FUNC_UART_RTS_CTS_EN BIT(2)
  8270. +#define AR724X_GPIO_FUNC_UART_EN BIT(1)
  8271. +#define AR724X_GPIO_FUNC_JTAG_DISABLE BIT(0)
  8272. +
  8273. +#define AR724X_GPIO_COUNT 18
  8274. +
  8275. +#define AR91XX_GPIO_FUNC_WMAC_LED_EN BIT(22)
  8276. +#define AR91XX_GPIO_FUNC_EXP_PORT_CS_EN BIT(21)
  8277. +#define AR91XX_GPIO_FUNC_I2S_REFCLKEN BIT(20)
  8278. +#define AR91XX_GPIO_FUNC_I2S_MCKEN BIT(19)
  8279. +#define AR91XX_GPIO_FUNC_I2S1_EN BIT(18)
  8280. +#define AR91XX_GPIO_FUNC_I2S0_EN BIT(17)
  8281. +#define AR91XX_GPIO_FUNC_SLIC_EN BIT(16)
  8282. +#define AR91XX_GPIO_FUNC_UART_RTSCTS_EN BIT(9)
  8283. +#define AR91XX_GPIO_FUNC_UART_EN BIT(8)
  8284. +#define AR91XX_GPIO_FUNC_USB_CLK_EN BIT(4)
  8285. +
  8286. +#define AR91XX_GPIO_COUNT 22
  8287. +
  8288. +extern void __iomem *ar71xx_gpio_base;
  8289. +
  8290. +static inline void ar71xx_gpio_wr(unsigned reg, u32 value)
  8291. +{
  8292. + __raw_writel(value, ar71xx_gpio_base + reg);
  8293. +}
  8294. +
  8295. +static inline u32 ar71xx_gpio_rr(unsigned reg)
  8296. +{
  8297. + return __raw_readl(ar71xx_gpio_base + reg);
  8298. +}
  8299. +
  8300. +void ar71xx_gpio_init(void) __init;
  8301. +void ar71xx_gpio_function_enable(u32 mask);
  8302. +void ar71xx_gpio_function_disable(u32 mask);
  8303. +void ar71xx_gpio_function_setup(u32 set, u32 clear);
  8304. +
  8305. +/*
  8306. + * DDR_CTRL block
  8307. + */
  8308. +#define AR71XX_DDR_REG_PCI_WIN0 0x7c
  8309. +#define AR71XX_DDR_REG_PCI_WIN1 0x80
  8310. +#define AR71XX_DDR_REG_PCI_WIN2 0x84
  8311. +#define AR71XX_DDR_REG_PCI_WIN3 0x88
  8312. +#define AR71XX_DDR_REG_PCI_WIN4 0x8c
  8313. +#define AR71XX_DDR_REG_PCI_WIN5 0x90
  8314. +#define AR71XX_DDR_REG_PCI_WIN6 0x94
  8315. +#define AR71XX_DDR_REG_PCI_WIN7 0x98
  8316. +#define AR71XX_DDR_REG_FLUSH_GE0 0x9c
  8317. +#define AR71XX_DDR_REG_FLUSH_GE1 0xa0
  8318. +#define AR71XX_DDR_REG_FLUSH_USB 0xa4
  8319. +#define AR71XX_DDR_REG_FLUSH_PCI 0xa8
  8320. +
  8321. +#define AR724X_DDR_REG_FLUSH_GE0 0x7c
  8322. +#define AR724X_DDR_REG_FLUSH_GE1 0x80
  8323. +#define AR724X_DDR_REG_FLUSH_USB 0x84
  8324. +#define AR724X_DDR_REG_FLUSH_PCIE 0x88
  8325. +
  8326. +#define AR91XX_DDR_REG_FLUSH_GE0 0x7c
  8327. +#define AR91XX_DDR_REG_FLUSH_GE1 0x80
  8328. +#define AR91XX_DDR_REG_FLUSH_USB 0x84
  8329. +#define AR91XX_DDR_REG_FLUSH_WMAC 0x88
  8330. +
  8331. +#define PCI_WIN0_OFFS 0x10000000
  8332. +#define PCI_WIN1_OFFS 0x11000000
  8333. +#define PCI_WIN2_OFFS 0x12000000
  8334. +#define PCI_WIN3_OFFS 0x13000000
  8335. +#define PCI_WIN4_OFFS 0x14000000
  8336. +#define PCI_WIN5_OFFS 0x15000000
  8337. +#define PCI_WIN6_OFFS 0x16000000
  8338. +#define PCI_WIN7_OFFS 0x07000000
  8339. +
  8340. +extern void __iomem *ar71xx_ddr_base;
  8341. +
  8342. +static inline void ar71xx_ddr_wr(unsigned reg, u32 val)
  8343. +{
  8344. + __raw_writel(val, ar71xx_ddr_base + reg);
  8345. +}
  8346. +
  8347. +static inline u32 ar71xx_ddr_rr(unsigned reg)
  8348. +{
  8349. + return __raw_readl(ar71xx_ddr_base + reg);
  8350. +}
  8351. +
  8352. +void ar71xx_ddr_flush(u32 reg);
  8353. +
  8354. +/*
  8355. + * PCI block
  8356. + */
  8357. +#define AR71XX_PCI_CFG_BASE (AR71XX_PCI_MEM_BASE + PCI_WIN7_OFFS + 0x10000)
  8358. +#define AR71XX_PCI_CFG_SIZE 0x100
  8359. +
  8360. +#define PCI_REG_CRP_AD_CBE 0x00
  8361. +#define PCI_REG_CRP_WRDATA 0x04
  8362. +#define PCI_REG_CRP_RDDATA 0x08
  8363. +#define PCI_REG_CFG_AD 0x0c
  8364. +#define PCI_REG_CFG_CBE 0x10
  8365. +#define PCI_REG_CFG_WRDATA 0x14
  8366. +#define PCI_REG_CFG_RDDATA 0x18
  8367. +#define PCI_REG_PCI_ERR 0x1c
  8368. +#define PCI_REG_PCI_ERR_ADDR 0x20
  8369. +#define PCI_REG_AHB_ERR 0x24
  8370. +#define PCI_REG_AHB_ERR_ADDR 0x28
  8371. +
  8372. +#define PCI_CRP_CMD_WRITE 0x00010000
  8373. +#define PCI_CRP_CMD_READ 0x00000000
  8374. +#define PCI_CFG_CMD_READ 0x0000000a
  8375. +#define PCI_CFG_CMD_WRITE 0x0000000b
  8376. +
  8377. +#define PCI_IDSEL_ADL_START 17
  8378. +
  8379. +#define AR724X_PCI_CFG_BASE (AR71XX_PCI_MEM_BASE + 0x4000000)
  8380. +#define AR724X_PCI_CFG_SIZE 0x1000
  8381. +
  8382. +#define AR724X_PCI_REG_APP 0x00
  8383. +#define AR724X_PCI_REG_RESET 0x18
  8384. +#define AR724X_PCI_REG_INT_STATUS 0x4c
  8385. +#define AR724X_PCI_REG_INT_MASK 0x50
  8386. +
  8387. +#define AR724X_PCI_APP_LTSSM_ENABLE BIT(0)
  8388. +#define AR724X_PCI_RESET_LINK_UP BIT(0)
  8389. +
  8390. +#define AR724X_PCI_INT_DEV0 BIT(14)
  8391. +
  8392. +/*
  8393. + * RESET block
  8394. + */
  8395. +#define AR71XX_RESET_REG_TIMER 0x00
  8396. +#define AR71XX_RESET_REG_TIMER_RELOAD 0x04
  8397. +#define AR71XX_RESET_REG_WDOG_CTRL 0x08
  8398. +#define AR71XX_RESET_REG_WDOG 0x0c
  8399. +#define AR71XX_RESET_REG_MISC_INT_STATUS 0x10
  8400. +#define AR71XX_RESET_REG_MISC_INT_ENABLE 0x14
  8401. +#define AR71XX_RESET_REG_PCI_INT_STATUS 0x18
  8402. +#define AR71XX_RESET_REG_PCI_INT_ENABLE 0x1c
  8403. +#define AR71XX_RESET_REG_GLOBAL_INT_STATUS 0x20
  8404. +#define AR71XX_RESET_REG_RESET_MODULE 0x24
  8405. +#define AR71XX_RESET_REG_PERFC_CTRL 0x2c
  8406. +#define AR71XX_RESET_REG_PERFC0 0x30
  8407. +#define AR71XX_RESET_REG_PERFC1 0x34
  8408. +#define AR71XX_RESET_REG_REV_ID 0x90
  8409. +
  8410. +#define AR91XX_RESET_REG_GLOBAL_INT_STATUS 0x18
  8411. +#define AR91XX_RESET_REG_RESET_MODULE 0x1c
  8412. +#define AR91XX_RESET_REG_PERF_CTRL 0x20
  8413. +#define AR91XX_RESET_REG_PERFC0 0x24
  8414. +#define AR91XX_RESET_REG_PERFC1 0x28
  8415. +
  8416. +#define AR724X_RESET_REG_RESET_MODULE 0x1c
  8417. +
  8418. +#define WDOG_CTRL_LAST_RESET BIT(31)
  8419. +#define WDOG_CTRL_ACTION_MASK 3
  8420. +#define WDOG_CTRL_ACTION_NONE 0 /* no action */
  8421. +#define WDOG_CTRL_ACTION_GPI 1 /* general purpose interrupt */
  8422. +#define WDOG_CTRL_ACTION_NMI 2 /* NMI */
  8423. +#define WDOG_CTRL_ACTION_FCR 3 /* full chip reset */
  8424. +
  8425. +#define MISC_INT_DMA BIT(7)
  8426. +#define MISC_INT_OHCI BIT(6)
  8427. +#define MISC_INT_PERFC BIT(5)
  8428. +#define MISC_INT_WDOG BIT(4)
  8429. +#define MISC_INT_UART BIT(3)
  8430. +#define MISC_INT_GPIO BIT(2)
  8431. +#define MISC_INT_ERROR BIT(1)
  8432. +#define MISC_INT_TIMER BIT(0)
  8433. +
  8434. +#define PCI_INT_CORE BIT(4)
  8435. +#define PCI_INT_DEV2 BIT(2)
  8436. +#define PCI_INT_DEV1 BIT(1)
  8437. +#define PCI_INT_DEV0 BIT(0)
  8438. +
  8439. +#define RESET_MODULE_EXTERNAL BIT(28)
  8440. +#define RESET_MODULE_FULL_CHIP BIT(24)
  8441. +#define RESET_MODULE_AMBA2WMAC BIT(22)
  8442. +#define RESET_MODULE_CPU_NMI BIT(21)
  8443. +#define RESET_MODULE_CPU_COLD BIT(20)
  8444. +#define RESET_MODULE_DMA BIT(19)
  8445. +#define RESET_MODULE_SLIC BIT(18)
  8446. +#define RESET_MODULE_STEREO BIT(17)
  8447. +#define RESET_MODULE_DDR BIT(16)
  8448. +#define RESET_MODULE_GE1_MAC BIT(13)
  8449. +#define RESET_MODULE_GE1_PHY BIT(12)
  8450. +#define RESET_MODULE_USBSUS_OVERRIDE BIT(10)
  8451. +#define RESET_MODULE_GE0_MAC BIT(9)
  8452. +#define RESET_MODULE_GE0_PHY BIT(8)
  8453. +#define RESET_MODULE_USB_OHCI_DLL BIT(6)
  8454. +#define RESET_MODULE_USB_HOST BIT(5)
  8455. +#define RESET_MODULE_USB_PHY BIT(4)
  8456. +#define RESET_MODULE_USB_OHCI_DLL_7240 BIT(3)
  8457. +#define RESET_MODULE_PCI_BUS BIT(1)
  8458. +#define RESET_MODULE_PCI_CORE BIT(0)
  8459. +
  8460. +#define AR724X_RESET_GE1_MDIO BIT(23)
  8461. +#define AR724X_RESET_GE0_MDIO BIT(22)
  8462. +#define AR724X_RESET_PCIE_PHY_SERIAL BIT(10)
  8463. +#define AR724X_RESET_PCIE_PHY BIT(7)
  8464. +#define AR724X_RESET_PCIE BIT(6)
  8465. +
  8466. +#define REV_ID_MAJOR_MASK 0xfff0
  8467. +#define REV_ID_MAJOR_AR71XX 0x00a0
  8468. +#define REV_ID_MAJOR_AR913X 0x00b0
  8469. +#define REV_ID_MAJOR_AR7240 0x00c0
  8470. +#define REV_ID_MAJOR_AR7241 0x0100
  8471. +#define REV_ID_MAJOR_AR7242 0x1100
  8472. +
  8473. +#define AR71XX_REV_ID_MINOR_MASK 0x3
  8474. +#define AR71XX_REV_ID_MINOR_AR7130 0x0
  8475. +#define AR71XX_REV_ID_MINOR_AR7141 0x1
  8476. +#define AR71XX_REV_ID_MINOR_AR7161 0x2
  8477. +#define AR71XX_REV_ID_REVISION_MASK 0x3
  8478. +#define AR71XX_REV_ID_REVISION_SHIFT 2
  8479. +
  8480. +#define AR91XX_REV_ID_MINOR_MASK 0x3
  8481. +#define AR91XX_REV_ID_MINOR_AR9130 0x0
  8482. +#define AR91XX_REV_ID_MINOR_AR9132 0x1
  8483. +#define AR91XX_REV_ID_REVISION_MASK 0x3
  8484. +#define AR91XX_REV_ID_REVISION_SHIFT 2
  8485. +
  8486. +#define AR724X_REV_ID_REVISION_MASK 0x3
  8487. +
  8488. +extern void __iomem *ar71xx_reset_base;
  8489. +
  8490. +static inline void ar71xx_reset_wr(unsigned reg, u32 val)
  8491. +{
  8492. + __raw_writel(val, ar71xx_reset_base + reg);
  8493. +}
  8494. +
  8495. +static inline u32 ar71xx_reset_rr(unsigned reg)
  8496. +{
  8497. + return __raw_readl(ar71xx_reset_base + reg);
  8498. +}
  8499. +
  8500. +void ar71xx_device_stop(u32 mask);
  8501. +void ar71xx_device_start(u32 mask);
  8502. +int ar71xx_device_stopped(u32 mask);
  8503. +
  8504. +/*
  8505. + * SPI block
  8506. + */
  8507. +#define SPI_REG_FS 0x00 /* Function Select */
  8508. +#define SPI_REG_CTRL 0x04 /* SPI Control */
  8509. +#define SPI_REG_IOC 0x08 /* SPI I/O Control */
  8510. +#define SPI_REG_RDS 0x0c /* Read Data Shift */
  8511. +
  8512. +#define SPI_FS_GPIO BIT(0) /* Enable GPIO mode */
  8513. +
  8514. +#define SPI_CTRL_RD BIT(6) /* Remap Disable */
  8515. +#define SPI_CTRL_DIV_MASK 0x3f
  8516. +
  8517. +#define SPI_IOC_DO BIT(0) /* Data Out pin */
  8518. +#define SPI_IOC_CLK BIT(8) /* CLK pin */
  8519. +#define SPI_IOC_CS(n) BIT(16 + (n))
  8520. +#define SPI_IOC_CS0 SPI_IOC_CS(0)
  8521. +#define SPI_IOC_CS1 SPI_IOC_CS(1)
  8522. +#define SPI_IOC_CS2 SPI_IOC_CS(2)
  8523. +#define SPI_IOC_CS_ALL (SPI_IOC_CS0 | SPI_IOC_CS1 | SPI_IOC_CS2)
  8524. +
  8525. +void ar71xx_flash_acquire(void);
  8526. +void ar71xx_flash_release(void);
  8527. +
  8528. +/*
  8529. + * MII_CTRL block
  8530. + */
  8531. +#define MII_REG_MII0_CTRL 0x00
  8532. +#define MII_REG_MII1_CTRL 0x04
  8533. +
  8534. +#define MII0_CTRL_IF_GMII 0
  8535. +#define MII0_CTRL_IF_MII 1
  8536. +#define MII0_CTRL_IF_RGMII 2
  8537. +#define MII0_CTRL_IF_RMII 3
  8538. +
  8539. +#define MII1_CTRL_IF_RGMII 0
  8540. +#define MII1_CTRL_IF_RMII 1
  8541. +
  8542. +#endif /* __ASSEMBLER__ */
  8543. +
  8544. +#endif /* __ASM_MACH_AR71XX_H */
  8545. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/ar91xx_flash.h linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/ar91xx_flash.h
  8546. --- linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/ar91xx_flash.h 1970-01-01 01:00:00.000000000 +0100
  8547. +++ linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/ar91xx_flash.h 2010-10-14 20:27:58.848101151 +0200
  8548. @@ -0,0 +1,26 @@
  8549. +/*
  8550. + * AR91xx parallel flash driver platform data definitions
  8551. + *
  8552. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  8553. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  8554. + *
  8555. + * This program is free software; you can redistribute it and/or modify it
  8556. + * under the terms of the GNU General Public License version 2 as published
  8557. + * by the Free Software Foundation.
  8558. + */
  8559. +
  8560. +#ifndef __AR91XX_FLASH_H
  8561. +#define __AR91XX_FLASH_H
  8562. +
  8563. +struct mtd_partition;
  8564. +
  8565. +struct ar91xx_flash_platform_data {
  8566. + unsigned int width;
  8567. + u8 is_shared:1;
  8568. +#ifdef CONFIG_MTD_PARTITIONS
  8569. + unsigned int nr_parts;
  8570. + struct mtd_partition *parts;
  8571. +#endif
  8572. +};
  8573. +
  8574. +#endif /* __AR91XX_FLASH_H */
  8575. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/cpu-feature-overrides.h linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/cpu-feature-overrides.h
  8576. --- linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/cpu-feature-overrides.h 1970-01-01 01:00:00.000000000 +0100
  8577. +++ linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/cpu-feature-overrides.h 2010-10-14 20:27:58.895601086 +0200
  8578. @@ -0,0 +1,56 @@
  8579. +/*
  8580. + * Atheros AR71xx specific CPU feature overrides
  8581. + *
  8582. + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
  8583. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  8584. + *
  8585. + * This file was derived from: include/asm-mips/cpu-features.h
  8586. + * Copyright (C) 2003, 2004 Ralf Baechle
  8587. + * Copyright (C) 2004 Maciej W. Rozycki
  8588. + *
  8589. + * This program is free software; you can redistribute it and/or modify it
  8590. + * under the terms of the GNU General Public License version 2 as published
  8591. + * by the Free Software Foundation.
  8592. + *
  8593. + */
  8594. +#ifndef __ASM_MACH_AR71XX_CPU_FEATURE_OVERRIDES_H
  8595. +#define __ASM_MACH_AR71XX_CPU_FEATURE_OVERRIDES_H
  8596. +
  8597. +#define cpu_has_tlb 1
  8598. +#define cpu_has_4kex 1
  8599. +#define cpu_has_3k_cache 0
  8600. +#define cpu_has_4k_cache 1
  8601. +#define cpu_has_tx39_cache 0
  8602. +#define cpu_has_sb1_cache 0
  8603. +#define cpu_has_fpu 0
  8604. +#define cpu_has_32fpr 0
  8605. +#define cpu_has_counter 1
  8606. +#define cpu_has_watch 1
  8607. +#define cpu_has_divec 1
  8608. +
  8609. +#define cpu_has_prefetch 1
  8610. +#define cpu_has_ejtag 1
  8611. +#define cpu_has_llsc 1
  8612. +
  8613. +#define cpu_has_mips16 1
  8614. +#define cpu_has_mdmx 0
  8615. +#define cpu_has_mips3d 0
  8616. +#define cpu_has_smartmips 0
  8617. +
  8618. +#define cpu_has_mips32r1 1
  8619. +#define cpu_has_mips32r2 1
  8620. +#define cpu_has_mips64r1 0
  8621. +#define cpu_has_mips64r2 0
  8622. +
  8623. +#define cpu_has_dsp 0
  8624. +#define cpu_has_mipsmt 0
  8625. +
  8626. +#define cpu_has_64bits 0
  8627. +#define cpu_has_64bit_zero_reg 0
  8628. +#define cpu_has_64bit_gp_regs 0
  8629. +#define cpu_has_64bit_addresses 0
  8630. +
  8631. +#define cpu_dcache_line_size() 32
  8632. +#define cpu_icache_line_size() 32
  8633. +
  8634. +#endif /* __ASM_MACH_AR71XX_CPU_FEATURE_OVERRIDES_H */
  8635. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/gpio.h linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/gpio.h
  8636. --- linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/gpio.h 1970-01-01 01:00:00.000000000 +0100
  8637. +++ linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/gpio.h 2010-10-14 20:27:58.945582628 +0200
  8638. @@ -0,0 +1,53 @@
  8639. +/*
  8640. + * Atheros AR71xx GPIO API definitions
  8641. + *
  8642. + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
  8643. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  8644. + *
  8645. + * This program is free software; you can redistribute it and/or modify it
  8646. + * under the terms of the GNU General Public License version 2 as published
  8647. + * by the Free Software Foundation.
  8648. + *
  8649. + */
  8650. +
  8651. +#ifndef __ASM_MACH_AR71XX_GPIO_H
  8652. +#define __ASM_MACH_AR71XX_GPIO_H
  8653. +
  8654. +#define ARCH_NR_GPIOS 64
  8655. +#include <asm-generic/gpio.h>
  8656. +
  8657. +#include <asm/mach-ar71xx/ar71xx.h>
  8658. +
  8659. +extern unsigned long ar71xx_gpio_count;
  8660. +extern void __ar71xx_gpio_set_value(unsigned gpio, int value);
  8661. +extern int __ar71xx_gpio_get_value(unsigned gpio);
  8662. +
  8663. +static inline int gpio_to_irq(unsigned gpio)
  8664. +{
  8665. + return AR71XX_GPIO_IRQ(gpio);
  8666. +}
  8667. +
  8668. +static inline int irq_to_gpio(unsigned irq)
  8669. +{
  8670. + return irq - AR71XX_GPIO_IRQ_BASE;
  8671. +}
  8672. +
  8673. +static inline int gpio_get_value(unsigned gpio)
  8674. +{
  8675. + if (gpio < ar71xx_gpio_count)
  8676. + return __ar71xx_gpio_get_value(gpio);
  8677. +
  8678. + return __gpio_get_value(gpio);
  8679. +}
  8680. +
  8681. +static inline void gpio_set_value(unsigned gpio, int value)
  8682. +{
  8683. + if (gpio < ar71xx_gpio_count)
  8684. + __ar71xx_gpio_set_value(gpio, value);
  8685. + else
  8686. + __gpio_set_value(gpio, value);
  8687. +}
  8688. +
  8689. +#define gpio_cansleep __gpio_cansleep
  8690. +
  8691. +#endif /* __ASM_MACH_AR71XX_GPIO_H */
  8692. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/irq.h linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/irq.h
  8693. --- linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/irq.h 1970-01-01 01:00:00.000000000 +0100
  8694. +++ linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/irq.h 2010-10-14 20:27:58.994356523 +0200
  8695. @@ -0,0 +1,17 @@
  8696. +/*
  8697. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  8698. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  8699. + *
  8700. + * This program is free software; you can redistribute it and/or modify it
  8701. + * under the terms of the GNU General Public License version 2 as published
  8702. + * by the Free Software Foundation.
  8703. + */
  8704. +#ifndef __ASM_MACH_AR71XX_IRQ_H
  8705. +#define __ASM_MACH_AR71XX_IRQ_H
  8706. +
  8707. +#define MIPS_CPU_IRQ_BASE 0
  8708. +#define NR_IRQS 56
  8709. +
  8710. +#include_next <irq.h>
  8711. +
  8712. +#endif /* __ASM_MACH_AR71XX_IRQ_H */
  8713. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/kernel-entry-init.h linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/kernel-entry-init.h
  8714. --- linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/kernel-entry-init.h 1970-01-01 01:00:00.000000000 +0100
  8715. +++ linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/kernel-entry-init.h 2010-10-14 20:27:59.045181409 +0200
  8716. @@ -0,0 +1,32 @@
  8717. +/*
  8718. + * Atheros AR71xx specific kernel entry setup
  8719. + *
  8720. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  8721. + *
  8722. + * This program is free software; you can redistribute it and/or modify it
  8723. + * under the terms of the GNU General Public License version 2 as published
  8724. + * by the Free Software Foundation.
  8725. + *
  8726. + */
  8727. +#ifndef __ASM_MACH_AR71XX_KERNEL_ENTRY_H
  8728. +#define __ASM_MACH_AR71XX_KERNEL_ENTRY_H
  8729. +
  8730. + /*
  8731. + * Some bootloaders set the 'Kseg0 coherency algorithm' to
  8732. + * 'Cacheable, noncoherent, write-through, no write allocate'
  8733. + * and this cause performance issues. Let's go and change it to
  8734. + * 'Cacheable, noncoherent, write-back, write allocate'
  8735. + */
  8736. + .macro kernel_entry_setup
  8737. + mfc0 t0, CP0_CONFIG
  8738. + li t1, ~CONF_CM_CMASK
  8739. + and t0, t1
  8740. + ori t0, CONF_CM_CACHABLE_NONCOHERENT
  8741. + mtc0 t0, CP0_CONFIG
  8742. + nop
  8743. + .endm
  8744. +
  8745. + .macro smp_slave_setup
  8746. + .endm
  8747. +
  8748. +#endif /* __ASM_MACH_AR71XX_KERNEL_ENTRY_H */
  8749. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/mach-rb750.h linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/mach-rb750.h
  8750. --- linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/mach-rb750.h 1970-01-01 01:00:00.000000000 +0100
  8751. +++ linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/mach-rb750.h 2010-10-14 20:27:59.095024740 +0200
  8752. @@ -0,0 +1,66 @@
  8753. +/*
  8754. + * MikroTik RouterBOARD 750 definitions
  8755. + *
  8756. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  8757. + *
  8758. + * This program is free software; you can redistribute it and/or modify it
  8759. + * under the terms of the GNU General Public License version 2 as published
  8760. + * by the Free Software Foundation.
  8761. + */
  8762. +#ifndef _MACH_RB750_H
  8763. +#define _MACH_RB750_H
  8764. +
  8765. +#include <linux/bitops.h>
  8766. +
  8767. +#define RB750_GPIO_LVC573_LE 0 /* Latch enable on LVC573 */
  8768. +#define RB750_GPIO_NAND_IO0 1 /* NAND I/O 0 */
  8769. +#define RB750_GPIO_NAND_IO1 2 /* NAND I/O 1 */
  8770. +#define RB750_GPIO_NAND_IO2 3 /* NAND I/O 2 */
  8771. +#define RB750_GPIO_NAND_IO3 4 /* NAND I/O 3 */
  8772. +#define RB750_GPIO_NAND_IO4 5 /* NAND I/O 4 */
  8773. +#define RB750_GPIO_NAND_IO5 6 /* NAND I/O 5 */
  8774. +#define RB750_GPIO_NAND_IO6 7 /* NAND I/O 6 */
  8775. +#define RB750_GPIO_NAND_IO7 8 /* NAND I/O 7 */
  8776. +#define RB750_GPIO_NAND_NCE 11 /* NAND Chip Enable (active low) */
  8777. +#define RB750_GPIO_NAND_RDY 12 /* NAND Ready */
  8778. +#define RB750_GPIO_NAND_CLE 14 /* NAND Command Latch Enable */
  8779. +#define RB750_GPIO_NAND_ALE 15 /* NAND Address Latch Enable */
  8780. +#define RB750_GPIO_NAND_NRE 16 /* NAND Read Enable (active low) */
  8781. +#define RB750_GPIO_NAND_NWE 17 /* NAND Write Enable (active low) */
  8782. +
  8783. +#define RB750_GPIO_BTN_RESET 1
  8784. +#define RB750_GPIO_SPI_CS0 2
  8785. +#define RB750_GPIO_LED_ACT 12
  8786. +#define RB750_GPIO_LED_PORT1 13
  8787. +#define RB750_GPIO_LED_PORT2 14
  8788. +#define RB750_GPIO_LED_PORT3 15
  8789. +#define RB750_GPIO_LED_PORT4 16
  8790. +#define RB750_GPIO_LED_PORT5 17
  8791. +
  8792. +#define RB750_LED_ACT BIT(RB750_GPIO_LED_ACT)
  8793. +#define RB750_LED_PORT1 BIT(RB750_GPIO_LED_PORT1)
  8794. +#define RB750_LED_PORT2 BIT(RB750_GPIO_LED_PORT2)
  8795. +#define RB750_LED_PORT3 BIT(RB750_GPIO_LED_PORT3)
  8796. +#define RB750_LED_PORT4 BIT(RB750_GPIO_LED_PORT4)
  8797. +#define RB750_LED_PORT5 BIT(RB750_GPIO_LED_PORT5)
  8798. +
  8799. +#define RB750_LVC573_LE BIT(RB750_GPIO_LVC573_LE)
  8800. +
  8801. +#define RB750_LED_BITS (RB750_LED_PORT1 | RB750_LED_PORT2 | RB750_LED_PORT3 | \
  8802. + RB750_LED_PORT4 | RB750_LED_PORT5 | RB750_LED_ACT)
  8803. +
  8804. +struct rb750_led_data {
  8805. + char *name;
  8806. + char *default_trigger;
  8807. + u32 mask;
  8808. + int active_low;
  8809. +};
  8810. +
  8811. +struct rb750_led_platform_data {
  8812. + int num_leds;
  8813. + struct rb750_led_data *leds;
  8814. +};
  8815. +
  8816. +int rb750_latch_change(u32 mask_clr, u32 mask_set);
  8817. +
  8818. +#endif /* _MACH_RB750_H */
  8819. \ No newline at end of file
  8820. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/mangle-port.h linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/mangle-port.h
  8821. --- linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/mangle-port.h 1970-01-01 01:00:00.000000000 +0100
  8822. +++ linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/mangle-port.h 2010-10-14 20:27:59.144833241 +0200
  8823. @@ -0,0 +1,45 @@
  8824. +/*
  8825. + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
  8826. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  8827. + *
  8828. + * This file was derived from: inlude/asm-mips/mach-generic/mangle-port.h
  8829. + * Copyright (C) 2003, 2004 Ralf Baechle
  8830. + *
  8831. + * This program is free software; you can redistribute it and/or modify it
  8832. + * under the terms of the GNU General Public License version 2 as published
  8833. + * by the Free Software Foundation.
  8834. + */
  8835. +
  8836. +#ifndef __ASM_MACH_AR71XX_MANGLE_PORT_H
  8837. +#define __ASM_MACH_AR71XX_MANGLE_PORT_H
  8838. +
  8839. +#define __swizzle_addr_b(port) ((port) ^ 3)
  8840. +#define __swizzle_addr_w(port) ((port) ^ 2)
  8841. +#define __swizzle_addr_l(port) (port)
  8842. +#define __swizzle_addr_q(port) (port)
  8843. +
  8844. +#if defined(CONFIG_SWAP_IO_SPACE)
  8845. +
  8846. +# define ioswabb(a, x) (x)
  8847. +# define __mem_ioswabb(a, x) (x)
  8848. +# define ioswabw(a, x) le16_to_cpu(x)
  8849. +# define __mem_ioswabw(a, x) (x)
  8850. +# define ioswabl(a, x) le32_to_cpu(x)
  8851. +# define __mem_ioswabl(a, x) (x)
  8852. +# define ioswabq(a, x) le64_to_cpu(x)
  8853. +# define __mem_ioswabq(a, x) (x)
  8854. +
  8855. +#else
  8856. +
  8857. +# define ioswabb(a, x) (x)
  8858. +# define __mem_ioswabb(a, x) (x)
  8859. +# define ioswabw(a, x) (x)
  8860. +# define __mem_ioswabw(a, x) cpu_to_le16(x)
  8861. +# define ioswabl(a, x) (x)
  8862. +# define __mem_ioswabl(a, x) cpu_to_le32(x)
  8863. +# define ioswabq(a, x) (x)
  8864. +# define __mem_ioswabq(a, x) cpu_to_le64(x)
  8865. +
  8866. +#endif
  8867. +
  8868. +#endif /* __ASM_MACH_AR71XX_MANGLE_PORT_H */
  8869. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/pci.h linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/pci.h
  8870. --- linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/pci.h 1970-01-01 01:00:00.000000000 +0100
  8871. +++ linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/pci.h 2010-10-14 20:27:59.194642423 +0200
  8872. @@ -0,0 +1,39 @@
  8873. +/*
  8874. + * Atheros AR71xx SoC specific PCI definitions
  8875. + *
  8876. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  8877. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  8878. + *
  8879. + * This program is free software; you can redistribute it and/or modify it
  8880. + * under the terms of the GNU General Public License version 2 as published
  8881. + * by the Free Software Foundation.
  8882. + */
  8883. +
  8884. +#ifndef __ASM_MACH_AR71XX_PCI_H
  8885. +#define __ASM_MACH_AR71XX_PCI_H
  8886. +
  8887. +struct pci_dev;
  8888. +
  8889. +struct ar71xx_pci_irq {
  8890. + int irq;
  8891. + u8 slot;
  8892. + u8 pin;
  8893. +};
  8894. +
  8895. +extern int (*ar71xx_pci_plat_dev_init)(struct pci_dev *dev);
  8896. +extern unsigned ar71xx_pci_nr_irqs __initdata;
  8897. +extern struct ar71xx_pci_irq *ar71xx_pci_irq_map __initdata;
  8898. +
  8899. +int ar71xx_pcibios_map_irq(const struct pci_dev *dev,
  8900. + uint8_t slot, uint8_t pin) __init;
  8901. +int ar71xx_pcibios_init(void) __init;
  8902. +
  8903. +int ar71xx_pci_be_handler(int is_fixup);
  8904. +
  8905. +int ar724x_pcibios_map_irq(const struct pci_dev *dev,
  8906. + uint8_t slot, uint8_t pin) __init;
  8907. +int ar724x_pcibios_init(void) __init;
  8908. +
  8909. +int ar71xx_pci_init(unsigned nr_irqs, struct ar71xx_pci_irq *map) __init;
  8910. +
  8911. +#endif /* __ASM_MACH_AR71XX_PCI_H */
  8912. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/platform.h linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/platform.h
  8913. --- linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/platform.h 1970-01-01 01:00:00.000000000 +0100
  8914. +++ linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/platform.h 2010-10-14 20:27:59.252778691 +0200
  8915. @@ -0,0 +1,61 @@
  8916. +/*
  8917. + * Atheros AR71xx SoC specific platform data definitions
  8918. + *
  8919. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  8920. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  8921. + *
  8922. + * This program is free software; you can redistribute it and/or modify it
  8923. + * under the terms of the GNU General Public License version 2 as published
  8924. + * by the Free Software Foundation.
  8925. + */
  8926. +
  8927. +#ifndef __ASM_MACH_AR71XX_PLATFORM_H
  8928. +#define __ASM_MACH_AR71XX_PLATFORM_H
  8929. +
  8930. +#include <linux/if_ether.h>
  8931. +#include <linux/skbuff.h>
  8932. +#include <linux/phy.h>
  8933. +#include <linux/spi/spi.h>
  8934. +
  8935. +struct ag71xx_platform_data {
  8936. + phy_interface_t phy_if_mode;
  8937. + u32 phy_mask;
  8938. + int speed;
  8939. + int duplex;
  8940. + u32 reset_bit;
  8941. + u32 mii_if;
  8942. + u8 mac_addr[ETH_ALEN];
  8943. + struct device *mii_bus_dev;
  8944. +
  8945. + u8 has_gbit:1;
  8946. + u8 is_ar91xx:1;
  8947. + u8 is_ar724x:1;
  8948. + u8 has_ar8216:1;
  8949. +
  8950. + void (* ddr_flush)(void);
  8951. + void (* set_pll)(int speed);
  8952. +
  8953. + u32 fifo_cfg1;
  8954. + u32 fifo_cfg2;
  8955. + u32 fifo_cfg3;
  8956. +};
  8957. +
  8958. +struct ag71xx_mdio_platform_data {
  8959. + u32 phy_mask;
  8960. + int is_ar7240;
  8961. +};
  8962. +
  8963. +struct ar71xx_ehci_platform_data {
  8964. + u8 is_ar91xx;
  8965. +};
  8966. +
  8967. +struct ar71xx_spi_platform_data {
  8968. + unsigned bus_num;
  8969. + unsigned num_chipselect;
  8970. + u32 (*get_ioc_base)(u8 chip_select, int cs_high, int is_on);
  8971. +};
  8972. +
  8973. +#define AR71XX_SPI_CS_INACTIVE 0
  8974. +#define AR71XX_SPI_CS_ACTIVE 1
  8975. +
  8976. +#endif /* __ASM_MACH_AR71XX_PLATFORM_H */
  8977. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/war.h linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/war.h
  8978. --- linux-2.6.35.7.orig/arch/mips/include/asm/mach-ar71xx/war.h 1970-01-01 01:00:00.000000000 +0100
  8979. +++ linux-2.6.35.7/arch/mips/include/asm/mach-ar71xx/war.h 2010-10-14 20:27:59.295939760 +0200
  8980. @@ -0,0 +1,25 @@
  8981. +/*
  8982. + * This file is subject to the terms and conditions of the GNU General Public
  8983. + * License. See the file "COPYING" in the main directory of this archive
  8984. + * for more details.
  8985. + *
  8986. + * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
  8987. + */
  8988. +#ifndef __ASM_MACH_AR71XX_WAR_H
  8989. +#define __ASM_MACH_AR71XX_WAR_H
  8990. +
  8991. +#define R4600_V1_INDEX_ICACHEOP_WAR 0
  8992. +#define R4600_V1_HIT_CACHEOP_WAR 0
  8993. +#define R4600_V2_HIT_CACHEOP_WAR 0
  8994. +#define R5432_CP0_INTERRUPT_WAR 0
  8995. +#define BCM1250_M3_WAR 0
  8996. +#define SIBYTE_1956_WAR 0
  8997. +#define MIPS4K_ICACHE_REFILL_WAR 0
  8998. +#define MIPS_CACHE_SYNC_WAR 0
  8999. +#define TX49XX_ICACHE_INDEX_INV_WAR 0
  9000. +#define RM9000_CDEX_SMP_WAR 0
  9001. +#define ICACHE_REFILLS_WORKAROUND_WAR 0
  9002. +#define R10000_LLSC_WAR 0
  9003. +#define MIPS34K_MISSED_ITLB_WAR 0
  9004. +
  9005. +#endif /* __ASM_MACH_AR71XX_WAR_H */
  9006. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/mips_machine.h linux-2.6.35.7/arch/mips/include/asm/mips_machine.h
  9007. --- linux-2.6.35.7.orig/arch/mips/include/asm/mips_machine.h 1970-01-01 01:00:00.000000000 +0100
  9008. +++ linux-2.6.35.7/arch/mips/include/asm/mips_machine.h 2010-10-14 20:27:59.335601098 +0200
  9009. @@ -0,0 +1,54 @@
  9010. +/*
  9011. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  9012. + *
  9013. + * This program is free software; you can redistribute it and/or modify it
  9014. + * under the terms of the GNU General Public License version 2 as published
  9015. + * by the Free Software Foundation.
  9016. + *
  9017. + */
  9018. +
  9019. +#ifndef __ASM_MIPS_MACHINE_H
  9020. +#define __ASM_MIPS_MACHINE_H
  9021. +
  9022. +#include <linux/init.h>
  9023. +#include <linux/list.h>
  9024. +
  9025. +#include <asm/bootinfo.h>
  9026. +
  9027. +struct mips_machine {
  9028. + unsigned long mach_type;
  9029. + char *mach_id;
  9030. + char *mach_name;
  9031. + void (*mach_setup)(void);
  9032. + struct list_head list;
  9033. +};
  9034. +
  9035. +void mips_machine_register(struct mips_machine *) __init;
  9036. +void mips_machine_setup(void) __init;
  9037. +int mips_machtype_setup(char *id) __init;
  9038. +void mips_machine_set_name(char *name) __init;
  9039. +
  9040. +extern char *mips_machine_name;
  9041. +
  9042. +#define MIPS_MACHINE(_type, _id, _name, _setup) \
  9043. +static const char machine_name_##_type[] __initconst \
  9044. + __aligned(1) = _name; \
  9045. +static const char machine_id_##_type[] __initconst \
  9046. + __aligned(1) = _id; \
  9047. +static struct mips_machine machine_##_type __initdata = \
  9048. +{ \
  9049. + .mach_type = _type, \
  9050. + .mach_id = (char *) machine_id_##_type, \
  9051. + .mach_name = (char *) machine_name_##_type, \
  9052. + .mach_setup = _setup, \
  9053. +}; \
  9054. + \
  9055. +static int __init register_machine_##_type(void) \
  9056. +{ \
  9057. + mips_machine_register(&machine_##_type); \
  9058. + return 0; \
  9059. +} \
  9060. + \
  9061. +pure_initcall(register_machine_##_type)
  9062. +
  9063. +#endif /* __ASM_MIPS_MACHINE_H */
  9064. diff -Nur linux-2.6.35.7.orig/arch/mips/include/asm/time.h linux-2.6.35.7/arch/mips/include/asm/time.h
  9065. --- linux-2.6.35.7.orig/arch/mips/include/asm/time.h 2010-09-29 03:09:08.000000000 +0200
  9066. +++ linux-2.6.35.7/arch/mips/include/asm/time.h 2010-10-14 20:27:59.385601208 +0200
  9067. @@ -52,6 +52,7 @@
  9068. */
  9069. #ifdef CONFIG_CEVT_R4K_LIB
  9070. extern unsigned int __weak get_c0_compare_int(void);
  9071. +extern unsigned int __weak get_c0_compare_irq(void);
  9072. extern int r4k_clockevent_init(void);
  9073. #endif
  9074. diff -Nur linux-2.6.35.7.orig/arch/mips/Kconfig linux-2.6.35.7/arch/mips/Kconfig
  9075. --- linux-2.6.35.7.orig/arch/mips/Kconfig 2010-09-29 03:09:08.000000000 +0200
  9076. +++ linux-2.6.35.7/arch/mips/Kconfig 2010-10-14 20:27:59.436851139 +0200
  9077. @@ -48,6 +48,23 @@
  9078. Support for the Texas Instruments AR7 System-on-a-Chip
  9079. family: TNETD7100, 7200 and 7300.
  9080. +config ATHEROS_AR71XX
  9081. + bool "Atheros AR71xx based boards"
  9082. + select CEVT_R4K
  9083. + select CSRC_R4K
  9084. + select DMA_NONCOHERENT
  9085. + select HW_HAS_PCI
  9086. + select IRQ_CPU
  9087. + select ARCH_REQUIRE_GPIOLIB
  9088. + select SYS_HAS_CPU_MIPS32_R1
  9089. + select SYS_HAS_CPU_MIPS32_R2
  9090. + select SYS_SUPPORTS_32BIT_KERNEL
  9091. + select SYS_SUPPORTS_BIG_ENDIAN
  9092. + select SYS_HAS_EARLY_PRINTK
  9093. + select MIPS_MACHINE
  9094. + help
  9095. + Support for Atheros AR71xx based boards.
  9096. +
  9097. config BCM47XX
  9098. bool "Broadcom BCM47XX based boards"
  9099. select CEVT_R4K
  9100. @@ -684,6 +701,7 @@
  9101. endchoice
  9102. source "arch/mips/alchemy/Kconfig"
  9103. +source "arch/mips/ar71xx/Kconfig"
  9104. source "arch/mips/bcm63xx/Kconfig"
  9105. source "arch/mips/jazz/Kconfig"
  9106. source "arch/mips/lasat/Kconfig"
  9107. @@ -850,9 +868,15 @@
  9108. config MIPS_DISABLE_OBSOLETE_IDE
  9109. bool
  9110. +config MYLOADER
  9111. + bool
  9112. +
  9113. config SYNC_R4K
  9114. bool
  9115. +config MIPS_MACHINE
  9116. + def_bool n
  9117. +
  9118. config NO_IOPORT
  9119. def_bool n
  9120. diff -Nur linux-2.6.35.7.orig/arch/mips/kernel/Makefile linux-2.6.35.7/arch/mips/kernel/Makefile
  9121. --- linux-2.6.35.7.orig/arch/mips/kernel/Makefile 2010-09-29 03:09:08.000000000 +0200
  9122. +++ linux-2.6.35.7/arch/mips/kernel/Makefile 2010-10-14 20:27:59.485313916 +0200
  9123. @@ -93,6 +93,7 @@
  9124. obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
  9125. obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
  9126. +obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o
  9127. obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o
  9128. CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
  9129. diff -Nur linux-2.6.35.7.orig/arch/mips/kernel/mips_machine.c linux-2.6.35.7/arch/mips/kernel/mips_machine.c
  9130. --- linux-2.6.35.7.orig/arch/mips/kernel/mips_machine.c 1970-01-01 01:00:00.000000000 +0100
  9131. +++ linux-2.6.35.7/arch/mips/kernel/mips_machine.c 2010-10-14 20:27:59.536722433 +0200
  9132. @@ -0,0 +1,121 @@
  9133. +/*
  9134. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  9135. + *
  9136. + * This program is free software; you can redistribute it and/or modify it
  9137. + * under the terms of the GNU General Public License version 2 as published
  9138. + * by the Free Software Foundation.
  9139. + *
  9140. + */
  9141. +#include <linux/mm.h>
  9142. +#include <linux/slab.h>
  9143. +#include <linux/string.h>
  9144. +
  9145. +#include <asm/mips_machine.h>
  9146. +
  9147. +static struct list_head mips_machines __initdata =
  9148. + LIST_HEAD_INIT(mips_machines);
  9149. +static char *mips_machid __initdata;
  9150. +
  9151. +char *mips_machine_name = "Unknown";
  9152. +
  9153. +static struct mips_machine * __init mips_machine_find(unsigned long machtype)
  9154. +{
  9155. + struct list_head *this;
  9156. +
  9157. + list_for_each(this, &mips_machines) {
  9158. + struct mips_machine *mach;
  9159. +
  9160. + mach = list_entry(this, struct mips_machine, list);
  9161. + if (mach->mach_type == machtype)
  9162. + return mach;
  9163. + }
  9164. +
  9165. + return NULL;
  9166. +}
  9167. +
  9168. +void __init mips_machine_register(struct mips_machine *mach)
  9169. +{
  9170. + list_add_tail(&mach->list, &mips_machines);
  9171. +}
  9172. +
  9173. +void __init mips_machine_set_name(char *name)
  9174. +{
  9175. + unsigned int len;
  9176. + char *p;
  9177. +
  9178. + if (name == NULL)
  9179. + return;
  9180. +
  9181. + len = strlen(name);
  9182. + p = kmalloc(len + 1, GFP_KERNEL);
  9183. + if (p) {
  9184. + strncpy(p, name, len);
  9185. + p[len] = '\0';
  9186. + mips_machine_name = p;
  9187. + } else {
  9188. + printk(KERN_WARNING "MIPS: no memory for machine_name\n");
  9189. + }
  9190. +}
  9191. +
  9192. +void __init mips_machine_setup(void)
  9193. +{
  9194. + struct mips_machine *mach;
  9195. +
  9196. + mach = mips_machine_find(mips_machtype);
  9197. + if (!mach) {
  9198. + printk(KERN_WARNING "MIPS: no machine registered for "
  9199. + "machtype %lu\n", mips_machtype);
  9200. + return;
  9201. + }
  9202. +
  9203. + mips_machine_set_name(mach->mach_name);
  9204. + printk(KERN_NOTICE "MIPS: machine is %s\n", mips_machine_name);
  9205. +
  9206. + if (mach->mach_setup)
  9207. + mach->mach_setup();
  9208. +}
  9209. +
  9210. +int __init mips_machtype_setup(char *id)
  9211. +{
  9212. + if (mips_machid == NULL)
  9213. + mips_machid = id;
  9214. +
  9215. + return 1;
  9216. +}
  9217. +
  9218. +__setup("machtype=", mips_machtype_setup);
  9219. +
  9220. +static int __init mips_machtype_init(void)
  9221. +{
  9222. + struct list_head *this;
  9223. + struct mips_machine *mach;
  9224. +
  9225. + if (mips_machid == NULL)
  9226. + return 0;
  9227. +
  9228. + list_for_each(this, &mips_machines) {
  9229. + mach = list_entry(this, struct mips_machine, list);
  9230. + if (mach->mach_id == NULL)
  9231. + continue;
  9232. +
  9233. + if (strcmp(mach->mach_id, mips_machid) == 0) {
  9234. + mips_machtype = mach->mach_type;
  9235. + return 0;
  9236. + }
  9237. + }
  9238. +
  9239. + printk(KERN_WARNING
  9240. + "MIPS: no machine found for id: '%s', registered machines:\n",
  9241. + mips_machid);
  9242. + printk(KERN_WARNING "%32s %s\n", "id", "name");
  9243. +
  9244. + list_for_each(this, &mips_machines) {
  9245. + mach = list_entry(this, struct mips_machine, list);
  9246. + printk(KERN_WARNING "%32s %s\n",
  9247. + mach->mach_id ? mach->mach_id : "", mach->mach_name);
  9248. + }
  9249. +
  9250. + return 0;
  9251. +}
  9252. +
  9253. +core_initcall(mips_machtype_init);
  9254. diff -Nur linux-2.6.35.7.orig/arch/mips/kernel/proc.c linux-2.6.35.7/arch/mips/kernel/proc.c
  9255. --- linux-2.6.35.7.orig/arch/mips/kernel/proc.c 2010-09-29 03:09:08.000000000 +0200
  9256. +++ linux-2.6.35.7/arch/mips/kernel/proc.c 2010-10-14 20:27:59.578101125 +0200
  9257. @@ -12,6 +12,7 @@
  9258. #include <asm/cpu-features.h>
  9259. #include <asm/mipsregs.h>
  9260. #include <asm/processor.h>
  9261. +#include <asm/mips_machine.h>
  9262. unsigned int vced_count, vcei_count;
  9263. @@ -31,8 +32,12 @@
  9264. /*
  9265. * For the first processor also print the system type
  9266. */
  9267. - if (n == 0)
  9268. + if (n == 0) {
  9269. seq_printf(m, "system type\t\t: %s\n", get_system_type());
  9270. +#ifdef CONFIG_MIPS_MACHINE
  9271. + seq_printf(m, "machine\t\t\t: %s\n", mips_machine_name);
  9272. +#endif
  9273. + }
  9274. seq_printf(m, "processor\t\t: %ld\n", n);
  9275. sprintf(fmt, "cpu model\t\t: %%s V%%d.%%d%s\n",
  9276. diff -Nur linux-2.6.35.7.orig/arch/mips/kernel/traps.c linux-2.6.35.7/arch/mips/kernel/traps.c
  9277. --- linux-2.6.35.7.orig/arch/mips/kernel/traps.c 2010-09-29 03:09:08.000000000 +0200
  9278. +++ linux-2.6.35.7/arch/mips/kernel/traps.c 2010-10-14 20:27:59.634370215 +0200
  9279. @@ -51,6 +51,7 @@
  9280. #include <asm/types.h>
  9281. #include <asm/stacktrace.h>
  9282. #include <asm/irq.h>
  9283. +#include <asm/time.h>
  9284. #include <asm/uasm.h>
  9285. extern void check_wait(void);
  9286. @@ -1519,6 +1520,8 @@
  9287. if (cpu_has_mips_r2) {
  9288. cp0_compare_irq_shift = CAUSEB_TI - CAUSEB_IP;
  9289. cp0_compare_irq = (read_c0_intctl() >> INTCTLB_IPTI) & 7;
  9290. + if (get_c0_compare_irq)
  9291. + cp0_compare_irq = get_c0_compare_irq();
  9292. cp0_perfcount_irq = (read_c0_intctl() >> INTCTLB_IPPCI) & 7;
  9293. if (cp0_perfcount_irq == cp0_compare_irq)
  9294. cp0_perfcount_irq = -1;
  9295. diff -Nur linux-2.6.35.7.orig/arch/mips/kernel/traps.c.orig linux-2.6.35.7/arch/mips/kernel/traps.c.orig
  9296. --- linux-2.6.35.7.orig/arch/mips/kernel/traps.c.orig 1970-01-01 01:00:00.000000000 +0100
  9297. +++ linux-2.6.35.7/arch/mips/kernel/traps.c.orig 2010-09-29 03:09:08.000000000 +0200
  9298. @@ -0,0 +1,1738 @@
  9299. +/*
  9300. + * This file is subject to the terms and conditions of the GNU General Public
  9301. + * License. See the file "COPYING" in the main directory of this archive
  9302. + * for more details.
  9303. + *
  9304. + * Copyright (C) 1994 - 1999, 2000, 01, 06 Ralf Baechle
  9305. + * Copyright (C) 1995, 1996 Paul M. Antoine
  9306. + * Copyright (C) 1998 Ulf Carlsson
  9307. + * Copyright (C) 1999 Silicon Graphics, Inc.
  9308. + * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
  9309. + * Copyright (C) 2000, 01 MIPS Technologies, Inc.
  9310. + * Copyright (C) 2002, 2003, 2004, 2005, 2007 Maciej W. Rozycki
  9311. + */
  9312. +#include <linux/bug.h>
  9313. +#include <linux/compiler.h>
  9314. +#include <linux/init.h>
  9315. +#include <linux/mm.h>
  9316. +#include <linux/module.h>
  9317. +#include <linux/sched.h>
  9318. +#include <linux/smp.h>
  9319. +#include <linux/spinlock.h>
  9320. +#include <linux/kallsyms.h>
  9321. +#include <linux/bootmem.h>
  9322. +#include <linux/interrupt.h>
  9323. +#include <linux/ptrace.h>
  9324. +#include <linux/kgdb.h>
  9325. +#include <linux/kdebug.h>
  9326. +#include <linux/notifier.h>
  9327. +#include <linux/kdb.h>
  9328. +
  9329. +#include <asm/bootinfo.h>
  9330. +#include <asm/branch.h>
  9331. +#include <asm/break.h>
  9332. +#include <asm/cop2.h>
  9333. +#include <asm/cpu.h>
  9334. +#include <asm/dsp.h>
  9335. +#include <asm/fpu.h>
  9336. +#include <asm/fpu_emulator.h>
  9337. +#include <asm/mipsregs.h>
  9338. +#include <asm/mipsmtregs.h>
  9339. +#include <asm/module.h>
  9340. +#include <asm/pgtable.h>
  9341. +#include <asm/ptrace.h>
  9342. +#include <asm/sections.h>
  9343. +#include <asm/system.h>
  9344. +#include <asm/tlbdebug.h>
  9345. +#include <asm/traps.h>
  9346. +#include <asm/uaccess.h>
  9347. +#include <asm/watch.h>
  9348. +#include <asm/mmu_context.h>
  9349. +#include <asm/types.h>
  9350. +#include <asm/stacktrace.h>
  9351. +#include <asm/irq.h>
  9352. +#include <asm/uasm.h>
  9353. +
  9354. +extern void check_wait(void);
  9355. +extern asmlinkage void r4k_wait(void);
  9356. +extern asmlinkage void rollback_handle_int(void);
  9357. +extern asmlinkage void handle_int(void);
  9358. +extern asmlinkage void handle_tlbm(void);
  9359. +extern asmlinkage void handle_tlbl(void);
  9360. +extern asmlinkage void handle_tlbs(void);
  9361. +extern asmlinkage void handle_adel(void);
  9362. +extern asmlinkage void handle_ades(void);
  9363. +extern asmlinkage void handle_ibe(void);
  9364. +extern asmlinkage void handle_dbe(void);
  9365. +extern asmlinkage void handle_sys(void);
  9366. +extern asmlinkage void handle_bp(void);
  9367. +extern asmlinkage void handle_ri(void);
  9368. +extern asmlinkage void handle_ri_rdhwr_vivt(void);
  9369. +extern asmlinkage void handle_ri_rdhwr(void);
  9370. +extern asmlinkage void handle_cpu(void);
  9371. +extern asmlinkage void handle_ov(void);
  9372. +extern asmlinkage void handle_tr(void);
  9373. +extern asmlinkage void handle_fpe(void);
  9374. +extern asmlinkage void handle_mdmx(void);
  9375. +extern asmlinkage void handle_watch(void);
  9376. +extern asmlinkage void handle_mt(void);
  9377. +extern asmlinkage void handle_dsp(void);
  9378. +extern asmlinkage void handle_mcheck(void);
  9379. +extern asmlinkage void handle_reserved(void);
  9380. +
  9381. +extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
  9382. + struct mips_fpu_struct *ctx, int has_fpu);
  9383. +
  9384. +void (*board_be_init)(void);
  9385. +int (*board_be_handler)(struct pt_regs *regs, int is_fixup);
  9386. +void (*board_nmi_handler_setup)(void);
  9387. +void (*board_ejtag_handler_setup)(void);
  9388. +void (*board_bind_eic_interrupt)(int irq, int regset);
  9389. +
  9390. +
  9391. +static void show_raw_backtrace(unsigned long reg29)
  9392. +{
  9393. + unsigned long *sp = (unsigned long *)(reg29 & ~3);
  9394. + unsigned long addr;
  9395. +
  9396. + printk("Call Trace:");
  9397. +#ifdef CONFIG_KALLSYMS
  9398. + printk("\n");
  9399. +#endif
  9400. + while (!kstack_end(sp)) {
  9401. + unsigned long __user *p =
  9402. + (unsigned long __user *)(unsigned long)sp++;
  9403. + if (__get_user(addr, p)) {
  9404. + printk(" (Bad stack address)");
  9405. + break;
  9406. + }
  9407. + if (__kernel_text_address(addr))
  9408. + print_ip_sym(addr);
  9409. + }
  9410. + printk("\n");
  9411. +}
  9412. +
  9413. +#ifdef CONFIG_KALLSYMS
  9414. +int raw_show_trace;
  9415. +static int __init set_raw_show_trace(char *str)
  9416. +{
  9417. + raw_show_trace = 1;
  9418. + return 1;
  9419. +}
  9420. +__setup("raw_show_trace", set_raw_show_trace);
  9421. +#endif
  9422. +
  9423. +static void show_backtrace(struct task_struct *task, const struct pt_regs *regs)
  9424. +{
  9425. + unsigned long sp = regs->regs[29];
  9426. + unsigned long ra = regs->regs[31];
  9427. + unsigned long pc = regs->cp0_epc;
  9428. +
  9429. + if (raw_show_trace || !__kernel_text_address(pc)) {
  9430. + show_raw_backtrace(sp);
  9431. + return;
  9432. + }
  9433. + printk("Call Trace:\n");
  9434. + do {
  9435. + print_ip_sym(pc);
  9436. + pc = unwind_stack(task, &sp, pc, &ra);
  9437. + } while (pc);
  9438. + printk("\n");
  9439. +}
  9440. +
  9441. +/*
  9442. + * This routine abuses get_user()/put_user() to reference pointers
  9443. + * with at least a bit of error checking ...
  9444. + */
  9445. +static void show_stacktrace(struct task_struct *task,
  9446. + const struct pt_regs *regs)
  9447. +{
  9448. + const int field = 2 * sizeof(unsigned long);
  9449. + long stackdata;
  9450. + int i;
  9451. + unsigned long __user *sp = (unsigned long __user *)regs->regs[29];
  9452. +
  9453. + printk("Stack :");
  9454. + i = 0;
  9455. + while ((unsigned long) sp & (PAGE_SIZE - 1)) {
  9456. + if (i && ((i % (64 / field)) == 0))
  9457. + printk("\n ");
  9458. + if (i > 39) {
  9459. + printk(" ...");
  9460. + break;
  9461. + }
  9462. +
  9463. + if (__get_user(stackdata, sp++)) {
  9464. + printk(" (Bad stack address)");
  9465. + break;
  9466. + }
  9467. +
  9468. + printk(" %0*lx", field, stackdata);
  9469. + i++;
  9470. + }
  9471. + printk("\n");
  9472. + show_backtrace(task, regs);
  9473. +}
  9474. +
  9475. +void show_stack(struct task_struct *task, unsigned long *sp)
  9476. +{
  9477. + struct pt_regs regs;
  9478. + if (sp) {
  9479. + regs.regs[29] = (unsigned long)sp;
  9480. + regs.regs[31] = 0;
  9481. + regs.cp0_epc = 0;
  9482. + } else {
  9483. + if (task && task != current) {
  9484. + regs.regs[29] = task->thread.reg29;
  9485. + regs.regs[31] = 0;
  9486. + regs.cp0_epc = task->thread.reg31;
  9487. +#ifdef CONFIG_KGDB_KDB
  9488. + } else if (atomic_read(&kgdb_active) != -1 &&
  9489. + kdb_current_regs) {
  9490. + memcpy(&regs, kdb_current_regs, sizeof(regs));
  9491. +#endif /* CONFIG_KGDB_KDB */
  9492. + } else {
  9493. + prepare_frametrace(&regs);
  9494. + }
  9495. + }
  9496. + show_stacktrace(task, &regs);
  9497. +}
  9498. +
  9499. +/*
  9500. + * The architecture-independent dump_stack generator
  9501. + */
  9502. +void dump_stack(void)
  9503. +{
  9504. + struct pt_regs regs;
  9505. +
  9506. + prepare_frametrace(&regs);
  9507. + show_backtrace(current, &regs);
  9508. +}
  9509. +
  9510. +EXPORT_SYMBOL(dump_stack);
  9511. +
  9512. +static void show_code(unsigned int __user *pc)
  9513. +{
  9514. + long i;
  9515. + unsigned short __user *pc16 = NULL;
  9516. +
  9517. + printk("\nCode:");
  9518. +
  9519. + if ((unsigned long)pc & 1)
  9520. + pc16 = (unsigned short __user *)((unsigned long)pc & ~1);
  9521. + for(i = -3 ; i < 6 ; i++) {
  9522. + unsigned int insn;
  9523. + if (pc16 ? __get_user(insn, pc16 + i) : __get_user(insn, pc + i)) {
  9524. + printk(" (Bad address in epc)\n");
  9525. + break;
  9526. + }
  9527. + printk("%c%0*x%c", (i?' ':'<'), pc16 ? 4 : 8, insn, (i?' ':'>'));
  9528. + }
  9529. +}
  9530. +
  9531. +static void __show_regs(const struct pt_regs *regs)
  9532. +{
  9533. + const int field = 2 * sizeof(unsigned long);
  9534. + unsigned int cause = regs->cp0_cause;
  9535. + int i;
  9536. +
  9537. + printk("Cpu %d\n", smp_processor_id());
  9538. +
  9539. + /*
  9540. + * Saved main processor registers
  9541. + */
  9542. + for (i = 0; i < 32; ) {
  9543. + if ((i % 4) == 0)
  9544. + printk("$%2d :", i);
  9545. + if (i == 0)
  9546. + printk(" %0*lx", field, 0UL);
  9547. + else if (i == 26 || i == 27)
  9548. + printk(" %*s", field, "");
  9549. + else
  9550. + printk(" %0*lx", field, regs->regs[i]);
  9551. +
  9552. + i++;
  9553. + if ((i % 4) == 0)
  9554. + printk("\n");
  9555. + }
  9556. +
  9557. +#ifdef CONFIG_CPU_HAS_SMARTMIPS
  9558. + printk("Acx : %0*lx\n", field, regs->acx);
  9559. +#endif
  9560. + printk("Hi : %0*lx\n", field, regs->hi);
  9561. + printk("Lo : %0*lx\n", field, regs->lo);
  9562. +
  9563. + /*
  9564. + * Saved cp0 registers
  9565. + */
  9566. + printk("epc : %0*lx %pS\n", field, regs->cp0_epc,
  9567. + (void *) regs->cp0_epc);
  9568. + printk(" %s\n", print_tainted());
  9569. + printk("ra : %0*lx %pS\n", field, regs->regs[31],
  9570. + (void *) regs->regs[31]);
  9571. +
  9572. + printk("Status: %08x ", (uint32_t) regs->cp0_status);
  9573. +
  9574. + if (current_cpu_data.isa_level == MIPS_CPU_ISA_I) {
  9575. + if (regs->cp0_status & ST0_KUO)
  9576. + printk("KUo ");
  9577. + if (regs->cp0_status & ST0_IEO)
  9578. + printk("IEo ");
  9579. + if (regs->cp0_status & ST0_KUP)
  9580. + printk("KUp ");
  9581. + if (regs->cp0_status & ST0_IEP)
  9582. + printk("IEp ");
  9583. + if (regs->cp0_status & ST0_KUC)
  9584. + printk("KUc ");
  9585. + if (regs->cp0_status & ST0_IEC)
  9586. + printk("IEc ");
  9587. + } else {
  9588. + if (regs->cp0_status & ST0_KX)
  9589. + printk("KX ");
  9590. + if (regs->cp0_status & ST0_SX)
  9591. + printk("SX ");
  9592. + if (regs->cp0_status & ST0_UX)
  9593. + printk("UX ");
  9594. + switch (regs->cp0_status & ST0_KSU) {
  9595. + case KSU_USER:
  9596. + printk("USER ");
  9597. + break;
  9598. + case KSU_SUPERVISOR:
  9599. + printk("SUPERVISOR ");
  9600. + break;
  9601. + case KSU_KERNEL:
  9602. + printk("KERNEL ");
  9603. + break;
  9604. + default:
  9605. + printk("BAD_MODE ");
  9606. + break;
  9607. + }
  9608. + if (regs->cp0_status & ST0_ERL)
  9609. + printk("ERL ");
  9610. + if (regs->cp0_status & ST0_EXL)
  9611. + printk("EXL ");
  9612. + if (regs->cp0_status & ST0_IE)
  9613. + printk("IE ");
  9614. + }
  9615. + printk("\n");
  9616. +
  9617. + printk("Cause : %08x\n", cause);
  9618. +
  9619. + cause = (cause & CAUSEF_EXCCODE) >> CAUSEB_EXCCODE;
  9620. + if (1 <= cause && cause <= 5)
  9621. + printk("BadVA : %0*lx\n", field, regs->cp0_badvaddr);
  9622. +
  9623. + printk("PrId : %08x (%s)\n", read_c0_prid(),
  9624. + cpu_name_string());
  9625. +}
  9626. +
  9627. +/*
  9628. + * FIXME: really the generic show_regs should take a const pointer argument.
  9629. + */
  9630. +void show_regs(struct pt_regs *regs)
  9631. +{
  9632. + __show_regs((struct pt_regs *)regs);
  9633. +}
  9634. +
  9635. +void show_registers(const struct pt_regs *regs)
  9636. +{
  9637. + const int field = 2 * sizeof(unsigned long);
  9638. +
  9639. + __show_regs(regs);
  9640. + print_modules();
  9641. + printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
  9642. + current->comm, current->pid, current_thread_info(), current,
  9643. + field, current_thread_info()->tp_value);
  9644. + if (cpu_has_userlocal) {
  9645. + unsigned long tls;
  9646. +
  9647. + tls = read_c0_userlocal();
  9648. + if (tls != current_thread_info()->tp_value)
  9649. + printk("*HwTLS: %0*lx\n", field, tls);
  9650. + }
  9651. +
  9652. + show_stacktrace(current, regs);
  9653. + show_code((unsigned int __user *) regs->cp0_epc);
  9654. + printk("\n");
  9655. +}
  9656. +
  9657. +static DEFINE_SPINLOCK(die_lock);
  9658. +
  9659. +void __noreturn die(const char * str, struct pt_regs * regs)
  9660. +{
  9661. + static int die_counter;
  9662. + int sig = SIGSEGV;
  9663. +#ifdef CONFIG_MIPS_MT_SMTC
  9664. + unsigned long dvpret = dvpe();
  9665. +#endif /* CONFIG_MIPS_MT_SMTC */
  9666. +
  9667. + notify_die(DIE_OOPS, str, (struct pt_regs *)regs, SIGSEGV, 0, 0);
  9668. +
  9669. + console_verbose();
  9670. + spin_lock_irq(&die_lock);
  9671. + bust_spinlocks(1);
  9672. +#ifdef CONFIG_MIPS_MT_SMTC
  9673. + mips_mt_regdump(dvpret);
  9674. +#endif /* CONFIG_MIPS_MT_SMTC */
  9675. +
  9676. + if (notify_die(DIE_OOPS, str, regs, 0, current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
  9677. + sig = 0;
  9678. +
  9679. + printk("%s[#%d]:\n", str, ++die_counter);
  9680. + show_registers(regs);
  9681. + add_taint(TAINT_DIE);
  9682. + spin_unlock_irq(&die_lock);
  9683. +
  9684. + if (in_interrupt())
  9685. + panic("Fatal exception in interrupt");
  9686. +
  9687. + if (panic_on_oops) {
  9688. + printk(KERN_EMERG "Fatal exception: panic in 5 seconds\n");
  9689. + ssleep(5);
  9690. + panic("Fatal exception");
  9691. + }
  9692. +
  9693. + do_exit(sig);
  9694. +}
  9695. +
  9696. +extern struct exception_table_entry __start___dbe_table[];
  9697. +extern struct exception_table_entry __stop___dbe_table[];
  9698. +
  9699. +__asm__(
  9700. +" .section __dbe_table, \"a\"\n"
  9701. +" .previous \n");
  9702. +
  9703. +/* Given an address, look for it in the exception tables. */
  9704. +static const struct exception_table_entry *search_dbe_tables(unsigned long addr)
  9705. +{
  9706. + const struct exception_table_entry *e;
  9707. +
  9708. + e = search_extable(__start___dbe_table, __stop___dbe_table - 1, addr);
  9709. + if (!e)
  9710. + e = search_module_dbetables(addr);
  9711. + return e;
  9712. +}
  9713. +
  9714. +asmlinkage void do_be(struct pt_regs *regs)
  9715. +{
  9716. + const int field = 2 * sizeof(unsigned long);
  9717. + const struct exception_table_entry *fixup = NULL;
  9718. + int data = regs->cp0_cause & 4;
  9719. + int action = MIPS_BE_FATAL;
  9720. +
  9721. + /* XXX For now. Fixme, this searches the wrong table ... */
  9722. + if (data && !user_mode(regs))
  9723. + fixup = search_dbe_tables(exception_epc(regs));
  9724. +
  9725. + if (fixup)
  9726. + action = MIPS_BE_FIXUP;
  9727. +
  9728. + if (board_be_handler)
  9729. + action = board_be_handler(regs, fixup != NULL);
  9730. +
  9731. + switch (action) {
  9732. + case MIPS_BE_DISCARD:
  9733. + return;
  9734. + case MIPS_BE_FIXUP:
  9735. + if (fixup) {
  9736. + regs->cp0_epc = fixup->nextinsn;
  9737. + return;
  9738. + }
  9739. + break;
  9740. + default:
  9741. + break;
  9742. + }
  9743. +
  9744. + /*
  9745. + * Assume it would be too dangerous to continue ...
  9746. + */
  9747. + printk(KERN_ALERT "%s bus error, epc == %0*lx, ra == %0*lx\n",
  9748. + data ? "Data" : "Instruction",
  9749. + field, regs->cp0_epc, field, regs->regs[31]);
  9750. + if (notify_die(DIE_OOPS, "bus error", regs, SIGBUS, 0, 0)
  9751. + == NOTIFY_STOP)
  9752. + return;
  9753. +
  9754. + die_if_kernel("Oops", regs);
  9755. + force_sig(SIGBUS, current);
  9756. +}
  9757. +
  9758. +/*
  9759. + * ll/sc, rdhwr, sync emulation
  9760. + */
  9761. +
  9762. +#define OPCODE 0xfc000000
  9763. +#define BASE 0x03e00000
  9764. +#define RT 0x001f0000
  9765. +#define OFFSET 0x0000ffff
  9766. +#define LL 0xc0000000
  9767. +#define SC 0xe0000000
  9768. +#define SPEC0 0x00000000
  9769. +#define SPEC3 0x7c000000
  9770. +#define RD 0x0000f800
  9771. +#define FUNC 0x0000003f
  9772. +#define SYNC 0x0000000f
  9773. +#define RDHWR 0x0000003b
  9774. +
  9775. +/*
  9776. + * The ll_bit is cleared by r*_switch.S
  9777. + */
  9778. +
  9779. +unsigned int ll_bit;
  9780. +struct task_struct *ll_task;
  9781. +
  9782. +static inline int simulate_ll(struct pt_regs *regs, unsigned int opcode)
  9783. +{
  9784. + unsigned long value, __user *vaddr;
  9785. + long offset;
  9786. +
  9787. + /*
  9788. + * analyse the ll instruction that just caused a ri exception
  9789. + * and put the referenced address to addr.
  9790. + */
  9791. +
  9792. + /* sign extend offset */
  9793. + offset = opcode & OFFSET;
  9794. + offset <<= 16;
  9795. + offset >>= 16;
  9796. +
  9797. + vaddr = (unsigned long __user *)
  9798. + ((unsigned long)(regs->regs[(opcode & BASE) >> 21]) + offset);
  9799. +
  9800. + if ((unsigned long)vaddr & 3)
  9801. + return SIGBUS;
  9802. + if (get_user(value, vaddr))
  9803. + return SIGSEGV;
  9804. +
  9805. + preempt_disable();
  9806. +
  9807. + if (ll_task == NULL || ll_task == current) {
  9808. + ll_bit = 1;
  9809. + } else {
  9810. + ll_bit = 0;
  9811. + }
  9812. + ll_task = current;
  9813. +
  9814. + preempt_enable();
  9815. +
  9816. + regs->regs[(opcode & RT) >> 16] = value;
  9817. +
  9818. + return 0;
  9819. +}
  9820. +
  9821. +static inline int simulate_sc(struct pt_regs *regs, unsigned int opcode)
  9822. +{
  9823. + unsigned long __user *vaddr;
  9824. + unsigned long reg;
  9825. + long offset;
  9826. +
  9827. + /*
  9828. + * analyse the sc instruction that just caused a ri exception
  9829. + * and put the referenced address to addr.
  9830. + */
  9831. +
  9832. + /* sign extend offset */
  9833. + offset = opcode & OFFSET;
  9834. + offset <<= 16;
  9835. + offset >>= 16;
  9836. +
  9837. + vaddr = (unsigned long __user *)
  9838. + ((unsigned long)(regs->regs[(opcode & BASE) >> 21]) + offset);
  9839. + reg = (opcode & RT) >> 16;
  9840. +
  9841. + if ((unsigned long)vaddr & 3)
  9842. + return SIGBUS;
  9843. +
  9844. + preempt_disable();
  9845. +
  9846. + if (ll_bit == 0 || ll_task != current) {
  9847. + regs->regs[reg] = 0;
  9848. + preempt_enable();
  9849. + return 0;
  9850. + }
  9851. +
  9852. + preempt_enable();
  9853. +
  9854. + if (put_user(regs->regs[reg], vaddr))
  9855. + return SIGSEGV;
  9856. +
  9857. + regs->regs[reg] = 1;
  9858. +
  9859. + return 0;
  9860. +}
  9861. +
  9862. +/*
  9863. + * ll uses the opcode of lwc0 and sc uses the opcode of swc0. That is both
  9864. + * opcodes are supposed to result in coprocessor unusable exceptions if
  9865. + * executed on ll/sc-less processors. That's the theory. In practice a
  9866. + * few processors such as NEC's VR4100 throw reserved instruction exceptions
  9867. + * instead, so we're doing the emulation thing in both exception handlers.
  9868. + */
  9869. +static int simulate_llsc(struct pt_regs *regs, unsigned int opcode)
  9870. +{
  9871. + if ((opcode & OPCODE) == LL)
  9872. + return simulate_ll(regs, opcode);
  9873. + if ((opcode & OPCODE) == SC)
  9874. + return simulate_sc(regs, opcode);
  9875. +
  9876. + return -1; /* Must be something else ... */
  9877. +}
  9878. +
  9879. +/*
  9880. + * Simulate trapping 'rdhwr' instructions to provide user accessible
  9881. + * registers not implemented in hardware.
  9882. + */
  9883. +static int simulate_rdhwr(struct pt_regs *regs, unsigned int opcode)
  9884. +{
  9885. + struct thread_info *ti = task_thread_info(current);
  9886. +
  9887. + if ((opcode & OPCODE) == SPEC3 && (opcode & FUNC) == RDHWR) {
  9888. + int rd = (opcode & RD) >> 11;
  9889. + int rt = (opcode & RT) >> 16;
  9890. + switch (rd) {
  9891. + case 0: /* CPU number */
  9892. + regs->regs[rt] = smp_processor_id();
  9893. + return 0;
  9894. + case 1: /* SYNCI length */
  9895. + regs->regs[rt] = min(current_cpu_data.dcache.linesz,
  9896. + current_cpu_data.icache.linesz);
  9897. + return 0;
  9898. + case 2: /* Read count register */
  9899. + regs->regs[rt] = read_c0_count();
  9900. + return 0;
  9901. + case 3: /* Count register resolution */
  9902. + switch (current_cpu_data.cputype) {
  9903. + case CPU_20KC:
  9904. + case CPU_25KF:
  9905. + regs->regs[rt] = 1;
  9906. + break;
  9907. + default:
  9908. + regs->regs[rt] = 2;
  9909. + }
  9910. + return 0;
  9911. + case 29:
  9912. + regs->regs[rt] = ti->tp_value;
  9913. + return 0;
  9914. + default:
  9915. + return -1;
  9916. + }
  9917. + }
  9918. +
  9919. + /* Not ours. */
  9920. + return -1;
  9921. +}
  9922. +
  9923. +static int simulate_sync(struct pt_regs *regs, unsigned int opcode)
  9924. +{
  9925. + if ((opcode & OPCODE) == SPEC0 && (opcode & FUNC) == SYNC)
  9926. + return 0;
  9927. +
  9928. + return -1; /* Must be something else ... */
  9929. +}
  9930. +
  9931. +asmlinkage void do_ov(struct pt_regs *regs)
  9932. +{
  9933. + siginfo_t info;
  9934. +
  9935. + die_if_kernel("Integer overflow", regs);
  9936. +
  9937. + info.si_code = FPE_INTOVF;
  9938. + info.si_signo = SIGFPE;
  9939. + info.si_errno = 0;
  9940. + info.si_addr = (void __user *) regs->cp0_epc;
  9941. + force_sig_info(SIGFPE, &info, current);
  9942. +}
  9943. +
  9944. +/*
  9945. + * XXX Delayed fp exceptions when doing a lazy ctx switch XXX
  9946. + */
  9947. +asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
  9948. +{
  9949. + siginfo_t info;
  9950. +
  9951. + if (notify_die(DIE_FP, "FP exception", regs, SIGFPE, 0, 0)
  9952. + == NOTIFY_STOP)
  9953. + return;
  9954. + die_if_kernel("FP exception in kernel code", regs);
  9955. +
  9956. + if (fcr31 & FPU_CSR_UNI_X) {
  9957. + int sig;
  9958. +
  9959. + /*
  9960. + * Unimplemented operation exception. If we've got the full
  9961. + * software emulator on-board, let's use it...
  9962. + *
  9963. + * Force FPU to dump state into task/thread context. We're
  9964. + * moving a lot of data here for what is probably a single
  9965. + * instruction, but the alternative is to pre-decode the FP
  9966. + * register operands before invoking the emulator, which seems
  9967. + * a bit extreme for what should be an infrequent event.
  9968. + */
  9969. + /* Ensure 'resume' not overwrite saved fp context again. */
  9970. + lose_fpu(1);
  9971. +
  9972. + /* Run the emulator */
  9973. + sig = fpu_emulator_cop1Handler(regs, &current->thread.fpu, 1);
  9974. +
  9975. + /*
  9976. + * We can't allow the emulated instruction to leave any of
  9977. + * the cause bit set in $fcr31.
  9978. + */
  9979. + current->thread.fpu.fcr31 &= ~FPU_CSR_ALL_X;
  9980. +
  9981. + /* Restore the hardware register state */
  9982. + own_fpu(1); /* Using the FPU again. */
  9983. +
  9984. + /* If something went wrong, signal */
  9985. + if (sig)
  9986. + force_sig(sig, current);
  9987. +
  9988. + return;
  9989. + } else if (fcr31 & FPU_CSR_INV_X)
  9990. + info.si_code = FPE_FLTINV;
  9991. + else if (fcr31 & FPU_CSR_DIV_X)
  9992. + info.si_code = FPE_FLTDIV;
  9993. + else if (fcr31 & FPU_CSR_OVF_X)
  9994. + info.si_code = FPE_FLTOVF;
  9995. + else if (fcr31 & FPU_CSR_UDF_X)
  9996. + info.si_code = FPE_FLTUND;
  9997. + else if (fcr31 & FPU_CSR_INE_X)
  9998. + info.si_code = FPE_FLTRES;
  9999. + else
  10000. + info.si_code = __SI_FAULT;
  10001. + info.si_signo = SIGFPE;
  10002. + info.si_errno = 0;
  10003. + info.si_addr = (void __user *) regs->cp0_epc;
  10004. + force_sig_info(SIGFPE, &info, current);
  10005. +}
  10006. +
  10007. +static void do_trap_or_bp(struct pt_regs *regs, unsigned int code,
  10008. + const char *str)
  10009. +{
  10010. + siginfo_t info;
  10011. + char b[40];
  10012. +
  10013. +#ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
  10014. + if (kgdb_ll_trap(DIE_TRAP, str, regs, code, 0, 0) == NOTIFY_STOP)
  10015. + return;
  10016. +#endif /* CONFIG_KGDB_LOW_LEVEL_TRAP */
  10017. +
  10018. + if (notify_die(DIE_TRAP, str, regs, code, 0, 0) == NOTIFY_STOP)
  10019. + return;
  10020. +
  10021. + /*
  10022. + * A short test says that IRIX 5.3 sends SIGTRAP for all trap
  10023. + * insns, even for trap and break codes that indicate arithmetic
  10024. + * failures. Weird ...
  10025. + * But should we continue the brokenness??? --macro
  10026. + */
  10027. + switch (code) {
  10028. + case BRK_OVERFLOW:
  10029. + case BRK_DIVZERO:
  10030. + scnprintf(b, sizeof(b), "%s instruction in kernel code", str);
  10031. + die_if_kernel(b, regs);
  10032. + if (code == BRK_DIVZERO)
  10033. + info.si_code = FPE_INTDIV;
  10034. + else
  10035. + info.si_code = FPE_INTOVF;
  10036. + info.si_signo = SIGFPE;
  10037. + info.si_errno = 0;
  10038. + info.si_addr = (void __user *) regs->cp0_epc;
  10039. + force_sig_info(SIGFPE, &info, current);
  10040. + break;
  10041. + case BRK_BUG:
  10042. + die_if_kernel("Kernel bug detected", regs);
  10043. + force_sig(SIGTRAP, current);
  10044. + break;
  10045. + case BRK_MEMU:
  10046. + /*
  10047. + * Address errors may be deliberately induced by the FPU
  10048. + * emulator to retake control of the CPU after executing the
  10049. + * instruction in the delay slot of an emulated branch.
  10050. + *
  10051. + * Terminate if exception was recognized as a delay slot return
  10052. + * otherwise handle as normal.
  10053. + */
  10054. + if (do_dsemulret(regs))
  10055. + return;
  10056. +
  10057. + die_if_kernel("Math emu break/trap", regs);
  10058. + force_sig(SIGTRAP, current);
  10059. + break;
  10060. + default:
  10061. + scnprintf(b, sizeof(b), "%s instruction in kernel code", str);
  10062. + die_if_kernel(b, regs);
  10063. + force_sig(SIGTRAP, current);
  10064. + }
  10065. +}
  10066. +
  10067. +asmlinkage void do_bp(struct pt_regs *regs)
  10068. +{
  10069. + unsigned int opcode, bcode;
  10070. +
  10071. + if (__get_user(opcode, (unsigned int __user *) exception_epc(regs)))
  10072. + goto out_sigsegv;
  10073. +
  10074. + /*
  10075. + * There is the ancient bug in the MIPS assemblers that the break
  10076. + * code starts left to bit 16 instead to bit 6 in the opcode.
  10077. + * Gas is bug-compatible, but not always, grrr...
  10078. + * We handle both cases with a simple heuristics. --macro
  10079. + */
  10080. + bcode = ((opcode >> 6) & ((1 << 20) - 1));
  10081. + if (bcode >= (1 << 10))
  10082. + bcode >>= 10;
  10083. +
  10084. + do_trap_or_bp(regs, bcode, "Break");
  10085. + return;
  10086. +
  10087. +out_sigsegv:
  10088. + force_sig(SIGSEGV, current);
  10089. +}
  10090. +
  10091. +asmlinkage void do_tr(struct pt_regs *regs)
  10092. +{
  10093. + unsigned int opcode, tcode = 0;
  10094. +
  10095. + if (__get_user(opcode, (unsigned int __user *) exception_epc(regs)))
  10096. + goto out_sigsegv;
  10097. +
  10098. + /* Immediate versions don't provide a code. */
  10099. + if (!(opcode & OPCODE))
  10100. + tcode = ((opcode >> 6) & ((1 << 10) - 1));
  10101. +
  10102. + do_trap_or_bp(regs, tcode, "Trap");
  10103. + return;
  10104. +
  10105. +out_sigsegv:
  10106. + force_sig(SIGSEGV, current);
  10107. +}
  10108. +
  10109. +asmlinkage void do_ri(struct pt_regs *regs)
  10110. +{
  10111. + unsigned int __user *epc = (unsigned int __user *)exception_epc(regs);
  10112. + unsigned long old_epc = regs->cp0_epc;
  10113. + unsigned int opcode = 0;
  10114. + int status = -1;
  10115. +
  10116. + if (notify_die(DIE_RI, "RI Fault", regs, SIGSEGV, 0, 0)
  10117. + == NOTIFY_STOP)
  10118. + return;
  10119. +
  10120. + die_if_kernel("Reserved instruction in kernel code", regs);
  10121. +
  10122. + if (unlikely(compute_return_epc(regs) < 0))
  10123. + return;
  10124. +
  10125. + if (unlikely(get_user(opcode, epc) < 0))
  10126. + status = SIGSEGV;
  10127. +
  10128. + if (!cpu_has_llsc && status < 0)
  10129. + status = simulate_llsc(regs, opcode);
  10130. +
  10131. + if (status < 0)
  10132. + status = simulate_rdhwr(regs, opcode);
  10133. +
  10134. + if (status < 0)
  10135. + status = simulate_sync(regs, opcode);
  10136. +
  10137. + if (status < 0)
  10138. + status = SIGILL;
  10139. +
  10140. + if (unlikely(status > 0)) {
  10141. + regs->cp0_epc = old_epc; /* Undo skip-over. */
  10142. + force_sig(status, current);
  10143. + }
  10144. +}
  10145. +
  10146. +/*
  10147. + * MIPS MT processors may have fewer FPU contexts than CPU threads. If we've
  10148. + * emulated more than some threshold number of instructions, force migration to
  10149. + * a "CPU" that has FP support.
  10150. + */
  10151. +static void mt_ase_fp_affinity(void)
  10152. +{
  10153. +#ifdef CONFIG_MIPS_MT_FPAFF
  10154. + if (mt_fpemul_threshold > 0 &&
  10155. + ((current->thread.emulated_fp++ > mt_fpemul_threshold))) {
  10156. + /*
  10157. + * If there's no FPU present, or if the application has already
  10158. + * restricted the allowed set to exclude any CPUs with FPUs,
  10159. + * we'll skip the procedure.
  10160. + */
  10161. + if (cpus_intersects(current->cpus_allowed, mt_fpu_cpumask)) {
  10162. + cpumask_t tmask;
  10163. +
  10164. + current->thread.user_cpus_allowed
  10165. + = current->cpus_allowed;
  10166. + cpus_and(tmask, current->cpus_allowed,
  10167. + mt_fpu_cpumask);
  10168. + set_cpus_allowed_ptr(current, &tmask);
  10169. + set_thread_flag(TIF_FPUBOUND);
  10170. + }
  10171. + }
  10172. +#endif /* CONFIG_MIPS_MT_FPAFF */
  10173. +}
  10174. +
  10175. +/*
  10176. + * No lock; only written during early bootup by CPU 0.
  10177. + */
  10178. +static RAW_NOTIFIER_HEAD(cu2_chain);
  10179. +
  10180. +int __ref register_cu2_notifier(struct notifier_block *nb)
  10181. +{
  10182. + return raw_notifier_chain_register(&cu2_chain, nb);
  10183. +}
  10184. +
  10185. +int cu2_notifier_call_chain(unsigned long val, void *v)
  10186. +{
  10187. + return raw_notifier_call_chain(&cu2_chain, val, v);
  10188. +}
  10189. +
  10190. +static int default_cu2_call(struct notifier_block *nfb, unsigned long action,
  10191. + void *data)
  10192. +{
  10193. + struct pt_regs *regs = data;
  10194. +
  10195. + switch (action) {
  10196. + default:
  10197. + die_if_kernel("Unhandled kernel unaligned access or invalid "
  10198. + "instruction", regs);
  10199. + /* Fall through */
  10200. +
  10201. + case CU2_EXCEPTION:
  10202. + force_sig(SIGILL, current);
  10203. + }
  10204. +
  10205. + return NOTIFY_OK;
  10206. +}
  10207. +
  10208. +static struct notifier_block default_cu2_notifier = {
  10209. + .notifier_call = default_cu2_call,
  10210. + .priority = 0x80000000, /* Run last */
  10211. +};
  10212. +
  10213. +asmlinkage void do_cpu(struct pt_regs *regs)
  10214. +{
  10215. + unsigned int __user *epc;
  10216. + unsigned long old_epc;
  10217. + unsigned int opcode;
  10218. + unsigned int cpid;
  10219. + int status;
  10220. + unsigned long __maybe_unused flags;
  10221. +
  10222. + die_if_kernel("do_cpu invoked from kernel context!", regs);
  10223. +
  10224. + cpid = (regs->cp0_cause >> CAUSEB_CE) & 3;
  10225. +
  10226. + switch (cpid) {
  10227. + case 0:
  10228. + epc = (unsigned int __user *)exception_epc(regs);
  10229. + old_epc = regs->cp0_epc;
  10230. + opcode = 0;
  10231. + status = -1;
  10232. +
  10233. + if (unlikely(compute_return_epc(regs) < 0))
  10234. + return;
  10235. +
  10236. + if (unlikely(get_user(opcode, epc) < 0))
  10237. + status = SIGSEGV;
  10238. +
  10239. + if (!cpu_has_llsc && status < 0)
  10240. + status = simulate_llsc(regs, opcode);
  10241. +
  10242. + if (status < 0)
  10243. + status = simulate_rdhwr(regs, opcode);
  10244. +
  10245. + if (status < 0)
  10246. + status = SIGILL;
  10247. +
  10248. + if (unlikely(status > 0)) {
  10249. + regs->cp0_epc = old_epc; /* Undo skip-over. */
  10250. + force_sig(status, current);
  10251. + }
  10252. +
  10253. + return;
  10254. +
  10255. + case 1:
  10256. + if (used_math()) /* Using the FPU again. */
  10257. + own_fpu(1);
  10258. + else { /* First time FPU user. */
  10259. + init_fpu();
  10260. + set_used_math();
  10261. + }
  10262. +
  10263. + if (!raw_cpu_has_fpu) {
  10264. + int sig;
  10265. + sig = fpu_emulator_cop1Handler(regs,
  10266. + &current->thread.fpu, 0);
  10267. + if (sig)
  10268. + force_sig(sig, current);
  10269. + else
  10270. + mt_ase_fp_affinity();
  10271. + }
  10272. +
  10273. + return;
  10274. +
  10275. + case 2:
  10276. + raw_notifier_call_chain(&cu2_chain, CU2_EXCEPTION, regs);
  10277. + return;
  10278. +
  10279. + case 3:
  10280. + break;
  10281. + }
  10282. +
  10283. + force_sig(SIGILL, current);
  10284. +}
  10285. +
  10286. +asmlinkage void do_mdmx(struct pt_regs *regs)
  10287. +{
  10288. + force_sig(SIGILL, current);
  10289. +}
  10290. +
  10291. +/*
  10292. + * Called with interrupts disabled.
  10293. + */
  10294. +asmlinkage void do_watch(struct pt_regs *regs)
  10295. +{
  10296. + u32 cause;
  10297. +
  10298. + /*
  10299. + * Clear WP (bit 22) bit of cause register so we don't loop
  10300. + * forever.
  10301. + */
  10302. + cause = read_c0_cause();
  10303. + cause &= ~(1 << 22);
  10304. + write_c0_cause(cause);
  10305. +
  10306. + /*
  10307. + * If the current thread has the watch registers loaded, save
  10308. + * their values and send SIGTRAP. Otherwise another thread
  10309. + * left the registers set, clear them and continue.
  10310. + */
  10311. + if (test_tsk_thread_flag(current, TIF_LOAD_WATCH)) {
  10312. + mips_read_watch_registers();
  10313. + local_irq_enable();
  10314. + force_sig(SIGTRAP, current);
  10315. + } else {
  10316. + mips_clear_watch_registers();
  10317. + local_irq_enable();
  10318. + }
  10319. +}
  10320. +
  10321. +asmlinkage void do_mcheck(struct pt_regs *regs)
  10322. +{
  10323. + const int field = 2 * sizeof(unsigned long);
  10324. + int multi_match = regs->cp0_status & ST0_TS;
  10325. +
  10326. + show_regs(regs);
  10327. +
  10328. + if (multi_match) {
  10329. + printk("Index : %0x\n", read_c0_index());
  10330. + printk("Pagemask: %0x\n", read_c0_pagemask());
  10331. + printk("EntryHi : %0*lx\n", field, read_c0_entryhi());
  10332. + printk("EntryLo0: %0*lx\n", field, read_c0_entrylo0());
  10333. + printk("EntryLo1: %0*lx\n", field, read_c0_entrylo1());
  10334. + printk("\n");
  10335. + dump_tlb_all();
  10336. + }
  10337. +
  10338. + show_code((unsigned int __user *) regs->cp0_epc);
  10339. +
  10340. + /*
  10341. + * Some chips may have other causes of machine check (e.g. SB1
  10342. + * graduation timer)
  10343. + */
  10344. + panic("Caught Machine Check exception - %scaused by multiple "
  10345. + "matching entries in the TLB.",
  10346. + (multi_match) ? "" : "not ");
  10347. +}
  10348. +
  10349. +asmlinkage void do_mt(struct pt_regs *regs)
  10350. +{
  10351. + int subcode;
  10352. +
  10353. + subcode = (read_vpe_c0_vpecontrol() & VPECONTROL_EXCPT)
  10354. + >> VPECONTROL_EXCPT_SHIFT;
  10355. + switch (subcode) {
  10356. + case 0:
  10357. + printk(KERN_DEBUG "Thread Underflow\n");
  10358. + break;
  10359. + case 1:
  10360. + printk(KERN_DEBUG "Thread Overflow\n");
  10361. + break;
  10362. + case 2:
  10363. + printk(KERN_DEBUG "Invalid YIELD Qualifier\n");
  10364. + break;
  10365. + case 3:
  10366. + printk(KERN_DEBUG "Gating Storage Exception\n");
  10367. + break;
  10368. + case 4:
  10369. + printk(KERN_DEBUG "YIELD Scheduler Exception\n");
  10370. + break;
  10371. + case 5:
  10372. + printk(KERN_DEBUG "Gating Storage Schedulier Exception\n");
  10373. + break;
  10374. + default:
  10375. + printk(KERN_DEBUG "*** UNKNOWN THREAD EXCEPTION %d ***\n",
  10376. + subcode);
  10377. + break;
  10378. + }
  10379. + die_if_kernel("MIPS MT Thread exception in kernel", regs);
  10380. +
  10381. + force_sig(SIGILL, current);
  10382. +}
  10383. +
  10384. +
  10385. +asmlinkage void do_dsp(struct pt_regs *regs)
  10386. +{
  10387. + if (cpu_has_dsp)
  10388. + panic("Unexpected DSP exception\n");
  10389. +
  10390. + force_sig(SIGILL, current);
  10391. +}
  10392. +
  10393. +asmlinkage void do_reserved(struct pt_regs *regs)
  10394. +{
  10395. + /*
  10396. + * Game over - no way to handle this if it ever occurs. Most probably
  10397. + * caused by a new unknown cpu type or after another deadly
  10398. + * hard/software error.
  10399. + */
  10400. + show_regs(regs);
  10401. + panic("Caught reserved exception %ld - should not happen.",
  10402. + (regs->cp0_cause & 0x7f) >> 2);
  10403. +}
  10404. +
  10405. +static int __initdata l1parity = 1;
  10406. +static int __init nol1parity(char *s)
  10407. +{
  10408. + l1parity = 0;
  10409. + return 1;
  10410. +}
  10411. +__setup("nol1par", nol1parity);
  10412. +static int __initdata l2parity = 1;
  10413. +static int __init nol2parity(char *s)
  10414. +{
  10415. + l2parity = 0;
  10416. + return 1;
  10417. +}
  10418. +__setup("nol2par", nol2parity);
  10419. +
  10420. +/*
  10421. + * Some MIPS CPUs can enable/disable for cache parity detection, but do
  10422. + * it different ways.
  10423. + */
  10424. +static inline void parity_protection_init(void)
  10425. +{
  10426. + switch (current_cpu_type()) {
  10427. + case CPU_24K:
  10428. + case CPU_34K:
  10429. + case CPU_74K:
  10430. + case CPU_1004K:
  10431. + {
  10432. +#define ERRCTL_PE 0x80000000
  10433. +#define ERRCTL_L2P 0x00800000
  10434. + unsigned long errctl;
  10435. + unsigned int l1parity_present, l2parity_present;
  10436. +
  10437. + errctl = read_c0_ecc();
  10438. + errctl &= ~(ERRCTL_PE|ERRCTL_L2P);
  10439. +
  10440. + /* probe L1 parity support */
  10441. + write_c0_ecc(errctl | ERRCTL_PE);
  10442. + back_to_back_c0_hazard();
  10443. + l1parity_present = (read_c0_ecc() & ERRCTL_PE);
  10444. +
  10445. + /* probe L2 parity support */
  10446. + write_c0_ecc(errctl|ERRCTL_L2P);
  10447. + back_to_back_c0_hazard();
  10448. + l2parity_present = (read_c0_ecc() & ERRCTL_L2P);
  10449. +
  10450. + if (l1parity_present && l2parity_present) {
  10451. + if (l1parity)
  10452. + errctl |= ERRCTL_PE;
  10453. + if (l1parity ^ l2parity)
  10454. + errctl |= ERRCTL_L2P;
  10455. + } else if (l1parity_present) {
  10456. + if (l1parity)
  10457. + errctl |= ERRCTL_PE;
  10458. + } else if (l2parity_present) {
  10459. + if (l2parity)
  10460. + errctl |= ERRCTL_L2P;
  10461. + } else {
  10462. + /* No parity available */
  10463. + }
  10464. +
  10465. + printk(KERN_INFO "Writing ErrCtl register=%08lx\n", errctl);
  10466. +
  10467. + write_c0_ecc(errctl);
  10468. + back_to_back_c0_hazard();
  10469. + errctl = read_c0_ecc();
  10470. + printk(KERN_INFO "Readback ErrCtl register=%08lx\n", errctl);
  10471. +
  10472. + if (l1parity_present)
  10473. + printk(KERN_INFO "Cache parity protection %sabled\n",
  10474. + (errctl & ERRCTL_PE) ? "en" : "dis");
  10475. +
  10476. + if (l2parity_present) {
  10477. + if (l1parity_present && l1parity)
  10478. + errctl ^= ERRCTL_L2P;
  10479. + printk(KERN_INFO "L2 cache parity protection %sabled\n",
  10480. + (errctl & ERRCTL_L2P) ? "en" : "dis");
  10481. + }
  10482. + }
  10483. + break;
  10484. +
  10485. + case CPU_5KC:
  10486. + write_c0_ecc(0x80000000);
  10487. + back_to_back_c0_hazard();
  10488. + /* Set the PE bit (bit 31) in the c0_errctl register. */
  10489. + printk(KERN_INFO "Cache parity protection %sabled\n",
  10490. + (read_c0_ecc() & 0x80000000) ? "en" : "dis");
  10491. + break;
  10492. + case CPU_20KC:
  10493. + case CPU_25KF:
  10494. + /* Clear the DE bit (bit 16) in the c0_status register. */
  10495. + printk(KERN_INFO "Enable cache parity protection for "
  10496. + "MIPS 20KC/25KF CPUs.\n");
  10497. + clear_c0_status(ST0_DE);
  10498. + break;
  10499. + default:
  10500. + break;
  10501. + }
  10502. +}
  10503. +
  10504. +asmlinkage void cache_parity_error(void)
  10505. +{
  10506. + const int field = 2 * sizeof(unsigned long);
  10507. + unsigned int reg_val;
  10508. +
  10509. + /* For the moment, report the problem and hang. */
  10510. + printk("Cache error exception:\n");
  10511. + printk("cp0_errorepc == %0*lx\n", field, read_c0_errorepc());
  10512. + reg_val = read_c0_cacheerr();
  10513. + printk("c0_cacheerr == %08x\n", reg_val);
  10514. +
  10515. + printk("Decoded c0_cacheerr: %s cache fault in %s reference.\n",
  10516. + reg_val & (1<<30) ? "secondary" : "primary",
  10517. + reg_val & (1<<31) ? "data" : "insn");
  10518. + printk("Error bits: %s%s%s%s%s%s%s\n",
  10519. + reg_val & (1<<29) ? "ED " : "",
  10520. + reg_val & (1<<28) ? "ET " : "",
  10521. + reg_val & (1<<26) ? "EE " : "",
  10522. + reg_val & (1<<25) ? "EB " : "",
  10523. + reg_val & (1<<24) ? "EI " : "",
  10524. + reg_val & (1<<23) ? "E1 " : "",
  10525. + reg_val & (1<<22) ? "E0 " : "");
  10526. + printk("IDX: 0x%08x\n", reg_val & ((1<<22)-1));
  10527. +
  10528. +#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
  10529. + if (reg_val & (1<<22))
  10530. + printk("DErrAddr0: 0x%0*lx\n", field, read_c0_derraddr0());
  10531. +
  10532. + if (reg_val & (1<<23))
  10533. + printk("DErrAddr1: 0x%0*lx\n", field, read_c0_derraddr1());
  10534. +#endif
  10535. +
  10536. + panic("Can't handle the cache error!");
  10537. +}
  10538. +
  10539. +/*
  10540. + * SDBBP EJTAG debug exception handler.
  10541. + * We skip the instruction and return to the next instruction.
  10542. + */
  10543. +void ejtag_exception_handler(struct pt_regs *regs)
  10544. +{
  10545. + const int field = 2 * sizeof(unsigned long);
  10546. + unsigned long depc, old_epc;
  10547. + unsigned int debug;
  10548. +
  10549. + printk(KERN_DEBUG "SDBBP EJTAG debug exception - not handled yet, just ignored!\n");
  10550. + depc = read_c0_depc();
  10551. + debug = read_c0_debug();
  10552. + printk(KERN_DEBUG "c0_depc = %0*lx, DEBUG = %08x\n", field, depc, debug);
  10553. + if (debug & 0x80000000) {
  10554. + /*
  10555. + * In branch delay slot.
  10556. + * We cheat a little bit here and use EPC to calculate the
  10557. + * debug return address (DEPC). EPC is restored after the
  10558. + * calculation.
  10559. + */
  10560. + old_epc = regs->cp0_epc;
  10561. + regs->cp0_epc = depc;
  10562. + __compute_return_epc(regs);
  10563. + depc = regs->cp0_epc;
  10564. + regs->cp0_epc = old_epc;
  10565. + } else
  10566. + depc += 4;
  10567. + write_c0_depc(depc);
  10568. +
  10569. +#if 0
  10570. + printk(KERN_DEBUG "\n\n----- Enable EJTAG single stepping ----\n\n");
  10571. + write_c0_debug(debug | 0x100);
  10572. +#endif
  10573. +}
  10574. +
  10575. +/*
  10576. + * NMI exception handler.
  10577. + */
  10578. +NORET_TYPE void ATTRIB_NORET nmi_exception_handler(struct pt_regs *regs)
  10579. +{
  10580. + bust_spinlocks(1);
  10581. + printk("NMI taken!!!!\n");
  10582. + die("NMI", regs);
  10583. +}
  10584. +
  10585. +#define VECTORSPACING 0x100 /* for EI/VI mode */
  10586. +
  10587. +unsigned long ebase;
  10588. +unsigned long exception_handlers[32];
  10589. +unsigned long vi_handlers[64];
  10590. +
  10591. +void __init *set_except_vector(int n, void *addr)
  10592. +{
  10593. + unsigned long handler = (unsigned long) addr;
  10594. + unsigned long old_handler = exception_handlers[n];
  10595. +
  10596. + exception_handlers[n] = handler;
  10597. + if (n == 0 && cpu_has_divec) {
  10598. + unsigned long jump_mask = ~((1 << 28) - 1);
  10599. + u32 *buf = (u32 *)(ebase + 0x200);
  10600. + unsigned int k0 = 26;
  10601. + if ((handler & jump_mask) == ((ebase + 0x200) & jump_mask)) {
  10602. + uasm_i_j(&buf, handler & ~jump_mask);
  10603. + uasm_i_nop(&buf);
  10604. + } else {
  10605. + UASM_i_LA(&buf, k0, handler);
  10606. + uasm_i_jr(&buf, k0);
  10607. + uasm_i_nop(&buf);
  10608. + }
  10609. + local_flush_icache_range(ebase + 0x200, (unsigned long)buf);
  10610. + }
  10611. + return (void *)old_handler;
  10612. +}
  10613. +
  10614. +static asmlinkage void do_default_vi(void)
  10615. +{
  10616. + show_regs(get_irq_regs());
  10617. + panic("Caught unexpected vectored interrupt.");
  10618. +}
  10619. +
  10620. +static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs)
  10621. +{
  10622. + unsigned long handler;
  10623. + unsigned long old_handler = vi_handlers[n];
  10624. + int srssets = current_cpu_data.srsets;
  10625. + u32 *w;
  10626. + unsigned char *b;
  10627. +
  10628. + BUG_ON(!cpu_has_veic && !cpu_has_vint);
  10629. +
  10630. + if (addr == NULL) {
  10631. + handler = (unsigned long) do_default_vi;
  10632. + srs = 0;
  10633. + } else
  10634. + handler = (unsigned long) addr;
  10635. + vi_handlers[n] = (unsigned long) addr;
  10636. +
  10637. + b = (unsigned char *)(ebase + 0x200 + n*VECTORSPACING);
  10638. +
  10639. + if (srs >= srssets)
  10640. + panic("Shadow register set %d not supported", srs);
  10641. +
  10642. + if (cpu_has_veic) {
  10643. + if (board_bind_eic_interrupt)
  10644. + board_bind_eic_interrupt(n, srs);
  10645. + } else if (cpu_has_vint) {
  10646. + /* SRSMap is only defined if shadow sets are implemented */
  10647. + if (srssets > 1)
  10648. + change_c0_srsmap(0xf << n*4, srs << n*4);
  10649. + }
  10650. +
  10651. + if (srs == 0) {
  10652. + /*
  10653. + * If no shadow set is selected then use the default handler
  10654. + * that does normal register saving and a standard interrupt exit
  10655. + */
  10656. +
  10657. + extern char except_vec_vi, except_vec_vi_lui;
  10658. + extern char except_vec_vi_ori, except_vec_vi_end;
  10659. + extern char rollback_except_vec_vi;
  10660. + char *vec_start = (cpu_wait == r4k_wait) ?
  10661. + &rollback_except_vec_vi : &except_vec_vi;
  10662. +#ifdef CONFIG_MIPS_MT_SMTC
  10663. + /*
  10664. + * We need to provide the SMTC vectored interrupt handler
  10665. + * not only with the address of the handler, but with the
  10666. + * Status.IM bit to be masked before going there.
  10667. + */
  10668. + extern char except_vec_vi_mori;
  10669. + const int mori_offset = &except_vec_vi_mori - vec_start;
  10670. +#endif /* CONFIG_MIPS_MT_SMTC */
  10671. + const int handler_len = &except_vec_vi_end - vec_start;
  10672. + const int lui_offset = &except_vec_vi_lui - vec_start;
  10673. + const int ori_offset = &except_vec_vi_ori - vec_start;
  10674. +
  10675. + if (handler_len > VECTORSPACING) {
  10676. + /*
  10677. + * Sigh... panicing won't help as the console
  10678. + * is probably not configured :(
  10679. + */
  10680. + panic("VECTORSPACING too small");
  10681. + }
  10682. +
  10683. + memcpy(b, vec_start, handler_len);
  10684. +#ifdef CONFIG_MIPS_MT_SMTC
  10685. + BUG_ON(n > 7); /* Vector index %d exceeds SMTC maximum. */
  10686. +
  10687. + w = (u32 *)(b + mori_offset);
  10688. + *w = (*w & 0xffff0000) | (0x100 << n);
  10689. +#endif /* CONFIG_MIPS_MT_SMTC */
  10690. + w = (u32 *)(b + lui_offset);
  10691. + *w = (*w & 0xffff0000) | (((u32)handler >> 16) & 0xffff);
  10692. + w = (u32 *)(b + ori_offset);
  10693. + *w = (*w & 0xffff0000) | ((u32)handler & 0xffff);
  10694. + local_flush_icache_range((unsigned long)b,
  10695. + (unsigned long)(b+handler_len));
  10696. + }
  10697. + else {
  10698. + /*
  10699. + * In other cases jump directly to the interrupt handler
  10700. + *
  10701. + * It is the handlers responsibility to save registers if required
  10702. + * (eg hi/lo) and return from the exception using "eret"
  10703. + */
  10704. + w = (u32 *)b;
  10705. + *w++ = 0x08000000 | (((u32)handler >> 2) & 0x03fffff); /* j handler */
  10706. + *w = 0;
  10707. + local_flush_icache_range((unsigned long)b,
  10708. + (unsigned long)(b+8));
  10709. + }
  10710. +
  10711. + return (void *)old_handler;
  10712. +}
  10713. +
  10714. +void *set_vi_handler(int n, vi_handler_t addr)
  10715. +{
  10716. + return set_vi_srs_handler(n, addr, 0);
  10717. +}
  10718. +
  10719. +extern void cpu_cache_init(void);
  10720. +extern void tlb_init(void);
  10721. +extern void flush_tlb_handlers(void);
  10722. +
  10723. +/*
  10724. + * Timer interrupt
  10725. + */
  10726. +int cp0_compare_irq;
  10727. +int cp0_compare_irq_shift;
  10728. +
  10729. +/*
  10730. + * Performance counter IRQ or -1 if shared with timer
  10731. + */
  10732. +int cp0_perfcount_irq;
  10733. +EXPORT_SYMBOL_GPL(cp0_perfcount_irq);
  10734. +
  10735. +static int __cpuinitdata noulri;
  10736. +
  10737. +static int __init ulri_disable(char *s)
  10738. +{
  10739. + pr_info("Disabling ulri\n");
  10740. + noulri = 1;
  10741. +
  10742. + return 1;
  10743. +}
  10744. +__setup("noulri", ulri_disable);
  10745. +
  10746. +void __cpuinit per_cpu_trap_init(void)
  10747. +{
  10748. + unsigned int cpu = smp_processor_id();
  10749. + unsigned int status_set = ST0_CU0;
  10750. +#ifdef CONFIG_MIPS_MT_SMTC
  10751. + int secondaryTC = 0;
  10752. + int bootTC = (cpu == 0);
  10753. +
  10754. + /*
  10755. + * Only do per_cpu_trap_init() for first TC of Each VPE.
  10756. + * Note that this hack assumes that the SMTC init code
  10757. + * assigns TCs consecutively and in ascending order.
  10758. + */
  10759. +
  10760. + if (((read_c0_tcbind() & TCBIND_CURTC) != 0) &&
  10761. + ((read_c0_tcbind() & TCBIND_CURVPE) == cpu_data[cpu - 1].vpe_id))
  10762. + secondaryTC = 1;
  10763. +#endif /* CONFIG_MIPS_MT_SMTC */
  10764. +
  10765. + /*
  10766. + * Disable coprocessors and select 32-bit or 64-bit addressing
  10767. + * and the 16/32 or 32/32 FPR register model. Reset the BEV
  10768. + * flag that some firmware may have left set and the TS bit (for
  10769. + * IP27). Set XX for ISA IV code to work.
  10770. + */
  10771. +#ifdef CONFIG_64BIT
  10772. + status_set |= ST0_FR|ST0_KX|ST0_SX|ST0_UX;
  10773. +#endif
  10774. + if (current_cpu_data.isa_level == MIPS_CPU_ISA_IV)
  10775. + status_set |= ST0_XX;
  10776. + if (cpu_has_dsp)
  10777. + status_set |= ST0_MX;
  10778. +
  10779. + change_c0_status(ST0_CU|ST0_MX|ST0_RE|ST0_FR|ST0_BEV|ST0_TS|ST0_KX|ST0_SX|ST0_UX,
  10780. + status_set);
  10781. +
  10782. + if (cpu_has_mips_r2) {
  10783. + unsigned int enable = 0x0000000f | cpu_hwrena_impl_bits;
  10784. +
  10785. + if (!noulri && cpu_has_userlocal)
  10786. + enable |= (1 << 29);
  10787. +
  10788. + write_c0_hwrena(enable);
  10789. + }
  10790. +
  10791. +#ifdef CONFIG_MIPS_MT_SMTC
  10792. + if (!secondaryTC) {
  10793. +#endif /* CONFIG_MIPS_MT_SMTC */
  10794. +
  10795. + if (cpu_has_veic || cpu_has_vint) {
  10796. + unsigned long sr = set_c0_status(ST0_BEV);
  10797. + write_c0_ebase(ebase);
  10798. + write_c0_status(sr);
  10799. + /* Setting vector spacing enables EI/VI mode */
  10800. + change_c0_intctl(0x3e0, VECTORSPACING);
  10801. + }
  10802. + if (cpu_has_divec) {
  10803. + if (cpu_has_mipsmt) {
  10804. + unsigned int vpflags = dvpe();
  10805. + set_c0_cause(CAUSEF_IV);
  10806. + evpe(vpflags);
  10807. + } else
  10808. + set_c0_cause(CAUSEF_IV);
  10809. + }
  10810. +
  10811. + /*
  10812. + * Before R2 both interrupt numbers were fixed to 7, so on R2 only:
  10813. + *
  10814. + * o read IntCtl.IPTI to determine the timer interrupt
  10815. + * o read IntCtl.IPPCI to determine the performance counter interrupt
  10816. + */
  10817. + if (cpu_has_mips_r2) {
  10818. + cp0_compare_irq_shift = CAUSEB_TI - CAUSEB_IP;
  10819. + cp0_compare_irq = (read_c0_intctl() >> INTCTLB_IPTI) & 7;
  10820. + cp0_perfcount_irq = (read_c0_intctl() >> INTCTLB_IPPCI) & 7;
  10821. + if (cp0_perfcount_irq == cp0_compare_irq)
  10822. + cp0_perfcount_irq = -1;
  10823. + } else {
  10824. + cp0_compare_irq = CP0_LEGACY_COMPARE_IRQ;
  10825. + cp0_compare_irq_shift = cp0_compare_irq;
  10826. + cp0_perfcount_irq = -1;
  10827. + }
  10828. +
  10829. +#ifdef CONFIG_MIPS_MT_SMTC
  10830. + }
  10831. +#endif /* CONFIG_MIPS_MT_SMTC */
  10832. +
  10833. + cpu_data[cpu].asid_cache = ASID_FIRST_VERSION;
  10834. + TLBMISS_HANDLER_SETUP();
  10835. +
  10836. + atomic_inc(&init_mm.mm_count);
  10837. + current->active_mm = &init_mm;
  10838. + BUG_ON(current->mm);
  10839. + enter_lazy_tlb(&init_mm, current);
  10840. +
  10841. +#ifdef CONFIG_MIPS_MT_SMTC
  10842. + if (bootTC) {
  10843. +#endif /* CONFIG_MIPS_MT_SMTC */
  10844. + cpu_cache_init();
  10845. + tlb_init();
  10846. +#ifdef CONFIG_MIPS_MT_SMTC
  10847. + } else if (!secondaryTC) {
  10848. + /*
  10849. + * First TC in non-boot VPE must do subset of tlb_init()
  10850. + * for MMU countrol registers.
  10851. + */
  10852. + write_c0_pagemask(PM_DEFAULT_MASK);
  10853. + write_c0_wired(0);
  10854. + }
  10855. +#endif /* CONFIG_MIPS_MT_SMTC */
  10856. +}
  10857. +
  10858. +/* Install CPU exception handler */
  10859. +void __init set_handler(unsigned long offset, void *addr, unsigned long size)
  10860. +{
  10861. + memcpy((void *)(ebase + offset), addr, size);
  10862. + local_flush_icache_range(ebase + offset, ebase + offset + size);
  10863. +}
  10864. +
  10865. +static char panic_null_cerr[] __cpuinitdata =
  10866. + "Trying to set NULL cache error exception handler";
  10867. +
  10868. +/*
  10869. + * Install uncached CPU exception handler.
  10870. + * This is suitable only for the cache error exception which is the only
  10871. + * exception handler that is being run uncached.
  10872. + */
  10873. +void __cpuinit set_uncached_handler(unsigned long offset, void *addr,
  10874. + unsigned long size)
  10875. +{
  10876. + unsigned long uncached_ebase = CKSEG1ADDR(ebase);
  10877. +
  10878. + if (!addr)
  10879. + panic(panic_null_cerr);
  10880. +
  10881. + memcpy((void *)(uncached_ebase + offset), addr, size);
  10882. +}
  10883. +
  10884. +static int __initdata rdhwr_noopt;
  10885. +static int __init set_rdhwr_noopt(char *str)
  10886. +{
  10887. + rdhwr_noopt = 1;
  10888. + return 1;
  10889. +}
  10890. +
  10891. +__setup("rdhwr_noopt", set_rdhwr_noopt);
  10892. +
  10893. +void __init trap_init(void)
  10894. +{
  10895. + extern char except_vec3_generic, except_vec3_r4000;
  10896. + extern char except_vec4;
  10897. + unsigned long i;
  10898. + int rollback;
  10899. +
  10900. + check_wait();
  10901. + rollback = (cpu_wait == r4k_wait);
  10902. +
  10903. +#if defined(CONFIG_KGDB)
  10904. + if (kgdb_early_setup)
  10905. + return; /* Already done */
  10906. +#endif
  10907. +
  10908. + if (cpu_has_veic || cpu_has_vint) {
  10909. + unsigned long size = 0x200 + VECTORSPACING*64;
  10910. + ebase = (unsigned long)
  10911. + __alloc_bootmem(size, 1 << fls(size), 0);
  10912. + } else {
  10913. + ebase = CKSEG0;
  10914. + if (cpu_has_mips_r2)
  10915. + ebase += (read_c0_ebase() & 0x3ffff000);
  10916. + }
  10917. +
  10918. + per_cpu_trap_init();
  10919. +
  10920. + /*
  10921. + * Copy the generic exception handlers to their final destination.
  10922. + * This will be overriden later as suitable for a particular
  10923. + * configuration.
  10924. + */
  10925. + set_handler(0x180, &except_vec3_generic, 0x80);
  10926. +
  10927. + /*
  10928. + * Setup default vectors
  10929. + */
  10930. + for (i = 0; i <= 31; i++)
  10931. + set_except_vector(i, handle_reserved);
  10932. +
  10933. + /*
  10934. + * Copy the EJTAG debug exception vector handler code to it's final
  10935. + * destination.
  10936. + */
  10937. + if (cpu_has_ejtag && board_ejtag_handler_setup)
  10938. + board_ejtag_handler_setup();
  10939. +
  10940. + /*
  10941. + * Only some CPUs have the watch exceptions.
  10942. + */
  10943. + if (cpu_has_watch)
  10944. + set_except_vector(23, handle_watch);
  10945. +
  10946. + /*
  10947. + * Initialise interrupt handlers
  10948. + */
  10949. + if (cpu_has_veic || cpu_has_vint) {
  10950. + int nvec = cpu_has_veic ? 64 : 8;
  10951. + for (i = 0; i < nvec; i++)
  10952. + set_vi_handler(i, NULL);
  10953. + }
  10954. + else if (cpu_has_divec)
  10955. + set_handler(0x200, &except_vec4, 0x8);
  10956. +
  10957. + /*
  10958. + * Some CPUs can enable/disable for cache parity detection, but does
  10959. + * it different ways.
  10960. + */
  10961. + parity_protection_init();
  10962. +
  10963. + /*
  10964. + * The Data Bus Errors / Instruction Bus Errors are signaled
  10965. + * by external hardware. Therefore these two exceptions
  10966. + * may have board specific handlers.
  10967. + */
  10968. + if (board_be_init)
  10969. + board_be_init();
  10970. +
  10971. + set_except_vector(0, rollback ? rollback_handle_int : handle_int);
  10972. + set_except_vector(1, handle_tlbm);
  10973. + set_except_vector(2, handle_tlbl);
  10974. + set_except_vector(3, handle_tlbs);
  10975. +
  10976. + set_except_vector(4, handle_adel);
  10977. + set_except_vector(5, handle_ades);
  10978. +
  10979. + set_except_vector(6, handle_ibe);
  10980. + set_except_vector(7, handle_dbe);
  10981. +
  10982. + set_except_vector(8, handle_sys);
  10983. + set_except_vector(9, handle_bp);
  10984. + set_except_vector(10, rdhwr_noopt ? handle_ri :
  10985. + (cpu_has_vtag_icache ?
  10986. + handle_ri_rdhwr_vivt : handle_ri_rdhwr));
  10987. + set_except_vector(11, handle_cpu);
  10988. + set_except_vector(12, handle_ov);
  10989. + set_except_vector(13, handle_tr);
  10990. +
  10991. + if (current_cpu_type() == CPU_R6000 ||
  10992. + current_cpu_type() == CPU_R6000A) {
  10993. + /*
  10994. + * The R6000 is the only R-series CPU that features a machine
  10995. + * check exception (similar to the R4000 cache error) and
  10996. + * unaligned ldc1/sdc1 exception. The handlers have not been
  10997. + * written yet. Well, anyway there is no R6000 machine on the
  10998. + * current list of targets for Linux/MIPS.
  10999. + * (Duh, crap, there is someone with a triple R6k machine)
  11000. + */
  11001. + //set_except_vector(14, handle_mc);
  11002. + //set_except_vector(15, handle_ndc);
  11003. + }
  11004. +
  11005. +
  11006. + if (board_nmi_handler_setup)
  11007. + board_nmi_handler_setup();
  11008. +
  11009. + if (cpu_has_fpu && !cpu_has_nofpuex)
  11010. + set_except_vector(15, handle_fpe);
  11011. +
  11012. + set_except_vector(22, handle_mdmx);
  11013. +
  11014. + if (cpu_has_mcheck)
  11015. + set_except_vector(24, handle_mcheck);
  11016. +
  11017. + if (cpu_has_mipsmt)
  11018. + set_except_vector(25, handle_mt);
  11019. +
  11020. + set_except_vector(26, handle_dsp);
  11021. +
  11022. + if (cpu_has_vce)
  11023. + /* Special exception: R4[04]00 uses also the divec space. */
  11024. + memcpy((void *)(ebase + 0x180), &except_vec3_r4000, 0x100);
  11025. + else if (cpu_has_4kex)
  11026. + memcpy((void *)(ebase + 0x180), &except_vec3_generic, 0x80);
  11027. + else
  11028. + memcpy((void *)(ebase + 0x080), &except_vec3_generic, 0x80);
  11029. +
  11030. + local_flush_icache_range(ebase, ebase + 0x400);
  11031. + flush_tlb_handlers();
  11032. +
  11033. + sort_extable(__start___dbe_table, __stop___dbe_table);
  11034. +
  11035. + register_cu2_notifier(&default_cu2_notifier);
  11036. +}
  11037. diff -Nur linux-2.6.35.7.orig/arch/mips/Makefile linux-2.6.35.7/arch/mips/Makefile
  11038. --- linux-2.6.35.7.orig/arch/mips/Makefile 2010-09-29 03:09:08.000000000 +0200
  11039. +++ linux-2.6.35.7/arch/mips/Makefile 2010-10-14 20:27:59.685601082 +0200
  11040. @@ -179,6 +179,13 @@
  11041. cflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -Wa,-march=octeon
  11042. endif
  11043. +#
  11044. +# Atheros AR71xx
  11045. +#
  11046. +core-$(CONFIG_ATHEROS_AR71XX) += arch/mips/ar71xx/
  11047. +cflags-$(CONFIG_ATHEROS_AR71XX) += -I$(srctree)/arch/mips/include/asm/mach-ar71xx
  11048. +load-$(CONFIG_ATHEROS_AR71XX) += 0xffffffff80060000
  11049. +
  11050. cflags-$(CONFIG_CPU_R4000_WORKAROUNDS) += $(call cc-option,-mfix-r4000,)
  11051. cflags-$(CONFIG_CPU_R4400_WORKAROUNDS) += $(call cc-option,-mfix-r4400,)
  11052. cflags-$(CONFIG_CPU_DADDI_WORKAROUNDS) += $(call cc-option,-mno-daddi,)
  11053. diff -Nur linux-2.6.35.7.orig/arch/mips/pci/Makefile linux-2.6.35.7/arch/mips/pci/Makefile
  11054. --- linux-2.6.35.7.orig/arch/mips/pci/Makefile 2010-09-29 03:09:08.000000000 +0200
  11055. +++ linux-2.6.35.7/arch/mips/pci/Makefile 2010-10-14 20:27:59.718092160 +0200
  11056. @@ -18,6 +18,7 @@
  11057. obj-$(CONFIG_BCM47XX) += pci-bcm47xx.o
  11058. obj-$(CONFIG_BCM63XX) += pci-bcm63xx.o fixup-bcm63xx.o \
  11059. ops-bcm63xx.o
  11060. +obj-$(CONFIG_ATHEROS_AR71XX) += pci-ar71xx.o pci-ar724x.o
  11061. #
  11062. # These are still pretty much in the old state, watch, go blind.
  11063. diff -Nur linux-2.6.35.7.orig/arch/mips/pci/pci-ar71xx.c linux-2.6.35.7/arch/mips/pci/pci-ar71xx.c
  11064. --- linux-2.6.35.7.orig/arch/mips/pci/pci-ar71xx.c 1970-01-01 01:00:00.000000000 +0100
  11065. +++ linux-2.6.35.7/arch/mips/pci/pci-ar71xx.c 2010-10-14 20:27:59.758101117 +0200
  11066. @@ -0,0 +1,409 @@
  11067. +/*
  11068. + * Atheros AR71xx PCI host controller driver
  11069. + *
  11070. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  11071. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  11072. + *
  11073. + * Parts of this file are based on Atheros' 2.6.15 BSP
  11074. + *
  11075. + * This program is free software; you can redistribute it and/or modify it
  11076. + * under the terms of the GNU General Public License version 2 as published
  11077. + * by the Free Software Foundation.
  11078. + */
  11079. +
  11080. +#include <linux/resource.h>
  11081. +#include <linux/types.h>
  11082. +#include <linux/delay.h>
  11083. +#include <linux/bitops.h>
  11084. +#include <linux/pci.h>
  11085. +#include <linux/pci_regs.h>
  11086. +#include <linux/interrupt.h>
  11087. +
  11088. +#include <asm/mach-ar71xx/ar71xx.h>
  11089. +#include <asm/mach-ar71xx/pci.h>
  11090. +
  11091. +#undef DEBUG
  11092. +#ifdef DEBUG
  11093. +#define DBG(fmt, args...) printk(KERN_DEBUG fmt, ## args)
  11094. +#else
  11095. +#define DBG(fmt, args...)
  11096. +#endif
  11097. +
  11098. +#define AR71XX_PCI_DELAY 100 /* msecs */
  11099. +
  11100. +#if 0
  11101. +#define PCI_IDSEL_BASE PCI_IDSEL_ADL_START
  11102. +#else
  11103. +#define PCI_IDSEL_BASE 0
  11104. +#endif
  11105. +
  11106. +static void __iomem *ar71xx_pcicfg_base;
  11107. +static DEFINE_SPINLOCK(ar71xx_pci_lock);
  11108. +static int ar71xx_pci_fixup_enable;
  11109. +
  11110. +static inline void ar71xx_pci_delay(void)
  11111. +{
  11112. + mdelay(AR71XX_PCI_DELAY);
  11113. +}
  11114. +
  11115. +/* Byte lane enable bits */
  11116. +static u8 ble_table[4][4] = {
  11117. + {0x0, 0xf, 0xf, 0xf},
  11118. + {0xe, 0xd, 0xb, 0x7},
  11119. + {0xc, 0xf, 0x3, 0xf},
  11120. + {0xf, 0xf, 0xf, 0xf},
  11121. +};
  11122. +
  11123. +static inline u32 ar71xx_pci_get_ble(int where, int size, int local)
  11124. +{
  11125. + u32 t;
  11126. +
  11127. + t = ble_table[size & 3][where & 3];
  11128. + BUG_ON(t == 0xf);
  11129. + t <<= (local) ? 20 : 4;
  11130. + return t;
  11131. +}
  11132. +
  11133. +static inline u32 ar71xx_pci_bus_addr(struct pci_bus *bus, unsigned int devfn,
  11134. + int where)
  11135. +{
  11136. + u32 ret;
  11137. +
  11138. + if (!bus->number) {
  11139. + /* type 0 */
  11140. + ret = (1 << (PCI_IDSEL_BASE + PCI_SLOT(devfn)))
  11141. + | (PCI_FUNC(devfn) << 8) | (where & ~3);
  11142. + } else {
  11143. + /* type 1 */
  11144. + ret = (bus->number << 16) | (PCI_SLOT(devfn) << 11)
  11145. + | (PCI_FUNC(devfn) << 8) | (where & ~3) | 1;
  11146. + }
  11147. +
  11148. + return ret;
  11149. +}
  11150. +
  11151. +int ar71xx_pci_be_handler(int is_fixup)
  11152. +{
  11153. + void __iomem *base = ar71xx_pcicfg_base;
  11154. + u32 pci_err;
  11155. + u32 ahb_err;
  11156. +
  11157. + pci_err = __raw_readl(base + PCI_REG_PCI_ERR) & 3;
  11158. + if (pci_err) {
  11159. + if (!is_fixup)
  11160. + printk(KERN_ALERT "PCI error %d at PCI addr 0x%x\n",
  11161. + pci_err,
  11162. + __raw_readl(base + PCI_REG_PCI_ERR_ADDR));
  11163. +
  11164. + __raw_writel(pci_err, base + PCI_REG_PCI_ERR);
  11165. + }
  11166. +
  11167. + ahb_err = __raw_readl(base + PCI_REG_AHB_ERR) & 1;
  11168. + if (ahb_err) {
  11169. + if (!is_fixup)
  11170. + printk(KERN_ALERT "AHB error at AHB address 0x%x\n",
  11171. + __raw_readl(base + PCI_REG_AHB_ERR_ADDR));
  11172. +
  11173. + __raw_writel(ahb_err, base + PCI_REG_AHB_ERR);
  11174. + }
  11175. +
  11176. + return ((ahb_err | pci_err) ? 1 : 0);
  11177. +}
  11178. +
  11179. +static inline int ar71xx_pci_set_cfgaddr(struct pci_bus *bus,
  11180. + unsigned int devfn, int where, int size, u32 cmd)
  11181. +{
  11182. + void __iomem *base = ar71xx_pcicfg_base;
  11183. + u32 addr;
  11184. +
  11185. + addr = ar71xx_pci_bus_addr(bus, devfn, where);
  11186. +
  11187. + DBG("PCI: set cfgaddr: %02x:%02x.%01x/%02x:%01d, addr=%08x\n",
  11188. + bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn),
  11189. + where, size, addr);
  11190. +
  11191. + __raw_writel(addr, base + PCI_REG_CFG_AD);
  11192. + __raw_writel(cmd | ar71xx_pci_get_ble(where, size, 0),
  11193. + base + PCI_REG_CFG_CBE);
  11194. +
  11195. + return ar71xx_pci_be_handler(1);
  11196. +}
  11197. +
  11198. +static int ar71xx_pci_read_config(struct pci_bus *bus, unsigned int devfn,
  11199. + int where, int size, u32 *value)
  11200. +{
  11201. + void __iomem *base = ar71xx_pcicfg_base;
  11202. + static u32 mask[8] = {0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0};
  11203. + unsigned long flags;
  11204. + u32 data;
  11205. + int ret;
  11206. +
  11207. + ret = PCIBIOS_SUCCESSFUL;
  11208. +
  11209. + DBG("PCI: read config: %02x:%02x.%01x/%02x:%01d\n", bus->number,
  11210. + PCI_SLOT(devfn), PCI_FUNC(devfn), where, size);
  11211. +
  11212. + spin_lock_irqsave(&ar71xx_pci_lock, flags);
  11213. +
  11214. + if (bus->number == 0 && devfn == 0) {
  11215. + u32 t;
  11216. +
  11217. + t = PCI_CRP_CMD_READ | (where & ~3);
  11218. +
  11219. + __raw_writel(t, base + PCI_REG_CRP_AD_CBE);
  11220. + data = __raw_readl(base + PCI_REG_CRP_RDDATA);
  11221. +
  11222. + DBG("PCI: rd local cfg, ad_cbe:%08x, data:%08x\n", t, data);
  11223. +
  11224. + } else {
  11225. + int err;
  11226. +
  11227. + err = ar71xx_pci_set_cfgaddr(bus, devfn, where, size,
  11228. + PCI_CFG_CMD_READ);
  11229. +
  11230. + if (err == 0) {
  11231. + data = __raw_readl(base + PCI_REG_CFG_RDDATA);
  11232. + } else {
  11233. + ret = PCIBIOS_DEVICE_NOT_FOUND;
  11234. + data = ~0;
  11235. + }
  11236. + }
  11237. +
  11238. + spin_unlock_irqrestore(&ar71xx_pci_lock, flags);
  11239. +
  11240. + DBG("PCI: read config: data=%08x raw=%08x\n",
  11241. + (data >> (8 * (where & 3))) & mask[size & 7], data);
  11242. +
  11243. + *value = (data >> (8 * (where & 3))) & mask[size & 7];
  11244. +
  11245. + return ret;
  11246. +}
  11247. +
  11248. +static int ar71xx_pci_write_config(struct pci_bus *bus, unsigned int devfn,
  11249. + int where, int size, u32 value)
  11250. +{
  11251. + void __iomem *base = ar71xx_pcicfg_base;
  11252. + unsigned long flags;
  11253. + int ret;
  11254. +
  11255. + DBG("PCI: write config: %02x:%02x.%01x/%02x:%01d value=%08x\n",
  11256. + bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn),
  11257. + where, size, value);
  11258. +
  11259. + value = value << (8 * (where & 3));
  11260. + ret = PCIBIOS_SUCCESSFUL;
  11261. +
  11262. + spin_lock_irqsave(&ar71xx_pci_lock, flags);
  11263. + if (bus->number == 0 && devfn == 0) {
  11264. + u32 t;
  11265. +
  11266. + t = PCI_CRP_CMD_WRITE | (where & ~3);
  11267. + t |= ar71xx_pci_get_ble(where, size, 1);
  11268. +
  11269. + DBG("PCI: wr local cfg, ad_cbe:%08x, value:%08x\n", t, value);
  11270. +
  11271. + __raw_writel(t, base + PCI_REG_CRP_AD_CBE);
  11272. + __raw_writel(value, base + PCI_REG_CRP_WRDATA);
  11273. + } else {
  11274. + int err;
  11275. +
  11276. + err = ar71xx_pci_set_cfgaddr(bus, devfn, where, size,
  11277. + PCI_CFG_CMD_WRITE);
  11278. +
  11279. + if (err == 0)
  11280. + __raw_writel(value, base + PCI_REG_CFG_WRDATA);
  11281. + else
  11282. + ret = PCIBIOS_DEVICE_NOT_FOUND;
  11283. + }
  11284. + spin_unlock_irqrestore(&ar71xx_pci_lock, flags);
  11285. +
  11286. + return ret;
  11287. +}
  11288. +
  11289. +static void ar71xx_pci_fixup(struct pci_dev *dev)
  11290. +{
  11291. + u32 t;
  11292. +
  11293. + if (!ar71xx_pci_fixup_enable)
  11294. + return;
  11295. +
  11296. + if (dev->bus->number != 0 || dev->devfn != 0)
  11297. + return;
  11298. +
  11299. + DBG("PCI: fixup host controller %s (%04x:%04x)\n", pci_name(dev),
  11300. + dev->vendor, dev->device);
  11301. +
  11302. + /* setup COMMAND register */
  11303. + t = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE
  11304. + | PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_FAST_BACK;
  11305. +
  11306. + pci_write_config_word(dev, PCI_COMMAND, t);
  11307. +}
  11308. +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ar71xx_pci_fixup);
  11309. +
  11310. +int __init ar71xx_pcibios_map_irq(const struct pci_dev *dev, uint8_t slot,
  11311. + uint8_t pin)
  11312. +{
  11313. + int irq = -1;
  11314. + int i;
  11315. +
  11316. + slot -= PCI_IDSEL_ADL_START - PCI_IDSEL_BASE;
  11317. +
  11318. + for (i = 0; i < ar71xx_pci_nr_irqs; i++) {
  11319. + struct ar71xx_pci_irq *entry;
  11320. +
  11321. + entry = &ar71xx_pci_irq_map[i];
  11322. + if (entry->slot == slot && entry->pin == pin) {
  11323. + irq = entry->irq;
  11324. + break;
  11325. + }
  11326. + }
  11327. +
  11328. + if (irq < 0) {
  11329. + printk(KERN_ALERT "PCI: no irq found for pin%u@%s\n",
  11330. + pin, pci_name((struct pci_dev *)dev));
  11331. + } else {
  11332. + printk(KERN_INFO "PCI: mapping irq %d to pin%u@%s\n",
  11333. + irq, pin, pci_name((struct pci_dev *)dev));
  11334. + }
  11335. +
  11336. + return irq;
  11337. +}
  11338. +
  11339. +static struct pci_ops ar71xx_pci_ops = {
  11340. + .read = ar71xx_pci_read_config,
  11341. + .write = ar71xx_pci_write_config,
  11342. +};
  11343. +
  11344. +static struct resource ar71xx_pci_io_resource = {
  11345. + .name = "PCI IO space",
  11346. + .start = 0,
  11347. + .end = 0,
  11348. + .flags = IORESOURCE_IO,
  11349. +};
  11350. +
  11351. +static struct resource ar71xx_pci_mem_resource = {
  11352. + .name = "PCI memory space",
  11353. + .start = AR71XX_PCI_MEM_BASE,
  11354. + .end = AR71XX_PCI_MEM_BASE + AR71XX_PCI_MEM_SIZE - 1,
  11355. + .flags = IORESOURCE_MEM
  11356. +};
  11357. +
  11358. +static struct pci_controller ar71xx_pci_controller = {
  11359. + .pci_ops = &ar71xx_pci_ops,
  11360. + .mem_resource = &ar71xx_pci_mem_resource,
  11361. + .io_resource = &ar71xx_pci_io_resource,
  11362. +};
  11363. +
  11364. +static void ar71xx_pci_irq_handler(unsigned int irq, struct irq_desc *desc)
  11365. +{
  11366. + void __iomem *base = ar71xx_reset_base;
  11367. + u32 pending;
  11368. +
  11369. + pending = __raw_readl(base + AR71XX_RESET_REG_PCI_INT_STATUS) &
  11370. + __raw_readl(base + AR71XX_RESET_REG_PCI_INT_ENABLE);
  11371. +
  11372. + if (pending & PCI_INT_DEV0)
  11373. + generic_handle_irq(AR71XX_PCI_IRQ_DEV0);
  11374. +
  11375. + else if (pending & PCI_INT_DEV1)
  11376. + generic_handle_irq(AR71XX_PCI_IRQ_DEV1);
  11377. +
  11378. + else if (pending & PCI_INT_DEV2)
  11379. + generic_handle_irq(AR71XX_PCI_IRQ_DEV2);
  11380. +
  11381. + else if (pending & PCI_INT_CORE)
  11382. + generic_handle_irq(AR71XX_PCI_IRQ_CORE);
  11383. +
  11384. + else
  11385. + spurious_interrupt();
  11386. +}
  11387. +
  11388. +static void ar71xx_pci_irq_unmask(unsigned int irq)
  11389. +{
  11390. + void __iomem *base = ar71xx_reset_base;
  11391. + u32 t;
  11392. +
  11393. + irq -= AR71XX_PCI_IRQ_BASE;
  11394. +
  11395. + t = __raw_readl(base + AR71XX_RESET_REG_PCI_INT_ENABLE);
  11396. + __raw_writel(t | (1 << irq), base + AR71XX_RESET_REG_PCI_INT_ENABLE);
  11397. +
  11398. + /* flush write */
  11399. + (void) __raw_readl(base + AR71XX_RESET_REG_PCI_INT_ENABLE);
  11400. +}
  11401. +
  11402. +static void ar71xx_pci_irq_mask(unsigned int irq)
  11403. +{
  11404. + void __iomem *base = ar71xx_reset_base;
  11405. + u32 t;
  11406. +
  11407. + irq -= AR71XX_PCI_IRQ_BASE;
  11408. +
  11409. + t = __raw_readl(base + AR71XX_RESET_REG_PCI_INT_ENABLE);
  11410. + __raw_writel(t & ~(1 << irq), base + AR71XX_RESET_REG_PCI_INT_ENABLE);
  11411. +
  11412. + /* flush write */
  11413. + (void) __raw_readl(base + AR71XX_RESET_REG_PCI_INT_ENABLE);
  11414. +}
  11415. +
  11416. +static struct irq_chip ar71xx_pci_irq_chip = {
  11417. + .name = "AR71XX PCI ",
  11418. + .mask = ar71xx_pci_irq_mask,
  11419. + .unmask = ar71xx_pci_irq_unmask,
  11420. + .mask_ack = ar71xx_pci_irq_mask,
  11421. +};
  11422. +
  11423. +static void __init ar71xx_pci_irq_init(void)
  11424. +{
  11425. + void __iomem *base = ar71xx_reset_base;
  11426. + int i;
  11427. +
  11428. + __raw_writel(0, base + AR71XX_RESET_REG_PCI_INT_ENABLE);
  11429. + __raw_writel(0, base + AR71XX_RESET_REG_PCI_INT_STATUS);
  11430. +
  11431. + for (i = AR71XX_PCI_IRQ_BASE;
  11432. + i < AR71XX_PCI_IRQ_BASE + AR71XX_PCI_IRQ_COUNT; i++) {
  11433. + irq_desc[i].status = IRQ_DISABLED;
  11434. + set_irq_chip_and_handler(i, &ar71xx_pci_irq_chip,
  11435. + handle_level_irq);
  11436. + }
  11437. +
  11438. + set_irq_chained_handler(AR71XX_CPU_IRQ_IP2, ar71xx_pci_irq_handler);
  11439. +}
  11440. +
  11441. +int __init ar71xx_pcibios_init(void)
  11442. +{
  11443. + void __iomem *ddr_base = ar71xx_ddr_base;
  11444. +
  11445. + ar71xx_device_stop(RESET_MODULE_PCI_BUS | RESET_MODULE_PCI_CORE);
  11446. + ar71xx_pci_delay();
  11447. +
  11448. + ar71xx_device_start(RESET_MODULE_PCI_BUS | RESET_MODULE_PCI_CORE);
  11449. + ar71xx_pci_delay();
  11450. +
  11451. + ar71xx_pcicfg_base = ioremap_nocache(AR71XX_PCI_CFG_BASE,
  11452. + AR71XX_PCI_CFG_SIZE);
  11453. + if (ar71xx_pcicfg_base == NULL)
  11454. + return -ENOMEM;
  11455. +
  11456. + __raw_writel(PCI_WIN0_OFFS, ddr_base + AR71XX_DDR_REG_PCI_WIN0);
  11457. + __raw_writel(PCI_WIN1_OFFS, ddr_base + AR71XX_DDR_REG_PCI_WIN1);
  11458. + __raw_writel(PCI_WIN2_OFFS, ddr_base + AR71XX_DDR_REG_PCI_WIN2);
  11459. + __raw_writel(PCI_WIN3_OFFS, ddr_base + AR71XX_DDR_REG_PCI_WIN3);
  11460. + __raw_writel(PCI_WIN4_OFFS, ddr_base + AR71XX_DDR_REG_PCI_WIN4);
  11461. + __raw_writel(PCI_WIN5_OFFS, ddr_base + AR71XX_DDR_REG_PCI_WIN5);
  11462. + __raw_writel(PCI_WIN6_OFFS, ddr_base + AR71XX_DDR_REG_PCI_WIN6);
  11463. + __raw_writel(PCI_WIN7_OFFS, ddr_base + AR71XX_DDR_REG_PCI_WIN7);
  11464. +
  11465. + ar71xx_pci_delay();
  11466. +
  11467. + /* clear bus errors */
  11468. + (void)ar71xx_pci_be_handler(1);
  11469. +
  11470. + ar71xx_pci_fixup_enable = 1;
  11471. + ar71xx_pci_irq_init();
  11472. + register_pci_controller(&ar71xx_pci_controller);
  11473. +
  11474. + return 0;
  11475. +}
  11476. diff -Nur linux-2.6.35.7.orig/arch/mips/pci/pci-ar724x.c linux-2.6.35.7/arch/mips/pci/pci-ar724x.c
  11477. --- linux-2.6.35.7.orig/arch/mips/pci/pci-ar724x.c 1970-01-01 01:00:00.000000000 +0100
  11478. +++ linux-2.6.35.7/arch/mips/pci/pci-ar724x.c 2010-10-14 20:27:59.798101290 +0200
  11479. @@ -0,0 +1,395 @@
  11480. +/*
  11481. + * Atheros AR724x PCI host controller driver
  11482. + *
  11483. + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  11484. + *
  11485. + * Parts of this file are based on Atheros' 2.6.15 BSP
  11486. + *
  11487. + * This program is free software; you can redistribute it and/or modify it
  11488. + * under the terms of the GNU General Public License version 2 as published
  11489. + * by the Free Software Foundation.
  11490. + */
  11491. +
  11492. +#include <linux/resource.h>
  11493. +#include <linux/types.h>
  11494. +#include <linux/delay.h>
  11495. +#include <linux/bitops.h>
  11496. +#include <linux/pci.h>
  11497. +#include <linux/pci_regs.h>
  11498. +#include <linux/interrupt.h>
  11499. +
  11500. +#include <asm/mach-ar71xx/ar71xx.h>
  11501. +#include <asm/mach-ar71xx/pci.h>
  11502. +
  11503. +#undef DEBUG
  11504. +#ifdef DEBUG
  11505. +#define DBG(fmt, args...) printk(KERN_INFO fmt, ## args)
  11506. +#else
  11507. +#define DBG(fmt, args...)
  11508. +#endif
  11509. +
  11510. +static void __iomem *ar724x_pci_localcfg_base;
  11511. +static void __iomem *ar724x_pci_devcfg_base;
  11512. +static void __iomem *ar724x_pci_ctrl_base;
  11513. +static int ar724x_pci_fixup_enable;
  11514. +
  11515. +static DEFINE_SPINLOCK(ar724x_pci_lock);
  11516. +
  11517. +static void ar724x_pci_read(void __iomem *base, int where, int size, u32 *value)
  11518. +{
  11519. + unsigned long flags;
  11520. + u32 data;
  11521. +
  11522. + spin_lock_irqsave(&ar724x_pci_lock, flags);
  11523. + data = __raw_readl(base + (where & ~3));
  11524. +
  11525. + switch (size) {
  11526. + case 1:
  11527. + if (where & 1)
  11528. + data >>= 8;
  11529. + if (where & 2)
  11530. + data >>= 16;
  11531. + data &= 0xFF;
  11532. + break;
  11533. + case 2:
  11534. + if (where & 2)
  11535. + data >>= 16;
  11536. + data &= 0xFFFF;
  11537. + break;
  11538. + }
  11539. +
  11540. + *value = data;
  11541. + spin_unlock_irqrestore(&ar724x_pci_lock, flags);
  11542. +}
  11543. +
  11544. +static void ar724x_pci_write(void __iomem *base, int where, int size, u32 value)
  11545. +{
  11546. + unsigned long flags;
  11547. + u32 data;
  11548. + int s;
  11549. +
  11550. + spin_lock_irqsave(&ar724x_pci_lock, flags);
  11551. + data = __raw_readl(base + (where & ~3));
  11552. +
  11553. + switch (size) {
  11554. + case 1:
  11555. + s = ((where & 3) << 3);
  11556. + data &= ~(0xFF << s);
  11557. + data |= ((value & 0xFF) << s);
  11558. + break;
  11559. + case 2:
  11560. + s = ((where & 2) << 3);
  11561. + data &= ~(0xFFFF << s);
  11562. + data |= ((value & 0xFFFF) << s);
  11563. + break;
  11564. + case 4:
  11565. + data = value;
  11566. + break;
  11567. + }
  11568. +
  11569. + __raw_writel(data, base + (where & ~3));
  11570. + /* flush write */
  11571. + (void)__raw_readl(base + (where & ~3));
  11572. + spin_unlock_irqrestore(&ar724x_pci_lock, flags);
  11573. +}
  11574. +
  11575. +static int ar724x_pci_read_config(struct pci_bus *bus, unsigned int devfn,
  11576. + int where, int size, u32 *value)
  11577. +{
  11578. +
  11579. + if (bus->number != 0 || devfn != 0)
  11580. + return PCIBIOS_DEVICE_NOT_FOUND;
  11581. +
  11582. + ar724x_pci_read(ar724x_pci_devcfg_base, where, size, value);
  11583. +
  11584. + DBG("PCI: read config: %02x:%02x.%01x/%02x:%01d, value=%08x\n",
  11585. + bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn),
  11586. + where, size, *value);
  11587. +
  11588. + /*
  11589. + * WAR for BAR issue - We are unable to access the PCI device space
  11590. + * if we set the BAR with proper base address
  11591. + */
  11592. + if ((where == 0x10) && (size == 4)) {
  11593. + if (ar71xx_soc == AR71XX_SOC_AR7240)
  11594. + ar724x_pci_write(ar724x_pci_devcfg_base, where, size, 0xffff);
  11595. + else
  11596. + ar724x_pci_write(ar724x_pci_devcfg_base, where, size, 0x1000ffff);
  11597. + }
  11598. +
  11599. + return PCIBIOS_SUCCESSFUL;
  11600. +}
  11601. +
  11602. +static int ar724x_pci_write_config(struct pci_bus *bus, unsigned int devfn,
  11603. + int where, int size, u32 value)
  11604. +{
  11605. + if (bus->number != 0 || devfn != 0)
  11606. + return PCIBIOS_DEVICE_NOT_FOUND;
  11607. +
  11608. + DBG("PCI: write config: %02x:%02x.%01x/%02x:%01d, value=%08x\n",
  11609. + bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn),
  11610. + where, size, value);
  11611. +
  11612. + ar724x_pci_write(ar724x_pci_devcfg_base, where, size, value);
  11613. +
  11614. + return PCIBIOS_SUCCESSFUL;
  11615. +}
  11616. +
  11617. +static void ar724x_pci_fixup(struct pci_dev *dev)
  11618. +{
  11619. + u16 cmd;
  11620. +
  11621. + if (!ar724x_pci_fixup_enable)
  11622. + return;
  11623. +
  11624. + if (dev->bus->number != 0 || dev->devfn != 0)
  11625. + return;
  11626. +
  11627. + /* setup COMMAND register */
  11628. + pci_read_config_word(dev, PCI_COMMAND, &cmd);
  11629. + cmd |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
  11630. + PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY | PCI_COMMAND_SERR |
  11631. + PCI_COMMAND_FAST_BACK;
  11632. +
  11633. + pci_write_config_word(dev, PCI_COMMAND, cmd);
  11634. +}
  11635. +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ar724x_pci_fixup);
  11636. +
  11637. +int __init ar724x_pcibios_map_irq(const struct pci_dev *dev, uint8_t slot,
  11638. + uint8_t pin)
  11639. +{
  11640. + int irq = -1;
  11641. + int i;
  11642. +
  11643. + for (i = 0; i < ar71xx_pci_nr_irqs; i++) {
  11644. + struct ar71xx_pci_irq *entry;
  11645. + entry = &ar71xx_pci_irq_map[i];
  11646. +
  11647. + if (entry->slot == slot && entry->pin == pin) {
  11648. + irq = entry->irq;
  11649. + break;
  11650. + }
  11651. + }
  11652. +
  11653. + if (irq < 0)
  11654. + printk(KERN_ALERT "PCI: no irq found for pin%u@%s\n",
  11655. + pin, pci_name((struct pci_dev *)dev));
  11656. + else
  11657. + printk(KERN_INFO "PCI: mapping irq %d to pin%u@%s\n",
  11658. + irq, pin, pci_name((struct pci_dev *)dev));
  11659. +
  11660. + return irq;
  11661. +}
  11662. +
  11663. +static struct pci_ops ar724x_pci_ops = {
  11664. + .read = ar724x_pci_read_config,
  11665. + .write = ar724x_pci_write_config,
  11666. +};
  11667. +
  11668. +static struct resource ar724x_pci_io_resource = {
  11669. + .name = "PCI IO space",
  11670. + .start = 0,
  11671. + .end = 0,
  11672. + .flags = IORESOURCE_IO,
  11673. +};
  11674. +
  11675. +static struct resource ar724x_pci_mem_resource = {
  11676. + .name = "PCI memory space",
  11677. + .start = AR71XX_PCI_MEM_BASE,
  11678. + .end = AR71XX_PCI_MEM_BASE + AR71XX_PCI_MEM_SIZE - 1,
  11679. + .flags = IORESOURCE_MEM
  11680. +};
  11681. +
  11682. +static struct pci_controller ar724x_pci_controller = {
  11683. + .pci_ops = &ar724x_pci_ops,
  11684. + .mem_resource = &ar724x_pci_mem_resource,
  11685. + .io_resource = &ar724x_pci_io_resource,
  11686. +};
  11687. +
  11688. +static void __init ar724x_pci_reset(void)
  11689. +{
  11690. + ar71xx_device_stop(AR724X_RESET_PCIE);
  11691. + ar71xx_device_stop(AR724X_RESET_PCIE_PHY);
  11692. + ar71xx_device_stop(AR724X_RESET_PCIE_PHY_SERIAL);
  11693. + udelay(100);
  11694. +
  11695. + ar71xx_device_start(AR724X_RESET_PCIE_PHY_SERIAL);
  11696. + udelay(100);
  11697. + ar71xx_device_start(AR724X_RESET_PCIE_PHY);
  11698. + ar71xx_device_start(AR724X_RESET_PCIE);
  11699. +}
  11700. +
  11701. +static int __init ar724x_pci_setup(void)
  11702. +{
  11703. + void __iomem *base = ar724x_pci_ctrl_base;
  11704. + u32 t;
  11705. +
  11706. + /* setup COMMAND register */
  11707. + t = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE |
  11708. + PCI_COMMAND_PARITY|PCI_COMMAND_SERR|PCI_COMMAND_FAST_BACK;
  11709. +
  11710. + ar724x_pci_write(ar724x_pci_localcfg_base, PCI_COMMAND, 4, t);
  11711. + ar724x_pci_write(ar724x_pci_localcfg_base, 0x20, 4, 0x1ff01000);
  11712. + ar724x_pci_write(ar724x_pci_localcfg_base, 0x24, 4, 0x1ff01000);
  11713. +
  11714. + t = __raw_readl(base + AR724X_PCI_REG_RESET);
  11715. + if (t != 0x7) {
  11716. + udelay(100000);
  11717. + __raw_writel(0, base + AR724X_PCI_REG_RESET);
  11718. + udelay(100);
  11719. + __raw_writel(4, base + AR724X_PCI_REG_RESET);
  11720. + udelay(100000);
  11721. + }
  11722. +
  11723. + if (ar71xx_soc == AR71XX_SOC_AR7240)
  11724. + t = AR724X_PCI_APP_LTSSM_ENABLE;
  11725. + else
  11726. + t = 0x1ffc1;
  11727. + __raw_writel(t, base + AR724X_PCI_REG_APP);
  11728. + /* flush write */
  11729. + (void) __raw_readl(base + AR724X_PCI_REG_APP);
  11730. + udelay(1000);
  11731. +
  11732. + t = __raw_readl(base + AR724X_PCI_REG_RESET);
  11733. + if ((t & AR724X_PCI_RESET_LINK_UP) == 0x0) {
  11734. + printk(KERN_WARNING "PCI: no PCIe module found\n");
  11735. + return -ENODEV;
  11736. + }
  11737. +
  11738. + if (ar71xx_soc == AR71XX_SOC_AR7241 || ar71xx_soc == AR71XX_SOC_AR7242) {
  11739. + t = __raw_readl(base + AR724X_PCI_REG_APP);
  11740. + t |= BIT(16);
  11741. + __raw_writel(t, base + AR724X_PCI_REG_APP);
  11742. + }
  11743. +
  11744. + return 0;
  11745. +}
  11746. +
  11747. +static void ar724x_pci_irq_handler(unsigned int irq, struct irq_desc *desc)
  11748. +{
  11749. + void __iomem *base = ar724x_pci_ctrl_base;
  11750. + u32 pending;
  11751. +
  11752. + pending = __raw_readl(base + AR724X_PCI_REG_INT_STATUS) &
  11753. + __raw_readl(base + AR724X_PCI_REG_INT_MASK);
  11754. +
  11755. + if (pending & AR724X_PCI_INT_DEV0)
  11756. + generic_handle_irq(AR71XX_PCI_IRQ_DEV0);
  11757. +
  11758. + else
  11759. + spurious_interrupt();
  11760. +}
  11761. +
  11762. +static void ar724x_pci_irq_unmask(unsigned int irq)
  11763. +{
  11764. + void __iomem *base = ar724x_pci_ctrl_base;
  11765. + u32 t;
  11766. +
  11767. + switch (irq) {
  11768. + case AR71XX_PCI_IRQ_DEV0:
  11769. + irq -= AR71XX_PCI_IRQ_BASE;
  11770. +
  11771. + t = __raw_readl(base + AR724X_PCI_REG_INT_MASK);
  11772. + __raw_writel(t | AR724X_PCI_INT_DEV0,
  11773. + base + AR724X_PCI_REG_INT_MASK);
  11774. + /* flush write */
  11775. + (void) __raw_readl(base + AR724X_PCI_REG_INT_MASK);
  11776. + }
  11777. +}
  11778. +
  11779. +static void ar724x_pci_irq_mask(unsigned int irq)
  11780. +{
  11781. + void __iomem *base = ar724x_pci_ctrl_base;
  11782. + u32 t;
  11783. +
  11784. + switch (irq) {
  11785. + case AR71XX_PCI_IRQ_DEV0:
  11786. + irq -= AR71XX_PCI_IRQ_BASE;
  11787. +
  11788. + t = __raw_readl(base + AR724X_PCI_REG_INT_MASK);
  11789. + __raw_writel(t & ~AR724X_PCI_INT_DEV0,
  11790. + base + AR724X_PCI_REG_INT_MASK);
  11791. +
  11792. + /* flush write */
  11793. + (void) __raw_readl(base + AR724X_PCI_REG_INT_MASK);
  11794. +
  11795. + t = __raw_readl(base + AR724X_PCI_REG_INT_STATUS);
  11796. + __raw_writel(t | AR724X_PCI_INT_DEV0,
  11797. + base + AR724X_PCI_REG_INT_STATUS);
  11798. +
  11799. + /* flush write */
  11800. + (void) __raw_readl(base + AR724X_PCI_REG_INT_STATUS);
  11801. + }
  11802. +}
  11803. +
  11804. +static struct irq_chip ar724x_pci_irq_chip = {
  11805. + .name = "AR724X PCI ",
  11806. + .mask = ar724x_pci_irq_mask,
  11807. + .unmask = ar724x_pci_irq_unmask,
  11808. + .mask_ack = ar724x_pci_irq_mask,
  11809. +};
  11810. +
  11811. +static void __init ar724x_pci_irq_init(void)
  11812. +{
  11813. + void __iomem *base = ar724x_pci_ctrl_base;
  11814. + u32 t;
  11815. + int i;
  11816. +
  11817. + t = ar71xx_reset_rr(AR724X_RESET_REG_RESET_MODULE);
  11818. + if (t & (AR724X_RESET_PCIE | AR724X_RESET_PCIE_PHY |
  11819. + AR724X_RESET_PCIE_PHY_SERIAL)) {
  11820. + return;
  11821. + }
  11822. +
  11823. + __raw_writel(0, base + AR724X_PCI_REG_INT_MASK);
  11824. + __raw_writel(0, base + AR724X_PCI_REG_INT_STATUS);
  11825. +
  11826. + for (i = AR71XX_PCI_IRQ_BASE;
  11827. + i < AR71XX_PCI_IRQ_BASE + AR71XX_PCI_IRQ_COUNT; i++) {
  11828. + irq_desc[i].status = IRQ_DISABLED;
  11829. + set_irq_chip_and_handler(i, &ar724x_pci_irq_chip,
  11830. + handle_level_irq);
  11831. + }
  11832. +
  11833. + set_irq_chained_handler(AR71XX_CPU_IRQ_IP2, ar724x_pci_irq_handler);
  11834. +}
  11835. +
  11836. +int __init ar724x_pcibios_init(void)
  11837. +{
  11838. + int ret = -ENOMEM;
  11839. +
  11840. + ar724x_pci_localcfg_base = ioremap_nocache(AR724X_PCI_CRP_BASE,
  11841. + AR724X_PCI_CRP_SIZE);
  11842. + if (ar724x_pci_localcfg_base == NULL)
  11843. + goto err;
  11844. +
  11845. + ar724x_pci_devcfg_base = ioremap_nocache(AR724X_PCI_CFG_BASE,
  11846. + AR724X_PCI_CFG_SIZE);
  11847. + if (ar724x_pci_devcfg_base == NULL)
  11848. + goto err_unmap_localcfg;
  11849. +
  11850. + ar724x_pci_ctrl_base = ioremap_nocache(AR724X_PCI_CTRL_BASE,
  11851. + AR724X_PCI_CTRL_SIZE);
  11852. + if (ar724x_pci_ctrl_base == NULL)
  11853. + goto err_unmap_devcfg;
  11854. +
  11855. + ar724x_pci_reset();
  11856. + ret = ar724x_pci_setup();
  11857. + if (ret)
  11858. + goto err_unmap_ctrl;
  11859. +
  11860. + ar724x_pci_fixup_enable = 1;
  11861. + ar724x_pci_irq_init();
  11862. + register_pci_controller(&ar724x_pci_controller);
  11863. +
  11864. + return 0;
  11865. +
  11866. + err_unmap_ctrl:
  11867. + iounmap(ar724x_pci_ctrl_base);
  11868. + err_unmap_devcfg:
  11869. + iounmap(ar724x_pci_devcfg_base);
  11870. + err_unmap_localcfg:
  11871. + iounmap(ar724x_pci_localcfg_base);
  11872. + err:
  11873. + return ret;
  11874. +}
  11875. diff -Nur linux-2.6.35.7.orig/drivers/char/Kconfig linux-2.6.35.7/drivers/char/Kconfig
  11876. --- linux-2.6.35.7.orig/drivers/char/Kconfig 2010-09-29 03:09:08.000000000 +0200
  11877. +++ linux-2.6.35.7/drivers/char/Kconfig 2010-10-14 20:27:59.828101117 +0200
  11878. @@ -1032,6 +1032,14 @@
  11879. If compiled as a module, it will be called cs5535_gpio.
  11880. +config GPIO_DEVICE
  11881. + tristate "GPIO device support"
  11882. + depends on GENERIC_GPIO
  11883. + help
  11884. + Say Y to enable Linux GPIO device support. This allows control of
  11885. + GPIO pins using a character device
  11886. +
  11887. +
  11888. config RAW_DRIVER
  11889. tristate "RAW driver (/dev/raw/rawN)"
  11890. depends on BLOCK
  11891. diff -Nur linux-2.6.35.7.orig/drivers/char/Kconfig.orig linux-2.6.35.7/drivers/char/Kconfig.orig
  11892. --- linux-2.6.35.7.orig/drivers/char/Kconfig.orig 1970-01-01 01:00:00.000000000 +0100
  11893. +++ linux-2.6.35.7/drivers/char/Kconfig.orig 2010-09-29 03:09:08.000000000 +0200
  11894. @@ -0,0 +1,1133 @@
  11895. +#
  11896. +# Character device configuration
  11897. +#
  11898. +
  11899. +menu "Character devices"
  11900. +
  11901. +config VT
  11902. + bool "Virtual terminal" if EMBEDDED
  11903. + depends on !S390
  11904. + select INPUT
  11905. + default y
  11906. + ---help---
  11907. + If you say Y here, you will get support for terminal devices with
  11908. + display and keyboard devices. These are called "virtual" because you
  11909. + can run several virtual terminals (also called virtual consoles) on
  11910. + one physical terminal. This is rather useful, for example one
  11911. + virtual terminal can collect system messages and warnings, another
  11912. + one can be used for a text-mode user session, and a third could run
  11913. + an X session, all in parallel. Switching between virtual terminals
  11914. + is done with certain key combinations, usually Alt-<function key>.
  11915. +
  11916. + The setterm command ("man setterm") can be used to change the
  11917. + properties (such as colors or beeping) of a virtual terminal. The
  11918. + man page console_codes(4) ("man console_codes") contains the special
  11919. + character sequences that can be used to change those properties
  11920. + directly. The fonts used on virtual terminals can be changed with
  11921. + the setfont ("man setfont") command and the key bindings are defined
  11922. + with the loadkeys ("man loadkeys") command.
  11923. +
  11924. + You need at least one virtual terminal device in order to make use
  11925. + of your keyboard and monitor. Therefore, only people configuring an
  11926. + embedded system would want to say N here in order to save some
  11927. + memory; the only way to log into such a system is then via a serial
  11928. + or network connection.
  11929. +
  11930. + If unsure, say Y, or else you won't be able to do much with your new
  11931. + shiny Linux system :-)
  11932. +
  11933. +config CONSOLE_TRANSLATIONS
  11934. + depends on VT
  11935. + default y
  11936. + bool "Enable character translations in console" if EMBEDDED
  11937. + ---help---
  11938. + This enables support for font mapping and Unicode translation
  11939. + on virtual consoles.
  11940. +
  11941. +config VT_CONSOLE
  11942. + bool "Support for console on virtual terminal" if EMBEDDED
  11943. + depends on VT
  11944. + default y
  11945. + ---help---
  11946. + The system console is the device which receives all kernel messages
  11947. + and warnings and which allows logins in single user mode. If you
  11948. + answer Y here, a virtual terminal (the device used to interact with
  11949. + a physical terminal) can be used as system console. This is the most
  11950. + common mode of operations, so you should say Y here unless you want
  11951. + the kernel messages be output only to a serial port (in which case
  11952. + you should say Y to "Console on serial port", below).
  11953. +
  11954. + If you do say Y here, by default the currently visible virtual
  11955. + terminal (/dev/tty0) will be used as system console. You can change
  11956. + that with a kernel command line option such as "console=tty3" which
  11957. + would use the third virtual terminal as system console. (Try "man
  11958. + bootparam" or see the documentation of your boot loader (lilo or
  11959. + loadlin) about how to pass options to the kernel at boot time.)
  11960. +
  11961. + If unsure, say Y.
  11962. +
  11963. +config HW_CONSOLE
  11964. + bool
  11965. + depends on VT && !S390 && !UML
  11966. + default y
  11967. +
  11968. +config VT_HW_CONSOLE_BINDING
  11969. + bool "Support for binding and unbinding console drivers"
  11970. + depends on HW_CONSOLE
  11971. + default n
  11972. + ---help---
  11973. + The virtual terminal is the device that interacts with the physical
  11974. + terminal through console drivers. On these systems, at least one
  11975. + console driver is loaded. In other configurations, additional console
  11976. + drivers may be enabled, such as the framebuffer console. If more than
  11977. + 1 console driver is enabled, setting this to 'y' will allow you to
  11978. + select the console driver that will serve as the backend for the
  11979. + virtual terminals.
  11980. +
  11981. + See <file:Documentation/console/console.txt> for more
  11982. + information. For framebuffer console users, please refer to
  11983. + <file:Documentation/fb/fbcon.txt>.
  11984. +
  11985. +config DEVKMEM
  11986. + bool "/dev/kmem virtual device support"
  11987. + default y
  11988. + help
  11989. + Say Y here if you want to support the /dev/kmem device. The
  11990. + /dev/kmem device is rarely used, but can be used for certain
  11991. + kind of kernel debugging operations.
  11992. + When in doubt, say "N".
  11993. +
  11994. +config BFIN_JTAG_COMM
  11995. + tristate "Blackfin JTAG Communication"
  11996. + depends on BLACKFIN
  11997. + help
  11998. + Add support for emulating a TTY device over the Blackfin JTAG.
  11999. +
  12000. + To compile this driver as a module, choose M here: the
  12001. + module will be called bfin_jtag_comm.
  12002. +
  12003. +config BFIN_JTAG_COMM_CONSOLE
  12004. + bool "Console on Blackfin JTAG"
  12005. + depends on BFIN_JTAG_COMM=y
  12006. +
  12007. +config SERIAL_NONSTANDARD
  12008. + bool "Non-standard serial port support"
  12009. + depends on HAS_IOMEM
  12010. + ---help---
  12011. + Say Y here if you have any non-standard serial boards -- boards
  12012. + which aren't supported using the standard "dumb" serial driver.
  12013. + This includes intelligent serial boards such as Cyclades,
  12014. + Digiboards, etc. These are usually used for systems that need many
  12015. + serial ports because they serve many terminals or dial-in
  12016. + connections.
  12017. +
  12018. + Note that the answer to this question won't directly affect the
  12019. + kernel: saying N will just cause the configurator to skip all
  12020. + the questions about non-standard serial boards.
  12021. +
  12022. + Most people can say N here.
  12023. +
  12024. +config COMPUTONE
  12025. + tristate "Computone IntelliPort Plus serial support"
  12026. + depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
  12027. + ---help---
  12028. + This driver supports the entire family of Intelliport II/Plus
  12029. + controllers with the exception of the MicroChannel controllers and
  12030. + products previous to the Intelliport II. These are multiport cards,
  12031. + which give you many serial ports. You would need something like this
  12032. + to connect more than two modems to your Linux box, for instance in
  12033. + order to become a dial-in server. If you have a card like that, say
  12034. + Y here and read <file:Documentation/serial/computone.txt>.
  12035. +
  12036. + To compile this driver as module, choose M here: the
  12037. + module will be called ip2.
  12038. +
  12039. +config ROCKETPORT
  12040. + tristate "Comtrol RocketPort support"
  12041. + depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
  12042. + help
  12043. + This driver supports Comtrol RocketPort and RocketModem PCI boards.
  12044. + These boards provide 2, 4, 8, 16, or 32 high-speed serial ports or
  12045. + modems. For information about the RocketPort/RocketModem boards
  12046. + and this driver read <file:Documentation/serial/rocket.txt>.
  12047. +
  12048. + To compile this driver as a module, choose M here: the
  12049. + module will be called rocket.
  12050. +
  12051. + If you want to compile this driver into the kernel, say Y here. If
  12052. + you don't have a Comtrol RocketPort/RocketModem card installed, say N.
  12053. +
  12054. +config CYCLADES
  12055. + tristate "Cyclades async mux support"
  12056. + depends on SERIAL_NONSTANDARD && (PCI || ISA)
  12057. + select FW_LOADER
  12058. + ---help---
  12059. + This driver supports Cyclades Z and Y multiserial boards.
  12060. + You would need something like this to connect more than two modems to
  12061. + your Linux box, for instance in order to become a dial-in server.
  12062. +
  12063. + For information about the Cyclades-Z card, read
  12064. + <file:Documentation/serial/README.cycladesZ>.
  12065. +
  12066. + To compile this driver as a module, choose M here: the
  12067. + module will be called cyclades.
  12068. +
  12069. + If you haven't heard about it, it's safe to say N.
  12070. +
  12071. +config CYZ_INTR
  12072. + bool "Cyclades-Z interrupt mode operation (EXPERIMENTAL)"
  12073. + depends on EXPERIMENTAL && CYCLADES
  12074. + help
  12075. + The Cyclades-Z family of multiport cards allows 2 (two) driver op
  12076. + modes: polling and interrupt. In polling mode, the driver will check
  12077. + the status of the Cyclades-Z ports every certain amount of time
  12078. + (which is called polling cycle and is configurable). In interrupt
  12079. + mode, it will use an interrupt line (IRQ) in order to check the
  12080. + status of the Cyclades-Z ports. The default op mode is polling. If
  12081. + unsure, say N.
  12082. +
  12083. +config DIGIEPCA
  12084. + tristate "Digiboard Intelligent Async Support"
  12085. + depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
  12086. + ---help---
  12087. + This is a driver for Digi International's Xx, Xeve, and Xem series
  12088. + of cards which provide multiple serial ports. You would need
  12089. + something like this to connect more than two modems to your Linux
  12090. + box, for instance in order to become a dial-in server. This driver
  12091. + supports the original PC (ISA) boards as well as PCI, and EISA. If
  12092. + you have a card like this, say Y here and read the file
  12093. + <file:Documentation/serial/digiepca.txt>.
  12094. +
  12095. + To compile this driver as a module, choose M here: the
  12096. + module will be called epca.
  12097. +
  12098. +config MOXA_INTELLIO
  12099. + tristate "Moxa Intellio support"
  12100. + depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
  12101. + select FW_LOADER
  12102. + help
  12103. + Say Y here if you have a Moxa Intellio multiport serial card.
  12104. +
  12105. + To compile this driver as a module, choose M here: the
  12106. + module will be called moxa.
  12107. +
  12108. +config MOXA_SMARTIO
  12109. + tristate "Moxa SmartIO support v. 2.0"
  12110. + depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
  12111. + help
  12112. + Say Y here if you have a Moxa SmartIO multiport serial card and/or
  12113. + want to help develop a new version of this driver.
  12114. +
  12115. + This is upgraded (1.9.1) driver from original Moxa drivers with
  12116. + changes finally resulting in PCI probing.
  12117. +
  12118. + This driver can also be built as a module. The module will be called
  12119. + mxser. If you want to do that, say M here.
  12120. +
  12121. +config ISI
  12122. + tristate "Multi-Tech multiport card support (EXPERIMENTAL)"
  12123. + depends on SERIAL_NONSTANDARD && PCI
  12124. + select FW_LOADER
  12125. + help
  12126. + This is a driver for the Multi-Tech cards which provide several
  12127. + serial ports. The driver is experimental and can currently only be
  12128. + built as a module. The module will be called isicom.
  12129. + If you want to do that, choose M here.
  12130. +
  12131. +config SYNCLINK
  12132. + tristate "Microgate SyncLink card support"
  12133. + depends on SERIAL_NONSTANDARD && PCI && ISA_DMA_API
  12134. + help
  12135. + Provides support for the SyncLink ISA and PCI multiprotocol serial
  12136. + adapters. These adapters support asynchronous and HDLC bit
  12137. + synchronous communication up to 10Mbps (PCI adapter).
  12138. +
  12139. + This driver can only be built as a module ( = code which can be
  12140. + inserted in and removed from the running kernel whenever you want).
  12141. + The module will be called synclink. If you want to do that, say M
  12142. + here.
  12143. +
  12144. +config SYNCLINKMP
  12145. + tristate "SyncLink Multiport support"
  12146. + depends on SERIAL_NONSTANDARD && PCI
  12147. + help
  12148. + Enable support for the SyncLink Multiport (2 or 4 ports)
  12149. + serial adapter, running asynchronous and HDLC communications up
  12150. + to 2.048Mbps. Each ports is independently selectable for
  12151. + RS-232, V.35, RS-449, RS-530, and X.21
  12152. +
  12153. + This driver may be built as a module ( = code which can be
  12154. + inserted in and removed from the running kernel whenever you want).
  12155. + The module will be called synclinkmp. If you want to do that, say M
  12156. + here.
  12157. +
  12158. +config SYNCLINK_GT
  12159. + tristate "SyncLink GT/AC support"
  12160. + depends on SERIAL_NONSTANDARD && PCI
  12161. + help
  12162. + Support for SyncLink GT and SyncLink AC families of
  12163. + synchronous and asynchronous serial adapters
  12164. + manufactured by Microgate Systems, Ltd. (www.microgate.com)
  12165. +
  12166. +config N_HDLC
  12167. + tristate "HDLC line discipline support"
  12168. + depends on SERIAL_NONSTANDARD
  12169. + help
  12170. + Allows synchronous HDLC communications with tty device drivers that
  12171. + support synchronous HDLC such as the Microgate SyncLink adapter.
  12172. +
  12173. + This driver can be built as a module ( = code which can be
  12174. + inserted in and removed from the running kernel whenever you want).
  12175. + The module will be called n_hdlc. If you want to do that, say M
  12176. + here.
  12177. +
  12178. +config N_GSM
  12179. + tristate "GSM MUX line discipline support (EXPERIMENTAL)"
  12180. + depends on EXPERIMENTAL
  12181. + depends on NET
  12182. + help
  12183. + This line discipline provides support for the GSM MUX protocol and
  12184. + presents the mux as a set of 61 individual tty devices.
  12185. +
  12186. +config RISCOM8
  12187. + tristate "SDL RISCom/8 card support"
  12188. + depends on SERIAL_NONSTANDARD
  12189. + help
  12190. + This is a driver for the SDL Communications RISCom/8 multiport card,
  12191. + which gives you many serial ports. You would need something like
  12192. + this to connect more than two modems to your Linux box, for instance
  12193. + in order to become a dial-in server. If you have a card like that,
  12194. + say Y here and read the file <file:Documentation/serial/riscom8.txt>.
  12195. +
  12196. + Also it's possible to say M here and compile this driver as kernel
  12197. + loadable module; the module will be called riscom8.
  12198. +
  12199. +config SPECIALIX
  12200. + tristate "Specialix IO8+ card support"
  12201. + depends on SERIAL_NONSTANDARD
  12202. + help
  12203. + This is a driver for the Specialix IO8+ multiport card (both the
  12204. + ISA and the PCI version) which gives you many serial ports. You
  12205. + would need something like this to connect more than two modems to
  12206. + your Linux box, for instance in order to become a dial-in server.
  12207. +
  12208. + If you have a card like that, say Y here and read the file
  12209. + <file:Documentation/serial/specialix.txt>. Also it's possible to say
  12210. + M here and compile this driver as kernel loadable module which will be
  12211. + called specialix.
  12212. +
  12213. +config SX
  12214. + tristate "Specialix SX (and SI) card support"
  12215. + depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) && BROKEN
  12216. + help
  12217. + This is a driver for the SX and SI multiport serial cards.
  12218. + Please read the file <file:Documentation/serial/sx.txt> for details.
  12219. +
  12220. + This driver can only be built as a module ( = code which can be
  12221. + inserted in and removed from the running kernel whenever you want).
  12222. + The module will be called sx. If you want to do that, say M here.
  12223. +
  12224. +config RIO
  12225. + tristate "Specialix RIO system support"
  12226. + depends on SERIAL_NONSTANDARD && BROKEN
  12227. + help
  12228. + This is a driver for the Specialix RIO, a smart serial card which
  12229. + drives an outboard box that can support up to 128 ports. Product
  12230. + information is at <http://www.perle.com/support/documentation.html#multiport>.
  12231. + There are both ISA and PCI versions.
  12232. +
  12233. +config RIO_OLDPCI
  12234. + bool "Support really old RIO/PCI cards"
  12235. + depends on RIO
  12236. + help
  12237. + Older RIO PCI cards need some initialization-time configuration to
  12238. + determine the IRQ and some control addresses. If you have a RIO and
  12239. + this doesn't seem to work, try setting this to Y.
  12240. +
  12241. +config STALDRV
  12242. + bool "Stallion multiport serial support"
  12243. + depends on SERIAL_NONSTANDARD
  12244. + help
  12245. + Stallion cards give you many serial ports. You would need something
  12246. + like this to connect more than two modems to your Linux box, for
  12247. + instance in order to become a dial-in server. If you say Y here,
  12248. + you will be asked for your specific card model in the next
  12249. + questions. Make sure to read <file:Documentation/serial/stallion.txt>
  12250. + in this case. If you have never heard about all this, it's safe to
  12251. + say N.
  12252. +
  12253. +config STALLION
  12254. + tristate "Stallion EasyIO or EC8/32 support"
  12255. + depends on STALDRV && (ISA || EISA || PCI)
  12256. + help
  12257. + If you have an EasyIO or EasyConnection 8/32 multiport Stallion
  12258. + card, then this is for you; say Y. Make sure to read
  12259. + <file:Documentation/serial/stallion.txt>.
  12260. +
  12261. + To compile this driver as a module, choose M here: the
  12262. + module will be called stallion.
  12263. +
  12264. +config ISTALLION
  12265. + tristate "Stallion EC8/64, ONboard, Brumby support"
  12266. + depends on STALDRV && (ISA || EISA || PCI)
  12267. + help
  12268. + If you have an EasyConnection 8/64, ONboard, Brumby or Stallion
  12269. + serial multiport card, say Y here. Make sure to read
  12270. + <file:Documentation/serial/stallion.txt>.
  12271. +
  12272. + To compile this driver as a module, choose M here: the
  12273. + module will be called istallion.
  12274. +
  12275. +config NOZOMI
  12276. + tristate "HSDPA Broadband Wireless Data Card - Globe Trotter"
  12277. + depends on PCI && EXPERIMENTAL
  12278. + help
  12279. + If you have a HSDPA driver Broadband Wireless Data Card -
  12280. + Globe Trotter PCMCIA card, say Y here.
  12281. +
  12282. + To compile this driver as a module, choose M here, the module
  12283. + will be called nozomi.
  12284. +
  12285. +config A2232
  12286. + tristate "Commodore A2232 serial support (EXPERIMENTAL)"
  12287. + depends on EXPERIMENTAL && ZORRO && BROKEN
  12288. + ---help---
  12289. + This option supports the 2232 7-port serial card shipped with the
  12290. + Amiga 2000 and other Zorro-bus machines, dating from 1989. At
  12291. + a max of 19,200 bps, the ports are served by a 6551 ACIA UART chip
  12292. + each, plus a 8520 CIA, and a master 6502 CPU and buffer as well. The
  12293. + ports were connected with 8 pin DIN connectors on the card bracket,
  12294. + for which 8 pin to DB25 adapters were supplied. The card also had
  12295. + jumpers internally to toggle various pinning configurations.
  12296. +
  12297. + This driver can be built as a module; but then "generic_serial"
  12298. + will also be built as a module. This has to be loaded before
  12299. + "ser_a2232". If you want to do this, answer M here.
  12300. +
  12301. +config SGI_SNSC
  12302. + bool "SGI Altix system controller communication support"
  12303. + depends on (IA64_SGI_SN2 || IA64_GENERIC)
  12304. + help
  12305. + If you have an SGI Altix and you want to enable system
  12306. + controller communication from user space (you want this!),
  12307. + say Y. Otherwise, say N.
  12308. +
  12309. +config SGI_TIOCX
  12310. + bool "SGI TIO CX driver support"
  12311. + depends on (IA64_SGI_SN2 || IA64_GENERIC)
  12312. + help
  12313. + If you have an SGI Altix and you have fpga devices attached
  12314. + to your TIO, say Y here, otherwise say N.
  12315. +
  12316. +config SGI_MBCS
  12317. + tristate "SGI FPGA Core Services driver support"
  12318. + depends on SGI_TIOCX
  12319. + help
  12320. + If you have an SGI Altix with an attached SABrick
  12321. + say Y or M here, otherwise say N.
  12322. +
  12323. +source "drivers/serial/Kconfig"
  12324. +
  12325. +config UNIX98_PTYS
  12326. + bool "Unix98 PTY support" if EMBEDDED
  12327. + default y
  12328. + ---help---
  12329. + A pseudo terminal (PTY) is a software device consisting of two
  12330. + halves: a master and a slave. The slave device behaves identical to
  12331. + a physical terminal; the master device is used by a process to
  12332. + read data from and write data to the slave, thereby emulating a
  12333. + terminal. Typical programs for the master side are telnet servers
  12334. + and xterms.
  12335. +
  12336. + Linux has traditionally used the BSD-like names /dev/ptyxx for
  12337. + masters and /dev/ttyxx for slaves of pseudo terminals. This scheme
  12338. + has a number of problems. The GNU C library glibc 2.1 and later,
  12339. + however, supports the Unix98 naming standard: in order to acquire a
  12340. + pseudo terminal, a process opens /dev/ptmx; the number of the pseudo
  12341. + terminal is then made available to the process and the pseudo
  12342. + terminal slave can be accessed as /dev/pts/<number>. What was
  12343. + traditionally /dev/ttyp2 will then be /dev/pts/2, for example.
  12344. +
  12345. + All modern Linux systems use the Unix98 ptys. Say Y unless
  12346. + you're on an embedded system and want to conserve memory.
  12347. +
  12348. +config DEVPTS_MULTIPLE_INSTANCES
  12349. + bool "Support multiple instances of devpts"
  12350. + depends on UNIX98_PTYS
  12351. + default n
  12352. + ---help---
  12353. + Enable support for multiple instances of devpts filesystem.
  12354. + If you want to have isolated PTY namespaces (eg: in containers),
  12355. + say Y here. Otherwise, say N. If enabled, each mount of devpts
  12356. + filesystem with the '-o newinstance' option will create an
  12357. + independent PTY namespace.
  12358. +
  12359. +config LEGACY_PTYS
  12360. + bool "Legacy (BSD) PTY support"
  12361. + default y
  12362. + ---help---
  12363. + A pseudo terminal (PTY) is a software device consisting of two
  12364. + halves: a master and a slave. The slave device behaves identical to
  12365. + a physical terminal; the master device is used by a process to
  12366. + read data from and write data to the slave, thereby emulating a
  12367. + terminal. Typical programs for the master side are telnet servers
  12368. + and xterms.
  12369. +
  12370. + Linux has traditionally used the BSD-like names /dev/ptyxx
  12371. + for masters and /dev/ttyxx for slaves of pseudo
  12372. + terminals. This scheme has a number of problems, including
  12373. + security. This option enables these legacy devices; on most
  12374. + systems, it is safe to say N.
  12375. +
  12376. +
  12377. +config LEGACY_PTY_COUNT
  12378. + int "Maximum number of legacy PTY in use"
  12379. + depends on LEGACY_PTYS
  12380. + range 0 256
  12381. + default "256"
  12382. + ---help---
  12383. + The maximum number of legacy PTYs that can be used at any one time.
  12384. + The default is 256, and should be more than enough. Embedded
  12385. + systems may want to reduce this to save memory.
  12386. +
  12387. + When not in use, each legacy PTY occupies 12 bytes on 32-bit
  12388. + architectures and 24 bytes on 64-bit architectures.
  12389. +
  12390. +config BRIQ_PANEL
  12391. + tristate 'Total Impact briQ front panel driver'
  12392. + depends on PPC_CHRP
  12393. + ---help---
  12394. + The briQ is a small footprint CHRP computer with a frontpanel VFD, a
  12395. + tristate led and two switches. It is the size of a CDROM drive.
  12396. +
  12397. + If you have such one and want anything showing on the VFD then you
  12398. + must answer Y here.
  12399. +
  12400. + To compile this driver as a module, choose M here: the
  12401. + module will be called briq_panel.
  12402. +
  12403. + It's safe to say N here.
  12404. +
  12405. +config BFIN_OTP
  12406. + tristate "Blackfin On-Chip OTP Memory Support"
  12407. + depends on BLACKFIN && (BF51x || BF52x || BF54x)
  12408. + default y
  12409. + help
  12410. + If you say Y here, you will get support for a character device
  12411. + interface into the One Time Programmable memory pages that are
  12412. + stored on the Blackfin processor. This will not get you access
  12413. + to the secure memory pages however. You will need to write your
  12414. + own secure code and reader for that.
  12415. +
  12416. + To compile this driver as a module, choose M here: the module
  12417. + will be called bfin-otp.
  12418. +
  12419. + If unsure, it is safe to say Y.
  12420. +
  12421. +config BFIN_OTP_WRITE_ENABLE
  12422. + bool "Enable writing support of OTP pages"
  12423. + depends on BFIN_OTP
  12424. + default n
  12425. + help
  12426. + If you say Y here, you will enable support for writing of the
  12427. + OTP pages. This is dangerous by nature as you can only program
  12428. + the pages once, so only enable this option when you actually
  12429. + need it so as to not inadvertently clobber data.
  12430. +
  12431. + If unsure, say N.
  12432. +
  12433. +config PRINTER
  12434. + tristate "Parallel printer support"
  12435. + depends on PARPORT
  12436. + ---help---
  12437. + If you intend to attach a printer to the parallel port of your Linux
  12438. + box (as opposed to using a serial printer; if the connector at the
  12439. + printer has 9 or 25 holes ["female"], then it's serial), say Y.
  12440. + Also read the Printing-HOWTO, available from
  12441. + <http://www.tldp.org/docs.html#howto>.
  12442. +
  12443. + It is possible to share one parallel port among several devices
  12444. + (e.g. printer and ZIP drive) and it is safe to compile the
  12445. + corresponding drivers into the kernel.
  12446. +
  12447. + To compile this driver as a module, choose M here and read
  12448. + <file:Documentation/parport.txt>. The module will be called lp.
  12449. +
  12450. + If you have several parallel ports, you can specify which ports to
  12451. + use with the "lp" kernel command line option. (Try "man bootparam"
  12452. + or see the documentation of your boot loader (lilo or loadlin) about
  12453. + how to pass options to the kernel at boot time.) The syntax of the
  12454. + "lp" command line option can be found in <file:drivers/char/lp.c>.
  12455. +
  12456. + If you have more than 8 printers, you need to increase the LP_NO
  12457. + macro in lp.c and the PARPORT_MAX macro in parport.h.
  12458. +
  12459. +config LP_CONSOLE
  12460. + bool "Support for console on line printer"
  12461. + depends on PRINTER
  12462. + ---help---
  12463. + If you want kernel messages to be printed out as they occur, you
  12464. + can have a console on the printer. This option adds support for
  12465. + doing that; to actually get it to happen you need to pass the
  12466. + option "console=lp0" to the kernel at boot time.
  12467. +
  12468. + If the printer is out of paper (or off, or unplugged, or too
  12469. + busy..) the kernel will stall until the printer is ready again.
  12470. + By defining CONSOLE_LP_STRICT to 0 (at your own risk) you
  12471. + can make the kernel continue when this happens,
  12472. + but it'll lose the kernel messages.
  12473. +
  12474. + If unsure, say N.
  12475. +
  12476. +config PPDEV
  12477. + tristate "Support for user-space parallel port device drivers"
  12478. + depends on PARPORT
  12479. + ---help---
  12480. + Saying Y to this adds support for /dev/parport device nodes. This
  12481. + is needed for programs that want portable access to the parallel
  12482. + port, for instance deviceid (which displays Plug-and-Play device
  12483. + IDs).
  12484. +
  12485. + This is the parallel port equivalent of SCSI generic support (sg).
  12486. + It is safe to say N to this -- it is not needed for normal printing
  12487. + or parallel port CD-ROM/disk support.
  12488. +
  12489. + To compile this driver as a module, choose M here: the
  12490. + module will be called ppdev.
  12491. +
  12492. + If unsure, say N.
  12493. +
  12494. +config HVC_DRIVER
  12495. + bool
  12496. + help
  12497. + Generic "hypervisor virtual console" infrastructure for various
  12498. + hypervisors (pSeries, iSeries, Xen, lguest).
  12499. + It will automatically be selected if one of the back-end console drivers
  12500. + is selected.
  12501. +
  12502. +config HVC_IRQ
  12503. + bool
  12504. +
  12505. +config HVC_CONSOLE
  12506. + bool "pSeries Hypervisor Virtual Console support"
  12507. + depends on PPC_PSERIES
  12508. + select HVC_DRIVER
  12509. + select HVC_IRQ
  12510. + help
  12511. + pSeries machines when partitioned support a hypervisor virtual
  12512. + console. This driver allows each pSeries partition to have a console
  12513. + which is accessed via the HMC.
  12514. +
  12515. +config HVC_ISERIES
  12516. + bool "iSeries Hypervisor Virtual Console support"
  12517. + depends on PPC_ISERIES
  12518. + default y
  12519. + select HVC_DRIVER
  12520. + select HVC_IRQ
  12521. + select VIOPATH
  12522. + help
  12523. + iSeries machines support a hypervisor virtual console.
  12524. +
  12525. +config HVC_RTAS
  12526. + bool "IBM RTAS Console support"
  12527. + depends on PPC_RTAS
  12528. + select HVC_DRIVER
  12529. + help
  12530. + IBM Console device driver which makes use of RTAS
  12531. +
  12532. +config HVC_BEAT
  12533. + bool "Toshiba's Beat Hypervisor Console support"
  12534. + depends on PPC_CELLEB
  12535. + select HVC_DRIVER
  12536. + help
  12537. + Toshiba's Cell Reference Set Beat Console device driver
  12538. +
  12539. +config HVC_IUCV
  12540. + bool "z/VM IUCV Hypervisor console support (VM only)"
  12541. + depends on S390
  12542. + select HVC_DRIVER
  12543. + select IUCV
  12544. + default y
  12545. + help
  12546. + This driver provides a Hypervisor console (HVC) back-end to access
  12547. + a Linux (console) terminal via a z/VM IUCV communication path.
  12548. +
  12549. +config HVC_XEN
  12550. + bool "Xen Hypervisor Console support"
  12551. + depends on XEN
  12552. + select HVC_DRIVER
  12553. + select HVC_IRQ
  12554. + default y
  12555. + help
  12556. + Xen virtual console device driver
  12557. +
  12558. +config HVC_UDBG
  12559. + bool "udbg based fake hypervisor console"
  12560. + depends on PPC && EXPERIMENTAL
  12561. + select HVC_DRIVER
  12562. + default n
  12563. +
  12564. +config VIRTIO_CONSOLE
  12565. + tristate "Virtio console"
  12566. + depends on VIRTIO
  12567. + select HVC_DRIVER
  12568. + help
  12569. + Virtio console for use with lguest and other hypervisors.
  12570. +
  12571. + Also serves as a general-purpose serial device for data
  12572. + transfer between the guest and host. Character devices at
  12573. + /dev/vportNpn will be created when corresponding ports are
  12574. + found, where N is the device number and n is the port number
  12575. + within that device. If specified by the host, a sysfs
  12576. + attribute called 'name' will be populated with a name for
  12577. + the port which can be used by udev scripts to create a
  12578. + symlink to the device.
  12579. +
  12580. +config HVCS
  12581. + tristate "IBM Hypervisor Virtual Console Server support"
  12582. + depends on PPC_PSERIES && HVC_CONSOLE
  12583. + help
  12584. + Partitionable IBM Power5 ppc64 machines allow hosting of
  12585. + firmware virtual consoles from one Linux partition by
  12586. + another Linux partition. This driver allows console data
  12587. + from Linux partitions to be accessed through TTY device
  12588. + interfaces in the device tree of a Linux partition running
  12589. + this driver.
  12590. +
  12591. + To compile this driver as a module, choose M here: the
  12592. + module will be called hvcs. Additionally, this module
  12593. + will depend on arch specific APIs exported from hvcserver.ko
  12594. + which will also be compiled when this driver is built as a
  12595. + module.
  12596. +
  12597. +config IBM_BSR
  12598. + tristate "IBM POWER Barrier Synchronization Register support"
  12599. + depends on PPC_PSERIES
  12600. + help
  12601. + This devices exposes a hardware mechanism for fast synchronization
  12602. + of threads across a large system which avoids bouncing a cacheline
  12603. + between several cores on a system
  12604. +
  12605. +source "drivers/char/ipmi/Kconfig"
  12606. +
  12607. +config DS1620
  12608. + tristate "NetWinder thermometer support"
  12609. + depends on ARCH_NETWINDER
  12610. + help
  12611. + Say Y here to include support for the thermal management hardware
  12612. + found in the NetWinder. This driver allows the user to control the
  12613. + temperature set points and to read the current temperature.
  12614. +
  12615. + It is also possible to say M here to build it as a module (ds1620)
  12616. + It is recommended to be used on a NetWinder, but it is not a
  12617. + necessity.
  12618. +
  12619. +config NWBUTTON
  12620. + tristate "NetWinder Button"
  12621. + depends on ARCH_NETWINDER
  12622. + ---help---
  12623. + If you say Y here and create a character device node /dev/nwbutton
  12624. + with major and minor numbers 10 and 158 ("man mknod"), then every
  12625. + time the orange button is pressed a number of times, the number of
  12626. + times the button was pressed will be written to that device.
  12627. +
  12628. + This is most useful for applications, as yet unwritten, which
  12629. + perform actions based on how many times the button is pressed in a
  12630. + row.
  12631. +
  12632. + Do not hold the button down for too long, as the driver does not
  12633. + alter the behaviour of the hardware reset circuitry attached to the
  12634. + button; it will still execute a hard reset if the button is held
  12635. + down for longer than approximately five seconds.
  12636. +
  12637. + To compile this driver as a module, choose M here: the
  12638. + module will be called nwbutton.
  12639. +
  12640. + Most people will answer Y to this question and "Reboot Using Button"
  12641. + below to be able to initiate a system shutdown from the button.
  12642. +
  12643. +config NWBUTTON_REBOOT
  12644. + bool "Reboot Using Button"
  12645. + depends on NWBUTTON
  12646. + help
  12647. + If you say Y here, then you will be able to initiate a system
  12648. + shutdown and reboot by pressing the orange button a number of times.
  12649. + The number of presses to initiate the shutdown is two by default,
  12650. + but this can be altered by modifying the value of NUM_PRESSES_REBOOT
  12651. + in nwbutton.h and recompiling the driver or, if you compile the
  12652. + driver as a module, you can specify the number of presses at load
  12653. + time with "insmod button reboot_count=<something>".
  12654. +
  12655. +config NWFLASH
  12656. + tristate "NetWinder flash support"
  12657. + depends on ARCH_NETWINDER
  12658. + ---help---
  12659. + If you say Y here and create a character device /dev/flash with
  12660. + major 10 and minor 160 you can manipulate the flash ROM containing
  12661. + the NetWinder firmware. Be careful as accidentally overwriting the
  12662. + flash contents can render your computer unbootable. On no account
  12663. + allow random users access to this device. :-)
  12664. +
  12665. + To compile this driver as a module, choose M here: the
  12666. + module will be called nwflash.
  12667. +
  12668. + If you're not sure, say N.
  12669. +
  12670. +source "drivers/char/hw_random/Kconfig"
  12671. +
  12672. +config NVRAM
  12673. + tristate "/dev/nvram support"
  12674. + depends on ATARI || X86 || (ARM && RTC_DRV_CMOS) || GENERIC_NVRAM
  12675. + ---help---
  12676. + If you say Y here and create a character special file /dev/nvram
  12677. + with major number 10 and minor number 144 using mknod ("man mknod"),
  12678. + you get read and write access to the extra bytes of non-volatile
  12679. + memory in the real time clock (RTC), which is contained in every PC
  12680. + and most Ataris. The actual number of bytes varies, depending on the
  12681. + nvram in the system, but is usually 114 (128-14 for the RTC).
  12682. +
  12683. + This memory is conventionally called "CMOS RAM" on PCs and "NVRAM"
  12684. + on Ataris. /dev/nvram may be used to view settings there, or to
  12685. + change them (with some utility). It could also be used to frequently
  12686. + save a few bits of very important data that may not be lost over
  12687. + power-off and for which writing to disk is too insecure. Note
  12688. + however that most NVRAM space in a PC belongs to the BIOS and you
  12689. + should NEVER idly tamper with it. See Ralf Brown's interrupt list
  12690. + for a guide to the use of CMOS bytes by your BIOS.
  12691. +
  12692. + On Atari machines, /dev/nvram is always configured and does not need
  12693. + to be selected.
  12694. +
  12695. + To compile this driver as a module, choose M here: the
  12696. + module will be called nvram.
  12697. +
  12698. +#
  12699. +# These legacy RTC drivers just cause too many conflicts with the generic
  12700. +# RTC framework ... let's not even try to coexist any more.
  12701. +#
  12702. +if RTC_LIB=n
  12703. +
  12704. +config RTC
  12705. + tristate "Enhanced Real Time Clock Support (legacy PC RTC driver)"
  12706. + depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV \
  12707. + && !ARM && !SUPERH && !S390 && !AVR32 && !BLACKFIN
  12708. + ---help---
  12709. + If you say Y here and create a character special file /dev/rtc with
  12710. + major number 10 and minor number 135 using mknod ("man mknod"), you
  12711. + will get access to the real time clock (or hardware clock) built
  12712. + into your computer.
  12713. +
  12714. + Every PC has such a clock built in. It can be used to generate
  12715. + signals from as low as 1Hz up to 8192Hz, and can also be used
  12716. + as a 24 hour alarm. It reports status information via the file
  12717. + /proc/driver/rtc and its behaviour is set by various ioctls on
  12718. + /dev/rtc.
  12719. +
  12720. + If you run Linux on a multiprocessor machine and said Y to
  12721. + "Symmetric Multi Processing" above, you should say Y here to read
  12722. + and set the RTC in an SMP compatible fashion.
  12723. +
  12724. + If you think you have a use for such a device (such as periodic data
  12725. + sampling), then say Y here, and read <file:Documentation/rtc.txt>
  12726. + for details.
  12727. +
  12728. + To compile this driver as a module, choose M here: the
  12729. + module will be called rtc.
  12730. +
  12731. +config JS_RTC
  12732. + tristate "Enhanced Real Time Clock Support"
  12733. + depends on SPARC32 && PCI
  12734. + ---help---
  12735. + If you say Y here and create a character special file /dev/rtc with
  12736. + major number 10 and minor number 135 using mknod ("man mknod"), you
  12737. + will get access to the real time clock (or hardware clock) built
  12738. + into your computer.
  12739. +
  12740. + Every PC has such a clock built in. It can be used to generate
  12741. + signals from as low as 1Hz up to 8192Hz, and can also be used
  12742. + as a 24 hour alarm. It reports status information via the file
  12743. + /proc/driver/rtc and its behaviour is set by various ioctls on
  12744. + /dev/rtc.
  12745. +
  12746. + If you think you have a use for such a device (such as periodic data
  12747. + sampling), then say Y here, and read <file:Documentation/rtc.txt>
  12748. + for details.
  12749. +
  12750. + To compile this driver as a module, choose M here: the
  12751. + module will be called js-rtc.
  12752. +
  12753. +config GEN_RTC
  12754. + tristate "Generic /dev/rtc emulation"
  12755. + depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH && !AVR32 && !BLACKFIN
  12756. + ---help---
  12757. + If you say Y here and create a character special file /dev/rtc with
  12758. + major number 10 and minor number 135 using mknod ("man mknod"), you
  12759. + will get access to the real time clock (or hardware clock) built
  12760. + into your computer.
  12761. +
  12762. + It reports status information via the file /proc/driver/rtc and its
  12763. + behaviour is set by various ioctls on /dev/rtc. If you enable the
  12764. + "extended RTC operation" below it will also provide an emulation
  12765. + for RTC_UIE which is required by some programs and may improve
  12766. + precision in some cases.
  12767. +
  12768. + To compile this driver as a module, choose M here: the
  12769. + module will be called genrtc.
  12770. +
  12771. +config GEN_RTC_X
  12772. + bool "Extended RTC operation"
  12773. + depends on GEN_RTC
  12774. + help
  12775. + Provides an emulation for RTC_UIE which is required by some programs
  12776. + and may improve precision of the generic RTC support in some cases.
  12777. +
  12778. +config EFI_RTC
  12779. + bool "EFI Real Time Clock Services"
  12780. + depends on IA64
  12781. +
  12782. +config DS1302
  12783. + tristate "DS1302 RTC support"
  12784. + depends on M32R && (PLAT_M32700UT || PLAT_OPSPUT)
  12785. + help
  12786. + If you say Y here and create a character special file /dev/rtc with
  12787. + major number 121 and minor number 0 using mknod ("man mknod"), you
  12788. + will get access to the real time clock (or hardware clock) built
  12789. + into your computer.
  12790. +
  12791. +endif # RTC_LIB
  12792. +
  12793. +config DTLK
  12794. + tristate "Double Talk PC internal speech card support"
  12795. + depends on ISA
  12796. + help
  12797. + This driver is for the DoubleTalk PC, a speech synthesizer
  12798. + manufactured by RC Systems (<http://www.rcsys.com/>). It is also
  12799. + called the `internal DoubleTalk'.
  12800. +
  12801. + To compile this driver as a module, choose M here: the
  12802. + module will be called dtlk.
  12803. +
  12804. +config XILINX_HWICAP
  12805. + tristate "Xilinx HWICAP Support"
  12806. + depends on XILINX_VIRTEX || MICROBLAZE
  12807. + help
  12808. + This option enables support for Xilinx Internal Configuration
  12809. + Access Port (ICAP) driver. The ICAP is used on Xilinx Virtex
  12810. + FPGA platforms to partially reconfigure the FPGA at runtime.
  12811. +
  12812. + If unsure, say N.
  12813. +
  12814. +config R3964
  12815. + tristate "Siemens R3964 line discipline"
  12816. + ---help---
  12817. + This driver allows synchronous communication with devices using the
  12818. + Siemens R3964 packet protocol. Unless you are dealing with special
  12819. + hardware like PLCs, you are unlikely to need this.
  12820. +
  12821. + To compile this driver as a module, choose M here: the
  12822. + module will be called n_r3964.
  12823. +
  12824. + If unsure, say N.
  12825. +
  12826. +config APPLICOM
  12827. + tristate "Applicom intelligent fieldbus card support"
  12828. + depends on PCI
  12829. + ---help---
  12830. + This driver provides the kernel-side support for the intelligent
  12831. + fieldbus cards made by Applicom International. More information
  12832. + about these cards can be found on the WWW at the address
  12833. + <http://www.applicom-int.com/>, or by email from David Woodhouse
  12834. + <dwmw2@infradead.org>.
  12835. +
  12836. + To compile this driver as a module, choose M here: the
  12837. + module will be called applicom.
  12838. +
  12839. + If unsure, say N.
  12840. +
  12841. +config SONYPI
  12842. + tristate "Sony Vaio Programmable I/O Control Device support (EXPERIMENTAL)"
  12843. + depends on EXPERIMENTAL && X86 && PCI && INPUT && !64BIT
  12844. + ---help---
  12845. + This driver enables access to the Sony Programmable I/O Control
  12846. + Device which can be found in many (all ?) Sony Vaio laptops.
  12847. +
  12848. + If you have one of those laptops, read
  12849. + <file:Documentation/laptops/sonypi.txt>, and say Y or M here.
  12850. +
  12851. + To compile this driver as a module, choose M here: the
  12852. + module will be called sonypi.
  12853. +
  12854. +config GPIO_TB0219
  12855. + tristate "TANBAC TB0219 GPIO support"
  12856. + depends on TANBAC_TB022X
  12857. + select GPIO_VR41XX
  12858. +
  12859. +source "drivers/char/pcmcia/Kconfig"
  12860. +
  12861. +config MWAVE
  12862. + tristate "ACP Modem (Mwave) support"
  12863. + depends on X86
  12864. + select SERIAL_8250
  12865. + ---help---
  12866. + The ACP modem (Mwave) for Linux is a WinModem. It is composed of a
  12867. + kernel driver and a user level application. Together these components
  12868. + support direct attachment to public switched telephone networks (PSTNs)
  12869. + and support selected world wide countries.
  12870. +
  12871. + This version of the ACP Modem driver supports the IBM Thinkpad 600E,
  12872. + 600, and 770 that include on board ACP modem hardware.
  12873. +
  12874. + The modem also supports the standard communications port interface
  12875. + (ttySx) and is compatible with the Hayes AT Command Set.
  12876. +
  12877. + The user level application needed to use this driver can be found at
  12878. + the IBM Linux Technology Center (LTC) web site:
  12879. + <http://www.ibm.com/linux/ltc/>.
  12880. +
  12881. + If you own one of the above IBM Thinkpads which has the Mwave chipset
  12882. + in it, say Y.
  12883. +
  12884. + To compile this driver as a module, choose M here: the
  12885. + module will be called mwave.
  12886. +
  12887. +config SCx200_GPIO
  12888. + tristate "NatSemi SCx200 GPIO Support"
  12889. + depends on SCx200
  12890. + select NSC_GPIO
  12891. + help
  12892. + Give userspace access to the GPIO pins on the National
  12893. + Semiconductor SCx200 processors.
  12894. +
  12895. + If compiled as a module, it will be called scx200_gpio.
  12896. +
  12897. +config PC8736x_GPIO
  12898. + tristate "NatSemi PC8736x GPIO Support"
  12899. + depends on X86
  12900. + default SCx200_GPIO # mostly N
  12901. + select NSC_GPIO # needed for support routines
  12902. + help
  12903. + Give userspace access to the GPIO pins on the National
  12904. + Semiconductor PC-8736x (x=[03456]) SuperIO chip. The chip
  12905. + has multiple functional units, inc several managed by
  12906. + hwmon/pc87360 driver. Tested with PC-87366
  12907. +
  12908. + If compiled as a module, it will be called pc8736x_gpio.
  12909. +
  12910. +config NSC_GPIO
  12911. + tristate "NatSemi Base GPIO Support"
  12912. + depends on X86_32
  12913. + # selected by SCx200_GPIO and PC8736x_GPIO
  12914. + # what about 2 selectors differing: m != y
  12915. + help
  12916. + Common support used (and needed) by scx200_gpio and
  12917. + pc8736x_gpio drivers. If those drivers are built as
  12918. + modules, this one will be too, named nsc_gpio
  12919. +
  12920. +config CS5535_GPIO
  12921. + tristate "AMD CS5535/CS5536 GPIO (Geode Companion Device)"
  12922. + depends on X86_32
  12923. + help
  12924. + Give userspace access to the GPIO pins on the AMD CS5535 and
  12925. + CS5536 Geode companion devices.
  12926. +
  12927. + If compiled as a module, it will be called cs5535_gpio.
  12928. +
  12929. +config RAW_DRIVER
  12930. + tristate "RAW driver (/dev/raw/rawN)"
  12931. + depends on BLOCK
  12932. + help
  12933. + The raw driver permits block devices to be bound to /dev/raw/rawN.
  12934. + Once bound, I/O against /dev/raw/rawN uses efficient zero-copy I/O.
  12935. + See the raw(8) manpage for more details.
  12936. +
  12937. + Applications should preferably open the device (eg /dev/hda1)
  12938. + with the O_DIRECT flag.
  12939. +
  12940. +config MAX_RAW_DEVS
  12941. + int "Maximum number of RAW devices to support (1-8192)"
  12942. + depends on RAW_DRIVER
  12943. + default "256"
  12944. + help
  12945. + The maximum number of RAW devices that are supported.
  12946. + Default is 256. Increase this number in case you need lots of
  12947. + raw devices.
  12948. +
  12949. +config HPET
  12950. + bool "HPET - High Precision Event Timer" if (X86 || IA64)
  12951. + default n
  12952. + depends on ACPI
  12953. + help
  12954. + If you say Y here, you will have a miscdevice named "/dev/hpet/". Each
  12955. + open selects one of the timers supported by the HPET. The timers are
  12956. + non-periodic and/or periodic.
  12957. +
  12958. +config HPET_MMAP
  12959. + bool "Allow mmap of HPET"
  12960. + default y
  12961. + depends on HPET
  12962. + help
  12963. + If you say Y here, user applications will be able to mmap
  12964. + the HPET registers.
  12965. +
  12966. + In some hardware implementations, the page containing HPET
  12967. + registers may also contain other things that shouldn't be
  12968. + exposed to the user. If this applies to your hardware,
  12969. + say N here.
  12970. +
  12971. +config HANGCHECK_TIMER
  12972. + tristate "Hangcheck timer"
  12973. + depends on X86 || IA64 || PPC64 || S390
  12974. + help
  12975. + The hangcheck-timer module detects when the system has gone
  12976. + out to lunch past a certain margin. It can reboot the system
  12977. + or merely print a warning.
  12978. +
  12979. +config MMTIMER
  12980. + tristate "MMTIMER Memory mapped RTC for SGI Altix"
  12981. + depends on IA64_GENERIC || IA64_SGI_SN2
  12982. + default y
  12983. + help
  12984. + The mmtimer device allows direct userspace access to the
  12985. + Altix system timer.
  12986. +
  12987. +config UV_MMTIMER
  12988. + tristate "UV_MMTIMER Memory mapped RTC for SGI UV"
  12989. + depends on X86_UV
  12990. + default m
  12991. + help
  12992. + The uv_mmtimer device allows direct userspace access to the
  12993. + UV system timer.
  12994. +
  12995. +source "drivers/char/tpm/Kconfig"
  12996. +
  12997. +config TELCLOCK
  12998. + tristate "Telecom clock driver for ATCA SBC"
  12999. + depends on EXPERIMENTAL && X86
  13000. + default n
  13001. + help
  13002. + The telecom clock device is specific to the MPCBL0010 and MPCBL0050
  13003. + ATCA computers and allows direct userspace access to the
  13004. + configuration of the telecom clock configuration settings. This
  13005. + device is used for hardware synchronization across the ATCA backplane
  13006. + fabric. Upon loading, the driver exports a sysfs directory,
  13007. + /sys/devices/platform/telco_clock, with a number of files for
  13008. + controlling the behavior of this hardware.
  13009. +
  13010. +config DEVPORT
  13011. + bool
  13012. + depends on !M68K
  13013. + depends on ISA || PCI
  13014. + default y
  13015. +
  13016. +source "drivers/s390/char/Kconfig"
  13017. +
  13018. +config RAMOOPS
  13019. + tristate "Log panic/oops to a RAM buffer"
  13020. + depends on HAS_IOMEM
  13021. + default n
  13022. + help
  13023. + This enables panic and oops messages to be logged to a circular
  13024. + buffer in RAM where it can be read back at some later point.
  13025. +
  13026. +endmenu
  13027. +
  13028. diff -Nur linux-2.6.35.7.orig/drivers/char/Makefile linux-2.6.35.7/drivers/char/Makefile
  13029. --- linux-2.6.35.7.orig/drivers/char/Makefile 2010-09-29 03:09:08.000000000 +0200
  13030. +++ linux-2.6.35.7/drivers/char/Makefile 2010-10-14 20:27:59.875601109 +0200
  13031. @@ -96,6 +96,7 @@
  13032. obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o
  13033. obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o
  13034. obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
  13035. +obj-$(CONFIG_GPIO_DEVICE) += gpio_dev.o
  13036. obj-$(CONFIG_GPIO_TB0219) += tb0219.o
  13037. obj-$(CONFIG_TELCLOCK) += tlclk.o
  13038. diff -Nur linux-2.6.35.7.orig/drivers/char/Makefile.orig linux-2.6.35.7/drivers/char/Makefile.orig
  13039. --- linux-2.6.35.7.orig/drivers/char/Makefile.orig 1970-01-01 01:00:00.000000000 +0100
  13040. +++ linux-2.6.35.7/drivers/char/Makefile.orig 2010-09-29 03:09:08.000000000 +0200
  13041. @@ -0,0 +1,139 @@
  13042. +#
  13043. +# Makefile for the kernel character device drivers.
  13044. +#
  13045. +
  13046. +#
  13047. +# This file contains the font map for the default (hardware) font
  13048. +#
  13049. +FONTMAPFILE = cp437.uni
  13050. +
  13051. +obj-y += mem.o random.o tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o tty_buffer.o tty_port.o
  13052. +
  13053. +obj-$(CONFIG_LEGACY_PTYS) += pty.o
  13054. +obj-$(CONFIG_UNIX98_PTYS) += pty.o
  13055. +obj-y += misc.o
  13056. +obj-$(CONFIG_VT) += vt_ioctl.o vc_screen.o selection.o keyboard.o
  13057. +obj-$(CONFIG_BFIN_JTAG_COMM) += bfin_jtag_comm.o
  13058. +obj-$(CONFIG_CONSOLE_TRANSLATIONS) += consolemap.o consolemap_deftbl.o
  13059. +obj-$(CONFIG_HW_CONSOLE) += vt.o defkeymap.o
  13060. +obj-$(CONFIG_AUDIT) += tty_audit.o
  13061. +obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o
  13062. +obj-$(CONFIG_MVME147_SCC) += generic_serial.o vme_scc.o
  13063. +obj-$(CONFIG_MVME162_SCC) += generic_serial.o vme_scc.o
  13064. +obj-$(CONFIG_BVME6000_SCC) += generic_serial.o vme_scc.o
  13065. +obj-$(CONFIG_ROCKETPORT) += rocket.o
  13066. +obj-$(CONFIG_SERIAL167) += serial167.o
  13067. +obj-$(CONFIG_CYCLADES) += cyclades.o
  13068. +obj-$(CONFIG_STALLION) += stallion.o
  13069. +obj-$(CONFIG_ISTALLION) += istallion.o
  13070. +obj-$(CONFIG_NOZOMI) += nozomi.o
  13071. +obj-$(CONFIG_DIGIEPCA) += epca.o
  13072. +obj-$(CONFIG_SPECIALIX) += specialix.o
  13073. +obj-$(CONFIG_MOXA_INTELLIO) += moxa.o
  13074. +obj-$(CONFIG_A2232) += ser_a2232.o generic_serial.o
  13075. +obj-$(CONFIG_ATARI_DSP56K) += dsp56k.o
  13076. +obj-$(CONFIG_MOXA_SMARTIO) += mxser.o
  13077. +obj-$(CONFIG_COMPUTONE) += ip2/
  13078. +obj-$(CONFIG_RISCOM8) += riscom8.o
  13079. +obj-$(CONFIG_ISI) += isicom.o
  13080. +obj-$(CONFIG_SYNCLINK) += synclink.o
  13081. +obj-$(CONFIG_SYNCLINKMP) += synclinkmp.o
  13082. +obj-$(CONFIG_SYNCLINK_GT) += synclink_gt.o
  13083. +obj-$(CONFIG_N_HDLC) += n_hdlc.o
  13084. +obj-$(CONFIG_N_GSM) += n_gsm.o
  13085. +obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
  13086. +obj-$(CONFIG_SX) += sx.o generic_serial.o
  13087. +obj-$(CONFIG_RIO) += rio/ generic_serial.o
  13088. +obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o
  13089. +obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o
  13090. +obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
  13091. +obj-$(CONFIG_HVC_BEAT) += hvc_beat.o
  13092. +obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
  13093. +obj-$(CONFIG_HVC_IRQ) += hvc_irq.o
  13094. +obj-$(CONFIG_HVC_XEN) += hvc_xen.o
  13095. +obj-$(CONFIG_HVC_IUCV) += hvc_iucv.o
  13096. +obj-$(CONFIG_HVC_UDBG) += hvc_udbg.o
  13097. +obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o
  13098. +obj-$(CONFIG_RAW_DRIVER) += raw.o
  13099. +obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
  13100. +obj-$(CONFIG_MSPEC) += mspec.o
  13101. +obj-$(CONFIG_MMTIMER) += mmtimer.o
  13102. +obj-$(CONFIG_UV_MMTIMER) += uv_mmtimer.o
  13103. +obj-$(CONFIG_VIOTAPE) += viotape.o
  13104. +obj-$(CONFIG_HVCS) += hvcs.o
  13105. +obj-$(CONFIG_IBM_BSR) += bsr.o
  13106. +obj-$(CONFIG_SGI_MBCS) += mbcs.o
  13107. +obj-$(CONFIG_BRIQ_PANEL) += briq_panel.o
  13108. +obj-$(CONFIG_BFIN_OTP) += bfin-otp.o
  13109. +
  13110. +obj-$(CONFIG_PRINTER) += lp.o
  13111. +
  13112. +obj-$(CONFIG_APM_EMULATION) += apm-emulation.o
  13113. +
  13114. +obj-$(CONFIG_DTLK) += dtlk.o
  13115. +obj-$(CONFIG_R3964) += n_r3964.o
  13116. +obj-$(CONFIG_APPLICOM) += applicom.o
  13117. +obj-$(CONFIG_SONYPI) += sonypi.o
  13118. +obj-$(CONFIG_RTC) += rtc.o
  13119. +obj-$(CONFIG_HPET) += hpet.o
  13120. +obj-$(CONFIG_GEN_RTC) += genrtc.o
  13121. +obj-$(CONFIG_EFI_RTC) += efirtc.o
  13122. +obj-$(CONFIG_DS1302) += ds1302.o
  13123. +obj-$(CONFIG_XILINX_HWICAP) += xilinx_hwicap/
  13124. +ifeq ($(CONFIG_GENERIC_NVRAM),y)
  13125. + obj-$(CONFIG_NVRAM) += generic_nvram.o
  13126. +else
  13127. + obj-$(CONFIG_NVRAM) += nvram.o
  13128. +endif
  13129. +obj-$(CONFIG_TOSHIBA) += toshiba.o
  13130. +obj-$(CONFIG_I8K) += i8k.o
  13131. +obj-$(CONFIG_DS1620) += ds1620.o
  13132. +obj-$(CONFIG_HW_RANDOM) += hw_random/
  13133. +obj-$(CONFIG_PPDEV) += ppdev.o
  13134. +obj-$(CONFIG_NWBUTTON) += nwbutton.o
  13135. +obj-$(CONFIG_NWFLASH) += nwflash.o
  13136. +obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
  13137. +obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o
  13138. +obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o
  13139. +obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
  13140. +obj-$(CONFIG_GPIO_TB0219) += tb0219.o
  13141. +obj-$(CONFIG_TELCLOCK) += tlclk.o
  13142. +
  13143. +obj-$(CONFIG_MWAVE) += mwave/
  13144. +obj-$(CONFIG_AGP) += agp/
  13145. +obj-$(CONFIG_PCMCIA) += pcmcia/
  13146. +obj-$(CONFIG_IPMI_HANDLER) += ipmi/
  13147. +
  13148. +obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o
  13149. +obj-$(CONFIG_TCG_TPM) += tpm/
  13150. +
  13151. +obj-$(CONFIG_PS3_FLASH) += ps3flash.o
  13152. +obj-$(CONFIG_RAMOOPS) += ramoops.o
  13153. +
  13154. +obj-$(CONFIG_JS_RTC) += js-rtc.o
  13155. +js-rtc-y = rtc.o
  13156. +
  13157. +# Files generated that shall be removed upon make clean
  13158. +clean-files := consolemap_deftbl.c defkeymap.c
  13159. +
  13160. +quiet_cmd_conmk = CONMK $@
  13161. + cmd_conmk = scripts/conmakehash $< > $@
  13162. +
  13163. +$(obj)/consolemap_deftbl.c: $(src)/$(FONTMAPFILE)
  13164. + $(call cmd,conmk)
  13165. +
  13166. +$(obj)/defkeymap.o: $(obj)/defkeymap.c
  13167. +
  13168. +# Uncomment if you're changing the keymap and have an appropriate
  13169. +# loadkeys version for the map. By default, we'll use the shipped
  13170. +# versions.
  13171. +# GENERATE_KEYMAP := 1
  13172. +
  13173. +ifdef GENERATE_KEYMAP
  13174. +
  13175. +$(obj)/defkeymap.c: $(obj)/%.c: $(src)/%.map
  13176. + loadkeys --mktable $< > $@.tmp
  13177. + sed -e 's/^static *//' $@.tmp > $@
  13178. + rm $@.tmp
  13179. +
  13180. +endif
  13181. diff -Nur linux-2.6.35.7.orig/drivers/gpio/nxp_74hc153.c linux-2.6.35.7/drivers/gpio/nxp_74hc153.c
  13182. --- linux-2.6.35.7.orig/drivers/gpio/nxp_74hc153.c 1970-01-01 01:00:00.000000000 +0100
  13183. +++ linux-2.6.35.7/drivers/gpio/nxp_74hc153.c 2010-10-14 20:27:59.918101359 +0200
  13184. @@ -0,0 +1,246 @@
  13185. +/*
  13186. + * NXP 74HC153 - Dual 4-input multiplexer GPIO driver
  13187. + *
  13188. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  13189. + *
  13190. + * This program is free software; you can redistribute it and/or modify
  13191. + * it under the terms of the GNU General Public License version 2 as
  13192. + * published by the Free Software Foundation.
  13193. + */
  13194. +
  13195. +#include <linux/module.h>
  13196. +#include <linux/init.h>
  13197. +#include <linux/gpio.h>
  13198. +#include <linux/platform_device.h>
  13199. +#include <linux/nxp_74hc153.h>
  13200. +
  13201. +#define NXP_74HC153_NUM_GPIOS 8
  13202. +#define NXP_74HC153_S0_MASK 0x1
  13203. +#define NXP_74HC153_S1_MASK 0x2
  13204. +#define NXP_74HC153_BANK_MASK 0x4
  13205. +
  13206. +struct nxp_74hc153_chip {
  13207. + struct device *parent;
  13208. + struct gpio_chip gpio_chip;
  13209. + struct mutex lock;
  13210. +};
  13211. +
  13212. +static struct nxp_74hc153_chip *gpio_to_nxp(struct gpio_chip *gc)
  13213. +{
  13214. + return container_of(gc, struct nxp_74hc153_chip, gpio_chip);
  13215. +}
  13216. +
  13217. +static int nxp_74hc153_direction_input(struct gpio_chip *gc, unsigned offset)
  13218. +{
  13219. + return 0;
  13220. +}
  13221. +
  13222. +static int nxp_74hc153_direction_output(struct gpio_chip *gc,
  13223. + unsigned offset, int val)
  13224. +{
  13225. + return -EINVAL;
  13226. +}
  13227. +
  13228. +static int nxp_74hc153_get_value(struct gpio_chip *gc, unsigned offset)
  13229. +{
  13230. + struct nxp_74hc153_chip *nxp;
  13231. + struct nxp_74hc153_platform_data *pdata;
  13232. + unsigned s0;
  13233. + unsigned s1;
  13234. + unsigned pin;
  13235. + int ret;
  13236. +
  13237. + nxp = gpio_to_nxp(gc);
  13238. + pdata = nxp->parent->platform_data;
  13239. +
  13240. + s0 = !!(offset & NXP_74HC153_S0_MASK);
  13241. + s1 = !!(offset & NXP_74HC153_S1_MASK);
  13242. + pin = (offset & NXP_74HC153_BANK_MASK) ? pdata->gpio_pin_2y
  13243. + : pdata->gpio_pin_1y;
  13244. +
  13245. + mutex_lock(&nxp->lock);
  13246. + gpio_set_value(pdata->gpio_pin_s0, s0);
  13247. + gpio_set_value(pdata->gpio_pin_s1, s1);
  13248. + ret = gpio_get_value(pin);
  13249. + mutex_unlock(&nxp->lock);
  13250. +
  13251. + return ret;
  13252. +}
  13253. +
  13254. +static void nxp_74hc153_set_value(struct gpio_chip *gc,
  13255. + unsigned offset, int val)
  13256. +{
  13257. + /* not supported */
  13258. +}
  13259. +
  13260. +static int __devinit nxp_74hc153_probe(struct platform_device *pdev)
  13261. +{
  13262. + struct nxp_74hc153_platform_data *pdata;
  13263. + struct nxp_74hc153_chip *nxp;
  13264. + struct gpio_chip *gc;
  13265. + int err;
  13266. +
  13267. + pdata = pdev->dev.platform_data;
  13268. + if (pdata == NULL) {
  13269. + dev_dbg(&pdev->dev, "no platform data specified\n");
  13270. + return -EINVAL;
  13271. + }
  13272. +
  13273. + nxp = kzalloc(sizeof(struct nxp_74hc153_chip), GFP_KERNEL);
  13274. + if (nxp == NULL) {
  13275. + dev_err(&pdev->dev, "no memory for private data\n");
  13276. + return -ENOMEM;
  13277. + }
  13278. +
  13279. + err = gpio_request(pdata->gpio_pin_s0, dev_name(&pdev->dev));
  13280. + if (err) {
  13281. + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
  13282. + pdata->gpio_pin_s0, err);
  13283. + goto err_free_nxp;
  13284. + }
  13285. +
  13286. + err = gpio_request(pdata->gpio_pin_s1, dev_name(&pdev->dev));
  13287. + if (err) {
  13288. + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
  13289. + pdata->gpio_pin_s1, err);
  13290. + goto err_free_s0;
  13291. + }
  13292. +
  13293. + err = gpio_request(pdata->gpio_pin_1y, dev_name(&pdev->dev));
  13294. + if (err) {
  13295. + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
  13296. + pdata->gpio_pin_1y, err);
  13297. + goto err_free_s1;
  13298. + }
  13299. +
  13300. + err = gpio_request(pdata->gpio_pin_2y, dev_name(&pdev->dev));
  13301. + if (err) {
  13302. + dev_err(&pdev->dev, "unable to claim gpio %u, err=%d\n",
  13303. + pdata->gpio_pin_2y, err);
  13304. + goto err_free_1y;
  13305. + }
  13306. +
  13307. + err = gpio_direction_output(pdata->gpio_pin_s0, 0);
  13308. + if (err) {
  13309. + dev_err(&pdev->dev,
  13310. + "unable to set direction of gpio %u, err=%d\n",
  13311. + pdata->gpio_pin_s0, err);
  13312. + goto err_free_2y;
  13313. + }
  13314. +
  13315. + err = gpio_direction_output(pdata->gpio_pin_s1, 0);
  13316. + if (err) {
  13317. + dev_err(&pdev->dev,
  13318. + "unable to set direction of gpio %u, err=%d\n",
  13319. + pdata->gpio_pin_s1, err);
  13320. + goto err_free_2y;
  13321. + }
  13322. +
  13323. + err = gpio_direction_input(pdata->gpio_pin_1y);
  13324. + if (err) {
  13325. + dev_err(&pdev->dev,
  13326. + "unable to set direction of gpio %u, err=%d\n",
  13327. + pdata->gpio_pin_1y, err);
  13328. + goto err_free_2y;
  13329. + }
  13330. +
  13331. + err = gpio_direction_input(pdata->gpio_pin_2y);
  13332. + if (err) {
  13333. + dev_err(&pdev->dev,
  13334. + "unable to set direction of gpio %u, err=%d\n",
  13335. + pdata->gpio_pin_2y, err);
  13336. + goto err_free_2y;
  13337. + }
  13338. +
  13339. + nxp->parent = &pdev->dev;
  13340. + mutex_init(&nxp->lock);
  13341. +
  13342. + gc = &nxp->gpio_chip;
  13343. +
  13344. + gc->direction_input = nxp_74hc153_direction_input;
  13345. + gc->direction_output = nxp_74hc153_direction_output;
  13346. + gc->get = nxp_74hc153_get_value;
  13347. + gc->set = nxp_74hc153_set_value;
  13348. + gc->can_sleep = 1;
  13349. +
  13350. + gc->base = pdata->gpio_base;
  13351. + gc->ngpio = NXP_74HC153_NUM_GPIOS;
  13352. + gc->label = dev_name(nxp->parent);
  13353. + gc->dev = nxp->parent;
  13354. + gc->owner = THIS_MODULE;
  13355. +
  13356. + err = gpiochip_add(&nxp->gpio_chip);
  13357. + if (err) {
  13358. + dev_err(&pdev->dev, "unable to add gpio chip, err=%d\n", err);
  13359. + goto err_free_2y;
  13360. + }
  13361. +
  13362. + platform_set_drvdata(pdev, nxp);
  13363. + return 0;
  13364. +
  13365. + err_free_2y:
  13366. + gpio_free(pdata->gpio_pin_2y);
  13367. + err_free_1y:
  13368. + gpio_free(pdata->gpio_pin_1y);
  13369. + err_free_s1:
  13370. + gpio_free(pdata->gpio_pin_s1);
  13371. + err_free_s0:
  13372. + gpio_free(pdata->gpio_pin_s0);
  13373. + err_free_nxp:
  13374. + kfree(nxp);
  13375. + return err;
  13376. +}
  13377. +
  13378. +static int nxp_74hc153_remove(struct platform_device *pdev)
  13379. +{
  13380. + struct nxp_74hc153_chip *nxp = platform_get_drvdata(pdev);
  13381. + struct nxp_74hc153_platform_data *pdata = pdev->dev.platform_data;
  13382. +
  13383. + if (nxp) {
  13384. + int err;
  13385. +
  13386. + err = gpiochip_remove(&nxp->gpio_chip);
  13387. + if (err) {
  13388. + dev_err(&pdev->dev,
  13389. + "unable to remove gpio chip, err=%d\n",
  13390. + err);
  13391. + return err;
  13392. + }
  13393. +
  13394. + gpio_free(pdata->gpio_pin_2y);
  13395. + gpio_free(pdata->gpio_pin_1y);
  13396. + gpio_free(pdata->gpio_pin_s1);
  13397. + gpio_free(pdata->gpio_pin_s0);
  13398. +
  13399. + kfree(nxp);
  13400. + platform_set_drvdata(pdev, NULL);
  13401. + }
  13402. +
  13403. + return 0;
  13404. +}
  13405. +
  13406. +static struct platform_driver nxp_74hc153_driver = {
  13407. + .probe = nxp_74hc153_probe,
  13408. + .remove = __devexit_p(nxp_74hc153_remove),
  13409. + .driver = {
  13410. + .name = NXP_74HC153_DRIVER_NAME,
  13411. + .owner = THIS_MODULE,
  13412. + },
  13413. +};
  13414. +
  13415. +static int __init nxp_74hc153_init(void)
  13416. +{
  13417. + return platform_driver_register(&nxp_74hc153_driver);
  13418. +}
  13419. +subsys_initcall(nxp_74hc153_init);
  13420. +
  13421. +static void __exit nxp_74hc153_exit(void)
  13422. +{
  13423. + platform_driver_unregister(&nxp_74hc153_driver);
  13424. +}
  13425. +module_exit(nxp_74hc153_exit);
  13426. +
  13427. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  13428. +MODULE_DESCRIPTION("GPIO expander driver for NXP 74HC153");
  13429. +MODULE_LICENSE("GPL v2");
  13430. +MODULE_ALIAS("platform:" NXP_74HC153_DRIVER_NAME);
  13431. diff -Nur linux-2.6.35.7.orig/drivers/input/misc/gpio_buttons.c linux-2.6.35.7/drivers/input/misc/gpio_buttons.c
  13432. --- linux-2.6.35.7.orig/drivers/input/misc/gpio_buttons.c 1970-01-01 01:00:00.000000000 +0100
  13433. +++ linux-2.6.35.7/drivers/input/misc/gpio_buttons.c 2010-10-14 20:27:59.954442279 +0200
  13434. @@ -0,0 +1,216 @@
  13435. +/*
  13436. + * Driver for buttons on GPIO lines not capable of generating interrupts
  13437. + *
  13438. + * Copyright (C) 2007-2010 Gabor Juhos <juhosg@openwrt.org>
  13439. + * Copyright (C) 2010 Nuno Goncalves <nunojpg@gmail.com>
  13440. + *
  13441. + * This file was based on: /drivers/input/misc/cobalt_btns.c
  13442. + * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
  13443. + *
  13444. + * also was based on: /drivers/input/keyboard/gpio_keys.c
  13445. + * Copyright 2005 Phil Blundell
  13446. + *
  13447. + * This program is free software; you can redistribute it and/or modify
  13448. + * it under the terms of the GNU General Public License version 2 as
  13449. + * published by the Free Software Foundation.
  13450. + *
  13451. + */
  13452. +
  13453. +#include <linux/kernel.h>
  13454. +#include <linux/module.h>
  13455. +#include <linux/init.h>
  13456. +#include <linux/slab.h>
  13457. +
  13458. +#include <linux/input.h>
  13459. +#include <linux/input-polldev.h>
  13460. +#include <linux/ioport.h>
  13461. +#include <linux/platform_device.h>
  13462. +
  13463. +#include <linux/gpio_buttons.h>
  13464. +
  13465. +#include <asm/gpio.h>
  13466. +
  13467. +#define DRV_NAME "gpio-buttons"
  13468. +#define DRV_VERSION "0.1.2"
  13469. +#define PFX DRV_NAME ": "
  13470. +
  13471. +struct gpio_button_data {
  13472. + int last_state;
  13473. + int count;
  13474. +};
  13475. +
  13476. +struct gpio_buttons_dev {
  13477. + struct input_polled_dev *poll_dev;
  13478. + struct gpio_buttons_platform_data *pdata;
  13479. + struct gpio_button_data *data;
  13480. +};
  13481. +
  13482. +static void gpio_buttons_poll(struct input_polled_dev *dev)
  13483. +{
  13484. + struct gpio_buttons_dev *bdev = dev->private;
  13485. + struct gpio_buttons_platform_data *pdata = bdev->pdata;
  13486. + struct input_dev *input = dev->input;
  13487. + int i;
  13488. +
  13489. + for (i = 0; i < bdev->pdata->nbuttons; i++) {
  13490. + struct gpio_button *button = &pdata->buttons[i];
  13491. + unsigned int type = button->type ?: EV_KEY;
  13492. + int state;
  13493. +
  13494. + if (bdev->data[i].count < button->threshold) {
  13495. + bdev->data[i].count++;
  13496. + continue;
  13497. + }
  13498. +
  13499. + state = gpio_get_value(button->gpio) ? 1 : 0;
  13500. + if (state != bdev->data[i].last_state) {
  13501. + input_event(input, type, button->code,
  13502. + !!(state ^ button->active_low));
  13503. + input_sync(input);
  13504. + bdev->data[i].count = 0;
  13505. + bdev->data[i].last_state = state;
  13506. + }
  13507. + }
  13508. +}
  13509. +
  13510. +static int __devinit gpio_buttons_probe(struct platform_device *pdev)
  13511. +{
  13512. + struct gpio_buttons_platform_data *pdata = pdev->dev.platform_data;
  13513. + struct gpio_buttons_dev *bdev;
  13514. + struct input_polled_dev *poll_dev;
  13515. + struct input_dev *input;
  13516. + int error, i;
  13517. +
  13518. + if (!pdata)
  13519. + return -ENXIO;
  13520. +
  13521. + bdev = kzalloc(sizeof(struct gpio_buttons_dev) +
  13522. + sizeof(struct gpio_button_data) * pdata->nbuttons,
  13523. + GFP_KERNEL);
  13524. + if (!bdev) {
  13525. + printk(KERN_ERR DRV_NAME "no memory for device\n");
  13526. + return -ENOMEM;
  13527. + }
  13528. +
  13529. + bdev->data = (struct gpio_button_data *) &bdev[1];
  13530. +
  13531. + poll_dev = input_allocate_polled_device();
  13532. + if (!poll_dev) {
  13533. + printk(KERN_ERR DRV_NAME "no memory for polled device\n");
  13534. + error = -ENOMEM;
  13535. + goto err_free_bdev;
  13536. + }
  13537. +
  13538. + poll_dev->private = bdev;
  13539. + poll_dev->poll = gpio_buttons_poll;
  13540. + poll_dev->poll_interval = pdata->poll_interval;
  13541. +
  13542. + input = poll_dev->input;
  13543. +
  13544. + input->evbit[0] = BIT(EV_KEY);
  13545. + input->name = pdev->name;
  13546. + input->phys = "gpio-buttons/input0";
  13547. + input->dev.parent = &pdev->dev;
  13548. +
  13549. + input->id.bustype = BUS_HOST;
  13550. + input->id.vendor = 0x0001;
  13551. + input->id.product = 0x0001;
  13552. + input->id.version = 0x0100;
  13553. +
  13554. + for (i = 0; i < pdata->nbuttons; i++) {
  13555. + struct gpio_button *button = &pdata->buttons[i];
  13556. + unsigned int gpio = button->gpio;
  13557. + unsigned int type = button->type ?: EV_KEY;
  13558. +
  13559. + error = gpio_request(gpio, button->desc ?
  13560. + button->desc : DRV_NAME);
  13561. + if (error) {
  13562. + printk(KERN_ERR PFX "unable to claim gpio %u, "
  13563. + "error %d\n", gpio, error);
  13564. + goto err_free_gpio;
  13565. + }
  13566. +
  13567. + error = gpio_direction_input(gpio);
  13568. + if (error) {
  13569. + printk(KERN_ERR PFX "unable to set direction on "
  13570. + "gpio %u, error %d\n", gpio, error);
  13571. + goto err_free_gpio;
  13572. + }
  13573. +
  13574. + input_set_capability(input, type, button->code);
  13575. + bdev->data[i].last_state = gpio_get_value(button->gpio) ? 1 : 0;
  13576. + }
  13577. +
  13578. + bdev->poll_dev = poll_dev;
  13579. + bdev->pdata = pdata;
  13580. + platform_set_drvdata(pdev, bdev);
  13581. +
  13582. + error = input_register_polled_device(poll_dev);
  13583. + if (error) {
  13584. + printk(KERN_ERR PFX "unable to register polled device, "
  13585. + "error %d\n", error);
  13586. + goto err_free_gpio;
  13587. + }
  13588. +
  13589. + return 0;
  13590. +
  13591. +err_free_gpio:
  13592. + for (i = i - 1; i >= 0; i--)
  13593. + gpio_free(pdata->buttons[i].gpio);
  13594. +
  13595. + input_free_polled_device(poll_dev);
  13596. +
  13597. +err_free_bdev:
  13598. + kfree(bdev);
  13599. +
  13600. + platform_set_drvdata(pdev, NULL);
  13601. + return error;
  13602. +}
  13603. +
  13604. +static int __devexit gpio_buttons_remove(struct platform_device *pdev)
  13605. +{
  13606. + struct gpio_buttons_dev *bdev = platform_get_drvdata(pdev);
  13607. + struct gpio_buttons_platform_data *pdata = bdev->pdata;
  13608. + int i;
  13609. +
  13610. + input_unregister_polled_device(bdev->poll_dev);
  13611. +
  13612. + for (i = 0; i < pdata->nbuttons; i++)
  13613. + gpio_free(pdata->buttons[i].gpio);
  13614. +
  13615. + input_free_polled_device(bdev->poll_dev);
  13616. +
  13617. + kfree(bdev);
  13618. + platform_set_drvdata(pdev, NULL);
  13619. +
  13620. + return 0;
  13621. +}
  13622. +
  13623. +static struct platform_driver gpio_buttons_driver = {
  13624. + .probe = gpio_buttons_probe,
  13625. + .remove = __devexit_p(gpio_buttons_remove),
  13626. + .driver = {
  13627. + .name = DRV_NAME,
  13628. + .owner = THIS_MODULE,
  13629. + },
  13630. +};
  13631. +
  13632. +static int __init gpio_buttons_init(void)
  13633. +{
  13634. + printk(KERN_INFO DRV_NAME " driver version " DRV_VERSION "\n");
  13635. + return platform_driver_register(&gpio_buttons_driver);
  13636. +}
  13637. +
  13638. +static void __exit gpio_buttons_exit(void)
  13639. +{
  13640. + platform_driver_unregister(&gpio_buttons_driver);
  13641. +}
  13642. +
  13643. +module_init(gpio_buttons_init);
  13644. +module_exit(gpio_buttons_exit);
  13645. +
  13646. +MODULE_LICENSE("GPL");
  13647. +MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
  13648. +MODULE_VERSION(DRV_VERSION);
  13649. +MODULE_DESCRIPTION("Polled buttons driver for CPU GPIOs");
  13650. +
  13651. diff -Nur linux-2.6.35.7.orig/drivers/input/misc/Kconfig linux-2.6.35.7/drivers/input/misc/Kconfig
  13652. --- linux-2.6.35.7.orig/drivers/input/misc/Kconfig 2010-09-29 03:09:08.000000000 +0200
  13653. +++ linux-2.6.35.7/drivers/input/misc/Kconfig 2010-10-14 20:27:59.998101300 +0200
  13654. @@ -390,4 +390,20 @@
  13655. To compile this driver as a module, choose M here: the
  13656. module will be called pcap_keys.
  13657. +config INPUT_GPIO_BUTTONS
  13658. + tristate "Polled GPIO buttons interface"
  13659. + depends on GENERIC_GPIO
  13660. + select INPUT_POLLDEV
  13661. + help
  13662. + This driver implements support for buttons connected
  13663. + to GPIO pins of various CPUs (and some other chips).
  13664. +
  13665. + Say Y here if your device has buttons connected
  13666. + directly to such GPIO pins. Your board-specific
  13667. + setup logic must also provide a platform device,
  13668. + with configuration data saying which GPIOs are used.
  13669. +
  13670. + To compile this driver as a module, choose M here: the
  13671. + module will be called gpio-buttons.
  13672. +
  13673. endif
  13674. diff -Nur linux-2.6.35.7.orig/drivers/input/misc/Kconfig.orig linux-2.6.35.7/drivers/input/misc/Kconfig.orig
  13675. --- linux-2.6.35.7.orig/drivers/input/misc/Kconfig.orig 1970-01-01 01:00:00.000000000 +0100
  13676. +++ linux-2.6.35.7/drivers/input/misc/Kconfig.orig 2010-09-29 03:09:08.000000000 +0200
  13677. @@ -0,0 +1,393 @@
  13678. +#
  13679. +# Input misc drivers configuration
  13680. +#
  13681. +menuconfig INPUT_MISC
  13682. + bool "Miscellaneous devices"
  13683. + help
  13684. + Say Y here, and a list of miscellaneous input drivers will be displayed.
  13685. + Everything that didn't fit into the other categories is here. This option
  13686. + doesn't affect the kernel.
  13687. +
  13688. + If unsure, say Y.
  13689. +
  13690. +if INPUT_MISC
  13691. +
  13692. +config INPUT_88PM860X_ONKEY
  13693. + tristate "88PM860x ONKEY support"
  13694. + depends on MFD_88PM860X
  13695. + help
  13696. + Support the ONKEY of Marvell 88PM860x PMICs as an input device
  13697. + reporting power button status.
  13698. +
  13699. + To compile this driver as a module, choose M here: the module
  13700. + will be called 88pm860x_onkey.
  13701. +
  13702. +config INPUT_AD714X
  13703. + tristate "Analog Devices AD714x Capacitance Touch Sensor"
  13704. + help
  13705. + Say Y here if you want to support an AD7142/3/7/8/7A touch sensor.
  13706. +
  13707. + You should select a bus connection too.
  13708. +
  13709. + To compile this driver as a module, choose M here: the
  13710. + module will be called ad714x.
  13711. +
  13712. +config INPUT_AD714X_I2C
  13713. + tristate "support I2C bus connection"
  13714. + depends on INPUT_AD714X && I2C
  13715. + default y
  13716. + help
  13717. + Say Y here if you have AD7142/AD7147 hooked to an I2C bus.
  13718. +
  13719. + To compile this driver as a module, choose M here: the
  13720. + module will be called ad714x-i2c.
  13721. +
  13722. +config INPUT_AD714X_SPI
  13723. + tristate "support SPI bus connection"
  13724. + depends on INPUT_AD714X && SPI
  13725. + default y
  13726. + help
  13727. + Say Y here if you have AD7142/AD7147 hooked to a SPI bus.
  13728. +
  13729. + To compile this driver as a module, choose M here: the
  13730. + module will be called ad714x-spi.
  13731. +
  13732. +config INPUT_PCSPKR
  13733. + tristate "PC Speaker support"
  13734. + depends on PCSPKR_PLATFORM
  13735. + help
  13736. + Say Y here if you want the standard PC Speaker to be used for
  13737. + bells and whistles.
  13738. +
  13739. + If unsure, say Y.
  13740. +
  13741. + To compile this driver as a module, choose M here: the
  13742. + module will be called pcspkr.
  13743. +
  13744. +config INPUT_SPARCSPKR
  13745. + tristate "SPARC Speaker support"
  13746. + depends on PCI && SPARC64
  13747. + help
  13748. + Say Y here if you want the standard Speaker on Sparc PCI systems
  13749. + to be used for bells and whistles.
  13750. +
  13751. + If unsure, say Y.
  13752. +
  13753. + To compile this driver as a module, choose M here: the
  13754. + module will be called sparcspkr.
  13755. +
  13756. +config INPUT_M68K_BEEP
  13757. + tristate "M68k Beeper support"
  13758. + depends on M68K
  13759. +
  13760. +config INPUT_MAX8925_ONKEY
  13761. + tristate "MAX8925 ONKEY support"
  13762. + depends on MFD_MAX8925
  13763. + help
  13764. + Support the ONKEY of MAX8925 PMICs as an input device
  13765. + reporting power button status.
  13766. +
  13767. + To compile this driver as a module, choose M here: the module
  13768. + will be called max8925_onkey.
  13769. +
  13770. +config INPUT_APANEL
  13771. + tristate "Fujitsu Lifebook Application Panel buttons"
  13772. + depends on X86 && I2C && LEDS_CLASS
  13773. + select INPUT_POLLDEV
  13774. + select CHECK_SIGNATURE
  13775. + help
  13776. + Say Y here for support of the Application Panel buttons, used on
  13777. + Fujitsu Lifebook. These are attached to the mainboard through
  13778. + an SMBus interface managed by the I2C Intel ICH (i801) driver,
  13779. + which you should also build for this kernel.
  13780. +
  13781. + To compile this driver as a module, choose M here: the module will
  13782. + be called apanel.
  13783. +
  13784. +config INPUT_IXP4XX_BEEPER
  13785. + tristate "IXP4XX Beeper support"
  13786. + depends on ARCH_IXP4XX
  13787. + help
  13788. + If you say yes here, you can connect a beeper to the
  13789. + ixp4xx gpio pins. This is used by the LinkSys NSLU2.
  13790. +
  13791. + If unsure, say Y.
  13792. +
  13793. + To compile this driver as a module, choose M here: the
  13794. + module will be called ixp4xx-beeper.
  13795. +
  13796. +config INPUT_COBALT_BTNS
  13797. + tristate "Cobalt button interface"
  13798. + depends on MIPS_COBALT
  13799. + select INPUT_POLLDEV
  13800. + help
  13801. + Say Y here if you want to support MIPS Cobalt button interface.
  13802. +
  13803. + To compile this driver as a module, choose M here: the
  13804. + module will be called cobalt_btns.
  13805. +
  13806. +config INPUT_WISTRON_BTNS
  13807. + tristate "x86 Wistron laptop button interface"
  13808. + depends on X86 && !X86_64
  13809. + select INPUT_POLLDEV
  13810. + select INPUT_SPARSEKMAP
  13811. + select NEW_LEDS
  13812. + select LEDS_CLASS
  13813. + select CHECK_SIGNATURE
  13814. + help
  13815. + Say Y here for support of Wistron laptop button interfaces, used on
  13816. + laptops of various brands, including Acer and Fujitsu-Siemens. If
  13817. + available, mail and wifi LEDs will be controllable via /sys/class/leds.
  13818. +
  13819. + To compile this driver as a module, choose M here: the module will
  13820. + be called wistron_btns.
  13821. +
  13822. +config INPUT_ATLAS_BTNS
  13823. + tristate "x86 Atlas button interface"
  13824. + depends on X86 && ACPI
  13825. + help
  13826. + Say Y here for support of Atlas wallmount touchscreen buttons.
  13827. + The events will show up as scancodes F1 through F9 via evdev.
  13828. +
  13829. + To compile this driver as a module, choose M here: the module will
  13830. + be called atlas_btns.
  13831. +
  13832. +config INPUT_ATI_REMOTE
  13833. + tristate "ATI / X10 USB RF remote control"
  13834. + depends on USB_ARCH_HAS_HCD
  13835. + select USB
  13836. + help
  13837. + Say Y here if you want to use an ATI or X10 "Lola" USB remote control.
  13838. + These are RF remotes with USB receivers.
  13839. + The ATI remote comes with many of ATI's All-In-Wonder video cards.
  13840. + The X10 "Lola" remote is available at:
  13841. + <http://www.x10.com/products/lola_sg1.htm>
  13842. + This driver provides mouse pointer, left and right mouse buttons,
  13843. + and maps all the other remote buttons to keypress events.
  13844. +
  13845. + To compile this driver as a module, choose M here: the module will be
  13846. + called ati_remote.
  13847. +
  13848. +config INPUT_ATI_REMOTE2
  13849. + tristate "ATI / Philips USB RF remote control"
  13850. + depends on USB_ARCH_HAS_HCD
  13851. + select USB
  13852. + help
  13853. + Say Y here if you want to use an ATI or Philips USB RF remote control.
  13854. + These are RF remotes with USB receivers.
  13855. + ATI Remote Wonder II comes with some ATI's All-In-Wonder video cards
  13856. + and is also available as a separate product.
  13857. + This driver provides mouse pointer, left and right mouse buttons,
  13858. + and maps all the other remote buttons to keypress events.
  13859. +
  13860. + To compile this driver as a module, choose M here: the module will be
  13861. + called ati_remote2.
  13862. +
  13863. +config INPUT_KEYSPAN_REMOTE
  13864. + tristate "Keyspan DMR USB remote control (EXPERIMENTAL)"
  13865. + depends on EXPERIMENTAL
  13866. + depends on USB_ARCH_HAS_HCD
  13867. + select USB
  13868. + help
  13869. + Say Y here if you want to use a Keyspan DMR USB remote control.
  13870. + Currently only the UIA-11 type of receiver has been tested. The tag
  13871. + on the receiver that connects to the USB port should have a P/N that
  13872. + will tell you what type of DMR you have. The UIA-10 type is not
  13873. + supported at this time. This driver maps all buttons to keypress
  13874. + events.
  13875. +
  13876. + To compile this driver as a module, choose M here: the module will
  13877. + be called keyspan_remote.
  13878. +
  13879. +config INPUT_POWERMATE
  13880. + tristate "Griffin PowerMate and Contour Jog support"
  13881. + depends on USB_ARCH_HAS_HCD
  13882. + select USB
  13883. + help
  13884. + Say Y here if you want to use Griffin PowerMate or Contour Jog devices.
  13885. + These are aluminum dials which can measure clockwise and anticlockwise
  13886. + rotation. The dial also acts as a pushbutton. The base contains an LED
  13887. + which can be instructed to pulse or to switch to a particular intensity.
  13888. +
  13889. + You can download userspace tools from
  13890. + <http://sowerbutts.com/powermate/>.
  13891. +
  13892. + To compile this driver as a module, choose M here: the
  13893. + module will be called powermate.
  13894. +
  13895. +config INPUT_YEALINK
  13896. + tristate "Yealink usb-p1k voip phone"
  13897. + depends on EXPERIMENTAL
  13898. + depends on USB_ARCH_HAS_HCD
  13899. + select USB
  13900. + help
  13901. + Say Y here if you want to enable keyboard and LCD functions of the
  13902. + Yealink usb-p1k usb phones. The audio part is enabled by the generic
  13903. + usb sound driver, so you might want to enable that as well.
  13904. +
  13905. + For information about how to use these additional functions, see
  13906. + <file:Documentation/input/yealink.txt>.
  13907. +
  13908. + To compile this driver as a module, choose M here: the module will be
  13909. + called yealink.
  13910. +
  13911. +config INPUT_CM109
  13912. + tristate "C-Media CM109 USB I/O Controller"
  13913. + depends on EXPERIMENTAL
  13914. + depends on USB_ARCH_HAS_HCD
  13915. + select USB
  13916. + help
  13917. + Say Y here if you want to enable keyboard and buzzer functions of the
  13918. + C-Media CM109 usb phones. The audio part is enabled by the generic
  13919. + usb sound driver, so you might want to enable that as well.
  13920. +
  13921. + To compile this driver as a module, choose M here: the module will be
  13922. + called cm109.
  13923. +
  13924. +config INPUT_TWL4030_PWRBUTTON
  13925. + tristate "TWL4030 Power button Driver"
  13926. + depends on TWL4030_CORE
  13927. + help
  13928. + Say Y here if you want to enable power key reporting via the
  13929. + TWL4030 family of chips.
  13930. +
  13931. + To compile this driver as a module, choose M here. The module will
  13932. + be called twl4030_pwrbutton.
  13933. +
  13934. +config INPUT_TWL4030_VIBRA
  13935. + tristate "Support for TWL4030 Vibrator"
  13936. + depends on TWL4030_CORE
  13937. + select TWL4030_CODEC
  13938. + select INPUT_FF_MEMLESS
  13939. + help
  13940. + This option enables support for TWL4030 Vibrator Driver.
  13941. +
  13942. + To compile this driver as a module, choose M here. The module will
  13943. + be called twl4030_vibra.
  13944. +
  13945. +config INPUT_UINPUT
  13946. + tristate "User level driver support"
  13947. + help
  13948. + Say Y here if you want to support user level drivers for input
  13949. + subsystem accessible under char device 10:223 - /dev/input/uinput.
  13950. +
  13951. + To compile this driver as a module, choose M here: the
  13952. + module will be called uinput.
  13953. +
  13954. +config INPUT_SGI_BTNS
  13955. + tristate "SGI Indy/O2 volume button interface"
  13956. + depends on SGI_IP22 || SGI_IP32
  13957. + select INPUT_POLLDEV
  13958. + help
  13959. + Say Y here if you want to support SGI Indy/O2 volume button interface.
  13960. +
  13961. + To compile this driver as a module, choose M here: the
  13962. + module will be called sgi_btns.
  13963. +
  13964. +config INPUT_WINBOND_CIR
  13965. + tristate "Winbond IR remote control"
  13966. + depends on X86 && PNP
  13967. + select NEW_LEDS
  13968. + select LEDS_CLASS
  13969. + select LEDS_TRIGGERS
  13970. + select BITREVERSE
  13971. + help
  13972. + Say Y here if you want to use the IR remote functionality found
  13973. + in some Winbond SuperI/O chips. Currently only the WPCD376I
  13974. + chip is supported (included in some Intel Media series motherboards).
  13975. +
  13976. + IR Receive and wake-on-IR from suspend and power-off is currently
  13977. + supported.
  13978. +
  13979. + To compile this driver as a module, choose M here: the module will be
  13980. + called winbond_cir.
  13981. +
  13982. +config HP_SDC_RTC
  13983. + tristate "HP SDC Real Time Clock"
  13984. + depends on (GSC || HP300) && SERIO
  13985. + select HP_SDC
  13986. + help
  13987. + Say Y here if you want to support the built-in real time clock
  13988. + of the HP SDC controller.
  13989. +
  13990. +config INPUT_PCF50633_PMU
  13991. + tristate "PCF50633 PMU events"
  13992. + depends on MFD_PCF50633
  13993. + help
  13994. + Say Y to include support for delivering PMU events via input
  13995. + layer on NXP PCF50633.
  13996. +
  13997. +config INPUT_PCF8574
  13998. + tristate "PCF8574 Keypad input device"
  13999. + depends on I2C && EXPERIMENTAL
  14000. + help
  14001. + Say Y here if you want to support a keypad connetced via I2C
  14002. + with a PCF8574.
  14003. +
  14004. + To compile this driver as a module, choose M here: the
  14005. + module will be called pcf8574_keypad.
  14006. +
  14007. +config INPUT_GPIO_ROTARY_ENCODER
  14008. + tristate "Rotary encoders connected to GPIO pins"
  14009. + depends on GPIOLIB && GENERIC_GPIO
  14010. + help
  14011. + Say Y here to add support for rotary encoders connected to GPIO lines.
  14012. + Check file:Documentation/input/rotary-encoder.txt for more
  14013. + information.
  14014. +
  14015. + To compile this driver as a module, choose M here: the
  14016. + module will be called rotary_encoder.
  14017. +
  14018. +config INPUT_RB532_BUTTON
  14019. + tristate "Mikrotik Routerboard 532 button interface"
  14020. + depends on MIKROTIK_RB532
  14021. + depends on GPIOLIB && GENERIC_GPIO
  14022. + select INPUT_POLLDEV
  14023. + help
  14024. + Say Y here if you want support for the S1 button built into
  14025. + Mikrotik's Routerboard 532.
  14026. +
  14027. + To compile this driver as a module, choose M here: the
  14028. + module will be called rb532_button.
  14029. +
  14030. +config INPUT_DM355EVM
  14031. + tristate "TI DaVinci DM355 EVM Keypad and IR Remote"
  14032. + depends on MFD_DM355EVM_MSP
  14033. + select INPUT_SPARSEKMAP
  14034. + help
  14035. + Supports the pushbuttons and IR remote used with
  14036. + the DM355 EVM board.
  14037. +
  14038. + To compile this driver as a module, choose M here: the
  14039. + module will be called dm355evm_keys.
  14040. +
  14041. +config INPUT_BFIN_ROTARY
  14042. + tristate "Blackfin Rotary support"
  14043. + depends on BF54x || BF52x
  14044. + help
  14045. + Say Y here if you want to use the Blackfin Rotary.
  14046. +
  14047. + To compile this driver as a module, choose M here: the
  14048. + module will be called bfin-rotary.
  14049. +
  14050. +config INPUT_WM831X_ON
  14051. + tristate "WM831X ON pin"
  14052. + depends on MFD_WM831X
  14053. + help
  14054. + Support the ON pin of WM831X PMICs as an input device
  14055. + reporting power button status.
  14056. +
  14057. + To compile this driver as a module, choose M here: the module
  14058. + will be called wm831x_on.
  14059. +
  14060. +config INPUT_PCAP
  14061. + tristate "Motorola EZX PCAP misc input events"
  14062. + depends on EZX_PCAP
  14063. + help
  14064. + Say Y here if you want to use Power key and Headphone button
  14065. + on Motorola EZX phones.
  14066. +
  14067. + To compile this driver as a module, choose M here: the
  14068. + module will be called pcap_keys.
  14069. +
  14070. +endif
  14071. diff -Nur linux-2.6.35.7.orig/drivers/input/misc/Makefile linux-2.6.35.7/drivers/input/misc/Makefile
  14072. --- linux-2.6.35.7.orig/drivers/input/misc/Makefile 2010-09-29 03:09:08.000000000 +0200
  14073. +++ linux-2.6.35.7/drivers/input/misc/Makefile 2010-10-14 20:28:00.038101118 +0200
  14074. @@ -37,4 +37,5 @@
  14075. obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
  14076. obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o
  14077. obj-$(CONFIG_INPUT_YEALINK) += yealink.o
  14078. +obj-$(CONFIG_INPUT_GPIO_BUTTONS) += gpio_buttons.o
  14079. diff -Nur linux-2.6.35.7.orig/drivers/input/misc/Makefile.orig linux-2.6.35.7/drivers/input/misc/Makefile.orig
  14080. --- linux-2.6.35.7.orig/drivers/input/misc/Makefile.orig 1970-01-01 01:00:00.000000000 +0100
  14081. +++ linux-2.6.35.7/drivers/input/misc/Makefile.orig 2010-09-29 03:09:08.000000000 +0200
  14082. @@ -0,0 +1,40 @@
  14083. +#
  14084. +# Makefile for the input misc drivers.
  14085. +#
  14086. +
  14087. +# Each configuration option enables a list of files.
  14088. +
  14089. +obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o
  14090. +obj-$(CONFIG_INPUT_AD714X) += ad714x.o
  14091. +obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o
  14092. +obj-$(CONFIG_INPUT_AD714X_SPI) += ad714x-spi.o
  14093. +obj-$(CONFIG_INPUT_APANEL) += apanel.o
  14094. +obj-$(CONFIG_INPUT_ATI_REMOTE) += ati_remote.o
  14095. +obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o
  14096. +obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
  14097. +obj-$(CONFIG_INPUT_BFIN_ROTARY) += bfin_rotary.o
  14098. +obj-$(CONFIG_INPUT_CM109) += cm109.o
  14099. +obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o
  14100. +obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o
  14101. +obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
  14102. +obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o
  14103. +obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o
  14104. +obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o
  14105. +obj-$(CONFIG_INPUT_MAX8925_ONKEY) += max8925_onkey.o
  14106. +obj-$(CONFIG_INPUT_PCAP) += pcap_keys.o
  14107. +obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o
  14108. +obj-$(CONFIG_INPUT_PCF8574) += pcf8574_keypad.o
  14109. +obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o
  14110. +obj-$(CONFIG_INPUT_POWERMATE) += powermate.o
  14111. +obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o
  14112. +obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o
  14113. +obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
  14114. +obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o
  14115. +obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o
  14116. +obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o
  14117. +obj-$(CONFIG_INPUT_UINPUT) += uinput.o
  14118. +obj-$(CONFIG_INPUT_WINBOND_CIR) += winbond-cir.o
  14119. +obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
  14120. +obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o
  14121. +obj-$(CONFIG_INPUT_YEALINK) += yealink.o
  14122. +
  14123. diff -Nur linux-2.6.35.7.orig/drivers/leds/leds-rb750.c linux-2.6.35.7/drivers/leds/leds-rb750.c
  14124. --- linux-2.6.35.7.orig/drivers/leds/leds-rb750.c 1970-01-01 01:00:00.000000000 +0100
  14125. +++ linux-2.6.35.7/drivers/leds/leds-rb750.c 2010-10-14 20:28:00.074930320 +0200
  14126. @@ -0,0 +1,140 @@
  14127. +/*
  14128. + * LED driver for the RouterBOARD 750
  14129. + *
  14130. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  14131. + *
  14132. + * This program is free software; you can redistribute it and/or modify
  14133. + * it under the terms of the GNU General Public License version 2 as
  14134. + * published by the Free Software Foundation.
  14135. + *
  14136. + */
  14137. +#include <linux/kernel.h>
  14138. +#include <linux/init.h>
  14139. +#include <linux/platform_device.h>
  14140. +#include <linux/leds.h>
  14141. +
  14142. +#include <asm/mach-ar71xx/mach-rb750.h>
  14143. +
  14144. +#define DRV_NAME "leds-rb750"
  14145. +
  14146. +struct rb750_led_dev {
  14147. + struct led_classdev cdev;
  14148. + u32 mask;
  14149. + int active_low;
  14150. +};
  14151. +
  14152. +struct rb750_led_drvdata {
  14153. + struct rb750_led_dev *led_devs;
  14154. + int num_leds;
  14155. +};
  14156. +
  14157. +static inline struct rb750_led_dev *to_rbled(struct led_classdev *led_cdev)
  14158. +{
  14159. + return (struct rb750_led_dev *)container_of(led_cdev,
  14160. + struct rb750_led_dev, cdev);
  14161. +}
  14162. +
  14163. +static void rb750_led_brightness_set(struct led_classdev *led_cdev,
  14164. + enum led_brightness value)
  14165. +{
  14166. + struct rb750_led_dev *rbled = to_rbled(led_cdev);
  14167. + int level;
  14168. +
  14169. + level = (value == LED_OFF) ? 0 : 1;
  14170. + level ^= rbled->active_low;
  14171. +
  14172. + if (level)
  14173. + rb750_latch_change(0, rbled->mask);
  14174. + else
  14175. + rb750_latch_change(rbled->mask, 0);
  14176. +}
  14177. +
  14178. +static int __devinit rb750_led_probe(struct platform_device *pdev)
  14179. +{
  14180. + struct rb750_led_platform_data *pdata;
  14181. + struct rb750_led_drvdata *drvdata;
  14182. + int ret = 0;
  14183. + int i;
  14184. +
  14185. + pdata = pdev->dev.platform_data;
  14186. + if (!pdata)
  14187. + return -EINVAL;
  14188. +
  14189. + drvdata = kzalloc(sizeof(struct rb750_led_drvdata) +
  14190. + sizeof(struct rb750_led_dev) * pdata->num_leds,
  14191. + GFP_KERNEL);
  14192. + if (!drvdata)
  14193. + return -ENOMEM;
  14194. +
  14195. + drvdata->num_leds = pdata->num_leds;
  14196. + drvdata->led_devs = (struct rb750_led_dev *) &drvdata[1];
  14197. +
  14198. + for (i = 0; i < drvdata->num_leds; i++) {
  14199. + struct rb750_led_dev *rbled = &drvdata->led_devs[i];
  14200. + struct rb750_led_data *led_data = &pdata->leds[i];
  14201. +
  14202. + rbled->cdev.name = led_data->name;
  14203. + rbled->cdev.default_trigger = led_data->default_trigger;
  14204. + rbled->cdev.brightness_set = rb750_led_brightness_set;
  14205. + rbled->cdev.brightness = LED_OFF;
  14206. +
  14207. + rbled->mask = led_data->mask;
  14208. + rbled->active_low = !!led_data->active_low;
  14209. +
  14210. + ret = led_classdev_register(&pdev->dev, &rbled->cdev);
  14211. + if (ret)
  14212. + goto err;
  14213. + }
  14214. +
  14215. + platform_set_drvdata(pdev, drvdata);
  14216. + return 0;
  14217. +
  14218. + err:
  14219. + for (i = i - 1; i >= 0; i--)
  14220. + led_classdev_unregister(&drvdata->led_devs[i].cdev);
  14221. +
  14222. + kfree(drvdata);
  14223. + return ret;
  14224. +}
  14225. +
  14226. +static int __devexit rb750_led_remove(struct platform_device *pdev)
  14227. +{
  14228. + struct rb750_led_drvdata *drvdata;
  14229. + int i;
  14230. +
  14231. + drvdata = platform_get_drvdata(pdev);
  14232. + for (i = 0; i < drvdata->num_leds; i++)
  14233. + led_classdev_unregister(&drvdata->led_devs[i].cdev);
  14234. +
  14235. + kfree(drvdata);
  14236. + return 0;
  14237. +}
  14238. +
  14239. +static struct platform_driver rb750_led_driver = {
  14240. + .probe = rb750_led_probe,
  14241. + .remove = __devexit_p(rb750_led_remove),
  14242. + .driver = {
  14243. + .name = DRV_NAME,
  14244. + .owner = THIS_MODULE,
  14245. + },
  14246. +};
  14247. +
  14248. +MODULE_ALIAS("platform:leds-rb750");
  14249. +
  14250. +static int __init rb750_led_init(void)
  14251. +{
  14252. + return platform_driver_register(&rb750_led_driver);
  14253. +}
  14254. +
  14255. +static void __exit rb750_led_exit(void)
  14256. +{
  14257. + platform_driver_unregister(&rb750_led_driver);
  14258. +}
  14259. +
  14260. +module_init(rb750_led_init);
  14261. +module_exit(rb750_led_exit);
  14262. +
  14263. +MODULE_DESCRIPTION(DRV_NAME);
  14264. +MODULE_DESCRIPTION("LED driver for the RouterBOARD 750");
  14265. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  14266. +MODULE_LICENSE("GPL v2");
  14267. diff -Nur linux-2.6.35.7.orig/drivers/leds/leds-wndr3700-usb.c linux-2.6.35.7/drivers/leds/leds-wndr3700-usb.c
  14268. --- linux-2.6.35.7.orig/drivers/leds/leds-wndr3700-usb.c 1970-01-01 01:00:00.000000000 +0100
  14269. +++ linux-2.6.35.7/drivers/leds/leds-wndr3700-usb.c 2010-10-14 20:28:00.116443396 +0200
  14270. @@ -0,0 +1,75 @@
  14271. +/*
  14272. + * USB LED driver for the NETGEAR WNDR3700
  14273. + *
  14274. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  14275. + *
  14276. + * This program is free software; you can redistribute it and/or modify it
  14277. + * under the terms of the GNU General Public License version 2 as published
  14278. + * by the Free Software Foundation.
  14279. + */
  14280. +
  14281. +#include <linux/leds.h>
  14282. +#include <linux/module.h>
  14283. +#include <linux/platform_device.h>
  14284. +
  14285. +#include <asm/mach-ar71xx/ar71xx.h>
  14286. +
  14287. +#define DRIVER_NAME "wndr3700-led-usb"
  14288. +
  14289. +static void wndr3700_usb_led_set(struct led_classdev *cdev,
  14290. + enum led_brightness brightness)
  14291. +{
  14292. + if (brightness)
  14293. + ar71xx_device_start(RESET_MODULE_GE1_PHY);
  14294. + else
  14295. + ar71xx_device_stop(RESET_MODULE_GE1_PHY);
  14296. +}
  14297. +
  14298. +static enum led_brightness wndr3700_usb_led_get(struct led_classdev *cdev)
  14299. +{
  14300. + return ar71xx_device_stopped(RESET_MODULE_GE1_PHY) ? LED_OFF : LED_FULL;
  14301. +}
  14302. +
  14303. +static struct led_classdev wndr3700_usb_led = {
  14304. + .name = "wndr3700:green:usb",
  14305. + .brightness_set = wndr3700_usb_led_set,
  14306. + .brightness_get = wndr3700_usb_led_get,
  14307. +};
  14308. +
  14309. +static int __devinit wndr3700_usb_led_probe(struct platform_device *pdev)
  14310. +{
  14311. + return led_classdev_register(&pdev->dev, &wndr3700_usb_led);
  14312. +}
  14313. +
  14314. +static int __devexit wndr3700_usb_led_remove(struct platform_device *pdev)
  14315. +{
  14316. + led_classdev_unregister(&wndr3700_usb_led);
  14317. + return 0;
  14318. +}
  14319. +
  14320. +static struct platform_driver wndr3700_usb_led_driver = {
  14321. + .probe = wndr3700_usb_led_probe,
  14322. + .remove = __devexit_p(wndr3700_usb_led_remove),
  14323. + .driver = {
  14324. + .name = DRIVER_NAME,
  14325. + .owner = THIS_MODULE,
  14326. + },
  14327. +};
  14328. +
  14329. +static int __init wndr3700_usb_led_init(void)
  14330. +{
  14331. + return platform_driver_register(&wndr3700_usb_led_driver);
  14332. +}
  14333. +
  14334. +static void __exit wndr3700_usb_led_exit(void)
  14335. +{
  14336. + platform_driver_unregister(&wndr3700_usb_led_driver);
  14337. +}
  14338. +
  14339. +module_init(wndr3700_usb_led_init);
  14340. +module_exit(wndr3700_usb_led_exit);
  14341. +
  14342. +MODULE_DESCRIPTION("USB LED driver for the NETGEAR WNDR3700");
  14343. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  14344. +MODULE_LICENSE("GPL v2");
  14345. +MODULE_ALIAS("platform:" DRIVER_NAME);
  14346. diff -Nur linux-2.6.35.7.orig/drivers/mtd/maps/ar91xx_flash.c linux-2.6.35.7/drivers/mtd/maps/ar91xx_flash.c
  14347. --- linux-2.6.35.7.orig/drivers/mtd/maps/ar91xx_flash.c 1970-01-01 01:00:00.000000000 +0100
  14348. +++ linux-2.6.35.7/drivers/mtd/maps/ar91xx_flash.c 2010-10-14 20:28:00.154356608 +0200
  14349. @@ -0,0 +1,310 @@
  14350. +/*
  14351. + * Parallel flash driver for the Atheros AR91xx SoC
  14352. + *
  14353. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  14354. + *
  14355. + * This program is free software; you can redistribute it and/or modify
  14356. + * it under the terms of the GNU General Public License version 2 as
  14357. + * published by the Free Software Foundation.
  14358. + *
  14359. + */
  14360. +
  14361. +#include <linux/module.h>
  14362. +#include <linux/types.h>
  14363. +#include <linux/kernel.h>
  14364. +#include <linux/init.h>
  14365. +#include <linux/slab.h>
  14366. +#include <linux/device.h>
  14367. +#include <linux/platform_device.h>
  14368. +#include <linux/mtd/mtd.h>
  14369. +#include <linux/mtd/map.h>
  14370. +#include <linux/mtd/partitions.h>
  14371. +#include <linux/io.h>
  14372. +
  14373. +#include <asm/mach-ar71xx/ar71xx.h>
  14374. +#include <asm/mach-ar71xx/ar91xx_flash.h>
  14375. +
  14376. +#define DRV_NAME "ar91xx-flash"
  14377. +
  14378. +struct ar91xx_flash_info {
  14379. + struct mtd_info *mtd;
  14380. + struct map_info map;
  14381. +#ifdef CONFIG_MTD_PARTITIONS
  14382. + int nr_parts;
  14383. + struct mtd_partition *parts;
  14384. +#endif
  14385. +};
  14386. +
  14387. +static map_word ar91xx_flash_read(struct map_info *map, unsigned long ofs)
  14388. +{
  14389. + map_word val;
  14390. +
  14391. + if (map_bankwidth_is_1(map))
  14392. + val.x[0] = __raw_readb(map->virt + (ofs ^ 3));
  14393. + else if (map_bankwidth_is_2(map))
  14394. + val.x[0] = __raw_readw(map->virt + (ofs ^ 2));
  14395. + else
  14396. + val = map_word_ff(map);
  14397. +
  14398. + return val;
  14399. +}
  14400. +
  14401. +static void ar91xx_flash_write(struct map_info *map, map_word d,
  14402. + unsigned long ofs)
  14403. +{
  14404. + if (map_bankwidth_is_1(map))
  14405. + __raw_writeb(d.x[0], map->virt + (ofs ^ 3));
  14406. + else if (map_bankwidth_is_2(map))
  14407. + __raw_writew(d.x[0], map->virt + (ofs ^ 2));
  14408. +
  14409. + mb();
  14410. +}
  14411. +
  14412. +static map_word ar91xx_flash_read_lock(struct map_info *map, unsigned long ofs)
  14413. +{
  14414. + map_word ret;
  14415. +
  14416. + ar71xx_flash_acquire();
  14417. + ret = ar91xx_flash_read(map, ofs);
  14418. + ar71xx_flash_release();
  14419. +
  14420. + return ret;
  14421. +}
  14422. +
  14423. +static void ar91xx_flash_write_lock(struct map_info *map, map_word d,
  14424. + unsigned long ofs)
  14425. +{
  14426. + ar71xx_flash_acquire();
  14427. + ar91xx_flash_write(map, d, ofs);
  14428. + ar71xx_flash_release();
  14429. +}
  14430. +
  14431. +static void ar91xx_flash_copy_from_lock(struct map_info *map, void *to,
  14432. + unsigned long from, ssize_t len)
  14433. +{
  14434. + ar71xx_flash_acquire();
  14435. + inline_map_copy_from(map, to, from, len);
  14436. + ar71xx_flash_release();
  14437. +}
  14438. +
  14439. +static void ar91xx_flash_copy_to_lock(struct map_info *map, unsigned long to,
  14440. + const void *from, ssize_t len)
  14441. +{
  14442. + ar71xx_flash_acquire();
  14443. + inline_map_copy_to(map, to, from, len);
  14444. + ar71xx_flash_release();
  14445. +}
  14446. +
  14447. +static int ar91xx_flash_remove(struct platform_device *pdev)
  14448. +{
  14449. + struct ar91xx_flash_platform_data *pdata;
  14450. + struct ar91xx_flash_info *info;
  14451. +
  14452. + info = platform_get_drvdata(pdev);
  14453. + if (info == NULL)
  14454. + return 0;
  14455. +
  14456. + platform_set_drvdata(pdev, NULL);
  14457. +
  14458. + if (info->mtd == NULL)
  14459. + return 0;
  14460. +
  14461. + pdata = pdev->dev.platform_data;
  14462. +#ifdef CONFIG_MTD_PARTITIONS
  14463. + if (info->nr_parts) {
  14464. + del_mtd_partitions(info->mtd);
  14465. + kfree(info->parts);
  14466. + } else if (pdata->nr_parts) {
  14467. + del_mtd_partitions(info->mtd);
  14468. + } else {
  14469. + del_mtd_device(info->mtd);
  14470. + }
  14471. +#else
  14472. + del_mtd_device(info->mtd);
  14473. +#endif
  14474. + map_destroy(info->mtd);
  14475. +
  14476. + return 0;
  14477. +}
  14478. +
  14479. +static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL };
  14480. +#ifdef CONFIG_MTD_PARTITIONS
  14481. +static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL };
  14482. +#endif
  14483. +
  14484. +static int ar91xx_flash_probe(struct platform_device *pdev)
  14485. +{
  14486. + struct ar91xx_flash_platform_data *pdata;
  14487. + struct ar91xx_flash_info *info;
  14488. + struct resource *res;
  14489. + struct resource *region;
  14490. + const char **probe_type;
  14491. + int err = 0;
  14492. +
  14493. + pdata = pdev->dev.platform_data;
  14494. + if (pdata == NULL)
  14495. + return -EINVAL;
  14496. +
  14497. + info = devm_kzalloc(&pdev->dev, sizeof(struct ar91xx_flash_info),
  14498. + GFP_KERNEL);
  14499. + if (info == NULL) {
  14500. + err = -ENOMEM;
  14501. + goto err_out;
  14502. + }
  14503. +
  14504. + platform_set_drvdata(pdev, info);
  14505. +
  14506. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  14507. + if (res == NULL) {
  14508. + err = -ENOENT;
  14509. + goto err_out;
  14510. + }
  14511. +
  14512. + dev_info(&pdev->dev, "%.8llx at %.8llx\n",
  14513. + (unsigned long long)(res->end - res->start + 1),
  14514. + (unsigned long long)res->start);
  14515. +
  14516. + region = devm_request_mem_region(&pdev->dev,
  14517. + res->start, res->end - res->start + 1,
  14518. + dev_name(&pdev->dev));
  14519. + if (region == NULL) {
  14520. + dev_err(&pdev->dev, "could not reserve memory region\n");
  14521. + err = -ENOMEM;
  14522. + goto err_out;
  14523. + }
  14524. +
  14525. + info->map.name = dev_name(&pdev->dev);
  14526. + info->map.phys = res->start;
  14527. + info->map.size = res->end - res->start + 1;
  14528. + info->map.bankwidth = pdata->width;
  14529. +
  14530. + info->map.virt = devm_ioremap(&pdev->dev, info->map.phys,
  14531. + info->map.size);
  14532. + if (info->map.virt == NULL) {
  14533. + dev_err(&pdev->dev, "failed to ioremap flash region\n");
  14534. + err = -EIO;
  14535. + goto err_out;
  14536. + }
  14537. +
  14538. + simple_map_init(&info->map);
  14539. + if (pdata->is_shared) {
  14540. + info->map.read = ar91xx_flash_read_lock;
  14541. + info->map.write = ar91xx_flash_write_lock;
  14542. + info->map.copy_from = ar91xx_flash_copy_from_lock;
  14543. + info->map.copy_to = ar91xx_flash_copy_to_lock;
  14544. + } else {
  14545. + info->map.read = ar91xx_flash_read;
  14546. + info->map.write = ar91xx_flash_write;
  14547. + }
  14548. +
  14549. + probe_type = rom_probe_types;
  14550. + for (; info->mtd == NULL && *probe_type != NULL; probe_type++)
  14551. + info->mtd = do_map_probe(*probe_type, &info->map);
  14552. +
  14553. + if (info->mtd == NULL) {
  14554. + dev_err(&pdev->dev, "map_probe failed\n");
  14555. + err = -ENXIO;
  14556. + goto err_out;
  14557. + }
  14558. +
  14559. + info->mtd->owner = THIS_MODULE;
  14560. +
  14561. +#ifdef CONFIG_MTD_PARTITIONS
  14562. + if (pdata->nr_parts) {
  14563. + dev_info(&pdev->dev, "using static partition mapping\n");
  14564. + add_mtd_partitions(info->mtd, pdata->parts, pdata->nr_parts);
  14565. + return 0;
  14566. + }
  14567. +
  14568. + err = parse_mtd_partitions(info->mtd, part_probe_types,
  14569. + &info->parts, 0);
  14570. + if (err > 0) {
  14571. + add_mtd_partitions(info->mtd, info->parts, err);
  14572. + return 0;
  14573. + }
  14574. +#endif
  14575. +
  14576. + add_mtd_device(info->mtd);
  14577. + return 0;
  14578. +
  14579. + err_out:
  14580. + ar91xx_flash_remove(pdev);
  14581. + return err;
  14582. +}
  14583. +
  14584. +#ifdef CONFIG_PM
  14585. +static int ar91xx_flash_suspend(struct platform_device *dev, pm_message_t state)
  14586. +{
  14587. + struct ar91xx_flash_info *info = platform_get_drvdata(dev);
  14588. + int ret = 0;
  14589. +
  14590. + if (info->mtd->suspend)
  14591. + ret = info->mtd->suspend(info->mtd);
  14592. +
  14593. + if (ret)
  14594. + goto fail;
  14595. +
  14596. + return 0;
  14597. +
  14598. + fail:
  14599. + if (info->mtd->suspend) {
  14600. + BUG_ON(!info->mtd->resume);
  14601. + info->mtd->resume(info->mtd);
  14602. + }
  14603. +
  14604. + return ret;
  14605. +}
  14606. +
  14607. +static int ar91xx_flash_resume(struct platform_device *pdev)
  14608. +{
  14609. + struct ar91xx_flash_info *info = platform_get_drvdata(pdev);
  14610. +
  14611. + if (info->mtd->resume)
  14612. + info->mtd->resume(info->mtd);
  14613. +
  14614. + return 0;
  14615. +}
  14616. +
  14617. +static void ar91xx_flash_shutdown(struct platform_device *pdev)
  14618. +{
  14619. + struct ar91xx_flash_info *info = platform_get_drvdata(pdev);
  14620. +
  14621. + if (info->mtd->suspend && info->mtd->resume)
  14622. + if (info->mtd->suspend(info->mtd) == 0)
  14623. + info->mtd->resume(info->mtd);
  14624. +}
  14625. +#else
  14626. +#define ar91xx_flash_suspend NULL
  14627. +#define ar91xx_flash_resume NULL
  14628. +#define ar91xx_flash_shutdown NULL
  14629. +#endif
  14630. +
  14631. +static struct platform_driver ar91xx_flash_driver = {
  14632. + .probe = ar91xx_flash_probe,
  14633. + .remove = ar91xx_flash_remove,
  14634. + .suspend = ar91xx_flash_suspend,
  14635. + .resume = ar91xx_flash_resume,
  14636. + .shutdown = ar91xx_flash_shutdown,
  14637. + .driver = {
  14638. + .name = DRV_NAME,
  14639. + .owner = THIS_MODULE,
  14640. + },
  14641. +};
  14642. +
  14643. +static int __init ar91xx_flash_init(void)
  14644. +{
  14645. + return platform_driver_register(&ar91xx_flash_driver);
  14646. +}
  14647. +
  14648. +static void __exit ar91xx_flash_exit(void)
  14649. +{
  14650. + platform_driver_unregister(&ar91xx_flash_driver);
  14651. +}
  14652. +
  14653. +module_init(ar91xx_flash_init);
  14654. +module_exit(ar91xx_flash_exit);
  14655. +
  14656. +MODULE_LICENSE("GPL v2");
  14657. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  14658. +MODULE_DESCRIPTION("Parallel flash driver for the Atheros AR91xx SoC");
  14659. +MODULE_ALIAS("platform:" DRV_NAME);
  14660. diff -Nur linux-2.6.35.7.orig/drivers/mtd/maps/Kconfig linux-2.6.35.7/drivers/mtd/maps/Kconfig
  14661. --- linux-2.6.35.7.orig/drivers/mtd/maps/Kconfig 2010-09-29 03:09:08.000000000 +0200
  14662. +++ linux-2.6.35.7/drivers/mtd/maps/Kconfig 2010-10-14 20:28:00.198101134 +0200
  14663. @@ -251,6 +251,13 @@
  14664. help
  14665. Support for flash chips on NETtel/SecureEdge/SnapGear boards.
  14666. +config MTD_AR91XX_FLASH
  14667. + tristate "Atheros AR91xx parallel flash support"
  14668. + depends on ATHEROS_AR71XX
  14669. + select MTD_COMPLEX_MAPPINGS
  14670. + help
  14671. + Parallel flash driver for the Atheros AR91xx based boards.
  14672. +
  14673. config MTD_DILNETPC
  14674. tristate "CFI Flash device mapped on DIL/Net PC"
  14675. depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT && BROKEN
  14676. diff -Nur linux-2.6.35.7.orig/drivers/mtd/maps/Makefile linux-2.6.35.7/drivers/mtd/maps/Makefile
  14677. --- linux-2.6.35.7.orig/drivers/mtd/maps/Makefile 2010-09-29 03:09:08.000000000 +0200
  14678. +++ linux-2.6.35.7/drivers/mtd/maps/Makefile 2010-10-14 20:28:00.238101165 +0200
  14679. @@ -7,6 +7,7 @@
  14680. endif
  14681. # Chip mappings
  14682. +obj-$(CONFIG_MTD_AR91XX_FLASH) += ar91xx_flash.o
  14683. obj-$(CONFIG_MTD_CDB89712) += cdb89712.o
  14684. obj-$(CONFIG_MTD_ARM_INTEGRATOR)+= integrator-flash.o
  14685. obj-$(CONFIG_MTD_CFI_FLAGADM) += cfi_flagadm.o
  14686. diff -Nur linux-2.6.35.7.orig/drivers/mtd/nand/Kconfig linux-2.6.35.7/drivers/mtd/nand/Kconfig
  14687. --- linux-2.6.35.7.orig/drivers/mtd/nand/Kconfig 2010-09-29 03:09:08.000000000 +0200
  14688. +++ linux-2.6.35.7/drivers/mtd/nand/Kconfig 2010-10-14 20:28:00.288101273 +0200
  14689. @@ -526,4 +526,8 @@
  14690. This enables the driver for the NAND Flash on evaluation board based
  14691. on w90p910 / NUC9xx.
  14692. +config MTD_NAND_RB4XX
  14693. + tristate "NAND flash driver for RouterBoard 4xx series"
  14694. + depends on MTD_NAND && AR71XX_MACH_RB4XX
  14695. +
  14696. endif # MTD_NAND
  14697. diff -Nur linux-2.6.35.7.orig/drivers/mtd/nand/Kconfig.orig linux-2.6.35.7/drivers/mtd/nand/Kconfig.orig
  14698. --- linux-2.6.35.7.orig/drivers/mtd/nand/Kconfig.orig 1970-01-01 01:00:00.000000000 +0100
  14699. +++ linux-2.6.35.7/drivers/mtd/nand/Kconfig.orig 2010-09-29 03:09:08.000000000 +0200
  14700. @@ -0,0 +1,529 @@
  14701. +config MTD_NAND_ECC
  14702. + tristate
  14703. +
  14704. +config MTD_NAND_ECC_SMC
  14705. + bool "NAND ECC Smart Media byte order"
  14706. + depends on MTD_NAND_ECC
  14707. + default n
  14708. + help
  14709. + Software ECC according to the Smart Media Specification.
  14710. + The original Linux implementation had byte 0 and 1 swapped.
  14711. +
  14712. +
  14713. +menuconfig MTD_NAND
  14714. + tristate "NAND Device Support"
  14715. + depends on MTD
  14716. + select MTD_NAND_IDS
  14717. + select MTD_NAND_ECC
  14718. + help
  14719. + This enables support for accessing all type of NAND flash
  14720. + devices. For further information see
  14721. + <http://www.linux-mtd.infradead.org/doc/nand.html>.
  14722. +
  14723. +if MTD_NAND
  14724. +
  14725. +config MTD_NAND_VERIFY_WRITE
  14726. + bool "Verify NAND page writes"
  14727. + help
  14728. + This adds an extra check when data is written to the flash. The
  14729. + NAND flash device internally checks only bits transitioning
  14730. + from 1 to 0. There is a rare possibility that even though the
  14731. + device thinks the write was successful, a bit could have been
  14732. + flipped accidentally due to device wear or something else.
  14733. +
  14734. +config MTD_SM_COMMON
  14735. + tristate
  14736. + default n
  14737. +
  14738. +config MTD_NAND_MUSEUM_IDS
  14739. + bool "Enable chip ids for obsolete ancient NAND devices"
  14740. + depends on MTD_NAND
  14741. + default n
  14742. + help
  14743. + Enable this option only when your board has first generation
  14744. + NAND chips (page size 256 byte, erase size 4-8KiB). The IDs
  14745. + of these chips were reused by later, larger chips.
  14746. +
  14747. +config MTD_NAND_AUTCPU12
  14748. + tristate "SmartMediaCard on autronix autcpu12 board"
  14749. + depends on ARCH_AUTCPU12
  14750. + help
  14751. + This enables the driver for the autronix autcpu12 board to
  14752. + access the SmartMediaCard.
  14753. +
  14754. +config MTD_NAND_DENALI
  14755. + depends on PCI
  14756. + tristate "Support Denali NAND controller on Intel Moorestown"
  14757. + help
  14758. + Enable the driver for NAND flash on Intel Moorestown, using the
  14759. + Denali NAND controller core.
  14760. +
  14761. +config MTD_NAND_DENALI_SCRATCH_REG_ADDR
  14762. + hex "Denali NAND size scratch register address"
  14763. + default "0xFF108018"
  14764. + help
  14765. + Some platforms place the NAND chip size in a scratch register
  14766. + because (some versions of) the driver aren't able to automatically
  14767. + determine the size of certain chips. Set the address of the
  14768. + scratch register here to enable this feature. On Intel Moorestown
  14769. + boards, the scratch register is at 0xFF108018.
  14770. +
  14771. +config MTD_NAND_EDB7312
  14772. + tristate "Support for Cirrus Logic EBD7312 evaluation board"
  14773. + depends on ARCH_EDB7312
  14774. + help
  14775. + This enables the driver for the Cirrus Logic EBD7312 evaluation
  14776. + board to access the onboard NAND Flash.
  14777. +
  14778. +config MTD_NAND_H1900
  14779. + tristate "iPAQ H1900 flash"
  14780. + depends on ARCH_PXA && MTD_PARTITIONS
  14781. + help
  14782. + This enables the driver for the iPAQ h1900 flash.
  14783. +
  14784. +config MTD_NAND_GPIO
  14785. + tristate "GPIO NAND Flash driver"
  14786. + depends on GENERIC_GPIO && ARM
  14787. + help
  14788. + This enables a GPIO based NAND flash driver.
  14789. +
  14790. +config MTD_NAND_SPIA
  14791. + tristate "NAND Flash device on SPIA board"
  14792. + depends on ARCH_P720T
  14793. + help
  14794. + If you had to ask, you don't have one. Say 'N'.
  14795. +
  14796. +config MTD_NAND_AMS_DELTA
  14797. + tristate "NAND Flash device on Amstrad E3"
  14798. + depends on MACH_AMS_DELTA
  14799. + help
  14800. + Support for NAND flash on Amstrad E3 (Delta).
  14801. +
  14802. +config MTD_NAND_OMAP2
  14803. + tristate "NAND Flash device on OMAP2 and OMAP3"
  14804. + depends on ARM && MTD_NAND && (ARCH_OMAP2 || ARCH_OMAP3)
  14805. + help
  14806. + Support for NAND flash on Texas Instruments OMAP2 and OMAP3 platforms.
  14807. +
  14808. +config MTD_NAND_OMAP_PREFETCH
  14809. + bool "GPMC prefetch support for NAND Flash device"
  14810. + depends on MTD_NAND && MTD_NAND_OMAP2
  14811. + default y
  14812. + help
  14813. + The NAND device can be accessed for Read/Write using GPMC PREFETCH engine
  14814. + to improve the performance.
  14815. +
  14816. +config MTD_NAND_OMAP_PREFETCH_DMA
  14817. + depends on MTD_NAND_OMAP_PREFETCH
  14818. + bool "DMA mode"
  14819. + default n
  14820. + help
  14821. + The GPMC PREFETCH engine can be configured eigther in MPU interrupt mode
  14822. + or in DMA interrupt mode.
  14823. + Say y for DMA mode or MPU mode will be used
  14824. +
  14825. +config MTD_NAND_IDS
  14826. + tristate
  14827. +
  14828. +config MTD_NAND_RICOH
  14829. + tristate "Ricoh xD card reader"
  14830. + default n
  14831. + depends on PCI
  14832. + select MTD_SM_COMMON
  14833. + help
  14834. + Enable support for Ricoh R5C852 xD card reader
  14835. + You also need to enable ether
  14836. + NAND SSFDC (SmartMedia) read only translation layer' or new
  14837. + expermental, readwrite
  14838. + 'SmartMedia/xD new translation layer'
  14839. +
  14840. +config MTD_NAND_AU1550
  14841. + tristate "Au1550/1200 NAND support"
  14842. + depends on SOC_AU1200 || SOC_AU1550
  14843. + help
  14844. + This enables the driver for the NAND flash controller on the
  14845. + AMD/Alchemy 1550 SOC.
  14846. +
  14847. +config MTD_NAND_BF5XX
  14848. + tristate "Blackfin on-chip NAND Flash Controller driver"
  14849. + depends on (BF54x || BF52x) && MTD_NAND
  14850. + help
  14851. + This enables the Blackfin on-chip NAND flash controller
  14852. +
  14853. + No board specific support is done by this driver, each board
  14854. + must advertise a platform_device for the driver to attach.
  14855. +
  14856. + This driver can also be built as a module. If so, the module
  14857. + will be called bf5xx-nand.
  14858. +
  14859. +config MTD_NAND_BF5XX_HWECC
  14860. + bool "BF5XX NAND Hardware ECC"
  14861. + default y
  14862. + depends on MTD_NAND_BF5XX
  14863. + help
  14864. + Enable the use of the BF5XX's internal ECC generator when
  14865. + using NAND.
  14866. +
  14867. +config MTD_NAND_BF5XX_BOOTROM_ECC
  14868. + bool "Use Blackfin BootROM ECC Layout"
  14869. + default n
  14870. + depends on MTD_NAND_BF5XX_HWECC
  14871. + help
  14872. + If you wish to modify NAND pages and allow the Blackfin on-chip
  14873. + BootROM to boot from them, say Y here. This is only necessary
  14874. + if you are booting U-Boot out of NAND and you wish to update
  14875. + U-Boot from Linux' userspace. Otherwise, you should say N here.
  14876. +
  14877. + If unsure, say N.
  14878. +
  14879. +config MTD_NAND_RTC_FROM4
  14880. + tristate "Renesas Flash ROM 4-slot interface board (FROM_BOARD4)"
  14881. + depends on SH_SOLUTION_ENGINE
  14882. + select REED_SOLOMON
  14883. + select REED_SOLOMON_DEC8
  14884. + select BITREVERSE
  14885. + help
  14886. + This enables the driver for the Renesas Technology AG-AND
  14887. + flash interface board (FROM_BOARD4)
  14888. +
  14889. +config MTD_NAND_PPCHAMELEONEVB
  14890. + tristate "NAND Flash device on PPChameleonEVB board"
  14891. + depends on PPCHAMELEONEVB && BROKEN
  14892. + help
  14893. + This enables the NAND flash driver on the PPChameleon EVB Board.
  14894. +
  14895. +config MTD_NAND_S3C2410
  14896. + tristate "NAND Flash support for Samsung S3C SoCs"
  14897. + depends on ARCH_S3C2410 || ARCH_S3C64XX
  14898. + help
  14899. + This enables the NAND flash controller on the S3C24xx and S3C64xx
  14900. + SoCs
  14901. +
  14902. + No board specific support is done by this driver, each board
  14903. + must advertise a platform_device for the driver to attach.
  14904. +
  14905. +config MTD_NAND_S3C2410_DEBUG
  14906. + bool "Samsung S3C NAND driver debug"
  14907. + depends on MTD_NAND_S3C2410
  14908. + help
  14909. + Enable debugging of the S3C NAND driver
  14910. +
  14911. +config MTD_NAND_S3C2410_HWECC
  14912. + bool "Samsung S3C NAND Hardware ECC"
  14913. + depends on MTD_NAND_S3C2410
  14914. + help
  14915. + Enable the use of the controller's internal ECC generator when
  14916. + using NAND. Early versions of the chips have had problems with
  14917. + incorrect ECC generation, and if using these, the default of
  14918. + software ECC is preferable.
  14919. +
  14920. +config MTD_NAND_NDFC
  14921. + tristate "NDFC NanD Flash Controller"
  14922. + depends on 4xx
  14923. + select MTD_NAND_ECC_SMC
  14924. + help
  14925. + NDFC Nand Flash Controllers are integrated in IBM/AMCC's 4xx SoCs
  14926. +
  14927. +config MTD_NAND_S3C2410_CLKSTOP
  14928. + bool "Samsung S3C NAND IDLE clock stop"
  14929. + depends on MTD_NAND_S3C2410
  14930. + default n
  14931. + help
  14932. + Stop the clock to the NAND controller when there is no chip
  14933. + selected to save power. This will mean there is a small delay
  14934. + when the is NAND chip selected or released, but will save
  14935. + approximately 5mA of power when there is nothing happening.
  14936. +
  14937. +config MTD_NAND_BCM_UMI
  14938. + tristate "NAND Flash support for BCM Reference Boards"
  14939. + depends on ARCH_BCMRING && MTD_NAND
  14940. + help
  14941. + This enables the NAND flash controller on the BCM UMI block.
  14942. +
  14943. + No board specfic support is done by this driver, each board
  14944. + must advertise a platform_device for the driver to attach.
  14945. +
  14946. +config MTD_NAND_BCM_UMI_HWCS
  14947. + bool "BCM UMI NAND Hardware CS"
  14948. + depends on MTD_NAND_BCM_UMI
  14949. + help
  14950. + Enable the use of the BCM UMI block's internal CS using NAND.
  14951. + This should only be used if you know the external NAND CS can toggle.
  14952. +
  14953. +config MTD_NAND_DISKONCHIP
  14954. + tristate "DiskOnChip 2000, Millennium and Millennium Plus (NAND reimplementation) (EXPERIMENTAL)"
  14955. + depends on EXPERIMENTAL
  14956. + select REED_SOLOMON
  14957. + select REED_SOLOMON_DEC16
  14958. + help
  14959. + This is a reimplementation of M-Systems DiskOnChip 2000,
  14960. + Millennium and Millennium Plus as a standard NAND device driver,
  14961. + as opposed to the earlier self-contained MTD device drivers.
  14962. + This should enable, among other things, proper JFFS2 operation on
  14963. + these devices.
  14964. +
  14965. +config MTD_NAND_DISKONCHIP_PROBE_ADVANCED
  14966. + bool "Advanced detection options for DiskOnChip"
  14967. + depends on MTD_NAND_DISKONCHIP
  14968. + help
  14969. + This option allows you to specify nonstandard address at which to
  14970. + probe for a DiskOnChip, or to change the detection options. You
  14971. + are unlikely to need any of this unless you are using LinuxBIOS.
  14972. + Say 'N'.
  14973. +
  14974. +config MTD_NAND_DISKONCHIP_PROBE_ADDRESS
  14975. + hex "Physical address of DiskOnChip" if MTD_NAND_DISKONCHIP_PROBE_ADVANCED
  14976. + depends on MTD_NAND_DISKONCHIP
  14977. + default "0"
  14978. + ---help---
  14979. + By default, the probe for DiskOnChip devices will look for a
  14980. + DiskOnChip at every multiple of 0x2000 between 0xC8000 and 0xEE000.
  14981. + This option allows you to specify a single address at which to probe
  14982. + for the device, which is useful if you have other devices in that
  14983. + range which get upset when they are probed.
  14984. +
  14985. + (Note that on PowerPC, the normal probe will only check at
  14986. + 0xE4000000.)
  14987. +
  14988. + Normally, you should leave this set to zero, to allow the probe at
  14989. + the normal addresses.
  14990. +
  14991. +config MTD_NAND_DISKONCHIP_PROBE_HIGH
  14992. + bool "Probe high addresses"
  14993. + depends on MTD_NAND_DISKONCHIP_PROBE_ADVANCED
  14994. + help
  14995. + By default, the probe for DiskOnChip devices will look for a
  14996. + DiskOnChip at every multiple of 0x2000 between 0xC8000 and 0xEE000.
  14997. + This option changes to make it probe between 0xFFFC8000 and
  14998. + 0xFFFEE000. Unless you are using LinuxBIOS, this is unlikely to be
  14999. + useful to you. Say 'N'.
  15000. +
  15001. +config MTD_NAND_DISKONCHIP_BBTWRITE
  15002. + bool "Allow BBT writes on DiskOnChip Millennium and 2000TSOP"
  15003. + depends on MTD_NAND_DISKONCHIP
  15004. + help
  15005. + On DiskOnChip devices shipped with the INFTL filesystem (Millennium
  15006. + and 2000 TSOP/Alon), Linux reserves some space at the end of the
  15007. + device for the Bad Block Table (BBT). If you have existing INFTL
  15008. + data on your device (created by non-Linux tools such as M-Systems'
  15009. + DOS drivers), your data might overlap the area Linux wants to use for
  15010. + the BBT. If this is a concern for you, leave this option disabled and
  15011. + Linux will not write BBT data into this area.
  15012. + The downside of leaving this option disabled is that if bad blocks
  15013. + are detected by Linux, they will not be recorded in the BBT, which
  15014. + could cause future problems.
  15015. + Once you enable this option, new filesystems (INFTL or others, created
  15016. + in Linux or other operating systems) will not use the reserved area.
  15017. + The only reason not to enable this option is to prevent damage to
  15018. + preexisting filesystems.
  15019. + Even if you leave this disabled, you can enable BBT writes at module
  15020. + load time (assuming you build diskonchip as a module) with the module
  15021. + parameter "inftl_bbt_write=1".
  15022. +
  15023. +config MTD_NAND_SHARPSL
  15024. + tristate "Support for NAND Flash on Sharp SL Series (C7xx + others)"
  15025. + depends on ARCH_PXA
  15026. +
  15027. +config MTD_NAND_CAFE
  15028. + tristate "NAND support for OLPC CAFÉ chip"
  15029. + depends on PCI
  15030. + select REED_SOLOMON
  15031. + select REED_SOLOMON_DEC16
  15032. + help
  15033. + Use NAND flash attached to the CAFÉ chip designed for the OLPC
  15034. + laptop.
  15035. +
  15036. +config MTD_NAND_CS553X
  15037. + tristate "NAND support for CS5535/CS5536 (AMD Geode companion chip)"
  15038. + depends on X86_32
  15039. + help
  15040. + The CS553x companion chips for the AMD Geode processor
  15041. + include NAND flash controllers with built-in hardware ECC
  15042. + capabilities; enabling this option will allow you to use
  15043. + these. The driver will check the MSRs to verify that the
  15044. + controller is enabled for NAND, and currently requires that
  15045. + the controller be in MMIO mode.
  15046. +
  15047. + If you say "m", the module will be called cs553x_nand.
  15048. +
  15049. +config MTD_NAND_ATMEL
  15050. + tristate "Support for NAND Flash / SmartMedia on AT91 and AVR32"
  15051. + depends on ARCH_AT91 || AVR32
  15052. + help
  15053. + Enables support for NAND Flash / Smart Media Card interface
  15054. + on Atmel AT91 and AVR32 processors.
  15055. +choice
  15056. + prompt "ECC management for NAND Flash / SmartMedia on AT91 / AVR32"
  15057. + depends on MTD_NAND_ATMEL
  15058. +
  15059. +config MTD_NAND_ATMEL_ECC_HW
  15060. + bool "Hardware ECC"
  15061. + depends on ARCH_AT91SAM9263 || ARCH_AT91SAM9260 || AVR32
  15062. + help
  15063. + Use hardware ECC instead of software ECC when the chip
  15064. + supports it.
  15065. +
  15066. + The hardware ECC controller is capable of single bit error
  15067. + correction and 2-bit random detection per page.
  15068. +
  15069. + NB : hardware and software ECC schemes are incompatible.
  15070. + If you switch from one to another, you'll have to erase your
  15071. + mtd partition.
  15072. +
  15073. + If unsure, say Y
  15074. +
  15075. +config MTD_NAND_ATMEL_ECC_SOFT
  15076. + bool "Software ECC"
  15077. + help
  15078. + Use software ECC.
  15079. +
  15080. + NB : hardware and software ECC schemes are incompatible.
  15081. + If you switch from one to another, you'll have to erase your
  15082. + mtd partition.
  15083. +
  15084. +config MTD_NAND_ATMEL_ECC_NONE
  15085. + bool "No ECC (testing only, DANGEROUS)"
  15086. + depends on DEBUG_KERNEL
  15087. + help
  15088. + No ECC will be used.
  15089. + It's not a good idea and it should be reserved for testing
  15090. + purpose only.
  15091. +
  15092. + If unsure, say N
  15093. +
  15094. +endchoice
  15095. +
  15096. +config MTD_NAND_PXA3xx
  15097. + tristate "Support for NAND flash devices on PXA3xx"
  15098. + depends on MTD_NAND && (PXA3xx || ARCH_MMP)
  15099. + help
  15100. + This enables the driver for the NAND flash device found on
  15101. + PXA3xx processors
  15102. +
  15103. +config MTD_NAND_PXA3xx_BUILTIN
  15104. + bool "Use builtin definitions for some NAND chips (deprecated)"
  15105. + depends on MTD_NAND_PXA3xx
  15106. + help
  15107. + This enables builtin definitions for some NAND chips. This
  15108. + is deprecated in favor of platform specific data.
  15109. +
  15110. +config MTD_NAND_CM_X270
  15111. + tristate "Support for NAND Flash on CM-X270 modules"
  15112. + depends on MTD_NAND && MACH_ARMCORE
  15113. +
  15114. +config MTD_NAND_PASEMI
  15115. + tristate "NAND support for PA Semi PWRficient"
  15116. + depends on MTD_NAND && PPC_PASEMI
  15117. + help
  15118. + Enables support for NAND Flash interface on PA Semi PWRficient
  15119. + based boards
  15120. +
  15121. +config MTD_NAND_TMIO
  15122. + tristate "NAND Flash device on Toshiba Mobile IO Controller"
  15123. + depends on MTD_NAND && MFD_TMIO
  15124. + help
  15125. + Support for NAND flash connected to a Toshiba Mobile IO
  15126. + Controller in some PDAs, including the Sharp SL6000x.
  15127. +
  15128. +config MTD_NAND_NANDSIM
  15129. + tristate "Support for NAND Flash Simulator"
  15130. + depends on MTD_PARTITIONS
  15131. + help
  15132. + The simulator may simulate various NAND flash chips for the
  15133. + MTD nand layer.
  15134. +
  15135. +config MTD_NAND_PLATFORM
  15136. + tristate "Support for generic platform NAND driver"
  15137. + depends on MTD_NAND
  15138. + help
  15139. + This implements a generic NAND driver for on-SOC platform
  15140. + devices. You will need to provide platform-specific functions
  15141. + via platform_data.
  15142. +
  15143. +config MTD_ALAUDA
  15144. + tristate "MTD driver for Olympus MAUSB-10 and Fujifilm DPC-R1"
  15145. + depends on MTD_NAND && USB
  15146. + help
  15147. + These two (and possibly other) Alauda-based cardreaders for
  15148. + SmartMedia and xD allow raw flash access.
  15149. +
  15150. +config MTD_NAND_ORION
  15151. + tristate "NAND Flash support for Marvell Orion SoC"
  15152. + depends on PLAT_ORION && MTD_NAND
  15153. + help
  15154. + This enables the NAND flash controller on Orion machines.
  15155. +
  15156. + No board specific support is done by this driver, each board
  15157. + must advertise a platform_device for the driver to attach.
  15158. +
  15159. +config MTD_NAND_FSL_ELBC
  15160. + tristate "NAND support for Freescale eLBC controllers"
  15161. + depends on MTD_NAND && PPC_OF
  15162. + help
  15163. + Various Freescale chips, including the 8313, include a NAND Flash
  15164. + Controller Module with built-in hardware ECC capabilities.
  15165. + Enabling this option will enable you to use this to control
  15166. + external NAND devices.
  15167. +
  15168. +config MTD_NAND_FSL_UPM
  15169. + tristate "Support for NAND on Freescale UPM"
  15170. + depends on MTD_NAND && (PPC_83xx || PPC_85xx)
  15171. + select FSL_LBC
  15172. + help
  15173. + Enables support for NAND Flash chips wired onto Freescale PowerPC
  15174. + processor localbus with User-Programmable Machine support.
  15175. +
  15176. +config MTD_NAND_MPC5121_NFC
  15177. + tristate "MPC5121 built-in NAND Flash Controller support"
  15178. + depends on PPC_MPC512x
  15179. + help
  15180. + This enables the driver for the NAND flash controller on the
  15181. + MPC5121 SoC.
  15182. +
  15183. +config MTD_NAND_MXC
  15184. + tristate "MXC NAND support"
  15185. + depends on ARCH_MX2 || ARCH_MX25 || ARCH_MX3
  15186. + help
  15187. + This enables the driver for the NAND flash controller on the
  15188. + MXC processors.
  15189. +
  15190. +config MTD_NAND_NOMADIK
  15191. + tristate "ST Nomadik 8815 NAND support"
  15192. + depends on ARCH_NOMADIK
  15193. + help
  15194. + Driver for the NAND flash controller on the Nomadik, with ECC.
  15195. +
  15196. +config MTD_NAND_SH_FLCTL
  15197. + tristate "Support for NAND on Renesas SuperH FLCTL"
  15198. + depends on MTD_NAND && (SUPERH || ARCH_SHMOBILE)
  15199. + help
  15200. + Several Renesas SuperH CPU has FLCTL. This option enables support
  15201. + for NAND Flash using FLCTL.
  15202. +
  15203. +config MTD_NAND_DAVINCI
  15204. + tristate "Support NAND on DaVinci SoC"
  15205. + depends on ARCH_DAVINCI
  15206. + help
  15207. + Enable the driver for NAND flash chips on Texas Instruments
  15208. + DaVinci processors.
  15209. +
  15210. +config MTD_NAND_TXX9NDFMC
  15211. + tristate "NAND Flash support for TXx9 SoC"
  15212. + depends on SOC_TX4938 || SOC_TX4939
  15213. + help
  15214. + This enables the NAND flash controller on the TXx9 SoCs.
  15215. +
  15216. +config MTD_NAND_SOCRATES
  15217. + tristate "Support for NAND on Socrates board"
  15218. + depends on MTD_NAND && SOCRATES
  15219. + help
  15220. + Enables support for NAND Flash chips wired onto Socrates board.
  15221. +
  15222. +config MTD_NAND_NUC900
  15223. + tristate "Support for NAND on Nuvoton NUC9xx/w90p910 evaluation boards."
  15224. + depends on ARCH_W90X900 && MTD_PARTITIONS
  15225. + help
  15226. + This enables the driver for the NAND Flash on evaluation board based
  15227. + on w90p910 / NUC9xx.
  15228. +
  15229. +endif # MTD_NAND
  15230. diff -Nur linux-2.6.35.7.orig/drivers/mtd/nand/Makefile linux-2.6.35.7/drivers/mtd/nand/Makefile
  15231. --- linux-2.6.35.7.orig/drivers/mtd/nand/Makefile 2010-09-29 03:09:08.000000000 +0200
  15232. +++ linux-2.6.35.7/drivers/mtd/nand/Makefile 2010-10-14 20:28:00.318093945 +0200
  15233. @@ -32,6 +32,7 @@
  15234. obj-$(CONFIG_MTD_NAND_PXA3xx) += pxa3xx_nand.o
  15235. obj-$(CONFIG_MTD_NAND_TMIO) += tmio_nand.o
  15236. obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o
  15237. +obj-$(CONFIG_MTD_NAND_RB4XX) += rb4xx_nand.o
  15238. obj-$(CONFIG_MTD_ALAUDA) += alauda.o
  15239. obj-$(CONFIG_MTD_NAND_PASEMI) += pasemi_nand.o
  15240. obj-$(CONFIG_MTD_NAND_ORION) += orion_nand.o
  15241. diff -Nur linux-2.6.35.7.orig/drivers/mtd/nand/Makefile.orig linux-2.6.35.7/drivers/mtd/nand/Makefile.orig
  15242. --- linux-2.6.35.7.orig/drivers/mtd/nand/Makefile.orig 1970-01-01 01:00:00.000000000 +0100
  15243. +++ linux-2.6.35.7/drivers/mtd/nand/Makefile.orig 2010-09-29 03:09:08.000000000 +0200
  15244. @@ -0,0 +1,50 @@
  15245. +#
  15246. +# linux/drivers/nand/Makefile
  15247. +#
  15248. +
  15249. +obj-$(CONFIG_MTD_NAND) += nand.o
  15250. +obj-$(CONFIG_MTD_NAND_ECC) += nand_ecc.o
  15251. +obj-$(CONFIG_MTD_NAND_IDS) += nand_ids.o
  15252. +obj-$(CONFIG_MTD_SM_COMMON) += sm_common.o
  15253. +
  15254. +obj-$(CONFIG_MTD_NAND_CAFE) += cafe_nand.o
  15255. +obj-$(CONFIG_MTD_NAND_SPIA) += spia.o
  15256. +obj-$(CONFIG_MTD_NAND_AMS_DELTA) += ams-delta.o
  15257. +obj-$(CONFIG_MTD_NAND_AUTCPU12) += autcpu12.o
  15258. +obj-$(CONFIG_MTD_NAND_DENALI) += denali.o
  15259. +obj-$(CONFIG_MTD_NAND_EDB7312) += edb7312.o
  15260. +obj-$(CONFIG_MTD_NAND_AU1550) += au1550nd.o
  15261. +obj-$(CONFIG_MTD_NAND_BF5XX) += bf5xx_nand.o
  15262. +obj-$(CONFIG_MTD_NAND_PPCHAMELEONEVB) += ppchameleonevb.o
  15263. +obj-$(CONFIG_MTD_NAND_S3C2410) += s3c2410.o
  15264. +obj-$(CONFIG_MTD_NAND_DAVINCI) += davinci_nand.o
  15265. +obj-$(CONFIG_MTD_NAND_DISKONCHIP) += diskonchip.o
  15266. +obj-$(CONFIG_MTD_NAND_H1900) += h1910.o
  15267. +obj-$(CONFIG_MTD_NAND_RTC_FROM4) += rtc_from4.o
  15268. +obj-$(CONFIG_MTD_NAND_SHARPSL) += sharpsl.o
  15269. +obj-$(CONFIG_MTD_NAND_NANDSIM) += nandsim.o
  15270. +obj-$(CONFIG_MTD_NAND_CS553X) += cs553x_nand.o
  15271. +obj-$(CONFIG_MTD_NAND_NDFC) += ndfc.o
  15272. +obj-$(CONFIG_MTD_NAND_ATMEL) += atmel_nand.o
  15273. +obj-$(CONFIG_MTD_NAND_GPIO) += gpio.o
  15274. +obj-$(CONFIG_MTD_NAND_OMAP2) += omap2.o
  15275. +obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o
  15276. +obj-$(CONFIG_MTD_NAND_PXA3xx) += pxa3xx_nand.o
  15277. +obj-$(CONFIG_MTD_NAND_TMIO) += tmio_nand.o
  15278. +obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o
  15279. +obj-$(CONFIG_MTD_ALAUDA) += alauda.o
  15280. +obj-$(CONFIG_MTD_NAND_PASEMI) += pasemi_nand.o
  15281. +obj-$(CONFIG_MTD_NAND_ORION) += orion_nand.o
  15282. +obj-$(CONFIG_MTD_NAND_FSL_ELBC) += fsl_elbc_nand.o
  15283. +obj-$(CONFIG_MTD_NAND_FSL_UPM) += fsl_upm.o
  15284. +obj-$(CONFIG_MTD_NAND_SH_FLCTL) += sh_flctl.o
  15285. +obj-$(CONFIG_MTD_NAND_MXC) += mxc_nand.o
  15286. +obj-$(CONFIG_MTD_NAND_SOCRATES) += socrates_nand.o
  15287. +obj-$(CONFIG_MTD_NAND_TXX9NDFMC) += txx9ndfmc.o
  15288. +obj-$(CONFIG_MTD_NAND_NUC900) += nuc900_nand.o
  15289. +obj-$(CONFIG_MTD_NAND_NOMADIK) += nomadik_nand.o
  15290. +obj-$(CONFIG_MTD_NAND_BCM_UMI) += bcm_umi_nand.o nand_bcm_umi.o
  15291. +obj-$(CONFIG_MTD_NAND_MPC5121_NFC) += mpc5121_nfc.o
  15292. +obj-$(CONFIG_MTD_NAND_RICOH) += r852.o
  15293. +
  15294. +nand-objs := nand_base.o nand_bbt.o
  15295. diff -Nur linux-2.6.35.7.orig/drivers/mtd/nand/rb4xx_nand.c linux-2.6.35.7/drivers/mtd/nand/rb4xx_nand.c
  15296. --- linux-2.6.35.7.orig/drivers/mtd/nand/rb4xx_nand.c 1970-01-01 01:00:00.000000000 +0100
  15297. +++ linux-2.6.35.7/drivers/mtd/nand/rb4xx_nand.c 2010-10-14 20:28:34.515600563 +0200
  15298. @@ -0,0 +1,513 @@
  15299. +/*
  15300. + * NAND flash driver for the MikroTik RouterBoard 4xx series
  15301. + *
  15302. + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
  15303. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  15304. + *
  15305. + * This file was based on the driver for Linux 2.6.22 published by
  15306. + * MikroTik for their RouterBoard 4xx series devices.
  15307. + *
  15308. + * This program is free software; you can redistribute it and/or modify it
  15309. + * under the terms of the GNU General Public License version 2 as published
  15310. + * by the Free Software Foundation.
  15311. + */
  15312. +
  15313. +#include <linux/init.h>
  15314. +#include <linux/mtd/nand.h>
  15315. +#include <linux/mtd/mtd.h>
  15316. +#include <linux/mtd/partitions.h>
  15317. +#include <linux/platform_device.h>
  15318. +#include <linux/delay.h>
  15319. +#include <linux/io.h>
  15320. +#include <linux/gpio.h>
  15321. +#include <linux/slab.h>
  15322. +
  15323. +#include <asm/mach-ar71xx/ar71xx.h>
  15324. +
  15325. +#define DRV_NAME "rb4xx-nand"
  15326. +#define DRV_VERSION "0.1.10"
  15327. +#define DRV_DESC "NAND flash driver for RouterBoard 4xx series"
  15328. +
  15329. +#define USE_FAST_READ 1
  15330. +#define USE_FAST_WRITE 1
  15331. +#undef RB4XX_NAND_DEBUG
  15332. +
  15333. +#ifdef RB4XX_NAND_DEBUG
  15334. +#define DBG(fmt, arg...) printk(KERN_DEBUG DRV_NAME ": " fmt, ## arg)
  15335. +#else
  15336. +#define DBG(fmt, arg...) do {} while (0)
  15337. +#endif
  15338. +
  15339. +#define RB4XX_NAND_GPIO_RDY 5
  15340. +#define RB4XX_FLASH_HZ 33333334
  15341. +#define RB4XX_NAND_HZ 33333334
  15342. +
  15343. +#define SPI_CTRL_FASTEST 0x40
  15344. +#define SPI_CTRL_SAFE 0x43 /* 25 MHz for AHB 200 MHz */
  15345. +#define SBIT_IOC_BASE SPI_IOC_CS1
  15346. +#define SBIT_IOC_DO_SHIFT 0
  15347. +#define SBIT_IOC_DO (1u << SBIT_IOC_DO_SHIFT)
  15348. +#define SBIT_IOC_DO2_SHIFT 18
  15349. +#define SBIT_IOC_DO2 (1u << SBIT_IOC_DO2_SHIFT)
  15350. +
  15351. +#define CPLD_CMD_WRITE_MULT 0x08 /* send cmd, n x send data, read data */
  15352. +#define CPLD_CMD_WRITE_CFG 0x09 /* send cmd, n x send cfg */
  15353. +#define CPLD_CMD_READ_MULT 0x0a /* send cmd, send idle, n x read data */
  15354. +#define CPLD_CMD_READ_FAST 0x0b /* send cmd, 4 x idle, n x read data */
  15355. +
  15356. +#define CFG_BIT_nCE 0x80
  15357. +#define CFG_BIT_CLE 0x40
  15358. +#define CFG_BIT_ALE 0x20
  15359. +#define CFG_BIT_FAN 0x10
  15360. +#define CFG_BIT_nLED4 0x08
  15361. +#define CFG_BIT_nLED3 0x04
  15362. +#define CFG_BIT_nLED2 0x02
  15363. +#define CFG_BIT_nLED1 0x01
  15364. +
  15365. +#define CFG_BIT_nLEDS \
  15366. + (CFG_BIT_nLED1 | CFG_BIT_nLED2 | CFG_BIT_nLED3 | CFG_BIT_nLED4)
  15367. +
  15368. +struct rb4xx_nand_info {
  15369. + struct nand_chip chip;
  15370. + struct mtd_info mtd;
  15371. +};
  15372. +
  15373. +/*
  15374. + * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
  15375. + * will not be able to find the kernel that we load.
  15376. + */
  15377. +static struct nand_ecclayout rb4xx_nand_ecclayout = {
  15378. + .eccbytes = 6,
  15379. + .eccpos = { 8, 9, 10, 13, 14, 15 },
  15380. + .oobavail = 9,
  15381. + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
  15382. +};
  15383. +
  15384. +static struct mtd_partition rb4xx_nand_partitions[] = {
  15385. + {
  15386. + .name = "booter",
  15387. + .offset = 0,
  15388. + .size = (256 * 1024),
  15389. + .mask_flags = MTD_WRITEABLE,
  15390. + },
  15391. + {
  15392. + .name = "kernel",
  15393. + .offset = (256 * 1024),
  15394. + .size = (4 * 1024 * 1024) - (256 * 1024),
  15395. + },
  15396. + {
  15397. + .name = "rootfs",
  15398. + .offset = MTDPART_OFS_NXTBLK,
  15399. + .size = (1024*1024*64) - (1024*256) - (4 * 1024 * 1024)
  15400. + },
  15401. + {
  15402. + .name = "cfgfs",
  15403. + .offset = (1024*1024*64) - (1024*256),
  15404. + .size = (1024*256),
  15405. + },
  15406. +};
  15407. +
  15408. +#if USE_FAST_READ
  15409. +#define SPI_NDATA_BASE 0x00800000
  15410. +static unsigned spi_ctrl_fread = SPI_CTRL_SAFE;
  15411. +static unsigned spi_ctrl_flash = SPI_CTRL_SAFE;
  15412. +extern unsigned mips_hpt_frequency;
  15413. +#endif
  15414. +
  15415. +static inline unsigned rb4xx_spi_rreg(unsigned r)
  15416. +{
  15417. + return __raw_readl((void * __iomem)(KSEG1ADDR(AR71XX_SPI_BASE) + r));
  15418. +}
  15419. +
  15420. +static inline void rb4xx_spi_wreg(unsigned r, unsigned v)
  15421. +{
  15422. + __raw_writel(v, (void * __iomem)(KSEG1ADDR(AR71XX_SPI_BASE) + r));
  15423. +}
  15424. +
  15425. +static inline void do_spi_clk(int bit)
  15426. +{
  15427. + unsigned bval = SBIT_IOC_BASE | (bit & 1);
  15428. +
  15429. + rb4xx_spi_wreg(SPI_REG_IOC, bval);
  15430. + rb4xx_spi_wreg(SPI_REG_IOC, bval | SPI_IOC_CLK);
  15431. +}
  15432. +
  15433. +static void do_spi_byte(uint8_t byte)
  15434. +{
  15435. + do_spi_clk(byte >> 7);
  15436. + do_spi_clk(byte >> 6);
  15437. + do_spi_clk(byte >> 5);
  15438. + do_spi_clk(byte >> 4);
  15439. + do_spi_clk(byte >> 3);
  15440. + do_spi_clk(byte >> 2);
  15441. + do_spi_clk(byte >> 1);
  15442. + do_spi_clk(byte);
  15443. +
  15444. + DBG("spi_byte sent 0x%02x got 0x%x\n",
  15445. + byte, rb4xx_spi_rreg(SPI_REG_RDS));
  15446. +}
  15447. +
  15448. +#if USE_FAST_WRITE
  15449. +static inline void do_spi_clk_fast(int bit1, int bit2)
  15450. +{
  15451. + unsigned bval = (SBIT_IOC_BASE |
  15452. + ((bit1 << SBIT_IOC_DO_SHIFT) & SBIT_IOC_DO) |
  15453. + ((bit2 << SBIT_IOC_DO2_SHIFT) & SBIT_IOC_DO2));
  15454. +
  15455. + rb4xx_spi_wreg(SPI_REG_IOC, bval);
  15456. + rb4xx_spi_wreg(SPI_REG_IOC, bval | SPI_IOC_CLK);
  15457. +}
  15458. +
  15459. +static inline void do_spi_byte_fast(uint8_t byte)
  15460. +{
  15461. + do_spi_clk_fast(byte >> 7, byte >> 6);
  15462. + do_spi_clk_fast(byte >> 5, byte >> 4);
  15463. + do_spi_clk_fast(byte >> 3, byte >> 2);
  15464. + do_spi_clk_fast(byte >> 1, byte >> 0);
  15465. +
  15466. + DBG("spi_byte_fast sent 0x%02x got 0x%x\n",
  15467. + byte, rb4xx_spi_rreg(SPI_REG_RDS));
  15468. +}
  15469. +#else
  15470. +static inline void do_spi_byte_fast(uint8_t byte)
  15471. +{
  15472. + do_spi_byte(byte);
  15473. +}
  15474. +#endif /* USE_FAST_WRITE */
  15475. +
  15476. +static int do_spi_cmd(unsigned cmd, unsigned sendCnt, const uint8_t *sendData,
  15477. + unsigned recvCnt, uint8_t *recvData,
  15478. + const uint8_t *verifyData, int fastWrite)
  15479. +{
  15480. + unsigned i;
  15481. +
  15482. + DBG("SPI cmd 0x%x send %u recv %u\n", cmd, sendCnt, recvCnt);
  15483. +
  15484. + rb4xx_spi_wreg(SPI_REG_FS, SPI_FS_GPIO);
  15485. + rb4xx_spi_wreg(SPI_REG_CTRL, SPI_CTRL_FASTEST);
  15486. +
  15487. + do_spi_byte(cmd);
  15488. +#if 0
  15489. + if (cmd == CPLD_CMD_READ_FAST) {
  15490. + do_spi_byte(0x80);
  15491. + do_spi_byte(0);
  15492. + do_spi_byte(0);
  15493. + }
  15494. +#endif
  15495. + for (i = 0; i < sendCnt; ++i) {
  15496. + if (fastWrite)
  15497. + do_spi_byte_fast(sendData[i]);
  15498. + else
  15499. + do_spi_byte(sendData[i]);
  15500. + }
  15501. +
  15502. + for (i = 0; i < recvCnt; ++i) {
  15503. + if (fastWrite)
  15504. + do_spi_byte_fast(0);
  15505. + else
  15506. + do_spi_byte(0);
  15507. +
  15508. + if (recvData) {
  15509. + recvData[i] = rb4xx_spi_rreg(SPI_REG_RDS) & 0xff;
  15510. + } else if (verifyData) {
  15511. + if (verifyData[i] != (rb4xx_spi_rreg(SPI_REG_RDS)
  15512. + & 0xff))
  15513. + break;
  15514. + }
  15515. + }
  15516. +
  15517. + rb4xx_spi_wreg(SPI_REG_IOC, SBIT_IOC_BASE | SPI_IOC_CS0);
  15518. + rb4xx_spi_wreg(SPI_REG_CTRL, spi_ctrl_flash);
  15519. + rb4xx_spi_wreg(SPI_REG_FS, 0);
  15520. +
  15521. + return i == recvCnt;
  15522. +}
  15523. +
  15524. +static int got_write = 1;
  15525. +
  15526. +static void rb4xx_nand_write_data(const uint8_t *byte, unsigned cnt)
  15527. +{
  15528. + do_spi_cmd(CPLD_CMD_WRITE_MULT, cnt, byte, 1, NULL, NULL, 1);
  15529. + got_write = 1;
  15530. +}
  15531. +
  15532. +static void rb4xx_nand_write_byte(uint8_t byte)
  15533. +{
  15534. + rb4xx_nand_write_data(&byte, 1);
  15535. +}
  15536. +
  15537. +#if USE_FAST_READ
  15538. +static uint8_t *rb4xx_nand_read_getaddr(unsigned cnt)
  15539. +{
  15540. + static unsigned nboffset = 0x100000;
  15541. + unsigned addr;
  15542. +
  15543. + if (got_write) {
  15544. + nboffset = (nboffset + 31) & ~31;
  15545. + if (nboffset >= 0x100000) /* 1MB */
  15546. + nboffset = 0;
  15547. +
  15548. + got_write = 0;
  15549. + rb4xx_spi_wreg(SPI_REG_FS, SPI_FS_GPIO);
  15550. + rb4xx_spi_wreg(SPI_REG_CTRL, spi_ctrl_fread);
  15551. + rb4xx_spi_wreg(SPI_REG_FS, 0);
  15552. + }
  15553. +
  15554. + addr = KSEG1ADDR(AR71XX_SPI_BASE + SPI_NDATA_BASE) + nboffset;
  15555. + DBG("rb4xx_nand_read_getaddr 0x%x cnt 0x%x\n", addr, cnt);
  15556. +
  15557. + nboffset += cnt;
  15558. + return (uint8_t *)addr;
  15559. +}
  15560. +
  15561. +static void rb4xx_nand_read_data(uint8_t *buf, unsigned cnt)
  15562. +{
  15563. + unsigned size32 = cnt & ~31;
  15564. + unsigned remain = cnt & 31;
  15565. +
  15566. + if (size32) {
  15567. + uint8_t *addr = rb4xx_nand_read_getaddr(size32);
  15568. + memcpy(buf, (void *)addr, size32);
  15569. + }
  15570. +
  15571. + if (remain) {
  15572. + do_spi_cmd(CPLD_CMD_READ_MULT, 1, buf, remain,
  15573. + buf + size32, NULL, 0);
  15574. + }
  15575. +}
  15576. +
  15577. +static int rb4xx_nand_verify_data(const uint8_t *buf, unsigned cnt)
  15578. +{
  15579. + unsigned size32 = cnt & ~31;
  15580. + unsigned remain = cnt & 31;
  15581. +
  15582. + if (size32) {
  15583. + uint8_t *addr = rb4xx_nand_read_getaddr(size32);
  15584. + if (memcmp(buf, (void *)addr, size32) != 0)
  15585. + return 0;
  15586. + }
  15587. +
  15588. + if (remain) {
  15589. + return do_spi_cmd(CPLD_CMD_READ_MULT, 1, buf, remain,
  15590. + NULL, buf + size32, 0);
  15591. + }
  15592. + return 1;
  15593. +}
  15594. +#else /* USE_FAST_READ */
  15595. +static void rb4xx_nand_read_data(uint8_t *buf, unsigned cnt)
  15596. +{
  15597. + do_spi_cmd(CPLD_CMD_READ_MULT, 1, buf, cnt, buf, NULL, 0);
  15598. +}
  15599. +
  15600. +static int rb4xx_nand_verify_data(const uint8_t *buf, unsigned cnt)
  15601. +{
  15602. + return do_spi_cmd(CPLD_CMD_READ_MULT, 1, buf, cnt, NULL, buf, 0);
  15603. +}
  15604. +#endif /* USE_FAST_READ */
  15605. +
  15606. +static void rb4xx_nand_write_cfg(uint8_t byte)
  15607. +{
  15608. + do_spi_cmd(CPLD_CMD_WRITE_CFG, 1, &byte, 0, NULL, NULL, 0);
  15609. + got_write = 1;
  15610. +}
  15611. +
  15612. +static int rb4xx_nand_dev_ready(struct mtd_info *mtd)
  15613. +{
  15614. + return gpio_get_value(RB4XX_NAND_GPIO_RDY);
  15615. +}
  15616. +
  15617. +static void rb4xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
  15618. + unsigned int ctrl)
  15619. +{
  15620. + if (ctrl & NAND_CTRL_CHANGE) {
  15621. + uint8_t cfg = CFG_BIT_nLEDS;
  15622. +
  15623. + cfg |= (ctrl & NAND_CLE) ? CFG_BIT_CLE : 0;
  15624. + cfg |= (ctrl & NAND_ALE) ? CFG_BIT_ALE : 0;
  15625. + cfg |= (ctrl & NAND_NCE) ? 0 : CFG_BIT_nCE;
  15626. +
  15627. + rb4xx_nand_write_cfg(cfg);
  15628. + }
  15629. +
  15630. + if (cmd != NAND_CMD_NONE)
  15631. + rb4xx_nand_write_byte(cmd);
  15632. +}
  15633. +
  15634. +static uint8_t rb4xx_nand_read_byte(struct mtd_info *mtd)
  15635. +{
  15636. + uint8_t byte = 0;
  15637. +
  15638. + rb4xx_nand_read_data(&byte, 1);
  15639. + return byte;
  15640. +}
  15641. +
  15642. +static void rb4xx_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf,
  15643. + int len)
  15644. +{
  15645. + rb4xx_nand_write_data(buf, len);
  15646. +}
  15647. +
  15648. +static void rb4xx_nand_read_buf(struct mtd_info *mtd, uint8_t *buf,
  15649. + int len)
  15650. +{
  15651. + rb4xx_nand_read_data(buf, len);
  15652. +}
  15653. +
  15654. +static int rb4xx_nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf,
  15655. + int len)
  15656. +{
  15657. + if (!rb4xx_nand_verify_data(buf, len))
  15658. + return -EFAULT;
  15659. +
  15660. + return 0;
  15661. +}
  15662. +
  15663. +static unsigned get_spi_ctrl(unsigned hz_max, const char *name)
  15664. +{
  15665. + unsigned div;
  15666. +
  15667. + div = (ar71xx_ahb_freq - 1) / (2 * hz_max);
  15668. + /*
  15669. + * CPU has a bug at (div == 0) - first bit read is random
  15670. + */
  15671. + if (div == 0)
  15672. + ++div;
  15673. +
  15674. + if (name) {
  15675. + unsigned ahb_khz = (ar71xx_ahb_freq + 500) / 1000;
  15676. + unsigned div_real = 2 * (div + 1);
  15677. + printk(KERN_INFO "%s SPI clock %u kHz (AHB %u kHz / %u)\n",
  15678. + name,
  15679. + ahb_khz / div_real,
  15680. + ahb_khz, div_real);
  15681. + }
  15682. +
  15683. + return SPI_CTRL_FASTEST + div;
  15684. +}
  15685. +
  15686. +static int __init rb4xx_nand_probe(struct platform_device *pdev)
  15687. +{
  15688. + struct rb4xx_nand_info *info;
  15689. + int ret;
  15690. +
  15691. + printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
  15692. +
  15693. + ret = gpio_request(RB4XX_NAND_GPIO_RDY, "NAND RDY");
  15694. + if (ret) {
  15695. + printk(KERN_ERR "rb4xx-nand: gpio request failed\n");
  15696. + return ret;
  15697. + }
  15698. +
  15699. + ret = gpio_direction_input(RB4XX_NAND_GPIO_RDY);
  15700. + if (ret) {
  15701. + printk(KERN_ERR "rb4xx-nand: unable to set input mode "
  15702. + "on gpio%d\n", RB4XX_NAND_GPIO_RDY);
  15703. + goto err_free_gpio;
  15704. + }
  15705. +
  15706. + info = kzalloc(sizeof(*info), GFP_KERNEL);
  15707. + if (!info) {
  15708. + printk(KERN_ERR "rb4xx-nand: no memory for private data\n");
  15709. + ret = -ENOMEM;
  15710. + goto err_free_gpio;
  15711. + }
  15712. +
  15713. +#if USE_FAST_READ
  15714. + spi_ctrl_fread = get_spi_ctrl(RB4XX_NAND_HZ, "NAND");
  15715. +#endif
  15716. + spi_ctrl_flash = get_spi_ctrl(RB4XX_FLASH_HZ, "FLASH");
  15717. +
  15718. + rb4xx_nand_write_cfg(CFG_BIT_nLEDS | CFG_BIT_nCE);
  15719. +
  15720. + info->chip.priv = &info;
  15721. + info->mtd.priv = &info->chip;
  15722. + info->mtd.owner = THIS_MODULE;
  15723. +
  15724. + info->chip.cmd_ctrl = rb4xx_nand_cmd_ctrl;
  15725. + info->chip.dev_ready = rb4xx_nand_dev_ready;
  15726. + info->chip.read_byte = rb4xx_nand_read_byte;
  15727. + info->chip.write_buf = rb4xx_nand_write_buf;
  15728. + info->chip.read_buf = rb4xx_nand_read_buf;
  15729. + info->chip.verify_buf = rb4xx_nand_verify_buf;
  15730. +
  15731. + info->chip.chip_delay = 25;
  15732. + info->chip.ecc.mode = NAND_ECC_SOFT;
  15733. + info->chip.options |= NAND_NO_AUTOINCR;
  15734. +
  15735. + platform_set_drvdata(pdev, info);
  15736. +
  15737. + ret = nand_scan_ident(&info->mtd, 1, NULL);
  15738. + if (ret) {
  15739. + ret = -ENXIO;
  15740. + goto err_free_info;
  15741. + }
  15742. +
  15743. + if (info->mtd.writesize == 512)
  15744. + info->chip.ecc.layout = &rb4xx_nand_ecclayout;
  15745. +
  15746. + ret = nand_scan_tail(&info->mtd);
  15747. + if (ret) {
  15748. + return -ENXIO;
  15749. + goto err_set_drvdata;
  15750. + }
  15751. +
  15752. +#ifdef CONFIG_MTD_PARTITIONS
  15753. + ret = add_mtd_partitions(&info->mtd, rb4xx_nand_partitions,
  15754. + ARRAY_SIZE(rb4xx_nand_partitions));
  15755. +#else
  15756. + ret = add_mtd_device(&info->mtd);
  15757. +#endif
  15758. + if (ret)
  15759. + goto err_release_nand;
  15760. +
  15761. + return 0;
  15762. +
  15763. +err_release_nand:
  15764. + nand_release(&info->mtd);
  15765. +err_set_drvdata:
  15766. + platform_set_drvdata(pdev, NULL);
  15767. +err_free_info:
  15768. + kfree(info);
  15769. +err_free_gpio:
  15770. + gpio_free(RB4XX_NAND_GPIO_RDY);
  15771. + return ret;
  15772. +}
  15773. +
  15774. +static int __devexit rb4xx_nand_remove(struct platform_device *pdev)
  15775. +{
  15776. + struct rb4xx_nand_info *info = platform_get_drvdata(pdev);
  15777. +
  15778. + nand_release(&info->mtd);
  15779. + platform_set_drvdata(pdev, NULL);
  15780. + kfree(info);
  15781. +
  15782. + return 0;
  15783. +}
  15784. +
  15785. +static struct platform_driver rb4xx_nand_driver = {
  15786. + .probe = rb4xx_nand_probe,
  15787. + .remove = __devexit_p(rb4xx_nand_remove),
  15788. + .driver = {
  15789. + .name = DRV_NAME,
  15790. + .owner = THIS_MODULE,
  15791. + },
  15792. +};
  15793. +
  15794. +static int __init rb4xx_nand_init(void)
  15795. +{
  15796. + return platform_driver_register(&rb4xx_nand_driver);
  15797. +}
  15798. +
  15799. +static void __exit rb4xx_nand_exit(void)
  15800. +{
  15801. + platform_driver_unregister(&rb4xx_nand_driver);
  15802. +}
  15803. +
  15804. +module_init(rb4xx_nand_init);
  15805. +module_exit(rb4xx_nand_exit);
  15806. +
  15807. +MODULE_DESCRIPTION(DRV_DESC);
  15808. +MODULE_VERSION(DRV_VERSION);
  15809. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  15810. +MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>");
  15811. +MODULE_LICENSE("GPL v2");
  15812. diff -Nur linux-2.6.35.7.orig/drivers/mtd/nand/rb750_nand.c linux-2.6.35.7/drivers/mtd/nand/rb750_nand.c
  15813. --- linux-2.6.35.7.orig/drivers/mtd/nand/rb750_nand.c 1970-01-01 01:00:00.000000000 +0100
  15814. +++ linux-2.6.35.7/drivers/mtd/nand/rb750_nand.c 2010-10-14 20:28:00.398101127 +0200
  15815. @@ -0,0 +1,360 @@
  15816. +/*
  15817. + * NAND flash driver for the MikroTik RouterBOARD 750
  15818. + *
  15819. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  15820. + *
  15821. + * This program is free software; you can redistribute it and/or modify it
  15822. + * under the terms of the GNU General Public License version 2 as published
  15823. + * by the Free Software Foundation.
  15824. + */
  15825. +
  15826. +#include <linux/init.h>
  15827. +#include <linux/mtd/nand.h>
  15828. +#include <linux/mtd/mtd.h>
  15829. +#include <linux/mtd/partitions.h>
  15830. +#include <linux/platform_device.h>
  15831. +#include <linux/io.h>
  15832. +
  15833. +#include <asm/mach-ar71xx/ar71xx.h>
  15834. +#include <asm/mach-ar71xx/mach-rb750.h>
  15835. +
  15836. +#define DRV_NAME "rb750-nand"
  15837. +#define DRV_VERSION "0.1.0"
  15838. +#define DRV_DESC "NAND flash driver for the RouterBOARD 750"
  15839. +
  15840. +#define RB750_NAND_IO0 BIT(RB750_GPIO_NAND_IO0)
  15841. +#define RB750_NAND_ALE BIT(RB750_GPIO_NAND_ALE)
  15842. +#define RB750_NAND_CLE BIT(RB750_GPIO_NAND_CLE)
  15843. +#define RB750_NAND_NRE BIT(RB750_GPIO_NAND_NRE)
  15844. +#define RB750_NAND_NWE BIT(RB750_GPIO_NAND_NWE)
  15845. +#define RB750_NAND_RDY BIT(RB750_GPIO_NAND_RDY)
  15846. +#define RB750_NAND_NCE BIT(RB750_GPIO_NAND_NCE)
  15847. +
  15848. +#define RB750_NAND_DATA_SHIFT 1
  15849. +#define RB750_NAND_DATA_BITS (0xff << RB750_NAND_DATA_SHIFT)
  15850. +#define RB750_NAND_INPUT_BITS (RB750_NAND_DATA_BITS | RB750_NAND_RDY)
  15851. +#define RB750_NAND_OUTPUT_BITS (RB750_NAND_ALE | RB750_NAND_CLE | \
  15852. + RB750_NAND_NRE | RB750_NAND_NWE | \
  15853. + RB750_NAND_NCE)
  15854. +
  15855. +struct rb750_nand_info {
  15856. + struct nand_chip chip;
  15857. + struct mtd_info mtd;
  15858. +};
  15859. +
  15860. +/*
  15861. + * We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
  15862. + * will not be able to find the kernel that we load.
  15863. + */
  15864. +static struct nand_ecclayout rb750_nand_ecclayout = {
  15865. + .eccbytes = 6,
  15866. + .eccpos = { 8, 9, 10, 13, 14, 15 },
  15867. + .oobavail = 9,
  15868. + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
  15869. +};
  15870. +
  15871. +static struct mtd_partition rb750_nand_partitions[] = {
  15872. + {
  15873. + .name = "booter",
  15874. + .offset = 0,
  15875. + .size = (256 * 1024),
  15876. + .mask_flags = MTD_WRITEABLE,
  15877. + }, {
  15878. + .name = "kernel",
  15879. + .offset = (256 * 1024),
  15880. + .size = (4 * 1024 * 1024) - (256 * 1024),
  15881. + }, {
  15882. + .name = "rootfs",
  15883. + .offset = MTDPART_OFS_NXTBLK,
  15884. + .size = MTDPART_SIZ_FULL,
  15885. + },
  15886. +};
  15887. +
  15888. +static void rb750_nand_write(const u8 *buf, unsigned len)
  15889. +{
  15890. + void __iomem *base = ar71xx_gpio_base;
  15891. + u32 out;
  15892. + unsigned i;
  15893. +
  15894. + /* set data lines to output mode */
  15895. + __raw_writel(__raw_readl(base + GPIO_REG_OE) | RB750_NAND_DATA_BITS,
  15896. + base + GPIO_REG_OE);
  15897. +
  15898. + out = __raw_readl(base + GPIO_REG_OUT);
  15899. + out &= ~(RB750_NAND_DATA_BITS | RB750_NAND_NWE);
  15900. + for (i = 0; i != len; i++) {
  15901. + u32 data;
  15902. +
  15903. + data = buf[i];
  15904. + data <<= RB750_NAND_DATA_SHIFT;
  15905. + data |= out;
  15906. + __raw_writel(data, base + GPIO_REG_OUT);
  15907. +
  15908. + __raw_writel(data | RB750_NAND_NWE, base + GPIO_REG_OUT);
  15909. + /* flush write */
  15910. + __raw_readl(base + GPIO_REG_OUT);
  15911. + }
  15912. +
  15913. + /* set data lines to input mode */
  15914. + __raw_writel(__raw_readl(base + GPIO_REG_OE) & ~RB750_NAND_DATA_BITS,
  15915. + base + GPIO_REG_OE);
  15916. + /* flush write */
  15917. + __raw_readl(base + GPIO_REG_OE);
  15918. +}
  15919. +
  15920. +static int rb750_nand_read_verify(u8 *read_buf, unsigned len,
  15921. + const u8 *verify_buf)
  15922. +{
  15923. + void __iomem *base = ar71xx_gpio_base;
  15924. + unsigned i;
  15925. +
  15926. + for (i = 0; i < len; i++) {
  15927. + u8 data;
  15928. +
  15929. + /* activate RE line */
  15930. + __raw_writel(RB750_NAND_NRE, base + GPIO_REG_CLEAR);
  15931. + /* flush write */
  15932. + __raw_readl(base + GPIO_REG_CLEAR);
  15933. +
  15934. + /* read input lines */
  15935. + data = __raw_readl(base + GPIO_REG_IN) >> RB750_NAND_DATA_SHIFT;
  15936. +
  15937. + /* deactivate RE line */
  15938. + __raw_writel(RB750_NAND_NRE, base + GPIO_REG_SET);
  15939. +
  15940. + if (read_buf)
  15941. + read_buf[i] = data;
  15942. + else if (verify_buf && verify_buf[i] != data)
  15943. + return -EFAULT;
  15944. + }
  15945. +
  15946. + return 0;
  15947. +}
  15948. +
  15949. +static void rb750_nand_select_chip(struct mtd_info *mtd, int chip)
  15950. +{
  15951. + void __iomem *base = ar71xx_gpio_base;
  15952. + u32 func;
  15953. +
  15954. + func = __raw_readl(base + GPIO_REG_FUNC);
  15955. + if (chip >= 0) {
  15956. + /* disable latch */
  15957. + rb750_latch_change(RB750_LVC573_LE, 0);
  15958. +
  15959. + /* disable alternate functions */
  15960. + ar71xx_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
  15961. + AR724X_GPIO_FUNC_SPI_EN);
  15962. +
  15963. + /* set input mode for data lines */
  15964. + __raw_writel(__raw_readl(base + GPIO_REG_OE) &
  15965. + ~RB750_NAND_INPUT_BITS,
  15966. + base + GPIO_REG_OE);
  15967. +
  15968. + /* deactivate RE and WE lines */
  15969. + __raw_writel(RB750_NAND_NRE | RB750_NAND_NWE,
  15970. + base + GPIO_REG_SET);
  15971. + /* flush write */
  15972. + (void) __raw_readl(base + GPIO_REG_SET);
  15973. +
  15974. + /* activate CE line */
  15975. + __raw_writel(RB750_NAND_NCE, base + GPIO_REG_CLEAR);
  15976. + } else {
  15977. + /* deactivate CE line */
  15978. + __raw_writel(RB750_NAND_NCE, base + GPIO_REG_SET);
  15979. + /* flush write */
  15980. + (void) __raw_readl(base + GPIO_REG_SET);
  15981. +
  15982. + __raw_writel(__raw_readl(base + GPIO_REG_OE) |
  15983. + RB750_NAND_IO0 | RB750_NAND_RDY,
  15984. + base + GPIO_REG_OE);
  15985. +
  15986. + /* restore alternate functions */
  15987. + ar71xx_gpio_function_setup(AR724X_GPIO_FUNC_SPI_EN,
  15988. + AR724X_GPIO_FUNC_JTAG_DISABLE);
  15989. +
  15990. + /* enable latch */
  15991. + rb750_latch_change(0, RB750_LVC573_LE);
  15992. + }
  15993. +}
  15994. +
  15995. +static int rb750_nand_dev_ready(struct mtd_info *mtd)
  15996. +{
  15997. + void __iomem *base = ar71xx_gpio_base;
  15998. +
  15999. + return !!(__raw_readl(base + GPIO_REG_IN) & RB750_NAND_RDY);
  16000. +}
  16001. +
  16002. +static void rb750_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
  16003. + unsigned int ctrl)
  16004. +{
  16005. + if (ctrl & NAND_CTRL_CHANGE) {
  16006. + void __iomem *base = ar71xx_gpio_base;
  16007. + u32 t;
  16008. +
  16009. + t = __raw_readl(base + GPIO_REG_OUT);
  16010. +
  16011. + t &= ~(RB750_NAND_CLE | RB750_NAND_ALE);
  16012. + t |= (ctrl & NAND_CLE) ? RB750_NAND_CLE : 0;
  16013. + t |= (ctrl & NAND_ALE) ? RB750_NAND_ALE : 0;
  16014. +
  16015. + __raw_writel(t, base + GPIO_REG_OUT);
  16016. + /* flush write */
  16017. + __raw_readl(base + GPIO_REG_OUT);
  16018. + }
  16019. +
  16020. + if (cmd != NAND_CMD_NONE) {
  16021. + u8 t = cmd;
  16022. + rb750_nand_write(&t, 1);
  16023. + }
  16024. +}
  16025. +
  16026. +static u8 rb750_nand_read_byte(struct mtd_info *mtd)
  16027. +{
  16028. + u8 data = 0;
  16029. + rb750_nand_read_verify(&data, 1, NULL);
  16030. + return data;
  16031. +}
  16032. +
  16033. +static void rb750_nand_read_buf(struct mtd_info *mtd, u8 *buf, int len)
  16034. +{
  16035. + rb750_nand_read_verify(buf, len, NULL);
  16036. +}
  16037. +
  16038. +static void rb750_nand_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
  16039. +{
  16040. + rb750_nand_write(buf, len);
  16041. +}
  16042. +
  16043. +static int rb750_nand_verify_buf(struct mtd_info *mtd, const u8 *buf, int len)
  16044. +{
  16045. + return rb750_nand_read_verify(NULL, len, buf);
  16046. +}
  16047. +
  16048. +static void __init rb750_nand_gpio_init(void)
  16049. +{
  16050. + void __iomem *base = ar71xx_gpio_base;
  16051. + u32 out;
  16052. +
  16053. + out = __raw_readl(base + GPIO_REG_OUT);
  16054. +
  16055. + /* setup output levels */
  16056. + __raw_writel(RB750_NAND_NCE | RB750_NAND_NRE | RB750_NAND_NWE,
  16057. + base + GPIO_REG_SET);
  16058. +
  16059. + __raw_writel(RB750_NAND_ALE | RB750_NAND_CLE,
  16060. + base + GPIO_REG_CLEAR);
  16061. +
  16062. + /* setup input lines */
  16063. + __raw_writel(__raw_readl(base + GPIO_REG_OE) & ~(RB750_NAND_INPUT_BITS),
  16064. + base + GPIO_REG_OE);
  16065. +
  16066. + /* setup output lines */
  16067. + __raw_writel(__raw_readl(base + GPIO_REG_OE) | RB750_NAND_OUTPUT_BITS,
  16068. + base + GPIO_REG_OE);
  16069. +
  16070. + rb750_latch_change(~out & RB750_NAND_IO0, out & RB750_NAND_IO0);
  16071. +}
  16072. +
  16073. +static int __init rb750_nand_probe(struct platform_device *pdev)
  16074. +{
  16075. + struct rb750_nand_info *info;
  16076. + int ret;
  16077. +
  16078. + printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
  16079. +
  16080. + rb750_nand_gpio_init();
  16081. +
  16082. + info = kzalloc(sizeof(*info), GFP_KERNEL);
  16083. + if (!info)
  16084. + return -ENOMEM;
  16085. +
  16086. + info->chip.priv = &info;
  16087. + info->mtd.priv = &info->chip;
  16088. + info->mtd.owner = THIS_MODULE;
  16089. +
  16090. + info->chip.select_chip = rb750_nand_select_chip;
  16091. + info->chip.cmd_ctrl = rb750_nand_cmd_ctrl;
  16092. + info->chip.dev_ready = rb750_nand_dev_ready;
  16093. + info->chip.read_byte = rb750_nand_read_byte;
  16094. + info->chip.write_buf = rb750_nand_write_buf;
  16095. + info->chip.read_buf = rb750_nand_read_buf;
  16096. + info->chip.verify_buf = rb750_nand_verify_buf;
  16097. +
  16098. + info->chip.chip_delay = 25;
  16099. + info->chip.ecc.mode = NAND_ECC_SOFT;
  16100. + info->chip.options |= NAND_NO_AUTOINCR;
  16101. +
  16102. + platform_set_drvdata(pdev, info);
  16103. +
  16104. + ret = nand_scan_ident(&info->mtd, 1);
  16105. + if (ret) {
  16106. + ret = -ENXIO;
  16107. + goto err_free_info;
  16108. + }
  16109. +
  16110. + if (info->mtd.writesize == 512)
  16111. + info->chip.ecc.layout = &rb750_nand_ecclayout;
  16112. +
  16113. + ret = nand_scan_tail(&info->mtd);
  16114. + if (ret) {
  16115. + return -ENXIO;
  16116. + goto err_set_drvdata;
  16117. + }
  16118. +
  16119. +#ifdef CONFIG_MTD_PARTITIONS
  16120. + ret = add_mtd_partitions(&info->mtd, rb750_nand_partitions,
  16121. + ARRAY_SIZE(rb750_nand_partitions));
  16122. +#else
  16123. + ret = add_mtd_device(&info->mtd);
  16124. +#endif
  16125. + if (ret)
  16126. + goto err_release_nand;
  16127. +
  16128. + return 0;
  16129. +
  16130. + err_release_nand:
  16131. + nand_release(&info->mtd);
  16132. + err_set_drvdata:
  16133. + platform_set_drvdata(pdev, NULL);
  16134. + err_free_info:
  16135. + kfree(info);
  16136. + return ret;
  16137. +}
  16138. +
  16139. +static int __devexit rb750_nand_remove(struct platform_device *pdev)
  16140. +{
  16141. + struct rb750_nand_info *info = platform_get_drvdata(pdev);
  16142. +
  16143. + nand_release(&info->mtd);
  16144. + platform_set_drvdata(pdev, NULL);
  16145. + kfree(info);
  16146. +
  16147. + return 0;
  16148. +}
  16149. +
  16150. +static struct platform_driver rb750_nand_driver = {
  16151. + .probe = rb750_nand_probe,
  16152. + .remove = __devexit_p(rb750_nand_remove),
  16153. + .driver = {
  16154. + .name = DRV_NAME,
  16155. + .owner = THIS_MODULE,
  16156. + },
  16157. +};
  16158. +
  16159. +static int __init rb750_nand_init(void)
  16160. +{
  16161. + return platform_driver_register(&rb750_nand_driver);
  16162. +}
  16163. +
  16164. +static void __exit rb750_nand_exit(void)
  16165. +{
  16166. + platform_driver_unregister(&rb750_nand_driver);
  16167. +}
  16168. +
  16169. +module_init(rb750_nand_init);
  16170. +module_exit(rb750_nand_exit);
  16171. +
  16172. +MODULE_DESCRIPTION(DRV_DESC);
  16173. +MODULE_VERSION(DRV_VERSION);
  16174. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  16175. +MODULE_LICENSE("GPL v2");
  16176. diff -Nur linux-2.6.35.7.orig/drivers/mtd/wrt160nl_part.c linux-2.6.35.7/drivers/mtd/wrt160nl_part.c
  16177. --- linux-2.6.35.7.orig/drivers/mtd/wrt160nl_part.c 1970-01-01 01:00:00.000000000 +0100
  16178. +++ linux-2.6.35.7/drivers/mtd/wrt160nl_part.c 2010-10-14 20:28:00.438101171 +0200
  16179. @@ -0,0 +1,181 @@
  16180. +/*
  16181. + * Copyright (C) 2009 Christian Daniel <cd@maintech.de>
  16182. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  16183. + *
  16184. + * This program is free software; you can redistribute it and/or modify
  16185. + * it under the terms of the GNU General Public License as published by
  16186. + * the Free Software Foundation; either version 2 of the License, or
  16187. + * (at your option) any later version.
  16188. + *
  16189. + * This program is distributed in the hope that it will be useful,
  16190. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16191. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16192. + * GNU General Public License for more details.
  16193. + *
  16194. + * You should have received a copy of the GNU General Public License
  16195. + * along with this program; if not, write to the Free Software
  16196. + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16197. + *
  16198. + * TRX flash partition table.
  16199. + * Based on ar7 map by Felix Fietkau <nbd@openwrt.org>
  16200. + *
  16201. + */
  16202. +
  16203. +#include <linux/kernel.h>
  16204. +#include <linux/slab.h>
  16205. +#include <linux/vmalloc.h>
  16206. +
  16207. +#include <linux/mtd/mtd.h>
  16208. +#include <linux/mtd/partitions.h>
  16209. +
  16210. +struct cybertan_header {
  16211. + char magic[4];
  16212. + u8 res1[4];
  16213. + char fw_date[3];
  16214. + char fw_ver[3];
  16215. + char id[4];
  16216. + char hw_ver;
  16217. + char unused;
  16218. + u8 flags[2];
  16219. + u8 res2[10];
  16220. +};
  16221. +
  16222. +#define TRX_PARTS 6
  16223. +#define TRX_MAGIC 0x30524448
  16224. +#define TRX_MAX_OFFSET 3
  16225. +
  16226. +struct trx_header {
  16227. + uint32_t magic; /* "HDR0" */
  16228. + uint32_t len; /* Length of file including header */
  16229. + uint32_t crc32; /* 32-bit CRC from flag_version to end of file */
  16230. + uint32_t flag_version; /* 0:15 flags, 16:31 version */
  16231. + uint32_t offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
  16232. +};
  16233. +
  16234. +#define IH_MAGIC 0x27051956 /* Image Magic Number */
  16235. +#define IH_NMLEN 32 /* Image Name Length */
  16236. +
  16237. +struct uimage_header {
  16238. + uint32_t ih_magic; /* Image Header Magic Number */
  16239. + uint32_t ih_hcrc; /* Image Header CRC Checksum */
  16240. + uint32_t ih_time; /* Image Creation Timestamp */
  16241. + uint32_t ih_size; /* Image Data Size */
  16242. + uint32_t ih_load; /* Data» Load Address */
  16243. + uint32_t ih_ep; /* Entry Point Address */
  16244. + uint32_t ih_dcrc; /* Image Data CRC Checksum */
  16245. + uint8_t ih_os; /* Operating System */
  16246. + uint8_t ih_arch; /* CPU architecture */
  16247. + uint8_t ih_type; /* Image Type */
  16248. + uint8_t ih_comp; /* Compression Type */
  16249. + uint8_t ih_name[IH_NMLEN]; /* Image Name */
  16250. +};
  16251. +
  16252. +struct wrt160nl_header {
  16253. + struct cybertan_header cybertan;
  16254. + struct trx_header trx;
  16255. + struct uimage_header uimage;
  16256. +} __attribute__ ((packed));
  16257. +
  16258. +static struct mtd_partition trx_parts[TRX_PARTS];
  16259. +
  16260. +static int wrt160nl_parse_partitions(struct mtd_info *master,
  16261. + struct mtd_partition **pparts,
  16262. + unsigned long origin)
  16263. +{
  16264. + struct wrt160nl_header *header;
  16265. + struct trx_header *theader;
  16266. + struct uimage_header *uheader;
  16267. + size_t retlen;
  16268. + unsigned int kernel_len;
  16269. + int ret;
  16270. +
  16271. + header = vmalloc(sizeof(*header));
  16272. + if (!header) {
  16273. + return -ENOMEM;
  16274. + goto out;
  16275. + }
  16276. +
  16277. + ret = master->read(master, 4 * master->erasesize, sizeof(*header),
  16278. + &retlen, (void *) header);
  16279. + if (ret)
  16280. + goto free_hdr;
  16281. +
  16282. + if (retlen != sizeof(*header)) {
  16283. + ret = -EIO;
  16284. + goto free_hdr;
  16285. + }
  16286. +
  16287. + if (strncmp(header->cybertan.magic, "NL16", 4) != 0) {
  16288. + printk(KERN_NOTICE "%s: no WRT160NL signature found\n",
  16289. + master->name);
  16290. + goto free_hdr;
  16291. + }
  16292. +
  16293. + theader = &header->trx;
  16294. + if (le32_to_cpu(theader->magic) != TRX_MAGIC) {
  16295. + printk(KERN_NOTICE "%s: no TRX header found\n", master->name);
  16296. + goto free_hdr;
  16297. + }
  16298. +
  16299. + uheader = &header->uimage;
  16300. + if (uheader->ih_magic != IH_MAGIC) {
  16301. + printk(KERN_NOTICE "%s: no uImage found\n", master->name);
  16302. + goto free_hdr;
  16303. + }
  16304. +
  16305. + kernel_len = le32_to_cpu(theader->offsets[1]) + sizeof(struct cybertan_header);
  16306. +
  16307. + trx_parts[0].name = "u-boot";
  16308. + trx_parts[0].offset = 0;
  16309. + trx_parts[0].size = 4 * master->erasesize;
  16310. + trx_parts[0].mask_flags = MTD_WRITEABLE;
  16311. +
  16312. + trx_parts[1].name = "kernel";
  16313. + trx_parts[1].offset = trx_parts[0].offset + trx_parts[0].size;
  16314. + trx_parts[1].size = kernel_len;
  16315. + trx_parts[1].mask_flags = 0;
  16316. +
  16317. + trx_parts[2].name = "rootfs";
  16318. + trx_parts[2].offset = trx_parts[1].offset + trx_parts[1].size;
  16319. + trx_parts[2].size = master->size - 6 * master->erasesize - trx_parts[1].size;
  16320. + trx_parts[2].mask_flags = 0;
  16321. +
  16322. + trx_parts[3].name = "nvram";
  16323. + trx_parts[3].offset = master->size - 2 * master->erasesize;
  16324. + trx_parts[3].size = master->erasesize;
  16325. + trx_parts[3].mask_flags = MTD_WRITEABLE;
  16326. +
  16327. + trx_parts[4].name = "art";
  16328. + trx_parts[4].offset = master->size - master->erasesize;
  16329. + trx_parts[4].size = master->erasesize;
  16330. + trx_parts[4].mask_flags = MTD_WRITEABLE;
  16331. +
  16332. + trx_parts[5].name = "firmware";
  16333. + trx_parts[5].offset = 4 * master->erasesize;
  16334. + trx_parts[5].size = master->size - 6 * master->erasesize;
  16335. + trx_parts[5].mask_flags = 0;
  16336. +
  16337. + *pparts = trx_parts;
  16338. + ret = TRX_PARTS;
  16339. +
  16340. + free_hdr:
  16341. + vfree(header);
  16342. + out:
  16343. + return ret;
  16344. +}
  16345. +
  16346. +static struct mtd_part_parser wrt160nl_parser = {
  16347. + .owner = THIS_MODULE,
  16348. + .parse_fn = wrt160nl_parse_partitions,
  16349. + .name = "wrt160nl",
  16350. +};
  16351. +
  16352. +static int __init wrt160nl_parser_init(void)
  16353. +{
  16354. + return register_mtd_parser(&wrt160nl_parser);
  16355. +}
  16356. +
  16357. +module_init(wrt160nl_parser_init);
  16358. +
  16359. +MODULE_LICENSE("GPL");
  16360. +MODULE_AUTHOR("Christian Daniel <cd@maintech.de>");
  16361. diff -Nur linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_ar8216.c linux-2.6.35.7/drivers/net/ag71xx/ag71xx_ar8216.c
  16362. --- linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_ar8216.c 1970-01-01 01:00:00.000000000 +0100
  16363. +++ linux-2.6.35.7/drivers/net/ag71xx/ag71xx_ar8216.c 2010-10-14 20:28:00.478101179 +0200
  16364. @@ -0,0 +1,44 @@
  16365. +/*
  16366. + * Atheros AR71xx built-in ethernet mac driver
  16367. + * Special support for the Atheros ar8216 switch chip
  16368. + *
  16369. + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  16370. + *
  16371. + * Based on Atheros' AG7100 driver
  16372. + *
  16373. + * This program is free software; you can redistribute it and/or modify it
  16374. + * under the terms of the GNU General Public License version 2 as published
  16375. + * by the Free Software Foundation.
  16376. + */
  16377. +
  16378. +#include "ag71xx.h"
  16379. +
  16380. +#define AR8216_PACKET_TYPE_MASK 0xf
  16381. +#define AR8216_PACKET_TYPE_NORMAL 0
  16382. +
  16383. +#define AR8216_HEADER_LEN 2
  16384. +
  16385. +void ag71xx_add_ar8216_header(struct ag71xx *ag, struct sk_buff *skb)
  16386. +{
  16387. + skb_push(skb, AR8216_HEADER_LEN);
  16388. + skb->data[0] = 0x10;
  16389. + skb->data[1] = 0x80;
  16390. +}
  16391. +
  16392. +int ag71xx_remove_ar8216_header(struct ag71xx *ag, struct sk_buff *skb,
  16393. + int pktlen)
  16394. +{
  16395. + u8 type;
  16396. +
  16397. + type = skb->data[1] & AR8216_PACKET_TYPE_MASK;
  16398. + switch (type) {
  16399. + case AR8216_PACKET_TYPE_NORMAL:
  16400. + break;
  16401. +
  16402. + default:
  16403. + return -EINVAL;
  16404. + }
  16405. +
  16406. + skb_pull(skb, AR8216_HEADER_LEN);
  16407. + return 0;
  16408. +}
  16409. diff -Nur linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_debugfs.c linux-2.6.35.7/drivers/net/ag71xx/ag71xx_debugfs.c
  16410. --- linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_debugfs.c 1970-01-01 01:00:00.000000000 +0100
  16411. +++ linux-2.6.35.7/drivers/net/ag71xx/ag71xx_debugfs.c 2010-10-14 20:28:00.514356373 +0200
  16412. @@ -0,0 +1,197 @@
  16413. +/*
  16414. + * Atheros AR71xx built-in ethernet mac driver
  16415. + *
  16416. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  16417. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  16418. + *
  16419. + * Based on Atheros' AG7100 driver
  16420. + *
  16421. + * This program is free software; you can redistribute it and/or modify it
  16422. + * under the terms of the GNU General Public License version 2 as published
  16423. + * by the Free Software Foundation.
  16424. + */
  16425. +
  16426. +#include <linux/debugfs.h>
  16427. +
  16428. +#include "ag71xx.h"
  16429. +
  16430. +static struct dentry *ag71xx_debugfs_root;
  16431. +
  16432. +static int ag71xx_debugfs_generic_open(struct inode *inode, struct file *file)
  16433. +{
  16434. + file->private_data = inode->i_private;
  16435. + return 0;
  16436. +}
  16437. +
  16438. +void ag71xx_debugfs_update_int_stats(struct ag71xx *ag, u32 status)
  16439. +{
  16440. + if (status)
  16441. + ag->debug.int_stats.total++;
  16442. + if (status & AG71XX_INT_TX_PS)
  16443. + ag->debug.int_stats.tx_ps++;
  16444. + if (status & AG71XX_INT_TX_UR)
  16445. + ag->debug.int_stats.tx_ur++;
  16446. + if (status & AG71XX_INT_TX_BE)
  16447. + ag->debug.int_stats.tx_be++;
  16448. + if (status & AG71XX_INT_RX_PR)
  16449. + ag->debug.int_stats.rx_pr++;
  16450. + if (status & AG71XX_INT_RX_OF)
  16451. + ag->debug.int_stats.rx_of++;
  16452. + if (status & AG71XX_INT_RX_BE)
  16453. + ag->debug.int_stats.rx_be++;
  16454. +}
  16455. +
  16456. +static ssize_t read_file_int_stats(struct file *file, char __user *user_buf,
  16457. + size_t count, loff_t *ppos)
  16458. +{
  16459. +#define PR_INT_STAT(_label, _field) \
  16460. + len += snprintf(buf + len, sizeof(buf) - len, \
  16461. + "%20s: %10lu\n", _label, ag->debug.int_stats._field);
  16462. +
  16463. + struct ag71xx *ag = file->private_data;
  16464. + char buf[256];
  16465. + unsigned int len = 0;
  16466. +
  16467. + PR_INT_STAT("TX Packet Sent", tx_ps);
  16468. + PR_INT_STAT("TX Underrun", tx_ur);
  16469. + PR_INT_STAT("TX Bus Error", tx_be);
  16470. + PR_INT_STAT("RX Packet Received", rx_pr);
  16471. + PR_INT_STAT("RX Overflow", rx_of);
  16472. + PR_INT_STAT("RX Bus Error", rx_be);
  16473. + len += snprintf(buf + len, sizeof(buf) - len, "\n");
  16474. + PR_INT_STAT("Total", total);
  16475. +
  16476. + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  16477. +#undef PR_INT_STAT
  16478. +}
  16479. +
  16480. +static const struct file_operations ag71xx_fops_int_stats = {
  16481. + .open = ag71xx_debugfs_generic_open,
  16482. + .read = read_file_int_stats,
  16483. + .owner = THIS_MODULE
  16484. +};
  16485. +
  16486. +void ag71xx_debugfs_update_napi_stats(struct ag71xx *ag, int rx, int tx)
  16487. +{
  16488. + struct ag71xx_napi_stats *stats = &ag->debug.napi_stats;
  16489. +
  16490. + if (rx) {
  16491. + stats->rx_count++;
  16492. + stats->rx_packets += rx;
  16493. + if (rx <= AG71XX_NAPI_WEIGHT)
  16494. + stats->rx[rx]++;
  16495. + if (rx > stats->rx_packets_max)
  16496. + stats->rx_packets_max = rx;
  16497. + }
  16498. +
  16499. + if (tx) {
  16500. + stats->tx_count++;
  16501. + stats->tx_packets += tx;
  16502. + if (tx <= AG71XX_NAPI_WEIGHT)
  16503. + stats->tx[tx]++;
  16504. + if (tx > stats->tx_packets_max)
  16505. + stats->tx_packets_max = tx;
  16506. + }
  16507. +}
  16508. +
  16509. +static ssize_t read_file_napi_stats(struct file *file, char __user *user_buf,
  16510. + size_t count, loff_t *ppos)
  16511. +{
  16512. + struct ag71xx *ag = file->private_data;
  16513. + struct ag71xx_napi_stats *stats = &ag->debug.napi_stats;
  16514. + char buf[2048];
  16515. + unsigned int len = 0;
  16516. + unsigned long rx_avg = 0;
  16517. + unsigned long tx_avg = 0;
  16518. + int i;
  16519. +
  16520. + if (stats->rx_count)
  16521. + rx_avg = stats->rx_packets / stats->rx_count;
  16522. +
  16523. + if (stats->tx_count)
  16524. + tx_avg = stats->tx_packets / stats->tx_count;
  16525. +
  16526. + len += snprintf(buf + len, sizeof(buf) - len, "%3s %10s %10s\n",
  16527. + "len", "rx", "tx");
  16528. +
  16529. + for (i = 1; i <= AG71XX_NAPI_WEIGHT; i++)
  16530. + len += snprintf(buf + len, sizeof(buf) - len,
  16531. + "%3d: %10lu %10lu\n",
  16532. + i, stats->rx[i], stats->tx[i]);
  16533. +
  16534. + len += snprintf(buf + len, sizeof(buf) - len, "\n");
  16535. +
  16536. + len += snprintf(buf + len, sizeof(buf) - len, "%3s: %10lu %10lu\n",
  16537. + "sum", stats->rx_count, stats->tx_count);
  16538. + len += snprintf(buf + len, sizeof(buf) - len, "%3s: %10lu %10lu\n",
  16539. + "avg", rx_avg, tx_avg);
  16540. + len += snprintf(buf + len, sizeof(buf) - len, "%3s: %10lu %10lu\n",
  16541. + "max", stats->rx_packets_max, stats->tx_packets_max);
  16542. + len += snprintf(buf + len, sizeof(buf) - len, "%3s: %10lu %10lu\n",
  16543. + "pkt", stats->rx_packets, stats->tx_packets);
  16544. +
  16545. + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  16546. +}
  16547. +
  16548. +static const struct file_operations ag71xx_fops_napi_stats = {
  16549. + .open = ag71xx_debugfs_generic_open,
  16550. + .read = read_file_napi_stats,
  16551. + .owner = THIS_MODULE
  16552. +};
  16553. +
  16554. +void ag71xx_debugfs_exit(struct ag71xx *ag)
  16555. +{
  16556. + debugfs_remove(ag->debug.debugfs_napi_stats);
  16557. + debugfs_remove(ag->debug.debugfs_int_stats);
  16558. + debugfs_remove(ag->debug.debugfs_dir);
  16559. +}
  16560. +
  16561. +int ag71xx_debugfs_init(struct ag71xx *ag)
  16562. +{
  16563. + ag->debug.debugfs_dir = debugfs_create_dir(ag->dev->name,
  16564. + ag71xx_debugfs_root);
  16565. + if (!ag->debug.debugfs_dir)
  16566. + goto err;
  16567. +
  16568. + ag->debug.debugfs_int_stats =
  16569. + debugfs_create_file("int_stats",
  16570. + S_IRUGO,
  16571. + ag->debug.debugfs_dir,
  16572. + ag,
  16573. + &ag71xx_fops_int_stats);
  16574. + if (!ag->debug.debugfs_int_stats)
  16575. + goto err;
  16576. +
  16577. + ag->debug.debugfs_napi_stats =
  16578. + debugfs_create_file("napi_stats",
  16579. + S_IRUGO,
  16580. + ag->debug.debugfs_dir,
  16581. + ag,
  16582. + &ag71xx_fops_napi_stats);
  16583. + if (!ag->debug.debugfs_napi_stats)
  16584. + goto err;
  16585. +
  16586. + return 0;
  16587. +
  16588. + err:
  16589. + ag71xx_debugfs_exit(ag);
  16590. + return -ENOMEM;
  16591. +}
  16592. +
  16593. +int ag71xx_debugfs_root_init(void)
  16594. +{
  16595. + if (ag71xx_debugfs_root)
  16596. + return -EBUSY;
  16597. +
  16598. + ag71xx_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
  16599. + if (!ag71xx_debugfs_root)
  16600. + return -ENOENT;
  16601. +
  16602. + return 0;
  16603. +}
  16604. +
  16605. +void ag71xx_debugfs_root_exit(void)
  16606. +{
  16607. + debugfs_remove(ag71xx_debugfs_root);
  16608. + ag71xx_debugfs_root = NULL;
  16609. +}
  16610. diff -Nur linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_ethtool.c linux-2.6.35.7/drivers/net/ag71xx/ag71xx_ethtool.c
  16611. --- linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_ethtool.c 1970-01-01 01:00:00.000000000 +0100
  16612. +++ linux-2.6.35.7/drivers/net/ag71xx/ag71xx_ethtool.c 2010-10-14 20:28:00.558101160 +0200
  16613. @@ -0,0 +1,71 @@
  16614. +/*
  16615. + * Atheros AR71xx built-in ethernet mac driver
  16616. + *
  16617. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  16618. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  16619. + *
  16620. + * Based on Atheros' AG7100 driver
  16621. + *
  16622. + * This program is free software; you can redistribute it and/or modify it
  16623. + * under the terms of the GNU General Public License version 2 as published
  16624. + * by the Free Software Foundation.
  16625. + */
  16626. +
  16627. +#include "ag71xx.h"
  16628. +
  16629. +static int ag71xx_ethtool_get_settings(struct net_device *dev,
  16630. + struct ethtool_cmd *cmd)
  16631. +{
  16632. + struct ag71xx *ag = netdev_priv(dev);
  16633. + struct phy_device *phydev = ag->phy_dev;
  16634. +
  16635. + if (!phydev)
  16636. + return -ENODEV;
  16637. +
  16638. + return phy_ethtool_gset(phydev, cmd);
  16639. +}
  16640. +
  16641. +static int ag71xx_ethtool_set_settings(struct net_device *dev,
  16642. + struct ethtool_cmd *cmd)
  16643. +{
  16644. + struct ag71xx *ag = netdev_priv(dev);
  16645. + struct phy_device *phydev = ag->phy_dev;
  16646. +
  16647. + if (!phydev)
  16648. + return -ENODEV;
  16649. +
  16650. + return phy_ethtool_sset(phydev, cmd);
  16651. +}
  16652. +
  16653. +static void ag71xx_ethtool_get_drvinfo(struct net_device *dev,
  16654. + struct ethtool_drvinfo *info)
  16655. +{
  16656. + struct ag71xx *ag = netdev_priv(dev);
  16657. +
  16658. + strcpy(info->driver, ag->pdev->dev.driver->name);
  16659. + strcpy(info->version, AG71XX_DRV_VERSION);
  16660. + strcpy(info->bus_info, dev_name(&ag->pdev->dev));
  16661. +}
  16662. +
  16663. +static u32 ag71xx_ethtool_get_msglevel(struct net_device *dev)
  16664. +{
  16665. + struct ag71xx *ag = netdev_priv(dev);
  16666. +
  16667. + return ag->msg_enable;
  16668. +}
  16669. +
  16670. +static void ag71xx_ethtool_set_msglevel(struct net_device *dev, u32 msg_level)
  16671. +{
  16672. + struct ag71xx *ag = netdev_priv(dev);
  16673. +
  16674. + ag->msg_enable = msg_level;
  16675. +}
  16676. +
  16677. +struct ethtool_ops ag71xx_ethtool_ops = {
  16678. + .set_settings = ag71xx_ethtool_set_settings,
  16679. + .get_settings = ag71xx_ethtool_get_settings,
  16680. + .get_drvinfo = ag71xx_ethtool_get_drvinfo,
  16681. + .get_msglevel = ag71xx_ethtool_get_msglevel,
  16682. + .set_msglevel = ag71xx_ethtool_set_msglevel,
  16683. + .get_link = ethtool_op_get_link,
  16684. +};
  16685. diff -Nur linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx.h linux-2.6.35.7/drivers/net/ag71xx/ag71xx.h
  16686. --- linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx.h 1970-01-01 01:00:00.000000000 +0100
  16687. +++ linux-2.6.35.7/drivers/net/ag71xx/ag71xx.h 2010-10-14 20:28:00.594356402 +0200
  16688. @@ -0,0 +1,500 @@
  16689. +/*
  16690. + * Atheros AR71xx built-in ethernet mac driver
  16691. + *
  16692. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  16693. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  16694. + *
  16695. + * Based on Atheros' AG7100 driver
  16696. + *
  16697. + * This program is free software; you can redistribute it and/or modify it
  16698. + * under the terms of the GNU General Public License version 2 as published
  16699. + * by the Free Software Foundation.
  16700. + */
  16701. +
  16702. +#ifndef __AG71XX_H
  16703. +#define __AG71XX_H
  16704. +
  16705. +#include <linux/kernel.h>
  16706. +#include <linux/version.h>
  16707. +#include <linux/module.h>
  16708. +#include <linux/init.h>
  16709. +#include <linux/types.h>
  16710. +#include <linux/random.h>
  16711. +#include <linux/spinlock.h>
  16712. +#include <linux/interrupt.h>
  16713. +#include <linux/platform_device.h>
  16714. +#include <linux/ethtool.h>
  16715. +#include <linux/etherdevice.h>
  16716. +#include <linux/phy.h>
  16717. +#include <linux/skbuff.h>
  16718. +#include <linux/dma-mapping.h>
  16719. +#include <linux/workqueue.h>
  16720. +
  16721. +#include <linux/bitops.h>
  16722. +
  16723. +#include <asm/mach-ar71xx/ar71xx.h>
  16724. +#include <asm/mach-ar71xx/platform.h>
  16725. +
  16726. +#define ETH_FCS_LEN 4
  16727. +
  16728. +#define AG71XX_DRV_NAME "ag71xx"
  16729. +#define AG71XX_DRV_VERSION "0.5.35"
  16730. +
  16731. +#define AG71XX_NAPI_WEIGHT 64
  16732. +#define AG71XX_OOM_REFILL (1 + HZ/10)
  16733. +
  16734. +#define AG71XX_INT_ERR (AG71XX_INT_RX_BE | AG71XX_INT_TX_BE)
  16735. +#define AG71XX_INT_TX (AG71XX_INT_TX_PS)
  16736. +#define AG71XX_INT_RX (AG71XX_INT_RX_PR | AG71XX_INT_RX_OF)
  16737. +
  16738. +#define AG71XX_INT_POLL (AG71XX_INT_RX | AG71XX_INT_TX)
  16739. +#define AG71XX_INT_INIT (AG71XX_INT_ERR | AG71XX_INT_POLL)
  16740. +
  16741. +#define AG71XX_TX_FIFO_LEN 2048
  16742. +#define AG71XX_TX_MTU_LEN 1536
  16743. +#define AG71XX_RX_PKT_RESERVE 64
  16744. +#define AG71XX_RX_PKT_SIZE \
  16745. + (AG71XX_RX_PKT_RESERVE + ETH_HLEN + ETH_FRAME_LEN + ETH_FCS_LEN)
  16746. +
  16747. +#define AG71XX_TX_RING_SIZE 64
  16748. +#define AG71XX_TX_THRES_STOP (AG71XX_TX_RING_SIZE - 4)
  16749. +#define AG71XX_TX_THRES_WAKEUP \
  16750. + (AG71XX_TX_RING_SIZE - (AG71XX_TX_RING_SIZE / 4))
  16751. +
  16752. +#define AG71XX_RX_RING_SIZE 128
  16753. +
  16754. +#ifdef CONFIG_AG71XX_DEBUG
  16755. +#define DBG(fmt, args...) printk(KERN_DEBUG fmt, ## args)
  16756. +#else
  16757. +#define DBG(fmt, args...) do {} while (0)
  16758. +#endif
  16759. +
  16760. +#define ag71xx_assert(_cond) \
  16761. +do { \
  16762. + if (_cond) \
  16763. + break; \
  16764. + printk("%s,%d: assertion failed\n", __FILE__, __LINE__); \
  16765. + BUG(); \
  16766. +} while (0)
  16767. +
  16768. +struct ag71xx_desc {
  16769. + u32 data;
  16770. + u32 ctrl;
  16771. +#define DESC_EMPTY BIT(31)
  16772. +#define DESC_MORE BIT(24)
  16773. +#define DESC_PKTLEN_M 0xfff
  16774. + u32 next;
  16775. + u32 pad;
  16776. +} __attribute__((aligned(4)));
  16777. +
  16778. +struct ag71xx_buf {
  16779. + struct sk_buff *skb;
  16780. + struct ag71xx_desc *desc;
  16781. + dma_addr_t dma_addr;
  16782. + u32 pad;
  16783. +};
  16784. +
  16785. +struct ag71xx_ring {
  16786. + struct ag71xx_buf *buf;
  16787. + u8 *descs_cpu;
  16788. + dma_addr_t descs_dma;
  16789. + unsigned int desc_size;
  16790. + unsigned int curr;
  16791. + unsigned int dirty;
  16792. + unsigned int size;
  16793. +};
  16794. +
  16795. +struct ag71xx_mdio {
  16796. + struct mii_bus *mii_bus;
  16797. + int mii_irq[PHY_MAX_ADDR];
  16798. + void __iomem *mdio_base;
  16799. + struct ag71xx_mdio_platform_data *pdata;
  16800. +};
  16801. +
  16802. +struct ag71xx_int_stats {
  16803. + unsigned long rx_pr;
  16804. + unsigned long rx_be;
  16805. + unsigned long rx_of;
  16806. + unsigned long tx_ps;
  16807. + unsigned long tx_be;
  16808. + unsigned long tx_ur;
  16809. + unsigned long total;
  16810. +};
  16811. +
  16812. +struct ag71xx_napi_stats {
  16813. + unsigned long napi_calls;
  16814. + unsigned long rx_count;
  16815. + unsigned long rx_packets;
  16816. + unsigned long rx_packets_max;
  16817. + unsigned long tx_count;
  16818. + unsigned long tx_packets;
  16819. + unsigned long tx_packets_max;
  16820. +
  16821. + unsigned long rx[AG71XX_NAPI_WEIGHT + 1];
  16822. + unsigned long tx[AG71XX_NAPI_WEIGHT + 1];
  16823. +};
  16824. +
  16825. +struct ag71xx_debug {
  16826. + struct dentry *debugfs_dir;
  16827. + struct dentry *debugfs_int_stats;
  16828. + struct dentry *debugfs_napi_stats;
  16829. +
  16830. + struct ag71xx_int_stats int_stats;
  16831. + struct ag71xx_napi_stats napi_stats;
  16832. +};
  16833. +
  16834. +struct ag71xx {
  16835. + void __iomem *mac_base;
  16836. + void __iomem *mii_ctrl;
  16837. +
  16838. + spinlock_t lock;
  16839. + struct platform_device *pdev;
  16840. + struct net_device *dev;
  16841. + struct napi_struct napi;
  16842. + u32 msg_enable;
  16843. +
  16844. + struct ag71xx_ring rx_ring;
  16845. + struct ag71xx_ring tx_ring;
  16846. +
  16847. + struct mii_bus *mii_bus;
  16848. + struct phy_device *phy_dev;
  16849. +
  16850. + unsigned int link;
  16851. + unsigned int speed;
  16852. + int duplex;
  16853. +
  16854. + struct work_struct restart_work;
  16855. + struct timer_list oom_timer;
  16856. +
  16857. +#ifdef CONFIG_AG71XX_DEBUG_FS
  16858. + struct ag71xx_debug debug;
  16859. +#endif
  16860. +};
  16861. +
  16862. +extern struct ethtool_ops ag71xx_ethtool_ops;
  16863. +void ag71xx_link_adjust(struct ag71xx *ag);
  16864. +
  16865. +int ag71xx_mdio_driver_init(void) __init;
  16866. +void ag71xx_mdio_driver_exit(void);
  16867. +
  16868. +int ag71xx_phy_connect(struct ag71xx *ag);
  16869. +void ag71xx_phy_disconnect(struct ag71xx *ag);
  16870. +void ag71xx_phy_start(struct ag71xx *ag);
  16871. +void ag71xx_phy_stop(struct ag71xx *ag);
  16872. +
  16873. +static inline struct ag71xx_platform_data *ag71xx_get_pdata(struct ag71xx *ag)
  16874. +{
  16875. + return ag->pdev->dev.platform_data;
  16876. +}
  16877. +
  16878. +static inline int ag71xx_desc_empty(struct ag71xx_desc *desc)
  16879. +{
  16880. + return ((desc->ctrl & DESC_EMPTY) != 0);
  16881. +}
  16882. +
  16883. +static inline int ag71xx_desc_pktlen(struct ag71xx_desc *desc)
  16884. +{
  16885. + return (desc->ctrl & DESC_PKTLEN_M);
  16886. +}
  16887. +
  16888. +/* Register offsets */
  16889. +#define AG71XX_REG_MAC_CFG1 0x0000
  16890. +#define AG71XX_REG_MAC_CFG2 0x0004
  16891. +#define AG71XX_REG_MAC_IPG 0x0008
  16892. +#define AG71XX_REG_MAC_HDX 0x000c
  16893. +#define AG71XX_REG_MAC_MFL 0x0010
  16894. +#define AG71XX_REG_MII_CFG 0x0020
  16895. +#define AG71XX_REG_MII_CMD 0x0024
  16896. +#define AG71XX_REG_MII_ADDR 0x0028
  16897. +#define AG71XX_REG_MII_CTRL 0x002c
  16898. +#define AG71XX_REG_MII_STATUS 0x0030
  16899. +#define AG71XX_REG_MII_IND 0x0034
  16900. +#define AG71XX_REG_MAC_IFCTL 0x0038
  16901. +#define AG71XX_REG_MAC_ADDR1 0x0040
  16902. +#define AG71XX_REG_MAC_ADDR2 0x0044
  16903. +#define AG71XX_REG_FIFO_CFG0 0x0048
  16904. +#define AG71XX_REG_FIFO_CFG1 0x004c
  16905. +#define AG71XX_REG_FIFO_CFG2 0x0050
  16906. +#define AG71XX_REG_FIFO_CFG3 0x0054
  16907. +#define AG71XX_REG_FIFO_CFG4 0x0058
  16908. +#define AG71XX_REG_FIFO_CFG5 0x005c
  16909. +#define AG71XX_REG_FIFO_RAM0 0x0060
  16910. +#define AG71XX_REG_FIFO_RAM1 0x0064
  16911. +#define AG71XX_REG_FIFO_RAM2 0x0068
  16912. +#define AG71XX_REG_FIFO_RAM3 0x006c
  16913. +#define AG71XX_REG_FIFO_RAM4 0x0070
  16914. +#define AG71XX_REG_FIFO_RAM5 0x0074
  16915. +#define AG71XX_REG_FIFO_RAM6 0x0078
  16916. +#define AG71XX_REG_FIFO_RAM7 0x007c
  16917. +
  16918. +#define AG71XX_REG_TX_CTRL 0x0180
  16919. +#define AG71XX_REG_TX_DESC 0x0184
  16920. +#define AG71XX_REG_TX_STATUS 0x0188
  16921. +#define AG71XX_REG_RX_CTRL 0x018c
  16922. +#define AG71XX_REG_RX_DESC 0x0190
  16923. +#define AG71XX_REG_RX_STATUS 0x0194
  16924. +#define AG71XX_REG_INT_ENABLE 0x0198
  16925. +#define AG71XX_REG_INT_STATUS 0x019c
  16926. +
  16927. +#define MAC_CFG1_TXE BIT(0) /* Tx Enable */
  16928. +#define MAC_CFG1_STX BIT(1) /* Synchronize Tx Enable */
  16929. +#define MAC_CFG1_RXE BIT(2) /* Rx Enable */
  16930. +#define MAC_CFG1_SRX BIT(3) /* Synchronize Rx Enable */
  16931. +#define MAC_CFG1_TFC BIT(4) /* Tx Flow Control Enable */
  16932. +#define MAC_CFG1_RFC BIT(5) /* Rx Flow Control Enable */
  16933. +#define MAC_CFG1_LB BIT(8) /* Loopback mode */
  16934. +#define MAC_CFG1_SR BIT(31) /* Soft Reset */
  16935. +
  16936. +#define MAC_CFG2_FDX BIT(0)
  16937. +#define MAC_CFG2_CRC_EN BIT(1)
  16938. +#define MAC_CFG2_PAD_CRC_EN BIT(2)
  16939. +#define MAC_CFG2_LEN_CHECK BIT(4)
  16940. +#define MAC_CFG2_HUGE_FRAME_EN BIT(5)
  16941. +#define MAC_CFG2_IF_1000 BIT(9)
  16942. +#define MAC_CFG2_IF_10_100 BIT(8)
  16943. +
  16944. +#define FIFO_CFG0_WTM BIT(0) /* Watermark Module */
  16945. +#define FIFO_CFG0_RXS BIT(1) /* Rx System Module */
  16946. +#define FIFO_CFG0_RXF BIT(2) /* Rx Fabric Module */
  16947. +#define FIFO_CFG0_TXS BIT(3) /* Tx System Module */
  16948. +#define FIFO_CFG0_TXF BIT(4) /* Tx Fabric Module */
  16949. +#define FIFO_CFG0_ALL (FIFO_CFG0_WTM | FIFO_CFG0_RXS | FIFO_CFG0_RXF \
  16950. + | FIFO_CFG0_TXS | FIFO_CFG0_TXF)
  16951. +
  16952. +#define FIFO_CFG0_ENABLE_SHIFT 8
  16953. +
  16954. +#define FIFO_CFG4_DE BIT(0) /* Drop Event */
  16955. +#define FIFO_CFG4_DV BIT(1) /* RX_DV Event */
  16956. +#define FIFO_CFG4_FC BIT(2) /* False Carrier */
  16957. +#define FIFO_CFG4_CE BIT(3) /* Code Error */
  16958. +#define FIFO_CFG4_CR BIT(4) /* CRC error */
  16959. +#define FIFO_CFG4_LM BIT(5) /* Length Mismatch */
  16960. +#define FIFO_CFG4_LO BIT(6) /* Length out of range */
  16961. +#define FIFO_CFG4_OK BIT(7) /* Packet is OK */
  16962. +#define FIFO_CFG4_MC BIT(8) /* Multicast Packet */
  16963. +#define FIFO_CFG4_BC BIT(9) /* Broadcast Packet */
  16964. +#define FIFO_CFG4_DR BIT(10) /* Dribble */
  16965. +#define FIFO_CFG4_LE BIT(11) /* Long Event */
  16966. +#define FIFO_CFG4_CF BIT(12) /* Control Frame */
  16967. +#define FIFO_CFG4_PF BIT(13) /* Pause Frame */
  16968. +#define FIFO_CFG4_UO BIT(14) /* Unsupported Opcode */
  16969. +#define FIFO_CFG4_VT BIT(15) /* VLAN tag detected */
  16970. +#define FIFO_CFG4_FT BIT(16) /* Frame Truncated */
  16971. +#define FIFO_CFG4_UC BIT(17) /* Unicast Packet */
  16972. +
  16973. +#define FIFO_CFG5_DE BIT(0) /* Drop Event */
  16974. +#define FIFO_CFG5_DV BIT(1) /* RX_DV Event */
  16975. +#define FIFO_CFG5_FC BIT(2) /* False Carrier */
  16976. +#define FIFO_CFG5_CE BIT(3) /* Code Error */
  16977. +#define FIFO_CFG5_LM BIT(4) /* Length Mismatch */
  16978. +#define FIFO_CFG5_LO BIT(5) /* Length Out of Range */
  16979. +#define FIFO_CFG5_OK BIT(6) /* Packet is OK */
  16980. +#define FIFO_CFG5_MC BIT(7) /* Multicast Packet */
  16981. +#define FIFO_CFG5_BC BIT(8) /* Broadcast Packet */
  16982. +#define FIFO_CFG5_DR BIT(9) /* Dribble */
  16983. +#define FIFO_CFG5_CF BIT(10) /* Control Frame */
  16984. +#define FIFO_CFG5_PF BIT(11) /* Pause Frame */
  16985. +#define FIFO_CFG5_UO BIT(12) /* Unsupported Opcode */
  16986. +#define FIFO_CFG5_VT BIT(13) /* VLAN tag detected */
  16987. +#define FIFO_CFG5_LE BIT(14) /* Long Event */
  16988. +#define FIFO_CFG5_FT BIT(15) /* Frame Truncated */
  16989. +#define FIFO_CFG5_16 BIT(16) /* unknown */
  16990. +#define FIFO_CFG5_17 BIT(17) /* unknown */
  16991. +#define FIFO_CFG5_SF BIT(18) /* Short Frame */
  16992. +#define FIFO_CFG5_BM BIT(19) /* Byte Mode */
  16993. +
  16994. +#define AG71XX_INT_TX_PS BIT(0)
  16995. +#define AG71XX_INT_TX_UR BIT(1)
  16996. +#define AG71XX_INT_TX_BE BIT(3)
  16997. +#define AG71XX_INT_RX_PR BIT(4)
  16998. +#define AG71XX_INT_RX_OF BIT(6)
  16999. +#define AG71XX_INT_RX_BE BIT(7)
  17000. +
  17001. +#define MAC_IFCTL_SPEED BIT(16)
  17002. +
  17003. +#define MII_CFG_CLK_DIV_4 0
  17004. +#define MII_CFG_CLK_DIV_6 2
  17005. +#define MII_CFG_CLK_DIV_8 3
  17006. +#define MII_CFG_CLK_DIV_10 4
  17007. +#define MII_CFG_CLK_DIV_14 5
  17008. +#define MII_CFG_CLK_DIV_20 6
  17009. +#define MII_CFG_CLK_DIV_28 7
  17010. +#define MII_CFG_RESET BIT(31)
  17011. +
  17012. +#define MII_CMD_WRITE 0x0
  17013. +#define MII_CMD_READ 0x1
  17014. +#define MII_ADDR_SHIFT 8
  17015. +#define MII_IND_BUSY BIT(0)
  17016. +#define MII_IND_INVALID BIT(2)
  17017. +
  17018. +#define TX_CTRL_TXE BIT(0) /* Tx Enable */
  17019. +
  17020. +#define TX_STATUS_PS BIT(0) /* Packet Sent */
  17021. +#define TX_STATUS_UR BIT(1) /* Tx Underrun */
  17022. +#define TX_STATUS_BE BIT(3) /* Bus Error */
  17023. +
  17024. +#define RX_CTRL_RXE BIT(0) /* Rx Enable */
  17025. +
  17026. +#define RX_STATUS_PR BIT(0) /* Packet Received */
  17027. +#define RX_STATUS_OF BIT(2) /* Rx Overflow */
  17028. +#define RX_STATUS_BE BIT(3) /* Bus Error */
  17029. +
  17030. +#define MII_CTRL_IF_MASK 3
  17031. +#define MII_CTRL_SPEED_SHIFT 4
  17032. +#define MII_CTRL_SPEED_MASK 3
  17033. +#define MII_CTRL_SPEED_10 0
  17034. +#define MII_CTRL_SPEED_100 1
  17035. +#define MII_CTRL_SPEED_1000 2
  17036. +
  17037. +static inline void ag71xx_check_reg_offset(struct ag71xx *ag, unsigned reg)
  17038. +{
  17039. + switch (reg) {
  17040. + case AG71XX_REG_MAC_CFG1 ... AG71XX_REG_MAC_MFL:
  17041. + case AG71XX_REG_MAC_IFCTL ... AG71XX_REG_INT_STATUS:
  17042. + break;
  17043. +
  17044. + default:
  17045. + BUG();
  17046. + }
  17047. +}
  17048. +
  17049. +static inline void ag71xx_wr(struct ag71xx *ag, unsigned reg, u32 value)
  17050. +{
  17051. + ag71xx_check_reg_offset(ag, reg);
  17052. +
  17053. + __raw_writel(value, ag->mac_base + reg);
  17054. + /* flush write */
  17055. + (void) __raw_readl(ag->mac_base + reg);
  17056. +}
  17057. +
  17058. +static inline u32 ag71xx_rr(struct ag71xx *ag, unsigned reg)
  17059. +{
  17060. + ag71xx_check_reg_offset(ag, reg);
  17061. +
  17062. + return __raw_readl(ag->mac_base + reg);
  17063. +}
  17064. +
  17065. +static inline void ag71xx_sb(struct ag71xx *ag, unsigned reg, u32 mask)
  17066. +{
  17067. + void __iomem *r;
  17068. +
  17069. + ag71xx_check_reg_offset(ag, reg);
  17070. +
  17071. + r = ag->mac_base + reg;
  17072. + __raw_writel(__raw_readl(r) | mask, r);
  17073. + /* flush write */
  17074. + (void)__raw_readl(r);
  17075. +}
  17076. +
  17077. +static inline void ag71xx_cb(struct ag71xx *ag, unsigned reg, u32 mask)
  17078. +{
  17079. + void __iomem *r;
  17080. +
  17081. + ag71xx_check_reg_offset(ag, reg);
  17082. +
  17083. + r = ag->mac_base + reg;
  17084. + __raw_writel(__raw_readl(r) & ~mask, r);
  17085. + /* flush write */
  17086. + (void) __raw_readl(r);
  17087. +}
  17088. +
  17089. +static inline void ag71xx_int_enable(struct ag71xx *ag, u32 ints)
  17090. +{
  17091. + ag71xx_sb(ag, AG71XX_REG_INT_ENABLE, ints);
  17092. +}
  17093. +
  17094. +static inline void ag71xx_int_disable(struct ag71xx *ag, u32 ints)
  17095. +{
  17096. + ag71xx_cb(ag, AG71XX_REG_INT_ENABLE, ints);
  17097. +}
  17098. +
  17099. +static inline void ag71xx_mii_ctrl_wr(struct ag71xx *ag, u32 value)
  17100. +{
  17101. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  17102. +
  17103. + if (pdata->is_ar724x)
  17104. + return;
  17105. +
  17106. + __raw_writel(value, ag->mii_ctrl);
  17107. +
  17108. + /* flush write */
  17109. + __raw_readl(ag->mii_ctrl);
  17110. +}
  17111. +
  17112. +static inline u32 ag71xx_mii_ctrl_rr(struct ag71xx *ag)
  17113. +{
  17114. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  17115. +
  17116. + if (pdata->is_ar724x)
  17117. + return 0xffffffff;
  17118. +
  17119. + return __raw_readl(ag->mii_ctrl);
  17120. +}
  17121. +
  17122. +static void inline ag71xx_mii_ctrl_set_if(struct ag71xx *ag,
  17123. + unsigned int mii_if)
  17124. +{
  17125. + u32 t;
  17126. +
  17127. + t = ag71xx_mii_ctrl_rr(ag);
  17128. + t &= ~(MII_CTRL_IF_MASK);
  17129. + t |= (mii_if & MII_CTRL_IF_MASK);
  17130. + ag71xx_mii_ctrl_wr(ag, t);
  17131. +}
  17132. +
  17133. +static void inline ag71xx_mii_ctrl_set_speed(struct ag71xx *ag,
  17134. + unsigned int speed)
  17135. +{
  17136. + u32 t;
  17137. +
  17138. + t = ag71xx_mii_ctrl_rr(ag);
  17139. + t &= ~(MII_CTRL_SPEED_MASK << MII_CTRL_SPEED_SHIFT);
  17140. + t |= (speed & MII_CTRL_SPEED_MASK) << MII_CTRL_SPEED_SHIFT;
  17141. + ag71xx_mii_ctrl_wr(ag, t);
  17142. +}
  17143. +
  17144. +#ifdef CONFIG_AG71XX_AR8216_SUPPORT
  17145. +void ag71xx_add_ar8216_header(struct ag71xx *ag, struct sk_buff *skb);
  17146. +int ag71xx_remove_ar8216_header(struct ag71xx *ag, struct sk_buff *skb,
  17147. + int pktlen);
  17148. +static inline int ag71xx_has_ar8216(struct ag71xx *ag)
  17149. +{
  17150. + return ag71xx_get_pdata(ag)->has_ar8216;
  17151. +}
  17152. +#else
  17153. +static inline void ag71xx_add_ar8216_header(struct ag71xx *ag,
  17154. + struct sk_buff *skb)
  17155. +{
  17156. +}
  17157. +
  17158. +static inline int ag71xx_remove_ar8216_header(struct ag71xx *ag,
  17159. + struct sk_buff *skb,
  17160. + int pktlen)
  17161. +{
  17162. + return 0;
  17163. +}
  17164. +static inline int ag71xx_has_ar8216(struct ag71xx *ag)
  17165. +{
  17166. + return 0;
  17167. +}
  17168. +#endif
  17169. +
  17170. +#ifdef CONFIG_AG71XX_DEBUG_FS
  17171. +int ag71xx_debugfs_root_init(void);
  17172. +void ag71xx_debugfs_root_exit(void);
  17173. +int ag71xx_debugfs_init(struct ag71xx *ag);
  17174. +void ag71xx_debugfs_exit(struct ag71xx *ag);
  17175. +void ag71xx_debugfs_update_int_stats(struct ag71xx *ag, u32 status);
  17176. +void ag71xx_debugfs_update_napi_stats(struct ag71xx *ag, int rx, int tx);
  17177. +#else
  17178. +static inline int ag71xx_debugfs_root_init(void) { return 0; }
  17179. +static inline void ag71xx_debugfs_root_exit(void) {}
  17180. +static inline int ag71xx_debugfs_init(struct ag71xx *ag) { return 0; }
  17181. +static inline void ag71xx_debugfs_exit(struct ag71xx *ag) {}
  17182. +static inline void ag71xx_debugfs_update_int_stats(struct ag71xx *ag,
  17183. + u32 status) {}
  17184. +static inline void ag71xx_debugfs_update_napi_stats(struct ag71xx *ag,
  17185. + int rx, int tx) {}
  17186. +#endif /* CONFIG_AG71XX_DEBUG_FS */
  17187. +
  17188. +#endif /* _AG71XX_H */
  17189. diff -Nur linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_main.c linux-2.6.35.7/drivers/net/ag71xx/ag71xx_main.c
  17190. --- linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_main.c 1970-01-01 01:00:00.000000000 +0100
  17191. +++ linux-2.6.35.7/drivers/net/ag71xx/ag71xx_main.c 2010-10-14 20:28:00.638101269 +0200
  17192. @@ -0,0 +1,1184 @@
  17193. +/*
  17194. + * Atheros AR71xx built-in ethernet mac driver
  17195. + *
  17196. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  17197. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  17198. + *
  17199. + * Based on Atheros' AG7100 driver
  17200. + *
  17201. + * This program is free software; you can redistribute it and/or modify it
  17202. + * under the terms of the GNU General Public License version 2 as published
  17203. + * by the Free Software Foundation.
  17204. + */
  17205. +
  17206. +#include "ag71xx.h"
  17207. +
  17208. +#define AG71XX_DEFAULT_MSG_ENABLE \
  17209. + ( NETIF_MSG_DRV \
  17210. + | NETIF_MSG_PROBE \
  17211. + | NETIF_MSG_LINK \
  17212. + | NETIF_MSG_TIMER \
  17213. + | NETIF_MSG_IFDOWN \
  17214. + | NETIF_MSG_IFUP \
  17215. + | NETIF_MSG_RX_ERR \
  17216. + | NETIF_MSG_TX_ERR )
  17217. +
  17218. +static int ag71xx_msg_level = -1;
  17219. +
  17220. +module_param_named(msg_level, ag71xx_msg_level, int, 0);
  17221. +MODULE_PARM_DESC(msg_level, "Message level (-1=defaults,0=none,...,16=all)");
  17222. +
  17223. +static void ag71xx_dump_dma_regs(struct ag71xx *ag)
  17224. +{
  17225. + DBG("%s: dma_tx_ctrl=%08x, dma_tx_desc=%08x, dma_tx_status=%08x\n",
  17226. + ag->dev->name,
  17227. + ag71xx_rr(ag, AG71XX_REG_TX_CTRL),
  17228. + ag71xx_rr(ag, AG71XX_REG_TX_DESC),
  17229. + ag71xx_rr(ag, AG71XX_REG_TX_STATUS));
  17230. +
  17231. + DBG("%s: dma_rx_ctrl=%08x, dma_rx_desc=%08x, dma_rx_status=%08x\n",
  17232. + ag->dev->name,
  17233. + ag71xx_rr(ag, AG71XX_REG_RX_CTRL),
  17234. + ag71xx_rr(ag, AG71XX_REG_RX_DESC),
  17235. + ag71xx_rr(ag, AG71XX_REG_RX_STATUS));
  17236. +}
  17237. +
  17238. +static void ag71xx_dump_regs(struct ag71xx *ag)
  17239. +{
  17240. + DBG("%s: mac_cfg1=%08x, mac_cfg2=%08x, ipg=%08x, hdx=%08x, mfl=%08x\n",
  17241. + ag->dev->name,
  17242. + ag71xx_rr(ag, AG71XX_REG_MAC_CFG1),
  17243. + ag71xx_rr(ag, AG71XX_REG_MAC_CFG2),
  17244. + ag71xx_rr(ag, AG71XX_REG_MAC_IPG),
  17245. + ag71xx_rr(ag, AG71XX_REG_MAC_HDX),
  17246. + ag71xx_rr(ag, AG71XX_REG_MAC_MFL));
  17247. + DBG("%s: mac_ifctl=%08x, mac_addr1=%08x, mac_addr2=%08x\n",
  17248. + ag->dev->name,
  17249. + ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL),
  17250. + ag71xx_rr(ag, AG71XX_REG_MAC_ADDR1),
  17251. + ag71xx_rr(ag, AG71XX_REG_MAC_ADDR2));
  17252. + DBG("%s: fifo_cfg0=%08x, fifo_cfg1=%08x, fifo_cfg2=%08x\n",
  17253. + ag->dev->name,
  17254. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG0),
  17255. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG1),
  17256. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG2));
  17257. + DBG("%s: fifo_cfg3=%08x, fifo_cfg4=%08x, fifo_cfg5=%08x\n",
  17258. + ag->dev->name,
  17259. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG3),
  17260. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG4),
  17261. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5));
  17262. +}
  17263. +
  17264. +static inline void ag71xx_dump_intr(struct ag71xx *ag, char *label, u32 intr)
  17265. +{
  17266. + DBG("%s: %s intr=%08x %s%s%s%s%s%s\n",
  17267. + ag->dev->name, label, intr,
  17268. + (intr & AG71XX_INT_TX_PS) ? "TXPS " : "",
  17269. + (intr & AG71XX_INT_TX_UR) ? "TXUR " : "",
  17270. + (intr & AG71XX_INT_TX_BE) ? "TXBE " : "",
  17271. + (intr & AG71XX_INT_RX_PR) ? "RXPR " : "",
  17272. + (intr & AG71XX_INT_RX_OF) ? "RXOF " : "",
  17273. + (intr & AG71XX_INT_RX_BE) ? "RXBE " : "");
  17274. +}
  17275. +
  17276. +static void ag71xx_ring_free(struct ag71xx_ring *ring)
  17277. +{
  17278. + kfree(ring->buf);
  17279. +
  17280. + if (ring->descs_cpu)
  17281. + dma_free_coherent(NULL, ring->size * ring->desc_size,
  17282. + ring->descs_cpu, ring->descs_dma);
  17283. +}
  17284. +
  17285. +static int ag71xx_ring_alloc(struct ag71xx_ring *ring, unsigned int size)
  17286. +{
  17287. + int err;
  17288. + int i;
  17289. +
  17290. + ring->desc_size = sizeof(struct ag71xx_desc);
  17291. + if (ring->desc_size % cache_line_size()) {
  17292. + DBG("ag71xx: ring %p, desc size %u rounded to %u\n",
  17293. + ring, ring->desc_size,
  17294. + roundup(ring->desc_size, cache_line_size()));
  17295. + ring->desc_size = roundup(ring->desc_size, cache_line_size());
  17296. + }
  17297. +
  17298. + ring->descs_cpu = dma_alloc_coherent(NULL, size * ring->desc_size,
  17299. + &ring->descs_dma, GFP_ATOMIC);
  17300. + if (!ring->descs_cpu) {
  17301. + err = -ENOMEM;
  17302. + goto err;
  17303. + }
  17304. +
  17305. + ring->size = size;
  17306. +
  17307. + ring->buf = kzalloc(size * sizeof(*ring->buf), GFP_KERNEL);
  17308. + if (!ring->buf) {
  17309. + err = -ENOMEM;
  17310. + goto err;
  17311. + }
  17312. +
  17313. + for (i = 0; i < size; i++) {
  17314. + ring->buf[i].desc = (struct ag71xx_desc *)&ring->descs_cpu[i * ring->desc_size];
  17315. + DBG("ag71xx: ring %p, desc %d at %p\n",
  17316. + ring, i, ring->buf[i].desc);
  17317. + }
  17318. +
  17319. + return 0;
  17320. +
  17321. + err:
  17322. + return err;
  17323. +}
  17324. +
  17325. +static void ag71xx_ring_tx_clean(struct ag71xx *ag)
  17326. +{
  17327. + struct ag71xx_ring *ring = &ag->tx_ring;
  17328. + struct net_device *dev = ag->dev;
  17329. +
  17330. + while (ring->curr != ring->dirty) {
  17331. + u32 i = ring->dirty % AG71XX_TX_RING_SIZE;
  17332. +
  17333. + if (!ag71xx_desc_empty(ring->buf[i].desc)) {
  17334. + ring->buf[i].desc->ctrl = 0;
  17335. + dev->stats.tx_errors++;
  17336. + }
  17337. +
  17338. + if (ring->buf[i].skb)
  17339. + dev_kfree_skb_any(ring->buf[i].skb);
  17340. +
  17341. + ring->buf[i].skb = NULL;
  17342. +
  17343. + ring->dirty++;
  17344. + }
  17345. +
  17346. + /* flush descriptors */
  17347. + wmb();
  17348. +
  17349. +}
  17350. +
  17351. +static void ag71xx_ring_tx_init(struct ag71xx *ag)
  17352. +{
  17353. + struct ag71xx_ring *ring = &ag->tx_ring;
  17354. + int i;
  17355. +
  17356. + for (i = 0; i < AG71XX_TX_RING_SIZE; i++) {
  17357. + ring->buf[i].desc->next = (u32) (ring->descs_dma +
  17358. + ring->desc_size * ((i + 1) % AG71XX_TX_RING_SIZE));
  17359. +
  17360. + ring->buf[i].desc->ctrl = DESC_EMPTY;
  17361. + ring->buf[i].skb = NULL;
  17362. + }
  17363. +
  17364. + /* flush descriptors */
  17365. + wmb();
  17366. +
  17367. + ring->curr = 0;
  17368. + ring->dirty = 0;
  17369. +}
  17370. +
  17371. +static void ag71xx_ring_rx_clean(struct ag71xx *ag)
  17372. +{
  17373. + struct ag71xx_ring *ring = &ag->rx_ring;
  17374. + int i;
  17375. +
  17376. + if (!ring->buf)
  17377. + return;
  17378. +
  17379. + for (i = 0; i < AG71XX_RX_RING_SIZE; i++)
  17380. + if (ring->buf[i].skb) {
  17381. + dma_unmap_single(&ag->dev->dev, ring->buf[i].dma_addr,
  17382. + AG71XX_RX_PKT_SIZE, DMA_FROM_DEVICE);
  17383. + kfree_skb(ring->buf[i].skb);
  17384. + }
  17385. +}
  17386. +
  17387. +static int ag71xx_rx_reserve(struct ag71xx *ag)
  17388. +{
  17389. + int reserve = 0;
  17390. +
  17391. + if (ag71xx_get_pdata(ag)->is_ar724x) {
  17392. + if (!ag71xx_has_ar8216(ag))
  17393. + reserve = 2;
  17394. +
  17395. + if (ag->phy_dev)
  17396. + reserve += 4 - (ag->phy_dev->pkt_align % 4);
  17397. +
  17398. + reserve %= 4;
  17399. + }
  17400. +
  17401. + return reserve + AG71XX_RX_PKT_RESERVE;
  17402. +}
  17403. +
  17404. +
  17405. +static int ag71xx_ring_rx_init(struct ag71xx *ag)
  17406. +{
  17407. + struct ag71xx_ring *ring = &ag->rx_ring;
  17408. + unsigned int reserve = ag71xx_rx_reserve(ag);
  17409. + unsigned int i;
  17410. + int ret;
  17411. +
  17412. + ret = 0;
  17413. + for (i = 0; i < AG71XX_RX_RING_SIZE; i++) {
  17414. + ring->buf[i].desc->next = (u32) (ring->descs_dma +
  17415. + ring->desc_size * ((i + 1) % AG71XX_RX_RING_SIZE));
  17416. +
  17417. + DBG("ag71xx: RX desc at %p, next is %08x\n",
  17418. + ring->buf[i].desc,
  17419. + ring->buf[i].desc->next);
  17420. + }
  17421. +
  17422. + for (i = 0; i < AG71XX_RX_RING_SIZE; i++) {
  17423. + struct sk_buff *skb;
  17424. + dma_addr_t dma_addr;
  17425. +
  17426. + skb = dev_alloc_skb(AG71XX_RX_PKT_SIZE + reserve);
  17427. + if (!skb) {
  17428. + ret = -ENOMEM;
  17429. + break;
  17430. + }
  17431. +
  17432. + skb->dev = ag->dev;
  17433. + skb_reserve(skb, reserve);
  17434. +
  17435. + dma_addr = dma_map_single(&ag->dev->dev, skb->data,
  17436. + AG71XX_RX_PKT_SIZE,
  17437. + DMA_FROM_DEVICE);
  17438. + ring->buf[i].skb = skb;
  17439. + ring->buf[i].dma_addr = dma_addr;
  17440. + ring->buf[i].desc->data = (u32) dma_addr;
  17441. + ring->buf[i].desc->ctrl = DESC_EMPTY;
  17442. + }
  17443. +
  17444. + /* flush descriptors */
  17445. + wmb();
  17446. +
  17447. + ring->curr = 0;
  17448. + ring->dirty = 0;
  17449. +
  17450. + return ret;
  17451. +}
  17452. +
  17453. +static int ag71xx_ring_rx_refill(struct ag71xx *ag)
  17454. +{
  17455. + struct ag71xx_ring *ring = &ag->rx_ring;
  17456. + unsigned int reserve = ag71xx_rx_reserve(ag);
  17457. + unsigned int count;
  17458. +
  17459. + count = 0;
  17460. + for (; ring->curr - ring->dirty > 0; ring->dirty++) {
  17461. + unsigned int i;
  17462. +
  17463. + i = ring->dirty % AG71XX_RX_RING_SIZE;
  17464. +
  17465. + if (ring->buf[i].skb == NULL) {
  17466. + dma_addr_t dma_addr;
  17467. + struct sk_buff *skb;
  17468. +
  17469. + skb = dev_alloc_skb(AG71XX_RX_PKT_SIZE + reserve);
  17470. + if (skb == NULL)
  17471. + break;
  17472. +
  17473. + skb_reserve(skb, reserve);
  17474. + skb->dev = ag->dev;
  17475. +
  17476. + dma_addr = dma_map_single(&ag->dev->dev, skb->data,
  17477. + AG71XX_RX_PKT_SIZE,
  17478. + DMA_FROM_DEVICE);
  17479. +
  17480. + ring->buf[i].skb = skb;
  17481. + ring->buf[i].dma_addr = dma_addr;
  17482. + ring->buf[i].desc->data = (u32) dma_addr;
  17483. + }
  17484. +
  17485. + ring->buf[i].desc->ctrl = DESC_EMPTY;
  17486. + count++;
  17487. + }
  17488. +
  17489. + /* flush descriptors */
  17490. + wmb();
  17491. +
  17492. + DBG("%s: %u rx descriptors refilled\n", ag->dev->name, count);
  17493. +
  17494. + return count;
  17495. +}
  17496. +
  17497. +static int ag71xx_rings_init(struct ag71xx *ag)
  17498. +{
  17499. + int ret;
  17500. +
  17501. + ret = ag71xx_ring_alloc(&ag->tx_ring, AG71XX_TX_RING_SIZE);
  17502. + if (ret)
  17503. + return ret;
  17504. +
  17505. + ag71xx_ring_tx_init(ag);
  17506. +
  17507. + ret = ag71xx_ring_alloc(&ag->rx_ring, AG71XX_RX_RING_SIZE);
  17508. + if (ret)
  17509. + return ret;
  17510. +
  17511. + ret = ag71xx_ring_rx_init(ag);
  17512. + return ret;
  17513. +}
  17514. +
  17515. +static void ag71xx_rings_cleanup(struct ag71xx *ag)
  17516. +{
  17517. + ag71xx_ring_rx_clean(ag);
  17518. + ag71xx_ring_free(&ag->rx_ring);
  17519. +
  17520. + ag71xx_ring_tx_clean(ag);
  17521. + ag71xx_ring_free(&ag->tx_ring);
  17522. +}
  17523. +
  17524. +static unsigned char *ag71xx_speed_str(struct ag71xx *ag)
  17525. +{
  17526. + switch (ag->speed) {
  17527. + case SPEED_1000:
  17528. + return "1000";
  17529. + case SPEED_100:
  17530. + return "100";
  17531. + case SPEED_10:
  17532. + return "10";
  17533. + }
  17534. +
  17535. + return "?";
  17536. +}
  17537. +
  17538. +void ag71xx_link_adjust(struct ag71xx *ag)
  17539. +{
  17540. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  17541. + u32 cfg2;
  17542. + u32 ifctl;
  17543. + u32 fifo5;
  17544. + u32 mii_speed;
  17545. +
  17546. + if (!ag->link) {
  17547. + netif_carrier_off(ag->dev);
  17548. + if (netif_msg_link(ag))
  17549. + printk(KERN_INFO "%s: link down\n", ag->dev->name);
  17550. + return;
  17551. + }
  17552. +
  17553. + cfg2 = ag71xx_rr(ag, AG71XX_REG_MAC_CFG2);
  17554. + cfg2 &= ~(MAC_CFG2_IF_1000 | MAC_CFG2_IF_10_100 | MAC_CFG2_FDX);
  17555. + cfg2 |= (ag->duplex) ? MAC_CFG2_FDX : 0;
  17556. +
  17557. + ifctl = ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL);
  17558. + ifctl &= ~(MAC_IFCTL_SPEED);
  17559. +
  17560. + fifo5 = ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5);
  17561. + fifo5 &= ~FIFO_CFG5_BM;
  17562. +
  17563. + switch (ag->speed) {
  17564. + case SPEED_1000:
  17565. + mii_speed = MII_CTRL_SPEED_1000;
  17566. + cfg2 |= MAC_CFG2_IF_1000;
  17567. + fifo5 |= FIFO_CFG5_BM;
  17568. + break;
  17569. + case SPEED_100:
  17570. + mii_speed = MII_CTRL_SPEED_100;
  17571. + cfg2 |= MAC_CFG2_IF_10_100;
  17572. + ifctl |= MAC_IFCTL_SPEED;
  17573. + break;
  17574. + case SPEED_10:
  17575. + mii_speed = MII_CTRL_SPEED_10;
  17576. + cfg2 |= MAC_CFG2_IF_10_100;
  17577. + break;
  17578. + default:
  17579. + BUG();
  17580. + return;
  17581. + }
  17582. +
  17583. + if (pdata->is_ar91xx)
  17584. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3, 0x00780fff);
  17585. + else if (pdata->is_ar724x)
  17586. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3, pdata->fifo_cfg3);
  17587. + else
  17588. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG3, 0x008001ff);
  17589. +
  17590. + if (pdata->set_pll)
  17591. + pdata->set_pll(ag->speed);
  17592. +
  17593. + ag71xx_mii_ctrl_set_speed(ag, mii_speed);
  17594. +
  17595. + ag71xx_wr(ag, AG71XX_REG_MAC_CFG2, cfg2);
  17596. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, fifo5);
  17597. + ag71xx_wr(ag, AG71XX_REG_MAC_IFCTL, ifctl);
  17598. +
  17599. + netif_carrier_on(ag->dev);
  17600. + if (netif_msg_link(ag))
  17601. + printk(KERN_INFO "%s: link up (%sMbps/%s duplex)\n",
  17602. + ag->dev->name,
  17603. + ag71xx_speed_str(ag),
  17604. + (DUPLEX_FULL == ag->duplex) ? "Full" : "Half");
  17605. +
  17606. + DBG("%s: fifo_cfg0=%#x, fifo_cfg1=%#x, fifo_cfg2=%#x\n",
  17607. + ag->dev->name,
  17608. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG0),
  17609. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG1),
  17610. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG2));
  17611. +
  17612. + DBG("%s: fifo_cfg3=%#x, fifo_cfg4=%#x, fifo_cfg5=%#x\n",
  17613. + ag->dev->name,
  17614. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG3),
  17615. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG4),
  17616. + ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5));
  17617. +
  17618. + DBG("%s: mac_cfg2=%#x, mac_ifctl=%#x, mii_ctrl=%#x\n",
  17619. + ag->dev->name,
  17620. + ag71xx_rr(ag, AG71XX_REG_MAC_CFG2),
  17621. + ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL),
  17622. + ag71xx_mii_ctrl_rr(ag));
  17623. +}
  17624. +
  17625. +static void ag71xx_hw_set_macaddr(struct ag71xx *ag, unsigned char *mac)
  17626. +{
  17627. + u32 t;
  17628. +
  17629. + t = (((u32) mac[5]) << 24) | (((u32) mac[4]) << 16)
  17630. + | (((u32) mac[3]) << 8) | ((u32) mac[2]);
  17631. +
  17632. + ag71xx_wr(ag, AG71XX_REG_MAC_ADDR1, t);
  17633. +
  17634. + t = (((u32) mac[1]) << 24) | (((u32) mac[0]) << 16);
  17635. + ag71xx_wr(ag, AG71XX_REG_MAC_ADDR2, t);
  17636. +}
  17637. +
  17638. +static void ag71xx_dma_reset(struct ag71xx *ag)
  17639. +{
  17640. + u32 val;
  17641. + int i;
  17642. +
  17643. + ag71xx_dump_dma_regs(ag);
  17644. +
  17645. + /* stop RX and TX */
  17646. + ag71xx_wr(ag, AG71XX_REG_RX_CTRL, 0);
  17647. + ag71xx_wr(ag, AG71XX_REG_TX_CTRL, 0);
  17648. +
  17649. + /* clear descriptor addresses */
  17650. + ag71xx_wr(ag, AG71XX_REG_TX_DESC, 0);
  17651. + ag71xx_wr(ag, AG71XX_REG_RX_DESC, 0);
  17652. +
  17653. + /* clear pending RX/TX interrupts */
  17654. + for (i = 0; i < 256; i++) {
  17655. + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_PR);
  17656. + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_PS);
  17657. + }
  17658. +
  17659. + /* clear pending errors */
  17660. + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_BE | RX_STATUS_OF);
  17661. + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_BE | TX_STATUS_UR);
  17662. +
  17663. + val = ag71xx_rr(ag, AG71XX_REG_RX_STATUS);
  17664. + if (val)
  17665. + printk(KERN_ALERT "%s: unable to clear DMA Rx status: %08x\n",
  17666. + ag->dev->name, val);
  17667. +
  17668. + val = ag71xx_rr(ag, AG71XX_REG_TX_STATUS);
  17669. +
  17670. + /* mask out reserved bits */
  17671. + val &= ~0xff000000;
  17672. +
  17673. + if (val)
  17674. + printk(KERN_ALERT "%s: unable to clear DMA Tx status: %08x\n",
  17675. + ag->dev->name, val);
  17676. +
  17677. + ag71xx_dump_dma_regs(ag);
  17678. +}
  17679. +
  17680. +#define MAC_CFG1_INIT (MAC_CFG1_RXE | MAC_CFG1_TXE | \
  17681. + MAC_CFG1_SRX | MAC_CFG1_STX)
  17682. +
  17683. +#define FIFO_CFG0_INIT (FIFO_CFG0_ALL << FIFO_CFG0_ENABLE_SHIFT)
  17684. +
  17685. +#define FIFO_CFG4_INIT (FIFO_CFG4_DE | FIFO_CFG4_DV | FIFO_CFG4_FC | \
  17686. + FIFO_CFG4_CE | FIFO_CFG4_CR | FIFO_CFG4_LM | \
  17687. + FIFO_CFG4_LO | FIFO_CFG4_OK | FIFO_CFG4_MC | \
  17688. + FIFO_CFG4_BC | FIFO_CFG4_DR | FIFO_CFG4_LE | \
  17689. + FIFO_CFG4_CF | FIFO_CFG4_PF | FIFO_CFG4_UO | \
  17690. + FIFO_CFG4_VT)
  17691. +
  17692. +#define FIFO_CFG5_INIT (FIFO_CFG5_DE | FIFO_CFG5_DV | FIFO_CFG5_FC | \
  17693. + FIFO_CFG5_CE | FIFO_CFG5_LO | FIFO_CFG5_OK | \
  17694. + FIFO_CFG5_MC | FIFO_CFG5_BC | FIFO_CFG5_DR | \
  17695. + FIFO_CFG5_CF | FIFO_CFG5_PF | FIFO_CFG5_VT | \
  17696. + FIFO_CFG5_LE | FIFO_CFG5_FT | FIFO_CFG5_16 | \
  17697. + FIFO_CFG5_17 | FIFO_CFG5_SF)
  17698. +
  17699. +static void ag71xx_hw_init(struct ag71xx *ag)
  17700. +{
  17701. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  17702. +
  17703. + ag71xx_sb(ag, AG71XX_REG_MAC_CFG1, MAC_CFG1_SR);
  17704. + udelay(20);
  17705. +
  17706. + ar71xx_device_stop(pdata->reset_bit);
  17707. + mdelay(100);
  17708. + ar71xx_device_start(pdata->reset_bit);
  17709. + mdelay(100);
  17710. +
  17711. + /* setup MAC configuration registers */
  17712. + if (pdata->is_ar724x)
  17713. + ag71xx_wr(ag, AG71XX_REG_MAC_CFG1,
  17714. + MAC_CFG1_INIT | MAC_CFG1_TFC | MAC_CFG1_RFC);
  17715. + else
  17716. + ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, MAC_CFG1_INIT);
  17717. +
  17718. + ag71xx_sb(ag, AG71XX_REG_MAC_CFG2,
  17719. + MAC_CFG2_PAD_CRC_EN | MAC_CFG2_LEN_CHECK);
  17720. +
  17721. + /* setup max frame length */
  17722. + ag71xx_wr(ag, AG71XX_REG_MAC_MFL, AG71XX_TX_MTU_LEN);
  17723. +
  17724. + /* setup MII interface type */
  17725. + ag71xx_mii_ctrl_set_if(ag, pdata->mii_if);
  17726. +
  17727. + /* setup FIFO configuration registers */
  17728. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG0, FIFO_CFG0_INIT);
  17729. + if (pdata->is_ar724x) {
  17730. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG1, pdata->fifo_cfg1);
  17731. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG2, pdata->fifo_cfg2);
  17732. + } else {
  17733. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG1, 0x0fff0000);
  17734. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG2, 0x00001fff);
  17735. + }
  17736. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG4, FIFO_CFG4_INIT);
  17737. + ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, FIFO_CFG5_INIT);
  17738. +
  17739. + ag71xx_dma_reset(ag);
  17740. +}
  17741. +
  17742. +static void ag71xx_hw_start(struct ag71xx *ag)
  17743. +{
  17744. + /* start RX engine */
  17745. + ag71xx_wr(ag, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
  17746. +
  17747. + /* enable interrupts */
  17748. + ag71xx_wr(ag, AG71XX_REG_INT_ENABLE, AG71XX_INT_INIT);
  17749. +}
  17750. +
  17751. +static void ag71xx_hw_stop(struct ag71xx *ag)
  17752. +{
  17753. + /* disable all interrupts */
  17754. + ag71xx_wr(ag, AG71XX_REG_INT_ENABLE, 0);
  17755. +
  17756. + ag71xx_dma_reset(ag);
  17757. +}
  17758. +
  17759. +static int ag71xx_open(struct net_device *dev)
  17760. +{
  17761. + struct ag71xx *ag = netdev_priv(dev);
  17762. + int ret;
  17763. +
  17764. + ret = ag71xx_rings_init(ag);
  17765. + if (ret)
  17766. + goto err;
  17767. +
  17768. + napi_enable(&ag->napi);
  17769. +
  17770. + netif_carrier_off(dev);
  17771. + ag71xx_phy_start(ag);
  17772. +
  17773. + ag71xx_wr(ag, AG71XX_REG_TX_DESC, ag->tx_ring.descs_dma);
  17774. + ag71xx_wr(ag, AG71XX_REG_RX_DESC, ag->rx_ring.descs_dma);
  17775. +
  17776. + ag71xx_hw_set_macaddr(ag, dev->dev_addr);
  17777. +
  17778. + ag71xx_hw_start(ag);
  17779. +
  17780. + netif_start_queue(dev);
  17781. +
  17782. + return 0;
  17783. +
  17784. + err:
  17785. + ag71xx_rings_cleanup(ag);
  17786. + return ret;
  17787. +}
  17788. +
  17789. +static int ag71xx_stop(struct net_device *dev)
  17790. +{
  17791. + struct ag71xx *ag = netdev_priv(dev);
  17792. + unsigned long flags;
  17793. +
  17794. + netif_carrier_off(dev);
  17795. + ag71xx_phy_stop(ag);
  17796. +
  17797. + spin_lock_irqsave(&ag->lock, flags);
  17798. +
  17799. + netif_stop_queue(dev);
  17800. +
  17801. + ag71xx_hw_stop(ag);
  17802. +
  17803. + napi_disable(&ag->napi);
  17804. + del_timer_sync(&ag->oom_timer);
  17805. +
  17806. + spin_unlock_irqrestore(&ag->lock, flags);
  17807. +
  17808. + ag71xx_rings_cleanup(ag);
  17809. +
  17810. + return 0;
  17811. +}
  17812. +
  17813. +static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff *skb,
  17814. + struct net_device *dev)
  17815. +{
  17816. + struct ag71xx *ag = netdev_priv(dev);
  17817. + struct ag71xx_ring *ring = &ag->tx_ring;
  17818. + struct ag71xx_desc *desc;
  17819. + dma_addr_t dma_addr;
  17820. + int i;
  17821. +
  17822. + i = ring->curr % AG71XX_TX_RING_SIZE;
  17823. + desc = ring->buf[i].desc;
  17824. +
  17825. + if (!ag71xx_desc_empty(desc))
  17826. + goto err_drop;
  17827. +
  17828. + if (ag71xx_has_ar8216(ag))
  17829. + ag71xx_add_ar8216_header(ag, skb);
  17830. +
  17831. + if (skb->len <= 0) {
  17832. + DBG("%s: packet len is too small\n", ag->dev->name);
  17833. + goto err_drop;
  17834. + }
  17835. +
  17836. + dma_addr = dma_map_single(&dev->dev, skb->data, skb->len,
  17837. + DMA_TO_DEVICE);
  17838. +
  17839. + ring->buf[i].skb = skb;
  17840. +
  17841. + /* setup descriptor fields */
  17842. + desc->data = (u32) dma_addr;
  17843. + desc->ctrl = (skb->len & DESC_PKTLEN_M);
  17844. +
  17845. + /* flush descriptor */
  17846. + wmb();
  17847. +
  17848. + ring->curr++;
  17849. + if (ring->curr == (ring->dirty + AG71XX_TX_THRES_STOP)) {
  17850. + DBG("%s: tx queue full\n", ag->dev->name);
  17851. + netif_stop_queue(dev);
  17852. + }
  17853. +
  17854. + DBG("%s: packet injected into TX queue\n", ag->dev->name);
  17855. +
  17856. + /* enable TX engine */
  17857. + ag71xx_wr(ag, AG71XX_REG_TX_CTRL, TX_CTRL_TXE);
  17858. +
  17859. + return NETDEV_TX_OK;
  17860. +
  17861. + err_drop:
  17862. + dev->stats.tx_dropped++;
  17863. +
  17864. + dev_kfree_skb(skb);
  17865. + return NETDEV_TX_OK;
  17866. +}
  17867. +
  17868. +static int ag71xx_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  17869. +{
  17870. + struct mii_ioctl_data *data = (struct mii_ioctl_data *) &ifr->ifr_data;
  17871. + struct ag71xx *ag = netdev_priv(dev);
  17872. + int ret;
  17873. +
  17874. + switch (cmd) {
  17875. + case SIOCETHTOOL:
  17876. + if (ag->phy_dev == NULL)
  17877. + break;
  17878. +
  17879. + spin_lock_irq(&ag->lock);
  17880. + ret = phy_ethtool_ioctl(ag->phy_dev, (void *) ifr->ifr_data);
  17881. + spin_unlock_irq(&ag->lock);
  17882. + return ret;
  17883. +
  17884. + case SIOCSIFHWADDR:
  17885. + if (copy_from_user
  17886. + (dev->dev_addr, ifr->ifr_data, sizeof(dev->dev_addr)))
  17887. + return -EFAULT;
  17888. + return 0;
  17889. +
  17890. + case SIOCGIFHWADDR:
  17891. + if (copy_to_user
  17892. + (ifr->ifr_data, dev->dev_addr, sizeof(dev->dev_addr)))
  17893. + return -EFAULT;
  17894. + return 0;
  17895. +
  17896. + case SIOCGMIIPHY:
  17897. + case SIOCGMIIREG:
  17898. + case SIOCSMIIREG:
  17899. + if (ag->phy_dev == NULL)
  17900. + break;
  17901. +
  17902. + return phy_mii_ioctl(ag->phy_dev, data, cmd);
  17903. +
  17904. + default:
  17905. + break;
  17906. + }
  17907. +
  17908. + return -EOPNOTSUPP;
  17909. +}
  17910. +
  17911. +static void ag71xx_oom_timer_handler(unsigned long data)
  17912. +{
  17913. + struct net_device *dev = (struct net_device *) data;
  17914. + struct ag71xx *ag = netdev_priv(dev);
  17915. +
  17916. + napi_schedule(&ag->napi);
  17917. +}
  17918. +
  17919. +static void ag71xx_tx_timeout(struct net_device *dev)
  17920. +{
  17921. + struct ag71xx *ag = netdev_priv(dev);
  17922. +
  17923. + if (netif_msg_tx_err(ag))
  17924. + printk(KERN_DEBUG "%s: tx timeout\n", ag->dev->name);
  17925. +
  17926. + schedule_work(&ag->restart_work);
  17927. +}
  17928. +
  17929. +static void ag71xx_restart_work_func(struct work_struct *work)
  17930. +{
  17931. + struct ag71xx *ag = container_of(work, struct ag71xx, restart_work);
  17932. +
  17933. + ag71xx_stop(ag->dev);
  17934. + ag71xx_open(ag->dev);
  17935. +}
  17936. +
  17937. +static int ag71xx_tx_packets(struct ag71xx *ag)
  17938. +{
  17939. + struct ag71xx_ring *ring = &ag->tx_ring;
  17940. + int sent;
  17941. +
  17942. + DBG("%s: processing TX ring\n", ag->dev->name);
  17943. +
  17944. + sent = 0;
  17945. + while (ring->dirty != ring->curr) {
  17946. + unsigned int i = ring->dirty % AG71XX_TX_RING_SIZE;
  17947. + struct ag71xx_desc *desc = ring->buf[i].desc;
  17948. + struct sk_buff *skb = ring->buf[i].skb;
  17949. +
  17950. + if (!ag71xx_desc_empty(desc))
  17951. + break;
  17952. +
  17953. + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_PS);
  17954. +
  17955. + ag->dev->stats.tx_bytes += skb->len;
  17956. + ag->dev->stats.tx_packets++;
  17957. +
  17958. + dev_kfree_skb_any(skb);
  17959. + ring->buf[i].skb = NULL;
  17960. +
  17961. + ring->dirty++;
  17962. + sent++;
  17963. + }
  17964. +
  17965. + DBG("%s: %d packets sent out\n", ag->dev->name, sent);
  17966. +
  17967. + if ((ring->curr - ring->dirty) < AG71XX_TX_THRES_WAKEUP)
  17968. + netif_wake_queue(ag->dev);
  17969. +
  17970. + return sent;
  17971. +}
  17972. +
  17973. +static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
  17974. +{
  17975. + struct net_device *dev = ag->dev;
  17976. + struct ag71xx_ring *ring = &ag->rx_ring;
  17977. + int done = 0;
  17978. +
  17979. + DBG("%s: rx packets, limit=%d, curr=%u, dirty=%u\n",
  17980. + dev->name, limit, ring->curr, ring->dirty);
  17981. +
  17982. + while (done < limit) {
  17983. + unsigned int i = ring->curr % AG71XX_RX_RING_SIZE;
  17984. + struct ag71xx_desc *desc = ring->buf[i].desc;
  17985. + struct sk_buff *skb;
  17986. + int pktlen;
  17987. + int err = 0;
  17988. +
  17989. + if (ag71xx_desc_empty(desc))
  17990. + break;
  17991. +
  17992. + if ((ring->dirty + AG71XX_RX_RING_SIZE) == ring->curr) {
  17993. + ag71xx_assert(0);
  17994. + break;
  17995. + }
  17996. +
  17997. + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_PR);
  17998. +
  17999. + skb = ring->buf[i].skb;
  18000. + pktlen = ag71xx_desc_pktlen(desc);
  18001. + pktlen -= ETH_FCS_LEN;
  18002. +
  18003. + dma_unmap_single(&dev->dev, ring->buf[i].dma_addr,
  18004. + AG71XX_RX_PKT_SIZE, DMA_FROM_DEVICE);
  18005. +
  18006. + dev->last_rx = jiffies;
  18007. + dev->stats.rx_packets++;
  18008. + dev->stats.rx_bytes += pktlen;
  18009. +
  18010. + skb_put(skb, pktlen);
  18011. + if (ag71xx_has_ar8216(ag))
  18012. + err = ag71xx_remove_ar8216_header(ag, skb, pktlen);
  18013. +
  18014. + if (err) {
  18015. + dev->stats.rx_dropped++;
  18016. + kfree_skb(skb);
  18017. + } else {
  18018. + skb->dev = dev;
  18019. + skb->ip_summed = CHECKSUM_NONE;
  18020. + if (ag->phy_dev) {
  18021. + ag->phy_dev->netif_receive_skb(skb);
  18022. + } else {
  18023. + skb->protocol = eth_type_trans(skb, dev);
  18024. + netif_receive_skb(skb);
  18025. + }
  18026. + }
  18027. +
  18028. + ring->buf[i].skb = NULL;
  18029. + done++;
  18030. +
  18031. + ring->curr++;
  18032. + }
  18033. +
  18034. + ag71xx_ring_rx_refill(ag);
  18035. +
  18036. + DBG("%s: rx finish, curr=%u, dirty=%u, done=%d\n",
  18037. + dev->name, ring->curr, ring->dirty, done);
  18038. +
  18039. + return done;
  18040. +}
  18041. +
  18042. +static int ag71xx_poll(struct napi_struct *napi, int limit)
  18043. +{
  18044. + struct ag71xx *ag = container_of(napi, struct ag71xx, napi);
  18045. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  18046. + struct net_device *dev = ag->dev;
  18047. + struct ag71xx_ring *rx_ring;
  18048. + unsigned long flags;
  18049. + u32 status;
  18050. + int tx_done;
  18051. + int rx_done;
  18052. +
  18053. + pdata->ddr_flush();
  18054. + tx_done = ag71xx_tx_packets(ag);
  18055. +
  18056. + DBG("%s: processing RX ring\n", dev->name);
  18057. + rx_done = ag71xx_rx_packets(ag, limit);
  18058. +
  18059. + ag71xx_debugfs_update_napi_stats(ag, rx_done, tx_done);
  18060. +
  18061. + rx_ring = &ag->rx_ring;
  18062. + if (rx_ring->buf[rx_ring->dirty % AG71XX_RX_RING_SIZE].skb == NULL)
  18063. + goto oom;
  18064. +
  18065. + status = ag71xx_rr(ag, AG71XX_REG_RX_STATUS);
  18066. + if (unlikely(status & RX_STATUS_OF)) {
  18067. + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_OF);
  18068. + dev->stats.rx_fifo_errors++;
  18069. +
  18070. + /* restart RX */
  18071. + ag71xx_wr(ag, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
  18072. + }
  18073. +
  18074. + if (rx_done < limit) {
  18075. + if (status & RX_STATUS_PR)
  18076. + goto more;
  18077. +
  18078. + status = ag71xx_rr(ag, AG71XX_REG_TX_STATUS);
  18079. + if (status & TX_STATUS_PS)
  18080. + goto more;
  18081. +
  18082. + DBG("%s: disable polling mode, rx=%d, tx=%d,limit=%d\n",
  18083. + dev->name, rx_done, tx_done, limit);
  18084. +
  18085. + napi_complete(napi);
  18086. +
  18087. + /* enable interrupts */
  18088. + spin_lock_irqsave(&ag->lock, flags);
  18089. + ag71xx_int_enable(ag, AG71XX_INT_POLL);
  18090. + spin_unlock_irqrestore(&ag->lock, flags);
  18091. + return rx_done;
  18092. + }
  18093. +
  18094. + more:
  18095. + DBG("%s: stay in polling mode, rx=%d, tx=%d, limit=%d\n",
  18096. + dev->name, rx_done, tx_done, limit);
  18097. + return rx_done;
  18098. +
  18099. + oom:
  18100. + if (netif_msg_rx_err(ag))
  18101. + printk(KERN_DEBUG "%s: out of memory\n", dev->name);
  18102. +
  18103. + mod_timer(&ag->oom_timer, jiffies + AG71XX_OOM_REFILL);
  18104. + napi_complete(napi);
  18105. + return 0;
  18106. +}
  18107. +
  18108. +static irqreturn_t ag71xx_interrupt(int irq, void *dev_id)
  18109. +{
  18110. + struct net_device *dev = dev_id;
  18111. + struct ag71xx *ag = netdev_priv(dev);
  18112. + u32 status;
  18113. +
  18114. + status = ag71xx_rr(ag, AG71XX_REG_INT_STATUS);
  18115. + ag71xx_dump_intr(ag, "raw", status);
  18116. +
  18117. + if (unlikely(!status))
  18118. + return IRQ_NONE;
  18119. +
  18120. + if (unlikely(status & AG71XX_INT_ERR)) {
  18121. + if (status & AG71XX_INT_TX_BE) {
  18122. + ag71xx_wr(ag, AG71XX_REG_TX_STATUS, TX_STATUS_BE);
  18123. + dev_err(&dev->dev, "TX BUS error\n");
  18124. + }
  18125. + if (status & AG71XX_INT_RX_BE) {
  18126. + ag71xx_wr(ag, AG71XX_REG_RX_STATUS, RX_STATUS_BE);
  18127. + dev_err(&dev->dev, "RX BUS error\n");
  18128. + }
  18129. + }
  18130. +
  18131. + if (likely(status & AG71XX_INT_POLL)) {
  18132. + ag71xx_int_disable(ag, AG71XX_INT_POLL);
  18133. + DBG("%s: enable polling mode\n", dev->name);
  18134. + napi_schedule(&ag->napi);
  18135. + }
  18136. +
  18137. + ag71xx_debugfs_update_int_stats(ag, status);
  18138. +
  18139. + return IRQ_HANDLED;
  18140. +}
  18141. +
  18142. +static void ag71xx_set_multicast_list(struct net_device *dev)
  18143. +{
  18144. + /* TODO */
  18145. +}
  18146. +
  18147. +#ifdef CONFIG_NET_POLL_CONTROLLER
  18148. +/*
  18149. + * Polling 'interrupt' - used by things like netconsole to send skbs
  18150. + * without having to re-enable interrupts. It's not called while
  18151. + * the interrupt routine is executing.
  18152. + */
  18153. +static void ag71xx_netpoll(struct net_device *dev)
  18154. +{
  18155. + disable_irq(dev->irq);
  18156. + ag71xx_interrupt(dev->irq, dev);
  18157. + enable_irq(dev->irq);
  18158. +}
  18159. +#endif
  18160. +
  18161. +static const struct net_device_ops ag71xx_netdev_ops = {
  18162. + .ndo_open = ag71xx_open,
  18163. + .ndo_stop = ag71xx_stop,
  18164. + .ndo_start_xmit = ag71xx_hard_start_xmit,
  18165. + .ndo_set_multicast_list = ag71xx_set_multicast_list,
  18166. + .ndo_do_ioctl = ag71xx_do_ioctl,
  18167. + .ndo_tx_timeout = ag71xx_tx_timeout,
  18168. + .ndo_change_mtu = eth_change_mtu,
  18169. + .ndo_set_mac_address = eth_mac_addr,
  18170. + .ndo_validate_addr = eth_validate_addr,
  18171. +#ifdef CONFIG_NET_POLL_CONTROLLER
  18172. + .ndo_poll_controller = ag71xx_netpoll,
  18173. +#endif
  18174. +};
  18175. +
  18176. +static int __init ag71xx_probe(struct platform_device *pdev)
  18177. +{
  18178. + struct net_device *dev;
  18179. + struct resource *res;
  18180. + struct ag71xx *ag;
  18181. + struct ag71xx_platform_data *pdata;
  18182. + int err;
  18183. +
  18184. + pdata = pdev->dev.platform_data;
  18185. + if (!pdata) {
  18186. + dev_err(&pdev->dev, "no platform data specified\n");
  18187. + err = -ENXIO;
  18188. + goto err_out;
  18189. + }
  18190. +
  18191. + if (pdata->mii_bus_dev == NULL) {
  18192. + dev_err(&pdev->dev, "no MII bus device specified\n");
  18193. + err = -EINVAL;
  18194. + goto err_out;
  18195. + }
  18196. +
  18197. + dev = alloc_etherdev(sizeof(*ag));
  18198. + if (!dev) {
  18199. + dev_err(&pdev->dev, "alloc_etherdev failed\n");
  18200. + err = -ENOMEM;
  18201. + goto err_out;
  18202. + }
  18203. +
  18204. + SET_NETDEV_DEV(dev, &pdev->dev);
  18205. +
  18206. + ag = netdev_priv(dev);
  18207. + ag->pdev = pdev;
  18208. + ag->dev = dev;
  18209. + ag->msg_enable = netif_msg_init(ag71xx_msg_level,
  18210. + AG71XX_DEFAULT_MSG_ENABLE);
  18211. + spin_lock_init(&ag->lock);
  18212. +
  18213. + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mac_base");
  18214. + if (!res) {
  18215. + dev_err(&pdev->dev, "no mac_base resource found\n");
  18216. + err = -ENXIO;
  18217. + goto err_out;
  18218. + }
  18219. +
  18220. + ag->mac_base = ioremap_nocache(res->start, res->end - res->start + 1);
  18221. + if (!ag->mac_base) {
  18222. + dev_err(&pdev->dev, "unable to ioremap mac_base\n");
  18223. + err = -ENOMEM;
  18224. + goto err_free_dev;
  18225. + }
  18226. +
  18227. + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mii_ctrl");
  18228. + if (!res) {
  18229. + dev_err(&pdev->dev, "no mii_ctrl resource found\n");
  18230. + err = -ENXIO;
  18231. + goto err_unmap_base;
  18232. + }
  18233. +
  18234. + ag->mii_ctrl = ioremap_nocache(res->start, res->end - res->start + 1);
  18235. + if (!ag->mii_ctrl) {
  18236. + dev_err(&pdev->dev, "unable to ioremap mii_ctrl\n");
  18237. + err = -ENOMEM;
  18238. + goto err_unmap_base;
  18239. + }
  18240. +
  18241. + dev->irq = platform_get_irq(pdev, 0);
  18242. + err = request_irq(dev->irq, ag71xx_interrupt,
  18243. + IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
  18244. + dev->name, dev);
  18245. + if (err) {
  18246. + dev_err(&pdev->dev, "unable to request IRQ %d\n", dev->irq);
  18247. + goto err_unmap_mii_ctrl;
  18248. + }
  18249. +
  18250. + dev->base_addr = (unsigned long)ag->mac_base;
  18251. + dev->netdev_ops = &ag71xx_netdev_ops;
  18252. + dev->ethtool_ops = &ag71xx_ethtool_ops;
  18253. +
  18254. + INIT_WORK(&ag->restart_work, ag71xx_restart_work_func);
  18255. +
  18256. + init_timer(&ag->oom_timer);
  18257. + ag->oom_timer.data = (unsigned long) dev;
  18258. + ag->oom_timer.function = ag71xx_oom_timer_handler;
  18259. +
  18260. + memcpy(dev->dev_addr, pdata->mac_addr, ETH_ALEN);
  18261. +
  18262. + netif_napi_add(dev, &ag->napi, ag71xx_poll, AG71XX_NAPI_WEIGHT);
  18263. +
  18264. + err = register_netdev(dev);
  18265. + if (err) {
  18266. + dev_err(&pdev->dev, "unable to register net device\n");
  18267. + goto err_free_irq;
  18268. + }
  18269. +
  18270. + printk(KERN_INFO "%s: Atheros AG71xx at 0x%08lx, irq %d\n",
  18271. + dev->name, dev->base_addr, dev->irq);
  18272. +
  18273. + ag71xx_dump_regs(ag);
  18274. +
  18275. + ag71xx_hw_init(ag);
  18276. +
  18277. + ag71xx_dump_regs(ag);
  18278. +
  18279. + err = ag71xx_phy_connect(ag);
  18280. + if (err)
  18281. + goto err_unregister_netdev;
  18282. +
  18283. + err = ag71xx_debugfs_init(ag);
  18284. + if (err)
  18285. + goto err_phy_disconnect;
  18286. +
  18287. + platform_set_drvdata(pdev, dev);
  18288. +
  18289. + return 0;
  18290. +
  18291. + err_phy_disconnect:
  18292. + ag71xx_phy_disconnect(ag);
  18293. + err_unregister_netdev:
  18294. + unregister_netdev(dev);
  18295. + err_free_irq:
  18296. + free_irq(dev->irq, dev);
  18297. + err_unmap_mii_ctrl:
  18298. + iounmap(ag->mii_ctrl);
  18299. + err_unmap_base:
  18300. + iounmap(ag->mac_base);
  18301. + err_free_dev:
  18302. + kfree(dev);
  18303. + err_out:
  18304. + platform_set_drvdata(pdev, NULL);
  18305. + return err;
  18306. +}
  18307. +
  18308. +static int __exit ag71xx_remove(struct platform_device *pdev)
  18309. +{
  18310. + struct net_device *dev = platform_get_drvdata(pdev);
  18311. +
  18312. + if (dev) {
  18313. + struct ag71xx *ag = netdev_priv(dev);
  18314. +
  18315. + ag71xx_debugfs_exit(ag);
  18316. + ag71xx_phy_disconnect(ag);
  18317. + unregister_netdev(dev);
  18318. + free_irq(dev->irq, dev);
  18319. + iounmap(ag->mii_ctrl);
  18320. + iounmap(ag->mac_base);
  18321. + kfree(dev);
  18322. + platform_set_drvdata(pdev, NULL);
  18323. + }
  18324. +
  18325. + return 0;
  18326. +}
  18327. +
  18328. +static struct platform_driver ag71xx_driver = {
  18329. + .probe = ag71xx_probe,
  18330. + .remove = __exit_p(ag71xx_remove),
  18331. + .driver = {
  18332. + .name = AG71XX_DRV_NAME,
  18333. + }
  18334. +};
  18335. +
  18336. +static int __init ag71xx_module_init(void)
  18337. +{
  18338. + int ret;
  18339. +
  18340. + ret = ag71xx_debugfs_root_init();
  18341. + if (ret)
  18342. + goto err_out;
  18343. +
  18344. + ret = ag71xx_mdio_driver_init();
  18345. + if (ret)
  18346. + goto err_debugfs_exit;
  18347. +
  18348. + ret = platform_driver_register(&ag71xx_driver);
  18349. + if (ret)
  18350. + goto err_mdio_exit;
  18351. +
  18352. + return 0;
  18353. +
  18354. + err_mdio_exit:
  18355. + ag71xx_mdio_driver_exit();
  18356. + err_debugfs_exit:
  18357. + ag71xx_debugfs_root_exit();
  18358. + err_out:
  18359. + return ret;
  18360. +}
  18361. +
  18362. +static void __exit ag71xx_module_exit(void)
  18363. +{
  18364. + platform_driver_unregister(&ag71xx_driver);
  18365. + ag71xx_mdio_driver_exit();
  18366. + ag71xx_debugfs_root_exit();
  18367. +}
  18368. +
  18369. +module_init(ag71xx_module_init);
  18370. +module_exit(ag71xx_module_exit);
  18371. +
  18372. +MODULE_VERSION(AG71XX_DRV_VERSION);
  18373. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  18374. +MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>");
  18375. +MODULE_LICENSE("GPL v2");
  18376. +MODULE_ALIAS("platform:" AG71XX_DRV_NAME);
  18377. diff -Nur linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_mdio.c linux-2.6.35.7/drivers/net/ag71xx/ag71xx_mdio.c
  18378. --- linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_mdio.c 1970-01-01 01:00:00.000000000 +0100
  18379. +++ linux-2.6.35.7/drivers/net/ag71xx/ag71xx_mdio.c 2010-10-14 20:28:00.678101104 +0200
  18380. @@ -0,0 +1,243 @@
  18381. +/*
  18382. + * Atheros AR71xx built-in ethernet mac driver
  18383. + *
  18384. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  18385. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  18386. + *
  18387. + * Based on Atheros' AG7100 driver
  18388. + *
  18389. + * This program is free software; you can redistribute it and/or modify it
  18390. + * under the terms of the GNU General Public License version 2 as published
  18391. + * by the Free Software Foundation.
  18392. + */
  18393. +
  18394. +#include "ag71xx.h"
  18395. +
  18396. +#define AG71XX_MDIO_RETRY 1000
  18397. +#define AG71XX_MDIO_DELAY 5
  18398. +
  18399. +static inline void ag71xx_mdio_wr(struct ag71xx_mdio *am, unsigned reg,
  18400. + u32 value)
  18401. +{
  18402. + void __iomem *r;
  18403. +
  18404. + r = am->mdio_base + reg;
  18405. + __raw_writel(value, r);
  18406. +
  18407. + /* flush write */
  18408. + (void) __raw_readl(r);
  18409. +}
  18410. +
  18411. +static inline u32 ag71xx_mdio_rr(struct ag71xx_mdio *am, unsigned reg)
  18412. +{
  18413. + return __raw_readl(am->mdio_base + reg);
  18414. +}
  18415. +
  18416. +static void ag71xx_mdio_dump_regs(struct ag71xx_mdio *am)
  18417. +{
  18418. + DBG("%s: mii_cfg=%08x, mii_cmd=%08x, mii_addr=%08x\n",
  18419. + am->mii_bus->name,
  18420. + ag71xx_mdio_rr(am, AG71XX_REG_MII_CFG),
  18421. + ag71xx_mdio_rr(am, AG71XX_REG_MII_CMD),
  18422. + ag71xx_mdio_rr(am, AG71XX_REG_MII_ADDR));
  18423. + DBG("%s: mii_ctrl=%08x, mii_status=%08x, mii_ind=%08x\n",
  18424. + am->mii_bus->name,
  18425. + ag71xx_mdio_rr(am, AG71XX_REG_MII_CTRL),
  18426. + ag71xx_mdio_rr(am, AG71XX_REG_MII_STATUS),
  18427. + ag71xx_mdio_rr(am, AG71XX_REG_MII_IND));
  18428. +}
  18429. +
  18430. +static int ag71xx_mdio_mii_read(struct ag71xx_mdio *am, int addr, int reg)
  18431. +{
  18432. + int ret;
  18433. + int i;
  18434. +
  18435. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CMD, MII_CMD_WRITE);
  18436. + ag71xx_mdio_wr(am, AG71XX_REG_MII_ADDR,
  18437. + ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff));
  18438. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CMD, MII_CMD_READ);
  18439. +
  18440. + i = AG71XX_MDIO_RETRY;
  18441. + while (ag71xx_mdio_rr(am, AG71XX_REG_MII_IND) & MII_IND_BUSY) {
  18442. + if (i-- == 0) {
  18443. + printk(KERN_ERR "%s: mii_read timed out\n",
  18444. + am->mii_bus->name);
  18445. + ret = 0xffff;
  18446. + goto out;
  18447. + }
  18448. + udelay(AG71XX_MDIO_DELAY);
  18449. + }
  18450. +
  18451. + ret = ag71xx_mdio_rr(am, AG71XX_REG_MII_STATUS) & 0xffff;
  18452. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CMD, MII_CMD_WRITE);
  18453. +
  18454. + DBG("mii_read: addr=%04x, reg=%04x, value=%04x\n", addr, reg, ret);
  18455. +
  18456. + out:
  18457. + return ret;
  18458. +}
  18459. +
  18460. +static void ag71xx_mdio_mii_write(struct ag71xx_mdio *am,
  18461. + int addr, int reg, u16 val)
  18462. +{
  18463. + int i;
  18464. +
  18465. + DBG("mii_write: addr=%04x, reg=%04x, value=%04x\n", addr, reg, val);
  18466. +
  18467. + ag71xx_mdio_wr(am, AG71XX_REG_MII_ADDR,
  18468. + ((addr & 0xff) << MII_ADDR_SHIFT) | (reg & 0xff));
  18469. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CTRL, val);
  18470. +
  18471. + i = AG71XX_MDIO_RETRY;
  18472. + while (ag71xx_mdio_rr(am, AG71XX_REG_MII_IND) & MII_IND_BUSY) {
  18473. + if (i-- == 0) {
  18474. + printk(KERN_ERR "%s: mii_write timed out\n",
  18475. + am->mii_bus->name);
  18476. + break;
  18477. + }
  18478. + udelay(AG71XX_MDIO_DELAY);
  18479. + }
  18480. +}
  18481. +
  18482. +static int ag71xx_mdio_reset(struct mii_bus *bus)
  18483. +{
  18484. + struct ag71xx_mdio *am = bus->priv;
  18485. + u32 t;
  18486. +
  18487. + if (am->pdata->is_ar7240)
  18488. + t = MII_CFG_CLK_DIV_6;
  18489. + else
  18490. + t = MII_CFG_CLK_DIV_28;
  18491. +
  18492. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CFG, t | MII_CFG_RESET);
  18493. + udelay(100);
  18494. +
  18495. + ag71xx_mdio_wr(am, AG71XX_REG_MII_CFG, t);
  18496. + udelay(100);
  18497. +
  18498. + return 0;
  18499. +}
  18500. +
  18501. +static int ag71xx_mdio_read(struct mii_bus *bus, int addr, int reg)
  18502. +{
  18503. + struct ag71xx_mdio *am = bus->priv;
  18504. +
  18505. + return ag71xx_mdio_mii_read(am, addr, reg);
  18506. +}
  18507. +
  18508. +static int ag71xx_mdio_write(struct mii_bus *bus, int addr, int reg, u16 val)
  18509. +{
  18510. + struct ag71xx_mdio *am = bus->priv;
  18511. +
  18512. + ag71xx_mdio_mii_write(am, addr, reg, val);
  18513. + return 0;
  18514. +}
  18515. +
  18516. +static int __init ag71xx_mdio_probe(struct platform_device *pdev)
  18517. +{
  18518. + struct ag71xx_mdio_platform_data *pdata;
  18519. + struct ag71xx_mdio *am;
  18520. + struct resource *res;
  18521. + int i;
  18522. + int err;
  18523. +
  18524. + pdata = pdev->dev.platform_data;
  18525. + if (!pdata) {
  18526. + dev_err(&pdev->dev, "no platform data specified\n");
  18527. + return -EINVAL;
  18528. + }
  18529. +
  18530. + am = kzalloc(sizeof(*am), GFP_KERNEL);
  18531. + if (!am) {
  18532. + err = -ENOMEM;
  18533. + goto err_out;
  18534. + }
  18535. +
  18536. + am->pdata = pdata;
  18537. +
  18538. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  18539. + if (!res) {
  18540. + dev_err(&pdev->dev, "no iomem resource found\n");
  18541. + err = -ENXIO;
  18542. + goto err_out;
  18543. + }
  18544. +
  18545. + am->mdio_base = ioremap_nocache(res->start, res->end - res->start + 1);
  18546. + if (!am->mdio_base) {
  18547. + dev_err(&pdev->dev, "unable to ioremap registers\n");
  18548. + err = -ENOMEM;
  18549. + goto err_free_mdio;
  18550. + }
  18551. +
  18552. + am->mii_bus = mdiobus_alloc();
  18553. + if (am->mii_bus == NULL) {
  18554. + err = -ENOMEM;
  18555. + goto err_iounmap;
  18556. + }
  18557. +
  18558. + am->mii_bus->name = "ag71xx_mdio";
  18559. + am->mii_bus->read = ag71xx_mdio_read;
  18560. + am->mii_bus->write = ag71xx_mdio_write;
  18561. + am->mii_bus->reset = ag71xx_mdio_reset;
  18562. + am->mii_bus->irq = am->mii_irq;
  18563. + am->mii_bus->priv = am;
  18564. + am->mii_bus->parent = &pdev->dev;
  18565. + snprintf(am->mii_bus->id, MII_BUS_ID_SIZE, "%s", dev_name(&pdev->dev));
  18566. + am->mii_bus->phy_mask = pdata->phy_mask;
  18567. +
  18568. + for (i = 0; i < PHY_MAX_ADDR; i++)
  18569. + am->mii_irq[i] = PHY_POLL;
  18570. +
  18571. + ag71xx_mdio_wr(am, AG71XX_REG_MAC_CFG1, 0);
  18572. +
  18573. + err = mdiobus_register(am->mii_bus);
  18574. + if (err)
  18575. + goto err_free_bus;
  18576. +
  18577. + ag71xx_mdio_dump_regs(am);
  18578. +
  18579. + platform_set_drvdata(pdev, am);
  18580. + return 0;
  18581. +
  18582. + err_free_bus:
  18583. + mdiobus_free(am->mii_bus);
  18584. + err_iounmap:
  18585. + iounmap(am->mdio_base);
  18586. + err_free_mdio:
  18587. + kfree(am);
  18588. + err_out:
  18589. + return err;
  18590. +}
  18591. +
  18592. +static int __exit ag71xx_mdio_remove(struct platform_device *pdev)
  18593. +{
  18594. + struct ag71xx_mdio *am = platform_get_drvdata(pdev);
  18595. +
  18596. + if (am) {
  18597. + mdiobus_unregister(am->mii_bus);
  18598. + mdiobus_free(am->mii_bus);
  18599. + iounmap(am->mdio_base);
  18600. + kfree(am);
  18601. + platform_set_drvdata(pdev, NULL);
  18602. + }
  18603. +
  18604. + return 0;
  18605. +}
  18606. +
  18607. +static struct platform_driver ag71xx_mdio_driver = {
  18608. + .probe = ag71xx_mdio_probe,
  18609. + .remove = __exit_p(ag71xx_mdio_remove),
  18610. + .driver = {
  18611. + .name = "ag71xx-mdio",
  18612. + }
  18613. +};
  18614. +
  18615. +int ag71xx_mdio_driver_init(void)
  18616. +{
  18617. + return platform_driver_register(&ag71xx_mdio_driver);
  18618. +}
  18619. +
  18620. +void ag71xx_mdio_driver_exit(void)
  18621. +{
  18622. + platform_driver_unregister(&ag71xx_mdio_driver);
  18623. +}
  18624. diff -Nur linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_phy.c linux-2.6.35.7/drivers/net/ag71xx/ag71xx_phy.c
  18625. --- linux-2.6.35.7.orig/drivers/net/ag71xx/ag71xx_phy.c 1970-01-01 01:00:00.000000000 +0100
  18626. +++ linux-2.6.35.7/drivers/net/ag71xx/ag71xx_phy.c 2010-10-14 20:28:00.708092093 +0200
  18627. @@ -0,0 +1,213 @@
  18628. +/*
  18629. + * Atheros AR71xx built-in ethernet mac driver
  18630. + *
  18631. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  18632. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  18633. + *
  18634. + * Based on Atheros' AG7100 driver
  18635. + *
  18636. + * This program is free software; you can redistribute it and/or modify it
  18637. + * under the terms of the GNU General Public License version 2 as published
  18638. + * by the Free Software Foundation.
  18639. + */
  18640. +
  18641. +#include "ag71xx.h"
  18642. +
  18643. +static void ag71xx_phy_link_adjust(struct net_device *dev)
  18644. +{
  18645. + struct ag71xx *ag = netdev_priv(dev);
  18646. + struct phy_device *phydev = ag->phy_dev;
  18647. + unsigned long flags;
  18648. + int status_change = 0;
  18649. +
  18650. + spin_lock_irqsave(&ag->lock, flags);
  18651. +
  18652. + if (phydev->link) {
  18653. + if (ag->duplex != phydev->duplex
  18654. + || ag->speed != phydev->speed) {
  18655. + status_change = 1;
  18656. + }
  18657. + }
  18658. +
  18659. + if (phydev->link != ag->link)
  18660. + status_change = 1;
  18661. +
  18662. + ag->link = phydev->link;
  18663. + ag->duplex = phydev->duplex;
  18664. + ag->speed = phydev->speed;
  18665. +
  18666. + if (status_change)
  18667. + ag71xx_link_adjust(ag);
  18668. +
  18669. + spin_unlock_irqrestore(&ag->lock, flags);
  18670. +}
  18671. +
  18672. +void ag71xx_phy_start(struct ag71xx *ag)
  18673. +{
  18674. + if (ag->phy_dev) {
  18675. + phy_start(ag->phy_dev);
  18676. + } else {
  18677. + ag->link = 1;
  18678. + ag71xx_link_adjust(ag);
  18679. + }
  18680. +}
  18681. +
  18682. +void ag71xx_phy_stop(struct ag71xx *ag)
  18683. +{
  18684. + if (ag->phy_dev) {
  18685. + phy_stop(ag->phy_dev);
  18686. + } else {
  18687. + ag->link = 0;
  18688. + ag71xx_link_adjust(ag);
  18689. + }
  18690. +}
  18691. +
  18692. +static int ag71xx_phy_connect_fixed(struct ag71xx *ag)
  18693. +{
  18694. + struct net_device *dev = ag->dev;
  18695. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  18696. + int ret = 0;
  18697. +
  18698. + /* use fixed settings */
  18699. + switch (pdata->speed) {
  18700. + case SPEED_10:
  18701. + case SPEED_100:
  18702. + case SPEED_1000:
  18703. + break;
  18704. + default:
  18705. + printk(KERN_ERR "%s: invalid speed specified\n", dev->name);
  18706. + ret = -EINVAL;
  18707. + break;
  18708. + }
  18709. +
  18710. + printk(KERN_DEBUG "%s: using fixed link parameters\n", dev->name);
  18711. +
  18712. + ag->duplex = pdata->duplex;
  18713. + ag->speed = pdata->speed;
  18714. +
  18715. + return ret;
  18716. +}
  18717. +
  18718. +static int ag71xx_phy_connect_multi(struct ag71xx *ag)
  18719. +{
  18720. + struct net_device *dev = ag->dev;
  18721. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  18722. + struct phy_device *phydev = NULL;
  18723. + int phy_addr;
  18724. + int ret = 0;
  18725. +
  18726. + for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
  18727. + if (!(pdata->phy_mask & (1 << phy_addr)))
  18728. + continue;
  18729. +
  18730. + if (ag->mii_bus->phy_map[phy_addr] == NULL)
  18731. + continue;
  18732. +
  18733. + DBG("%s: PHY found at %s, uid=%08x\n",
  18734. + dev->name,
  18735. + dev_name(&ag->mii_bus->phy_map[phy_addr]->dev),
  18736. + ag->mii_bus->phy_map[phy_addr]->phy_id);
  18737. +
  18738. + if (phydev == NULL)
  18739. + phydev = ag->mii_bus->phy_map[phy_addr];
  18740. + }
  18741. +
  18742. + if (!phydev) {
  18743. + printk(KERN_ERR "%s: no PHY found with phy_mask=%08x\n",
  18744. + dev->name, pdata->phy_mask);
  18745. + return -ENODEV;
  18746. + }
  18747. +
  18748. + ag->phy_dev = phy_connect(dev, dev_name(&phydev->dev),
  18749. + &ag71xx_phy_link_adjust, 0,
  18750. + pdata->phy_if_mode);
  18751. +
  18752. + if (IS_ERR(ag->phy_dev)) {
  18753. + printk(KERN_ERR "%s: could not connect to PHY at %s\n",
  18754. + dev->name, dev_name(&phydev->dev));
  18755. + return PTR_ERR(ag->phy_dev);
  18756. + }
  18757. +
  18758. + /* mask with MAC supported features */
  18759. + if (pdata->has_gbit)
  18760. + phydev->supported &= PHY_GBIT_FEATURES;
  18761. + else
  18762. + phydev->supported &= PHY_BASIC_FEATURES;
  18763. +
  18764. + phydev->advertising = phydev->supported;
  18765. +
  18766. + printk(KERN_DEBUG "%s: connected to PHY at %s [uid=%08x, driver=%s]\n",
  18767. + dev->name, dev_name(&phydev->dev),
  18768. + phydev->phy_id, phydev->drv->name);
  18769. +
  18770. + ag->link = 0;
  18771. + ag->speed = 0;
  18772. + ag->duplex = -1;
  18773. +
  18774. + return ret;
  18775. +}
  18776. +
  18777. +static int dev_is_class(struct device *dev, void *class)
  18778. +{
  18779. + if (dev->class != NULL && !strcmp(dev->class->name, class))
  18780. + return 1;
  18781. +
  18782. + return 0;
  18783. +}
  18784. +
  18785. +static struct device *dev_find_class(struct device *parent, char *class)
  18786. +{
  18787. + if (dev_is_class(parent, class)) {
  18788. + get_device(parent);
  18789. + return parent;
  18790. + }
  18791. +
  18792. + return device_find_child(parent, class, dev_is_class);
  18793. +}
  18794. +
  18795. +static struct mii_bus *dev_to_mii_bus(struct device *dev)
  18796. +{
  18797. + struct device *d;
  18798. +
  18799. + d = dev_find_class(dev, "mdio_bus");
  18800. + if (d != NULL) {
  18801. + struct mii_bus *bus;
  18802. +
  18803. + bus = to_mii_bus(d);
  18804. + put_device(d);
  18805. +
  18806. + return bus;
  18807. + }
  18808. +
  18809. + return NULL;
  18810. +}
  18811. +
  18812. +int ag71xx_phy_connect(struct ag71xx *ag)
  18813. +{
  18814. + struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
  18815. +
  18816. + ag->mii_bus = dev_to_mii_bus(pdata->mii_bus_dev);
  18817. + if (ag->mii_bus == NULL) {
  18818. + printk(KERN_ERR "%s: unable to find MII bus on device '%s'\n",
  18819. + ag->dev->name, dev_name(pdata->mii_bus_dev));
  18820. + return -ENODEV;
  18821. + }
  18822. +
  18823. + /* Reset the mdio bus explicitly */
  18824. + if (ag->mii_bus->reset) {
  18825. + mutex_lock(&ag->mii_bus->mdio_lock);
  18826. + ag->mii_bus->reset(ag->mii_bus);
  18827. + mutex_unlock(&ag->mii_bus->mdio_lock);
  18828. + }
  18829. +
  18830. + if (pdata->phy_mask)
  18831. + return ag71xx_phy_connect_multi(ag);
  18832. +
  18833. + return ag71xx_phy_connect_fixed(ag);
  18834. +}
  18835. +
  18836. +void ag71xx_phy_disconnect(struct ag71xx *ag)
  18837. +{
  18838. + if (ag->phy_dev)
  18839. + phy_disconnect(ag->phy_dev);
  18840. +}
  18841. diff -Nur linux-2.6.35.7.orig/drivers/net/ag71xx/Kconfig linux-2.6.35.7/drivers/net/ag71xx/Kconfig
  18842. --- linux-2.6.35.7.orig/drivers/net/ag71xx/Kconfig 1970-01-01 01:00:00.000000000 +0100
  18843. +++ linux-2.6.35.7/drivers/net/ag71xx/Kconfig 2010-10-14 20:28:00.748098810 +0200
  18844. @@ -0,0 +1,33 @@
  18845. +config AG71XX
  18846. + tristate "Atheros AR71xx built-in ethernet mac support"
  18847. + depends on ATHEROS_AR71XX
  18848. + select PHYLIB
  18849. + help
  18850. + If you wish to compile a kernel for AR71xx/91xx and enable
  18851. + ethernet support, then you should always answer Y to this.
  18852. +
  18853. +if AG71XX
  18854. +
  18855. +config AG71XX_DEBUG
  18856. + bool "Atheros AR71xx built-in ethernet driver debugging"
  18857. + default n
  18858. + help
  18859. + Atheros AR71xx built-in ethernet driver debugging messages.
  18860. +
  18861. +config AG71XX_DEBUG_FS
  18862. + bool "Atheros AR71xx built-in ethernet driver debugfs support"
  18863. + depends on DEBUG_FS
  18864. + default n
  18865. + help
  18866. + Say Y, if you need access to various statistics provided by
  18867. + the ag71xx driver.
  18868. +
  18869. +config AG71XX_AR8216_SUPPORT
  18870. + bool "special support for the Atheros AR8216 switch"
  18871. + default n
  18872. + default y if AR71XX_MACH_WNR2000 || AR71XX_MACH_MZK_W04NU
  18873. + help
  18874. + Say 'y' here if you want to enable special support for the
  18875. + Atheros AR8216 switch found on some boards.
  18876. +
  18877. +endif
  18878. diff -Nur linux-2.6.35.7.orig/drivers/net/ag71xx/Makefile linux-2.6.35.7/drivers/net/ag71xx/Makefile
  18879. --- linux-2.6.35.7.orig/drivers/net/ag71xx/Makefile 1970-01-01 01:00:00.000000000 +0100
  18880. +++ linux-2.6.35.7/drivers/net/ag71xx/Makefile 2010-10-14 20:28:00.784356250 +0200
  18881. @@ -0,0 +1,14 @@
  18882. +#
  18883. +# Makefile for the Atheros AR71xx built-in ethernet macs
  18884. +#
  18885. +
  18886. +ag71xx-y += ag71xx_main.o
  18887. +ag71xx-y += ag71xx_ethtool.o
  18888. +ag71xx-y += ag71xx_phy.o
  18889. +ag71xx-y += ag71xx_mdio.o
  18890. +
  18891. +ag71xx-$(CONFIG_AG71XX_DEBUG_FS) += ag71xx_debugfs.o
  18892. +ag71xx-$(CONFIG_AG71XX_AR8216_SUPPORT) += ag71xx_ar8216.o
  18893. +
  18894. +obj-$(CONFIG_AG71XX) += ag71xx.o
  18895. +
  18896. diff -Nur linux-2.6.35.7.orig/drivers/net/Kconfig linux-2.6.35.7/drivers/net/Kconfig
  18897. --- linux-2.6.35.7.orig/drivers/net/Kconfig 2010-09-29 03:09:08.000000000 +0200
  18898. +++ linux-2.6.35.7/drivers/net/Kconfig 2010-10-14 20:28:00.828101196 +0200
  18899. @@ -2032,6 +2032,8 @@
  18900. The safe and default value for this is N.
  18901. +source drivers/net/ag71xx/Kconfig
  18902. +
  18903. config DL2K
  18904. tristate "DL2000/TC902x-based Gigabit Ethernet support"
  18905. depends on PCI
  18906. diff -Nur linux-2.6.35.7.orig/drivers/net/Kconfig.orig linux-2.6.35.7/drivers/net/Kconfig.orig
  18907. --- linux-2.6.35.7.orig/drivers/net/Kconfig.orig 1970-01-01 01:00:00.000000000 +0100
  18908. +++ linux-2.6.35.7/drivers/net/Kconfig.orig 2010-09-29 03:09:08.000000000 +0200
  18909. @@ -0,0 +1,3314 @@
  18910. +#
  18911. +# Network device configuration
  18912. +#
  18913. +
  18914. +menuconfig NETDEVICES
  18915. + default y if UML
  18916. + depends on NET
  18917. + bool "Network device support"
  18918. + ---help---
  18919. + You can say N here if you don't intend to connect your Linux box to
  18920. + any other computer at all.
  18921. +
  18922. + You'll have to say Y if your computer contains a network card that
  18923. + you want to use under Linux. If you are going to run SLIP or PPP over
  18924. + telephone line or null modem cable you need say Y here. Connecting
  18925. + two machines with parallel ports using PLIP needs this, as well as
  18926. + AX.25/KISS for sending Internet traffic over amateur radio links.
  18927. +
  18928. + See also "The Linux Network Administrator's Guide" by Olaf Kirch and
  18929. + Terry Dawson. Available at <http://www.tldp.org/guides.html>.
  18930. +
  18931. + If unsure, say Y.
  18932. +
  18933. +# All the following symbols are dependent on NETDEVICES - do not repeat
  18934. +# that for each of the symbols.
  18935. +if NETDEVICES
  18936. +
  18937. +config IFB
  18938. + tristate "Intermediate Functional Block support"
  18939. + depends on NET_CLS_ACT
  18940. + ---help---
  18941. + This is an intermediate driver that allows sharing of
  18942. + resources.
  18943. + To compile this driver as a module, choose M here: the module
  18944. + will be called ifb. If you want to use more than one ifb
  18945. + device at a time, you need to compile this driver as a module.
  18946. + Instead of 'ifb', the devices will then be called 'ifb0',
  18947. + 'ifb1' etc.
  18948. + Look at the iproute2 documentation directory for usage etc
  18949. +
  18950. +config DUMMY
  18951. + tristate "Dummy net driver support"
  18952. + ---help---
  18953. + This is essentially a bit-bucket device (i.e. traffic you send to
  18954. + this device is consigned into oblivion) with a configurable IP
  18955. + address. It is most commonly used in order to make your currently
  18956. + inactive SLIP address seem like a real address for local programs.
  18957. + If you use SLIP or PPP, you might want to say Y here. Since this
  18958. + thing often comes in handy, the default is Y. It won't enlarge your
  18959. + kernel either. What a deal. Read about it in the Network
  18960. + Administrator's Guide, available from
  18961. + <http://www.tldp.org/docs.html#guide>.
  18962. +
  18963. + To compile this driver as a module, choose M here: the module
  18964. + will be called dummy. If you want to use more than one dummy
  18965. + device at a time, you need to compile this driver as a module.
  18966. + Instead of 'dummy', the devices will then be called 'dummy0',
  18967. + 'dummy1' etc.
  18968. +
  18969. +config BONDING
  18970. + tristate "Bonding driver support"
  18971. + depends on INET
  18972. + depends on IPV6 || IPV6=n
  18973. + ---help---
  18974. + Say 'Y' or 'M' if you wish to be able to 'bond' multiple Ethernet
  18975. + Channels together. This is called 'Etherchannel' by Cisco,
  18976. + 'Trunking' by Sun, 802.3ad by the IEEE, and 'Bonding' in Linux.
  18977. +
  18978. + The driver supports multiple bonding modes to allow for both high
  18979. + performance and high availability operation.
  18980. +
  18981. + Refer to <file:Documentation/networking/bonding.txt> for more
  18982. + information.
  18983. +
  18984. + To compile this driver as a module, choose M here: the module
  18985. + will be called bonding.
  18986. +
  18987. +config MACVLAN
  18988. + tristate "MAC-VLAN support (EXPERIMENTAL)"
  18989. + depends on EXPERIMENTAL
  18990. + ---help---
  18991. + This allows one to create virtual interfaces that map packets to
  18992. + or from specific MAC addresses to a particular interface.
  18993. +
  18994. + Macvlan devices can be added using the "ip" command from the
  18995. + iproute2 package starting with the iproute2-2.6.23 release:
  18996. +
  18997. + "ip link add link <real dev> [ address MAC ] [ NAME ] type macvlan"
  18998. +
  18999. + To compile this driver as a module, choose M here: the module
  19000. + will be called macvlan.
  19001. +
  19002. +config MACVTAP
  19003. + tristate "MAC-VLAN based tap driver (EXPERIMENTAL)"
  19004. + depends on MACVLAN
  19005. + help
  19006. + This adds a specialized tap character device driver that is based
  19007. + on the MAC-VLAN network interface, called macvtap. A macvtap device
  19008. + can be added in the same way as a macvlan device, using 'type
  19009. + macvlan', and then be accessed through the tap user space interface.
  19010. +
  19011. + To compile this driver as a module, choose M here: the module
  19012. + will be called macvtap.
  19013. +
  19014. +config EQUALIZER
  19015. + tristate "EQL (serial line load balancing) support"
  19016. + ---help---
  19017. + If you have two serial connections to some other computer (this
  19018. + usually requires two modems and two telephone lines) and you use
  19019. + SLIP (the protocol for sending Internet traffic over telephone
  19020. + lines) or PPP (a better SLIP) on them, you can make them behave like
  19021. + one double speed connection using this driver. Naturally, this has
  19022. + to be supported at the other end as well, either with a similar EQL
  19023. + Linux driver or with a Livingston Portmaster 2e.
  19024. +
  19025. + Say Y if you want this and read
  19026. + <file:Documentation/networking/eql.txt>. You may also want to read
  19027. + section 6.2 of the NET-3-HOWTO, available from
  19028. + <http://www.tldp.org/docs.html#howto>.
  19029. +
  19030. + To compile this driver as a module, choose M here: the module
  19031. + will be called eql. If unsure, say N.
  19032. +
  19033. +config TUN
  19034. + tristate "Universal TUN/TAP device driver support"
  19035. + select CRC32
  19036. + ---help---
  19037. + TUN/TAP provides packet reception and transmission for user space
  19038. + programs. It can be viewed as a simple Point-to-Point or Ethernet
  19039. + device, which instead of receiving packets from a physical media,
  19040. + receives them from user space program and instead of sending packets
  19041. + via physical media writes them to the user space program.
  19042. +
  19043. + When a program opens /dev/net/tun, driver creates and registers
  19044. + corresponding net device tunX or tapX. After a program closed above
  19045. + devices, driver will automatically delete tunXX or tapXX device and
  19046. + all routes corresponding to it.
  19047. +
  19048. + Please read <file:Documentation/networking/tuntap.txt> for more
  19049. + information.
  19050. +
  19051. + To compile this driver as a module, choose M here: the module
  19052. + will be called tun.
  19053. +
  19054. + If you don't know what to use this for, you don't need it.
  19055. +
  19056. +config VETH
  19057. + tristate "Virtual ethernet pair device"
  19058. + ---help---
  19059. + This device is a local ethernet tunnel. Devices are created in pairs.
  19060. + When one end receives the packet it appears on its pair and vice
  19061. + versa.
  19062. +
  19063. +config NET_SB1000
  19064. + tristate "General Instruments Surfboard 1000"
  19065. + depends on PNP
  19066. + ---help---
  19067. + This is a driver for the General Instrument (also known as
  19068. + NextLevel) SURFboard 1000 internal
  19069. + cable modem. This is an ISA card which is used by a number of cable
  19070. + TV companies to provide cable modem access. It's a one-way
  19071. + downstream-only cable modem, meaning that your upstream net link is
  19072. + provided by your regular phone modem.
  19073. +
  19074. + At present this driver only compiles as a module, so say M here if
  19075. + you have this card. The module will be called sb1000. Then read
  19076. + <file:Documentation/networking/README.sb1000> for information on how
  19077. + to use this module, as it needs special ppp scripts for establishing
  19078. + a connection. Further documentation and the necessary scripts can be
  19079. + found at:
  19080. +
  19081. + <http://www.jacksonville.net/~fventuri/>
  19082. + <http://home.adelphia.net/~siglercm/sb1000.html>
  19083. + <http://linuxpower.cx/~cable/>
  19084. +
  19085. + If you don't have this card, of course say N.
  19086. +
  19087. +source "drivers/net/arcnet/Kconfig"
  19088. +
  19089. +source "drivers/net/phy/Kconfig"
  19090. +
  19091. +#
  19092. +# Ethernet
  19093. +#
  19094. +
  19095. +menuconfig NET_ETHERNET
  19096. + bool "Ethernet (10 or 100Mbit)"
  19097. + depends on !UML
  19098. + ---help---
  19099. + Ethernet (also called IEEE 802.3 or ISO 8802-2) is the most common
  19100. + type of Local Area Network (LAN) in universities and companies.
  19101. +
  19102. + Common varieties of Ethernet are: 10BASE-2 or Thinnet (10 Mbps over
  19103. + coaxial cable, linking computers in a chain), 10BASE-T or twisted
  19104. + pair (10 Mbps over twisted pair cable, linking computers to central
  19105. + hubs), 10BASE-F (10 Mbps over optical fiber links, using hubs),
  19106. + 100BASE-TX (100 Mbps over two twisted pair cables, using hubs),
  19107. + 100BASE-T4 (100 Mbps over 4 standard voice-grade twisted pair
  19108. + cables, using hubs), 100BASE-FX (100 Mbps over optical fiber links)
  19109. + [the 100BASE varieties are also known as Fast Ethernet], and Gigabit
  19110. + Ethernet (1 Gbps over optical fiber or short copper links).
  19111. +
  19112. + If your Linux machine will be connected to an Ethernet and you have
  19113. + an Ethernet network interface card (NIC) installed in your computer,
  19114. + say Y here and read the Ethernet-HOWTO, available from
  19115. + <http://www.tldp.org/docs.html#howto>. You will then also have
  19116. + to say Y to the driver for your particular NIC.
  19117. +
  19118. + Note that the answer to this question won't directly affect the
  19119. + kernel: saying N will just cause the configurator to skip all
  19120. + the questions about Ethernet network cards. If unsure, say N.
  19121. +
  19122. +if NET_ETHERNET
  19123. +
  19124. +config MII
  19125. + tristate "Generic Media Independent Interface device support"
  19126. + help
  19127. + Most ethernet controllers have MII transceiver either as an external
  19128. + or internal device. It is safe to say Y or M here even if your
  19129. + ethernet card lack MII.
  19130. +
  19131. +config MACB
  19132. + tristate "Atmel MACB support"
  19133. + depends on AVR32 || ARCH_AT91SAM9260 || ARCH_AT91SAM9263 || ARCH_AT91SAM9G20 || ARCH_AT91SAM9G45 || ARCH_AT91CAP9
  19134. + select PHYLIB
  19135. + help
  19136. + The Atmel MACB ethernet interface is found on many AT32 and AT91
  19137. + parts. Say Y to include support for the MACB chip.
  19138. +
  19139. + To compile this driver as a module, choose M here: the module
  19140. + will be called macb.
  19141. +
  19142. +source "drivers/net/arm/Kconfig"
  19143. +
  19144. +config AX88796
  19145. + tristate "ASIX AX88796 NE2000 clone support"
  19146. + depends on ARM || MIPS || SUPERH
  19147. + select CRC32
  19148. + select MII
  19149. + help
  19150. + AX88796 driver, using platform bus to provide
  19151. + chip detection and resources
  19152. +
  19153. +config AX88796_93CX6
  19154. + bool "ASIX AX88796 external 93CX6 eeprom support"
  19155. + depends on AX88796
  19156. + select EEPROM_93CX6
  19157. + help
  19158. + Select this if your platform comes with an external 93CX6 eeprom.
  19159. +
  19160. +config MACE
  19161. + tristate "MACE (Power Mac ethernet) support"
  19162. + depends on PPC_PMAC && PPC32
  19163. + select CRC32
  19164. + help
  19165. + Power Macintoshes and clones with Ethernet built-in on the
  19166. + motherboard will usually use a MACE (Medium Access Control for
  19167. + Ethernet) interface. Say Y to include support for the MACE chip.
  19168. +
  19169. + To compile this driver as a module, choose M here: the module
  19170. + will be called mace.
  19171. +
  19172. +config MACE_AAUI_PORT
  19173. + bool "Use AAUI port instead of TP by default"
  19174. + depends on MACE
  19175. + help
  19176. + Some Apple machines (notably the Apple Network Server) which use the
  19177. + MACE ethernet chip have an Apple AUI port (small 15-pin connector),
  19178. + instead of an 8-pin RJ45 connector for twisted-pair ethernet. Say
  19179. + Y here if you have such a machine. If unsure, say N.
  19180. + The driver will default to AAUI on ANS anyway, and if you use it as
  19181. + a module, you can provide the port_aaui=0|1 to force the driver.
  19182. +
  19183. +config BMAC
  19184. + tristate "BMAC (G3 ethernet) support"
  19185. + depends on PPC_PMAC && PPC32
  19186. + select CRC32
  19187. + help
  19188. + Say Y for support of BMAC Ethernet interfaces. These are used on G3
  19189. + computers.
  19190. +
  19191. + To compile this driver as a module, choose M here: the module
  19192. + will be called bmac.
  19193. +
  19194. +config ARIADNE
  19195. + tristate "Ariadne support"
  19196. + depends on ZORRO
  19197. + help
  19198. + If you have a Village Tronic Ariadne Ethernet adapter, say Y.
  19199. + Otherwise, say N.
  19200. +
  19201. + To compile this driver as a module, choose M here: the module
  19202. + will be called ariadne.
  19203. +
  19204. +config A2065
  19205. + tristate "A2065 support"
  19206. + depends on ZORRO
  19207. + select CRC32
  19208. + help
  19209. + If you have a Commodore A2065 Ethernet adapter, say Y. Otherwise,
  19210. + say N.
  19211. +
  19212. + To compile this driver as a module, choose M here: the module
  19213. + will be called a2065.
  19214. +
  19215. +config HYDRA
  19216. + tristate "Hydra support"
  19217. + depends on ZORRO
  19218. + select CRC32
  19219. + help
  19220. + If you have a Hydra Ethernet adapter, say Y. Otherwise, say N.
  19221. +
  19222. + To compile this driver as a module, choose M here: the module
  19223. + will be called hydra.
  19224. +
  19225. +config ZORRO8390
  19226. + tristate "Zorro NS8390-based Ethernet support"
  19227. + depends on ZORRO
  19228. + select CRC32
  19229. + help
  19230. + This driver is for Zorro Ethernet cards using an NS8390-compatible
  19231. + chipset, like the Village Tronic Ariadne II and the Individual
  19232. + Computers X-Surf Ethernet cards. If you have such a card, say Y.
  19233. + Otherwise, say N.
  19234. +
  19235. + To compile this driver as a module, choose M here: the module
  19236. + will be called zorro8390.
  19237. +
  19238. +config APNE
  19239. + tristate "PCMCIA NE2000 support"
  19240. + depends on AMIGA_PCMCIA
  19241. + select CRC32
  19242. + help
  19243. + If you have a PCMCIA NE2000 compatible adapter, say Y. Otherwise,
  19244. + say N.
  19245. +
  19246. + To compile this driver as a module, choose M here: the module
  19247. + will be called apne.
  19248. +
  19249. +config MAC8390
  19250. + bool "Macintosh NS 8390 based ethernet cards"
  19251. + depends on MAC
  19252. + select CRC32
  19253. + help
  19254. + If you want to include a driver to support Nubus or LC-PDS
  19255. + Ethernet cards using an NS8390 chipset or its equivalent, say Y
  19256. + and read the Ethernet-HOWTO, available from
  19257. + <http://www.tldp.org/docs.html#howto>.
  19258. +
  19259. +config MAC89x0
  19260. + tristate "Macintosh CS89x0 based ethernet cards"
  19261. + depends on MAC
  19262. + ---help---
  19263. + Support for CS89x0 chipset based Ethernet cards. If you have a
  19264. + Nubus or LC-PDS network (Ethernet) card of this type, say Y and
  19265. + read the Ethernet-HOWTO, available from
  19266. + <http://www.tldp.org/docs.html#howto>.
  19267. +
  19268. + To compile this driver as a module, choose M here. This module will
  19269. + be called mac89x0.
  19270. +
  19271. +config MACSONIC
  19272. + tristate "Macintosh SONIC based ethernet (onboard, NuBus, LC, CS)"
  19273. + depends on MAC
  19274. + ---help---
  19275. + Support for NatSemi SONIC based Ethernet devices. This includes
  19276. + the onboard Ethernet in many Quadras as well as some LC-PDS,
  19277. + a few Nubus and all known Comm Slot Ethernet cards. If you have
  19278. + one of these say Y and read the Ethernet-HOWTO, available from
  19279. + <http://www.tldp.org/docs.html#howto>.
  19280. +
  19281. + To compile this driver as a module, choose M here. This module will
  19282. + be called macsonic.
  19283. +
  19284. +config MACMACE
  19285. + bool "Macintosh (AV) onboard MACE ethernet"
  19286. + depends on MAC
  19287. + select CRC32
  19288. + help
  19289. + Support for the onboard AMD 79C940 MACE Ethernet controller used in
  19290. + the 660AV and 840AV Macintosh. If you have one of these Macintoshes
  19291. + say Y and read the Ethernet-HOWTO, available from
  19292. + <http://www.tldp.org/docs.html#howto>.
  19293. +
  19294. +config MVME147_NET
  19295. + tristate "MVME147 (Lance) Ethernet support"
  19296. + depends on MVME147
  19297. + select CRC32
  19298. + help
  19299. + Support for the on-board Ethernet interface on the Motorola MVME147
  19300. + single-board computer. Say Y here to include the
  19301. + driver for this chip in your kernel.
  19302. + To compile this driver as a module, choose M here.
  19303. +
  19304. +config MVME16x_NET
  19305. + tristate "MVME16x Ethernet support"
  19306. + depends on MVME16x
  19307. + help
  19308. + This is the driver for the Ethernet interface on the Motorola
  19309. + MVME162, 166, 167, 172 and 177 boards. Say Y here to include the
  19310. + driver for this chip in your kernel.
  19311. + To compile this driver as a module, choose M here.
  19312. +
  19313. +config BVME6000_NET
  19314. + tristate "BVME6000 Ethernet support"
  19315. + depends on BVME6000
  19316. + help
  19317. + This is the driver for the Ethernet interface on BVME4000 and
  19318. + BVME6000 VME boards. Say Y here to include the driver for this chip
  19319. + in your kernel.
  19320. + To compile this driver as a module, choose M here.
  19321. +
  19322. +config ATARILANCE
  19323. + tristate "Atari Lance support"
  19324. + depends on ATARI
  19325. + help
  19326. + Say Y to include support for several Atari Ethernet adapters based
  19327. + on the AMD Lance chipset: RieblCard (with or without battery), or
  19328. + PAMCard VME (also the version by Rhotron, with different addresses).
  19329. +
  19330. +config SUN3LANCE
  19331. + tristate "Sun3/Sun3x on-board LANCE support"
  19332. + depends on SUN3 || SUN3X
  19333. + help
  19334. + Most Sun3 and Sun3x motherboards (including the 3/50, 3/60 and 3/80)
  19335. + featured an AMD Lance 10Mbit Ethernet controller on board; say Y
  19336. + here to compile in the Linux driver for this and enable Ethernet.
  19337. + General Linux information on the Sun 3 and 3x series (now
  19338. + discontinued) is at
  19339. + <http://www.angelfire.com/ca2/tech68k/sun3.html>.
  19340. +
  19341. + If you're not building a kernel for a Sun 3, say N.
  19342. +
  19343. +config SUN3_82586
  19344. + bool "Sun3 on-board Intel 82586 support"
  19345. + depends on SUN3
  19346. + help
  19347. + This driver enables support for the on-board Intel 82586 based
  19348. + Ethernet adapter found on Sun 3/1xx and 3/2xx motherboards. Note
  19349. + that this driver does not support 82586-based adapters on additional
  19350. + VME boards.
  19351. +
  19352. +config HPLANCE
  19353. + bool "HP on-board LANCE support"
  19354. + depends on DIO
  19355. + select CRC32
  19356. + help
  19357. + If you want to use the builtin "LANCE" Ethernet controller on an
  19358. + HP300 machine, say Y here.
  19359. +
  19360. +config LASI_82596
  19361. + tristate "Lasi ethernet"
  19362. + depends on GSC
  19363. + help
  19364. + Say Y here to support the builtin Intel 82596 ethernet controller
  19365. + found in Hewlett-Packard PA-RISC machines with 10Mbit ethernet.
  19366. +
  19367. +config SNI_82596
  19368. + tristate "SNI RM ethernet"
  19369. + depends on NET_ETHERNET && SNI_RM
  19370. + help
  19371. + Say Y here to support the on-board Intel 82596 ethernet controller
  19372. + built into SNI RM machines.
  19373. +
  19374. +config KORINA
  19375. + tristate "Korina (IDT RC32434) Ethernet support"
  19376. + depends on NET_ETHERNET && MIKROTIK_RB532
  19377. + help
  19378. + If you have a Mikrotik RouterBoard 500 or IDT RC32434
  19379. + based system say Y. Otherwise say N.
  19380. +
  19381. +config MIPS_JAZZ_SONIC
  19382. + tristate "MIPS JAZZ onboard SONIC Ethernet support"
  19383. + depends on MACH_JAZZ
  19384. + help
  19385. + This is the driver for the onboard card of MIPS Magnum 4000,
  19386. + Acer PICA, Olivetti M700-10 and a few other identical OEM systems.
  19387. +
  19388. +config XTENSA_XT2000_SONIC
  19389. + tristate "Xtensa XT2000 onboard SONIC Ethernet support"
  19390. + depends on XTENSA_PLATFORM_XT2000
  19391. + help
  19392. + This is the driver for the onboard card of the Xtensa XT2000 board.
  19393. +
  19394. +config MIPS_AU1X00_ENET
  19395. + tristate "MIPS AU1000 Ethernet support"
  19396. + depends on SOC_AU1X00
  19397. + select PHYLIB
  19398. + select CRC32
  19399. + help
  19400. + If you have an Alchemy Semi AU1X00 based system
  19401. + say Y. Otherwise, say N.
  19402. +
  19403. +config SGI_IOC3_ETH
  19404. + bool "SGI IOC3 Ethernet"
  19405. + depends on PCI && SGI_IP27
  19406. + select CRC32
  19407. + select MII
  19408. + help
  19409. + If you have a network (Ethernet) card of this type, say Y and read
  19410. + the Ethernet-HOWTO, available from
  19411. + <http://www.tldp.org/docs.html#howto>.
  19412. +
  19413. +config MIPS_SIM_NET
  19414. + tristate "MIPS simulator Network device"
  19415. + depends on MIPS_SIM
  19416. + help
  19417. + The MIPSNET device is a simple Ethernet network device which is
  19418. + emulated by the MIPS Simulator.
  19419. + If you are not using a MIPSsim or are unsure, say N.
  19420. +
  19421. +config SGI_O2MACE_ETH
  19422. + tristate "SGI O2 MACE Fast Ethernet support"
  19423. + depends on SGI_IP32=y
  19424. +
  19425. +config STNIC
  19426. + tristate "National DP83902AV support"
  19427. + depends on SUPERH
  19428. + select CRC32
  19429. + help
  19430. + Support for cards based on the National Semiconductor DP83902AV
  19431. + ST-NIC Serial Network Interface Controller for Twisted Pair. This
  19432. + is a 10Mbit/sec Ethernet controller. Product overview and specs at
  19433. + <http://www.national.com/pf/DP/DP83902A.html>.
  19434. +
  19435. + If unsure, say N.
  19436. +
  19437. +config SH_ETH
  19438. + tristate "Renesas SuperH Ethernet support"
  19439. + depends on SUPERH && \
  19440. + (CPU_SUBTYPE_SH7710 || CPU_SUBTYPE_SH7712 || \
  19441. + CPU_SUBTYPE_SH7763 || CPU_SUBTYPE_SH7619 || \
  19442. + CPU_SUBTYPE_SH7724)
  19443. + select CRC32
  19444. + select MII
  19445. + select MDIO_BITBANG
  19446. + select PHYLIB
  19447. + help
  19448. + Renesas SuperH Ethernet device driver.
  19449. + This driver support SH7710, SH7712, SH7763, SH7619, and SH7724.
  19450. +
  19451. +config SUNLANCE
  19452. + tristate "Sun LANCE support"
  19453. + depends on SBUS
  19454. + select CRC32
  19455. + help
  19456. + This driver supports the "le" interface present on all 32-bit Sparc
  19457. + systems, on some older Ultra systems and as an Sbus option. These
  19458. + cards are based on the AMD Lance chipset, which is better known
  19459. + via the NE2100 cards.
  19460. +
  19461. + To compile this driver as a module, choose M here: the module
  19462. + will be called sunlance.
  19463. +
  19464. +config HAPPYMEAL
  19465. + tristate "Sun Happy Meal 10/100baseT support"
  19466. + depends on SBUS || PCI
  19467. + select CRC32
  19468. + help
  19469. + This driver supports the "hme" interface present on most Ultra
  19470. + systems and as an option on older Sbus systems. This driver supports
  19471. + both PCI and Sbus devices. This driver also supports the "qfe" quad
  19472. + 100baseT device available in both PCI and Sbus configurations.
  19473. +
  19474. + To compile this driver as a module, choose M here: the module
  19475. + will be called sunhme.
  19476. +
  19477. +config SUNBMAC
  19478. + tristate "Sun BigMAC 10/100baseT support (EXPERIMENTAL)"
  19479. + depends on SBUS && EXPERIMENTAL
  19480. + select CRC32
  19481. + help
  19482. + This driver supports the "be" interface available as an Sbus option.
  19483. + This is Sun's older 100baseT Ethernet device.
  19484. +
  19485. + To compile this driver as a module, choose M here: the module
  19486. + will be called sunbmac.
  19487. +
  19488. +config SUNQE
  19489. + tristate "Sun QuadEthernet support"
  19490. + depends on SBUS
  19491. + select CRC32
  19492. + help
  19493. + This driver supports the "qe" 10baseT Ethernet device, available as
  19494. + an Sbus option. Note that this is not the same as Quad FastEthernet
  19495. + "qfe" which is supported by the Happy Meal driver instead.
  19496. +
  19497. + To compile this driver as a module, choose M here: the module
  19498. + will be called sunqe.
  19499. +
  19500. +config SUNGEM
  19501. + tristate "Sun GEM support"
  19502. + depends on PCI
  19503. + select CRC32
  19504. + help
  19505. + Support for the Sun GEM chip, aka Sun GigabitEthernet/P 2.0. See also
  19506. + <http://www.sun.com/products-n-solutions/hardware/docs/pdf/806-3985-10.pdf>.
  19507. +
  19508. +config CASSINI
  19509. + tristate "Sun Cassini support"
  19510. + depends on PCI
  19511. + select CRC32
  19512. + help
  19513. + Support for the Sun Cassini chip, aka Sun GigaSwift Ethernet. See also
  19514. + <http://www.sun.com/products-n-solutions/hardware/docs/pdf/817-4341-10.pdf>
  19515. +
  19516. +config SUNVNET
  19517. + tristate "Sun Virtual Network support"
  19518. + depends on SUN_LDOMS
  19519. + help
  19520. + Support for virtual network devices under Sun Logical Domains.
  19521. +
  19522. +config NET_VENDOR_3COM
  19523. + bool "3COM cards"
  19524. + depends on ISA || EISA || MCA || PCI
  19525. + help
  19526. + If you have a network (Ethernet) card belonging to this class, say Y
  19527. + and read the Ethernet-HOWTO, available from
  19528. + <http://www.tldp.org/docs.html#howto>.
  19529. +
  19530. + Note that the answer to this question doesn't directly affect the
  19531. + kernel: saying N will just cause the configurator to skip all
  19532. + the questions about 3COM cards. If you say Y, you will be asked for
  19533. + your specific card in the following questions.
  19534. +
  19535. +config EL1
  19536. + tristate "3c501 \"EtherLink\" support"
  19537. + depends on NET_VENDOR_3COM && ISA
  19538. + ---help---
  19539. + If you have a network (Ethernet) card of this type, say Y and read
  19540. + the Ethernet-HOWTO, available from
  19541. + <http://www.tldp.org/docs.html#howto>. Also, consider buying a
  19542. + new card, since the 3c501 is slow, broken, and obsolete: you will
  19543. + have problems. Some people suggest to ping ("man ping") a nearby
  19544. + machine every minute ("man cron") when using this card.
  19545. +
  19546. + To compile this driver as a module, choose M here. The module
  19547. + will be called 3c501.
  19548. +
  19549. +config EL2
  19550. + tristate "3c503 \"EtherLink II\" support"
  19551. + depends on NET_VENDOR_3COM && ISA
  19552. + select CRC32
  19553. + help
  19554. + If you have a network (Ethernet) card of this type, say Y and read
  19555. + the Ethernet-HOWTO, available from
  19556. + <http://www.tldp.org/docs.html#howto>.
  19557. +
  19558. + To compile this driver as a module, choose M here. The module
  19559. + will be called 3c503.
  19560. +
  19561. +config ELPLUS
  19562. + tristate "3c505 \"EtherLink Plus\" support"
  19563. + depends on NET_VENDOR_3COM && ISA && ISA_DMA_API
  19564. + ---help---
  19565. + Information about this network (Ethernet) card can be found in
  19566. + <file:Documentation/networking/3c505.txt>. If you have a card of
  19567. + this type, say Y and read the Ethernet-HOWTO, available from
  19568. + <http://www.tldp.org/docs.html#howto>.
  19569. +
  19570. + To compile this driver as a module, choose M here. The module
  19571. + will be called 3c505.
  19572. +
  19573. +config EL16
  19574. + tristate "3c507 \"EtherLink 16\" support (EXPERIMENTAL)"
  19575. + depends on NET_VENDOR_3COM && ISA && EXPERIMENTAL
  19576. + help
  19577. + If you have a network (Ethernet) card of this type, say Y and read
  19578. + the Ethernet-HOWTO, available from
  19579. + <http://www.tldp.org/docs.html#howto>.
  19580. +
  19581. + To compile this driver as a module, choose M here. The module
  19582. + will be called 3c507.
  19583. +
  19584. +config EL3
  19585. + tristate "3c509/3c529 (MCA)/3c579 \"EtherLink III\" support"
  19586. + depends on NET_VENDOR_3COM && (ISA || EISA || MCA)
  19587. + ---help---
  19588. + If you have a network (Ethernet) card belonging to the 3Com
  19589. + EtherLinkIII series, say Y and read the Ethernet-HOWTO, available
  19590. + from <http://www.tldp.org/docs.html#howto>.
  19591. +
  19592. + If your card is not working you may need to use the DOS
  19593. + setup disk to disable Plug & Play mode, and to select the default
  19594. + media type.
  19595. +
  19596. + To compile this driver as a module, choose M here. The module
  19597. + will be called 3c509.
  19598. +
  19599. +config 3C515
  19600. + tristate "3c515 ISA \"Fast EtherLink\""
  19601. + depends on NET_VENDOR_3COM && (ISA || EISA) && ISA_DMA_API
  19602. + help
  19603. + If you have a 3Com ISA EtherLink XL "Corkscrew" 3c515 Fast Ethernet
  19604. + network card, say Y and read the Ethernet-HOWTO, available from
  19605. + <http://www.tldp.org/docs.html#howto>.
  19606. +
  19607. + To compile this driver as a module, choose M here. The module
  19608. + will be called 3c515.
  19609. +
  19610. +config ELMC
  19611. + tristate "3c523 \"EtherLink/MC\" support"
  19612. + depends on NET_VENDOR_3COM && MCA_LEGACY
  19613. + help
  19614. + If you have a network (Ethernet) card of this type, say Y and read
  19615. + the Ethernet-HOWTO, available from
  19616. + <http://www.tldp.org/docs.html#howto>.
  19617. +
  19618. + To compile this driver as a module, choose M here. The module
  19619. + will be called 3c523.
  19620. +
  19621. +config ELMC_II
  19622. + tristate "3c527 \"EtherLink/MC 32\" support (EXPERIMENTAL)"
  19623. + depends on NET_VENDOR_3COM && MCA && MCA_LEGACY
  19624. + help
  19625. + If you have a network (Ethernet) card of this type, say Y and read
  19626. + the Ethernet-HOWTO, available from
  19627. + <http://www.tldp.org/docs.html#howto>.
  19628. +
  19629. + To compile this driver as a module, choose M here. The module
  19630. + will be called 3c527.
  19631. +
  19632. +config VORTEX
  19633. + tristate "3c590/3c900 series (592/595/597) \"Vortex/Boomerang\" support"
  19634. + depends on NET_VENDOR_3COM && (PCI || EISA)
  19635. + select MII
  19636. + ---help---
  19637. + This option enables driver support for a large number of 10Mbps and
  19638. + 10/100Mbps EISA, PCI and PCMCIA 3Com network cards:
  19639. +
  19640. + "Vortex" (Fast EtherLink 3c590/3c592/3c595/3c597) EISA and PCI
  19641. + "Boomerang" (EtherLink XL 3c900 or 3c905) PCI
  19642. + "Cyclone" (3c540/3c900/3c905/3c980/3c575/3c656) PCI and Cardbus
  19643. + "Tornado" (3c905) PCI
  19644. + "Hurricane" (3c555/3cSOHO) PCI
  19645. +
  19646. + If you have such a card, say Y and read the Ethernet-HOWTO,
  19647. + available from <http://www.tldp.org/docs.html#howto>. More
  19648. + specific information is in
  19649. + <file:Documentation/networking/vortex.txt> and in the comments at
  19650. + the beginning of <file:drivers/net/3c59x.c>.
  19651. +
  19652. + To compile this support as a module, choose M here.
  19653. +
  19654. +config TYPHOON
  19655. + tristate "3cr990 series \"Typhoon\" support"
  19656. + depends on NET_VENDOR_3COM && PCI
  19657. + select CRC32
  19658. + ---help---
  19659. + This option enables driver support for the 3cr990 series of cards:
  19660. +
  19661. + 3C990-TX, 3CR990-TX-95, 3CR990-TX-97, 3CR990-FX-95, 3CR990-FX-97,
  19662. + 3CR990SVR, 3CR990SVR95, 3CR990SVR97, 3CR990-FX-95 Server,
  19663. + 3CR990-FX-97 Server, 3C990B-TX-M, 3C990BSVR
  19664. +
  19665. + If you have a network (Ethernet) card of this type, say Y and read
  19666. + the Ethernet-HOWTO, available from
  19667. + <http://www.tldp.org/docs.html#howto>.
  19668. +
  19669. + To compile this driver as a module, choose M here. The module
  19670. + will be called typhoon.
  19671. +
  19672. +config LANCE
  19673. + tristate "AMD LANCE and PCnet (AT1500 and NE2100) support"
  19674. + depends on ISA && ISA_DMA_API
  19675. + help
  19676. + If you have a network (Ethernet) card of this type, say Y and read
  19677. + the Ethernet-HOWTO, available from
  19678. + <http://www.tldp.org/docs.html#howto>. Some LinkSys cards are
  19679. + of this type.
  19680. +
  19681. + To compile this driver as a module, choose M here: the module
  19682. + will be called lance. This is recommended.
  19683. +
  19684. +config NET_VENDOR_SMC
  19685. + bool "Western Digital/SMC cards"
  19686. + depends on ISA || MCA || EISA || MAC
  19687. + help
  19688. + If you have a network (Ethernet) card belonging to this class, say Y
  19689. + and read the Ethernet-HOWTO, available from
  19690. + <http://www.tldp.org/docs.html#howto>.
  19691. +
  19692. + Note that the answer to this question doesn't directly affect the
  19693. + kernel: saying N will just cause the configurator to skip all
  19694. + the questions about Western Digital cards. If you say Y, you will be
  19695. + asked for your specific card in the following questions.
  19696. +
  19697. +config WD80x3
  19698. + tristate "WD80*3 support"
  19699. + depends on NET_VENDOR_SMC && ISA
  19700. + select CRC32
  19701. + help
  19702. + If you have a network (Ethernet) card of this type, say Y and read
  19703. + the Ethernet-HOWTO, available from
  19704. + <http://www.tldp.org/docs.html#howto>.
  19705. +
  19706. + To compile this driver as a module, choose M here. The module
  19707. + will be called wd.
  19708. +
  19709. +config ULTRAMCA
  19710. + tristate "SMC Ultra MCA support"
  19711. + depends on NET_VENDOR_SMC && MCA
  19712. + select CRC32
  19713. + help
  19714. + If you have a network (Ethernet) card of this type and are running
  19715. + an MCA based system (PS/2), say Y and read the Ethernet-HOWTO,
  19716. + available from <http://www.tldp.org/docs.html#howto>.
  19717. +
  19718. + To compile this driver as a module, choose M here. The module
  19719. + will be called smc-mca.
  19720. +
  19721. +config ULTRA
  19722. + tristate "SMC Ultra support"
  19723. + depends on NET_VENDOR_SMC && ISA
  19724. + select CRC32
  19725. + ---help---
  19726. + If you have a network (Ethernet) card of this type, say Y and read
  19727. + the Ethernet-HOWTO, available from
  19728. + <http://www.tldp.org/docs.html#howto>.
  19729. +
  19730. + Important: There have been many reports that, with some motherboards
  19731. + mixing an SMC Ultra and an Adaptec AHA154x SCSI card (or compatible,
  19732. + such as some BusLogic models) causes corruption problems with many
  19733. + operating systems. The Linux smc-ultra driver has a work-around for
  19734. + this but keep it in mind if you have such a SCSI card and have
  19735. + problems.
  19736. +
  19737. + To compile this driver as a module, choose M here. The module
  19738. + will be called smc-ultra.
  19739. +
  19740. +config ULTRA32
  19741. + tristate "SMC Ultra32 EISA support"
  19742. + depends on NET_VENDOR_SMC && EISA
  19743. + select CRC32
  19744. + help
  19745. + If you have a network (Ethernet) card of this type, say Y and read
  19746. + the Ethernet-HOWTO, available from
  19747. + <http://www.tldp.org/docs.html#howto>.
  19748. +
  19749. + To compile this driver as a module, choose M here. The module
  19750. + will be called smc-ultra32.
  19751. +
  19752. +config BFIN_MAC
  19753. + tristate "Blackfin on-chip MAC support"
  19754. + depends on NET_ETHERNET && (BF516 || BF518 || BF526 || BF527 || BF536 || BF537)
  19755. + select CRC32
  19756. + select MII
  19757. + select PHYLIB
  19758. + select BFIN_MAC_USE_L1 if DMA_UNCACHED_NONE
  19759. + help
  19760. + This is the driver for Blackfin on-chip mac device. Say Y if you want it
  19761. + compiled into the kernel. This driver is also available as a module
  19762. + ( = code which can be inserted in and removed from the running kernel
  19763. + whenever you want). The module will be called bfin_mac.
  19764. +
  19765. +config BFIN_MAC_USE_L1
  19766. + bool "Use L1 memory for rx/tx packets"
  19767. + depends on BFIN_MAC && (BF527 || BF537)
  19768. + default y
  19769. + help
  19770. + To get maximum network performance, you should use L1 memory as rx/tx buffers.
  19771. + Say N here if you want to reserve L1 memory for other uses.
  19772. +
  19773. +config BFIN_TX_DESC_NUM
  19774. + int "Number of transmit buffer packets"
  19775. + depends on BFIN_MAC
  19776. + range 6 10 if BFIN_MAC_USE_L1
  19777. + range 10 100
  19778. + default "10"
  19779. + help
  19780. + Set the number of buffer packets used in driver.
  19781. +
  19782. +config BFIN_RX_DESC_NUM
  19783. + int "Number of receive buffer packets"
  19784. + depends on BFIN_MAC
  19785. + range 20 100 if BFIN_MAC_USE_L1
  19786. + range 20 800
  19787. + default "20"
  19788. + help
  19789. + Set the number of buffer packets used in driver.
  19790. +
  19791. +config BFIN_MAC_RMII
  19792. + bool "RMII PHY Interface"
  19793. + depends on BFIN_MAC
  19794. + default y if BFIN527_EZKIT
  19795. + default n if BFIN537_STAMP
  19796. + help
  19797. + Use Reduced PHY MII Interface
  19798. +
  19799. +config BFIN_MAC_USE_HWSTAMP
  19800. + bool "Use IEEE 1588 hwstamp"
  19801. + depends on BFIN_MAC && BF518
  19802. + default y
  19803. + help
  19804. + To support the IEEE 1588 Precision Time Protocol (PTP), select y here
  19805. +
  19806. +config SMC9194
  19807. + tristate "SMC 9194 support"
  19808. + depends on NET_VENDOR_SMC && (ISA || MAC && BROKEN)
  19809. + select CRC32
  19810. + ---help---
  19811. + This is support for the SMC9xxx based Ethernet cards. Choose this
  19812. + option if you have a DELL laptop with the docking station, or
  19813. + another SMC9192/9194 based chipset. Say Y if you want it compiled
  19814. + into the kernel, and read the file
  19815. + <file:Documentation/networking/smc9.txt> and the Ethernet-HOWTO,
  19816. + available from <http://www.tldp.org/docs.html#howto>.
  19817. +
  19818. + To compile this driver as a module, choose M here. The module
  19819. + will be called smc9194.
  19820. +
  19821. +config SMC91X
  19822. + tristate "SMC 91C9x/91C1xxx support"
  19823. + select CRC32
  19824. + select MII
  19825. + depends on ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || \
  19826. + MIPS || BLACKFIN || MN10300 || COLDFIRE
  19827. + help
  19828. + This is a driver for SMC's 91x series of Ethernet chipsets,
  19829. + including the SMC91C94 and the SMC91C111. Say Y if you want it
  19830. + compiled into the kernel, and read the file
  19831. + <file:Documentation/networking/smc9.txt> and the Ethernet-HOWTO,
  19832. + available from <http://www.linuxdoc.org/docs.html#howto>.
  19833. +
  19834. + This driver is also available as a module ( = code which can be
  19835. + inserted in and removed from the running kernel whenever you want).
  19836. + The module will be called smc91x. If you want to compile it as a
  19837. + module, say M here and read <file:Documentation/kbuild/modules.txt>.
  19838. +
  19839. +config NET_NETX
  19840. + tristate "NetX Ethernet support"
  19841. + select MII
  19842. + depends on ARCH_NETX
  19843. + help
  19844. + This is support for the Hilscher netX builtin Ethernet ports
  19845. +
  19846. + To compile this driver as a module, choose M here. The module
  19847. + will be called netx-eth.
  19848. +
  19849. +config TI_DAVINCI_EMAC
  19850. + tristate "TI DaVinci EMAC Support"
  19851. + depends on ARM && ( ARCH_DAVINCI || ARCH_OMAP3 )
  19852. + select PHYLIB
  19853. + help
  19854. + This driver supports TI's DaVinci Ethernet .
  19855. +
  19856. + To compile this driver as a module, choose M here: the module
  19857. + will be called davinci_emac_driver. This is recommended.
  19858. +
  19859. +config DM9000
  19860. + tristate "DM9000 support"
  19861. + depends on ARM || BLACKFIN || MIPS
  19862. + select CRC32
  19863. + select MII
  19864. + ---help---
  19865. + Support for DM9000 chipset.
  19866. +
  19867. + To compile this driver as a module, choose M here. The module
  19868. + will be called dm9000.
  19869. +
  19870. +config DM9000_DEBUGLEVEL
  19871. + int "DM9000 maximum debug level"
  19872. + depends on DM9000
  19873. + default 4
  19874. + help
  19875. + The maximum level of debugging code compiled into the DM9000
  19876. + driver.
  19877. +
  19878. +config DM9000_FORCE_SIMPLE_PHY_POLL
  19879. + bool "Force simple NSR based PHY polling"
  19880. + depends on DM9000
  19881. + ---help---
  19882. + This configuration forces the DM9000 to use the NSR's LinkStatus
  19883. + bit to determine if the link is up or down instead of the more
  19884. + costly MII PHY reads. Note, this will not work if the chip is
  19885. + operating with an external PHY.
  19886. +
  19887. +config ENC28J60
  19888. + tristate "ENC28J60 support"
  19889. + depends on EXPERIMENTAL && SPI && NET_ETHERNET
  19890. + select CRC32
  19891. + ---help---
  19892. + Support for the Microchip EN28J60 ethernet chip.
  19893. +
  19894. + To compile this driver as a module, choose M here. The module will be
  19895. + called enc28j60.
  19896. +
  19897. +config ENC28J60_WRITEVERIFY
  19898. + bool "Enable write verify"
  19899. + depends on ENC28J60
  19900. + ---help---
  19901. + Enable the verify after the buffer write useful for debugging purpose.
  19902. + If unsure, say N.
  19903. +
  19904. +config ETHOC
  19905. + tristate "OpenCores 10/100 Mbps Ethernet MAC support"
  19906. + depends on NET_ETHERNET && HAS_IOMEM && HAS_DMA
  19907. + select MII
  19908. + select PHYLIB
  19909. + select CRC32
  19910. + select BITREVERSE
  19911. + help
  19912. + Say Y here if you want to use the OpenCores 10/100 Mbps Ethernet MAC.
  19913. +
  19914. +config GRETH
  19915. + tristate "Aeroflex Gaisler GRETH Ethernet MAC support"
  19916. + depends on SPARC
  19917. + select PHYLIB
  19918. + select CRC32
  19919. + help
  19920. + Say Y here if you want to use the Aeroflex Gaisler GRETH Ethernet MAC.
  19921. +
  19922. +config SMC911X
  19923. + tristate "SMSC LAN911[5678] support"
  19924. + select CRC32
  19925. + select MII
  19926. + depends on ARM || SUPERH
  19927. + help
  19928. + This is a driver for SMSC's LAN911x series of Ethernet chipsets
  19929. + including the new LAN9115, LAN9116, LAN9117, and LAN9118.
  19930. + Say Y if you want it compiled into the kernel,
  19931. + and read the Ethernet-HOWTO, available from
  19932. + <http://www.linuxdoc.org/docs.html#howto>.
  19933. +
  19934. + This driver is also available as a module. The module will be
  19935. + called smc911x. If you want to compile it as a module, say M
  19936. + here and read <file:Documentation/kbuild/modules.txt>
  19937. +
  19938. +config SMSC911X
  19939. + tristate "SMSC LAN911x/LAN921x families embedded ethernet support"
  19940. + depends on ARM || SUPERH || BLACKFIN || MIPS
  19941. + select CRC32
  19942. + select MII
  19943. + select PHYLIB
  19944. + ---help---
  19945. + Say Y here if you want support for SMSC LAN911x and LAN921x families
  19946. + of ethernet controllers.
  19947. +
  19948. + To compile this driver as a module, choose M here and read
  19949. + <file:Documentation/networking/net-modules.txt>. The module
  19950. + will be called smsc911x.
  19951. +
  19952. +config NET_VENDOR_RACAL
  19953. + bool "Racal-Interlan (Micom) NI cards"
  19954. + depends on ISA
  19955. + help
  19956. + If you have a network (Ethernet) card belonging to this class, such
  19957. + as the NI5010, NI5210 or NI6210, say Y and read the Ethernet-HOWTO,
  19958. + available from <http://www.tldp.org/docs.html#howto>.
  19959. +
  19960. + Note that the answer to this question doesn't directly affect the
  19961. + kernel: saying N will just cause the configurator to skip all
  19962. + the questions about NI cards. If you say Y, you will be asked for
  19963. + your specific card in the following questions.
  19964. +
  19965. +config NI5010
  19966. + tristate "NI5010 support (EXPERIMENTAL)"
  19967. + depends on NET_VENDOR_RACAL && ISA && EXPERIMENTAL && BROKEN_ON_SMP
  19968. + ---help---
  19969. + If you have a network (Ethernet) card of this type, say Y and read
  19970. + the Ethernet-HOWTO, available from
  19971. + <http://www.tldp.org/docs.html#howto>. Note that this is still
  19972. + experimental code.
  19973. +
  19974. + To compile this driver as a module, choose M here. The module
  19975. + will be called ni5010.
  19976. +
  19977. +config NI52
  19978. + tristate "NI5210 support"
  19979. + depends on NET_VENDOR_RACAL && ISA
  19980. + help
  19981. + If you have a network (Ethernet) card of this type, say Y and read
  19982. + the Ethernet-HOWTO, available from
  19983. + <http://www.tldp.org/docs.html#howto>.
  19984. +
  19985. + To compile this driver as a module, choose M here. The module
  19986. + will be called ni52.
  19987. +
  19988. +config NI65
  19989. + tristate "NI6510 support"
  19990. + depends on NET_VENDOR_RACAL && ISA && ISA_DMA_API
  19991. + help
  19992. + If you have a network (Ethernet) card of this type, say Y and read
  19993. + the Ethernet-HOWTO, available from
  19994. + <http://www.tldp.org/docs.html#howto>.
  19995. +
  19996. + To compile this driver as a module, choose M here. The module
  19997. + will be called ni65.
  19998. +
  19999. +config DNET
  20000. + tristate "Dave ethernet support (DNET)"
  20001. + depends on NET_ETHERNET && HAS_IOMEM
  20002. + select PHYLIB
  20003. + help
  20004. + The Dave ethernet interface (DNET) is found on Qong Board FPGA.
  20005. + Say Y to include support for the DNET chip.
  20006. +
  20007. + To compile this driver as a module, choose M here: the module
  20008. + will be called dnet.
  20009. +
  20010. +source "drivers/net/tulip/Kconfig"
  20011. +
  20012. +config AT1700
  20013. + tristate "AT1700/1720 support (EXPERIMENTAL)"
  20014. + depends on (ISA || MCA_LEGACY) && EXPERIMENTAL
  20015. + select CRC32
  20016. + ---help---
  20017. + If you have a network (Ethernet) card of this type, say Y and read
  20018. + the Ethernet-HOWTO, available from
  20019. + <http://www.tldp.org/docs.html#howto>.
  20020. +
  20021. + To compile this driver as a module, choose M here. The module
  20022. + will be called at1700.
  20023. +
  20024. +config DEPCA
  20025. + tristate "DEPCA, DE10x, DE200, DE201, DE202, DE422 support"
  20026. + depends on ISA || EISA || MCA
  20027. + select CRC32
  20028. + ---help---
  20029. + If you have a network (Ethernet) card of this type, say Y and read
  20030. + the Ethernet-HOWTO, available from
  20031. + <http://www.tldp.org/docs.html#howto> as well as
  20032. + <file:drivers/net/depca.c>.
  20033. +
  20034. + To compile this driver as a module, choose M here. The module
  20035. + will be called depca.
  20036. +
  20037. +config HP100
  20038. + tristate "HP 10/100VG PCLAN (ISA, EISA, PCI) support"
  20039. + depends on ISA || EISA || PCI
  20040. + help
  20041. + If you have a network (Ethernet) card of this type, say Y and read
  20042. + the Ethernet-HOWTO, available from
  20043. + <http://www.tldp.org/docs.html#howto>.
  20044. +
  20045. + To compile this driver as a module, choose M here. The module
  20046. + will be called hp100.
  20047. +
  20048. +config NET_ISA
  20049. + bool "Other ISA cards"
  20050. + depends on ISA
  20051. + ---help---
  20052. + If your network (Ethernet) card hasn't been mentioned yet and its
  20053. + bus system (that's the way the cards talks to the other components
  20054. + of your computer) is ISA (as opposed to EISA, VLB or PCI), say Y.
  20055. + Make sure you know the name of your card. Read the Ethernet-HOWTO,
  20056. + available from <http://www.tldp.org/docs.html#howto>.
  20057. +
  20058. + If unsure, say Y.
  20059. +
  20060. + Note that the answer to this question doesn't directly affect the
  20061. + kernel: saying N will just cause the configurator to skip all
  20062. + the remaining ISA network card questions. If you say Y, you will be
  20063. + asked for your specific card in the following questions.
  20064. +
  20065. +config E2100
  20066. + tristate "Cabletron E21xx support"
  20067. + depends on NET_ISA
  20068. + select CRC32
  20069. + help
  20070. + If you have a network (Ethernet) card of this type, say Y and read
  20071. + the Ethernet-HOWTO, available from
  20072. + <http://www.tldp.org/docs.html#howto>.
  20073. +
  20074. + To compile this driver as a module, choose M here. The module
  20075. + will be called e2100.
  20076. +
  20077. +config EWRK3
  20078. + tristate "EtherWORKS 3 (DE203, DE204, DE205) support"
  20079. + depends on NET_ISA
  20080. + select CRC32
  20081. + ---help---
  20082. + This driver supports the DE203, DE204 and DE205 network (Ethernet)
  20083. + cards. If this is for you, say Y and read
  20084. + <file:Documentation/networking/ewrk3.txt> in the kernel source as
  20085. + well as the Ethernet-HOWTO, available from
  20086. + <http://www.tldp.org/docs.html#howto>.
  20087. +
  20088. + To compile this driver as a module, choose M here. The module
  20089. + will be called ewrk3.
  20090. +
  20091. +config EEXPRESS
  20092. + tristate "EtherExpress 16 support"
  20093. + depends on NET_ISA
  20094. + ---help---
  20095. + If you have an EtherExpress16 network (Ethernet) card, say Y and
  20096. + read the Ethernet-HOWTO, available from
  20097. + <http://www.tldp.org/docs.html#howto>. Note that the Intel
  20098. + EtherExpress16 card used to be regarded as a very poor choice
  20099. + because the driver was very unreliable. We now have a new driver
  20100. + that should do better.
  20101. +
  20102. + To compile this driver as a module, choose M here. The module
  20103. + will be called eexpress.
  20104. +
  20105. +config EEXPRESS_PRO
  20106. + tristate "EtherExpressPro support/EtherExpress 10 (i82595) support"
  20107. + depends on NET_ISA
  20108. + ---help---
  20109. + If you have a network (Ethernet) card of this type, say Y. This
  20110. + driver supports Intel i82595{FX,TX} based boards. Note however
  20111. + that the EtherExpress PRO/100 Ethernet card has its own separate
  20112. + driver. Please read the Ethernet-HOWTO, available from
  20113. + <http://www.tldp.org/docs.html#howto>.
  20114. +
  20115. + To compile this driver as a module, choose M here. The module
  20116. + will be called eepro.
  20117. +
  20118. +config HPLAN_PLUS
  20119. + tristate "HP PCLAN+ (27247B and 27252A) support"
  20120. + depends on NET_ISA
  20121. + select CRC32
  20122. + help
  20123. + If you have a network (Ethernet) card of this type, say Y and read
  20124. + the Ethernet-HOWTO, available from
  20125. + <http://www.tldp.org/docs.html#howto>.
  20126. +
  20127. + To compile this driver as a module, choose M here. The module
  20128. + will be called hp-plus.
  20129. +
  20130. +config HPLAN
  20131. + tristate "HP PCLAN (27245 and other 27xxx series) support"
  20132. + depends on NET_ISA
  20133. + select CRC32
  20134. + help
  20135. + If you have a network (Ethernet) card of this type, say Y and read
  20136. + the Ethernet-HOWTO, available from
  20137. + <http://www.tldp.org/docs.html#howto>.
  20138. +
  20139. + To compile this driver as a module, choose M here. The module
  20140. + will be called hp.
  20141. +
  20142. +config LP486E
  20143. + tristate "LP486E on board Ethernet"
  20144. + depends on NET_ISA
  20145. + help
  20146. + Say Y here to support the 82596-based on-board Ethernet controller
  20147. + for the Panther motherboard, which is one of the two shipped in the
  20148. + Intel Professional Workstation.
  20149. +
  20150. +config ETH16I
  20151. + tristate "ICL EtherTeam 16i/32 support"
  20152. + depends on NET_ISA
  20153. + help
  20154. + If you have a network (Ethernet) card of this type, say Y and read
  20155. + the Ethernet-HOWTO, available from
  20156. + <http://www.tldp.org/docs.html#howto>.
  20157. +
  20158. + To compile this driver as a module, choose M here. The module
  20159. + will be called eth16i.
  20160. +
  20161. +config NE2000
  20162. + tristate "NE2000/NE1000 support"
  20163. + depends on NET_ISA || (Q40 && m) || M32R || MACH_TX49XX
  20164. + select CRC32
  20165. + ---help---
  20166. + If you have a network (Ethernet) card of this type, say Y and read
  20167. + the Ethernet-HOWTO, available from
  20168. + <http://www.tldp.org/docs.html#howto>. Many Ethernet cards
  20169. + without a specific driver are compatible with NE2000.
  20170. +
  20171. + If you have a PCI NE2000 card however, say N here and Y to "PCI
  20172. + NE2000 and clone support" under "EISA, VLB, PCI and on board
  20173. + controllers" below. If you have a NE2000 card and are running on
  20174. + an MCA system (a bus system used on some IBM PS/2 computers and
  20175. + laptops), say N here and Y to "NE/2 (ne2000 MCA version) support",
  20176. + below.
  20177. +
  20178. + To compile this driver as a module, choose M here. The module
  20179. + will be called ne.
  20180. +
  20181. +config ZNET
  20182. + tristate "Zenith Z-Note support (EXPERIMENTAL)"
  20183. + depends on NET_ISA && EXPERIMENTAL && ISA_DMA_API
  20184. + help
  20185. + The Zenith Z-Note notebook computer has a built-in network
  20186. + (Ethernet) card, and this is the Linux driver for it. Note that the
  20187. + IBM Thinkpad 300 is compatible with the Z-Note and is also supported
  20188. + by this driver. Read the Ethernet-HOWTO, available from
  20189. + <http://www.tldp.org/docs.html#howto>.
  20190. +
  20191. +config SEEQ8005
  20192. + tristate "SEEQ8005 support (EXPERIMENTAL)"
  20193. + depends on NET_ISA && EXPERIMENTAL
  20194. + help
  20195. + This is a driver for the SEEQ 8005 network (Ethernet) card. If this
  20196. + is for you, read the Ethernet-HOWTO, available from
  20197. + <http://www.tldp.org/docs.html#howto>.
  20198. +
  20199. + To compile this driver as a module, choose M here. The module
  20200. + will be called seeq8005.
  20201. +
  20202. +config NE2_MCA
  20203. + tristate "NE/2 (ne2000 MCA version) support"
  20204. + depends on MCA_LEGACY
  20205. + select CRC32
  20206. + help
  20207. + If you have a network (Ethernet) card of this type, say Y and read
  20208. + the Ethernet-HOWTO, available from
  20209. + <http://www.tldp.org/docs.html#howto>.
  20210. +
  20211. + To compile this driver as a module, choose M here. The module
  20212. + will be called ne2.
  20213. +
  20214. +config IBMLANA
  20215. + tristate "IBM LAN Adapter/A support"
  20216. + depends on MCA
  20217. + ---help---
  20218. + This is a Micro Channel Ethernet adapter. You need to set
  20219. + CONFIG_MCA to use this driver. It is both available as an in-kernel
  20220. + driver and as a module.
  20221. +
  20222. + To compile this driver as a module, choose M here. The only
  20223. + currently supported card is the IBM LAN Adapter/A for Ethernet. It
  20224. + will both support 16K and 32K memory windows, however a 32K window
  20225. + gives a better security against packet losses. Usage of multiple
  20226. + boards with this driver should be possible, but has not been tested
  20227. + up to now due to lack of hardware.
  20228. +
  20229. +config IBMVETH
  20230. + tristate "IBM LAN Virtual Ethernet support"
  20231. + depends on PPC_PSERIES
  20232. + ---help---
  20233. + This driver supports virtual ethernet adapters on newer IBM iSeries
  20234. + and pSeries systems.
  20235. +
  20236. + To compile this driver as a module, choose M here. The module will
  20237. + be called ibmveth.
  20238. +
  20239. +source "drivers/net/ibm_newemac/Kconfig"
  20240. +
  20241. +config NET_PCI
  20242. + bool "EISA, VLB, PCI and on board controllers"
  20243. + depends on ISA || EISA || PCI
  20244. + help
  20245. + This is another class of network cards which attach directly to the
  20246. + bus. If you have one of those, say Y and read the Ethernet-HOWTO,
  20247. + available from <http://www.tldp.org/docs.html#howto>.
  20248. +
  20249. + Note that the answer to this question doesn't directly affect the
  20250. + kernel: saying N will just cause the configurator to skip all
  20251. + the questions about this class of network cards. If you say Y, you
  20252. + will be asked for your specific card in the following questions. If
  20253. + you are unsure, say Y.
  20254. +
  20255. +config PCNET32
  20256. + tristate "AMD PCnet32 PCI support"
  20257. + depends on NET_PCI && PCI
  20258. + select CRC32
  20259. + select MII
  20260. + help
  20261. + If you have a PCnet32 or PCnetPCI based network (Ethernet) card,
  20262. + answer Y here and read the Ethernet-HOWTO, available from
  20263. + <http://www.tldp.org/docs.html#howto>.
  20264. +
  20265. + To compile this driver as a module, choose M here. The module
  20266. + will be called pcnet32.
  20267. +
  20268. +config AMD8111_ETH
  20269. + tristate "AMD 8111 (new PCI lance) support"
  20270. + depends on NET_PCI && PCI
  20271. + select CRC32
  20272. + select MII
  20273. + help
  20274. + If you have an AMD 8111-based PCI lance ethernet card,
  20275. + answer Y here and read the Ethernet-HOWTO, available from
  20276. + <http://www.tldp.org/docs.html#howto>.
  20277. +
  20278. + To compile this driver as a module, choose M here. The module
  20279. + will be called amd8111e.
  20280. +
  20281. +config ADAPTEC_STARFIRE
  20282. + tristate "Adaptec Starfire/DuraLAN support"
  20283. + depends on NET_PCI && PCI
  20284. + select CRC32
  20285. + select MII
  20286. + help
  20287. + Say Y here if you have an Adaptec Starfire (or DuraLAN) PCI network
  20288. + adapter. The DuraLAN chip is used on the 64 bit PCI boards from
  20289. + Adaptec e.g. the ANA-6922A. The older 32 bit boards use the tulip
  20290. + driver.
  20291. +
  20292. + To compile this driver as a module, choose M here: the module
  20293. + will be called starfire. This is recommended.
  20294. +
  20295. +config AC3200
  20296. + tristate "Ansel Communications EISA 3200 support (EXPERIMENTAL)"
  20297. + depends on NET_PCI && (ISA || EISA) && EXPERIMENTAL
  20298. + select CRC32
  20299. + help
  20300. + If you have a network (Ethernet) card of this type, say Y and read
  20301. + the Ethernet-HOWTO, available from
  20302. + <http://www.tldp.org/docs.html#howto>.
  20303. +
  20304. + To compile this driver as a module, choose M here. The module
  20305. + will be called ac3200.
  20306. +
  20307. +config KSZ884X_PCI
  20308. + tristate "Micrel KSZ8841/2 PCI"
  20309. + depends on NET_PCI && PCI
  20310. + select MII
  20311. + select CRC32
  20312. + help
  20313. + This PCI driver is for Micrel KSZ8841/KSZ8842 PCI Ethernet chip.
  20314. +
  20315. + To compile this driver as a module, choose M here. The module
  20316. + will be called ksz884x.
  20317. +
  20318. +config APRICOT
  20319. + tristate "Apricot Xen-II on board Ethernet"
  20320. + depends on NET_PCI && ISA
  20321. + help
  20322. + If you have a network (Ethernet) controller of this type, say Y and
  20323. + read the Ethernet-HOWTO, available from
  20324. + <http://www.tldp.org/docs.html#howto>.
  20325. +
  20326. + To compile this driver as a module, choose M here. The module
  20327. + will be called apricot.
  20328. +
  20329. +config B44
  20330. + tristate "Broadcom 440x/47xx ethernet support"
  20331. + depends on SSB_POSSIBLE && HAS_DMA
  20332. + select SSB
  20333. + select MII
  20334. + help
  20335. + If you have a network (Ethernet) controller of this type, say Y
  20336. + or M and read the Ethernet-HOWTO, available from
  20337. + <http://www.tldp.org/docs.html#howto>.
  20338. +
  20339. + To compile this driver as a module, choose M here. The module
  20340. + will be called b44.
  20341. +
  20342. +# Auto-select SSB PCI-HOST support, if possible
  20343. +config B44_PCI_AUTOSELECT
  20344. + bool
  20345. + depends on B44 && SSB_PCIHOST_POSSIBLE
  20346. + select SSB_PCIHOST
  20347. + default y
  20348. +
  20349. +# Auto-select SSB PCICORE driver, if possible
  20350. +config B44_PCICORE_AUTOSELECT
  20351. + bool
  20352. + depends on B44 && SSB_DRIVER_PCICORE_POSSIBLE
  20353. + select SSB_DRIVER_PCICORE
  20354. + default y
  20355. +
  20356. +config B44_PCI
  20357. + bool
  20358. + depends on B44_PCI_AUTOSELECT && B44_PCICORE_AUTOSELECT
  20359. + default y
  20360. +
  20361. +config FORCEDETH
  20362. + tristate "nForce Ethernet support"
  20363. + depends on NET_PCI && PCI
  20364. + help
  20365. + If you have a network (Ethernet) controller of this type, say Y and
  20366. + read the Ethernet-HOWTO, available from
  20367. + <http://www.tldp.org/docs.html#howto>.
  20368. +
  20369. + To compile this driver as a module, choose M here. The module
  20370. + will be called forcedeth.
  20371. +
  20372. +config CS89x0
  20373. + tristate "CS89x0 support"
  20374. + depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \
  20375. + || ARCH_IXDP2X01 || ARCH_PNX010X || MACH_MX31ADS)
  20376. + ---help---
  20377. + Support for CS89x0 chipset based Ethernet cards. If you have a
  20378. + network (Ethernet) card of this type, say Y and read the
  20379. + Ethernet-HOWTO, available from
  20380. + <http://www.tldp.org/docs.html#howto> as well as
  20381. + <file:Documentation/networking/cs89x0.txt>.
  20382. +
  20383. + To compile this driver as a module, choose M here. The module
  20384. + will be called cs89x0.
  20385. +
  20386. +config CS89x0_NONISA_IRQ
  20387. + def_bool y
  20388. + depends on CS89x0 != n
  20389. + depends on MACH_IXDP2351 || ARCH_IXDP2X01 || ARCH_PNX010X || MACH_MX31ADS
  20390. +
  20391. +config TC35815
  20392. + tristate "TOSHIBA TC35815 Ethernet support"
  20393. + depends on NET_PCI && PCI && MIPS
  20394. + select PHYLIB
  20395. +
  20396. +config E100
  20397. + tristate "Intel(R) PRO/100+ support"
  20398. + depends on NET_PCI && PCI
  20399. + select MII
  20400. + ---help---
  20401. + This driver supports Intel(R) PRO/100 family of adapters.
  20402. + To verify that your adapter is supported, find the board ID number
  20403. + on the adapter. Look for a label that has a barcode and a number
  20404. + in the format 123456-001 (six digits hyphen three digits).
  20405. +
  20406. + Use the above information and the Adapter & Driver ID Guide at:
  20407. +
  20408. + <http://support.intel.com/support/network/adapter/pro100/21397.htm>
  20409. +
  20410. + to identify the adapter.
  20411. +
  20412. + For the latest Intel PRO/100 network driver for Linux, see:
  20413. +
  20414. + <http://appsr.intel.com/scripts-df/support_intel.asp>
  20415. +
  20416. + More specific information on configuring the driver is in
  20417. + <file:Documentation/networking/e100.txt>.
  20418. +
  20419. + To compile this driver as a module, choose M here. The module
  20420. + will be called e100.
  20421. +
  20422. +config LNE390
  20423. + tristate "Mylex EISA LNE390A/B support (EXPERIMENTAL)"
  20424. + depends on NET_PCI && EISA && EXPERIMENTAL
  20425. + select CRC32
  20426. + help
  20427. + If you have a network (Ethernet) card of this type, say Y and read
  20428. + the Ethernet-HOWTO, available from
  20429. + <http://www.tldp.org/docs.html#howto>.
  20430. +
  20431. + To compile this driver as a module, choose M here. The module
  20432. + will be called lne390.
  20433. +
  20434. +config FEALNX
  20435. + tristate "Myson MTD-8xx PCI Ethernet support"
  20436. + depends on NET_PCI && PCI
  20437. + select CRC32
  20438. + select MII
  20439. + help
  20440. + Say Y here to support the Mysom MTD-800 family of PCI-based Ethernet
  20441. + cards. Specifications and data at
  20442. + <http://www.myson.com.hk/mtd/datasheet/>.
  20443. +
  20444. +config NATSEMI
  20445. + tristate "National Semiconductor DP8381x series PCI Ethernet support"
  20446. + depends on NET_PCI && PCI
  20447. + select CRC32
  20448. + help
  20449. + This driver is for the National Semiconductor DP83810 series,
  20450. + which is used in cards from PureData, NetGear, Linksys
  20451. + and others, including the 83815 chip.
  20452. + More specific information and updates are available from
  20453. + <http://www.scyld.com/network/natsemi.html>.
  20454. +
  20455. +config NE2K_PCI
  20456. + tristate "PCI NE2000 and clones support (see help)"
  20457. + depends on NET_PCI && PCI
  20458. + select CRC32
  20459. + ---help---
  20460. + This driver is for NE2000 compatible PCI cards. It will not work
  20461. + with ISA NE2000 cards (they have their own driver, "NE2000/NE1000
  20462. + support" below). If you have a PCI NE2000 network (Ethernet) card,
  20463. + say Y and read the Ethernet-HOWTO, available from
  20464. + <http://www.tldp.org/docs.html#howto>.
  20465. +
  20466. + This driver also works for the following NE2000 clone cards:
  20467. + RealTek RTL-8029 Winbond 89C940 Compex RL2000 KTI ET32P2
  20468. + NetVin NV5000SC Via 86C926 SureCom NE34 Winbond
  20469. + Holtek HT80232 Holtek HT80229
  20470. +
  20471. + To compile this driver as a module, choose M here. The module
  20472. + will be called ne2k-pci.
  20473. +
  20474. +config NE3210
  20475. + tristate "Novell/Eagle/Microdyne NE3210 EISA support (EXPERIMENTAL)"
  20476. + depends on NET_PCI && EISA && EXPERIMENTAL
  20477. + select CRC32
  20478. + ---help---
  20479. + If you have a network (Ethernet) card of this type, say Y and read
  20480. + the Ethernet-HOWTO, available from
  20481. + <http://www.tldp.org/docs.html#howto>. Note that this driver
  20482. + will NOT WORK for NE3200 cards as they are completely different.
  20483. +
  20484. + To compile this driver as a module, choose M here. The module
  20485. + will be called ne3210.
  20486. +
  20487. +config ES3210
  20488. + tristate "Racal-Interlan EISA ES3210 support (EXPERIMENTAL)"
  20489. + depends on NET_PCI && EISA && EXPERIMENTAL
  20490. + select CRC32
  20491. + help
  20492. + If you have a network (Ethernet) card of this type, say Y and read
  20493. + the Ethernet-HOWTO, available from
  20494. + <http://www.tldp.org/docs.html#howto>.
  20495. +
  20496. + To compile this driver as a module, choose M here. The module
  20497. + will be called es3210.
  20498. +
  20499. +config 8139CP
  20500. + tristate "RealTek RTL-8139 C+ PCI Fast Ethernet Adapter support (EXPERIMENTAL)"
  20501. + depends on NET_PCI && PCI && EXPERIMENTAL
  20502. + select CRC32
  20503. + select MII
  20504. + help
  20505. + This is a driver for the Fast Ethernet PCI network cards based on
  20506. + the RTL8139C+ chips. If you have one of those, say Y and read
  20507. + the Ethernet-HOWTO, available from
  20508. + <http://www.tldp.org/docs.html#howto>.
  20509. +
  20510. + To compile this driver as a module, choose M here: the module
  20511. + will be called 8139cp. This is recommended.
  20512. +
  20513. +config 8139TOO
  20514. + tristate "RealTek RTL-8129/8130/8139 PCI Fast Ethernet Adapter support"
  20515. + depends on NET_PCI && PCI
  20516. + select CRC32
  20517. + select MII
  20518. + ---help---
  20519. + This is a driver for the Fast Ethernet PCI network cards based on
  20520. + the RTL 8129/8130/8139 chips. If you have one of those, say Y and
  20521. + read the Ethernet-HOWTO <http://www.tldp.org/docs.html#howto>.
  20522. +
  20523. + To compile this driver as a module, choose M here: the module
  20524. + will be called 8139too. This is recommended.
  20525. +
  20526. +config 8139TOO_PIO
  20527. + bool "Use PIO instead of MMIO"
  20528. + default y
  20529. + depends on 8139TOO
  20530. + help
  20531. + This instructs the driver to use programmed I/O ports (PIO) instead
  20532. + of PCI shared memory (MMIO). This can possibly solve some problems
  20533. + in case your mainboard has memory consistency issues. If unsure,
  20534. + say N.
  20535. +
  20536. +config 8139TOO_TUNE_TWISTER
  20537. + bool "Support for uncommon RTL-8139 rev. K (automatic channel equalization)"
  20538. + depends on 8139TOO
  20539. + help
  20540. + This implements a function which might come in handy in case you
  20541. + are using low quality on long cabling. It is required for RealTek
  20542. + RTL-8139 revision K boards, and totally unused otherwise. It tries
  20543. + to match the transceiver to the cable characteristics. This is
  20544. + experimental since hardly documented by the manufacturer.
  20545. + If unsure, say Y.
  20546. +
  20547. +config 8139TOO_8129
  20548. + bool "Support for older RTL-8129/8130 boards"
  20549. + depends on 8139TOO
  20550. + help
  20551. + This enables support for the older and uncommon RTL-8129 and
  20552. + RTL-8130 chips, which support MII via an external transceiver,
  20553. + instead of an internal one. Disabling this option will save some
  20554. + memory by making the code size smaller. If unsure, say Y.
  20555. +
  20556. +config 8139_OLD_RX_RESET
  20557. + bool "Use older RX-reset method"
  20558. + depends on 8139TOO
  20559. + help
  20560. + The 8139too driver was recently updated to contain a more rapid
  20561. + reset sequence, in the face of severe receive errors. This "new"
  20562. + RX-reset method should be adequate for all boards. But if you
  20563. + experience problems, you can enable this option to restore the
  20564. + old RX-reset behavior. If unsure, say N.
  20565. +
  20566. +config R6040
  20567. + tristate "RDC R6040 Fast Ethernet Adapter support"
  20568. + depends on NET_PCI && PCI
  20569. + select CRC32
  20570. + select MII
  20571. + help
  20572. + This is a driver for the R6040 Fast Ethernet MACs found in the
  20573. + the RDC R-321x System-on-chips.
  20574. +
  20575. + To compile this driver as a module, choose M here: the module
  20576. + will be called r6040. This is recommended.
  20577. +
  20578. +config SIS900
  20579. + tristate "SiS 900/7016 PCI Fast Ethernet Adapter support"
  20580. + depends on NET_PCI && PCI
  20581. + select CRC32
  20582. + select MII
  20583. + ---help---
  20584. + This is a driver for the Fast Ethernet PCI network cards based on
  20585. + the SiS 900 and SiS 7016 chips. The SiS 900 core is also embedded in
  20586. + SiS 630 and SiS 540 chipsets.
  20587. +
  20588. + This driver also supports AMD 79C901 HomePNA so that you can use
  20589. + your phone line as a network cable.
  20590. +
  20591. + To compile this driver as a module, choose M here: the module
  20592. + will be called sis900. This is recommended.
  20593. +
  20594. +config EPIC100
  20595. + tristate "SMC EtherPower II"
  20596. + depends on NET_PCI && PCI
  20597. + select CRC32
  20598. + select MII
  20599. + help
  20600. + This driver is for the SMC EtherPower II 9432 PCI Ethernet NIC,
  20601. + which is based on the SMC83c17x (EPIC/100).
  20602. + More specific information and updates are available from
  20603. + <http://www.scyld.com/network/epic100.html>.
  20604. +
  20605. +config SMSC9420
  20606. + tristate "SMSC LAN9420 PCI ethernet adapter support"
  20607. + depends on NET_PCI && PCI
  20608. + select CRC32
  20609. + select PHYLIB
  20610. + select SMSC_PHY
  20611. + help
  20612. + This is a driver for SMSC's LAN9420 PCI ethernet adapter.
  20613. + Say Y if you want it compiled into the kernel,
  20614. + and read the Ethernet-HOWTO, available from
  20615. + <http://www.linuxdoc.org/docs.html#howto>.
  20616. +
  20617. + This driver is also available as a module. The module will be
  20618. + called smsc9420. If you want to compile it as a module, say M
  20619. + here and read <file:Documentation/kbuild/modules.txt>
  20620. +
  20621. +config SUNDANCE
  20622. + tristate "Sundance Alta support"
  20623. + depends on NET_PCI && PCI
  20624. + select CRC32
  20625. + select MII
  20626. + help
  20627. + This driver is for the Sundance "Alta" chip.
  20628. + More specific information and updates are available from
  20629. + <http://www.scyld.com/network/sundance.html>.
  20630. +
  20631. +config SUNDANCE_MMIO
  20632. + bool "Use MMIO instead of PIO"
  20633. + depends on SUNDANCE
  20634. + help
  20635. + Enable memory-mapped I/O for interaction with Sundance NIC registers.
  20636. + Do NOT enable this by default, PIO (enabled when MMIO is disabled)
  20637. + is known to solve bugs on certain chips.
  20638. +
  20639. + If unsure, say N.
  20640. +
  20641. +config TLAN
  20642. + tristate "TI ThunderLAN support"
  20643. + depends on NET_PCI && (PCI || EISA)
  20644. + ---help---
  20645. + If you have a PCI Ethernet network card based on the ThunderLAN chip
  20646. + which is supported by this driver, say Y and read the
  20647. + Ethernet-HOWTO, available from
  20648. + <http://www.tldp.org/docs.html#howto>.
  20649. +
  20650. + Devices currently supported by this driver are Compaq Netelligent,
  20651. + Compaq NetFlex and Olicom cards. Please read the file
  20652. + <file:Documentation/networking/tlan.txt> for more details.
  20653. +
  20654. + To compile this driver as a module, choose M here. The module
  20655. + will be called tlan.
  20656. +
  20657. + Please email feedback to <torben.mathiasen@compaq.com>.
  20658. +
  20659. +config KS8842
  20660. + tristate "Micrel KSZ8842"
  20661. + depends on HAS_IOMEM
  20662. + help
  20663. + This platform driver is for Micrel KSZ8842 / KS8842
  20664. + 2-port ethernet switch chip (managed, VLAN, QoS).
  20665. +
  20666. +config KS8851
  20667. + tristate "Micrel KS8851 SPI"
  20668. + depends on SPI
  20669. + select MII
  20670. + select CRC32
  20671. + help
  20672. + SPI driver for Micrel KS8851 SPI attached network chip.
  20673. +
  20674. +config KS8851_MLL
  20675. + tristate "Micrel KS8851 MLL"
  20676. + depends on HAS_IOMEM
  20677. + select MII
  20678. + help
  20679. + This platform driver is for Micrel KS8851 Address/data bus
  20680. + multiplexed network chip.
  20681. +
  20682. +config VIA_RHINE
  20683. + tristate "VIA Rhine support"
  20684. + depends on NET_PCI && PCI
  20685. + select CRC32
  20686. + select MII
  20687. + help
  20688. + If you have a VIA "Rhine" based network card (Rhine-I (VT86C100A),
  20689. + Rhine-II (VT6102), or Rhine-III (VT6105)), say Y here. Rhine-type
  20690. + Ethernet functions can also be found integrated on South Bridges
  20691. + (e.g. VT8235).
  20692. +
  20693. + To compile this driver as a module, choose M here. The module
  20694. + will be called via-rhine.
  20695. +
  20696. +config VIA_RHINE_MMIO
  20697. + bool "Use MMIO instead of PIO"
  20698. + depends on VIA_RHINE
  20699. + help
  20700. + This instructs the driver to use PCI shared memory (MMIO) instead of
  20701. + programmed I/O ports (PIO). Enabling this gives an improvement in
  20702. + processing time in parts of the driver.
  20703. +
  20704. + If unsure, say Y.
  20705. +
  20706. +config SC92031
  20707. + tristate "Silan SC92031 PCI Fast Ethernet Adapter driver (EXPERIMENTAL)"
  20708. + depends on NET_PCI && PCI && EXPERIMENTAL
  20709. + select CRC32
  20710. + ---help---
  20711. + This is a driver for the Fast Ethernet PCI network cards based on
  20712. + the Silan SC92031 chip (sometimes also called Rsltek 8139D). If you
  20713. + have one of these, say Y here.
  20714. +
  20715. + To compile this driver as a module, choose M here: the module
  20716. + will be called sc92031. This is recommended.
  20717. +
  20718. +config CPMAC
  20719. + tristate "TI AR7 CPMAC Ethernet support (EXPERIMENTAL)"
  20720. + depends on NET_ETHERNET && EXPERIMENTAL && AR7
  20721. + select PHYLIB
  20722. + help
  20723. + TI AR7 CPMAC Ethernet support
  20724. +
  20725. +config NET_POCKET
  20726. + bool "Pocket and portable adapters"
  20727. + depends on PARPORT
  20728. + ---help---
  20729. + Cute little network (Ethernet) devices which attach to the parallel
  20730. + port ("pocket adapters"), commonly used with laptops. If you have
  20731. + one of those, say Y and read the Ethernet-HOWTO, available from
  20732. + <http://www.tldp.org/docs.html#howto>.
  20733. +
  20734. + If you want to plug a network (or some other) card into the PCMCIA
  20735. + (or PC-card) slot of your laptop instead (PCMCIA is the standard for
  20736. + credit card size extension cards used by all modern laptops), you
  20737. + need the pcmcia-cs package (location contained in the file
  20738. + <file:Documentation/Changes>) and you can say N here.
  20739. +
  20740. + Laptop users should read the Linux Laptop home page at
  20741. + <http://www.linux-on-laptops.com/> or
  20742. + Tuxmobil - Linux on Mobile Computers at <http://www.tuxmobil.org/>.
  20743. +
  20744. + Note that the answer to this question doesn't directly affect the
  20745. + kernel: saying N will just cause the configurator to skip all
  20746. + the questions about this class of network devices. If you say Y, you
  20747. + will be asked for your specific device in the following questions.
  20748. +
  20749. +config ATP
  20750. + tristate "AT-LAN-TEC/RealTek pocket adapter support"
  20751. + depends on NET_POCKET && PARPORT && X86
  20752. + select CRC32
  20753. + ---help---
  20754. + This is a network (Ethernet) device which attaches to your parallel
  20755. + port. Read <file:drivers/net/atp.c> as well as the Ethernet-HOWTO,
  20756. + available from <http://www.tldp.org/docs.html#howto>, if you
  20757. + want to use this. If you intend to use this driver, you should have
  20758. + said N to the "Parallel printer support", because the two drivers
  20759. + don't like each other.
  20760. +
  20761. + To compile this driver as a module, choose M here: the module
  20762. + will be called atp.
  20763. +
  20764. +config DE600
  20765. + tristate "D-Link DE600 pocket adapter support"
  20766. + depends on NET_POCKET && PARPORT
  20767. + ---help---
  20768. + This is a network (Ethernet) device which attaches to your parallel
  20769. + port. Read <file:Documentation/networking/DLINK.txt> as well as the
  20770. + Ethernet-HOWTO, available from
  20771. + <http://www.tldp.org/docs.html#howto>, if you want to use
  20772. + this. It is possible to have several devices share a single parallel
  20773. + port and it is safe to compile the corresponding drivers into the
  20774. + kernel.
  20775. +
  20776. + To compile this driver as a module, choose M here: the module
  20777. + will be called de600.
  20778. +
  20779. +config DE620
  20780. + tristate "D-Link DE620 pocket adapter support"
  20781. + depends on NET_POCKET && PARPORT
  20782. + ---help---
  20783. + This is a network (Ethernet) device which attaches to your parallel
  20784. + port. Read <file:Documentation/networking/DLINK.txt> as well as the
  20785. + Ethernet-HOWTO, available from
  20786. + <http://www.tldp.org/docs.html#howto>, if you want to use
  20787. + this. It is possible to have several devices share a single parallel
  20788. + port and it is safe to compile the corresponding drivers into the
  20789. + kernel.
  20790. +
  20791. + To compile this driver as a module, choose M here: the module
  20792. + will be called de620.
  20793. +
  20794. +config SGISEEQ
  20795. + tristate "SGI Seeq ethernet controller support"
  20796. + depends on SGI_HAS_SEEQ
  20797. + help
  20798. + Say Y here if you have an Seeq based Ethernet network card. This is
  20799. + used in many Silicon Graphics machines.
  20800. +
  20801. +config DECLANCE
  20802. + tristate "DEC LANCE ethernet controller support"
  20803. + depends on MACH_DECSTATION
  20804. + select CRC32
  20805. + help
  20806. + This driver is for the series of Ethernet controllers produced by
  20807. + DEC (now Compaq) based on the AMD Lance chipset, including the
  20808. + DEPCA series. (This chipset is better known via the NE2100 cards.)
  20809. +
  20810. +config 68360_ENET
  20811. + bool "Motorola 68360 ethernet controller"
  20812. + depends on M68360
  20813. + help
  20814. + Say Y here if you want to use the built-in ethernet controller of
  20815. + the Motorola 68360 processor.
  20816. +
  20817. +config FEC
  20818. + bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)"
  20819. + depends on M523x || M527x || M5272 || M528x || M520x || M532x || \
  20820. + MACH_MX27 || ARCH_MX35 || ARCH_MX25 || ARCH_MX5
  20821. + select PHYLIB
  20822. + help
  20823. + Say Y here if you want to use the built-in 10/100 Fast ethernet
  20824. + controller on some Motorola ColdFire and Freescale i.MX processors.
  20825. +
  20826. +config FEC2
  20827. + bool "Second FEC ethernet controller (on some ColdFire CPUs)"
  20828. + depends on FEC
  20829. + help
  20830. + Say Y here if you want to use the second built-in 10/100 Fast
  20831. + ethernet controller on some Motorola ColdFire processors.
  20832. +
  20833. +config FEC_MPC52xx
  20834. + tristate "MPC52xx FEC driver"
  20835. + depends on PPC_MPC52xx && PPC_BESTCOMM
  20836. + select CRC32
  20837. + select PHYLIB
  20838. + select PPC_BESTCOMM_FEC
  20839. + ---help---
  20840. + This option enables support for the MPC5200's on-chip
  20841. + Fast Ethernet Controller
  20842. + If compiled as module, it will be called fec_mpc52xx.
  20843. +
  20844. +config FEC_MPC52xx_MDIO
  20845. + bool "MPC52xx FEC MDIO bus driver"
  20846. + depends on FEC_MPC52xx
  20847. + default y
  20848. + ---help---
  20849. + The MPC5200's FEC can connect to the Ethernet either with
  20850. + an external MII PHY chip or 10 Mbps 7-wire interface
  20851. + (Motorola? industry standard).
  20852. + If your board uses an external PHY connected to FEC, enable this.
  20853. + If not sure, enable.
  20854. + If compiled as module, it will be called fec_mpc52xx_phy.
  20855. +
  20856. +config NE_H8300
  20857. + tristate "NE2000 compatible support for H8/300"
  20858. + depends on H8300
  20859. + help
  20860. + Say Y here if you want to use the NE2000 compatible
  20861. + controller on the Renesas H8/300 processor.
  20862. +
  20863. +config ATL2
  20864. + tristate "Atheros L2 Fast Ethernet support"
  20865. + depends on PCI
  20866. + select CRC32
  20867. + select MII
  20868. + help
  20869. + This driver supports the Atheros L2 fast ethernet adapter.
  20870. +
  20871. + To compile this driver as a module, choose M here. The module
  20872. + will be called atl2.
  20873. +
  20874. +config XILINX_EMACLITE
  20875. + tristate "Xilinx 10/100 Ethernet Lite support"
  20876. + depends on PPC32 || MICROBLAZE
  20877. + select PHYLIB
  20878. + help
  20879. + This driver supports the 10/100 Ethernet Lite from Xilinx.
  20880. +
  20881. +config BCM63XX_ENET
  20882. + tristate "Broadcom 63xx internal mac support"
  20883. + depends on BCM63XX
  20884. + select MII
  20885. + select PHYLIB
  20886. + help
  20887. + This driver supports the ethernet MACs in the Broadcom 63xx
  20888. + MIPS chipset family (BCM63XX).
  20889. +
  20890. +source "drivers/net/fs_enet/Kconfig"
  20891. +
  20892. +source "drivers/net/octeon/Kconfig"
  20893. +
  20894. +endif # NET_ETHERNET
  20895. +
  20896. +#
  20897. +# Gigabit Ethernet
  20898. +#
  20899. +
  20900. +menuconfig NETDEV_1000
  20901. + bool "Ethernet (1000 Mbit)"
  20902. + depends on !UML
  20903. + default y
  20904. + ---help---
  20905. + Ethernet (also called IEEE 802.3 or ISO 8802-2) is the most common
  20906. + type of Local Area Network (LAN) in universities and companies.
  20907. +
  20908. + Say Y here to get to see options for Gigabit Ethernet drivers.
  20909. + This option alone does not add any kernel code.
  20910. + Note that drivers supporting both 100 and 1000 MBit may be listed
  20911. + under "Ethernet (10 or 100MBit)" instead.
  20912. +
  20913. + If you say N, all options in this submenu will be skipped and disabled.
  20914. +
  20915. +if NETDEV_1000
  20916. +
  20917. +config ACENIC
  20918. + tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support"
  20919. + depends on PCI
  20920. + ---help---
  20921. + Say Y here if you have an Alteon AceNIC, 3Com 3C985(B), NetGear
  20922. + GA620, SGI Gigabit or Farallon PN9000-SX PCI Gigabit Ethernet
  20923. + adapter. The driver allows for using the Jumbo Frame option (9000
  20924. + bytes/frame) however it requires that your switches can handle this
  20925. + as well. To enable Jumbo Frames, add `mtu 9000' to your ifconfig
  20926. + line.
  20927. +
  20928. + To compile this driver as a module, choose M here: the
  20929. + module will be called acenic.
  20930. +
  20931. +config ACENIC_OMIT_TIGON_I
  20932. + bool "Omit support for old Tigon I based AceNICs"
  20933. + depends on ACENIC
  20934. + help
  20935. + Say Y here if you only have Tigon II based AceNICs and want to leave
  20936. + out support for the older Tigon I based cards which are no longer
  20937. + being sold (ie. the original Alteon AceNIC and 3Com 3C985 (non B
  20938. + version)). This will reduce the size of the driver object by
  20939. + app. 100KB. If you are not sure whether your card is a Tigon I or a
  20940. + Tigon II, say N here.
  20941. +
  20942. + The safe and default value for this is N.
  20943. +
  20944. +config DL2K
  20945. + tristate "DL2000/TC902x-based Gigabit Ethernet support"
  20946. + depends on PCI
  20947. + select CRC32
  20948. + help
  20949. + This driver supports DL2000/TC902x-based Gigabit ethernet cards,
  20950. + which includes
  20951. + D-Link DGE-550T Gigabit Ethernet Adapter.
  20952. + D-Link DL2000-based Gigabit Ethernet Adapter.
  20953. + Sundance/Tamarack TC902x Gigabit Ethernet Adapter.
  20954. +
  20955. + To compile this driver as a module, choose M here: the
  20956. + module will be called dl2k.
  20957. +
  20958. +config E1000
  20959. + tristate "Intel(R) PRO/1000 Gigabit Ethernet support"
  20960. + depends on PCI
  20961. + ---help---
  20962. + This driver supports Intel(R) PRO/1000 gigabit ethernet family of
  20963. + adapters. For more information on how to identify your adapter, go
  20964. + to the Adapter & Driver ID Guide at:
  20965. +
  20966. + <http://support.intel.com/support/network/adapter/pro100/21397.htm>
  20967. +
  20968. + For general information and support, go to the Intel support
  20969. + website at:
  20970. +
  20971. + <http://support.intel.com>
  20972. +
  20973. + More specific information on configuring the driver is in
  20974. + <file:Documentation/networking/e1000.txt>.
  20975. +
  20976. + To compile this driver as a module, choose M here. The module
  20977. + will be called e1000.
  20978. +
  20979. +config E1000E
  20980. + tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support"
  20981. + depends on PCI && (!SPARC32 || BROKEN)
  20982. + ---help---
  20983. + This driver supports the PCI-Express Intel(R) PRO/1000 gigabit
  20984. + ethernet family of adapters. For PCI or PCI-X e1000 adapters,
  20985. + use the regular e1000 driver For more information on how to
  20986. + identify your adapter, go to the Adapter & Driver ID Guide at:
  20987. +
  20988. + <http://support.intel.com/support/network/adapter/pro100/21397.htm>
  20989. +
  20990. + For general information and support, go to the Intel support
  20991. + website at:
  20992. +
  20993. + <http://support.intel.com>
  20994. +
  20995. + To compile this driver as a module, choose M here. The module
  20996. + will be called e1000e.
  20997. +
  20998. +config IP1000
  20999. + tristate "IP1000 Gigabit Ethernet support"
  21000. + depends on PCI && EXPERIMENTAL
  21001. + select MII
  21002. + ---help---
  21003. + This driver supports IP1000 gigabit Ethernet cards.
  21004. +
  21005. + To compile this driver as a module, choose M here: the module
  21006. + will be called ipg. This is recommended.
  21007. +
  21008. +config IGB
  21009. + tristate "Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support"
  21010. + depends on PCI
  21011. + ---help---
  21012. + This driver supports Intel(R) 82575/82576 gigabit ethernet family of
  21013. + adapters. For more information on how to identify your adapter, go
  21014. + to the Adapter & Driver ID Guide at:
  21015. +
  21016. + <http://support.intel.com/support/network/adapter/pro100/21397.htm>
  21017. +
  21018. + For general information and support, go to the Intel support
  21019. + website at:
  21020. +
  21021. + <http://support.intel.com>
  21022. +
  21023. + More specific information on configuring the driver is in
  21024. + <file:Documentation/networking/e1000.txt>.
  21025. +
  21026. + To compile this driver as a module, choose M here. The module
  21027. + will be called igb.
  21028. +
  21029. +config IGB_DCA
  21030. + bool "Direct Cache Access (DCA) Support"
  21031. + default y
  21032. + depends on IGB && DCA && !(IGB=y && DCA=m)
  21033. + ---help---
  21034. + Say Y here if you want to use Direct Cache Access (DCA) in the
  21035. + driver. DCA is a method for warming the CPU cache before data
  21036. + is used, with the intent of lessening the impact of cache misses.
  21037. +
  21038. +config IGBVF
  21039. + tristate "Intel(R) 82576 Virtual Function Ethernet support"
  21040. + depends on PCI
  21041. + ---help---
  21042. + This driver supports Intel(R) 82576 virtual functions. For more
  21043. + information on how to identify your adapter, go to the Adapter &
  21044. + Driver ID Guide at:
  21045. +
  21046. + <http://support.intel.com/support/network/adapter/pro100/21397.htm>
  21047. +
  21048. + For general information and support, go to the Intel support
  21049. + website at:
  21050. +
  21051. + <http://support.intel.com>
  21052. +
  21053. + More specific information on configuring the driver is in
  21054. + <file:Documentation/networking/e1000.txt>.
  21055. +
  21056. + To compile this driver as a module, choose M here. The module
  21057. + will be called igbvf.
  21058. +
  21059. +source "drivers/net/ixp2000/Kconfig"
  21060. +
  21061. +config MYRI_SBUS
  21062. + tristate "MyriCOM Gigabit Ethernet support"
  21063. + depends on SBUS
  21064. + help
  21065. + This driver supports MyriCOM Sbus gigabit Ethernet cards.
  21066. +
  21067. + To compile this driver as a module, choose M here: the module
  21068. + will be called myri_sbus. This is recommended.
  21069. +
  21070. +config NS83820
  21071. + tristate "National Semiconductor DP83820 support"
  21072. + depends on PCI
  21073. + help
  21074. + This is a driver for the National Semiconductor DP83820 series
  21075. + of gigabit ethernet MACs. Cards using this chipset include
  21076. + the D-Link DGE-500T, PureData's PDP8023Z-TG, SMC's SMC9462TX,
  21077. + SOHO-GA2000T, SOHO-GA2500T. The driver supports the use of
  21078. + zero copy.
  21079. +
  21080. +config HAMACHI
  21081. + tristate "Packet Engines Hamachi GNIC-II support"
  21082. + depends on PCI
  21083. + select MII
  21084. + help
  21085. + If you have a Gigabit Ethernet card of this type, say Y and read
  21086. + the Ethernet-HOWTO, available from
  21087. + <http://www.tldp.org/docs.html#howto>.
  21088. +
  21089. + To compile this driver as a module, choose M here. The module will be
  21090. + called hamachi.
  21091. +
  21092. +config YELLOWFIN
  21093. + tristate "Packet Engines Yellowfin Gigabit-NIC support (EXPERIMENTAL)"
  21094. + depends on PCI && EXPERIMENTAL
  21095. + select CRC32
  21096. + ---help---
  21097. + Say Y here if you have a Packet Engines G-NIC PCI Gigabit Ethernet
  21098. + adapter or the SYM53C885 Ethernet controller. The Gigabit adapter is
  21099. + used by the Beowulf Linux cluster project. See
  21100. + <http://cesdis.gsfc.nasa.gov/linux/drivers/yellowfin.html> for more
  21101. + information about this driver in particular and Beowulf in general.
  21102. +
  21103. + To compile this driver as a module, choose M here: the module
  21104. + will be called yellowfin. This is recommended.
  21105. +
  21106. +config R8169
  21107. + tristate "Realtek 8169 gigabit ethernet support"
  21108. + depends on PCI
  21109. + select CRC32
  21110. + select MII
  21111. + ---help---
  21112. + Say Y here if you have a Realtek 8169 PCI Gigabit Ethernet adapter.
  21113. +
  21114. + To compile this driver as a module, choose M here: the module
  21115. + will be called r8169. This is recommended.
  21116. +
  21117. +config R8169_VLAN
  21118. + bool "VLAN support"
  21119. + depends on R8169 && VLAN_8021Q
  21120. + ---help---
  21121. + Say Y here for the r8169 driver to support the functions required
  21122. + by the kernel 802.1Q code.
  21123. +
  21124. + If in doubt, say Y.
  21125. +
  21126. +config SB1250_MAC
  21127. + tristate "SB1250 Gigabit Ethernet support"
  21128. + depends on SIBYTE_SB1xxx_SOC
  21129. + select PHYLIB
  21130. + ---help---
  21131. + This driver supports Gigabit Ethernet interfaces based on the
  21132. + Broadcom SiByte family of System-On-a-Chip parts. They include
  21133. + the BCM1120, BCM1125, BCM1125H, BCM1250, BCM1255, BCM1280, BCM1455
  21134. + and BCM1480 chips.
  21135. +
  21136. + To compile this driver as a module, choose M here: the module
  21137. + will be called sb1250-mac.
  21138. +
  21139. +config SIS190
  21140. + tristate "SiS190/SiS191 gigabit ethernet support"
  21141. + depends on PCI
  21142. + select CRC32
  21143. + select MII
  21144. + ---help---
  21145. + Say Y here if you have a SiS 190 PCI Fast Ethernet adapter or
  21146. + a SiS 191 PCI Gigabit Ethernet adapter. Both are expected to
  21147. + appear in lan on motherboard designs which are based on SiS 965
  21148. + and SiS 966 south bridge.
  21149. +
  21150. + To compile this driver as a module, choose M here: the module
  21151. + will be called sis190. This is recommended.
  21152. +
  21153. +config SKGE
  21154. + tristate "New SysKonnect GigaEthernet support"
  21155. + depends on PCI
  21156. + select CRC32
  21157. + ---help---
  21158. + This driver support the Marvell Yukon or SysKonnect SK-98xx/SK-95xx
  21159. + and related Gigabit Ethernet adapters. It is a new smaller driver
  21160. + with better performance and more complete ethtool support.
  21161. +
  21162. + It does not support the link failover and network management
  21163. + features that "portable" vendor supplied sk98lin driver does.
  21164. +
  21165. + This driver supports adapters based on the original Yukon chipset:
  21166. + Marvell 88E8001, Belkin F5D5005, CNet GigaCard, DLink DGE-530T,
  21167. + Linksys EG1032/EG1064, 3Com 3C940/3C940B, SysKonnect SK-9871/9872.
  21168. +
  21169. + It does not support the newer Yukon2 chipset: a separate driver,
  21170. + sky2, is provided for Yukon2-based adapters.
  21171. +
  21172. + To compile this driver as a module, choose M here: the module
  21173. + will be called skge. This is recommended.
  21174. +
  21175. +config SKGE_DEBUG
  21176. + bool "Debugging interface"
  21177. + depends on SKGE && DEBUG_FS
  21178. + help
  21179. + This option adds the ability to dump driver state for debugging.
  21180. + The file /sys/kernel/debug/skge/ethX displays the state of the internal
  21181. + transmit and receive rings.
  21182. +
  21183. + If unsure, say N.
  21184. +
  21185. +config SKY2
  21186. + tristate "SysKonnect Yukon2 support"
  21187. + depends on PCI
  21188. + select CRC32
  21189. + ---help---
  21190. + This driver supports Gigabit Ethernet adapters based on the
  21191. + Marvell Yukon 2 chipset:
  21192. + Marvell 88E8021/88E8022/88E8035/88E8036/88E8038/88E8050/88E8052/
  21193. + 88E8053/88E8055/88E8061/88E8062, SysKonnect SK-9E21D/SK-9S21
  21194. +
  21195. + There is companion driver for the older Marvell Yukon and
  21196. + Genesis based adapters: skge.
  21197. +
  21198. + To compile this driver as a module, choose M here: the module
  21199. + will be called sky2. This is recommended.
  21200. +
  21201. +config SKY2_DEBUG
  21202. + bool "Debugging interface"
  21203. + depends on SKY2 && DEBUG_FS
  21204. + help
  21205. + This option adds the ability to dump driver state for debugging.
  21206. + The file /sys/kernel/debug/sky2/ethX displays the state of the internal
  21207. + transmit and receive rings.
  21208. +
  21209. + If unsure, say N.
  21210. +
  21211. +config VIA_VELOCITY
  21212. + tristate "VIA Velocity support"
  21213. + depends on PCI
  21214. + select CRC32
  21215. + select CRC_CCITT
  21216. + select MII
  21217. + help
  21218. + If you have a VIA "Velocity" based network card say Y here.
  21219. +
  21220. + To compile this driver as a module, choose M here. The module
  21221. + will be called via-velocity.
  21222. +
  21223. +config TIGON3
  21224. + tristate "Broadcom Tigon3 support"
  21225. + depends on PCI
  21226. + select PHYLIB
  21227. + help
  21228. + This driver supports Broadcom Tigon3 based gigabit Ethernet cards.
  21229. +
  21230. + To compile this driver as a module, choose M here: the module
  21231. + will be called tg3. This is recommended.
  21232. +
  21233. +config BNX2
  21234. + tristate "Broadcom NetXtremeII support"
  21235. + depends on PCI
  21236. + select CRC32
  21237. + select FW_LOADER
  21238. + help
  21239. + This driver supports Broadcom NetXtremeII gigabit Ethernet cards.
  21240. +
  21241. + To compile this driver as a module, choose M here: the module
  21242. + will be called bnx2. This is recommended.
  21243. +
  21244. +config CNIC
  21245. + tristate "Broadcom CNIC support"
  21246. + depends on PCI
  21247. + select BNX2
  21248. + select UIO
  21249. + help
  21250. + This driver supports offload features of Broadcom NetXtremeII
  21251. + gigabit Ethernet cards.
  21252. +
  21253. + To compile this driver as a module, choose M here: the module
  21254. + will be called cnic. This is recommended.
  21255. +
  21256. +config SPIDER_NET
  21257. + tristate "Spider Gigabit Ethernet driver"
  21258. + depends on PCI && (PPC_IBM_CELL_BLADE || PPC_CELLEB)
  21259. + select FW_LOADER
  21260. + help
  21261. + This driver supports the Gigabit Ethernet chips present on the
  21262. + Cell Processor-Based Blades from IBM.
  21263. +
  21264. +config TSI108_ETH
  21265. + tristate "Tundra TSI108 gigabit Ethernet support"
  21266. + depends on TSI108_BRIDGE
  21267. + help
  21268. + This driver supports Tundra TSI108 gigabit Ethernet ports.
  21269. + To compile this driver as a module, choose M here: the module
  21270. + will be called tsi108_eth.
  21271. +
  21272. +config GELIC_NET
  21273. + tristate "PS3 Gigabit Ethernet driver"
  21274. + depends on PPC_PS3
  21275. + select PS3_SYS_MANAGER
  21276. + help
  21277. + This driver supports the network device on the PS3 game
  21278. + console. This driver has built-in support for Ethernet.
  21279. +
  21280. + To compile this driver as a module, choose M here: the
  21281. + module will be called ps3_gelic.
  21282. +
  21283. +config GELIC_WIRELESS
  21284. + bool "PS3 Wireless support"
  21285. + depends on WLAN
  21286. + depends on GELIC_NET
  21287. + select WIRELESS_EXT
  21288. + help
  21289. + This option adds the support for the wireless feature of PS3.
  21290. + If you have the wireless-less model of PS3 or have no plan to
  21291. + use wireless feature, disabling this option saves memory. As
  21292. + the driver automatically distinguishes the models, you can
  21293. + safely enable this option even if you have a wireless-less model.
  21294. +
  21295. +config FSL_PQ_MDIO
  21296. + tristate "Freescale PQ MDIO"
  21297. + depends on FSL_SOC
  21298. + select PHYLIB
  21299. + help
  21300. + This driver supports the MDIO bus used by the gianfar and UCC drivers.
  21301. +
  21302. +config GIANFAR
  21303. + tristate "Gianfar Ethernet"
  21304. + depends on FSL_SOC
  21305. + select FSL_PQ_MDIO
  21306. + select PHYLIB
  21307. + select CRC32
  21308. + help
  21309. + This driver supports the Gigabit TSEC on the MPC83xx, MPC85xx,
  21310. + and MPC86xx family of chips, and the FEC on the 8540.
  21311. +
  21312. +config UCC_GETH
  21313. + tristate "Freescale QE Gigabit Ethernet"
  21314. + depends on QUICC_ENGINE
  21315. + select FSL_PQ_MDIO
  21316. + select PHYLIB
  21317. + help
  21318. + This driver supports the Gigabit Ethernet mode of the QUICC Engine,
  21319. + which is available on some Freescale SOCs.
  21320. +
  21321. +config UGETH_TX_ON_DEMAND
  21322. + bool "Transmit on Demand support"
  21323. + depends on UCC_GETH
  21324. +
  21325. +config MV643XX_ETH
  21326. + tristate "Marvell Discovery (643XX) and Orion ethernet support"
  21327. + depends on MV64X60 || PPC32 || PLAT_ORION
  21328. + select INET_LRO
  21329. + select PHYLIB
  21330. + help
  21331. + This driver supports the gigabit ethernet MACs in the
  21332. + Marvell Discovery PPC/MIPS chipset family (MV643XX) and
  21333. + in the Marvell Orion ARM SoC family.
  21334. +
  21335. + Some boards that use the Discovery chipset are the Momenco
  21336. + Ocelot C and Jaguar ATX and Pegasos II.
  21337. +
  21338. +config XILINX_LL_TEMAC
  21339. + tristate "Xilinx LL TEMAC (LocalLink Tri-mode Ethernet MAC) driver"
  21340. + depends on PPC || MICROBLAZE
  21341. + select PHYLIB
  21342. + help
  21343. + This driver supports the Xilinx 10/100/1000 LocalLink TEMAC
  21344. + core used in Xilinx Spartan and Virtex FPGAs
  21345. +
  21346. +config QLA3XXX
  21347. + tristate "QLogic QLA3XXX Network Driver Support"
  21348. + depends on PCI
  21349. + help
  21350. + This driver supports QLogic ISP3XXX gigabit Ethernet cards.
  21351. +
  21352. + To compile this driver as a module, choose M here: the module
  21353. + will be called qla3xxx.
  21354. +
  21355. +config ATL1
  21356. + tristate "Atheros/Attansic L1 Gigabit Ethernet support"
  21357. + depends on PCI
  21358. + select CRC32
  21359. + select MII
  21360. + help
  21361. + This driver supports the Atheros/Attansic L1 gigabit ethernet
  21362. + adapter.
  21363. +
  21364. + To compile this driver as a module, choose M here. The module
  21365. + will be called atl1.
  21366. +
  21367. +config ATL1E
  21368. + tristate "Atheros L1E Gigabit Ethernet support (EXPERIMENTAL)"
  21369. + depends on PCI && EXPERIMENTAL
  21370. + select CRC32
  21371. + select MII
  21372. + help
  21373. + This driver supports the Atheros L1E gigabit ethernet adapter.
  21374. +
  21375. + To compile this driver as a module, choose M here. The module
  21376. + will be called atl1e.
  21377. +
  21378. +config ATL1C
  21379. + tristate "Atheros L1C Gigabit Ethernet support (EXPERIMENTAL)"
  21380. + depends on PCI && EXPERIMENTAL
  21381. + select CRC32
  21382. + select MII
  21383. + help
  21384. + This driver supports the Atheros L1C gigabit ethernet adapter.
  21385. +
  21386. + To compile this driver as a module, choose M here. The module
  21387. + will be called atl1c.
  21388. +
  21389. +config JME
  21390. + tristate "JMicron(R) PCI-Express Gigabit Ethernet support"
  21391. + depends on PCI
  21392. + select CRC32
  21393. + select MII
  21394. + ---help---
  21395. + This driver supports the PCI-Express gigabit ethernet adapters
  21396. + based on JMicron JMC250 chipset.
  21397. +
  21398. + To compile this driver as a module, choose M here. The module
  21399. + will be called jme.
  21400. +
  21401. +config S6GMAC
  21402. + tristate "S6105 GMAC ethernet support"
  21403. + depends on XTENSA_VARIANT_S6000
  21404. + select PHYLIB
  21405. + help
  21406. + This driver supports the on chip ethernet device on the
  21407. + S6105 xtensa processor.
  21408. +
  21409. + To compile this driver as a module, choose M here. The module
  21410. + will be called s6gmac.
  21411. +
  21412. +source "drivers/net/stmmac/Kconfig"
  21413. +
  21414. +endif # NETDEV_1000
  21415. +
  21416. +#
  21417. +# 10 Gigabit Ethernet
  21418. +#
  21419. +
  21420. +menuconfig NETDEV_10000
  21421. + bool "Ethernet (10000 Mbit)"
  21422. + depends on !UML
  21423. + default y
  21424. + ---help---
  21425. + Say Y here to get to see options for 10 Gigabit Ethernet drivers.
  21426. + This option alone does not add any kernel code.
  21427. +
  21428. + If you say N, all options in this submenu will be skipped and disabled.
  21429. +
  21430. +if NETDEV_10000
  21431. +
  21432. +config MDIO
  21433. + tristate
  21434. +
  21435. +config CHELSIO_T1
  21436. + tristate "Chelsio 10Gb Ethernet support"
  21437. + depends on PCI
  21438. + select CRC32
  21439. + select MDIO
  21440. + help
  21441. + This driver supports Chelsio gigabit and 10-gigabit
  21442. + Ethernet cards. More information about adapter features and
  21443. + performance tuning is in <file:Documentation/networking/cxgb.txt>.
  21444. +
  21445. + For general information about Chelsio and our products, visit
  21446. + our website at <http://www.chelsio.com>.
  21447. +
  21448. + For customer support, please visit our customer support page at
  21449. + <http://www.chelsio.com/support.htm>.
  21450. +
  21451. + Please send feedback to <linux-bugs@chelsio.com>.
  21452. +
  21453. + To compile this driver as a module, choose M here: the module
  21454. + will be called cxgb.
  21455. +
  21456. +config CHELSIO_T1_1G
  21457. + bool "Chelsio gigabit Ethernet support"
  21458. + depends on CHELSIO_T1
  21459. + help
  21460. + Enables support for Chelsio's gigabit Ethernet PCI cards. If you
  21461. + are using only 10G cards say 'N' here.
  21462. +
  21463. +config CHELSIO_T3_DEPENDS
  21464. + tristate
  21465. + depends on PCI && INET
  21466. + default y
  21467. +
  21468. +config CHELSIO_T3
  21469. + tristate "Chelsio Communications T3 10Gb Ethernet support"
  21470. + depends on CHELSIO_T3_DEPENDS
  21471. + select FW_LOADER
  21472. + select MDIO
  21473. + help
  21474. + This driver supports Chelsio T3-based gigabit and 10Gb Ethernet
  21475. + adapters.
  21476. +
  21477. + For general information about Chelsio and our products, visit
  21478. + our website at <http://www.chelsio.com>.
  21479. +
  21480. + For customer support, please visit our customer support page at
  21481. + <http://www.chelsio.com/support.htm>.
  21482. +
  21483. + Please send feedback to <linux-bugs@chelsio.com>.
  21484. +
  21485. + To compile this driver as a module, choose M here: the module
  21486. + will be called cxgb3.
  21487. +
  21488. +config CHELSIO_T4_DEPENDS
  21489. + tristate
  21490. + depends on PCI && INET
  21491. + default y
  21492. +
  21493. +config CHELSIO_T4
  21494. + tristate "Chelsio Communications T4 Ethernet support"
  21495. + depends on CHELSIO_T4_DEPENDS
  21496. + select FW_LOADER
  21497. + select MDIO
  21498. + help
  21499. + This driver supports Chelsio T4-based gigabit and 10Gb Ethernet
  21500. + adapters.
  21501. +
  21502. + For general information about Chelsio and our products, visit
  21503. + our website at <http://www.chelsio.com>.
  21504. +
  21505. + For customer support, please visit our customer support page at
  21506. + <http://www.chelsio.com/support.htm>.
  21507. +
  21508. + Please send feedback to <linux-bugs@chelsio.com>.
  21509. +
  21510. + To compile this driver as a module choose M here; the module
  21511. + will be called cxgb4.
  21512. +
  21513. +config EHEA
  21514. + tristate "eHEA Ethernet support"
  21515. + depends on IBMEBUS && INET && SPARSEMEM
  21516. + select INET_LRO
  21517. + ---help---
  21518. + This driver supports the IBM pSeries eHEA ethernet adapter.
  21519. +
  21520. + To compile the driver as a module, choose M here. The module
  21521. + will be called ehea.
  21522. +
  21523. +config ENIC
  21524. + tristate "Cisco VIC Ethernet NIC Support"
  21525. + depends on PCI && INET
  21526. + select INET_LRO
  21527. + help
  21528. + This enables the support for the Cisco VIC Ethernet card.
  21529. +
  21530. +config IXGBE
  21531. + tristate "Intel(R) 10GbE PCI Express adapters support"
  21532. + depends on PCI && INET
  21533. + select MDIO
  21534. + ---help---
  21535. + This driver supports Intel(R) 10GbE PCI Express family of
  21536. + adapters. For more information on how to identify your adapter, go
  21537. + to the Adapter & Driver ID Guide at:
  21538. +
  21539. + <http://support.intel.com/support/network/adapter/pro100/21397.htm>
  21540. +
  21541. + For general information and support, go to the Intel support
  21542. + website at:
  21543. +
  21544. + <http://support.intel.com>
  21545. +
  21546. + To compile this driver as a module, choose M here. The module
  21547. + will be called ixgbe.
  21548. +
  21549. +config IXGBE_DCA
  21550. + bool "Direct Cache Access (DCA) Support"
  21551. + default y
  21552. + depends on IXGBE && DCA && !(IXGBE=y && DCA=m)
  21553. + ---help---
  21554. + Say Y here if you want to use Direct Cache Access (DCA) in the
  21555. + driver. DCA is a method for warming the CPU cache before data
  21556. + is used, with the intent of lessening the impact of cache misses.
  21557. +
  21558. +config IXGBE_DCB
  21559. + bool "Data Center Bridging (DCB) Support"
  21560. + default n
  21561. + depends on IXGBE && DCB
  21562. + ---help---
  21563. + Say Y here if you want to use Data Center Bridging (DCB) in the
  21564. + driver.
  21565. +
  21566. + If unsure, say N.
  21567. +
  21568. +config IXGBEVF
  21569. + tristate "Intel(R) 82599 Virtual Function Ethernet support"
  21570. + depends on PCI_MSI
  21571. + ---help---
  21572. + This driver supports Intel(R) 82599 virtual functions. For more
  21573. + information on how to identify your adapter, go to the Adapter &
  21574. + Driver ID Guide at:
  21575. +
  21576. + <http://support.intel.com/support/network/sb/CS-008441.htm>
  21577. +
  21578. + For general information and support, go to the Intel support
  21579. + website at:
  21580. +
  21581. + <http://support.intel.com>
  21582. +
  21583. + More specific information on configuring the driver is in
  21584. + <file:Documentation/networking/ixgbevf.txt>.
  21585. +
  21586. + To compile this driver as a module, choose M here. The module
  21587. + will be called ixgbevf. MSI-X interrupt support is required
  21588. + for this driver to work correctly.
  21589. +
  21590. +config IXGB
  21591. + tristate "Intel(R) PRO/10GbE support"
  21592. + depends on PCI
  21593. + ---help---
  21594. + This driver supports Intel(R) PRO/10GbE family of adapters for
  21595. + PCI-X type cards. For PCI-E type cards, use the "ixgbe" driver
  21596. + instead. For more information on how to identify your adapter, go
  21597. + to the Adapter & Driver ID Guide at:
  21598. +
  21599. + <http://support.intel.com/support/network/adapter/pro100/21397.htm>
  21600. +
  21601. + For general information and support, go to the Intel support
  21602. + website at:
  21603. +
  21604. + <http://support.intel.com>
  21605. +
  21606. + More specific information on configuring the driver is in
  21607. + <file:Documentation/networking/ixgb.txt>.
  21608. +
  21609. + To compile this driver as a module, choose M here. The module
  21610. + will be called ixgb.
  21611. +
  21612. +config S2IO
  21613. + tristate "S2IO 10Gbe XFrame NIC"
  21614. + depends on PCI
  21615. + ---help---
  21616. + This driver supports the 10Gbe XFrame NIC of S2IO.
  21617. + More specific information on configuring the driver is in
  21618. + <file:Documentation/networking/s2io.txt>.
  21619. +
  21620. +config VXGE
  21621. + tristate "Neterion X3100 Series 10GbE PCIe Server Adapter"
  21622. + depends on PCI && INET
  21623. + ---help---
  21624. + This driver supports Neterion Inc's X3100 Series 10 GbE PCIe
  21625. + I/O Virtualized Server Adapter.
  21626. + More specific information on configuring the driver is in
  21627. + <file:Documentation/networking/vxge.txt>.
  21628. +
  21629. +config VXGE_DEBUG_TRACE_ALL
  21630. + bool "Enabling All Debug trace statments in driver"
  21631. + default n
  21632. + depends on VXGE
  21633. + ---help---
  21634. + Say Y here if you want to enabling all the debug trace statements in
  21635. + driver. By default only few debug trace statements are enabled.
  21636. +
  21637. +config MYRI10GE
  21638. + tristate "Myricom Myri-10G Ethernet support"
  21639. + depends on PCI && INET
  21640. + select FW_LOADER
  21641. + select CRC32
  21642. + select INET_LRO
  21643. + ---help---
  21644. + This driver supports Myricom Myri-10G Dual Protocol interface in
  21645. + Ethernet mode. If the eeprom on your board is not recent enough,
  21646. + you will need a newer firmware image.
  21647. + You may get this image or more information, at:
  21648. +
  21649. + <http://www.myri.com/scs/download-Myri10GE.html>
  21650. +
  21651. + To compile this driver as a module, choose M here. The module
  21652. + will be called myri10ge.
  21653. +
  21654. +config MYRI10GE_DCA
  21655. + bool "Direct Cache Access (DCA) Support"
  21656. + default y
  21657. + depends on MYRI10GE && DCA && !(MYRI10GE=y && DCA=m)
  21658. + ---help---
  21659. + Say Y here if you want to use Direct Cache Access (DCA) in the
  21660. + driver. DCA is a method for warming the CPU cache before data
  21661. + is used, with the intent of lessening the impact of cache misses.
  21662. +
  21663. +config NETXEN_NIC
  21664. + tristate "NetXen Multi port (1/10) Gigabit Ethernet NIC"
  21665. + depends on PCI
  21666. + select FW_LOADER
  21667. + help
  21668. + This enables the support for NetXen's Gigabit Ethernet card.
  21669. +
  21670. +config NIU
  21671. + tristate "Sun Neptune 10Gbit Ethernet support"
  21672. + depends on PCI
  21673. + select CRC32
  21674. + help
  21675. + This enables support for cards based upon Sun's
  21676. + Neptune chipset.
  21677. +
  21678. +config PASEMI_MAC
  21679. + tristate "PA Semi 1/10Gbit MAC"
  21680. + depends on PPC_PASEMI && PCI
  21681. + select PHYLIB
  21682. + select INET_LRO
  21683. + help
  21684. + This driver supports the on-chip 1/10Gbit Ethernet controller on
  21685. + PA Semi's PWRficient line of chips.
  21686. +
  21687. +config MLX4_EN
  21688. + tristate "Mellanox Technologies 10Gbit Ethernet support"
  21689. + depends on PCI && INET
  21690. + select MLX4_CORE
  21691. + select INET_LRO
  21692. + help
  21693. + This driver supports Mellanox Technologies ConnectX Ethernet
  21694. + devices.
  21695. +
  21696. +config MLX4_CORE
  21697. + tristate
  21698. + depends on PCI
  21699. + default n
  21700. +
  21701. +config MLX4_DEBUG
  21702. + bool "Verbose debugging output" if (MLX4_CORE && EMBEDDED)
  21703. + depends on MLX4_CORE
  21704. + default y
  21705. + ---help---
  21706. + This option causes debugging code to be compiled into the
  21707. + mlx4_core driver. The output can be turned on via the
  21708. + debug_level module parameter (which can also be set after
  21709. + the driver is loaded through sysfs).
  21710. +
  21711. +config TEHUTI
  21712. + tristate "Tehuti Networks 10G Ethernet"
  21713. + depends on PCI
  21714. + help
  21715. + Tehuti Networks 10G Ethernet NIC
  21716. +
  21717. +config BNX2X
  21718. + tristate "Broadcom NetXtremeII 10Gb support"
  21719. + depends on PCI
  21720. + select FW_LOADER
  21721. + select ZLIB_INFLATE
  21722. + select LIBCRC32C
  21723. + select MDIO
  21724. + help
  21725. + This driver supports Broadcom NetXtremeII 10 gigabit Ethernet cards.
  21726. + To compile this driver as a module, choose M here: the module
  21727. + will be called bnx2x. This is recommended.
  21728. +
  21729. +config QLCNIC
  21730. + tristate "QLOGIC QLCNIC 1/10Gb Converged Ethernet NIC Support"
  21731. + depends on PCI
  21732. + select FW_LOADER
  21733. + help
  21734. + This driver supports QLogic QLE8240 and QLE8242 Converged Ethernet
  21735. + devices.
  21736. +
  21737. +config QLGE
  21738. + tristate "QLogic QLGE 10Gb Ethernet Driver Support"
  21739. + depends on PCI
  21740. + help
  21741. + This driver supports QLogic ISP8XXX 10Gb Ethernet cards.
  21742. +
  21743. + To compile this driver as a module, choose M here: the module
  21744. + will be called qlge.
  21745. +
  21746. +source "drivers/net/sfc/Kconfig"
  21747. +
  21748. +source "drivers/net/benet/Kconfig"
  21749. +
  21750. +endif # NETDEV_10000
  21751. +
  21752. +source "drivers/net/tokenring/Kconfig"
  21753. +
  21754. +source "drivers/net/wireless/Kconfig"
  21755. +
  21756. +source "drivers/net/wimax/Kconfig"
  21757. +
  21758. +source "drivers/net/usb/Kconfig"
  21759. +
  21760. +source "drivers/net/pcmcia/Kconfig"
  21761. +
  21762. +source "drivers/net/wan/Kconfig"
  21763. +
  21764. +source "drivers/atm/Kconfig"
  21765. +
  21766. +source "drivers/ieee802154/Kconfig"
  21767. +
  21768. +source "drivers/s390/net/Kconfig"
  21769. +
  21770. +source "drivers/net/caif/Kconfig"
  21771. +
  21772. +config XEN_NETDEV_FRONTEND
  21773. + tristate "Xen network device frontend driver"
  21774. + depends on XEN
  21775. + default y
  21776. + help
  21777. + The network device frontend driver allows the kernel to
  21778. + access network devices exported exported by a virtual
  21779. + machine containing a physical network device driver. The
  21780. + frontend driver is intended for unprivileged guest domains;
  21781. + if you are compiling a kernel for a Xen guest, you almost
  21782. + certainly want to enable this.
  21783. +
  21784. +config ISERIES_VETH
  21785. + tristate "iSeries Virtual Ethernet driver support"
  21786. + depends on PPC_ISERIES
  21787. +
  21788. +config RIONET
  21789. + tristate "RapidIO Ethernet over messaging driver support"
  21790. + depends on RAPIDIO
  21791. +
  21792. +config RIONET_TX_SIZE
  21793. + int "Number of outbound queue entries"
  21794. + depends on RIONET
  21795. + default "128"
  21796. +
  21797. +config RIONET_RX_SIZE
  21798. + int "Number of inbound queue entries"
  21799. + depends on RIONET
  21800. + default "128"
  21801. +
  21802. +config FDDI
  21803. + tristate "FDDI driver support"
  21804. + depends on (PCI || EISA || TC)
  21805. + help
  21806. + Fiber Distributed Data Interface is a high speed local area network
  21807. + design; essentially a replacement for high speed Ethernet. FDDI can
  21808. + run over copper or fiber. If you are connected to such a network and
  21809. + want a driver for the FDDI card in your computer, say Y here (and
  21810. + then also Y to the driver for your FDDI card, below). Most people
  21811. + will say N.
  21812. +
  21813. +config DEFXX
  21814. + tristate "Digital DEFTA/DEFEA/DEFPA adapter support"
  21815. + depends on FDDI && (PCI || EISA || TC)
  21816. + ---help---
  21817. + This is support for the DIGITAL series of TURBOchannel (DEFTA),
  21818. + EISA (DEFEA) and PCI (DEFPA) controllers which can connect you
  21819. + to a local FDDI network.
  21820. +
  21821. + To compile this driver as a module, choose M here: the module
  21822. + will be called defxx. If unsure, say N.
  21823. +
  21824. +config DEFXX_MMIO
  21825. + bool
  21826. + prompt "Use MMIO instead of PIO" if PCI || EISA
  21827. + depends on DEFXX
  21828. + default n if PCI || EISA
  21829. + default y
  21830. + ---help---
  21831. + This instructs the driver to use EISA or PCI memory-mapped I/O
  21832. + (MMIO) as appropriate instead of programmed I/O ports (PIO).
  21833. + Enabling this gives an improvement in processing time in parts
  21834. + of the driver, but it may cause problems with EISA (DEFEA)
  21835. + adapters. TURBOchannel does not have the concept of I/O ports,
  21836. + so MMIO is always used for these (DEFTA) adapters.
  21837. +
  21838. + If unsure, say N.
  21839. +
  21840. +config SKFP
  21841. + tristate "SysKonnect FDDI PCI support"
  21842. + depends on FDDI && PCI
  21843. + select BITREVERSE
  21844. + ---help---
  21845. + Say Y here if you have a SysKonnect FDDI PCI adapter.
  21846. + The following adapters are supported by this driver:
  21847. + - SK-5521 (SK-NET FDDI-UP)
  21848. + - SK-5522 (SK-NET FDDI-UP DAS)
  21849. + - SK-5541 (SK-NET FDDI-FP)
  21850. + - SK-5543 (SK-NET FDDI-LP)
  21851. + - SK-5544 (SK-NET FDDI-LP DAS)
  21852. + - SK-5821 (SK-NET FDDI-UP64)
  21853. + - SK-5822 (SK-NET FDDI-UP64 DAS)
  21854. + - SK-5841 (SK-NET FDDI-FP64)
  21855. + - SK-5843 (SK-NET FDDI-LP64)
  21856. + - SK-5844 (SK-NET FDDI-LP64 DAS)
  21857. + - Netelligent 100 FDDI DAS Fibre SC
  21858. + - Netelligent 100 FDDI SAS Fibre SC
  21859. + - Netelligent 100 FDDI DAS UTP
  21860. + - Netelligent 100 FDDI SAS UTP
  21861. + - Netelligent 100 FDDI SAS Fibre MIC
  21862. +
  21863. + Read <file:Documentation/networking/skfp.txt> for information about
  21864. + the driver.
  21865. +
  21866. + Questions concerning this driver can be addressed to:
  21867. + <linux@syskonnect.de>
  21868. +
  21869. + To compile this driver as a module, choose M here: the module
  21870. + will be called skfp. This is recommended.
  21871. +
  21872. +config HIPPI
  21873. + bool "HIPPI driver support (EXPERIMENTAL)"
  21874. + depends on EXPERIMENTAL && INET && PCI
  21875. + help
  21876. + HIgh Performance Parallel Interface (HIPPI) is a 800Mbit/sec and
  21877. + 1600Mbit/sec dual-simplex switched or point-to-point network. HIPPI
  21878. + can run over copper (25m) or fiber (300m on multi-mode or 10km on
  21879. + single-mode). HIPPI networks are commonly used for clusters and to
  21880. + connect to super computers. If you are connected to a HIPPI network
  21881. + and have a HIPPI network card in your computer that you want to use
  21882. + under Linux, say Y here (you must also remember to enable the driver
  21883. + for your HIPPI card below). Most people will say N here.
  21884. +
  21885. +config ROADRUNNER
  21886. + tristate "Essential RoadRunner HIPPI PCI adapter support (EXPERIMENTAL)"
  21887. + depends on HIPPI && PCI
  21888. + help
  21889. + Say Y here if this is your PCI HIPPI network card.
  21890. +
  21891. + To compile this driver as a module, choose M here: the module
  21892. + will be called rrunner. If unsure, say N.
  21893. +
  21894. +config ROADRUNNER_LARGE_RINGS
  21895. + bool "Use large TX/RX rings (EXPERIMENTAL)"
  21896. + depends on ROADRUNNER
  21897. + help
  21898. + If you say Y here, the RoadRunner driver will preallocate up to 2 MB
  21899. + of additional memory to allow for fastest operation, both for
  21900. + transmitting and receiving. This memory cannot be used by any other
  21901. + kernel code or by user space programs. Say Y here only if you have
  21902. + the memory.
  21903. +
  21904. +config PLIP
  21905. + tristate "PLIP (parallel port) support"
  21906. + depends on PARPORT
  21907. + ---help---
  21908. + PLIP (Parallel Line Internet Protocol) is used to create a
  21909. + reasonably fast mini network consisting of two (or, rarely, more)
  21910. + local machines. A PLIP link from a Linux box is a popular means to
  21911. + install a Linux distribution on a machine which doesn't have a
  21912. + CD-ROM drive (a minimal system has to be transferred with floppies
  21913. + first). The kernels on both machines need to have this PLIP option
  21914. + enabled for this to work.
  21915. +
  21916. + The PLIP driver has two modes, mode 0 and mode 1. The parallel
  21917. + ports (the connectors at the computers with 25 holes) are connected
  21918. + with "null printer" or "Turbo Laplink" cables which can transmit 4
  21919. + bits at a time (mode 0) or with special PLIP cables, to be used on
  21920. + bidirectional parallel ports only, which can transmit 8 bits at a
  21921. + time (mode 1); you can find the wiring of these cables in
  21922. + <file:Documentation/networking/PLIP.txt>. The cables can be up to
  21923. + 15m long. Mode 0 works also if one of the machines runs DOS/Windows
  21924. + and has some PLIP software installed, e.g. the Crynwr PLIP packet
  21925. + driver (<http://oak.oakland.edu/simtel.net/msdos/pktdrvr-pre.html>)
  21926. + and winsock or NCSA's telnet.
  21927. +
  21928. + If you want to use PLIP, say Y and read the PLIP mini-HOWTO as well
  21929. + as the NET-3-HOWTO, both available from
  21930. + <http://www.tldp.org/docs.html#howto>. Note that the PLIP
  21931. + protocol has been changed and this PLIP driver won't work together
  21932. + with the PLIP support in Linux versions 1.0.x. This option enlarges
  21933. + your kernel by about 8 KB.
  21934. +
  21935. + To compile this driver as a module, choose M here. The module
  21936. + will be called plip. If unsure, say Y or M, in case you buy
  21937. + a laptop later.
  21938. +
  21939. +config PPP
  21940. + tristate "PPP (point-to-point protocol) support"
  21941. + select SLHC
  21942. + ---help---
  21943. + PPP (Point to Point Protocol) is a newer and better SLIP. It serves
  21944. + the same purpose: sending Internet traffic over telephone (and other
  21945. + serial) lines. Ask your access provider if they support it, because
  21946. + otherwise you can't use it; most Internet access providers these
  21947. + days support PPP rather than SLIP.
  21948. +
  21949. + To use PPP, you need an additional program called pppd as described
  21950. + in the PPP-HOWTO, available at
  21951. + <http://www.tldp.org/docs.html#howto>. Make sure that you have
  21952. + the version of pppd recommended in <file:Documentation/Changes>.
  21953. + The PPP option enlarges your kernel by about 16 KB.
  21954. +
  21955. + There are actually two versions of PPP: the traditional PPP for
  21956. + asynchronous lines, such as regular analog phone lines, and
  21957. + synchronous PPP which can be used over digital ISDN lines for
  21958. + example. If you want to use PPP over phone lines or other
  21959. + asynchronous serial lines, you need to say Y (or M) here and also to
  21960. + the next option, "PPP support for async serial ports". For PPP over
  21961. + synchronous lines, you should say Y (or M) here and to "Support
  21962. + synchronous PPP", below.
  21963. +
  21964. + If you said Y to "Version information on all symbols" above, then
  21965. + you cannot compile the PPP driver into the kernel; you can then only
  21966. + compile it as a module. To compile this driver as a module, choose M
  21967. + here. The module will be called ppp_generic.
  21968. +
  21969. +config PPP_MULTILINK
  21970. + bool "PPP multilink support (EXPERIMENTAL)"
  21971. + depends on PPP && EXPERIMENTAL
  21972. + help
  21973. + PPP multilink is a protocol (defined in RFC 1990) which allows you
  21974. + to combine several (logical or physical) lines into one logical PPP
  21975. + connection, so that you can utilize your full bandwidth.
  21976. +
  21977. + This has to be supported at the other end as well and you need a
  21978. + version of the pppd daemon which understands the multilink protocol.
  21979. +
  21980. + If unsure, say N.
  21981. +
  21982. +config PPP_FILTER
  21983. + bool "PPP filtering"
  21984. + depends on PPP
  21985. + help
  21986. + Say Y here if you want to be able to filter the packets passing over
  21987. + PPP interfaces. This allows you to control which packets count as
  21988. + activity (i.e. which packets will reset the idle timer or bring up
  21989. + a demand-dialed link) and which packets are to be dropped entirely.
  21990. + You need to say Y here if you wish to use the pass-filter and
  21991. + active-filter options to pppd.
  21992. +
  21993. + If unsure, say N.
  21994. +
  21995. +config PPP_ASYNC
  21996. + tristate "PPP support for async serial ports"
  21997. + depends on PPP
  21998. + select CRC_CCITT
  21999. + ---help---
  22000. + Say Y (or M) here if you want to be able to use PPP over standard
  22001. + asynchronous serial ports, such as COM1 or COM2 on a PC. If you use
  22002. + a modem (not a synchronous or ISDN modem) to contact your ISP, you
  22003. + need this option.
  22004. +
  22005. + To compile this driver as a module, choose M here.
  22006. +
  22007. + If unsure, say Y.
  22008. +
  22009. +config PPP_SYNC_TTY
  22010. + tristate "PPP support for sync tty ports"
  22011. + depends on PPP
  22012. + help
  22013. + Say Y (or M) here if you want to be able to use PPP over synchronous
  22014. + (HDLC) tty devices, such as the SyncLink adapter. These devices
  22015. + are often used for high-speed leased lines like T1/E1.
  22016. +
  22017. + To compile this driver as a module, choose M here.
  22018. +
  22019. +config PPP_DEFLATE
  22020. + tristate "PPP Deflate compression"
  22021. + depends on PPP
  22022. + select ZLIB_INFLATE
  22023. + select ZLIB_DEFLATE
  22024. + ---help---
  22025. + Support for the Deflate compression method for PPP, which uses the
  22026. + Deflate algorithm (the same algorithm that gzip uses) to compress
  22027. + each PPP packet before it is sent over the wire. The machine at the
  22028. + other end of the PPP link (usually your ISP) has to support the
  22029. + Deflate compression method as well for this to be useful. Even if
  22030. + they don't support it, it is safe to say Y here.
  22031. +
  22032. + To compile this driver as a module, choose M here.
  22033. +
  22034. +config PPP_BSDCOMP
  22035. + tristate "PPP BSD-Compress compression"
  22036. + depends on PPP
  22037. + ---help---
  22038. + Support for the BSD-Compress compression method for PPP, which uses
  22039. + the LZW compression method to compress each PPP packet before it is
  22040. + sent over the wire. The machine at the other end of the PPP link
  22041. + (usually your ISP) has to support the BSD-Compress compression
  22042. + method as well for this to be useful. Even if they don't support it,
  22043. + it is safe to say Y here.
  22044. +
  22045. + The PPP Deflate compression method ("PPP Deflate compression",
  22046. + above) is preferable to BSD-Compress, because it compresses better
  22047. + and is patent-free.
  22048. +
  22049. + Note that the BSD compression code will always be compiled as a
  22050. + module; it is called bsd_comp and will show up in the directory
  22051. + modules once you have said "make modules". If unsure, say N.
  22052. +
  22053. +config PPP_MPPE
  22054. + tristate "PPP MPPE compression (encryption) (EXPERIMENTAL)"
  22055. + depends on PPP && EXPERIMENTAL
  22056. + select CRYPTO
  22057. + select CRYPTO_SHA1
  22058. + select CRYPTO_ARC4
  22059. + select CRYPTO_ECB
  22060. + ---help---
  22061. + Support for the MPPE Encryption protocol, as employed by the
  22062. + Microsoft Point-to-Point Tunneling Protocol.
  22063. +
  22064. + See http://pptpclient.sourceforge.net/ for information on
  22065. + configuring PPTP clients and servers to utilize this method.
  22066. +
  22067. +config PPPOE
  22068. + tristate "PPP over Ethernet (EXPERIMENTAL)"
  22069. + depends on EXPERIMENTAL && PPP
  22070. + help
  22071. + Support for PPP over Ethernet.
  22072. +
  22073. + This driver requires the latest version of pppd from the CVS
  22074. + repository at cvs.samba.org. Alternatively, see the
  22075. + RoaringPenguin package (<http://www.roaringpenguin.com/pppoe>)
  22076. + which contains instruction on how to use this driver (under
  22077. + the heading "Kernel mode PPPoE").
  22078. +
  22079. +config PPPOATM
  22080. + tristate "PPP over ATM"
  22081. + depends on ATM && PPP
  22082. + help
  22083. + Support PPP (Point to Point Protocol) encapsulated in ATM frames.
  22084. + This implementation does not yet comply with section 8 of RFC2364,
  22085. + which can lead to bad results if the ATM peer loses state and
  22086. + changes its encapsulation unilaterally.
  22087. +
  22088. +config PPPOL2TP
  22089. + tristate "PPP over L2TP (EXPERIMENTAL)"
  22090. + depends on EXPERIMENTAL && L2TP && PPP
  22091. + help
  22092. + Support for PPP-over-L2TP socket family. L2TP is a protocol
  22093. + used by ISPs and enterprises to tunnel PPP traffic over UDP
  22094. + tunnels. L2TP is replacing PPTP for VPN uses.
  22095. +
  22096. +config SLIP
  22097. + tristate "SLIP (serial line) support"
  22098. + ---help---
  22099. + Say Y if you intend to use SLIP or CSLIP (compressed SLIP) to
  22100. + connect to your Internet service provider or to connect to some
  22101. + other local Unix box or if you want to configure your Linux box as a
  22102. + Slip/CSlip server for other people to dial in. SLIP (Serial Line
  22103. + Internet Protocol) is a protocol used to send Internet traffic over
  22104. + serial connections such as telephone lines or null modem cables;
  22105. + nowadays, the protocol PPP is more commonly used for this same
  22106. + purpose.
  22107. +
  22108. + Normally, your access provider has to support SLIP in order for you
  22109. + to be able to use it, but there is now a SLIP emulator called SLiRP
  22110. + around (available from
  22111. + <ftp://ibiblio.org/pub/Linux/system/network/serial/>) which
  22112. + allows you to use SLIP over a regular dial up shell connection. If
  22113. + you plan to use SLiRP, make sure to say Y to CSLIP, below. The
  22114. + NET-3-HOWTO, available from
  22115. + <http://www.tldp.org/docs.html#howto>, explains how to
  22116. + configure SLIP. Note that you don't need this option if you just
  22117. + want to run term (term is a program which gives you almost full
  22118. + Internet connectivity if you have a regular dial up shell account on
  22119. + some Internet connected Unix computer. Read
  22120. + <http://www.bart.nl/~patrickr/term-howto/Term-HOWTO.html>). SLIP
  22121. + support will enlarge your kernel by about 4 KB. If unsure, say N.
  22122. +
  22123. + To compile this driver as a module, choose M here. The module
  22124. + will be called slip.
  22125. +
  22126. +config SLIP_COMPRESSED
  22127. + bool "CSLIP compressed headers"
  22128. + depends on SLIP
  22129. + select SLHC
  22130. + ---help---
  22131. + This protocol is faster than SLIP because it uses compression on the
  22132. + TCP/IP headers (not on the data itself), but it has to be supported
  22133. + on both ends. Ask your access provider if you are not sure and
  22134. + answer Y, just in case. You will still be able to use plain SLIP. If
  22135. + you plan to use SLiRP, the SLIP emulator (available from
  22136. + <ftp://ibiblio.org/pub/Linux/system/network/serial/>) which
  22137. + allows you to use SLIP over a regular dial up shell connection, you
  22138. + definitely want to say Y here. The NET-3-HOWTO, available from
  22139. + <http://www.tldp.org/docs.html#howto>, explains how to configure
  22140. + CSLIP. This won't enlarge your kernel.
  22141. +
  22142. +config SLHC
  22143. + tristate
  22144. + help
  22145. + This option enables Van Jacobsen serial line header compression
  22146. + routines.
  22147. +
  22148. +config SLIP_SMART
  22149. + bool "Keepalive and linefill"
  22150. + depends on SLIP
  22151. + help
  22152. + Adds additional capabilities to the SLIP driver to support the
  22153. + RELCOM line fill and keepalive monitoring. Ideal on poor quality
  22154. + analogue lines.
  22155. +
  22156. +config SLIP_MODE_SLIP6
  22157. + bool "Six bit SLIP encapsulation"
  22158. + depends on SLIP
  22159. + help
  22160. + Just occasionally you may need to run IP over hostile serial
  22161. + networks that don't pass all control characters or are only seven
  22162. + bit. Saying Y here adds an extra mode you can use with SLIP:
  22163. + "slip6". In this mode, SLIP will only send normal ASCII symbols over
  22164. + the serial device. Naturally, this has to be supported at the other
  22165. + end of the link as well. It's good enough, for example, to run IP
  22166. + over the async ports of a Camtec JNT Pad. If unsure, say N.
  22167. +
  22168. +config NET_FC
  22169. + bool "Fibre Channel driver support"
  22170. + depends on SCSI && PCI
  22171. + help
  22172. + Fibre Channel is a high speed serial protocol mainly used to connect
  22173. + large storage devices to the computer; it is compatible with and
  22174. + intended to replace SCSI.
  22175. +
  22176. + If you intend to use Fibre Channel, you need to have a Fibre channel
  22177. + adaptor card in your computer; say Y here and to the driver for your
  22178. + adaptor below. You also should have said Y to "SCSI support" and
  22179. + "SCSI generic support".
  22180. +
  22181. +config NETCONSOLE
  22182. + tristate "Network console logging support"
  22183. + ---help---
  22184. + If you want to log kernel messages over the network, enable this.
  22185. + See <file:Documentation/networking/netconsole.txt> for details.
  22186. +
  22187. +config NETCONSOLE_DYNAMIC
  22188. + bool "Dynamic reconfiguration of logging targets"
  22189. + depends on NETCONSOLE && SYSFS
  22190. + select CONFIGFS_FS
  22191. + help
  22192. + This option enables the ability to dynamically reconfigure target
  22193. + parameters (interface, IP addresses, port numbers, MAC addresses)
  22194. + at runtime through a userspace interface exported using configfs.
  22195. + See <file:Documentation/networking/netconsole.txt> for details.
  22196. +
  22197. +config NETPOLL
  22198. + def_bool NETCONSOLE
  22199. +
  22200. +config NETPOLL_TRAP
  22201. + bool "Netpoll traffic trapping"
  22202. + default n
  22203. + depends on NETPOLL
  22204. +
  22205. +config NET_POLL_CONTROLLER
  22206. + def_bool NETPOLL
  22207. +
  22208. +config VIRTIO_NET
  22209. + tristate "Virtio network driver (EXPERIMENTAL)"
  22210. + depends on EXPERIMENTAL && VIRTIO
  22211. + ---help---
  22212. + This is the virtual network driver for virtio. It can be used with
  22213. + lguest or QEMU based VMMs (like KVM or Xen). Say Y or M.
  22214. +
  22215. +config VMXNET3
  22216. + tristate "VMware VMXNET3 ethernet driver"
  22217. + depends on PCI && INET
  22218. + help
  22219. + This driver supports VMware's vmxnet3 virtual ethernet NIC.
  22220. + To compile this driver as a module, choose M here: the
  22221. + module will be called vmxnet3.
  22222. +
  22223. +endif # NETDEVICES
  22224. diff -Nur linux-2.6.35.7.orig/drivers/net/Makefile linux-2.6.35.7/drivers/net/Makefile
  22225. --- linux-2.6.35.7.orig/drivers/net/Makefile 2010-09-29 03:09:08.000000000 +0200
  22226. +++ linux-2.6.35.7/drivers/net/Makefile 2010-10-14 20:28:00.878101155 +0200
  22227. @@ -109,6 +109,7 @@
  22228. # end link order section
  22229. #
  22230. +obj-$(CONFIG_AG71XX) += ag71xx/
  22231. obj-$(CONFIG_SUNDANCE) += sundance.o
  22232. obj-$(CONFIG_HAMACHI) += hamachi.o
  22233. obj-$(CONFIG_NET) += Space.o loopback.o
  22234. diff -Nur linux-2.6.35.7.orig/drivers/net/phy/Kconfig linux-2.6.35.7/drivers/net/phy/Kconfig
  22235. --- linux-2.6.35.7.orig/drivers/net/phy/Kconfig 2010-09-29 03:09:08.000000000 +0200
  22236. +++ linux-2.6.35.7/drivers/net/phy/Kconfig 2010-10-14 20:28:00.918101155 +0200
  22237. @@ -93,6 +93,10 @@
  22238. ---help---
  22239. Supports the KSZ9021, VSC8201, KS8001 PHYs.
  22240. +config IP175C_PHY
  22241. + tristate "Driver for IC+ IP175C/IP178C switches"
  22242. + select SWCONFIG
  22243. +
  22244. config FIXED_PHY
  22245. bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs"
  22246. depends on PHYLIB=y
  22247. diff -Nur linux-2.6.35.7.orig/drivers/net/phy/phy.c linux-2.6.35.7/drivers/net/phy/phy.c
  22248. --- linux-2.6.35.7.orig/drivers/net/phy/phy.c 2010-09-29 03:09:08.000000000 +0200
  22249. +++ linux-2.6.35.7/drivers/net/phy/phy.c 2010-10-14 20:28:00.948101153 +0200
  22250. @@ -298,6 +298,50 @@
  22251. }
  22252. EXPORT_SYMBOL(phy_ethtool_gset);
  22253. +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr)
  22254. +{
  22255. + u32 cmd;
  22256. + int tmp;
  22257. + struct ethtool_cmd ecmd = { ETHTOOL_GSET };
  22258. + struct ethtool_value edata = { ETHTOOL_GLINK };
  22259. +
  22260. + if (get_user(cmd, (u32 *) useraddr))
  22261. + return -EFAULT;
  22262. +
  22263. + switch (cmd) {
  22264. + case ETHTOOL_GSET:
  22265. + phy_ethtool_gset(phydev, &ecmd);
  22266. + if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
  22267. + return -EFAULT;
  22268. + return 0;
  22269. +
  22270. + case ETHTOOL_SSET:
  22271. + if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
  22272. + return -EFAULT;
  22273. + return phy_ethtool_sset(phydev, &ecmd);
  22274. +
  22275. + case ETHTOOL_NWAY_RST:
  22276. + /* if autoneg is off, it's an error */
  22277. + tmp = phy_read(phydev, MII_BMCR);
  22278. + if (tmp & BMCR_ANENABLE) {
  22279. + tmp |= (BMCR_ANRESTART);
  22280. + phy_write(phydev, MII_BMCR, tmp);
  22281. + return 0;
  22282. + }
  22283. + return -EINVAL;
  22284. +
  22285. + case ETHTOOL_GLINK:
  22286. + edata.data = (phy_read(phydev,
  22287. + MII_BMSR) & BMSR_LSTATUS) ? 1 : 0;
  22288. + if (copy_to_user(useraddr, &edata, sizeof(edata)))
  22289. + return -EFAULT;
  22290. + return 0;
  22291. + }
  22292. +
  22293. + return -EOPNOTSUPP;
  22294. +}
  22295. +EXPORT_SYMBOL(phy_ethtool_ioctl);
  22296. +
  22297. /**
  22298. * phy_mii_ioctl - generic PHY MII ioctl interface
  22299. * @phydev: the phy_device struct
  22300. @@ -351,7 +395,7 @@
  22301. }
  22302. phy_write(phydev, mii_data->reg_num, val);
  22303. -
  22304. +
  22305. if (mii_data->reg_num == MII_BMCR &&
  22306. val & BMCR_RESET &&
  22307. phydev->drv->config_init) {
  22308. @@ -465,7 +509,7 @@
  22309. int idx;
  22310. idx = phy_find_setting(phydev->speed, phydev->duplex);
  22311. -
  22312. +
  22313. idx++;
  22314. idx = phy_find_valid(idx, phydev->supported);
  22315. diff -Nur linux-2.6.35.7.orig/drivers/net/phy/phy_device.c linux-2.6.35.7/drivers/net/phy/phy_device.c
  22316. --- linux-2.6.35.7.orig/drivers/net/phy/phy_device.c 2010-09-29 03:09:08.000000000 +0200
  22317. +++ linux-2.6.35.7/drivers/net/phy/phy_device.c 2010-10-14 20:28:01.005039092 +0200
  22318. @@ -146,6 +146,18 @@
  22319. }
  22320. EXPORT_SYMBOL(phy_scan_fixups);
  22321. +static int generic_receive_skb(struct sk_buff *skb)
  22322. +{
  22323. + skb->protocol = eth_type_trans(skb, skb->dev);
  22324. + return netif_receive_skb(skb);
  22325. +}
  22326. +
  22327. +static int generic_rx(struct sk_buff *skb)
  22328. +{
  22329. + skb->protocol = eth_type_trans(skb, skb->dev);
  22330. + return netif_rx(skb);
  22331. +}
  22332. +
  22333. struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
  22334. {
  22335. struct phy_device *dev;
  22336. @@ -176,6 +188,8 @@
  22337. dev_set_name(&dev->dev, PHY_ID_FMT, bus->id, addr);
  22338. dev->state = PHY_DOWN;
  22339. + dev->netif_receive_skb = &generic_receive_skb;
  22340. + dev->netif_rx = &generic_rx;
  22341. mutex_init(&dev->lock);
  22342. INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine);
  22343. diff -Nur linux-2.6.35.7.orig/drivers/net/phy/phy_device.c.orig linux-2.6.35.7/drivers/net/phy/phy_device.c.orig
  22344. --- linux-2.6.35.7.orig/drivers/net/phy/phy_device.c.orig 1970-01-01 01:00:00.000000000 +0100
  22345. +++ linux-2.6.35.7/drivers/net/phy/phy_device.c.orig 2010-09-29 03:09:08.000000000 +0200
  22346. @@ -0,0 +1,1041 @@
  22347. +/*
  22348. + * drivers/net/phy/phy_device.c
  22349. + *
  22350. + * Framework for finding and configuring PHYs.
  22351. + * Also contains generic PHY driver
  22352. + *
  22353. + * Author: Andy Fleming
  22354. + *
  22355. + * Copyright (c) 2004 Freescale Semiconductor, Inc.
  22356. + *
  22357. + * This program is free software; you can redistribute it and/or modify it
  22358. + * under the terms of the GNU General Public License as published by the
  22359. + * Free Software Foundation; either version 2 of the License, or (at your
  22360. + * option) any later version.
  22361. + *
  22362. + */
  22363. +#include <linux/kernel.h>
  22364. +#include <linux/string.h>
  22365. +#include <linux/errno.h>
  22366. +#include <linux/unistd.h>
  22367. +#include <linux/slab.h>
  22368. +#include <linux/interrupt.h>
  22369. +#include <linux/init.h>
  22370. +#include <linux/delay.h>
  22371. +#include <linux/netdevice.h>
  22372. +#include <linux/etherdevice.h>
  22373. +#include <linux/skbuff.h>
  22374. +#include <linux/mm.h>
  22375. +#include <linux/module.h>
  22376. +#include <linux/mii.h>
  22377. +#include <linux/ethtool.h>
  22378. +#include <linux/phy.h>
  22379. +
  22380. +#include <asm/io.h>
  22381. +#include <asm/irq.h>
  22382. +#include <asm/uaccess.h>
  22383. +
  22384. +MODULE_DESCRIPTION("PHY library");
  22385. +MODULE_AUTHOR("Andy Fleming");
  22386. +MODULE_LICENSE("GPL");
  22387. +
  22388. +void phy_device_free(struct phy_device *phydev)
  22389. +{
  22390. + kfree(phydev);
  22391. +}
  22392. +EXPORT_SYMBOL(phy_device_free);
  22393. +
  22394. +static void phy_device_release(struct device *dev)
  22395. +{
  22396. + phy_device_free(to_phy_device(dev));
  22397. +}
  22398. +
  22399. +static struct phy_driver genphy_driver;
  22400. +extern int mdio_bus_init(void);
  22401. +extern void mdio_bus_exit(void);
  22402. +
  22403. +static LIST_HEAD(phy_fixup_list);
  22404. +static DEFINE_MUTEX(phy_fixup_lock);
  22405. +
  22406. +/*
  22407. + * Creates a new phy_fixup and adds it to the list
  22408. + * @bus_id: A string which matches phydev->dev.bus_id (or PHY_ANY_ID)
  22409. + * @phy_uid: Used to match against phydev->phy_id (the UID of the PHY)
  22410. + * It can also be PHY_ANY_UID
  22411. + * @phy_uid_mask: Applied to phydev->phy_id and fixup->phy_uid before
  22412. + * comparison
  22413. + * @run: The actual code to be run when a matching PHY is found
  22414. + */
  22415. +int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
  22416. + int (*run)(struct phy_device *))
  22417. +{
  22418. + struct phy_fixup *fixup;
  22419. +
  22420. + fixup = kzalloc(sizeof(struct phy_fixup), GFP_KERNEL);
  22421. + if (!fixup)
  22422. + return -ENOMEM;
  22423. +
  22424. + strlcpy(fixup->bus_id, bus_id, sizeof(fixup->bus_id));
  22425. + fixup->phy_uid = phy_uid;
  22426. + fixup->phy_uid_mask = phy_uid_mask;
  22427. + fixup->run = run;
  22428. +
  22429. + mutex_lock(&phy_fixup_lock);
  22430. + list_add_tail(&fixup->list, &phy_fixup_list);
  22431. + mutex_unlock(&phy_fixup_lock);
  22432. +
  22433. + return 0;
  22434. +}
  22435. +EXPORT_SYMBOL(phy_register_fixup);
  22436. +
  22437. +/* Registers a fixup to be run on any PHY with the UID in phy_uid */
  22438. +int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
  22439. + int (*run)(struct phy_device *))
  22440. +{
  22441. + return phy_register_fixup(PHY_ANY_ID, phy_uid, phy_uid_mask, run);
  22442. +}
  22443. +EXPORT_SYMBOL(phy_register_fixup_for_uid);
  22444. +
  22445. +/* Registers a fixup to be run on the PHY with id string bus_id */
  22446. +int phy_register_fixup_for_id(const char *bus_id,
  22447. + int (*run)(struct phy_device *))
  22448. +{
  22449. + return phy_register_fixup(bus_id, PHY_ANY_UID, 0xffffffff, run);
  22450. +}
  22451. +EXPORT_SYMBOL(phy_register_fixup_for_id);
  22452. +
  22453. +/*
  22454. + * Returns 1 if fixup matches phydev in bus_id and phy_uid.
  22455. + * Fixups can be set to match any in one or more fields.
  22456. + */
  22457. +static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup)
  22458. +{
  22459. + if (strcmp(fixup->bus_id, dev_name(&phydev->dev)) != 0)
  22460. + if (strcmp(fixup->bus_id, PHY_ANY_ID) != 0)
  22461. + return 0;
  22462. +
  22463. + if ((fixup->phy_uid & fixup->phy_uid_mask) !=
  22464. + (phydev->phy_id & fixup->phy_uid_mask))
  22465. + if (fixup->phy_uid != PHY_ANY_UID)
  22466. + return 0;
  22467. +
  22468. + return 1;
  22469. +}
  22470. +
  22471. +/* Runs any matching fixups for this phydev */
  22472. +int phy_scan_fixups(struct phy_device *phydev)
  22473. +{
  22474. + struct phy_fixup *fixup;
  22475. +
  22476. + mutex_lock(&phy_fixup_lock);
  22477. + list_for_each_entry(fixup, &phy_fixup_list, list) {
  22478. + if (phy_needs_fixup(phydev, fixup)) {
  22479. + int err;
  22480. +
  22481. + err = fixup->run(phydev);
  22482. +
  22483. + if (err < 0) {
  22484. + mutex_unlock(&phy_fixup_lock);
  22485. + return err;
  22486. + }
  22487. + }
  22488. + }
  22489. + mutex_unlock(&phy_fixup_lock);
  22490. +
  22491. + return 0;
  22492. +}
  22493. +EXPORT_SYMBOL(phy_scan_fixups);
  22494. +
  22495. +struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
  22496. +{
  22497. + struct phy_device *dev;
  22498. +
  22499. + /* We allocate the device, and initialize the
  22500. + * default values */
  22501. + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
  22502. +
  22503. + if (NULL == dev)
  22504. + return (struct phy_device*) PTR_ERR((void*)-ENOMEM);
  22505. +
  22506. + dev->dev.release = phy_device_release;
  22507. +
  22508. + dev->speed = 0;
  22509. + dev->duplex = -1;
  22510. + dev->pause = dev->asym_pause = 0;
  22511. + dev->link = 1;
  22512. + dev->interface = PHY_INTERFACE_MODE_GMII;
  22513. +
  22514. + dev->autoneg = AUTONEG_ENABLE;
  22515. +
  22516. + dev->addr = addr;
  22517. + dev->phy_id = phy_id;
  22518. + dev->bus = bus;
  22519. + dev->dev.parent = bus->parent;
  22520. + dev->dev.bus = &mdio_bus_type;
  22521. + dev->irq = bus->irq != NULL ? bus->irq[addr] : PHY_POLL;
  22522. + dev_set_name(&dev->dev, PHY_ID_FMT, bus->id, addr);
  22523. +
  22524. + dev->state = PHY_DOWN;
  22525. +
  22526. + mutex_init(&dev->lock);
  22527. + INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine);
  22528. +
  22529. + /* Request the appropriate module unconditionally; don't
  22530. + bother trying to do so only if it isn't already loaded,
  22531. + because that gets complicated. A hotplug event would have
  22532. + done an unconditional modprobe anyway.
  22533. + We don't do normal hotplug because it won't work for MDIO
  22534. + -- because it relies on the device staying around for long
  22535. + enough for the driver to get loaded. With MDIO, the NIC
  22536. + driver will get bored and give up as soon as it finds that
  22537. + there's no driver _already_ loaded. */
  22538. + request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT, MDIO_ID_ARGS(phy_id));
  22539. +
  22540. + return dev;
  22541. +}
  22542. +EXPORT_SYMBOL(phy_device_create);
  22543. +
  22544. +/**
  22545. + * get_phy_id - reads the specified addr for its ID.
  22546. + * @bus: the target MII bus
  22547. + * @addr: PHY address on the MII bus
  22548. + * @phy_id: where to store the ID retrieved.
  22549. + *
  22550. + * Description: Reads the ID registers of the PHY at @addr on the
  22551. + * @bus, stores it in @phy_id and returns zero on success.
  22552. + */
  22553. +int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id)
  22554. +{
  22555. + int phy_reg;
  22556. +
  22557. + /* Grab the bits from PHYIR1, and put them
  22558. + * in the upper half */
  22559. + phy_reg = bus->read(bus, addr, MII_PHYSID1);
  22560. +
  22561. + if (phy_reg < 0)
  22562. + return -EIO;
  22563. +
  22564. + *phy_id = (phy_reg & 0xffff) << 16;
  22565. +
  22566. + /* Grab the bits from PHYIR2, and put them in the lower half */
  22567. + phy_reg = bus->read(bus, addr, MII_PHYSID2);
  22568. +
  22569. + if (phy_reg < 0)
  22570. + return -EIO;
  22571. +
  22572. + *phy_id |= (phy_reg & 0xffff);
  22573. +
  22574. + return 0;
  22575. +}
  22576. +EXPORT_SYMBOL(get_phy_id);
  22577. +
  22578. +/**
  22579. + * get_phy_device - reads the specified PHY device and returns its @phy_device struct
  22580. + * @bus: the target MII bus
  22581. + * @addr: PHY address on the MII bus
  22582. + *
  22583. + * Description: Reads the ID registers of the PHY at @addr on the
  22584. + * @bus, then allocates and returns the phy_device to represent it.
  22585. + */
  22586. +struct phy_device * get_phy_device(struct mii_bus *bus, int addr)
  22587. +{
  22588. + struct phy_device *dev = NULL;
  22589. + u32 phy_id;
  22590. + int r;
  22591. +
  22592. + r = get_phy_id(bus, addr, &phy_id);
  22593. + if (r)
  22594. + return ERR_PTR(r);
  22595. +
  22596. + /* If the phy_id is mostly Fs, there is no device there */
  22597. + if ((phy_id & 0x1fffffff) == 0x1fffffff)
  22598. + return NULL;
  22599. +
  22600. + dev = phy_device_create(bus, addr, phy_id);
  22601. +
  22602. + return dev;
  22603. +}
  22604. +EXPORT_SYMBOL(get_phy_device);
  22605. +
  22606. +/**
  22607. + * phy_device_register - Register the phy device on the MDIO bus
  22608. + * @phydev: phy_device structure to be added to the MDIO bus
  22609. + */
  22610. +int phy_device_register(struct phy_device *phydev)
  22611. +{
  22612. + int err;
  22613. +
  22614. + /* Don't register a phy if one is already registered at this
  22615. + * address */
  22616. + if (phydev->bus->phy_map[phydev->addr])
  22617. + return -EINVAL;
  22618. + phydev->bus->phy_map[phydev->addr] = phydev;
  22619. +
  22620. + /* Run all of the fixups for this PHY */
  22621. + phy_scan_fixups(phydev);
  22622. +
  22623. + err = device_register(&phydev->dev);
  22624. + if (err) {
  22625. + pr_err("phy %d failed to register\n", phydev->addr);
  22626. + goto out;
  22627. + }
  22628. +
  22629. + return 0;
  22630. +
  22631. + out:
  22632. + phydev->bus->phy_map[phydev->addr] = NULL;
  22633. + return err;
  22634. +}
  22635. +EXPORT_SYMBOL(phy_device_register);
  22636. +
  22637. +/**
  22638. + * phy_find_first - finds the first PHY device on the bus
  22639. + * @bus: the target MII bus
  22640. + */
  22641. +struct phy_device *phy_find_first(struct mii_bus *bus)
  22642. +{
  22643. + int addr;
  22644. +
  22645. + for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
  22646. + if (bus->phy_map[addr])
  22647. + return bus->phy_map[addr];
  22648. + }
  22649. + return NULL;
  22650. +}
  22651. +EXPORT_SYMBOL(phy_find_first);
  22652. +
  22653. +/**
  22654. + * phy_prepare_link - prepares the PHY layer to monitor link status
  22655. + * @phydev: target phy_device struct
  22656. + * @handler: callback function for link status change notifications
  22657. + *
  22658. + * Description: Tells the PHY infrastructure to handle the
  22659. + * gory details on monitoring link status (whether through
  22660. + * polling or an interrupt), and to call back to the
  22661. + * connected device driver when the link status changes.
  22662. + * If you want to monitor your own link state, don't call
  22663. + * this function.
  22664. + */
  22665. +void phy_prepare_link(struct phy_device *phydev,
  22666. + void (*handler)(struct net_device *))
  22667. +{
  22668. + phydev->adjust_link = handler;
  22669. +}
  22670. +
  22671. +/**
  22672. + * phy_connect_direct - connect an ethernet device to a specific phy_device
  22673. + * @dev: the network device to connect
  22674. + * @phydev: the pointer to the phy device
  22675. + * @handler: callback function for state change notifications
  22676. + * @flags: PHY device's dev_flags
  22677. + * @interface: PHY device's interface
  22678. + */
  22679. +int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
  22680. + void (*handler)(struct net_device *), u32 flags,
  22681. + phy_interface_t interface)
  22682. +{
  22683. + int rc;
  22684. +
  22685. + rc = phy_attach_direct(dev, phydev, flags, interface);
  22686. + if (rc)
  22687. + return rc;
  22688. +
  22689. + phy_prepare_link(phydev, handler);
  22690. + phy_start_machine(phydev, NULL);
  22691. + if (phydev->irq > 0)
  22692. + phy_start_interrupts(phydev);
  22693. +
  22694. + return 0;
  22695. +}
  22696. +EXPORT_SYMBOL(phy_connect_direct);
  22697. +
  22698. +/**
  22699. + * phy_connect - connect an ethernet device to a PHY device
  22700. + * @dev: the network device to connect
  22701. + * @bus_id: the id string of the PHY device to connect
  22702. + * @handler: callback function for state change notifications
  22703. + * @flags: PHY device's dev_flags
  22704. + * @interface: PHY device's interface
  22705. + *
  22706. + * Description: Convenience function for connecting ethernet
  22707. + * devices to PHY devices. The default behavior is for
  22708. + * the PHY infrastructure to handle everything, and only notify
  22709. + * the connected driver when the link status changes. If you
  22710. + * don't want, or can't use the provided functionality, you may
  22711. + * choose to call only the subset of functions which provide
  22712. + * the desired functionality.
  22713. + */
  22714. +struct phy_device * phy_connect(struct net_device *dev, const char *bus_id,
  22715. + void (*handler)(struct net_device *), u32 flags,
  22716. + phy_interface_t interface)
  22717. +{
  22718. + struct phy_device *phydev;
  22719. + struct device *d;
  22720. + int rc;
  22721. +
  22722. + /* Search the list of PHY devices on the mdio bus for the
  22723. + * PHY with the requested name */
  22724. + d = bus_find_device_by_name(&mdio_bus_type, NULL, bus_id);
  22725. + if (!d) {
  22726. + pr_err("PHY %s not found\n", bus_id);
  22727. + return ERR_PTR(-ENODEV);
  22728. + }
  22729. + phydev = to_phy_device(d);
  22730. +
  22731. + rc = phy_connect_direct(dev, phydev, handler, flags, interface);
  22732. + if (rc)
  22733. + return ERR_PTR(rc);
  22734. +
  22735. + return phydev;
  22736. +}
  22737. +EXPORT_SYMBOL(phy_connect);
  22738. +
  22739. +/**
  22740. + * phy_disconnect - disable interrupts, stop state machine, and detach a PHY device
  22741. + * @phydev: target phy_device struct
  22742. + */
  22743. +void phy_disconnect(struct phy_device *phydev)
  22744. +{
  22745. + if (phydev->irq > 0)
  22746. + phy_stop_interrupts(phydev);
  22747. +
  22748. + phy_stop_machine(phydev);
  22749. +
  22750. + phydev->adjust_link = NULL;
  22751. +
  22752. + phy_detach(phydev);
  22753. +}
  22754. +EXPORT_SYMBOL(phy_disconnect);
  22755. +
  22756. +int phy_init_hw(struct phy_device *phydev)
  22757. +{
  22758. + int ret;
  22759. +
  22760. + if (!phydev->drv || !phydev->drv->config_init)
  22761. + return 0;
  22762. +
  22763. + ret = phy_scan_fixups(phydev);
  22764. + if (ret < 0)
  22765. + return ret;
  22766. +
  22767. + return phydev->drv->config_init(phydev);
  22768. +}
  22769. +
  22770. +/**
  22771. + * phy_attach_direct - attach a network device to a given PHY device pointer
  22772. + * @dev: network device to attach
  22773. + * @phydev: Pointer to phy_device to attach
  22774. + * @flags: PHY device's dev_flags
  22775. + * @interface: PHY device's interface
  22776. + *
  22777. + * Description: Called by drivers to attach to a particular PHY
  22778. + * device. The phy_device is found, and properly hooked up
  22779. + * to the phy_driver. If no driver is attached, then the
  22780. + * genphy_driver is used. The phy_device is given a ptr to
  22781. + * the attaching device, and given a callback for link status
  22782. + * change. The phy_device is returned to the attaching driver.
  22783. + */
  22784. +int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
  22785. + u32 flags, phy_interface_t interface)
  22786. +{
  22787. + struct device *d = &phydev->dev;
  22788. +
  22789. + /* Assume that if there is no driver, that it doesn't
  22790. + * exist, and we should use the genphy driver. */
  22791. + if (NULL == d->driver) {
  22792. + int err;
  22793. + d->driver = &genphy_driver.driver;
  22794. +
  22795. + err = d->driver->probe(d);
  22796. + if (err >= 0)
  22797. + err = device_bind_driver(d);
  22798. +
  22799. + if (err)
  22800. + return err;
  22801. + }
  22802. +
  22803. + if (phydev->attached_dev) {
  22804. + dev_err(&dev->dev, "PHY already attached\n");
  22805. + return -EBUSY;
  22806. + }
  22807. +
  22808. + phydev->attached_dev = dev;
  22809. +
  22810. + phydev->dev_flags = flags;
  22811. +
  22812. + phydev->interface = interface;
  22813. +
  22814. + /* Do initial configuration here, now that
  22815. + * we have certain key parameters
  22816. + * (dev_flags and interface) */
  22817. + return phy_init_hw(phydev);
  22818. +}
  22819. +EXPORT_SYMBOL(phy_attach_direct);
  22820. +
  22821. +/**
  22822. + * phy_attach - attach a network device to a particular PHY device
  22823. + * @dev: network device to attach
  22824. + * @bus_id: Bus ID of PHY device to attach
  22825. + * @flags: PHY device's dev_flags
  22826. + * @interface: PHY device's interface
  22827. + *
  22828. + * Description: Same as phy_attach_direct() except that a PHY bus_id
  22829. + * string is passed instead of a pointer to a struct phy_device.
  22830. + */
  22831. +struct phy_device *phy_attach(struct net_device *dev,
  22832. + const char *bus_id, u32 flags, phy_interface_t interface)
  22833. +{
  22834. + struct bus_type *bus = &mdio_bus_type;
  22835. + struct phy_device *phydev;
  22836. + struct device *d;
  22837. + int rc;
  22838. +
  22839. + /* Search the list of PHY devices on the mdio bus for the
  22840. + * PHY with the requested name */
  22841. + d = bus_find_device_by_name(bus, NULL, bus_id);
  22842. + if (!d) {
  22843. + pr_err("PHY %s not found\n", bus_id);
  22844. + return ERR_PTR(-ENODEV);
  22845. + }
  22846. + phydev = to_phy_device(d);
  22847. +
  22848. + rc = phy_attach_direct(dev, phydev, flags, interface);
  22849. + if (rc)
  22850. + return ERR_PTR(rc);
  22851. +
  22852. + return phydev;
  22853. +}
  22854. +EXPORT_SYMBOL(phy_attach);
  22855. +
  22856. +/**
  22857. + * phy_detach - detach a PHY device from its network device
  22858. + * @phydev: target phy_device struct
  22859. + */
  22860. +void phy_detach(struct phy_device *phydev)
  22861. +{
  22862. + phydev->attached_dev = NULL;
  22863. +
  22864. + /* If the device had no specific driver before (i.e. - it
  22865. + * was using the generic driver), we unbind the device
  22866. + * from the generic driver so that there's a chance a
  22867. + * real driver could be loaded */
  22868. + if (phydev->dev.driver == &genphy_driver.driver)
  22869. + device_release_driver(&phydev->dev);
  22870. +}
  22871. +EXPORT_SYMBOL(phy_detach);
  22872. +
  22873. +
  22874. +/* Generic PHY support and helper functions */
  22875. +
  22876. +/**
  22877. + * genphy_config_advert - sanitize and advertise auto-negotation parameters
  22878. + * @phydev: target phy_device struct
  22879. + *
  22880. + * Description: Writes MII_ADVERTISE with the appropriate values,
  22881. + * after sanitizing the values to make sure we only advertise
  22882. + * what is supported. Returns < 0 on error, 0 if the PHY's advertisement
  22883. + * hasn't changed, and > 0 if it has changed.
  22884. + */
  22885. +int genphy_config_advert(struct phy_device *phydev)
  22886. +{
  22887. + u32 advertise;
  22888. + int oldadv, adv;
  22889. + int err, changed = 0;
  22890. +
  22891. + /* Only allow advertising what
  22892. + * this PHY supports */
  22893. + phydev->advertising &= phydev->supported;
  22894. + advertise = phydev->advertising;
  22895. +
  22896. + /* Setup standard advertisement */
  22897. + oldadv = adv = phy_read(phydev, MII_ADVERTISE);
  22898. +
  22899. + if (adv < 0)
  22900. + return adv;
  22901. +
  22902. + adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP |
  22903. + ADVERTISE_PAUSE_ASYM);
  22904. + if (advertise & ADVERTISED_10baseT_Half)
  22905. + adv |= ADVERTISE_10HALF;
  22906. + if (advertise & ADVERTISED_10baseT_Full)
  22907. + adv |= ADVERTISE_10FULL;
  22908. + if (advertise & ADVERTISED_100baseT_Half)
  22909. + adv |= ADVERTISE_100HALF;
  22910. + if (advertise & ADVERTISED_100baseT_Full)
  22911. + adv |= ADVERTISE_100FULL;
  22912. + if (advertise & ADVERTISED_Pause)
  22913. + adv |= ADVERTISE_PAUSE_CAP;
  22914. + if (advertise & ADVERTISED_Asym_Pause)
  22915. + adv |= ADVERTISE_PAUSE_ASYM;
  22916. +
  22917. + if (adv != oldadv) {
  22918. + err = phy_write(phydev, MII_ADVERTISE, adv);
  22919. +
  22920. + if (err < 0)
  22921. + return err;
  22922. + changed = 1;
  22923. + }
  22924. +
  22925. + /* Configure gigabit if it's supported */
  22926. + if (phydev->supported & (SUPPORTED_1000baseT_Half |
  22927. + SUPPORTED_1000baseT_Full)) {
  22928. + oldadv = adv = phy_read(phydev, MII_CTRL1000);
  22929. +
  22930. + if (adv < 0)
  22931. + return adv;
  22932. +
  22933. + adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
  22934. + if (advertise & SUPPORTED_1000baseT_Half)
  22935. + adv |= ADVERTISE_1000HALF;
  22936. + if (advertise & SUPPORTED_1000baseT_Full)
  22937. + adv |= ADVERTISE_1000FULL;
  22938. +
  22939. + if (adv != oldadv) {
  22940. + err = phy_write(phydev, MII_CTRL1000, adv);
  22941. +
  22942. + if (err < 0)
  22943. + return err;
  22944. + changed = 1;
  22945. + }
  22946. + }
  22947. +
  22948. + return changed;
  22949. +}
  22950. +EXPORT_SYMBOL(genphy_config_advert);
  22951. +
  22952. +/**
  22953. + * genphy_setup_forced - configures/forces speed/duplex from @phydev
  22954. + * @phydev: target phy_device struct
  22955. + *
  22956. + * Description: Configures MII_BMCR to force speed/duplex
  22957. + * to the values in phydev. Assumes that the values are valid.
  22958. + * Please see phy_sanitize_settings().
  22959. + */
  22960. +int genphy_setup_forced(struct phy_device *phydev)
  22961. +{
  22962. + int err;
  22963. + int ctl = 0;
  22964. +
  22965. + phydev->pause = phydev->asym_pause = 0;
  22966. +
  22967. + if (SPEED_1000 == phydev->speed)
  22968. + ctl |= BMCR_SPEED1000;
  22969. + else if (SPEED_100 == phydev->speed)
  22970. + ctl |= BMCR_SPEED100;
  22971. +
  22972. + if (DUPLEX_FULL == phydev->duplex)
  22973. + ctl |= BMCR_FULLDPLX;
  22974. +
  22975. + err = phy_write(phydev, MII_BMCR, ctl);
  22976. +
  22977. + return err;
  22978. +}
  22979. +
  22980. +
  22981. +/**
  22982. + * genphy_restart_aneg - Enable and Restart Autonegotiation
  22983. + * @phydev: target phy_device struct
  22984. + */
  22985. +int genphy_restart_aneg(struct phy_device *phydev)
  22986. +{
  22987. + int ctl;
  22988. +
  22989. + ctl = phy_read(phydev, MII_BMCR);
  22990. +
  22991. + if (ctl < 0)
  22992. + return ctl;
  22993. +
  22994. + ctl |= (BMCR_ANENABLE | BMCR_ANRESTART);
  22995. +
  22996. + /* Don't isolate the PHY if we're negotiating */
  22997. + ctl &= ~(BMCR_ISOLATE);
  22998. +
  22999. + ctl = phy_write(phydev, MII_BMCR, ctl);
  23000. +
  23001. + return ctl;
  23002. +}
  23003. +EXPORT_SYMBOL(genphy_restart_aneg);
  23004. +
  23005. +
  23006. +/**
  23007. + * genphy_config_aneg - restart auto-negotiation or write BMCR
  23008. + * @phydev: target phy_device struct
  23009. + *
  23010. + * Description: If auto-negotiation is enabled, we configure the
  23011. + * advertising, and then restart auto-negotiation. If it is not
  23012. + * enabled, then we write the BMCR.
  23013. + */
  23014. +int genphy_config_aneg(struct phy_device *phydev)
  23015. +{
  23016. + int result;
  23017. +
  23018. + if (AUTONEG_ENABLE != phydev->autoneg)
  23019. + return genphy_setup_forced(phydev);
  23020. +
  23021. + result = genphy_config_advert(phydev);
  23022. +
  23023. + if (result < 0) /* error */
  23024. + return result;
  23025. +
  23026. + if (result == 0) {
  23027. + /* Advertisment hasn't changed, but maybe aneg was never on to
  23028. + * begin with? Or maybe phy was isolated? */
  23029. + int ctl = phy_read(phydev, MII_BMCR);
  23030. +
  23031. + if (ctl < 0)
  23032. + return ctl;
  23033. +
  23034. + if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE))
  23035. + result = 1; /* do restart aneg */
  23036. + }
  23037. +
  23038. + /* Only restart aneg if we are advertising something different
  23039. + * than we were before. */
  23040. + if (result > 0)
  23041. + result = genphy_restart_aneg(phydev);
  23042. +
  23043. + return result;
  23044. +}
  23045. +EXPORT_SYMBOL(genphy_config_aneg);
  23046. +
  23047. +/**
  23048. + * genphy_update_link - update link status in @phydev
  23049. + * @phydev: target phy_device struct
  23050. + *
  23051. + * Description: Update the value in phydev->link to reflect the
  23052. + * current link value. In order to do this, we need to read
  23053. + * the status register twice, keeping the second value.
  23054. + */
  23055. +int genphy_update_link(struct phy_device *phydev)
  23056. +{
  23057. + int status;
  23058. +
  23059. + /* Do a fake read */
  23060. + status = phy_read(phydev, MII_BMSR);
  23061. +
  23062. + if (status < 0)
  23063. + return status;
  23064. +
  23065. + /* Read link and autonegotiation status */
  23066. + status = phy_read(phydev, MII_BMSR);
  23067. +
  23068. + if (status < 0)
  23069. + return status;
  23070. +
  23071. + if ((status & BMSR_LSTATUS) == 0)
  23072. + phydev->link = 0;
  23073. + else
  23074. + phydev->link = 1;
  23075. +
  23076. + return 0;
  23077. +}
  23078. +EXPORT_SYMBOL(genphy_update_link);
  23079. +
  23080. +/**
  23081. + * genphy_read_status - check the link status and update current link state
  23082. + * @phydev: target phy_device struct
  23083. + *
  23084. + * Description: Check the link, then figure out the current state
  23085. + * by comparing what we advertise with what the link partner
  23086. + * advertises. Start by checking the gigabit possibilities,
  23087. + * then move on to 10/100.
  23088. + */
  23089. +int genphy_read_status(struct phy_device *phydev)
  23090. +{
  23091. + int adv;
  23092. + int err;
  23093. + int lpa;
  23094. + int lpagb = 0;
  23095. +
  23096. + /* Update the link, but return if there
  23097. + * was an error */
  23098. + err = genphy_update_link(phydev);
  23099. + if (err)
  23100. + return err;
  23101. +
  23102. + if (AUTONEG_ENABLE == phydev->autoneg) {
  23103. + if (phydev->supported & (SUPPORTED_1000baseT_Half
  23104. + | SUPPORTED_1000baseT_Full)) {
  23105. + lpagb = phy_read(phydev, MII_STAT1000);
  23106. +
  23107. + if (lpagb < 0)
  23108. + return lpagb;
  23109. +
  23110. + adv = phy_read(phydev, MII_CTRL1000);
  23111. +
  23112. + if (adv < 0)
  23113. + return adv;
  23114. +
  23115. + lpagb &= adv << 2;
  23116. + }
  23117. +
  23118. + lpa = phy_read(phydev, MII_LPA);
  23119. +
  23120. + if (lpa < 0)
  23121. + return lpa;
  23122. +
  23123. + adv = phy_read(phydev, MII_ADVERTISE);
  23124. +
  23125. + if (adv < 0)
  23126. + return adv;
  23127. +
  23128. + lpa &= adv;
  23129. +
  23130. + phydev->speed = SPEED_10;
  23131. + phydev->duplex = DUPLEX_HALF;
  23132. + phydev->pause = phydev->asym_pause = 0;
  23133. +
  23134. + if (lpagb & (LPA_1000FULL | LPA_1000HALF)) {
  23135. + phydev->speed = SPEED_1000;
  23136. +
  23137. + if (lpagb & LPA_1000FULL)
  23138. + phydev->duplex = DUPLEX_FULL;
  23139. + } else if (lpa & (LPA_100FULL | LPA_100HALF)) {
  23140. + phydev->speed = SPEED_100;
  23141. +
  23142. + if (lpa & LPA_100FULL)
  23143. + phydev->duplex = DUPLEX_FULL;
  23144. + } else
  23145. + if (lpa & LPA_10FULL)
  23146. + phydev->duplex = DUPLEX_FULL;
  23147. +
  23148. + if (phydev->duplex == DUPLEX_FULL){
  23149. + phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
  23150. + phydev->asym_pause = lpa & LPA_PAUSE_ASYM ? 1 : 0;
  23151. + }
  23152. + } else {
  23153. + int bmcr = phy_read(phydev, MII_BMCR);
  23154. + if (bmcr < 0)
  23155. + return bmcr;
  23156. +
  23157. + if (bmcr & BMCR_FULLDPLX)
  23158. + phydev->duplex = DUPLEX_FULL;
  23159. + else
  23160. + phydev->duplex = DUPLEX_HALF;
  23161. +
  23162. + if (bmcr & BMCR_SPEED1000)
  23163. + phydev->speed = SPEED_1000;
  23164. + else if (bmcr & BMCR_SPEED100)
  23165. + phydev->speed = SPEED_100;
  23166. + else
  23167. + phydev->speed = SPEED_10;
  23168. +
  23169. + phydev->pause = phydev->asym_pause = 0;
  23170. + }
  23171. +
  23172. + return 0;
  23173. +}
  23174. +EXPORT_SYMBOL(genphy_read_status);
  23175. +
  23176. +static int genphy_config_init(struct phy_device *phydev)
  23177. +{
  23178. + int val;
  23179. + u32 features;
  23180. +
  23181. + /* For now, I'll claim that the generic driver supports
  23182. + * all possible port types */
  23183. + features = (SUPPORTED_TP | SUPPORTED_MII
  23184. + | SUPPORTED_AUI | SUPPORTED_FIBRE |
  23185. + SUPPORTED_BNC);
  23186. +
  23187. + /* Do we support autonegotiation? */
  23188. + val = phy_read(phydev, MII_BMSR);
  23189. +
  23190. + if (val < 0)
  23191. + return val;
  23192. +
  23193. + if (val & BMSR_ANEGCAPABLE)
  23194. + features |= SUPPORTED_Autoneg;
  23195. +
  23196. + if (val & BMSR_100FULL)
  23197. + features |= SUPPORTED_100baseT_Full;
  23198. + if (val & BMSR_100HALF)
  23199. + features |= SUPPORTED_100baseT_Half;
  23200. + if (val & BMSR_10FULL)
  23201. + features |= SUPPORTED_10baseT_Full;
  23202. + if (val & BMSR_10HALF)
  23203. + features |= SUPPORTED_10baseT_Half;
  23204. +
  23205. + if (val & BMSR_ESTATEN) {
  23206. + val = phy_read(phydev, MII_ESTATUS);
  23207. +
  23208. + if (val < 0)
  23209. + return val;
  23210. +
  23211. + if (val & ESTATUS_1000_TFULL)
  23212. + features |= SUPPORTED_1000baseT_Full;
  23213. + if (val & ESTATUS_1000_THALF)
  23214. + features |= SUPPORTED_1000baseT_Half;
  23215. + }
  23216. +
  23217. + phydev->supported = features;
  23218. + phydev->advertising = features;
  23219. +
  23220. + return 0;
  23221. +}
  23222. +int genphy_suspend(struct phy_device *phydev)
  23223. +{
  23224. + int value;
  23225. +
  23226. + mutex_lock(&phydev->lock);
  23227. +
  23228. + value = phy_read(phydev, MII_BMCR);
  23229. + phy_write(phydev, MII_BMCR, (value | BMCR_PDOWN));
  23230. +
  23231. + mutex_unlock(&phydev->lock);
  23232. +
  23233. + return 0;
  23234. +}
  23235. +EXPORT_SYMBOL(genphy_suspend);
  23236. +
  23237. +int genphy_resume(struct phy_device *phydev)
  23238. +{
  23239. + int value;
  23240. +
  23241. + mutex_lock(&phydev->lock);
  23242. +
  23243. + value = phy_read(phydev, MII_BMCR);
  23244. + phy_write(phydev, MII_BMCR, (value & ~BMCR_PDOWN));
  23245. +
  23246. + mutex_unlock(&phydev->lock);
  23247. +
  23248. + return 0;
  23249. +}
  23250. +EXPORT_SYMBOL(genphy_resume);
  23251. +
  23252. +/**
  23253. + * phy_probe - probe and init a PHY device
  23254. + * @dev: device to probe and init
  23255. + *
  23256. + * Description: Take care of setting up the phy_device structure,
  23257. + * set the state to READY (the driver's init function should
  23258. + * set it to STARTING if needed).
  23259. + */
  23260. +static int phy_probe(struct device *dev)
  23261. +{
  23262. + struct phy_device *phydev;
  23263. + struct phy_driver *phydrv;
  23264. + struct device_driver *drv;
  23265. + int err = 0;
  23266. +
  23267. + phydev = to_phy_device(dev);
  23268. +
  23269. + /* Make sure the driver is held.
  23270. + * XXX -- Is this correct? */
  23271. + drv = get_driver(phydev->dev.driver);
  23272. + phydrv = to_phy_driver(drv);
  23273. + phydev->drv = phydrv;
  23274. +
  23275. + /* Disable the interrupt if the PHY doesn't support it */
  23276. + if (!(phydrv->flags & PHY_HAS_INTERRUPT))
  23277. + phydev->irq = PHY_POLL;
  23278. +
  23279. + mutex_lock(&phydev->lock);
  23280. +
  23281. + /* Start out supporting everything. Eventually,
  23282. + * a controller will attach, and may modify one
  23283. + * or both of these values */
  23284. + phydev->supported = phydrv->features;
  23285. + phydev->advertising = phydrv->features;
  23286. +
  23287. + /* Set the state to READY by default */
  23288. + phydev->state = PHY_READY;
  23289. +
  23290. + if (phydev->drv->probe)
  23291. + err = phydev->drv->probe(phydev);
  23292. +
  23293. + mutex_unlock(&phydev->lock);
  23294. +
  23295. + return err;
  23296. +
  23297. +}
  23298. +
  23299. +static int phy_remove(struct device *dev)
  23300. +{
  23301. + struct phy_device *phydev;
  23302. +
  23303. + phydev = to_phy_device(dev);
  23304. +
  23305. + mutex_lock(&phydev->lock);
  23306. + phydev->state = PHY_DOWN;
  23307. + mutex_unlock(&phydev->lock);
  23308. +
  23309. + if (phydev->drv->remove)
  23310. + phydev->drv->remove(phydev);
  23311. +
  23312. + put_driver(dev->driver);
  23313. + phydev->drv = NULL;
  23314. +
  23315. + return 0;
  23316. +}
  23317. +
  23318. +/**
  23319. + * phy_driver_register - register a phy_driver with the PHY layer
  23320. + * @new_driver: new phy_driver to register
  23321. + */
  23322. +int phy_driver_register(struct phy_driver *new_driver)
  23323. +{
  23324. + int retval;
  23325. +
  23326. + new_driver->driver.name = new_driver->name;
  23327. + new_driver->driver.bus = &mdio_bus_type;
  23328. + new_driver->driver.probe = phy_probe;
  23329. + new_driver->driver.remove = phy_remove;
  23330. +
  23331. + retval = driver_register(&new_driver->driver);
  23332. +
  23333. + if (retval) {
  23334. + printk(KERN_ERR "%s: Error %d in registering driver\n",
  23335. + new_driver->name, retval);
  23336. +
  23337. + return retval;
  23338. + }
  23339. +
  23340. + pr_debug("%s: Registered new driver\n", new_driver->name);
  23341. +
  23342. + return 0;
  23343. +}
  23344. +EXPORT_SYMBOL(phy_driver_register);
  23345. +
  23346. +void phy_driver_unregister(struct phy_driver *drv)
  23347. +{
  23348. + driver_unregister(&drv->driver);
  23349. +}
  23350. +EXPORT_SYMBOL(phy_driver_unregister);
  23351. +
  23352. +static struct phy_driver genphy_driver = {
  23353. + .phy_id = 0xffffffff,
  23354. + .phy_id_mask = 0xffffffff,
  23355. + .name = "Generic PHY",
  23356. + .config_init = genphy_config_init,
  23357. + .features = 0,
  23358. + .config_aneg = genphy_config_aneg,
  23359. + .read_status = genphy_read_status,
  23360. + .suspend = genphy_suspend,
  23361. + .resume = genphy_resume,
  23362. + .driver = {.owner= THIS_MODULE, },
  23363. +};
  23364. +
  23365. +static int __init phy_init(void)
  23366. +{
  23367. + int rc;
  23368. +
  23369. + rc = mdio_bus_init();
  23370. + if (rc)
  23371. + return rc;
  23372. +
  23373. + rc = phy_driver_register(&genphy_driver);
  23374. + if (rc)
  23375. + mdio_bus_exit();
  23376. +
  23377. + return rc;
  23378. +}
  23379. +
  23380. +static void __exit phy_exit(void)
  23381. +{
  23382. + phy_driver_unregister(&genphy_driver);
  23383. + mdio_bus_exit();
  23384. +}
  23385. +
  23386. +subsys_initcall(phy_init);
  23387. +module_exit(phy_exit);
  23388. diff -Nur linux-2.6.35.7.orig/drivers/spi/ap83_spi.c linux-2.6.35.7/drivers/spi/ap83_spi.c
  23389. --- linux-2.6.35.7.orig/drivers/spi/ap83_spi.c 1970-01-01 01:00:00.000000000 +0100
  23390. +++ linux-2.6.35.7/drivers/spi/ap83_spi.c 2010-10-14 20:28:01.048101088 +0200
  23391. @@ -0,0 +1,282 @@
  23392. +/*
  23393. + * Atheros AP83 board specific SPI Controller driver
  23394. + *
  23395. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  23396. + *
  23397. + * This program is free software; you can redistribute it and/or modify
  23398. + * it under the terms of the GNU General Public License version 2 as
  23399. + * published by the Free Software Foundation.
  23400. + *
  23401. + */
  23402. +
  23403. +#include <linux/kernel.h>
  23404. +#include <linux/init.h>
  23405. +#include <linux/delay.h>
  23406. +#include <linux/spinlock.h>
  23407. +#include <linux/workqueue.h>
  23408. +#include <linux/platform_device.h>
  23409. +#include <linux/io.h>
  23410. +#include <linux/spi/spi.h>
  23411. +#include <linux/spi/spi_bitbang.h>
  23412. +#include <linux/bitops.h>
  23413. +#include <linux/gpio.h>
  23414. +
  23415. +#include <asm/mach-ar71xx/ar71xx.h>
  23416. +#include <asm/mach-ar71xx/platform.h>
  23417. +
  23418. +#define DRV_DESC "Atheros AP83 board SPI Controller driver"
  23419. +#define DRV_VERSION "0.1.0"
  23420. +#define DRV_NAME "ap83-spi"
  23421. +
  23422. +#define AP83_SPI_CLK_HIGH (1 << 23)
  23423. +#define AP83_SPI_CLK_LOW 0
  23424. +#define AP83_SPI_MOSI_HIGH (1 << 22)
  23425. +#define AP83_SPI_MOSI_LOW 0
  23426. +
  23427. +#define AP83_SPI_GPIO_CS 1
  23428. +#define AP83_SPI_GPIO_MISO 3
  23429. +
  23430. +struct ap83_spi {
  23431. + struct spi_bitbang bitbang;
  23432. + void __iomem *base;
  23433. + u32 addr;
  23434. +
  23435. + struct platform_device *pdev;
  23436. +};
  23437. +
  23438. +static inline u32 ap83_spi_rr(struct ap83_spi *sp, u32 reg)
  23439. +{
  23440. + return __raw_readl(sp->base + reg);
  23441. +}
  23442. +
  23443. +static inline struct ap83_spi *spidev_to_sp(struct spi_device *spi)
  23444. +{
  23445. + return spi_master_get_devdata(spi->master);
  23446. +}
  23447. +
  23448. +static inline void setsck(struct spi_device *spi, int val)
  23449. +{
  23450. + struct ap83_spi *sp = spidev_to_sp(spi);
  23451. +
  23452. + if (val)
  23453. + sp->addr |= AP83_SPI_CLK_HIGH;
  23454. + else
  23455. + sp->addr &= ~AP83_SPI_CLK_HIGH;
  23456. +
  23457. + dev_dbg(&spi->dev, "addr=%08x, SCK set to %s\n",
  23458. + sp->addr, (val) ? "HIGH" : "LOW");
  23459. +
  23460. + ap83_spi_rr(sp, sp->addr);
  23461. +}
  23462. +
  23463. +static inline void setmosi(struct spi_device *spi, int val)
  23464. +{
  23465. + struct ap83_spi *sp = spidev_to_sp(spi);
  23466. +
  23467. + if (val)
  23468. + sp->addr |= AP83_SPI_MOSI_HIGH;
  23469. + else
  23470. + sp->addr &= ~AP83_SPI_MOSI_HIGH;
  23471. +
  23472. + dev_dbg(&spi->dev, "addr=%08x, MOSI set to %s\n",
  23473. + sp->addr, (val) ? "HIGH" : "LOW");
  23474. +
  23475. + ap83_spi_rr(sp, sp->addr);
  23476. +}
  23477. +
  23478. +static inline u32 getmiso(struct spi_device *spi)
  23479. +{
  23480. + u32 ret;
  23481. +
  23482. + ret = gpio_get_value(AP83_SPI_GPIO_MISO) ? 1 : 0;
  23483. + dev_dbg(&spi->dev, "get MISO: %d\n", ret);
  23484. +
  23485. + return ret;
  23486. +}
  23487. +
  23488. +static inline void do_spidelay(struct spi_device *spi, unsigned nsecs)
  23489. +{
  23490. + ndelay(nsecs);
  23491. +}
  23492. +
  23493. +static void ap83_spi_chipselect(struct spi_device *spi, int on)
  23494. +{
  23495. + struct ap83_spi *sp = spidev_to_sp(spi);
  23496. +
  23497. + dev_dbg(&spi->dev, "set CS to %d\n", (on) ? 0 : 1);
  23498. +
  23499. + if (on) {
  23500. + ar71xx_flash_acquire();
  23501. +
  23502. + sp->addr = 0;
  23503. + ap83_spi_rr(sp, sp->addr);
  23504. +
  23505. + gpio_set_value(AP83_SPI_GPIO_CS, 0);
  23506. + } else {
  23507. + gpio_set_value(AP83_SPI_GPIO_CS, 1);
  23508. + ar71xx_flash_release();
  23509. + }
  23510. +}
  23511. +
  23512. +#define spidelay(nsecs) \
  23513. + do { \
  23514. + /* Steal the spi_device pointer from our caller. \
  23515. + * The bitbang-API should probably get fixed here... */ \
  23516. + do_spidelay(spi, nsecs); \
  23517. + } while (0)
  23518. +
  23519. +#define EXPAND_BITBANG_TXRX
  23520. +#include <linux/spi/spi_bitbang.h>
  23521. +
  23522. +static u32 ap83_spi_txrx_mode0(struct spi_device *spi,
  23523. + unsigned nsecs, u32 word, u8 bits)
  23524. +{
  23525. + dev_dbg(&spi->dev, "TXRX0 word=%08x, bits=%u\n", word, bits);
  23526. + return bitbang_txrx_be_cpha0(spi, nsecs, 0, word, bits);
  23527. +}
  23528. +
  23529. +static u32 ap83_spi_txrx_mode1(struct spi_device *spi,
  23530. + unsigned nsecs, u32 word, u8 bits)
  23531. +{
  23532. + dev_dbg(&spi->dev, "TXRX1 word=%08x, bits=%u\n", word, bits);
  23533. + return bitbang_txrx_be_cpha1(spi, nsecs, 0, word, bits);
  23534. +}
  23535. +
  23536. +static u32 ap83_spi_txrx_mode2(struct spi_device *spi,
  23537. + unsigned nsecs, u32 word, u8 bits)
  23538. +{
  23539. + dev_dbg(&spi->dev, "TXRX2 word=%08x, bits=%u\n", word, bits);
  23540. + return bitbang_txrx_be_cpha0(spi, nsecs, 1, word, bits);
  23541. +}
  23542. +
  23543. +static u32 ap83_spi_txrx_mode3(struct spi_device *spi,
  23544. + unsigned nsecs, u32 word, u8 bits)
  23545. +{
  23546. + dev_dbg(&spi->dev, "TXRX3 word=%08x, bits=%u\n", word, bits);
  23547. + return bitbang_txrx_be_cpha1(spi, nsecs, 1, word, bits);
  23548. +}
  23549. +
  23550. +static int ap83_spi_probe(struct platform_device *pdev)
  23551. +{
  23552. + struct spi_master *master;
  23553. + struct ap83_spi *sp;
  23554. + struct ap83_spi_platform_data *pdata;
  23555. + struct resource *r;
  23556. + int ret;
  23557. +
  23558. + ret = gpio_request(AP83_SPI_GPIO_MISO, "spi-miso");
  23559. + if (ret) {
  23560. + dev_err(&pdev->dev, "gpio request failed for MISO\n");
  23561. + return ret;
  23562. + }
  23563. +
  23564. + ret = gpio_request(AP83_SPI_GPIO_CS, "spi-cs");
  23565. + if (ret) {
  23566. + dev_err(&pdev->dev, "gpio request failed for CS\n");
  23567. + goto err_free_miso;
  23568. + }
  23569. +
  23570. + ret = gpio_direction_input(AP83_SPI_GPIO_MISO);
  23571. + if (ret) {
  23572. + dev_err(&pdev->dev, "unable to set direction of MISO\n");
  23573. + goto err_free_cs;
  23574. + }
  23575. +
  23576. + ret = gpio_direction_output(AP83_SPI_GPIO_CS, 0);
  23577. + if (ret) {
  23578. + dev_err(&pdev->dev, "unable to set direction of CS\n");
  23579. + goto err_free_cs;
  23580. + }
  23581. +
  23582. + master = spi_alloc_master(&pdev->dev, sizeof(*sp));
  23583. + if (master == NULL) {
  23584. + dev_err(&pdev->dev, "failed to allocate spi master\n");
  23585. + return -ENOMEM;
  23586. + }
  23587. +
  23588. + sp = spi_master_get_devdata(master);
  23589. + platform_set_drvdata(pdev, sp);
  23590. +
  23591. + pdata = pdev->dev.platform_data;
  23592. +
  23593. + sp->bitbang.master = spi_master_get(master);
  23594. + sp->bitbang.chipselect = ap83_spi_chipselect;
  23595. + sp->bitbang.txrx_word[SPI_MODE_0] = ap83_spi_txrx_mode0;
  23596. + sp->bitbang.txrx_word[SPI_MODE_1] = ap83_spi_txrx_mode1;
  23597. + sp->bitbang.txrx_word[SPI_MODE_2] = ap83_spi_txrx_mode2;
  23598. + sp->bitbang.txrx_word[SPI_MODE_3] = ap83_spi_txrx_mode3;
  23599. +
  23600. + sp->bitbang.master->bus_num = pdev->id;
  23601. + sp->bitbang.master->num_chipselect = 1;
  23602. +
  23603. + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  23604. + if (r == NULL) {
  23605. + ret = -ENOENT;
  23606. + goto err_spi_put;
  23607. + }
  23608. +
  23609. + sp->base = ioremap_nocache(r->start, r->end - r->start + 1);
  23610. + if (!sp->base) {
  23611. + ret = -ENXIO;
  23612. + goto err_spi_put;
  23613. + }
  23614. +
  23615. + ret = spi_bitbang_start(&sp->bitbang);
  23616. + if (!ret)
  23617. + goto err_unmap;
  23618. +
  23619. + dev_info(&pdev->dev, "AP83 SPI adapter at %08x\n", r->start);
  23620. +
  23621. + return 0;
  23622. +
  23623. + err_unmap:
  23624. + iounmap(sp->base);
  23625. + err_spi_put:
  23626. + platform_set_drvdata(pdev, NULL);
  23627. + spi_master_put(sp->bitbang.master);
  23628. +
  23629. + err_free_cs:
  23630. + gpio_free(AP83_SPI_GPIO_CS);
  23631. + err_free_miso:
  23632. + gpio_free(AP83_SPI_GPIO_MISO);
  23633. + return ret;
  23634. +}
  23635. +
  23636. +static int ap83_spi_remove(struct platform_device *pdev)
  23637. +{
  23638. + struct ap83_spi *sp = platform_get_drvdata(pdev);
  23639. +
  23640. + spi_bitbang_stop(&sp->bitbang);
  23641. + iounmap(sp->base);
  23642. + platform_set_drvdata(pdev, NULL);
  23643. + spi_master_put(sp->bitbang.master);
  23644. +
  23645. + return 0;
  23646. +}
  23647. +
  23648. +static struct platform_driver ap83_spi_drv = {
  23649. + .probe = ap83_spi_probe,
  23650. + .remove = ap83_spi_remove,
  23651. + .driver = {
  23652. + .name = DRV_NAME,
  23653. + .owner = THIS_MODULE,
  23654. + },
  23655. +};
  23656. +
  23657. +static int __init ap83_spi_init(void)
  23658. +{
  23659. + return platform_driver_register(&ap83_spi_drv);
  23660. +}
  23661. +module_init(ap83_spi_init);
  23662. +
  23663. +static void __exit ap83_spi_exit(void)
  23664. +{
  23665. + platform_driver_unregister(&ap83_spi_drv);
  23666. +}
  23667. +module_exit(ap83_spi_exit);
  23668. +
  23669. +MODULE_ALIAS("platform:" DRV_NAME);
  23670. +MODULE_DESCRIPTION(DRV_DESC);
  23671. +MODULE_VERSION(DRV_VERSION);
  23672. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  23673. +MODULE_LICENSE("GPL v2");
  23674. diff -Nur linux-2.6.35.7.orig/drivers/spi/ar71xx_spi.c linux-2.6.35.7/drivers/spi/ar71xx_spi.c
  23675. --- linux-2.6.35.7.orig/drivers/spi/ar71xx_spi.c 1970-01-01 01:00:00.000000000 +0100
  23676. +++ linux-2.6.35.7/drivers/spi/ar71xx_spi.c 2010-10-14 20:28:01.088050552 +0200
  23677. @@ -0,0 +1,283 @@
  23678. +/*
  23679. + * Atheros AR71xx SPI Controller driver
  23680. + *
  23681. + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
  23682. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  23683. + *
  23684. + * This program is free software; you can redistribute it and/or modify
  23685. + * it under the terms of the GNU General Public License version 2 as
  23686. + * published by the Free Software Foundation.
  23687. + *
  23688. + */
  23689. +
  23690. +#include <linux/kernel.h>
  23691. +#include <linux/init.h>
  23692. +#include <linux/delay.h>
  23693. +#include <linux/spinlock.h>
  23694. +#include <linux/workqueue.h>
  23695. +#include <linux/platform_device.h>
  23696. +#include <linux/io.h>
  23697. +#include <linux/spi/spi.h>
  23698. +#include <linux/spi/spi_bitbang.h>
  23699. +#include <linux/bitops.h>
  23700. +
  23701. +#include <asm/mach-ar71xx/ar71xx.h>
  23702. +#include <asm/mach-ar71xx/platform.h>
  23703. +
  23704. +#define DRV_DESC "Atheros AR71xx SPI Controller driver"
  23705. +#define DRV_VERSION "0.2.4"
  23706. +#define DRV_NAME "ar71xx-spi"
  23707. +
  23708. +#undef PER_BIT_READ
  23709. +
  23710. +struct ar71xx_spi {
  23711. + struct spi_bitbang bitbang;
  23712. + u32 ioc_base;
  23713. + u32 reg_ctrl;
  23714. +
  23715. + void __iomem *base;
  23716. +
  23717. + struct platform_device *pdev;
  23718. + u32 (*get_ioc_base)(u8 chip_select, int cs_high,
  23719. + int is_on);
  23720. +};
  23721. +
  23722. +static inline u32 ar71xx_spi_rr(struct ar71xx_spi *sp, unsigned reg)
  23723. +{
  23724. + return __raw_readl(sp->base + reg);
  23725. +}
  23726. +
  23727. +static inline void ar71xx_spi_wr(struct ar71xx_spi *sp, unsigned reg, u32 val)
  23728. +{
  23729. + __raw_writel(val, sp->base + reg);
  23730. +}
  23731. +
  23732. +static inline struct ar71xx_spi *spidev_to_sp(struct spi_device *spi)
  23733. +{
  23734. + return spi_master_get_devdata(spi->master);
  23735. +}
  23736. +
  23737. +static u32 ar71xx_spi_get_ioc_base(u8 chip_select, int cs_high, int is_on)
  23738. +{
  23739. + u32 ret;
  23740. +
  23741. + if (is_on == AR71XX_SPI_CS_INACTIVE)
  23742. + ret = SPI_IOC_CS_ALL;
  23743. + else
  23744. + ret = SPI_IOC_CS_ALL & ~SPI_IOC_CS(chip_select);
  23745. +
  23746. + return ret;
  23747. +}
  23748. +
  23749. +static void ar71xx_spi_chipselect(struct spi_device *spi, int value)
  23750. +{
  23751. + struct ar71xx_spi *sp = spidev_to_sp(spi);
  23752. + void __iomem *base = sp->base;
  23753. + u32 ioc_base;
  23754. +
  23755. + switch (value) {
  23756. + case BITBANG_CS_INACTIVE:
  23757. + ioc_base = sp->get_ioc_base(spi->chip_select,
  23758. + (spi->mode & SPI_CS_HIGH) != 0,
  23759. + AR71XX_SPI_CS_INACTIVE);
  23760. + __raw_writel(ioc_base, base + SPI_REG_IOC);
  23761. + break;
  23762. +
  23763. + case BITBANG_CS_ACTIVE:
  23764. + ioc_base = sp->get_ioc_base(spi->chip_select,
  23765. + (spi->mode & SPI_CS_HIGH) != 0,
  23766. + AR71XX_SPI_CS_ACTIVE);
  23767. +
  23768. + __raw_writel(ioc_base, base + SPI_REG_IOC);
  23769. + sp->ioc_base = ioc_base;
  23770. + break;
  23771. + }
  23772. +}
  23773. +
  23774. +static void ar71xx_spi_setup_regs(struct spi_device *spi)
  23775. +{
  23776. + struct ar71xx_spi *sp = spidev_to_sp(spi);
  23777. +
  23778. + /* enable GPIO mode */
  23779. + ar71xx_spi_wr(sp, SPI_REG_FS, SPI_FS_GPIO);
  23780. +
  23781. + /* save CTRL register */
  23782. + sp->reg_ctrl = ar71xx_spi_rr(sp, SPI_REG_CTRL);
  23783. +
  23784. + /* TODO: setup speed? */
  23785. + ar71xx_spi_wr(sp, SPI_REG_CTRL, 0x43);
  23786. +}
  23787. +
  23788. +static void ar71xx_spi_restore_regs(struct spi_device *spi)
  23789. +{
  23790. + struct ar71xx_spi *sp = spidev_to_sp(spi);
  23791. +
  23792. + /* restore CTRL register */
  23793. + ar71xx_spi_wr(sp, SPI_REG_CTRL, sp->reg_ctrl);
  23794. + /* disable GPIO mode */
  23795. + ar71xx_spi_wr(sp, SPI_REG_FS, 0);
  23796. +}
  23797. +
  23798. +static int ar71xx_spi_setup(struct spi_device *spi)
  23799. +{
  23800. + int status;
  23801. +
  23802. + if (spi->bits_per_word > 32)
  23803. + return -EINVAL;
  23804. +
  23805. + if (!spi->controller_state)
  23806. + ar71xx_spi_setup_regs(spi);
  23807. +
  23808. + status = spi_bitbang_setup(spi);
  23809. + if (status && !spi->controller_state)
  23810. + ar71xx_spi_restore_regs(spi);
  23811. +
  23812. + return status;
  23813. +}
  23814. +
  23815. +static void ar71xx_spi_cleanup(struct spi_device *spi)
  23816. +{
  23817. + ar71xx_spi_restore_regs(spi);
  23818. + spi_bitbang_cleanup(spi);
  23819. +}
  23820. +
  23821. +static u32 ar71xx_spi_txrx_mode0(struct spi_device *spi, unsigned nsecs,
  23822. + u32 word, u8 bits)
  23823. +{
  23824. + struct ar71xx_spi *sp = spidev_to_sp(spi);
  23825. + void __iomem *base = sp->base;
  23826. + u32 ioc = sp->ioc_base;
  23827. + u32 ret;
  23828. +
  23829. + /* clock starts at inactive polarity */
  23830. + for (word <<= (32 - bits); likely(bits); bits--) {
  23831. + u32 out;
  23832. +
  23833. + if (word & (1 << 31))
  23834. + out = ioc | SPI_IOC_DO;
  23835. + else
  23836. + out = ioc & ~SPI_IOC_DO;
  23837. +
  23838. + /* setup MSB (to slave) on trailing edge */
  23839. + __raw_writel(out, base + SPI_REG_IOC);
  23840. +
  23841. + __raw_writel(out | SPI_IOC_CLK, base + SPI_REG_IOC);
  23842. +
  23843. + word <<= 1;
  23844. +
  23845. +#ifdef PER_BIT_READ
  23846. + /* sample MSB (from slave) on leading edge */
  23847. + ret = __raw_readl(base + SPI_REG_RDS);
  23848. + __raw_writel(out, base + SPI_REG_IOC);
  23849. +#endif
  23850. +
  23851. + }
  23852. +
  23853. +#ifndef PER_BIT_READ
  23854. + ret = __raw_readl(base + SPI_REG_RDS);
  23855. +#endif
  23856. + return ret;
  23857. +}
  23858. +
  23859. +static int ar71xx_spi_probe(struct platform_device *pdev)
  23860. +{
  23861. + struct spi_master *master;
  23862. + struct ar71xx_spi *sp;
  23863. + struct ar71xx_spi_platform_data *pdata;
  23864. + struct resource *r;
  23865. + int ret;
  23866. +
  23867. + master = spi_alloc_master(&pdev->dev, sizeof(*sp));
  23868. + if (master == NULL) {
  23869. + dev_err(&pdev->dev, "failed to allocate spi master\n");
  23870. + return -ENOMEM;
  23871. + }
  23872. +
  23873. + sp = spi_master_get_devdata(master);
  23874. + platform_set_drvdata(pdev, sp);
  23875. +
  23876. + pdata = pdev->dev.platform_data;
  23877. +
  23878. + master->setup = ar71xx_spi_setup;
  23879. + master->cleanup = ar71xx_spi_cleanup;
  23880. +
  23881. + sp->bitbang.master = spi_master_get(master);
  23882. + sp->bitbang.chipselect = ar71xx_spi_chipselect;
  23883. + sp->bitbang.txrx_word[SPI_MODE_0] = ar71xx_spi_txrx_mode0;
  23884. + sp->bitbang.setup_transfer = spi_bitbang_setup_transfer;
  23885. +
  23886. + sp->get_ioc_base = ar71xx_spi_get_ioc_base;
  23887. + if (pdata) {
  23888. + sp->bitbang.master->bus_num = pdata->bus_num;
  23889. + sp->bitbang.master->num_chipselect = pdata->num_chipselect;
  23890. + if (pdata->get_ioc_base)
  23891. + sp->get_ioc_base = pdata->get_ioc_base;
  23892. + } else {
  23893. + sp->bitbang.master->bus_num = 0;
  23894. + sp->bitbang.master->num_chipselect = 3;
  23895. + }
  23896. +
  23897. + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  23898. + if (r == NULL) {
  23899. + ret = -ENOENT;
  23900. + goto err1;
  23901. + }
  23902. +
  23903. + sp->base = ioremap_nocache(r->start, r->end - r->start + 1);
  23904. + if (!sp->base) {
  23905. + ret = -ENXIO;
  23906. + goto err1;
  23907. + }
  23908. +
  23909. + ret = spi_bitbang_start(&sp->bitbang);
  23910. + if (!ret)
  23911. + return 0;
  23912. +
  23913. + iounmap(sp->base);
  23914. + err1:
  23915. + platform_set_drvdata(pdev, NULL);
  23916. + spi_master_put(sp->bitbang.master);
  23917. +
  23918. + return ret;
  23919. +}
  23920. +
  23921. +static int ar71xx_spi_remove(struct platform_device *pdev)
  23922. +{
  23923. + struct ar71xx_spi *sp = platform_get_drvdata(pdev);
  23924. +
  23925. + spi_bitbang_stop(&sp->bitbang);
  23926. + iounmap(sp->base);
  23927. + platform_set_drvdata(pdev, NULL);
  23928. + spi_master_put(sp->bitbang.master);
  23929. +
  23930. + return 0;
  23931. +}
  23932. +
  23933. +static struct platform_driver ar71xx_spi_drv = {
  23934. + .probe = ar71xx_spi_probe,
  23935. + .remove = ar71xx_spi_remove,
  23936. + .driver = {
  23937. + .name = DRV_NAME,
  23938. + .owner = THIS_MODULE,
  23939. + },
  23940. +};
  23941. +
  23942. +static int __init ar71xx_spi_init(void)
  23943. +{
  23944. + printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
  23945. + return platform_driver_register(&ar71xx_spi_drv);
  23946. +}
  23947. +module_init(ar71xx_spi_init);
  23948. +
  23949. +static void __exit ar71xx_spi_exit(void)
  23950. +{
  23951. + platform_driver_unregister(&ar71xx_spi_drv);
  23952. +}
  23953. +module_exit(ar71xx_spi_exit);
  23954. +
  23955. +MODULE_ALIAS("platform:" DRV_NAME);
  23956. +MODULE_DESCRIPTION(DRV_DESC);
  23957. +MODULE_VERSION(DRV_VERSION);
  23958. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  23959. +MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>");
  23960. +MODULE_LICENSE("GPL v2");
  23961. diff -Nur linux-2.6.35.7.orig/drivers/spi/Kconfig linux-2.6.35.7/drivers/spi/Kconfig
  23962. --- linux-2.6.35.7.orig/drivers/spi/Kconfig 2010-09-29 03:09:08.000000000 +0200
  23963. +++ linux-2.6.35.7/drivers/spi/Kconfig 2010-10-14 20:28:01.128101086 +0200
  23964. @@ -53,6 +53,13 @@
  23965. comment "SPI Master Controller Drivers"
  23966. +config SPI_AR71XX
  23967. + tristate "Atheros AR71xx SPI Controller"
  23968. + depends on SPI_MASTER && ATHEROS_AR71XX
  23969. + select SPI_BITBANG
  23970. + help
  23971. + This is the SPI contoller driver for Atheros AR71xx.
  23972. +
  23973. config SPI_ATMEL
  23974. tristate "Atmel SPI Controller"
  23975. depends on (ARCH_AT91 || AVR32)
  23976. diff -Nur linux-2.6.35.7.orig/drivers/spi/Makefile linux-2.6.35.7/drivers/spi/Makefile
  23977. --- linux-2.6.35.7.orig/drivers/spi/Makefile 2010-09-29 03:09:08.000000000 +0200
  23978. +++ linux-2.6.35.7/drivers/spi/Makefile 2010-10-14 20:28:01.168101108 +0200
  23979. @@ -11,6 +11,7 @@
  23980. obj-$(CONFIG_SPI_MASTER) += spi.o
  23981. # SPI master controller drivers (bus)
  23982. +obj-$(CONFIG_SPI_AR71XX) += ar71xx_spi.o
  23983. obj-$(CONFIG_SPI_ATMEL) += atmel_spi.o
  23984. obj-$(CONFIG_SPI_BFIN) += spi_bfin5xx.o
  23985. obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o
  23986. diff -Nur linux-2.6.35.7.orig/drivers/spi/pb44_spi.c linux-2.6.35.7/drivers/spi/pb44_spi.c
  23987. --- linux-2.6.35.7.orig/drivers/spi/pb44_spi.c 1970-01-01 01:00:00.000000000 +0100
  23988. +++ linux-2.6.35.7/drivers/spi/pb44_spi.c 2010-10-14 20:28:01.205601089 +0200
  23989. @@ -0,0 +1,299 @@
  23990. +/*
  23991. + * Atheros PB44 board SPI controller driver
  23992. + *
  23993. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  23994. + *
  23995. + * This program is free software; you can redistribute it and/or modify
  23996. + * it under the terms of the GNU General Public License version 2 as
  23997. + * published by the Free Software Foundation.
  23998. + *
  23999. + */
  24000. +
  24001. +#include <linux/kernel.h>
  24002. +#include <linux/init.h>
  24003. +#include <linux/delay.h>
  24004. +#include <linux/spinlock.h>
  24005. +#include <linux/workqueue.h>
  24006. +#include <linux/platform_device.h>
  24007. +#include <linux/io.h>
  24008. +#include <linux/spi/spi.h>
  24009. +#include <linux/spi/spi_bitbang.h>
  24010. +#include <linux/bitops.h>
  24011. +#include <linux/gpio.h>
  24012. +
  24013. +#include <asm/mach-ar71xx/ar71xx.h>
  24014. +#include <asm/mach-ar71xx/platform.h>
  24015. +
  24016. +#define DRV_DESC "Atheros PB44 SPI Controller driver"
  24017. +#define DRV_VERSION "0.1.0"
  24018. +#define DRV_NAME "pb44-spi"
  24019. +
  24020. +#undef PER_BIT_READ
  24021. +
  24022. +struct ar71xx_spi {
  24023. + struct spi_bitbang bitbang;
  24024. + u32 ioc_base;
  24025. + u32 reg_ctrl;
  24026. +
  24027. + void __iomem *base;
  24028. +
  24029. + struct platform_device *pdev;
  24030. +};
  24031. +
  24032. +static inline u32 pb44_spi_rr(struct ar71xx_spi *sp, unsigned reg)
  24033. +{
  24034. + return __raw_readl(sp->base + reg);
  24035. +}
  24036. +
  24037. +static inline void pb44_spi_wr(struct ar71xx_spi *sp, unsigned reg, u32 val)
  24038. +{
  24039. + __raw_writel(val, sp->base + reg);
  24040. +}
  24041. +
  24042. +static inline struct ar71xx_spi *spidev_to_sp(struct spi_device *spi)
  24043. +{
  24044. + return spi_master_get_devdata(spi->master);
  24045. +}
  24046. +
  24047. +static void pb44_spi_chipselect(struct spi_device *spi, int is_active)
  24048. +{
  24049. + struct ar71xx_spi *sp = spidev_to_sp(spi);
  24050. + int cs_high = (spi->mode & SPI_CS_HIGH) ? is_active : !is_active;
  24051. +
  24052. + if (is_active) {
  24053. + /* set initial clock polarity */
  24054. + if (spi->mode & SPI_CPOL)
  24055. + sp->ioc_base |= SPI_IOC_CLK;
  24056. + else
  24057. + sp->ioc_base &= ~SPI_IOC_CLK;
  24058. +
  24059. + pb44_spi_wr(sp, SPI_REG_IOC, sp->ioc_base);
  24060. + }
  24061. +
  24062. + if (spi->chip_select) {
  24063. + unsigned long gpio = (unsigned long) spi->controller_data;
  24064. +
  24065. + /* SPI is normally active-low */
  24066. + gpio_set_value(gpio, cs_high);
  24067. + } else {
  24068. + if (cs_high)
  24069. + sp->ioc_base |= SPI_IOC_CS0;
  24070. + else
  24071. + sp->ioc_base &= ~SPI_IOC_CS0;
  24072. +
  24073. + pb44_spi_wr(sp, SPI_REG_IOC, sp->ioc_base);
  24074. + }
  24075. +
  24076. +}
  24077. +
  24078. +static int pb44_spi_setup_cs(struct spi_device *spi)
  24079. +{
  24080. + struct ar71xx_spi *sp = spidev_to_sp(spi);
  24081. +
  24082. + /* enable GPIO mode */
  24083. + pb44_spi_wr(sp, SPI_REG_FS, SPI_FS_GPIO);
  24084. +
  24085. + /* save CTRL register */
  24086. + sp->reg_ctrl = pb44_spi_rr(sp, SPI_REG_CTRL);
  24087. + sp->ioc_base = pb44_spi_rr(sp, SPI_REG_IOC);
  24088. +
  24089. + /* TODO: setup speed? */
  24090. + pb44_spi_wr(sp, SPI_REG_CTRL, 0x43);
  24091. +
  24092. + if (spi->chip_select) {
  24093. + unsigned long gpio = (unsigned long) spi->controller_data;
  24094. + int status = 0;
  24095. +
  24096. + status = gpio_request(gpio, dev_name(&spi->dev));
  24097. + if (status)
  24098. + return status;
  24099. +
  24100. + status = gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH);
  24101. + if (status) {
  24102. + gpio_free(gpio);
  24103. + return status;
  24104. + }
  24105. + } else {
  24106. + if (spi->mode & SPI_CS_HIGH)
  24107. + sp->ioc_base |= SPI_IOC_CS0;
  24108. + else
  24109. + sp->ioc_base &= ~SPI_IOC_CS0;
  24110. + pb44_spi_wr(sp, SPI_REG_IOC, sp->ioc_base);
  24111. + }
  24112. +
  24113. + return 0;
  24114. +}
  24115. +
  24116. +static void pb44_spi_cleanup_cs(struct spi_device *spi)
  24117. +{
  24118. + struct ar71xx_spi *sp = spidev_to_sp(spi);
  24119. +
  24120. + if (spi->chip_select) {
  24121. + unsigned long gpio = (unsigned long) spi->controller_data;
  24122. + gpio_free(gpio);
  24123. + }
  24124. +
  24125. + /* restore CTRL register */
  24126. + pb44_spi_wr(sp, SPI_REG_CTRL, sp->reg_ctrl);
  24127. + /* disable GPIO mode */
  24128. + pb44_spi_wr(sp, SPI_REG_FS, 0);
  24129. +}
  24130. +
  24131. +static int pb44_spi_setup(struct spi_device *spi)
  24132. +{
  24133. + int status = 0;
  24134. +
  24135. + if (spi->bits_per_word > 32)
  24136. + return -EINVAL;
  24137. +
  24138. + if (!spi->controller_state) {
  24139. + status = pb44_spi_setup_cs(spi);
  24140. + if (status)
  24141. + return status;
  24142. + }
  24143. +
  24144. + status = spi_bitbang_setup(spi);
  24145. + if (status && !spi->controller_state)
  24146. + pb44_spi_cleanup_cs(spi);
  24147. +
  24148. + return status;
  24149. +}
  24150. +
  24151. +static void pb44_spi_cleanup(struct spi_device *spi)
  24152. +{
  24153. + pb44_spi_cleanup_cs(spi);
  24154. + spi_bitbang_cleanup(spi);
  24155. +}
  24156. +
  24157. +static u32 pb44_spi_txrx_mode0(struct spi_device *spi, unsigned nsecs,
  24158. + u32 word, u8 bits)
  24159. +{
  24160. + struct ar71xx_spi *sp = spidev_to_sp(spi);
  24161. + u32 ioc = sp->ioc_base;
  24162. + u32 ret;
  24163. +
  24164. + /* clock starts at inactive polarity */
  24165. + for (word <<= (32 - bits); likely(bits); bits--) {
  24166. + u32 out;
  24167. +
  24168. + if (word & (1 << 31))
  24169. + out = ioc | SPI_IOC_DO;
  24170. + else
  24171. + out = ioc & ~SPI_IOC_DO;
  24172. +
  24173. + /* setup MSB (to slave) on trailing edge */
  24174. + pb44_spi_wr(sp, SPI_REG_IOC, out);
  24175. + pb44_spi_wr(sp, SPI_REG_IOC, out | SPI_IOC_CLK);
  24176. +
  24177. + word <<= 1;
  24178. +
  24179. +#ifdef PER_BIT_READ
  24180. + /* sample MSB (from slave) on leading edge */
  24181. + ret = pb44_spi_rr(sp, SPI_REG_RDS);
  24182. + pb44_spi_wr(sp, SPI_REG_IOC, out);
  24183. +#endif
  24184. + }
  24185. +
  24186. +#ifndef PER_BIT_READ
  24187. + ret = pb44_spi_rr(sp, SPI_REG_RDS);
  24188. +#endif
  24189. + return ret;
  24190. +}
  24191. +
  24192. +static int pb44_spi_probe(struct platform_device *pdev)
  24193. +{
  24194. + struct spi_master *master;
  24195. + struct ar71xx_spi *sp;
  24196. + struct ar71xx_spi_platform_data *pdata;
  24197. + struct resource *r;
  24198. + int ret;
  24199. +
  24200. + master = spi_alloc_master(&pdev->dev, sizeof(*sp));
  24201. + if (master == NULL) {
  24202. + dev_err(&pdev->dev, "failed to allocate spi master\n");
  24203. + return -ENOMEM;
  24204. + }
  24205. +
  24206. + sp = spi_master_get_devdata(master);
  24207. + platform_set_drvdata(pdev, sp);
  24208. +
  24209. + pdata = pdev->dev.platform_data;
  24210. +
  24211. + master->setup = pb44_spi_setup;
  24212. + master->cleanup = pb44_spi_cleanup;
  24213. + if (pdata) {
  24214. + master->bus_num = pdata->bus_num;
  24215. + master->num_chipselect = pdata->num_chipselect;
  24216. + } else {
  24217. + master->bus_num = 0;
  24218. + master->num_chipselect = 1;
  24219. + }
  24220. +
  24221. + sp->bitbang.master = spi_master_get(master);
  24222. + sp->bitbang.chipselect = pb44_spi_chipselect;
  24223. + sp->bitbang.txrx_word[SPI_MODE_0] = pb44_spi_txrx_mode0;
  24224. + sp->bitbang.setup_transfer = spi_bitbang_setup_transfer;
  24225. + sp->bitbang.flags = SPI_CS_HIGH;
  24226. +
  24227. + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  24228. + if (r == NULL) {
  24229. + ret = -ENOENT;
  24230. + goto err1;
  24231. + }
  24232. +
  24233. + sp->base = ioremap_nocache(r->start, r->end - r->start + 1);
  24234. + if (!sp->base) {
  24235. + ret = -ENXIO;
  24236. + goto err1;
  24237. + }
  24238. +
  24239. + ret = spi_bitbang_start(&sp->bitbang);
  24240. + if (!ret)
  24241. + return 0;
  24242. +
  24243. + iounmap(sp->base);
  24244. + err1:
  24245. + platform_set_drvdata(pdev, NULL);
  24246. + spi_master_put(sp->bitbang.master);
  24247. +
  24248. + return ret;
  24249. +}
  24250. +
  24251. +static int pb44_spi_remove(struct platform_device *pdev)
  24252. +{
  24253. + struct ar71xx_spi *sp = platform_get_drvdata(pdev);
  24254. +
  24255. + spi_bitbang_stop(&sp->bitbang);
  24256. + iounmap(sp->base);
  24257. + platform_set_drvdata(pdev, NULL);
  24258. + spi_master_put(sp->bitbang.master);
  24259. +
  24260. + return 0;
  24261. +}
  24262. +
  24263. +static struct platform_driver pb44_spi_drv = {
  24264. + .probe = pb44_spi_probe,
  24265. + .remove = pb44_spi_remove,
  24266. + .driver = {
  24267. + .name = DRV_NAME,
  24268. + .owner = THIS_MODULE,
  24269. + },
  24270. +};
  24271. +
  24272. +static int __init pb44_spi_init(void)
  24273. +{
  24274. + return platform_driver_register(&pb44_spi_drv);
  24275. +}
  24276. +module_init(pb44_spi_init);
  24277. +
  24278. +static void __exit pb44_spi_exit(void)
  24279. +{
  24280. + platform_driver_unregister(&pb44_spi_drv);
  24281. +}
  24282. +module_exit(pb44_spi_exit);
  24283. +
  24284. +MODULE_ALIAS("platform:" DRV_NAME);
  24285. +MODULE_DESCRIPTION(DRV_DESC);
  24286. +MODULE_VERSION(DRV_VERSION);
  24287. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  24288. +MODULE_LICENSE("GPL v2");
  24289. diff -Nur linux-2.6.35.7.orig/drivers/spi/spi_vsc7385.c linux-2.6.35.7/drivers/spi/spi_vsc7385.c
  24290. --- linux-2.6.35.7.orig/drivers/spi/spi_vsc7385.c 1970-01-01 01:00:00.000000000 +0100
  24291. +++ linux-2.6.35.7/drivers/spi/spi_vsc7385.c 2010-10-14 20:28:01.238101190 +0200
  24292. @@ -0,0 +1,620 @@
  24293. +/*
  24294. + * SPI driver for the Vitesse VSC7385 ethernet switch
  24295. + *
  24296. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  24297. + *
  24298. + * Parts of this file are based on Atheros' 2.6.15 BSP
  24299. + *
  24300. + * This program is free software; you can redistribute it and/or modify it
  24301. + * under the terms of the GNU General Public License version 2 as published
  24302. + * by the Free Software Foundation.
  24303. + */
  24304. +
  24305. +#include <linux/types.h>
  24306. +#include <linux/kernel.h>
  24307. +#include <linux/init.h>
  24308. +#include <linux/module.h>
  24309. +#include <linux/delay.h>
  24310. +#include <linux/device.h>
  24311. +#include <linux/bitops.h>
  24312. +#include <linux/firmware.h>
  24313. +#include <linux/spi/spi.h>
  24314. +#include <linux/spi/vsc7385.h>
  24315. +
  24316. +#define DRV_NAME "spi-vsc7385"
  24317. +#define DRV_DESC "Vitesse VSC7385 Gbit ethernet switch driver"
  24318. +#define DRV_VERSION "0.1.0"
  24319. +
  24320. +#define VSC73XX_BLOCK_MAC 0x1
  24321. +#define VSC73XX_BLOCK_2 0x2
  24322. +#define VSC73XX_BLOCK_MII 0x3
  24323. +#define VSC73XX_BLOCK_4 0x4
  24324. +#define VSC73XX_BLOCK_5 0x5
  24325. +#define VSC73XX_BLOCK_SYSTEM 0x7
  24326. +
  24327. +#define VSC73XX_SUBBLOCK_PORT_0 0
  24328. +#define VSC73XX_SUBBLOCK_PORT_1 1
  24329. +#define VSC73XX_SUBBLOCK_PORT_2 2
  24330. +#define VSC73XX_SUBBLOCK_PORT_3 3
  24331. +#define VSC73XX_SUBBLOCK_PORT_4 4
  24332. +#define VSC73XX_SUBBLOCK_PORT_MAC 6
  24333. +
  24334. +/* MAC Block registers */
  24335. +#define VSC73XX_MAC_CFG 0x0
  24336. +#define VSC73XX_ADVPORTM 0x19
  24337. +#define VSC73XX_RXOCT 0x50
  24338. +#define VSC73XX_TXOCT 0x51
  24339. +#define VSC73XX_C_RX0 0x52
  24340. +#define VSC73XX_C_RX1 0x53
  24341. +#define VSC73XX_C_RX2 0x54
  24342. +#define VSC73XX_C_TX0 0x55
  24343. +#define VSC73XX_C_TX1 0x56
  24344. +#define VSC73XX_C_TX2 0x57
  24345. +#define VSC73XX_C_CFG 0x58
  24346. +
  24347. +/* MAC_CFG register bits */
  24348. +#define VSC73XX_MAC_CFG_WEXC_DIS (1 << 31)
  24349. +#define VSC73XX_MAC_CFG_PORT_RST (1 << 29)
  24350. +#define VSC73XX_MAC_CFG_TX_EN (1 << 28)
  24351. +#define VSC73XX_MAC_CFG_SEED_LOAD (1 << 27)
  24352. +#define VSC73XX_MAC_CFG_FDX (1 << 18)
  24353. +#define VSC73XX_MAC_CFG_GIGE (1 << 17)
  24354. +#define VSC73XX_MAC_CFG_RX_EN (1 << 16)
  24355. +#define VSC73XX_MAC_CFG_VLAN_DBLAWR (1 << 15)
  24356. +#define VSC73XX_MAC_CFG_VLAN_AWR (1 << 14)
  24357. +#define VSC73XX_MAC_CFG_100_BASE_T (1 << 13)
  24358. +#define VSC73XX_MAC_CFG_TX_IPG(x) (((x) & 0x1f) << 6)
  24359. +#define VSC73XX_MAC_CFG_MAC_RX_RST (1 << 5)
  24360. +#define VSC73XX_MAC_CFG_MAC_TX_RST (1 << 4)
  24361. +#define VSC73XX_MAC_CFG_BIT2 (1 << 2)
  24362. +#define VSC73XX_MAC_CFG_CLK_SEL(x) ((x) & 0x3)
  24363. +
  24364. +/* ADVPORTM register bits */
  24365. +#define VSC73XX_ADVPORTM_IFG_PPM (1 << 7)
  24366. +#define VSC73XX_ADVPORTM_EXC_COL_CONT (1 << 6)
  24367. +#define VSC73XX_ADVPORTM_EXT_PORT (1 << 5)
  24368. +#define VSC73XX_ADVPORTM_INV_GTX (1 << 4)
  24369. +#define VSC73XX_ADVPORTM_ENA_GTX (1 << 3)
  24370. +#define VSC73XX_ADVPORTM_DDR_MODE (1 << 2)
  24371. +#define VSC73XX_ADVPORTM_IO_LOOPBACK (1 << 1)
  24372. +#define VSC73XX_ADVPORTM_HOST_LOOPBACK (1 << 0)
  24373. +
  24374. +/* MII Block registers */
  24375. +#define VSC73XX_MII_STAT 0x0
  24376. +#define VSC73XX_MII_CMD 0x1
  24377. +#define VSC73XX_MII_DATA 0x2
  24378. +
  24379. +/* System Block registers */
  24380. +#define VSC73XX_ICPU_SIPAD 0x01
  24381. +#define VSC73XX_ICPU_CLOCK_DELAY 0x05
  24382. +#define VSC73XX_ICPU_CTRL 0x10
  24383. +#define VSC73XX_ICPU_ADDR 0x11
  24384. +#define VSC73XX_ICPU_SRAM 0x12
  24385. +#define VSC73XX_ICPU_MBOX_VAL 0x15
  24386. +#define VSC73XX_ICPU_MBOX_SET 0x16
  24387. +#define VSC73XX_ICPU_MBOX_CLR 0x17
  24388. +#define VSC73XX_ICPU_CHIPID 0x18
  24389. +#define VSC73XX_ICPU_GPIO 0x34
  24390. +
  24391. +#define VSC73XX_ICPU_CTRL_CLK_DIV (1 << 8)
  24392. +#define VSC73XX_ICPU_CTRL_SRST_HOLD (1 << 7)
  24393. +#define VSC73XX_ICPU_CTRL_BOOT_EN (1 << 3)
  24394. +#define VSC73XX_ICPU_CTRL_EXT_ACC_EN (1 << 2)
  24395. +#define VSC73XX_ICPU_CTRL_CLK_EN (1 << 1)
  24396. +#define VSC73XX_ICPU_CTRL_SRST (1 << 0)
  24397. +
  24398. +#define VSC73XX_ICPU_CHIPID_ID_SHIFT 12
  24399. +#define VSC73XX_ICPU_CHIPID_ID_MASK 0xffff
  24400. +#define VSC73XX_ICPU_CHIPID_REV_SHIFT 28
  24401. +#define VSC73XX_ICPU_CHIPID_REV_MASK 0xf
  24402. +#define VSC73XX_ICPU_CHIPID_ID_7385 0x7385
  24403. +#define VSC73XX_ICPU_CHIPID_ID_7395 0x7395
  24404. +
  24405. +#define VSC73XX_CMD_MODE_READ 0
  24406. +#define VSC73XX_CMD_MODE_WRITE 1
  24407. +#define VSC73XX_CMD_MODE_SHIFT 4
  24408. +#define VSC73XX_CMD_BLOCK_SHIFT 5
  24409. +#define VSC73XX_CMD_BLOCK_MASK 0x7
  24410. +#define VSC73XX_CMD_SUBBLOCK_MASK 0xf
  24411. +
  24412. +#define VSC7385_CLOCK_DELAY ((3 << 4) | 3)
  24413. +#define VSC7385_CLOCK_DELAY_MASK ((3 << 4) | 3)
  24414. +
  24415. +#define VSC73XX_ICPU_CTRL_STOP (VSC73XX_ICPU_CTRL_SRST_HOLD | \
  24416. + VSC73XX_ICPU_CTRL_BOOT_EN | \
  24417. + VSC73XX_ICPU_CTRL_EXT_ACC_EN)
  24418. +
  24419. +#define VSC73XX_ICPU_CTRL_START (VSC73XX_ICPU_CTRL_CLK_DIV | \
  24420. + VSC73XX_ICPU_CTRL_BOOT_EN | \
  24421. + VSC73XX_ICPU_CTRL_CLK_EN | \
  24422. + VSC73XX_ICPU_CTRL_SRST)
  24423. +
  24424. +#define VSC7385_ADVPORTM_MASK (VSC73XX_ADVPORTM_IFG_PPM | \
  24425. + VSC73XX_ADVPORTM_EXC_COL_CONT | \
  24426. + VSC73XX_ADVPORTM_EXT_PORT | \
  24427. + VSC73XX_ADVPORTM_INV_GTX | \
  24428. + VSC73XX_ADVPORTM_ENA_GTX | \
  24429. + VSC73XX_ADVPORTM_DDR_MODE | \
  24430. + VSC73XX_ADVPORTM_IO_LOOPBACK | \
  24431. + VSC73XX_ADVPORTM_HOST_LOOPBACK)
  24432. +
  24433. +#define VSC7385_ADVPORTM_INIT (VSC73XX_ADVPORTM_EXT_PORT | \
  24434. + VSC73XX_ADVPORTM_ENA_GTX | \
  24435. + VSC73XX_ADVPORTM_DDR_MODE)
  24436. +
  24437. +#define VSC7385_MAC_CFG_RESET (VSC73XX_MAC_CFG_PORT_RST | \
  24438. + VSC73XX_MAC_CFG_MAC_RX_RST | \
  24439. + VSC73XX_MAC_CFG_MAC_TX_RST)
  24440. +
  24441. +#define VSC73XX_MAC_CFG_INIT (VSC73XX_MAC_CFG_TX_EN | \
  24442. + VSC73XX_MAC_CFG_FDX | \
  24443. + VSC73XX_MAC_CFG_GIGE | \
  24444. + VSC73XX_MAC_CFG_RX_EN)
  24445. +
  24446. +#define VSC73XX_RESET_DELAY 100
  24447. +
  24448. +struct vsc7385 {
  24449. + struct spi_device *spi;
  24450. + struct mutex lock;
  24451. + struct vsc7385_platform_data *pdata;
  24452. +};
  24453. +
  24454. +static int vsc7385_is_addr_valid(u8 block, u8 subblock)
  24455. +{
  24456. + switch (block) {
  24457. + case VSC73XX_BLOCK_MAC:
  24458. + switch (subblock) {
  24459. + case 0 ... 4:
  24460. + case 6:
  24461. + return 1;
  24462. + }
  24463. + break;
  24464. +
  24465. + case VSC73XX_BLOCK_2:
  24466. + case VSC73XX_BLOCK_SYSTEM:
  24467. + switch (subblock) {
  24468. + case 0:
  24469. + return 1;
  24470. + }
  24471. + break;
  24472. +
  24473. + case VSC73XX_BLOCK_MII:
  24474. + case VSC73XX_BLOCK_4:
  24475. + case VSC73XX_BLOCK_5:
  24476. + switch (subblock) {
  24477. + case 0 ... 1:
  24478. + return 1;
  24479. + }
  24480. + break;
  24481. + }
  24482. +
  24483. + return 0;
  24484. +}
  24485. +
  24486. +static inline u8 vsc7385_make_addr(u8 mode, u8 block, u8 subblock)
  24487. +{
  24488. + u8 ret;
  24489. +
  24490. + ret = (block & VSC73XX_CMD_BLOCK_MASK) << VSC73XX_CMD_BLOCK_SHIFT;
  24491. + ret |= (mode & 1) << VSC73XX_CMD_MODE_SHIFT;
  24492. + ret |= subblock & VSC73XX_CMD_SUBBLOCK_MASK;
  24493. +
  24494. + return ret;
  24495. +}
  24496. +
  24497. +static int vsc7385_read(struct vsc7385 *vsc, u8 block, u8 subblock, u8 reg,
  24498. + u32 *value)
  24499. +{
  24500. + u8 cmd[4];
  24501. + u8 buf[4];
  24502. + struct spi_transfer t[2];
  24503. + struct spi_message m;
  24504. + int err;
  24505. +
  24506. + if (!vsc7385_is_addr_valid(block, subblock))
  24507. + return -EINVAL;
  24508. +
  24509. + spi_message_init(&m);
  24510. +
  24511. + memset(&t, 0, sizeof(t));
  24512. +
  24513. + t[0].tx_buf = cmd;
  24514. + t[0].len = sizeof(cmd);
  24515. + spi_message_add_tail(&t[0], &m);
  24516. +
  24517. + t[1].rx_buf = buf;
  24518. + t[1].len = sizeof(buf);
  24519. + spi_message_add_tail(&t[1], &m);
  24520. +
  24521. + cmd[0] = vsc7385_make_addr(VSC73XX_CMD_MODE_READ, block, subblock);
  24522. + cmd[1] = reg;
  24523. + cmd[2] = 0;
  24524. + cmd[3] = 0;
  24525. +
  24526. + mutex_lock(&vsc->lock);
  24527. + err = spi_sync(vsc->spi, &m);
  24528. + mutex_unlock(&vsc->lock);
  24529. +
  24530. + if (err)
  24531. + return err;
  24532. +
  24533. + *value = (((u32) buf[0]) << 24) | (((u32) buf[1]) << 16) |
  24534. + (((u32) buf[2]) << 8) | ((u32) buf[3]);
  24535. +
  24536. + return 0;
  24537. +}
  24538. +
  24539. +
  24540. +static int vsc7385_write(struct vsc7385 *vsc, u8 block, u8 subblock, u8 reg,
  24541. + u32 value)
  24542. +{
  24543. + u8 cmd[2];
  24544. + u8 buf[4];
  24545. + struct spi_transfer t[2];
  24546. + struct spi_message m;
  24547. + int err;
  24548. +
  24549. + if (!vsc7385_is_addr_valid(block, subblock))
  24550. + return -EINVAL;
  24551. +
  24552. + spi_message_init(&m);
  24553. +
  24554. + memset(&t, 0, sizeof(t));
  24555. +
  24556. + t[0].tx_buf = cmd;
  24557. + t[0].len = sizeof(cmd);
  24558. + spi_message_add_tail(&t[0], &m);
  24559. +
  24560. + t[1].tx_buf = buf;
  24561. + t[1].len = sizeof(buf);
  24562. + spi_message_add_tail(&t[1], &m);
  24563. +
  24564. + cmd[0] = vsc7385_make_addr(VSC73XX_CMD_MODE_WRITE, block, subblock);
  24565. + cmd[1] = reg;
  24566. +
  24567. + buf[0] = (value >> 24) & 0xff;
  24568. + buf[1] = (value >> 16) & 0xff;
  24569. + buf[2] = (value >> 8) & 0xff;
  24570. + buf[3] = value & 0xff;
  24571. +
  24572. + mutex_lock(&vsc->lock);
  24573. + err = spi_sync(vsc->spi, &m);
  24574. + mutex_unlock(&vsc->lock);
  24575. +
  24576. + return err;
  24577. +}
  24578. +
  24579. +static inline int vsc7385_write_verify(struct vsc7385 *vsc, u8 block,
  24580. + u8 subblock, u8 reg, u32 value,
  24581. + u32 read_mask, u32 read_val)
  24582. +{
  24583. + struct spi_device *spi = vsc->spi;
  24584. + u32 t;
  24585. + int err;
  24586. +
  24587. + err = vsc7385_write(vsc, block, subblock, reg, value);
  24588. + if (err)
  24589. + return err;
  24590. +
  24591. + err = vsc7385_read(vsc, block, subblock, reg, &t);
  24592. + if (err)
  24593. + return err;
  24594. +
  24595. + if ((t & read_mask) != read_val) {
  24596. + dev_err(&spi->dev, "register write error\n");
  24597. + return -EIO;
  24598. + }
  24599. +
  24600. + return 0;
  24601. +}
  24602. +
  24603. +static inline int vsc7385_set_clock_delay(struct vsc7385 *vsc, u32 val)
  24604. +{
  24605. + return vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  24606. + VSC73XX_ICPU_CLOCK_DELAY, val);
  24607. +}
  24608. +
  24609. +static inline int vsc7385_get_clock_delay(struct vsc7385 *vsc, u32 *val)
  24610. +{
  24611. + return vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  24612. + VSC73XX_ICPU_CLOCK_DELAY, val);
  24613. +}
  24614. +
  24615. +static inline int vsc7385_icpu_stop(struct vsc7385 *vsc)
  24616. +{
  24617. + return vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_ICPU_CTRL,
  24618. + VSC73XX_ICPU_CTRL_STOP);
  24619. +}
  24620. +
  24621. +static inline int vsc7385_icpu_start(struct vsc7385 *vsc)
  24622. +{
  24623. + return vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_ICPU_CTRL,
  24624. + VSC73XX_ICPU_CTRL_START);
  24625. +}
  24626. +
  24627. +static inline int vsc7385_icpu_reset(struct vsc7385 *vsc)
  24628. +{
  24629. + int rc;
  24630. +
  24631. + rc = vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_ICPU_ADDR,
  24632. + 0x0000);
  24633. + if (rc)
  24634. + dev_err(&vsc->spi->dev,
  24635. + "could not reset microcode, err=%d\n", rc);
  24636. +
  24637. + return rc;
  24638. +}
  24639. +
  24640. +static int vsc7385_upload_ucode(struct vsc7385 *vsc)
  24641. +{
  24642. + struct spi_device *spi = vsc->spi;
  24643. + const struct firmware *firmware;
  24644. + char *ucode_name;
  24645. + unsigned char *dp;
  24646. + unsigned int curVal;
  24647. + int i;
  24648. + int diffs;
  24649. + int rc;
  24650. +
  24651. + ucode_name = (vsc->pdata->ucode_name) ? vsc->pdata->ucode_name
  24652. + : "vsc7385_ucode.bin";
  24653. + rc = request_firmware(&firmware, ucode_name, &spi->dev);
  24654. + if (rc) {
  24655. + dev_err(&spi->dev, "request_firmware failed, err=%d\n",
  24656. + rc);
  24657. + return rc;
  24658. + }
  24659. +
  24660. + rc = vsc7385_icpu_stop(vsc);
  24661. + if (rc)
  24662. + goto out;
  24663. +
  24664. + rc = vsc7385_icpu_reset(vsc);
  24665. + if (rc)
  24666. + goto out;
  24667. +
  24668. + dev_info(&spi->dev, "uploading microcode...\n");
  24669. +
  24670. + dp = (unsigned char *) firmware->data;
  24671. + for (i = 0; i < firmware->size; i++) {
  24672. + rc = vsc7385_write(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  24673. + VSC73XX_ICPU_SRAM, *dp++);
  24674. + if (rc) {
  24675. + dev_err(&spi->dev, "could not load microcode, err=%d\n",
  24676. + rc);
  24677. + goto out;
  24678. + }
  24679. + }
  24680. +
  24681. + rc = vsc7385_icpu_reset(vsc);
  24682. + if (rc)
  24683. + goto out;
  24684. +
  24685. + dev_info(&spi->dev, "verifying microcode...\n");
  24686. +
  24687. + dp = (unsigned char *) firmware->data;
  24688. + diffs = 0;
  24689. + for (i = 0; i < firmware->size; i++) {
  24690. + rc = vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  24691. + VSC73XX_ICPU_SRAM, &curVal);
  24692. + if (rc) {
  24693. + dev_err(&spi->dev, "could not read microcode %d\n",rc);
  24694. + goto out;
  24695. + }
  24696. +
  24697. + if (curVal > 0xff) {
  24698. + dev_err(&spi->dev, "bad val read: %04x : %02x %02x\n",
  24699. + i, *dp, curVal);
  24700. + rc = -EIO;
  24701. + goto out;
  24702. + }
  24703. +
  24704. + if ((curVal & 0xff) != *dp) {
  24705. + diffs++;
  24706. + dev_err(&spi->dev, "verify error: %04x : %02x %02x\n",
  24707. + i, *dp, curVal);
  24708. +
  24709. + if (diffs > 4)
  24710. + break;
  24711. + }
  24712. + dp++;
  24713. + }
  24714. +
  24715. + if (diffs) {
  24716. + dev_err(&spi->dev, "microcode verification failed\n");
  24717. + rc = -EIO;
  24718. + goto out;
  24719. + }
  24720. +
  24721. + dev_info(&spi->dev, "microcode uploaded\n");
  24722. +
  24723. + rc = vsc7385_icpu_start(vsc);
  24724. +
  24725. + out:
  24726. + release_firmware(firmware);
  24727. + return rc;
  24728. +}
  24729. +
  24730. +static int vsc7385_setup(struct vsc7385 *vsc)
  24731. +{
  24732. + struct vsc7385_platform_data *pdata = vsc->pdata;
  24733. + u32 t;
  24734. + int err;
  24735. +
  24736. + err = vsc7385_write_verify(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  24737. + VSC73XX_ICPU_CLOCK_DELAY,
  24738. + VSC7385_CLOCK_DELAY,
  24739. + VSC7385_CLOCK_DELAY_MASK,
  24740. + VSC7385_CLOCK_DELAY);
  24741. + if (err)
  24742. + goto err;
  24743. +
  24744. + err = vsc7385_write_verify(vsc, VSC73XX_BLOCK_MAC,
  24745. + VSC73XX_SUBBLOCK_PORT_MAC, VSC73XX_ADVPORTM,
  24746. + VSC7385_ADVPORTM_INIT,
  24747. + VSC7385_ADVPORTM_MASK,
  24748. + VSC7385_ADVPORTM_INIT);
  24749. + if (err)
  24750. + goto err;
  24751. +
  24752. + err = vsc7385_write(vsc, VSC73XX_BLOCK_MAC, VSC73XX_SUBBLOCK_PORT_MAC,
  24753. + VSC73XX_MAC_CFG, VSC7385_MAC_CFG_RESET);
  24754. + if (err)
  24755. + goto err;
  24756. +
  24757. + t = VSC73XX_MAC_CFG_INIT;
  24758. + t |= VSC73XX_MAC_CFG_TX_IPG(pdata->mac_cfg.tx_ipg);
  24759. + t |= VSC73XX_MAC_CFG_CLK_SEL(pdata->mac_cfg.clk_sel);
  24760. + if (pdata->mac_cfg.bit2)
  24761. + t |= VSC73XX_MAC_CFG_BIT2;
  24762. +
  24763. + err = vsc7385_write(vsc, VSC73XX_BLOCK_MAC, VSC73XX_SUBBLOCK_PORT_MAC,
  24764. + VSC73XX_MAC_CFG, t);
  24765. + if (err)
  24766. + goto err;
  24767. +
  24768. + return 0;
  24769. +
  24770. + err:
  24771. + return err;
  24772. +}
  24773. +
  24774. +static int vsc7385_detect(struct vsc7385 *vsc)
  24775. +{
  24776. + struct spi_device *spi = vsc->spi;
  24777. + u32 t;
  24778. + u32 id;
  24779. + u32 rev;
  24780. + int err;
  24781. +
  24782. + err = vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  24783. + VSC73XX_ICPU_MBOX_VAL, &t);
  24784. + if (err) {
  24785. + dev_err(&spi->dev, "unable to read mailbox, err=%d\n", err);
  24786. + return err;
  24787. + }
  24788. +
  24789. + if (t == 0xffffffff) {
  24790. + dev_dbg(&spi->dev, "assert chip reset\n");
  24791. + if (vsc->pdata->reset)
  24792. + vsc->pdata->reset();
  24793. +
  24794. + }
  24795. +
  24796. + err = vsc7385_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
  24797. + VSC73XX_ICPU_CHIPID, &t);
  24798. + if (err) {
  24799. + dev_err(&spi->dev, "unable to read chip id, err=%d\n", err);
  24800. + return err;
  24801. + }
  24802. +
  24803. + id = (t >> VSC73XX_ICPU_CHIPID_ID_SHIFT) & VSC73XX_ICPU_CHIPID_ID_MASK;
  24804. + switch (id) {
  24805. + case VSC73XX_ICPU_CHIPID_ID_7385:
  24806. + case VSC73XX_ICPU_CHIPID_ID_7395:
  24807. + break;
  24808. + default:
  24809. + dev_err(&spi->dev, "unsupported chip, id=%04x\n", id);
  24810. + return -ENODEV;
  24811. + }
  24812. +
  24813. + rev = (t >> VSC73XX_ICPU_CHIPID_REV_SHIFT) &
  24814. + VSC73XX_ICPU_CHIPID_REV_MASK;
  24815. + dev_info(&spi->dev, "VSC%04X (rev. %d) switch found \n", id, rev);
  24816. +
  24817. + return 0;
  24818. +}
  24819. +
  24820. +static int __devinit vsc7385_probe(struct spi_device *spi)
  24821. +{
  24822. + struct vsc7385 *vsc;
  24823. + struct vsc7385_platform_data *pdata;
  24824. + int err;
  24825. +
  24826. + printk(KERN_INFO DRV_DESC " version " DRV_VERSION"\n");
  24827. +
  24828. + pdata = spi->dev.platform_data;
  24829. + if (!pdata) {
  24830. + dev_err(&spi->dev, "no platform data specified\n");
  24831. + return-ENODEV;
  24832. + }
  24833. +
  24834. + vsc = kzalloc(sizeof(*vsc), GFP_KERNEL);
  24835. + if (!vsc) {
  24836. + dev_err(&spi->dev, "no memory for private data\n");
  24837. + return-ENOMEM;
  24838. + }
  24839. +
  24840. + mutex_init(&vsc->lock);
  24841. + vsc->pdata = pdata;
  24842. + vsc->spi = spi_dev_get(spi);
  24843. + dev_set_drvdata(&spi->dev, vsc);
  24844. +
  24845. + spi->mode = SPI_MODE_0;
  24846. + spi->bits_per_word = 8;
  24847. + err = spi_setup(spi);
  24848. + if (err) {
  24849. + dev_err(&spi->dev, "spi_setup failed, err=%d \n", err);
  24850. + goto err_drvdata;
  24851. + }
  24852. +
  24853. + err = vsc7385_detect(vsc);
  24854. + if (err) {
  24855. + dev_err(&spi->dev, "no chip found, err=%d \n", err);
  24856. + goto err_drvdata;
  24857. + }
  24858. +
  24859. + err = vsc7385_upload_ucode(vsc);
  24860. + if (err)
  24861. + goto err_drvdata;
  24862. +
  24863. + err = vsc7385_setup(vsc);
  24864. + if (err)
  24865. + goto err_drvdata;
  24866. +
  24867. + return 0;
  24868. +
  24869. + err_drvdata:
  24870. + dev_set_drvdata(&spi->dev, NULL);
  24871. + kfree(vsc);
  24872. + return err;
  24873. +}
  24874. +
  24875. +static int __devexit vsc7385_remove(struct spi_device *spi)
  24876. +{
  24877. + struct vsc7385_data *vsc;
  24878. +
  24879. + vsc = dev_get_drvdata(&spi->dev);
  24880. + dev_set_drvdata(&spi->dev, NULL);
  24881. + kfree(vsc);
  24882. +
  24883. + return 0;
  24884. +}
  24885. +
  24886. +static struct spi_driver vsc7385_driver = {
  24887. + .driver = {
  24888. + .name = DRV_NAME,
  24889. + .bus = &spi_bus_type,
  24890. + .owner = THIS_MODULE,
  24891. + },
  24892. + .probe = vsc7385_probe,
  24893. + .remove = __devexit_p(vsc7385_remove),
  24894. +};
  24895. +
  24896. +static int __init vsc7385_init(void)
  24897. +{
  24898. + return spi_register_driver(&vsc7385_driver);
  24899. +}
  24900. +module_init(vsc7385_init);
  24901. +
  24902. +static void __exit vsc7385_exit(void)
  24903. +{
  24904. + spi_unregister_driver(&vsc7385_driver);
  24905. +}
  24906. +module_exit(vsc7385_exit);
  24907. +
  24908. +MODULE_DESCRIPTION(DRV_DESC);
  24909. +MODULE_VERSION(DRV_VERSION);
  24910. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  24911. +MODULE_LICENSE("GPL v2");
  24912. +
  24913. diff -Nur linux-2.6.35.7.orig/drivers/usb/host/ehci-ar71xx.c linux-2.6.35.7/drivers/usb/host/ehci-ar71xx.c
  24914. --- linux-2.6.35.7.orig/drivers/usb/host/ehci-ar71xx.c 1970-01-01 01:00:00.000000000 +0100
  24915. +++ linux-2.6.35.7/drivers/usb/host/ehci-ar71xx.c 2010-10-14 20:28:01.285601150 +0200
  24916. @@ -0,0 +1,242 @@
  24917. +/*
  24918. + * Bus Glue for Atheros AR71xx built-in EHCI controller.
  24919. + *
  24920. + * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  24921. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  24922. + *
  24923. + * Parts of this file are based on Atheros' 2.6.15 BSP
  24924. + * Copyright (C) 2007 Atheros Communications, Inc.
  24925. + *
  24926. + * This program is free software; you can redistribute it and/or modify it
  24927. + * under the terms of the GNU General Public License version 2 as published
  24928. + * by the Free Software Foundation.
  24929. + */
  24930. +
  24931. +#include <linux/platform_device.h>
  24932. +#include <linux/delay.h>
  24933. +
  24934. +#include <asm/mach-ar71xx/platform.h>
  24935. +
  24936. +extern int usb_disabled(void);
  24937. +
  24938. +static int ehci_ar71xx_init(struct usb_hcd *hcd)
  24939. +{
  24940. + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
  24941. + int ret;
  24942. +
  24943. + ehci->caps = hcd->regs;
  24944. + ehci->regs = hcd->regs +
  24945. + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
  24946. + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
  24947. +
  24948. + ehci->sbrn = 0x20;
  24949. + ehci->has_synopsys_hc_bug = 1;
  24950. +
  24951. + ehci_reset(ehci);
  24952. +
  24953. + ret = ehci_init(hcd);
  24954. + if (ret)
  24955. + return ret;
  24956. +
  24957. + ehci_port_power(ehci, 0);
  24958. +
  24959. + return 0;
  24960. +}
  24961. +
  24962. +static int ehci_ar91xx_init(struct usb_hcd *hcd)
  24963. +{
  24964. + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
  24965. + int ret;
  24966. +
  24967. + ehci->caps = hcd->regs + 0x100;
  24968. + ehci->regs = hcd->regs + 0x100 +
  24969. + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
  24970. + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
  24971. +
  24972. + hcd->has_tt = 1;
  24973. + ehci->sbrn = 0x20;
  24974. +
  24975. + ehci_reset(ehci);
  24976. +
  24977. + ret = ehci_init(hcd);
  24978. + if (ret)
  24979. + return ret;
  24980. +
  24981. + ehci_port_power(ehci, 0);
  24982. +
  24983. + return 0;
  24984. +}
  24985. +
  24986. +static int ehci_ar71xx_probe(const struct hc_driver *driver,
  24987. + struct usb_hcd **hcd_out,
  24988. + struct platform_device *pdev)
  24989. +{
  24990. + struct usb_hcd *hcd;
  24991. + struct resource *res;
  24992. + int irq;
  24993. + int ret;
  24994. +
  24995. + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  24996. + if (!res) {
  24997. + dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
  24998. + dev_name(&pdev->dev));
  24999. + return -ENODEV;
  25000. + }
  25001. + irq = res->start;
  25002. +
  25003. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  25004. + if (!res) {
  25005. + dev_dbg(&pdev->dev, "no base address specified for %s\n",
  25006. + dev_name(&pdev->dev));
  25007. + return -ENODEV;
  25008. + }
  25009. +
  25010. + hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
  25011. + if (!hcd)
  25012. + return -ENOMEM;
  25013. +
  25014. + hcd->rsrc_start = res->start;
  25015. + hcd->rsrc_len = res->end - res->start + 1;
  25016. +
  25017. + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
  25018. + dev_dbg(&pdev->dev, "controller already in use\n");
  25019. + ret = -EBUSY;
  25020. + goto err_put_hcd;
  25021. + }
  25022. +
  25023. + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
  25024. + if (!hcd->regs) {
  25025. + dev_dbg(&pdev->dev, "error mapping memory\n");
  25026. + ret = -EFAULT;
  25027. + goto err_release_region;
  25028. + }
  25029. +
  25030. + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
  25031. + if (ret)
  25032. + goto err_iounmap;
  25033. +
  25034. + return 0;
  25035. +
  25036. + err_iounmap:
  25037. + iounmap(hcd->regs);
  25038. +
  25039. + err_release_region:
  25040. + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  25041. + err_put_hcd:
  25042. + usb_put_hcd(hcd);
  25043. + return ret;
  25044. +}
  25045. +
  25046. +static void ehci_ar71xx_remove(struct usb_hcd *hcd,
  25047. + struct platform_device *pdev)
  25048. +{
  25049. + usb_remove_hcd(hcd);
  25050. + iounmap(hcd->regs);
  25051. + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  25052. + usb_put_hcd(hcd);
  25053. +}
  25054. +
  25055. +static const struct hc_driver ehci_ar71xx_hc_driver = {
  25056. + .description = hcd_name,
  25057. + .product_desc = "Atheros AR71xx built-in EHCI controller",
  25058. + .hcd_priv_size = sizeof(struct ehci_hcd),
  25059. +
  25060. + .irq = ehci_irq,
  25061. + .flags = HCD_MEMORY | HCD_USB2,
  25062. +
  25063. + .reset = ehci_ar71xx_init,
  25064. + .start = ehci_run,
  25065. + .stop = ehci_stop,
  25066. + .shutdown = ehci_shutdown,
  25067. +
  25068. + .urb_enqueue = ehci_urb_enqueue,
  25069. + .urb_dequeue = ehci_urb_dequeue,
  25070. + .endpoint_disable = ehci_endpoint_disable,
  25071. + .endpoint_reset = ehci_endpoint_reset,
  25072. +
  25073. + .get_frame_number = ehci_get_frame,
  25074. +
  25075. + .hub_status_data = ehci_hub_status_data,
  25076. + .hub_control = ehci_hub_control,
  25077. +#ifdef CONFIG_PM
  25078. + .hub_suspend = ehci_hub_suspend,
  25079. + .hub_resume = ehci_hub_resume,
  25080. +#endif
  25081. + .relinquish_port = ehci_relinquish_port,
  25082. + .port_handed_over = ehci_port_handed_over,
  25083. +
  25084. + .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
  25085. +};
  25086. +
  25087. +static const struct hc_driver ehci_ar91xx_hc_driver = {
  25088. + .description = hcd_name,
  25089. + .product_desc = "Atheros AR91xx built-in EHCI controller",
  25090. + .hcd_priv_size = sizeof(struct ehci_hcd),
  25091. + .irq = ehci_irq,
  25092. + .flags = HCD_MEMORY | HCD_USB2,
  25093. +
  25094. + .reset = ehci_ar91xx_init,
  25095. + .start = ehci_run,
  25096. + .stop = ehci_stop,
  25097. + .shutdown = ehci_shutdown,
  25098. +
  25099. + .urb_enqueue = ehci_urb_enqueue,
  25100. + .urb_dequeue = ehci_urb_dequeue,
  25101. + .endpoint_disable = ehci_endpoint_disable,
  25102. + .endpoint_reset = ehci_endpoint_reset,
  25103. +
  25104. + .get_frame_number = ehci_get_frame,
  25105. +
  25106. + .hub_status_data = ehci_hub_status_data,
  25107. + .hub_control = ehci_hub_control,
  25108. +#ifdef CONFIG_PM
  25109. + .hub_suspend = ehci_hub_suspend,
  25110. + .hub_resume = ehci_hub_resume,
  25111. +#endif
  25112. + .relinquish_port = ehci_relinquish_port,
  25113. + .port_handed_over = ehci_port_handed_over,
  25114. +
  25115. + .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
  25116. +};
  25117. +
  25118. +static int ehci_ar71xx_driver_probe(struct platform_device *pdev)
  25119. +{
  25120. + struct ar71xx_ehci_platform_data *pdata;
  25121. + struct usb_hcd *hcd = NULL;
  25122. + int ret;
  25123. +
  25124. + if (usb_disabled())
  25125. + return -ENODEV;
  25126. +
  25127. + pdata = pdev->dev.platform_data;
  25128. + if (!pdata) {
  25129. + dev_err(&pdev->dev, "no platform data specified for %s\n",
  25130. + dev_name(&pdev->dev));
  25131. + return -ENODEV;
  25132. + }
  25133. +
  25134. + if (pdata->is_ar91xx)
  25135. + ret = ehci_ar71xx_probe(&ehci_ar91xx_hc_driver, &hcd, pdev);
  25136. + else
  25137. + ret = ehci_ar71xx_probe(&ehci_ar71xx_hc_driver, &hcd, pdev);
  25138. +
  25139. + return ret;
  25140. +}
  25141. +
  25142. +static int ehci_ar71xx_driver_remove(struct platform_device *pdev)
  25143. +{
  25144. + struct usb_hcd *hcd = platform_get_drvdata(pdev);
  25145. +
  25146. + ehci_ar71xx_remove(hcd, pdev);
  25147. + return 0;
  25148. +}
  25149. +
  25150. +MODULE_ALIAS("platform:ar71xx-ehci");
  25151. +
  25152. +static struct platform_driver ehci_ar71xx_driver = {
  25153. + .probe = ehci_ar71xx_driver_probe,
  25154. + .remove = ehci_ar71xx_driver_remove,
  25155. + .driver = {
  25156. + .name = "ar71xx-ehci",
  25157. + }
  25158. +};
  25159. diff -Nur linux-2.6.35.7.orig/drivers/usb/host/ehci-hcd.c linux-2.6.35.7/drivers/usb/host/ehci-hcd.c
  25160. --- linux-2.6.35.7.orig/drivers/usb/host/ehci-hcd.c 2010-09-29 03:09:08.000000000 +0200
  25161. +++ linux-2.6.35.7/drivers/usb/host/ehci-hcd.c 2010-10-14 20:28:01.328100455 +0200
  25162. @@ -1158,6 +1158,11 @@
  25163. #define PLATFORM_DRIVER ehci_atmel_driver
  25164. #endif
  25165. +#ifdef CONFIG_USB_EHCI_AR71XX
  25166. +#include "ehci-ar71xx.c"
  25167. +#define PLATFORM_DRIVER ehci_ar71xx_driver
  25168. +#endif
  25169. +
  25170. #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
  25171. !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
  25172. !defined(XILINX_OF_PLATFORM_DRIVER)
  25173. diff -Nur linux-2.6.35.7.orig/drivers/usb/host/ehci-hcd.c.orig linux-2.6.35.7/drivers/usb/host/ehci-hcd.c.orig
  25174. --- linux-2.6.35.7.orig/drivers/usb/host/ehci-hcd.c.orig 1970-01-01 01:00:00.000000000 +0100
  25175. +++ linux-2.6.35.7/drivers/usb/host/ehci-hcd.c.orig 2010-09-29 03:09:08.000000000 +0200
  25176. @@ -0,0 +1,1278 @@
  25177. +/*
  25178. + * Copyright (c) 2000-2004 by David Brownell
  25179. + *
  25180. + * This program is free software; you can redistribute it and/or modify it
  25181. + * under the terms of the GNU General Public License as published by the
  25182. + * Free Software Foundation; either version 2 of the License, or (at your
  25183. + * option) any later version.
  25184. + *
  25185. + * This program is distributed in the hope that it will be useful, but
  25186. + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  25187. + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  25188. + * for more details.
  25189. + *
  25190. + * You should have received a copy of the GNU General Public License
  25191. + * along with this program; if not, write to the Free Software Foundation,
  25192. + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25193. + */
  25194. +
  25195. +#include <linux/module.h>
  25196. +#include <linux/pci.h>
  25197. +#include <linux/dmapool.h>
  25198. +#include <linux/kernel.h>
  25199. +#include <linux/delay.h>
  25200. +#include <linux/ioport.h>
  25201. +#include <linux/sched.h>
  25202. +#include <linux/vmalloc.h>
  25203. +#include <linux/errno.h>
  25204. +#include <linux/init.h>
  25205. +#include <linux/timer.h>
  25206. +#include <linux/ktime.h>
  25207. +#include <linux/list.h>
  25208. +#include <linux/interrupt.h>
  25209. +#include <linux/usb.h>
  25210. +#include <linux/usb/hcd.h>
  25211. +#include <linux/moduleparam.h>
  25212. +#include <linux/dma-mapping.h>
  25213. +#include <linux/debugfs.h>
  25214. +#include <linux/slab.h>
  25215. +
  25216. +#include <asm/byteorder.h>
  25217. +#include <asm/io.h>
  25218. +#include <asm/irq.h>
  25219. +#include <asm/system.h>
  25220. +#include <asm/unaligned.h>
  25221. +
  25222. +/*-------------------------------------------------------------------------*/
  25223. +
  25224. +/*
  25225. + * EHCI hc_driver implementation ... experimental, incomplete.
  25226. + * Based on the final 1.0 register interface specification.
  25227. + *
  25228. + * USB 2.0 shows up in upcoming www.pcmcia.org technology.
  25229. + * First was PCMCIA, like ISA; then CardBus, which is PCI.
  25230. + * Next comes "CardBay", using USB 2.0 signals.
  25231. + *
  25232. + * Contains additional contributions by Brad Hards, Rory Bolt, and others.
  25233. + * Special thanks to Intel and VIA for providing host controllers to
  25234. + * test this driver on, and Cypress (including In-System Design) for
  25235. + * providing early devices for those host controllers to talk to!
  25236. + */
  25237. +
  25238. +#define DRIVER_AUTHOR "David Brownell"
  25239. +#define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver"
  25240. +
  25241. +static const char hcd_name [] = "ehci_hcd";
  25242. +
  25243. +
  25244. +#undef VERBOSE_DEBUG
  25245. +#undef EHCI_URB_TRACE
  25246. +
  25247. +#ifdef DEBUG
  25248. +#define EHCI_STATS
  25249. +#endif
  25250. +
  25251. +/* magic numbers that can affect system performance */
  25252. +#define EHCI_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */
  25253. +#define EHCI_TUNE_RL_HS 4 /* nak throttle; see 4.9 */
  25254. +#define EHCI_TUNE_RL_TT 0
  25255. +#define EHCI_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */
  25256. +#define EHCI_TUNE_MULT_TT 1
  25257. +#define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */
  25258. +
  25259. +#define EHCI_IAA_MSECS 10 /* arbitrary */
  25260. +#define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */
  25261. +#define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */
  25262. +#define EHCI_SHRINK_FRAMES 5 /* async qh unlink delay */
  25263. +
  25264. +/* Initial IRQ latency: faster than hw default */
  25265. +static int log2_irq_thresh = 0; // 0 to 6
  25266. +module_param (log2_irq_thresh, int, S_IRUGO);
  25267. +MODULE_PARM_DESC (log2_irq_thresh, "log2 IRQ latency, 1-64 microframes");
  25268. +
  25269. +/* initial park setting: slower than hw default */
  25270. +static unsigned park = 0;
  25271. +module_param (park, uint, S_IRUGO);
  25272. +MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets");
  25273. +
  25274. +/* for flakey hardware, ignore overcurrent indicators */
  25275. +static int ignore_oc = 0;
  25276. +module_param (ignore_oc, bool, S_IRUGO);
  25277. +MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications");
  25278. +
  25279. +#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
  25280. +
  25281. +/*-------------------------------------------------------------------------*/
  25282. +
  25283. +#include "ehci.h"
  25284. +#include "ehci-dbg.c"
  25285. +
  25286. +/*-------------------------------------------------------------------------*/
  25287. +
  25288. +static void
  25289. +timer_action(struct ehci_hcd *ehci, enum ehci_timer_action action)
  25290. +{
  25291. + /* Don't override timeouts which shrink or (later) disable
  25292. + * the async ring; just the I/O watchdog. Note that if a
  25293. + * SHRINK were pending, OFF would never be requested.
  25294. + */
  25295. + if (timer_pending(&ehci->watchdog)
  25296. + && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF))
  25297. + & ehci->actions))
  25298. + return;
  25299. +
  25300. + if (!test_and_set_bit(action, &ehci->actions)) {
  25301. + unsigned long t;
  25302. +
  25303. + switch (action) {
  25304. + case TIMER_IO_WATCHDOG:
  25305. + if (!ehci->need_io_watchdog)
  25306. + return;
  25307. + t = EHCI_IO_JIFFIES;
  25308. + break;
  25309. + case TIMER_ASYNC_OFF:
  25310. + t = EHCI_ASYNC_JIFFIES;
  25311. + break;
  25312. + /* case TIMER_ASYNC_SHRINK: */
  25313. + default:
  25314. + /* add a jiffie since we synch against the
  25315. + * 8 KHz uframe counter.
  25316. + */
  25317. + t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1;
  25318. + break;
  25319. + }
  25320. + mod_timer(&ehci->watchdog, t + jiffies);
  25321. + }
  25322. +}
  25323. +
  25324. +/*-------------------------------------------------------------------------*/
  25325. +
  25326. +/*
  25327. + * handshake - spin reading hc until handshake completes or fails
  25328. + * @ptr: address of hc register to be read
  25329. + * @mask: bits to look at in result of read
  25330. + * @done: value of those bits when handshake succeeds
  25331. + * @usec: timeout in microseconds
  25332. + *
  25333. + * Returns negative errno, or zero on success
  25334. + *
  25335. + * Success happens when the "mask" bits have the specified value (hardware
  25336. + * handshake done). There are two failure modes: "usec" have passed (major
  25337. + * hardware flakeout), or the register reads as all-ones (hardware removed).
  25338. + *
  25339. + * That last failure should_only happen in cases like physical cardbus eject
  25340. + * before driver shutdown. But it also seems to be caused by bugs in cardbus
  25341. + * bridge shutdown: shutting down the bridge before the devices using it.
  25342. + */
  25343. +static int handshake (struct ehci_hcd *ehci, void __iomem *ptr,
  25344. + u32 mask, u32 done, int usec)
  25345. +{
  25346. + u32 result;
  25347. +
  25348. + do {
  25349. + result = ehci_readl(ehci, ptr);
  25350. + if (result == ~(u32)0) /* card removed */
  25351. + return -ENODEV;
  25352. + result &= mask;
  25353. + if (result == done)
  25354. + return 0;
  25355. + udelay (1);
  25356. + usec--;
  25357. + } while (usec > 0);
  25358. + return -ETIMEDOUT;
  25359. +}
  25360. +
  25361. +/* force HC to halt state from unknown (EHCI spec section 2.3) */
  25362. +static int ehci_halt (struct ehci_hcd *ehci)
  25363. +{
  25364. + u32 temp = ehci_readl(ehci, &ehci->regs->status);
  25365. +
  25366. + /* disable any irqs left enabled by previous code */
  25367. + ehci_writel(ehci, 0, &ehci->regs->intr_enable);
  25368. +
  25369. + if ((temp & STS_HALT) != 0)
  25370. + return 0;
  25371. +
  25372. + temp = ehci_readl(ehci, &ehci->regs->command);
  25373. + temp &= ~CMD_RUN;
  25374. + ehci_writel(ehci, temp, &ehci->regs->command);
  25375. + return handshake (ehci, &ehci->regs->status,
  25376. + STS_HALT, STS_HALT, 16 * 125);
  25377. +}
  25378. +
  25379. +static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr,
  25380. + u32 mask, u32 done, int usec)
  25381. +{
  25382. + int error;
  25383. +
  25384. + error = handshake(ehci, ptr, mask, done, usec);
  25385. + if (error) {
  25386. + ehci_halt(ehci);
  25387. + ehci_to_hcd(ehci)->state = HC_STATE_HALT;
  25388. + ehci_err(ehci, "force halt; handshake %p %08x %08x -> %d\n",
  25389. + ptr, mask, done, error);
  25390. + }
  25391. +
  25392. + return error;
  25393. +}
  25394. +
  25395. +/* put TDI/ARC silicon into EHCI mode */
  25396. +static void tdi_reset (struct ehci_hcd *ehci)
  25397. +{
  25398. + u32 __iomem *reg_ptr;
  25399. + u32 tmp;
  25400. +
  25401. + reg_ptr = (u32 __iomem *)(((u8 __iomem *)ehci->regs) + USBMODE);
  25402. + tmp = ehci_readl(ehci, reg_ptr);
  25403. + tmp |= USBMODE_CM_HC;
  25404. + /* The default byte access to MMR space is LE after
  25405. + * controller reset. Set the required endian mode
  25406. + * for transfer buffers to match the host microprocessor
  25407. + */
  25408. + if (ehci_big_endian_mmio(ehci))
  25409. + tmp |= USBMODE_BE;
  25410. + ehci_writel(ehci, tmp, reg_ptr);
  25411. +}
  25412. +
  25413. +/* reset a non-running (STS_HALT == 1) controller */
  25414. +static int ehci_reset (struct ehci_hcd *ehci)
  25415. +{
  25416. + int retval;
  25417. + u32 command = ehci_readl(ehci, &ehci->regs->command);
  25418. +
  25419. + /* If the EHCI debug controller is active, special care must be
  25420. + * taken before and after a host controller reset */
  25421. + if (ehci->debug && !dbgp_reset_prep())
  25422. + ehci->debug = NULL;
  25423. +
  25424. + command |= CMD_RESET;
  25425. + dbg_cmd (ehci, "reset", command);
  25426. + ehci_writel(ehci, command, &ehci->regs->command);
  25427. + ehci_to_hcd(ehci)->state = HC_STATE_HALT;
  25428. + ehci->next_statechange = jiffies;
  25429. + retval = handshake (ehci, &ehci->regs->command,
  25430. + CMD_RESET, 0, 250 * 1000);
  25431. +
  25432. + if (ehci->has_hostpc) {
  25433. + ehci_writel(ehci, USBMODE_EX_HC | USBMODE_EX_VBPS,
  25434. + (u32 __iomem *)(((u8 *)ehci->regs) + USBMODE_EX));
  25435. + ehci_writel(ehci, TXFIFO_DEFAULT,
  25436. + (u32 __iomem *)(((u8 *)ehci->regs) + TXFILLTUNING));
  25437. + }
  25438. + if (retval)
  25439. + return retval;
  25440. +
  25441. + if (ehci_is_TDI(ehci))
  25442. + tdi_reset (ehci);
  25443. +
  25444. + if (ehci->debug)
  25445. + dbgp_external_startup();
  25446. +
  25447. + return retval;
  25448. +}
  25449. +
  25450. +/* idle the controller (from running) */
  25451. +static void ehci_quiesce (struct ehci_hcd *ehci)
  25452. +{
  25453. + u32 temp;
  25454. +
  25455. +#ifdef DEBUG
  25456. + if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state))
  25457. + BUG ();
  25458. +#endif
  25459. +
  25460. + /* wait for any schedule enables/disables to take effect */
  25461. + temp = ehci_readl(ehci, &ehci->regs->command) << 10;
  25462. + temp &= STS_ASS | STS_PSS;
  25463. + if (handshake_on_error_set_halt(ehci, &ehci->regs->status,
  25464. + STS_ASS | STS_PSS, temp, 16 * 125))
  25465. + return;
  25466. +
  25467. + /* then disable anything that's still active */
  25468. + temp = ehci_readl(ehci, &ehci->regs->command);
  25469. + temp &= ~(CMD_ASE | CMD_IAAD | CMD_PSE);
  25470. + ehci_writel(ehci, temp, &ehci->regs->command);
  25471. +
  25472. + /* hardware can take 16 microframes to turn off ... */
  25473. + handshake_on_error_set_halt(ehci, &ehci->regs->status,
  25474. + STS_ASS | STS_PSS, 0, 16 * 125);
  25475. +}
  25476. +
  25477. +/*-------------------------------------------------------------------------*/
  25478. +
  25479. +static void end_unlink_async(struct ehci_hcd *ehci);
  25480. +static void ehci_work(struct ehci_hcd *ehci);
  25481. +
  25482. +#include "ehci-hub.c"
  25483. +#include "ehci-mem.c"
  25484. +#include "ehci-q.c"
  25485. +#include "ehci-sched.c"
  25486. +
  25487. +/*-------------------------------------------------------------------------*/
  25488. +
  25489. +static void ehci_iaa_watchdog(unsigned long param)
  25490. +{
  25491. + struct ehci_hcd *ehci = (struct ehci_hcd *) param;
  25492. + unsigned long flags;
  25493. +
  25494. + spin_lock_irqsave (&ehci->lock, flags);
  25495. +
  25496. + /* Lost IAA irqs wedge things badly; seen first with a vt8235.
  25497. + * So we need this watchdog, but must protect it against both
  25498. + * (a) SMP races against real IAA firing and retriggering, and
  25499. + * (b) clean HC shutdown, when IAA watchdog was pending.
  25500. + */
  25501. + if (ehci->reclaim
  25502. + && !timer_pending(&ehci->iaa_watchdog)
  25503. + && HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) {
  25504. + u32 cmd, status;
  25505. +
  25506. + /* If we get here, IAA is *REALLY* late. It's barely
  25507. + * conceivable that the system is so busy that CMD_IAAD
  25508. + * is still legitimately set, so let's be sure it's
  25509. + * clear before we read STS_IAA. (The HC should clear
  25510. + * CMD_IAAD when it sets STS_IAA.)
  25511. + */
  25512. + cmd = ehci_readl(ehci, &ehci->regs->command);
  25513. + if (cmd & CMD_IAAD)
  25514. + ehci_writel(ehci, cmd & ~CMD_IAAD,
  25515. + &ehci->regs->command);
  25516. +
  25517. + /* If IAA is set here it either legitimately triggered
  25518. + * before we cleared IAAD above (but _way_ late, so we'll
  25519. + * still count it as lost) ... or a silicon erratum:
  25520. + * - VIA seems to set IAA without triggering the IRQ;
  25521. + * - IAAD potentially cleared without setting IAA.
  25522. + */
  25523. + status = ehci_readl(ehci, &ehci->regs->status);
  25524. + if ((status & STS_IAA) || !(cmd & CMD_IAAD)) {
  25525. + COUNT (ehci->stats.lost_iaa);
  25526. + ehci_writel(ehci, STS_IAA, &ehci->regs->status);
  25527. + }
  25528. +
  25529. + ehci_vdbg(ehci, "IAA watchdog: status %x cmd %x\n",
  25530. + status, cmd);
  25531. + end_unlink_async(ehci);
  25532. + }
  25533. +
  25534. + spin_unlock_irqrestore(&ehci->lock, flags);
  25535. +}
  25536. +
  25537. +static void ehci_watchdog(unsigned long param)
  25538. +{
  25539. + struct ehci_hcd *ehci = (struct ehci_hcd *) param;
  25540. + unsigned long flags;
  25541. +
  25542. + spin_lock_irqsave(&ehci->lock, flags);
  25543. +
  25544. + /* stop async processing after it's idled a bit */
  25545. + if (test_bit (TIMER_ASYNC_OFF, &ehci->actions))
  25546. + start_unlink_async (ehci, ehci->async);
  25547. +
  25548. + /* ehci could run by timer, without IRQs ... */
  25549. + ehci_work (ehci);
  25550. +
  25551. + spin_unlock_irqrestore (&ehci->lock, flags);
  25552. +}
  25553. +
  25554. +/* On some systems, leaving remote wakeup enabled prevents system shutdown.
  25555. + * The firmware seems to think that powering off is a wakeup event!
  25556. + * This routine turns off remote wakeup and everything else, on all ports.
  25557. + */
  25558. +static void ehci_turn_off_all_ports(struct ehci_hcd *ehci)
  25559. +{
  25560. + int port = HCS_N_PORTS(ehci->hcs_params);
  25561. +
  25562. + while (port--)
  25563. + ehci_writel(ehci, PORT_RWC_BITS,
  25564. + &ehci->regs->port_status[port]);
  25565. +}
  25566. +
  25567. +/*
  25568. + * Halt HC, turn off all ports, and let the BIOS use the companion controllers.
  25569. + * Should be called with ehci->lock held.
  25570. + */
  25571. +static void ehci_silence_controller(struct ehci_hcd *ehci)
  25572. +{
  25573. + ehci_halt(ehci);
  25574. + ehci_turn_off_all_ports(ehci);
  25575. +
  25576. + /* make BIOS/etc use companion controller during reboot */
  25577. + ehci_writel(ehci, 0, &ehci->regs->configured_flag);
  25578. +
  25579. + /* unblock posted writes */
  25580. + ehci_readl(ehci, &ehci->regs->configured_flag);
  25581. +}
  25582. +
  25583. +/* ehci_shutdown kick in for silicon on any bus (not just pci, etc).
  25584. + * This forcibly disables dma and IRQs, helping kexec and other cases
  25585. + * where the next system software may expect clean state.
  25586. + */
  25587. +static void ehci_shutdown(struct usb_hcd *hcd)
  25588. +{
  25589. + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
  25590. +
  25591. + del_timer_sync(&ehci->watchdog);
  25592. + del_timer_sync(&ehci->iaa_watchdog);
  25593. +
  25594. + spin_lock_irq(&ehci->lock);
  25595. + ehci_silence_controller(ehci);
  25596. + spin_unlock_irq(&ehci->lock);
  25597. +}
  25598. +
  25599. +static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
  25600. +{
  25601. + unsigned port;
  25602. +
  25603. + if (!HCS_PPC (ehci->hcs_params))
  25604. + return;
  25605. +
  25606. + ehci_dbg (ehci, "...power%s ports...\n", is_on ? "up" : "down");
  25607. + for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
  25608. + (void) ehci_hub_control(ehci_to_hcd(ehci),
  25609. + is_on ? SetPortFeature : ClearPortFeature,
  25610. + USB_PORT_FEAT_POWER,
  25611. + port--, NULL, 0);
  25612. + /* Flush those writes */
  25613. + ehci_readl(ehci, &ehci->regs->command);
  25614. + msleep(20);
  25615. +}
  25616. +
  25617. +/*-------------------------------------------------------------------------*/
  25618. +
  25619. +/*
  25620. + * ehci_work is called from some interrupts, timers, and so on.
  25621. + * it calls driver completion functions, after dropping ehci->lock.
  25622. + */
  25623. +static void ehci_work (struct ehci_hcd *ehci)
  25624. +{
  25625. + timer_action_done (ehci, TIMER_IO_WATCHDOG);
  25626. +
  25627. + /* another CPU may drop ehci->lock during a schedule scan while
  25628. + * it reports urb completions. this flag guards against bogus
  25629. + * attempts at re-entrant schedule scanning.
  25630. + */
  25631. + if (ehci->scanning)
  25632. + return;
  25633. + ehci->scanning = 1;
  25634. + scan_async (ehci);
  25635. + if (ehci->next_uframe != -1)
  25636. + scan_periodic (ehci);
  25637. + ehci->scanning = 0;
  25638. +
  25639. + /* the IO watchdog guards against hardware or driver bugs that
  25640. + * misplace IRQs, and should let us run completely without IRQs.
  25641. + * such lossage has been observed on both VT6202 and VT8235.
  25642. + */
  25643. + if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state) &&
  25644. + (ehci->async->qh_next.ptr != NULL ||
  25645. + ehci->periodic_sched != 0))
  25646. + timer_action (ehci, TIMER_IO_WATCHDOG);
  25647. +}
  25648. +
  25649. +/*
  25650. + * Called when the ehci_hcd module is removed.
  25651. + */
  25652. +static void ehci_stop (struct usb_hcd *hcd)
  25653. +{
  25654. + struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  25655. +
  25656. + ehci_dbg (ehci, "stop\n");
  25657. +
  25658. + /* no more interrupts ... */
  25659. + del_timer_sync (&ehci->watchdog);
  25660. + del_timer_sync(&ehci->iaa_watchdog);
  25661. +
  25662. + spin_lock_irq(&ehci->lock);
  25663. + if (HC_IS_RUNNING (hcd->state))
  25664. + ehci_quiesce (ehci);
  25665. +
  25666. + ehci_silence_controller(ehci);
  25667. + ehci_reset (ehci);
  25668. + spin_unlock_irq(&ehci->lock);
  25669. +
  25670. + remove_companion_file(ehci);
  25671. + remove_debug_files (ehci);
  25672. +
  25673. + /* root hub is shut down separately (first, when possible) */
  25674. + spin_lock_irq (&ehci->lock);
  25675. + if (ehci->async)
  25676. + ehci_work (ehci);
  25677. + spin_unlock_irq (&ehci->lock);
  25678. + ehci_mem_cleanup (ehci);
  25679. +
  25680. +#ifdef EHCI_STATS
  25681. + ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n",
  25682. + ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim,
  25683. + ehci->stats.lost_iaa);
  25684. + ehci_dbg (ehci, "complete %ld unlink %ld\n",
  25685. + ehci->stats.complete, ehci->stats.unlink);
  25686. +#endif
  25687. +
  25688. + dbg_status (ehci, "ehci_stop completed",
  25689. + ehci_readl(ehci, &ehci->regs->status));
  25690. +}
  25691. +
  25692. +/* one-time init, only for memory state */
  25693. +static int ehci_init(struct usb_hcd *hcd)
  25694. +{
  25695. + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
  25696. + u32 temp;
  25697. + int retval;
  25698. + u32 hcc_params;
  25699. + struct ehci_qh_hw *hw;
  25700. +
  25701. + spin_lock_init(&ehci->lock);
  25702. +
  25703. + /*
  25704. + * keep io watchdog by default, those good HCDs could turn off it later
  25705. + */
  25706. + ehci->need_io_watchdog = 1;
  25707. + init_timer(&ehci->watchdog);
  25708. + ehci->watchdog.function = ehci_watchdog;
  25709. + ehci->watchdog.data = (unsigned long) ehci;
  25710. +
  25711. + init_timer(&ehci->iaa_watchdog);
  25712. + ehci->iaa_watchdog.function = ehci_iaa_watchdog;
  25713. + ehci->iaa_watchdog.data = (unsigned long) ehci;
  25714. +
  25715. + /*
  25716. + * hw default: 1K periodic list heads, one per frame.
  25717. + * periodic_size can shrink by USBCMD update if hcc_params allows.
  25718. + */
  25719. + ehci->periodic_size = DEFAULT_I_TDPS;
  25720. + INIT_LIST_HEAD(&ehci->cached_itd_list);
  25721. + INIT_LIST_HEAD(&ehci->cached_sitd_list);
  25722. + if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0)
  25723. + return retval;
  25724. +
  25725. + /* controllers may cache some of the periodic schedule ... */
  25726. + hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);
  25727. + if (HCC_ISOC_CACHE(hcc_params)) // full frame cache
  25728. + ehci->i_thresh = 2 + 8;
  25729. + else // N microframes cached
  25730. + ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
  25731. +
  25732. + ehci->reclaim = NULL;
  25733. + ehci->next_uframe = -1;
  25734. + ehci->clock_frame = -1;
  25735. +
  25736. + /*
  25737. + * dedicate a qh for the async ring head, since we couldn't unlink
  25738. + * a 'real' qh without stopping the async schedule [4.8]. use it
  25739. + * as the 'reclamation list head' too.
  25740. + * its dummy is used in hw_alt_next of many tds, to prevent the qh
  25741. + * from automatically advancing to the next td after short reads.
  25742. + */
  25743. + ehci->async->qh_next.qh = NULL;
  25744. + hw = ehci->async->hw;
  25745. + hw->hw_next = QH_NEXT(ehci, ehci->async->qh_dma);
  25746. + hw->hw_info1 = cpu_to_hc32(ehci, QH_HEAD);
  25747. + hw->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT);
  25748. + hw->hw_qtd_next = EHCI_LIST_END(ehci);
  25749. + ehci->async->qh_state = QH_STATE_LINKED;
  25750. + hw->hw_alt_next = QTD_NEXT(ehci, ehci->async->dummy->qtd_dma);
  25751. +
  25752. + /* clear interrupt enables, set irq latency */
  25753. + if (log2_irq_thresh < 0 || log2_irq_thresh > 6)
  25754. + log2_irq_thresh = 0;
  25755. + temp = 1 << (16 + log2_irq_thresh);
  25756. + if (HCC_CANPARK(hcc_params)) {
  25757. + /* HW default park == 3, on hardware that supports it (like
  25758. + * NVidia and ALI silicon), maximizes throughput on the async
  25759. + * schedule by avoiding QH fetches between transfers.
  25760. + *
  25761. + * With fast usb storage devices and NForce2, "park" seems to
  25762. + * make problems: throughput reduction (!), data errors...
  25763. + */
  25764. + if (park) {
  25765. + park = min(park, (unsigned) 3);
  25766. + temp |= CMD_PARK;
  25767. + temp |= park << 8;
  25768. + }
  25769. + ehci_dbg(ehci, "park %d\n", park);
  25770. + }
  25771. + if (HCC_PGM_FRAMELISTLEN(hcc_params)) {
  25772. + /* periodic schedule size can be smaller than default */
  25773. + temp &= ~(3 << 2);
  25774. + temp |= (EHCI_TUNE_FLS << 2);
  25775. + switch (EHCI_TUNE_FLS) {
  25776. + case 0: ehci->periodic_size = 1024; break;
  25777. + case 1: ehci->periodic_size = 512; break;
  25778. + case 2: ehci->periodic_size = 256; break;
  25779. + default: BUG();
  25780. + }
  25781. + }
  25782. + ehci->command = temp;
  25783. +
  25784. + /* Accept arbitrarily long scatter-gather lists */
  25785. + hcd->self.sg_tablesize = ~0;
  25786. + return 0;
  25787. +}
  25788. +
  25789. +/* start HC running; it's halted, ehci_init() has been run (once) */
  25790. +static int ehci_run (struct usb_hcd *hcd)
  25791. +{
  25792. + struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  25793. + int retval;
  25794. + u32 temp;
  25795. + u32 hcc_params;
  25796. +
  25797. + hcd->uses_new_polling = 1;
  25798. + hcd->poll_rh = 0;
  25799. +
  25800. + /* EHCI spec section 4.1 */
  25801. + if ((retval = ehci_reset(ehci)) != 0) {
  25802. + ehci_mem_cleanup(ehci);
  25803. + return retval;
  25804. + }
  25805. + ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list);
  25806. + ehci_writel(ehci, (u32)ehci->async->qh_dma, &ehci->regs->async_next);
  25807. +
  25808. + /*
  25809. + * hcc_params controls whether ehci->regs->segment must (!!!)
  25810. + * be used; it constrains QH/ITD/SITD and QTD locations.
  25811. + * pci_pool consistent memory always uses segment zero.
  25812. + * streaming mappings for I/O buffers, like pci_map_single(),
  25813. + * can return segments above 4GB, if the device allows.
  25814. + *
  25815. + * NOTE: the dma mask is visible through dma_supported(), so
  25816. + * drivers can pass this info along ... like NETIF_F_HIGHDMA,
  25817. + * Scsi_Host.highmem_io, and so forth. It's readonly to all
  25818. + * host side drivers though.
  25819. + */
  25820. + hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);
  25821. + if (HCC_64BIT_ADDR(hcc_params)) {
  25822. + ehci_writel(ehci, 0, &ehci->regs->segment);
  25823. +#if 0
  25824. +// this is deeply broken on almost all architectures
  25825. + if (!dma_set_mask(hcd->self.controller, DMA_BIT_MASK(64)))
  25826. + ehci_info(ehci, "enabled 64bit DMA\n");
  25827. +#endif
  25828. + }
  25829. +
  25830. +
  25831. + // Philips, Intel, and maybe others need CMD_RUN before the
  25832. + // root hub will detect new devices (why?); NEC doesn't
  25833. + ehci->command &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET);
  25834. + ehci->command |= CMD_RUN;
  25835. + ehci_writel(ehci, ehci->command, &ehci->regs->command);
  25836. + dbg_cmd (ehci, "init", ehci->command);
  25837. +
  25838. + /*
  25839. + * Start, enabling full USB 2.0 functionality ... usb 1.1 devices
  25840. + * are explicitly handed to companion controller(s), so no TT is
  25841. + * involved with the root hub. (Except where one is integrated,
  25842. + * and there's no companion controller unless maybe for USB OTG.)
  25843. + *
  25844. + * Turning on the CF flag will transfer ownership of all ports
  25845. + * from the companions to the EHCI controller. If any of the
  25846. + * companions are in the middle of a port reset at the time, it
  25847. + * could cause trouble. Write-locking ehci_cf_port_reset_rwsem
  25848. + * guarantees that no resets are in progress. After we set CF,
  25849. + * a short delay lets the hardware catch up; new resets shouldn't
  25850. + * be started before the port switching actions could complete.
  25851. + */
  25852. + down_write(&ehci_cf_port_reset_rwsem);
  25853. + hcd->state = HC_STATE_RUNNING;
  25854. + ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
  25855. + ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
  25856. + msleep(5);
  25857. + up_write(&ehci_cf_port_reset_rwsem);
  25858. + ehci->last_periodic_enable = ktime_get_real();
  25859. +
  25860. + temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase));
  25861. + ehci_info (ehci,
  25862. + "USB %x.%x started, EHCI %x.%02x%s\n",
  25863. + ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
  25864. + temp >> 8, temp & 0xff,
  25865. + ignore_oc ? ", overcurrent ignored" : "");
  25866. +
  25867. + ehci_writel(ehci, INTR_MASK,
  25868. + &ehci->regs->intr_enable); /* Turn On Interrupts */
  25869. +
  25870. + /* GRR this is run-once init(), being done every time the HC starts.
  25871. + * So long as they're part of class devices, we can't do it init()
  25872. + * since the class device isn't created that early.
  25873. + */
  25874. + create_debug_files(ehci);
  25875. + create_companion_file(ehci);
  25876. +
  25877. + return 0;
  25878. +}
  25879. +
  25880. +/*-------------------------------------------------------------------------*/
  25881. +
  25882. +static irqreturn_t ehci_irq (struct usb_hcd *hcd)
  25883. +{
  25884. + struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  25885. + u32 status, masked_status, pcd_status = 0, cmd;
  25886. + int bh;
  25887. +
  25888. + spin_lock (&ehci->lock);
  25889. +
  25890. + status = ehci_readl(ehci, &ehci->regs->status);
  25891. +
  25892. + /* e.g. cardbus physical eject */
  25893. + if (status == ~(u32) 0) {
  25894. + ehci_dbg (ehci, "device removed\n");
  25895. + goto dead;
  25896. + }
  25897. +
  25898. + masked_status = status & INTR_MASK;
  25899. + if (!masked_status) { /* irq sharing? */
  25900. + spin_unlock(&ehci->lock);
  25901. + return IRQ_NONE;
  25902. + }
  25903. +
  25904. + /* clear (just) interrupts */
  25905. + ehci_writel(ehci, masked_status, &ehci->regs->status);
  25906. + cmd = ehci_readl(ehci, &ehci->regs->command);
  25907. + bh = 0;
  25908. +
  25909. +#ifdef VERBOSE_DEBUG
  25910. + /* unrequested/ignored: Frame List Rollover */
  25911. + dbg_status (ehci, "irq", status);
  25912. +#endif
  25913. +
  25914. + /* INT, ERR, and IAA interrupt rates can be throttled */
  25915. +
  25916. + /* normal [4.15.1.2] or error [4.15.1.1] completion */
  25917. + if (likely ((status & (STS_INT|STS_ERR)) != 0)) {
  25918. + if (likely ((status & STS_ERR) == 0))
  25919. + COUNT (ehci->stats.normal);
  25920. + else
  25921. + COUNT (ehci->stats.error);
  25922. + bh = 1;
  25923. + }
  25924. +
  25925. + /* complete the unlinking of some qh [4.15.2.3] */
  25926. + if (status & STS_IAA) {
  25927. + /* guard against (alleged) silicon errata */
  25928. + if (cmd & CMD_IAAD) {
  25929. + ehci_writel(ehci, cmd & ~CMD_IAAD,
  25930. + &ehci->regs->command);
  25931. + ehci_dbg(ehci, "IAA with IAAD still set?\n");
  25932. + }
  25933. + if (ehci->reclaim) {
  25934. + COUNT(ehci->stats.reclaim);
  25935. + end_unlink_async(ehci);
  25936. + } else
  25937. + ehci_dbg(ehci, "IAA with nothing to reclaim?\n");
  25938. + }
  25939. +
  25940. + /* remote wakeup [4.3.1] */
  25941. + if (status & STS_PCD) {
  25942. + unsigned i = HCS_N_PORTS (ehci->hcs_params);
  25943. +
  25944. + /* kick root hub later */
  25945. + pcd_status = status;
  25946. +
  25947. + /* resume root hub? */
  25948. + if (!(cmd & CMD_RUN))
  25949. + usb_hcd_resume_root_hub(hcd);
  25950. +
  25951. + while (i--) {
  25952. + int pstatus = ehci_readl(ehci,
  25953. + &ehci->regs->port_status [i]);
  25954. +
  25955. + if (pstatus & PORT_OWNER)
  25956. + continue;
  25957. + if (!(test_bit(i, &ehci->suspended_ports) &&
  25958. + ((pstatus & PORT_RESUME) ||
  25959. + !(pstatus & PORT_SUSPEND)) &&
  25960. + (pstatus & PORT_PE) &&
  25961. + ehci->reset_done[i] == 0))
  25962. + continue;
  25963. +
  25964. + /* start 20 msec resume signaling from this port,
  25965. + * and make khubd collect PORT_STAT_C_SUSPEND to
  25966. + * stop that signaling. Use 5 ms extra for safety,
  25967. + * like usb_port_resume() does.
  25968. + */
  25969. + ehci->reset_done[i] = jiffies + msecs_to_jiffies(25);
  25970. + ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
  25971. + mod_timer(&hcd->rh_timer, ehci->reset_done[i]);
  25972. + }
  25973. + }
  25974. +
  25975. + /* PCI errors [4.15.2.4] */
  25976. + if (unlikely ((status & STS_FATAL) != 0)) {
  25977. + ehci_err(ehci, "fatal error\n");
  25978. + dbg_cmd(ehci, "fatal", cmd);
  25979. + dbg_status(ehci, "fatal", status);
  25980. + ehci_halt(ehci);
  25981. +dead:
  25982. + ehci_reset(ehci);
  25983. + ehci_writel(ehci, 0, &ehci->regs->configured_flag);
  25984. + /* generic layer kills/unlinks all urbs, then
  25985. + * uses ehci_stop to clean up the rest
  25986. + */
  25987. + bh = 1;
  25988. + }
  25989. +
  25990. + if (bh)
  25991. + ehci_work (ehci);
  25992. + spin_unlock (&ehci->lock);
  25993. + if (pcd_status)
  25994. + usb_hcd_poll_rh_status(hcd);
  25995. + return IRQ_HANDLED;
  25996. +}
  25997. +
  25998. +/*-------------------------------------------------------------------------*/
  25999. +
  26000. +/*
  26001. + * non-error returns are a promise to giveback() the urb later
  26002. + * we drop ownership so next owner (or urb unlink) can get it
  26003. + *
  26004. + * urb + dev is in hcd.self.controller.urb_list
  26005. + * we're queueing TDs onto software and hardware lists
  26006. + *
  26007. + * hcd-specific init for hcpriv hasn't been done yet
  26008. + *
  26009. + * NOTE: control, bulk, and interrupt share the same code to append TDs
  26010. + * to a (possibly active) QH, and the same QH scanning code.
  26011. + */
  26012. +static int ehci_urb_enqueue (
  26013. + struct usb_hcd *hcd,
  26014. + struct urb *urb,
  26015. + gfp_t mem_flags
  26016. +) {
  26017. + struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  26018. + struct list_head qtd_list;
  26019. +
  26020. + INIT_LIST_HEAD (&qtd_list);
  26021. +
  26022. + switch (usb_pipetype (urb->pipe)) {
  26023. + case PIPE_CONTROL:
  26024. + /* qh_completions() code doesn't handle all the fault cases
  26025. + * in multi-TD control transfers. Even 1KB is rare anyway.
  26026. + */
  26027. + if (urb->transfer_buffer_length > (16 * 1024))
  26028. + return -EMSGSIZE;
  26029. + /* FALLTHROUGH */
  26030. + /* case PIPE_BULK: */
  26031. + default:
  26032. + if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags))
  26033. + return -ENOMEM;
  26034. + return submit_async(ehci, urb, &qtd_list, mem_flags);
  26035. +
  26036. + case PIPE_INTERRUPT:
  26037. + if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags))
  26038. + return -ENOMEM;
  26039. + return intr_submit(ehci, urb, &qtd_list, mem_flags);
  26040. +
  26041. + case PIPE_ISOCHRONOUS:
  26042. + if (urb->dev->speed == USB_SPEED_HIGH)
  26043. + return itd_submit (ehci, urb, mem_flags);
  26044. + else
  26045. + return sitd_submit (ehci, urb, mem_flags);
  26046. + }
  26047. +}
  26048. +
  26049. +static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
  26050. +{
  26051. + /* failfast */
  26052. + if (!HC_IS_RUNNING(ehci_to_hcd(ehci)->state) && ehci->reclaim)
  26053. + end_unlink_async(ehci);
  26054. +
  26055. + /* If the QH isn't linked then there's nothing we can do
  26056. + * unless we were called during a giveback, in which case
  26057. + * qh_completions() has to deal with it.
  26058. + */
  26059. + if (qh->qh_state != QH_STATE_LINKED) {
  26060. + if (qh->qh_state == QH_STATE_COMPLETING)
  26061. + qh->needs_rescan = 1;
  26062. + return;
  26063. + }
  26064. +
  26065. + /* defer till later if busy */
  26066. + if (ehci->reclaim) {
  26067. + struct ehci_qh *last;
  26068. +
  26069. + for (last = ehci->reclaim;
  26070. + last->reclaim;
  26071. + last = last->reclaim)
  26072. + continue;
  26073. + qh->qh_state = QH_STATE_UNLINK_WAIT;
  26074. + last->reclaim = qh;
  26075. +
  26076. + /* start IAA cycle */
  26077. + } else
  26078. + start_unlink_async (ehci, qh);
  26079. +}
  26080. +
  26081. +/* remove from hardware lists
  26082. + * completions normally happen asynchronously
  26083. + */
  26084. +
  26085. +static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
  26086. +{
  26087. + struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  26088. + struct ehci_qh *qh;
  26089. + unsigned long flags;
  26090. + int rc;
  26091. +
  26092. + spin_lock_irqsave (&ehci->lock, flags);
  26093. + rc = usb_hcd_check_unlink_urb(hcd, urb, status);
  26094. + if (rc)
  26095. + goto done;
  26096. +
  26097. + switch (usb_pipetype (urb->pipe)) {
  26098. + // case PIPE_CONTROL:
  26099. + // case PIPE_BULK:
  26100. + default:
  26101. + qh = (struct ehci_qh *) urb->hcpriv;
  26102. + if (!qh)
  26103. + break;
  26104. + switch (qh->qh_state) {
  26105. + case QH_STATE_LINKED:
  26106. + case QH_STATE_COMPLETING:
  26107. + unlink_async(ehci, qh);
  26108. + break;
  26109. + case QH_STATE_UNLINK:
  26110. + case QH_STATE_UNLINK_WAIT:
  26111. + /* already started */
  26112. + break;
  26113. + case QH_STATE_IDLE:
  26114. + /* QH might be waiting for a Clear-TT-Buffer */
  26115. + qh_completions(ehci, qh);
  26116. + break;
  26117. + }
  26118. + break;
  26119. +
  26120. + case PIPE_INTERRUPT:
  26121. + qh = (struct ehci_qh *) urb->hcpriv;
  26122. + if (!qh)
  26123. + break;
  26124. + switch (qh->qh_state) {
  26125. + case QH_STATE_LINKED:
  26126. + case QH_STATE_COMPLETING:
  26127. + intr_deschedule (ehci, qh);
  26128. + break;
  26129. + case QH_STATE_IDLE:
  26130. + qh_completions (ehci, qh);
  26131. + break;
  26132. + default:
  26133. + ehci_dbg (ehci, "bogus qh %p state %d\n",
  26134. + qh, qh->qh_state);
  26135. + goto done;
  26136. + }
  26137. + break;
  26138. +
  26139. + case PIPE_ISOCHRONOUS:
  26140. + // itd or sitd ...
  26141. +
  26142. + // wait till next completion, do it then.
  26143. + // completion irqs can wait up to 1024 msec,
  26144. + break;
  26145. + }
  26146. +done:
  26147. + spin_unlock_irqrestore (&ehci->lock, flags);
  26148. + return rc;
  26149. +}
  26150. +
  26151. +/*-------------------------------------------------------------------------*/
  26152. +
  26153. +// bulk qh holds the data toggle
  26154. +
  26155. +static void
  26156. +ehci_endpoint_disable (struct usb_hcd *hcd, struct usb_host_endpoint *ep)
  26157. +{
  26158. + struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  26159. + unsigned long flags;
  26160. + struct ehci_qh *qh, *tmp;
  26161. +
  26162. + /* ASSERT: any requests/urbs are being unlinked */
  26163. + /* ASSERT: nobody can be submitting urbs for this any more */
  26164. +
  26165. +rescan:
  26166. + spin_lock_irqsave (&ehci->lock, flags);
  26167. + qh = ep->hcpriv;
  26168. + if (!qh)
  26169. + goto done;
  26170. +
  26171. + /* endpoints can be iso streams. for now, we don't
  26172. + * accelerate iso completions ... so spin a while.
  26173. + */
  26174. + if (qh->hw == NULL) {
  26175. + ehci_vdbg (ehci, "iso delay\n");
  26176. + goto idle_timeout;
  26177. + }
  26178. +
  26179. + if (!HC_IS_RUNNING (hcd->state))
  26180. + qh->qh_state = QH_STATE_IDLE;
  26181. + switch (qh->qh_state) {
  26182. + case QH_STATE_LINKED:
  26183. + case QH_STATE_COMPLETING:
  26184. + for (tmp = ehci->async->qh_next.qh;
  26185. + tmp && tmp != qh;
  26186. + tmp = tmp->qh_next.qh)
  26187. + continue;
  26188. + /* periodic qh self-unlinks on empty */
  26189. + if (!tmp)
  26190. + goto nogood;
  26191. + unlink_async (ehci, qh);
  26192. + /* FALL THROUGH */
  26193. + case QH_STATE_UNLINK: /* wait for hw to finish? */
  26194. + case QH_STATE_UNLINK_WAIT:
  26195. +idle_timeout:
  26196. + spin_unlock_irqrestore (&ehci->lock, flags);
  26197. + schedule_timeout_uninterruptible(1);
  26198. + goto rescan;
  26199. + case QH_STATE_IDLE: /* fully unlinked */
  26200. + if (qh->clearing_tt)
  26201. + goto idle_timeout;
  26202. + if (list_empty (&qh->qtd_list)) {
  26203. + qh_put (qh);
  26204. + break;
  26205. + }
  26206. + /* else FALL THROUGH */
  26207. + default:
  26208. +nogood:
  26209. + /* caller was supposed to have unlinked any requests;
  26210. + * that's not our job. just leak this memory.
  26211. + */
  26212. + ehci_err (ehci, "qh %p (#%02x) state %d%s\n",
  26213. + qh, ep->desc.bEndpointAddress, qh->qh_state,
  26214. + list_empty (&qh->qtd_list) ? "" : "(has tds)");
  26215. + break;
  26216. + }
  26217. + ep->hcpriv = NULL;
  26218. +done:
  26219. + spin_unlock_irqrestore (&ehci->lock, flags);
  26220. + return;
  26221. +}
  26222. +
  26223. +static void
  26224. +ehci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
  26225. +{
  26226. + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
  26227. + struct ehci_qh *qh;
  26228. + int eptype = usb_endpoint_type(&ep->desc);
  26229. + int epnum = usb_endpoint_num(&ep->desc);
  26230. + int is_out = usb_endpoint_dir_out(&ep->desc);
  26231. + unsigned long flags;
  26232. +
  26233. + if (eptype != USB_ENDPOINT_XFER_BULK && eptype != USB_ENDPOINT_XFER_INT)
  26234. + return;
  26235. +
  26236. + spin_lock_irqsave(&ehci->lock, flags);
  26237. + qh = ep->hcpriv;
  26238. +
  26239. + /* For Bulk and Interrupt endpoints we maintain the toggle state
  26240. + * in the hardware; the toggle bits in udev aren't used at all.
  26241. + * When an endpoint is reset by usb_clear_halt() we must reset
  26242. + * the toggle bit in the QH.
  26243. + */
  26244. + if (qh) {
  26245. + usb_settoggle(qh->dev, epnum, is_out, 0);
  26246. + if (!list_empty(&qh->qtd_list)) {
  26247. + WARN_ONCE(1, "clear_halt for a busy endpoint\n");
  26248. + } else if (qh->qh_state == QH_STATE_LINKED ||
  26249. + qh->qh_state == QH_STATE_COMPLETING) {
  26250. +
  26251. + /* The toggle value in the QH can't be updated
  26252. + * while the QH is active. Unlink it now;
  26253. + * re-linking will call qh_refresh().
  26254. + */
  26255. + if (eptype == USB_ENDPOINT_XFER_BULK)
  26256. + unlink_async(ehci, qh);
  26257. + else
  26258. + intr_deschedule(ehci, qh);
  26259. + }
  26260. + }
  26261. + spin_unlock_irqrestore(&ehci->lock, flags);
  26262. +}
  26263. +
  26264. +static int ehci_get_frame (struct usb_hcd *hcd)
  26265. +{
  26266. + struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  26267. + return (ehci_readl(ehci, &ehci->regs->frame_index) >> 3) %
  26268. + ehci->periodic_size;
  26269. +}
  26270. +
  26271. +/*-------------------------------------------------------------------------*/
  26272. +
  26273. +MODULE_DESCRIPTION(DRIVER_DESC);
  26274. +MODULE_AUTHOR (DRIVER_AUTHOR);
  26275. +MODULE_LICENSE ("GPL");
  26276. +
  26277. +#ifdef CONFIG_PCI
  26278. +#include "ehci-pci.c"
  26279. +#define PCI_DRIVER ehci_pci_driver
  26280. +#endif
  26281. +
  26282. +#ifdef CONFIG_USB_EHCI_FSL
  26283. +#include "ehci-fsl.c"
  26284. +#define PLATFORM_DRIVER ehci_fsl_driver
  26285. +#endif
  26286. +
  26287. +#ifdef CONFIG_USB_EHCI_MXC
  26288. +#include "ehci-mxc.c"
  26289. +#define PLATFORM_DRIVER ehci_mxc_driver
  26290. +#endif
  26291. +
  26292. +#ifdef CONFIG_SOC_AU1200
  26293. +#include "ehci-au1xxx.c"
  26294. +#define PLATFORM_DRIVER ehci_hcd_au1xxx_driver
  26295. +#endif
  26296. +
  26297. +#ifdef CONFIG_ARCH_OMAP3
  26298. +#include "ehci-omap.c"
  26299. +#define PLATFORM_DRIVER ehci_hcd_omap_driver
  26300. +#endif
  26301. +
  26302. +#ifdef CONFIG_PPC_PS3
  26303. +#include "ehci-ps3.c"
  26304. +#define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver
  26305. +#endif
  26306. +
  26307. +#ifdef CONFIG_USB_EHCI_HCD_PPC_OF
  26308. +#include "ehci-ppc-of.c"
  26309. +#define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver
  26310. +#endif
  26311. +
  26312. +#ifdef CONFIG_XPS_USB_HCD_XILINX
  26313. +#include "ehci-xilinx-of.c"
  26314. +#define XILINX_OF_PLATFORM_DRIVER ehci_hcd_xilinx_of_driver
  26315. +#endif
  26316. +
  26317. +#ifdef CONFIG_PLAT_ORION
  26318. +#include "ehci-orion.c"
  26319. +#define PLATFORM_DRIVER ehci_orion_driver
  26320. +#endif
  26321. +
  26322. +#ifdef CONFIG_ARCH_IXP4XX
  26323. +#include "ehci-ixp4xx.c"
  26324. +#define PLATFORM_DRIVER ixp4xx_ehci_driver
  26325. +#endif
  26326. +
  26327. +#ifdef CONFIG_USB_W90X900_EHCI
  26328. +#include "ehci-w90x900.c"
  26329. +#define PLATFORM_DRIVER ehci_hcd_w90x900_driver
  26330. +#endif
  26331. +
  26332. +#ifdef CONFIG_ARCH_AT91
  26333. +#include "ehci-atmel.c"
  26334. +#define PLATFORM_DRIVER ehci_atmel_driver
  26335. +#endif
  26336. +
  26337. +#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
  26338. + !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
  26339. + !defined(XILINX_OF_PLATFORM_DRIVER)
  26340. +#error "missing bus glue for ehci-hcd"
  26341. +#endif
  26342. +
  26343. +static int __init ehci_hcd_init(void)
  26344. +{
  26345. + int retval = 0;
  26346. +
  26347. + if (usb_disabled())
  26348. + return -ENODEV;
  26349. +
  26350. + printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name);
  26351. + set_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
  26352. + if (test_bit(USB_UHCI_LOADED, &usb_hcds_loaded) ||
  26353. + test_bit(USB_OHCI_LOADED, &usb_hcds_loaded))
  26354. + printk(KERN_WARNING "Warning! ehci_hcd should always be loaded"
  26355. + " before uhci_hcd and ohci_hcd, not after\n");
  26356. +
  26357. + pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
  26358. + hcd_name,
  26359. + sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
  26360. + sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
  26361. +
  26362. +#ifdef DEBUG
  26363. + ehci_debug_root = debugfs_create_dir("ehci", usb_debug_root);
  26364. + if (!ehci_debug_root) {
  26365. + retval = -ENOENT;
  26366. + goto err_debug;
  26367. + }
  26368. +#endif
  26369. +
  26370. +#ifdef PLATFORM_DRIVER
  26371. + retval = platform_driver_register(&PLATFORM_DRIVER);
  26372. + if (retval < 0)
  26373. + goto clean0;
  26374. +#endif
  26375. +
  26376. +#ifdef PCI_DRIVER
  26377. + retval = pci_register_driver(&PCI_DRIVER);
  26378. + if (retval < 0)
  26379. + goto clean1;
  26380. +#endif
  26381. +
  26382. +#ifdef PS3_SYSTEM_BUS_DRIVER
  26383. + retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER);
  26384. + if (retval < 0)
  26385. + goto clean2;
  26386. +#endif
  26387. +
  26388. +#ifdef OF_PLATFORM_DRIVER
  26389. + retval = of_register_platform_driver(&OF_PLATFORM_DRIVER);
  26390. + if (retval < 0)
  26391. + goto clean3;
  26392. +#endif
  26393. +
  26394. +#ifdef XILINX_OF_PLATFORM_DRIVER
  26395. + retval = of_register_platform_driver(&XILINX_OF_PLATFORM_DRIVER);
  26396. + if (retval < 0)
  26397. + goto clean4;
  26398. +#endif
  26399. + return retval;
  26400. +
  26401. +#ifdef XILINX_OF_PLATFORM_DRIVER
  26402. + /* of_unregister_platform_driver(&XILINX_OF_PLATFORM_DRIVER); */
  26403. +clean4:
  26404. +#endif
  26405. +#ifdef OF_PLATFORM_DRIVER
  26406. + of_unregister_platform_driver(&OF_PLATFORM_DRIVER);
  26407. +clean3:
  26408. +#endif
  26409. +#ifdef PS3_SYSTEM_BUS_DRIVER
  26410. + ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
  26411. +clean2:
  26412. +#endif
  26413. +#ifdef PCI_DRIVER
  26414. + pci_unregister_driver(&PCI_DRIVER);
  26415. +clean1:
  26416. +#endif
  26417. +#ifdef PLATFORM_DRIVER
  26418. + platform_driver_unregister(&PLATFORM_DRIVER);
  26419. +clean0:
  26420. +#endif
  26421. +#ifdef DEBUG
  26422. + debugfs_remove(ehci_debug_root);
  26423. + ehci_debug_root = NULL;
  26424. +err_debug:
  26425. +#endif
  26426. + clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
  26427. + return retval;
  26428. +}
  26429. +module_init(ehci_hcd_init);
  26430. +
  26431. +static void __exit ehci_hcd_cleanup(void)
  26432. +{
  26433. +#ifdef XILINX_OF_PLATFORM_DRIVER
  26434. + of_unregister_platform_driver(&XILINX_OF_PLATFORM_DRIVER);
  26435. +#endif
  26436. +#ifdef OF_PLATFORM_DRIVER
  26437. + of_unregister_platform_driver(&OF_PLATFORM_DRIVER);
  26438. +#endif
  26439. +#ifdef PLATFORM_DRIVER
  26440. + platform_driver_unregister(&PLATFORM_DRIVER);
  26441. +#endif
  26442. +#ifdef PCI_DRIVER
  26443. + pci_unregister_driver(&PCI_DRIVER);
  26444. +#endif
  26445. +#ifdef PS3_SYSTEM_BUS_DRIVER
  26446. + ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
  26447. +#endif
  26448. +#ifdef DEBUG
  26449. + debugfs_remove(ehci_debug_root);
  26450. +#endif
  26451. + clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
  26452. +}
  26453. +module_exit(ehci_hcd_cleanup);
  26454. +
  26455. diff -Nur linux-2.6.35.7.orig/drivers/usb/host/Kconfig linux-2.6.35.7/drivers/usb/host/Kconfig
  26456. --- linux-2.6.35.7.orig/drivers/usb/host/Kconfig 2010-09-29 03:09:08.000000000 +0200
  26457. +++ linux-2.6.35.7/drivers/usb/host/Kconfig 2010-10-14 20:28:01.385601136 +0200
  26458. @@ -109,6 +109,13 @@
  26459. support both high speed and full speed devices, or high speed
  26460. devices only.
  26461. +config USB_EHCI_AR71XX
  26462. + bool "USB EHCI support for AR71xx"
  26463. + depends on USB_EHCI_HCD && ATHEROS_AR71XX
  26464. + default y
  26465. + help
  26466. + Support for Atheros AR71xx built-in EHCI controller
  26467. +
  26468. config USB_EHCI_FSL
  26469. bool "Support for Freescale on-chip EHCI USB controller"
  26470. depends on USB_EHCI_HCD && FSL_SOC
  26471. @@ -222,6 +229,13 @@
  26472. Enables support for the on-chip OHCI controller on
  26473. OMAP3 and later chips.
  26474. +config USB_OHCI_AR71XX
  26475. + bool "USB OHCI support for Atheros AR71xx"
  26476. + depends on USB_OHCI_HCD && ATHEROS_AR71XX
  26477. + default y
  26478. + help
  26479. + Support for Atheros AR71xx built-in OHCI controller
  26480. +
  26481. config USB_OHCI_HCD_PPC_SOC
  26482. bool "OHCI support for on-chip PPC USB controller"
  26483. depends on USB_OHCI_HCD && (STB03xxx || PPC_MPC52xx)
  26484. diff -Nur linux-2.6.35.7.orig/drivers/usb/host/Kconfig.orig linux-2.6.35.7/drivers/usb/host/Kconfig.orig
  26485. --- linux-2.6.35.7.orig/drivers/usb/host/Kconfig.orig 1970-01-01 01:00:00.000000000 +0100
  26486. +++ linux-2.6.35.7/drivers/usb/host/Kconfig.orig 2010-09-29 03:09:08.000000000 +0200
  26487. @@ -0,0 +1,427 @@
  26488. +#
  26489. +# USB Host Controller Drivers
  26490. +#
  26491. +comment "USB Host Controller Drivers"
  26492. + depends on USB
  26493. +
  26494. +config USB_C67X00_HCD
  26495. + tristate "Cypress C67x00 HCD support"
  26496. + depends on USB
  26497. + help
  26498. + The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
  26499. + host/peripheral/OTG USB controllers.
  26500. +
  26501. + Enable this option to support this chip in host controller mode.
  26502. + If unsure, say N.
  26503. +
  26504. + To compile this driver as a module, choose M here: the
  26505. + module will be called c67x00.
  26506. +
  26507. +config USB_XHCI_HCD
  26508. + tristate "xHCI HCD (USB 3.0) support (EXPERIMENTAL)"
  26509. + depends on USB && PCI && EXPERIMENTAL
  26510. + ---help---
  26511. + The eXtensible Host Controller Interface (xHCI) is standard for USB 3.0
  26512. + "SuperSpeed" host controller hardware.
  26513. +
  26514. + To compile this driver as a module, choose M here: the
  26515. + module will be called xhci-hcd.
  26516. +
  26517. +config USB_XHCI_HCD_DEBUGGING
  26518. + bool "Debugging for the xHCI host controller"
  26519. + depends on USB_XHCI_HCD
  26520. + ---help---
  26521. + Say 'Y' to turn on debugging for the xHCI host controller driver.
  26522. + This will spew debugging output, even in interrupt context.
  26523. + This should only be used for debugging xHCI driver bugs.
  26524. +
  26525. + If unsure, say N.
  26526. +
  26527. +config USB_EHCI_HCD
  26528. + tristate "EHCI HCD (USB 2.0) support"
  26529. + depends on USB && USB_ARCH_HAS_EHCI
  26530. + ---help---
  26531. + The Enhanced Host Controller Interface (EHCI) is standard for USB 2.0
  26532. + "high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller hardware.
  26533. + If your USB host controller supports USB 2.0, you will likely want to
  26534. + configure this Host Controller Driver.
  26535. +
  26536. + EHCI controllers are packaged with "companion" host controllers (OHCI
  26537. + or UHCI) to handle USB 1.1 devices connected to root hub ports. Ports
  26538. + will connect to EHCI if the device is high speed, otherwise they
  26539. + connect to a companion controller. If you configure EHCI, you should
  26540. + probably configure the OHCI (for NEC and some other vendors) USB Host
  26541. + Controller Driver or UHCI (for Via motherboards) Host Controller
  26542. + Driver too.
  26543. +
  26544. + You may want to read <file:Documentation/usb/ehci.txt>.
  26545. +
  26546. + To compile this driver as a module, choose M here: the
  26547. + module will be called ehci-hcd.
  26548. +
  26549. +config USB_EHCI_ROOT_HUB_TT
  26550. + bool "Root Hub Transaction Translators"
  26551. + depends on USB_EHCI_HCD
  26552. + ---help---
  26553. + Some EHCI chips have vendor-specific extensions to integrate
  26554. + transaction translators, so that no OHCI or UHCI companion
  26555. + controller is needed. It's safe to say "y" even if your
  26556. + controller doesn't support this feature.
  26557. +
  26558. + This supports the EHCI implementation that's originally
  26559. + from ARC, and has since changed hands a few times.
  26560. +
  26561. +config USB_EHCI_TT_NEWSCHED
  26562. + bool "Improved Transaction Translator scheduling (EXPERIMENTAL)"
  26563. + depends on USB_EHCI_HCD && EXPERIMENTAL
  26564. + ---help---
  26565. + This changes the periodic scheduling code to fill more of the low
  26566. + and full speed bandwidth available from the Transaction Translator
  26567. + (TT) in USB 2.0 hubs. Without this, only one transfer will be
  26568. + issued in each microframe, significantly reducing the number of
  26569. + periodic low/fullspeed transfers possible.
  26570. +
  26571. + If you have multiple periodic low/fullspeed devices connected to a
  26572. + highspeed USB hub which is connected to a highspeed USB Host
  26573. + Controller, and some of those devices will not work correctly
  26574. + (possibly due to "ENOSPC" or "-28" errors), say Y.
  26575. +
  26576. + If unsure, say N.
  26577. +
  26578. +config USB_EHCI_BIG_ENDIAN_MMIO
  26579. + bool
  26580. + depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX)
  26581. + default y
  26582. +
  26583. +config USB_EHCI_BIG_ENDIAN_DESC
  26584. + bool
  26585. + depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX)
  26586. + default y
  26587. +
  26588. +config XPS_USB_HCD_XILINX
  26589. + bool "Use Xilinx usb host EHCI controller core"
  26590. + depends on USB_EHCI_HCD && (PPC32 || MICROBLAZE)
  26591. + select USB_EHCI_BIG_ENDIAN_DESC
  26592. + select USB_EHCI_BIG_ENDIAN_MMIO
  26593. + ---help---
  26594. + Xilinx xps USB host controller core is EHCI compilant and has
  26595. + transaction translator built-in. It can be configured to either
  26596. + support both high speed and full speed devices, or high speed
  26597. + devices only.
  26598. +
  26599. +config USB_EHCI_FSL
  26600. + bool "Support for Freescale on-chip EHCI USB controller"
  26601. + depends on USB_EHCI_HCD && FSL_SOC
  26602. + select USB_EHCI_ROOT_HUB_TT
  26603. + ---help---
  26604. + Variation of ARC USB block used in some Freescale chips.
  26605. +
  26606. +config USB_EHCI_MXC
  26607. + bool "Support for Freescale on-chip EHCI USB controller"
  26608. + depends on USB_EHCI_HCD && ARCH_MXC
  26609. + select USB_EHCI_ROOT_HUB_TT
  26610. + ---help---
  26611. + Variation of ARC USB block used in some Freescale chips.
  26612. +
  26613. +config USB_EHCI_HCD_PPC_OF
  26614. + bool "EHCI support for PPC USB controller on OF platform bus"
  26615. + depends on USB_EHCI_HCD && PPC_OF
  26616. + default y
  26617. + ---help---
  26618. + Enables support for the USB controller present on the PowerPC
  26619. + OpenFirmware platform bus.
  26620. +
  26621. +config USB_W90X900_EHCI
  26622. + bool "W90X900(W90P910) EHCI support"
  26623. + depends on USB_EHCI_HCD && ARCH_W90X900
  26624. + ---help---
  26625. + Enables support for the W90X900 USB controller
  26626. +
  26627. +config USB_OXU210HP_HCD
  26628. + tristate "OXU210HP HCD support"
  26629. + depends on USB
  26630. + ---help---
  26631. + The OXU210HP is an USB host/OTG/device controller. Enable this
  26632. + option if your board has this chip. If unsure, say N.
  26633. +
  26634. + This driver does not support isochronous transfers and doesn't
  26635. + implement OTG nor USB device controllers.
  26636. +
  26637. + To compile this driver as a module, choose M here: the
  26638. + module will be called oxu210hp-hcd.
  26639. +
  26640. +config USB_ISP116X_HCD
  26641. + tristate "ISP116X HCD support"
  26642. + depends on USB
  26643. + ---help---
  26644. + The ISP1160 and ISP1161 chips are USB host controllers. Enable this
  26645. + option if your board has this chip. If unsure, say N.
  26646. +
  26647. + This driver does not support isochronous transfers.
  26648. +
  26649. + To compile this driver as a module, choose M here: the
  26650. + module will be called isp116x-hcd.
  26651. +
  26652. +config USB_ISP1760_HCD
  26653. + tristate "ISP 1760 HCD support"
  26654. + depends on USB && EXPERIMENTAL
  26655. + ---help---
  26656. + The ISP1760 chip is a USB 2.0 host controller.
  26657. +
  26658. + This driver does not support isochronous transfers or OTG.
  26659. + This USB controller is usually attached to a non-DMA-Master
  26660. + capable bus. NXP's eval kit brings this chip on PCI card
  26661. + where the chip itself is behind a PLB to simulate such
  26662. + a bus.
  26663. +
  26664. + To compile this driver as a module, choose M here: the
  26665. + module will be called isp1760.
  26666. +
  26667. +config USB_ISP1362_HCD
  26668. + tristate "ISP1362 HCD support"
  26669. + depends on USB
  26670. + default N
  26671. + ---help---
  26672. + Supports the Philips ISP1362 chip as a host controller
  26673. +
  26674. + This driver does not support isochronous transfers.
  26675. +
  26676. + To compile this driver as a module, choose M here: the
  26677. + module will be called isp1362-hcd.
  26678. +
  26679. +config USB_OHCI_HCD
  26680. + tristate "OHCI HCD support"
  26681. + depends on USB && USB_ARCH_HAS_OHCI
  26682. + select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3
  26683. + select USB_OTG_UTILS if ARCH_OMAP
  26684. + ---help---
  26685. + The Open Host Controller Interface (OHCI) is a standard for accessing
  26686. + USB 1.1 host controller hardware. It does more in hardware than Intel's
  26687. + UHCI specification. If your USB host controller follows the OHCI spec,
  26688. + say Y. On most non-x86 systems, and on x86 hardware that's not using a
  26689. + USB controller from Intel or VIA, this is appropriate. If your host
  26690. + controller doesn't use PCI, this is probably appropriate. For a PCI
  26691. + based system where you're not sure, the "lspci -v" entry will list the
  26692. + right "prog-if" for your USB controller(s): EHCI, OHCI, or UHCI.
  26693. +
  26694. + To compile this driver as a module, choose M here: the
  26695. + module will be called ohci-hcd.
  26696. +
  26697. +config USB_OHCI_HCD_OMAP1
  26698. + bool "OHCI support for OMAP1/2 chips"
  26699. + depends on USB_OHCI_HCD && (ARCH_OMAP1 || ARCH_OMAP2)
  26700. + default y
  26701. + ---help---
  26702. + Enables support for the OHCI controller on OMAP1/2 chips.
  26703. +
  26704. +config USB_OHCI_HCD_OMAP3
  26705. + bool "OHCI support for OMAP3 and later chips"
  26706. + depends on USB_OHCI_HCD && (ARCH_OMAP3 || ARCH_OMAP4)
  26707. + default y
  26708. + ---help---
  26709. + Enables support for the on-chip OHCI controller on
  26710. + OMAP3 and later chips.
  26711. +
  26712. +config USB_OHCI_HCD_PPC_SOC
  26713. + bool "OHCI support for on-chip PPC USB controller"
  26714. + depends on USB_OHCI_HCD && (STB03xxx || PPC_MPC52xx)
  26715. + default y
  26716. + select USB_OHCI_BIG_ENDIAN_DESC
  26717. + select USB_OHCI_BIG_ENDIAN_MMIO
  26718. + ---help---
  26719. + Enables support for the USB controller on the MPC52xx or
  26720. + STB03xxx processor chip. If unsure, say Y.
  26721. +
  26722. +config USB_OHCI_HCD_PPC_OF_BE
  26723. + bool "OHCI support for OF platform bus (big endian)"
  26724. + depends on USB_OHCI_HCD && PPC_OF
  26725. + select USB_OHCI_BIG_ENDIAN_DESC
  26726. + select USB_OHCI_BIG_ENDIAN_MMIO
  26727. + ---help---
  26728. + Enables support for big-endian USB controllers present on the
  26729. + OpenFirmware platform bus.
  26730. +
  26731. +config USB_OHCI_HCD_PPC_OF_LE
  26732. + bool "OHCI support for OF platform bus (little endian)"
  26733. + depends on USB_OHCI_HCD && PPC_OF
  26734. + select USB_OHCI_LITTLE_ENDIAN
  26735. + ---help---
  26736. + Enables support for little-endian USB controllers present on the
  26737. + OpenFirmware platform bus.
  26738. +
  26739. +config USB_OHCI_HCD_PPC_OF
  26740. + bool
  26741. + depends on USB_OHCI_HCD && PPC_OF
  26742. + default USB_OHCI_HCD_PPC_OF_BE || USB_OHCI_HCD_PPC_OF_LE
  26743. +
  26744. +config USB_OHCI_HCD_PCI
  26745. + bool "OHCI support for PCI-bus USB controllers"
  26746. + depends on USB_OHCI_HCD && PCI && (STB03xxx || PPC_MPC52xx || USB_OHCI_HCD_PPC_OF)
  26747. + default y
  26748. + select USB_OHCI_LITTLE_ENDIAN
  26749. + ---help---
  26750. + Enables support for PCI-bus plug-in USB controller cards.
  26751. + If unsure, say Y.
  26752. +
  26753. +config USB_OHCI_HCD_SSB
  26754. + bool "OHCI support for Broadcom SSB OHCI core"
  26755. + depends on USB_OHCI_HCD && (SSB = y || SSB = USB_OHCI_HCD) && EXPERIMENTAL
  26756. + default n
  26757. + ---help---
  26758. + Support for the Sonics Silicon Backplane (SSB) attached
  26759. + Broadcom USB OHCI core.
  26760. +
  26761. + This device is present in some embedded devices with
  26762. + Broadcom based SSB bus.
  26763. +
  26764. + If unsure, say N.
  26765. +
  26766. +config USB_OHCI_BIG_ENDIAN_DESC
  26767. + bool
  26768. + depends on USB_OHCI_HCD
  26769. + default n
  26770. +
  26771. +config USB_OHCI_BIG_ENDIAN_MMIO
  26772. + bool
  26773. + depends on USB_OHCI_HCD
  26774. + default n
  26775. +
  26776. +config USB_OHCI_LITTLE_ENDIAN
  26777. + bool
  26778. + depends on USB_OHCI_HCD
  26779. + default n if STB03xxx || PPC_MPC52xx
  26780. + default y
  26781. +
  26782. +config USB_UHCI_HCD
  26783. + tristate "UHCI HCD (most Intel and VIA) support"
  26784. + depends on USB && PCI
  26785. + ---help---
  26786. + The Universal Host Controller Interface is a standard by Intel for
  26787. + accessing the USB hardware in the PC (which is also called the USB
  26788. + host controller). If your USB host controller conforms to this
  26789. + standard, you may want to say Y, but see below. All recent boards
  26790. + with Intel PCI chipsets (like intel 430TX, 440FX, 440LX, 440BX,
  26791. + i810, i820) conform to this standard. Also all VIA PCI chipsets
  26792. + (like VIA VP2, VP3, MVP3, Apollo Pro, Apollo Pro II or Apollo Pro
  26793. + 133). If unsure, say Y.
  26794. +
  26795. + To compile this driver as a module, choose M here: the
  26796. + module will be called uhci-hcd.
  26797. +
  26798. +config USB_FHCI_HCD
  26799. + tristate "Freescale QE USB Host Controller support"
  26800. + depends on USB && OF_GPIO && QE_GPIO && QUICC_ENGINE
  26801. + select FSL_GTM
  26802. + select QE_USB
  26803. + help
  26804. + This driver enables support for Freescale QE USB Host Controller
  26805. + (as found on MPC8360 and MPC8323 processors), the driver supports
  26806. + Full and Low Speed USB.
  26807. +
  26808. +config FHCI_DEBUG
  26809. + bool "Freescale QE USB Host Controller debug support"
  26810. + depends on USB_FHCI_HCD && DEBUG_FS
  26811. + help
  26812. + Say "y" to see some FHCI debug information and statistics
  26813. + throught debugfs.
  26814. +
  26815. +config USB_U132_HCD
  26816. + tristate "Elan U132 Adapter Host Controller"
  26817. + depends on USB && USB_FTDI_ELAN
  26818. + default M
  26819. + help
  26820. + The U132 adapter is a USB to CardBus adapter specifically designed
  26821. + for PC cards that contain an OHCI host controller. Typical PC cards
  26822. + are the Orange Mobile 3G Option GlobeTrotter Fusion card. The U132
  26823. + adapter will *NOT* work with PC cards that do not contain an OHCI
  26824. + controller.
  26825. +
  26826. + For those PC cards that contain multiple OHCI controllers only the
  26827. + first one is used.
  26828. +
  26829. + The driver consists of two modules, the "ftdi-elan" module is a
  26830. + USB client driver that interfaces to the FTDI chip within ELAN's
  26831. + USB-to-PCMCIA adapter, and this "u132-hcd" module is a USB host
  26832. + controller driver that talks to the OHCI controller within the
  26833. + CardBus cards that are inserted in the U132 adapter.
  26834. +
  26835. + This driver has been tested with a CardBus OHCI USB adapter, and
  26836. + worked with a USB PEN Drive inserted into the first USB port of
  26837. + the PCCARD. A rather pointless thing to do, but useful for testing.
  26838. +
  26839. + It is safe to say M here.
  26840. +
  26841. + See also <http://www.elandigitalsystems.com/support/ufaq/u132linux.php>
  26842. +
  26843. +config USB_SL811_HCD
  26844. + tristate "SL811HS HCD support"
  26845. + depends on USB
  26846. + help
  26847. + The SL811HS is a single-port USB controller that supports either
  26848. + host side or peripheral side roles. Enable this option if your
  26849. + board has this chip, and you want to use it as a host controller.
  26850. + If unsure, say N.
  26851. +
  26852. + To compile this driver as a module, choose M here: the
  26853. + module will be called sl811-hcd.
  26854. +
  26855. +config USB_SL811_CS
  26856. + tristate "CF/PCMCIA support for SL811HS HCD"
  26857. + depends on USB_SL811_HCD && PCMCIA
  26858. + help
  26859. + Wraps a PCMCIA driver around the SL811HS HCD, supporting the RATOC
  26860. + REX-CFU1U CF card (often used with PDAs). If unsure, say N.
  26861. +
  26862. + To compile this driver as a module, choose M here: the
  26863. + module will be called "sl811_cs".
  26864. +
  26865. +config USB_R8A66597_HCD
  26866. + tristate "R8A66597 HCD support"
  26867. + depends on USB
  26868. + help
  26869. + The R8A66597 is a USB 2.0 host and peripheral controller.
  26870. +
  26871. + Enable this option if your board has this chip, and you want
  26872. + to use it as a host controller. If unsure, say N.
  26873. +
  26874. + To compile this driver as a module, choose M here: the
  26875. + module will be called r8a66597-hcd.
  26876. +
  26877. +config USB_WHCI_HCD
  26878. + tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)"
  26879. + depends on EXPERIMENTAL
  26880. + depends on PCI && USB
  26881. + select USB_WUSB
  26882. + select UWB_WHCI
  26883. + help
  26884. + A driver for PCI-based Wireless USB Host Controllers that are
  26885. + compliant with the WHCI specification.
  26886. +
  26887. + To compile this driver a module, choose M here: the module
  26888. + will be called "whci-hcd".
  26889. +
  26890. +config USB_HWA_HCD
  26891. + tristate "Host Wire Adapter (HWA) driver (EXPERIMENTAL)"
  26892. + depends on EXPERIMENTAL
  26893. + depends on USB
  26894. + select USB_WUSB
  26895. + select UWB_HWA
  26896. + help
  26897. + This driver enables you to connect Wireless USB devices to
  26898. + your system using a Host Wire Adaptor USB dongle. This is an
  26899. + UWB Radio Controller and WUSB Host Controller connected to
  26900. + your machine via USB (specified in WUSB1.0).
  26901. +
  26902. + To compile this driver a module, choose M here: the module
  26903. + will be called "hwa-hc".
  26904. +
  26905. +config USB_IMX21_HCD
  26906. + tristate "iMX21 HCD support"
  26907. + depends on USB && ARM && MACH_MX21
  26908. + help
  26909. + This driver enables support for the on-chip USB host in the
  26910. + iMX21 processor.
  26911. +
  26912. + To compile this driver as a module, choose M here: the
  26913. + module will be called "imx21-hcd".
  26914. +
  26915. diff -Nur linux-2.6.35.7.orig/drivers/usb/host/ohci-ar71xx.c linux-2.6.35.7/drivers/usb/host/ohci-ar71xx.c
  26916. --- linux-2.6.35.7.orig/drivers/usb/host/ohci-ar71xx.c 1970-01-01 01:00:00.000000000 +0100
  26917. +++ linux-2.6.35.7/drivers/usb/host/ohci-ar71xx.c 2010-10-14 20:28:01.428101246 +0200
  26918. @@ -0,0 +1,165 @@
  26919. +/*
  26920. + * OHCI HCD (Host Controller Driver) for USB.
  26921. + *
  26922. + * Bus Glue for Atheros AR71xx built-in OHCI controller.
  26923. + *
  26924. + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
  26925. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  26926. + *
  26927. + * Parts of this file are based on Atheros' 2.6.15 BSP
  26928. + * Copyright (C) 2007 Atheros Communications, Inc.
  26929. + *
  26930. + * This program is free software; you can redistribute it and/or modify it
  26931. + * under the terms of the GNU General Public License version 2 as published
  26932. + * by the Free Software Foundation.
  26933. + */
  26934. +
  26935. +#include <linux/platform_device.h>
  26936. +#include <linux/delay.h>
  26937. +
  26938. +extern int usb_disabled(void);
  26939. +
  26940. +static int usb_hcd_ar71xx_probe(const struct hc_driver *driver,
  26941. + struct platform_device *pdev)
  26942. +{
  26943. + struct usb_hcd *hcd;
  26944. + struct resource *res;
  26945. + int irq;
  26946. + int ret;
  26947. +
  26948. + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  26949. + if (!res) {
  26950. + dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
  26951. + dev_name(&pdev->dev));
  26952. + return -ENODEV;
  26953. + }
  26954. + irq = res->start;
  26955. +
  26956. + hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
  26957. + if (!hcd)
  26958. + return -ENOMEM;
  26959. +
  26960. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  26961. + if (!res) {
  26962. + dev_dbg(&pdev->dev, "no base address specified for %s\n",
  26963. + dev_name(&pdev->dev));
  26964. + ret = -ENODEV;
  26965. + goto err_put_hcd;
  26966. + }
  26967. + hcd->rsrc_start = res->start;
  26968. + hcd->rsrc_len = res->end - res->start + 1;
  26969. +
  26970. + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
  26971. + dev_dbg(&pdev->dev, "controller already in use\n");
  26972. + ret = -EBUSY;
  26973. + goto err_put_hcd;
  26974. + }
  26975. +
  26976. + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
  26977. + if (!hcd->regs) {
  26978. + dev_dbg(&pdev->dev, "error mapping memory\n");
  26979. + ret = -EFAULT;
  26980. + goto err_release_region;
  26981. + }
  26982. +
  26983. + ohci_hcd_init(hcd_to_ohci(hcd));
  26984. +
  26985. + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
  26986. + if (ret)
  26987. + goto err_stop_hcd;
  26988. +
  26989. + return 0;
  26990. +
  26991. + err_stop_hcd:
  26992. + iounmap(hcd->regs);
  26993. + err_release_region:
  26994. + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  26995. + err_put_hcd:
  26996. + usb_put_hcd(hcd);
  26997. + return ret;
  26998. +}
  26999. +
  27000. +void usb_hcd_ar71xx_remove(struct usb_hcd *hcd, struct platform_device *pdev)
  27001. +{
  27002. + usb_remove_hcd(hcd);
  27003. + iounmap(hcd->regs);
  27004. + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
  27005. + usb_put_hcd(hcd);
  27006. +}
  27007. +
  27008. +static int __devinit ohci_ar71xx_start(struct usb_hcd *hcd)
  27009. +{
  27010. + struct ohci_hcd *ohci = hcd_to_ohci(hcd);
  27011. + int ret;
  27012. +
  27013. + ret = ohci_init(ohci);
  27014. + if (ret < 0)
  27015. + return ret;
  27016. +
  27017. + ret = ohci_run(ohci);
  27018. + if (ret < 0)
  27019. + goto err;
  27020. +
  27021. + return 0;
  27022. +
  27023. + err:
  27024. + ohci_stop(hcd);
  27025. + return ret;
  27026. +}
  27027. +
  27028. +static const struct hc_driver ohci_ar71xx_hc_driver = {
  27029. + .description = hcd_name,
  27030. + .product_desc = "Atheros AR71xx built-in OHCI controller",
  27031. + .hcd_priv_size = sizeof(struct ohci_hcd),
  27032. +
  27033. + .irq = ohci_irq,
  27034. + .flags = HCD_USB11 | HCD_MEMORY,
  27035. +
  27036. + .start = ohci_ar71xx_start,
  27037. + .stop = ohci_stop,
  27038. + .shutdown = ohci_shutdown,
  27039. +
  27040. + .urb_enqueue = ohci_urb_enqueue,
  27041. + .urb_dequeue = ohci_urb_dequeue,
  27042. + .endpoint_disable = ohci_endpoint_disable,
  27043. +
  27044. + /*
  27045. + * scheduling support
  27046. + */
  27047. + .get_frame_number = ohci_get_frame,
  27048. +
  27049. + /*
  27050. + * root hub support
  27051. + */
  27052. + .hub_status_data = ohci_hub_status_data,
  27053. + .hub_control = ohci_hub_control,
  27054. + .start_port_reset = ohci_start_port_reset,
  27055. +};
  27056. +
  27057. +static int ohci_hcd_ar71xx_drv_probe(struct platform_device *pdev)
  27058. +{
  27059. + if (usb_disabled())
  27060. + return -ENODEV;
  27061. +
  27062. + return usb_hcd_ar71xx_probe(&ohci_ar71xx_hc_driver, pdev);
  27063. +}
  27064. +
  27065. +static int ohci_hcd_ar71xx_drv_remove(struct platform_device *pdev)
  27066. +{
  27067. + struct usb_hcd *hcd = platform_get_drvdata(pdev);
  27068. +
  27069. + usb_hcd_ar71xx_remove(hcd, pdev);
  27070. + return 0;
  27071. +}
  27072. +
  27073. +MODULE_ALIAS("platform:ar71xx-ohci");
  27074. +
  27075. +static struct platform_driver ohci_hcd_ar71xx_driver = {
  27076. + .probe = ohci_hcd_ar71xx_drv_probe,
  27077. + .remove = ohci_hcd_ar71xx_drv_remove,
  27078. + .shutdown = usb_hcd_platform_shutdown,
  27079. + .driver = {
  27080. + .name = "ar71xx-ohci",
  27081. + .owner = THIS_MODULE,
  27082. + },
  27083. +};
  27084. diff -Nur linux-2.6.35.7.orig/drivers/usb/host/ohci-hcd.c linux-2.6.35.7/drivers/usb/host/ohci-hcd.c
  27085. --- linux-2.6.35.7.orig/drivers/usb/host/ohci-hcd.c 2010-09-29 03:09:08.000000000 +0200
  27086. +++ linux-2.6.35.7/drivers/usb/host/ohci-hcd.c 2010-10-14 20:28:01.468101083 +0200
  27087. @@ -1095,6 +1095,11 @@
  27088. #define TMIO_OHCI_DRIVER ohci_hcd_tmio_driver
  27089. #endif
  27090. +#ifdef CONFIG_USB_OHCI_AR71XX
  27091. +#include "ohci-ar71xx.c"
  27092. +#define PLATFORM_DRIVER ohci_hcd_ar71xx_driver
  27093. +#endif
  27094. +
  27095. #if !defined(PCI_DRIVER) && \
  27096. !defined(PLATFORM_DRIVER) && \
  27097. !defined(OMAP1_PLATFORM_DRIVER) && \
  27098. diff -Nur linux-2.6.35.7.orig/drivers/usb/host/ohci-hcd.c.orig linux-2.6.35.7/drivers/usb/host/ohci-hcd.c.orig
  27099. --- linux-2.6.35.7.orig/drivers/usb/host/ohci-hcd.c.orig 1970-01-01 01:00:00.000000000 +0100
  27100. +++ linux-2.6.35.7/drivers/usb/host/ohci-hcd.c.orig 2010-09-29 03:09:08.000000000 +0200
  27101. @@ -0,0 +1,1277 @@
  27102. +/*
  27103. + * OHCI HCD (Host Controller Driver) for USB.
  27104. + *
  27105. + * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
  27106. + * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
  27107. + *
  27108. + * [ Initialisation is based on Linus' ]
  27109. + * [ uhci code and gregs ohci fragments ]
  27110. + * [ (C) Copyright 1999 Linus Torvalds ]
  27111. + * [ (C) Copyright 1999 Gregory P. Smith]
  27112. + *
  27113. + *
  27114. + * OHCI is the main "non-Intel/VIA" standard for USB 1.1 host controller
  27115. + * interfaces (though some non-x86 Intel chips use it). It supports
  27116. + * smarter hardware than UHCI. A download link for the spec available
  27117. + * through the http://www.usb.org website.
  27118. + *
  27119. + * This file is licenced under the GPL.
  27120. + */
  27121. +
  27122. +#include <linux/module.h>
  27123. +#include <linux/moduleparam.h>
  27124. +#include <linux/pci.h>
  27125. +#include <linux/kernel.h>
  27126. +#include <linux/delay.h>
  27127. +#include <linux/ioport.h>
  27128. +#include <linux/sched.h>
  27129. +#include <linux/slab.h>
  27130. +#include <linux/errno.h>
  27131. +#include <linux/init.h>
  27132. +#include <linux/timer.h>
  27133. +#include <linux/list.h>
  27134. +#include <linux/usb.h>
  27135. +#include <linux/usb/otg.h>
  27136. +#include <linux/usb/hcd.h>
  27137. +#include <linux/dma-mapping.h>
  27138. +#include <linux/dmapool.h>
  27139. +#include <linux/workqueue.h>
  27140. +#include <linux/debugfs.h>
  27141. +
  27142. +#include <asm/io.h>
  27143. +#include <asm/irq.h>
  27144. +#include <asm/system.h>
  27145. +#include <asm/unaligned.h>
  27146. +#include <asm/byteorder.h>
  27147. +
  27148. +
  27149. +#define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell"
  27150. +#define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver"
  27151. +
  27152. +/*-------------------------------------------------------------------------*/
  27153. +
  27154. +#undef OHCI_VERBOSE_DEBUG /* not always helpful */
  27155. +
  27156. +/* For initializing controller (mask in an HCFS mode too) */
  27157. +#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
  27158. +#define OHCI_INTR_INIT \
  27159. + (OHCI_INTR_MIE | OHCI_INTR_RHSC | OHCI_INTR_UE \
  27160. + | OHCI_INTR_RD | OHCI_INTR_WDH)
  27161. +
  27162. +#ifdef __hppa__
  27163. +/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
  27164. +#define IR_DISABLE
  27165. +#endif
  27166. +
  27167. +#ifdef CONFIG_ARCH_OMAP
  27168. +/* OMAP doesn't support IR (no SMM; not needed) */
  27169. +#define IR_DISABLE
  27170. +#endif
  27171. +
  27172. +/*-------------------------------------------------------------------------*/
  27173. +
  27174. +static const char hcd_name [] = "ohci_hcd";
  27175. +
  27176. +#define STATECHANGE_DELAY msecs_to_jiffies(300)
  27177. +
  27178. +#include "ohci.h"
  27179. +
  27180. +static void ohci_dump (struct ohci_hcd *ohci, int verbose);
  27181. +static int ohci_init (struct ohci_hcd *ohci);
  27182. +static void ohci_stop (struct usb_hcd *hcd);
  27183. +
  27184. +#if defined(CONFIG_PM) || defined(CONFIG_PCI)
  27185. +static int ohci_restart (struct ohci_hcd *ohci);
  27186. +#endif
  27187. +
  27188. +#ifdef CONFIG_PCI
  27189. +static void quirk_amd_pll(int state);
  27190. +static void amd_iso_dev_put(void);
  27191. +static void sb800_prefetch(struct ohci_hcd *ohci, int on);
  27192. +#else
  27193. +static inline void quirk_amd_pll(int state)
  27194. +{
  27195. + return;
  27196. +}
  27197. +static inline void amd_iso_dev_put(void)
  27198. +{
  27199. + return;
  27200. +}
  27201. +static inline void sb800_prefetch(struct ohci_hcd *ohci, int on)
  27202. +{
  27203. + return;
  27204. +}
  27205. +#endif
  27206. +
  27207. +
  27208. +#include "ohci-hub.c"
  27209. +#include "ohci-dbg.c"
  27210. +#include "ohci-mem.c"
  27211. +#include "ohci-q.c"
  27212. +
  27213. +
  27214. +/*
  27215. + * On architectures with edge-triggered interrupts we must never return
  27216. + * IRQ_NONE.
  27217. + */
  27218. +#if defined(CONFIG_SA1111) /* ... or other edge-triggered systems */
  27219. +#define IRQ_NOTMINE IRQ_HANDLED
  27220. +#else
  27221. +#define IRQ_NOTMINE IRQ_NONE
  27222. +#endif
  27223. +
  27224. +
  27225. +/* Some boards misreport power switching/overcurrent */
  27226. +static int distrust_firmware = 1;
  27227. +module_param (distrust_firmware, bool, 0);
  27228. +MODULE_PARM_DESC (distrust_firmware,
  27229. + "true to distrust firmware power/overcurrent setup");
  27230. +
  27231. +/* Some boards leave IR set wrongly, since they fail BIOS/SMM handshakes */
  27232. +static int no_handshake = 0;
  27233. +module_param (no_handshake, bool, 0);
  27234. +MODULE_PARM_DESC (no_handshake, "true (not default) disables BIOS handshake");
  27235. +
  27236. +/*-------------------------------------------------------------------------*/
  27237. +
  27238. +/*
  27239. + * queue up an urb for anything except the root hub
  27240. + */
  27241. +static int ohci_urb_enqueue (
  27242. + struct usb_hcd *hcd,
  27243. + struct urb *urb,
  27244. + gfp_t mem_flags
  27245. +) {
  27246. + struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  27247. + struct ed *ed;
  27248. + urb_priv_t *urb_priv;
  27249. + unsigned int pipe = urb->pipe;
  27250. + int i, size = 0;
  27251. + unsigned long flags;
  27252. + int retval = 0;
  27253. +
  27254. +#ifdef OHCI_VERBOSE_DEBUG
  27255. + urb_print(urb, "SUB", usb_pipein(pipe), -EINPROGRESS);
  27256. +#endif
  27257. +
  27258. + /* every endpoint has a ed, locate and maybe (re)initialize it */
  27259. + if (! (ed = ed_get (ohci, urb->ep, urb->dev, pipe, urb->interval)))
  27260. + return -ENOMEM;
  27261. +
  27262. + /* for the private part of the URB we need the number of TDs (size) */
  27263. + switch (ed->type) {
  27264. + case PIPE_CONTROL:
  27265. + /* td_submit_urb() doesn't yet handle these */
  27266. + if (urb->transfer_buffer_length > 4096)
  27267. + return -EMSGSIZE;
  27268. +
  27269. + /* 1 TD for setup, 1 for ACK, plus ... */
  27270. + size = 2;
  27271. + /* FALLTHROUGH */
  27272. + // case PIPE_INTERRUPT:
  27273. + // case PIPE_BULK:
  27274. + default:
  27275. + /* one TD for every 4096 Bytes (can be upto 8K) */
  27276. + size += urb->transfer_buffer_length / 4096;
  27277. + /* ... and for any remaining bytes ... */
  27278. + if ((urb->transfer_buffer_length % 4096) != 0)
  27279. + size++;
  27280. + /* ... and maybe a zero length packet to wrap it up */
  27281. + if (size == 0)
  27282. + size++;
  27283. + else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0
  27284. + && (urb->transfer_buffer_length
  27285. + % usb_maxpacket (urb->dev, pipe,
  27286. + usb_pipeout (pipe))) == 0)
  27287. + size++;
  27288. + break;
  27289. + case PIPE_ISOCHRONOUS: /* number of packets from URB */
  27290. + size = urb->number_of_packets;
  27291. + break;
  27292. + }
  27293. +
  27294. + /* allocate the private part of the URB */
  27295. + urb_priv = kzalloc (sizeof (urb_priv_t) + size * sizeof (struct td *),
  27296. + mem_flags);
  27297. + if (!urb_priv)
  27298. + return -ENOMEM;
  27299. + INIT_LIST_HEAD (&urb_priv->pending);
  27300. + urb_priv->length = size;
  27301. + urb_priv->ed = ed;
  27302. +
  27303. + /* allocate the TDs (deferring hash chain updates) */
  27304. + for (i = 0; i < size; i++) {
  27305. + urb_priv->td [i] = td_alloc (ohci, mem_flags);
  27306. + if (!urb_priv->td [i]) {
  27307. + urb_priv->length = i;
  27308. + urb_free_priv (ohci, urb_priv);
  27309. + return -ENOMEM;
  27310. + }
  27311. + }
  27312. +
  27313. + spin_lock_irqsave (&ohci->lock, flags);
  27314. +
  27315. + /* don't submit to a dead HC */
  27316. + if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
  27317. + retval = -ENODEV;
  27318. + goto fail;
  27319. + }
  27320. + if (!HC_IS_RUNNING(hcd->state)) {
  27321. + retval = -ENODEV;
  27322. + goto fail;
  27323. + }
  27324. + retval = usb_hcd_link_urb_to_ep(hcd, urb);
  27325. + if (retval)
  27326. + goto fail;
  27327. +
  27328. + /* schedule the ed if needed */
  27329. + if (ed->state == ED_IDLE) {
  27330. + retval = ed_schedule (ohci, ed);
  27331. + if (retval < 0) {
  27332. + usb_hcd_unlink_urb_from_ep(hcd, urb);
  27333. + goto fail;
  27334. + }
  27335. + if (ed->type == PIPE_ISOCHRONOUS) {
  27336. + u16 frame = ohci_frame_no(ohci);
  27337. +
  27338. + /* delay a few frames before the first TD */
  27339. + frame += max_t (u16, 8, ed->interval);
  27340. + frame &= ~(ed->interval - 1);
  27341. + frame |= ed->branch;
  27342. + urb->start_frame = frame;
  27343. +
  27344. + /* yes, only URB_ISO_ASAP is supported, and
  27345. + * urb->start_frame is never used as input.
  27346. + */
  27347. + }
  27348. + } else if (ed->type == PIPE_ISOCHRONOUS)
  27349. + urb->start_frame = ed->last_iso + ed->interval;
  27350. +
  27351. + /* fill the TDs and link them to the ed; and
  27352. + * enable that part of the schedule, if needed
  27353. + * and update count of queued periodic urbs
  27354. + */
  27355. + urb->hcpriv = urb_priv;
  27356. + td_submit_urb (ohci, urb);
  27357. +
  27358. +fail:
  27359. + if (retval)
  27360. + urb_free_priv (ohci, urb_priv);
  27361. + spin_unlock_irqrestore (&ohci->lock, flags);
  27362. + return retval;
  27363. +}
  27364. +
  27365. +/*
  27366. + * decouple the URB from the HC queues (TDs, urb_priv).
  27367. + * reporting is always done
  27368. + * asynchronously, and we might be dealing with an urb that's
  27369. + * partially transferred, or an ED with other urbs being unlinked.
  27370. + */
  27371. +static int ohci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
  27372. +{
  27373. + struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  27374. + unsigned long flags;
  27375. + int rc;
  27376. +
  27377. +#ifdef OHCI_VERBOSE_DEBUG
  27378. + urb_print(urb, "UNLINK", 1, status);
  27379. +#endif
  27380. +
  27381. + spin_lock_irqsave (&ohci->lock, flags);
  27382. + rc = usb_hcd_check_unlink_urb(hcd, urb, status);
  27383. + if (rc) {
  27384. + ; /* Do nothing */
  27385. + } else if (HC_IS_RUNNING(hcd->state)) {
  27386. + urb_priv_t *urb_priv;
  27387. +
  27388. + /* Unless an IRQ completed the unlink while it was being
  27389. + * handed to us, flag it for unlink and giveback, and force
  27390. + * some upcoming INTR_SF to call finish_unlinks()
  27391. + */
  27392. + urb_priv = urb->hcpriv;
  27393. + if (urb_priv) {
  27394. + if (urb_priv->ed->state == ED_OPER)
  27395. + start_ed_unlink (ohci, urb_priv->ed);
  27396. + }
  27397. + } else {
  27398. + /*
  27399. + * with HC dead, we won't respect hc queue pointers
  27400. + * any more ... just clean up every urb's memory.
  27401. + */
  27402. + if (urb->hcpriv)
  27403. + finish_urb(ohci, urb, status);
  27404. + }
  27405. + spin_unlock_irqrestore (&ohci->lock, flags);
  27406. + return rc;
  27407. +}
  27408. +
  27409. +/*-------------------------------------------------------------------------*/
  27410. +
  27411. +/* frees config/altsetting state for endpoints,
  27412. + * including ED memory, dummy TD, and bulk/intr data toggle
  27413. + */
  27414. +
  27415. +static void
  27416. +ohci_endpoint_disable (struct usb_hcd *hcd, struct usb_host_endpoint *ep)
  27417. +{
  27418. + struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  27419. + unsigned long flags;
  27420. + struct ed *ed = ep->hcpriv;
  27421. + unsigned limit = 1000;
  27422. +
  27423. + /* ASSERT: any requests/urbs are being unlinked */
  27424. + /* ASSERT: nobody can be submitting urbs for this any more */
  27425. +
  27426. + if (!ed)
  27427. + return;
  27428. +
  27429. +rescan:
  27430. + spin_lock_irqsave (&ohci->lock, flags);
  27431. +
  27432. + if (!HC_IS_RUNNING (hcd->state)) {
  27433. +sanitize:
  27434. + ed->state = ED_IDLE;
  27435. + if (quirk_zfmicro(ohci) && ed->type == PIPE_INTERRUPT)
  27436. + ohci->eds_scheduled--;
  27437. + finish_unlinks (ohci, 0);
  27438. + }
  27439. +
  27440. + switch (ed->state) {
  27441. + case ED_UNLINK: /* wait for hw to finish? */
  27442. + /* major IRQ delivery trouble loses INTR_SF too... */
  27443. + if (limit-- == 0) {
  27444. + ohci_warn(ohci, "ED unlink timeout\n");
  27445. + if (quirk_zfmicro(ohci)) {
  27446. + ohci_warn(ohci, "Attempting ZF TD recovery\n");
  27447. + ohci->ed_to_check = ed;
  27448. + ohci->zf_delay = 2;
  27449. + }
  27450. + goto sanitize;
  27451. + }
  27452. + spin_unlock_irqrestore (&ohci->lock, flags);
  27453. + schedule_timeout_uninterruptible(1);
  27454. + goto rescan;
  27455. + case ED_IDLE: /* fully unlinked */
  27456. + if (list_empty (&ed->td_list)) {
  27457. + td_free (ohci, ed->dummy);
  27458. + ed_free (ohci, ed);
  27459. + break;
  27460. + }
  27461. + /* else FALL THROUGH */
  27462. + default:
  27463. + /* caller was supposed to have unlinked any requests;
  27464. + * that's not our job. can't recover; must leak ed.
  27465. + */
  27466. + ohci_err (ohci, "leak ed %p (#%02x) state %d%s\n",
  27467. + ed, ep->desc.bEndpointAddress, ed->state,
  27468. + list_empty (&ed->td_list) ? "" : " (has tds)");
  27469. + td_free (ohci, ed->dummy);
  27470. + break;
  27471. + }
  27472. + ep->hcpriv = NULL;
  27473. + spin_unlock_irqrestore (&ohci->lock, flags);
  27474. + return;
  27475. +}
  27476. +
  27477. +static int ohci_get_frame (struct usb_hcd *hcd)
  27478. +{
  27479. + struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  27480. +
  27481. + return ohci_frame_no(ohci);
  27482. +}
  27483. +
  27484. +static void ohci_usb_reset (struct ohci_hcd *ohci)
  27485. +{
  27486. + ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
  27487. + ohci->hc_control &= OHCI_CTRL_RWC;
  27488. + ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
  27489. +}
  27490. +
  27491. +/* ohci_shutdown forcibly disables IRQs and DMA, helping kexec and
  27492. + * other cases where the next software may expect clean state from the
  27493. + * "firmware". this is bus-neutral, unlike shutdown() methods.
  27494. + */
  27495. +static void
  27496. +ohci_shutdown (struct usb_hcd *hcd)
  27497. +{
  27498. + struct ohci_hcd *ohci;
  27499. +
  27500. + ohci = hcd_to_ohci (hcd);
  27501. + ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
  27502. + ohci_usb_reset (ohci);
  27503. + /* flush the writes */
  27504. + (void) ohci_readl (ohci, &ohci->regs->control);
  27505. +}
  27506. +
  27507. +static int check_ed(struct ohci_hcd *ohci, struct ed *ed)
  27508. +{
  27509. + return (hc32_to_cpu(ohci, ed->hwINFO) & ED_IN) != 0
  27510. + && (hc32_to_cpu(ohci, ed->hwHeadP) & TD_MASK)
  27511. + == (hc32_to_cpu(ohci, ed->hwTailP) & TD_MASK)
  27512. + && !list_empty(&ed->td_list);
  27513. +}
  27514. +
  27515. +/* ZF Micro watchdog timer callback. The ZF Micro chipset sometimes completes
  27516. + * an interrupt TD but neglects to add it to the donelist. On systems with
  27517. + * this chipset, we need to periodically check the state of the queues to look
  27518. + * for such "lost" TDs.
  27519. + */
  27520. +static void unlink_watchdog_func(unsigned long _ohci)
  27521. +{
  27522. + unsigned long flags;
  27523. + unsigned max;
  27524. + unsigned seen_count = 0;
  27525. + unsigned i;
  27526. + struct ed **seen = NULL;
  27527. + struct ohci_hcd *ohci = (struct ohci_hcd *) _ohci;
  27528. +
  27529. + spin_lock_irqsave(&ohci->lock, flags);
  27530. + max = ohci->eds_scheduled;
  27531. + if (!max)
  27532. + goto done;
  27533. +
  27534. + if (ohci->ed_to_check)
  27535. + goto out;
  27536. +
  27537. + seen = kcalloc(max, sizeof *seen, GFP_ATOMIC);
  27538. + if (!seen)
  27539. + goto out;
  27540. +
  27541. + for (i = 0; i < NUM_INTS; i++) {
  27542. + struct ed *ed = ohci->periodic[i];
  27543. +
  27544. + while (ed) {
  27545. + unsigned temp;
  27546. +
  27547. + /* scan this branch of the periodic schedule tree */
  27548. + for (temp = 0; temp < seen_count; temp++) {
  27549. + if (seen[temp] == ed) {
  27550. + /* we've checked it and what's after */
  27551. + ed = NULL;
  27552. + break;
  27553. + }
  27554. + }
  27555. + if (!ed)
  27556. + break;
  27557. + seen[seen_count++] = ed;
  27558. + if (!check_ed(ohci, ed)) {
  27559. + ed = ed->ed_next;
  27560. + continue;
  27561. + }
  27562. +
  27563. + /* HC's TD list is empty, but HCD sees at least one
  27564. + * TD that's not been sent through the donelist.
  27565. + */
  27566. + ohci->ed_to_check = ed;
  27567. + ohci->zf_delay = 2;
  27568. +
  27569. + /* The HC may wait until the next frame to report the
  27570. + * TD as done through the donelist and INTR_WDH. (We
  27571. + * just *assume* it's not a multi-TD interrupt URB;
  27572. + * those could defer the IRQ more than one frame, using
  27573. + * DI...) Check again after the next INTR_SF.
  27574. + */
  27575. + ohci_writel(ohci, OHCI_INTR_SF,
  27576. + &ohci->regs->intrstatus);
  27577. + ohci_writel(ohci, OHCI_INTR_SF,
  27578. + &ohci->regs->intrenable);
  27579. +
  27580. + /* flush those writes */
  27581. + (void) ohci_readl(ohci, &ohci->regs->control);
  27582. +
  27583. + goto out;
  27584. + }
  27585. + }
  27586. +out:
  27587. + kfree(seen);
  27588. + if (ohci->eds_scheduled)
  27589. + mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
  27590. +done:
  27591. + spin_unlock_irqrestore(&ohci->lock, flags);
  27592. +}
  27593. +
  27594. +/*-------------------------------------------------------------------------*
  27595. + * HC functions
  27596. + *-------------------------------------------------------------------------*/
  27597. +
  27598. +/* init memory, and kick BIOS/SMM off */
  27599. +
  27600. +static int ohci_init (struct ohci_hcd *ohci)
  27601. +{
  27602. + int ret;
  27603. + struct usb_hcd *hcd = ohci_to_hcd(ohci);
  27604. +
  27605. + if (distrust_firmware)
  27606. + ohci->flags |= OHCI_QUIRK_HUB_POWER;
  27607. +
  27608. + disable (ohci);
  27609. + ohci->regs = hcd->regs;
  27610. +
  27611. + /* REVISIT this BIOS handshake is now moved into PCI "quirks", and
  27612. + * was never needed for most non-PCI systems ... remove the code?
  27613. + */
  27614. +
  27615. +#ifndef IR_DISABLE
  27616. + /* SMM owns the HC? not for long! */
  27617. + if (!no_handshake && ohci_readl (ohci,
  27618. + &ohci->regs->control) & OHCI_CTRL_IR) {
  27619. + u32 temp;
  27620. +
  27621. + ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n");
  27622. +
  27623. + /* this timeout is arbitrary. we make it long, so systems
  27624. + * depending on usb keyboards may be usable even if the
  27625. + * BIOS/SMM code seems pretty broken.
  27626. + */
  27627. + temp = 500; /* arbitrary: five seconds */
  27628. +
  27629. + ohci_writel (ohci, OHCI_INTR_OC, &ohci->regs->intrenable);
  27630. + ohci_writel (ohci, OHCI_OCR, &ohci->regs->cmdstatus);
  27631. + while (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_IR) {
  27632. + msleep (10);
  27633. + if (--temp == 0) {
  27634. + ohci_err (ohci, "USB HC takeover failed!"
  27635. + " (BIOS/SMM bug)\n");
  27636. + return -EBUSY;
  27637. + }
  27638. + }
  27639. + ohci_usb_reset (ohci);
  27640. + }
  27641. +#endif
  27642. +
  27643. + /* Disable HC interrupts */
  27644. + ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
  27645. +
  27646. + /* flush the writes, and save key bits like RWC */
  27647. + if (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_RWC)
  27648. + ohci->hc_control |= OHCI_CTRL_RWC;
  27649. +
  27650. + /* Read the number of ports unless overridden */
  27651. + if (ohci->num_ports == 0)
  27652. + ohci->num_ports = roothub_a(ohci) & RH_A_NDP;
  27653. +
  27654. + if (ohci->hcca)
  27655. + return 0;
  27656. +
  27657. + ohci->hcca = dma_alloc_coherent (hcd->self.controller,
  27658. + sizeof *ohci->hcca, &ohci->hcca_dma, 0);
  27659. + if (!ohci->hcca)
  27660. + return -ENOMEM;
  27661. +
  27662. + if ((ret = ohci_mem_init (ohci)) < 0)
  27663. + ohci_stop (hcd);
  27664. + else {
  27665. + create_debug_files (ohci);
  27666. + }
  27667. +
  27668. + return ret;
  27669. +}
  27670. +
  27671. +/*-------------------------------------------------------------------------*/
  27672. +
  27673. +/* Start an OHCI controller, set the BUS operational
  27674. + * resets USB and controller
  27675. + * enable interrupts
  27676. + */
  27677. +static int ohci_run (struct ohci_hcd *ohci)
  27678. +{
  27679. + u32 mask, val;
  27680. + int first = ohci->fminterval == 0;
  27681. + struct usb_hcd *hcd = ohci_to_hcd(ohci);
  27682. +
  27683. + disable (ohci);
  27684. +
  27685. + /* boot firmware should have set this up (5.1.1.3.1) */
  27686. + if (first) {
  27687. +
  27688. + val = ohci_readl (ohci, &ohci->regs->fminterval);
  27689. + ohci->fminterval = val & 0x3fff;
  27690. + if (ohci->fminterval != FI)
  27691. + ohci_dbg (ohci, "fminterval delta %d\n",
  27692. + ohci->fminterval - FI);
  27693. + ohci->fminterval |= FSMP (ohci->fminterval) << 16;
  27694. + /* also: power/overcurrent flags in roothub.a */
  27695. + }
  27696. +
  27697. + /* Reset USB nearly "by the book". RemoteWakeupConnected has
  27698. + * to be checked in case boot firmware (BIOS/SMM/...) has set up
  27699. + * wakeup in a way the bus isn't aware of (e.g., legacy PCI PM).
  27700. + * If the bus glue detected wakeup capability then it should
  27701. + * already be enabled; if so we'll just enable it again.
  27702. + */
  27703. + if ((ohci->hc_control & OHCI_CTRL_RWC) != 0)
  27704. + device_set_wakeup_capable(hcd->self.controller, 1);
  27705. +
  27706. + switch (ohci->hc_control & OHCI_CTRL_HCFS) {
  27707. + case OHCI_USB_OPER:
  27708. + val = 0;
  27709. + break;
  27710. + case OHCI_USB_SUSPEND:
  27711. + case OHCI_USB_RESUME:
  27712. + ohci->hc_control &= OHCI_CTRL_RWC;
  27713. + ohci->hc_control |= OHCI_USB_RESUME;
  27714. + val = 10 /* msec wait */;
  27715. + break;
  27716. + // case OHCI_USB_RESET:
  27717. + default:
  27718. + ohci->hc_control &= OHCI_CTRL_RWC;
  27719. + ohci->hc_control |= OHCI_USB_RESET;
  27720. + val = 50 /* msec wait */;
  27721. + break;
  27722. + }
  27723. + ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
  27724. + // flush the writes
  27725. + (void) ohci_readl (ohci, &ohci->regs->control);
  27726. + msleep(val);
  27727. +
  27728. + memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
  27729. +
  27730. + /* 2msec timelimit here means no irqs/preempt */
  27731. + spin_lock_irq (&ohci->lock);
  27732. +
  27733. +retry:
  27734. + /* HC Reset requires max 10 us delay */
  27735. + ohci_writel (ohci, OHCI_HCR, &ohci->regs->cmdstatus);
  27736. + val = 30; /* ... allow extra time */
  27737. + while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
  27738. + if (--val == 0) {
  27739. + spin_unlock_irq (&ohci->lock);
  27740. + ohci_err (ohci, "USB HC reset timed out!\n");
  27741. + return -1;
  27742. + }
  27743. + udelay (1);
  27744. + }
  27745. +
  27746. + /* now we're in the SUSPEND state ... must go OPERATIONAL
  27747. + * within 2msec else HC enters RESUME
  27748. + *
  27749. + * ... but some hardware won't init fmInterval "by the book"
  27750. + * (SiS, OPTi ...), so reset again instead. SiS doesn't need
  27751. + * this if we write fmInterval after we're OPERATIONAL.
  27752. + * Unclear about ALi, ServerWorks, and others ... this could
  27753. + * easily be a longstanding bug in chip init on Linux.
  27754. + */
  27755. + if (ohci->flags & OHCI_QUIRK_INITRESET) {
  27756. + ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
  27757. + // flush those writes
  27758. + (void) ohci_readl (ohci, &ohci->regs->control);
  27759. + }
  27760. +
  27761. + /* Tell the controller where the control and bulk lists are
  27762. + * The lists are empty now. */
  27763. + ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);
  27764. + ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);
  27765. +
  27766. + /* a reset clears this */
  27767. + ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);
  27768. +
  27769. + periodic_reinit (ohci);
  27770. +
  27771. + /* some OHCI implementations are finicky about how they init.
  27772. + * bogus values here mean not even enumeration could work.
  27773. + */
  27774. + if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0
  27775. + || !ohci_readl (ohci, &ohci->regs->periodicstart)) {
  27776. + if (!(ohci->flags & OHCI_QUIRK_INITRESET)) {
  27777. + ohci->flags |= OHCI_QUIRK_INITRESET;
  27778. + ohci_dbg (ohci, "enabling initreset quirk\n");
  27779. + goto retry;
  27780. + }
  27781. + spin_unlock_irq (&ohci->lock);
  27782. + ohci_err (ohci, "init err (%08x %04x)\n",
  27783. + ohci_readl (ohci, &ohci->regs->fminterval),
  27784. + ohci_readl (ohci, &ohci->regs->periodicstart));
  27785. + return -EOVERFLOW;
  27786. + }
  27787. +
  27788. + /* use rhsc irqs after khubd is fully initialized */
  27789. + hcd->poll_rh = 1;
  27790. + hcd->uses_new_polling = 1;
  27791. +
  27792. + /* start controller operations */
  27793. + ohci->hc_control &= OHCI_CTRL_RWC;
  27794. + ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER;
  27795. + ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
  27796. + hcd->state = HC_STATE_RUNNING;
  27797. +
  27798. + /* wake on ConnectStatusChange, matching external hubs */
  27799. + ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status);
  27800. +
  27801. + /* Choose the interrupts we care about now, others later on demand */
  27802. + mask = OHCI_INTR_INIT;
  27803. + ohci_writel (ohci, ~0, &ohci->regs->intrstatus);
  27804. + ohci_writel (ohci, mask, &ohci->regs->intrenable);
  27805. +
  27806. + /* handle root hub init quirks ... */
  27807. + val = roothub_a (ohci);
  27808. + val &= ~(RH_A_PSM | RH_A_OCPM);
  27809. + if (ohci->flags & OHCI_QUIRK_SUPERIO) {
  27810. + /* NSC 87560 and maybe others */
  27811. + val |= RH_A_NOCP;
  27812. + val &= ~(RH_A_POTPGT | RH_A_NPS);
  27813. + ohci_writel (ohci, val, &ohci->regs->roothub.a);
  27814. + } else if ((ohci->flags & OHCI_QUIRK_AMD756) ||
  27815. + (ohci->flags & OHCI_QUIRK_HUB_POWER)) {
  27816. + /* hub power always on; required for AMD-756 and some
  27817. + * Mac platforms. ganged overcurrent reporting, if any.
  27818. + */
  27819. + val |= RH_A_NPS;
  27820. + ohci_writel (ohci, val, &ohci->regs->roothub.a);
  27821. + }
  27822. + ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status);
  27823. + ohci_writel (ohci, (val & RH_A_NPS) ? 0 : RH_B_PPCM,
  27824. + &ohci->regs->roothub.b);
  27825. + // flush those writes
  27826. + (void) ohci_readl (ohci, &ohci->regs->control);
  27827. +
  27828. + ohci->next_statechange = jiffies + STATECHANGE_DELAY;
  27829. + spin_unlock_irq (&ohci->lock);
  27830. +
  27831. + // POTPGT delay is bits 24-31, in 2 ms units.
  27832. + mdelay ((val >> 23) & 0x1fe);
  27833. + hcd->state = HC_STATE_RUNNING;
  27834. +
  27835. + if (quirk_zfmicro(ohci)) {
  27836. + /* Create timer to watch for bad queue state on ZF Micro */
  27837. + setup_timer(&ohci->unlink_watchdog, unlink_watchdog_func,
  27838. + (unsigned long) ohci);
  27839. +
  27840. + ohci->eds_scheduled = 0;
  27841. + ohci->ed_to_check = NULL;
  27842. + }
  27843. +
  27844. + ohci_dump (ohci, 1);
  27845. +
  27846. + return 0;
  27847. +}
  27848. +
  27849. +/*-------------------------------------------------------------------------*/
  27850. +
  27851. +/* an interrupt happens */
  27852. +
  27853. +static irqreturn_t ohci_irq (struct usb_hcd *hcd)
  27854. +{
  27855. + struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  27856. + struct ohci_regs __iomem *regs = ohci->regs;
  27857. + int ints;
  27858. +
  27859. + /* Read interrupt status (and flush pending writes). We ignore the
  27860. + * optimization of checking the LSB of hcca->done_head; it doesn't
  27861. + * work on all systems (edge triggering for OHCI can be a factor).
  27862. + */
  27863. + ints = ohci_readl(ohci, &regs->intrstatus);
  27864. +
  27865. + /* Check for an all 1's result which is a typical consequence
  27866. + * of dead, unclocked, or unplugged (CardBus...) devices
  27867. + */
  27868. + if (ints == ~(u32)0) {
  27869. + disable (ohci);
  27870. + ohci_dbg (ohci, "device removed!\n");
  27871. + return IRQ_HANDLED;
  27872. + }
  27873. +
  27874. + /* We only care about interrupts that are enabled */
  27875. + ints &= ohci_readl(ohci, &regs->intrenable);
  27876. +
  27877. + /* interrupt for some other device? */
  27878. + if (ints == 0)
  27879. + return IRQ_NOTMINE;
  27880. +
  27881. + if (ints & OHCI_INTR_UE) {
  27882. + // e.g. due to PCI Master/Target Abort
  27883. + if (quirk_nec(ohci)) {
  27884. + /* Workaround for a silicon bug in some NEC chips used
  27885. + * in Apple's PowerBooks. Adapted from Darwin code.
  27886. + */
  27887. + ohci_err (ohci, "OHCI Unrecoverable Error, scheduling NEC chip restart\n");
  27888. +
  27889. + ohci_writel (ohci, OHCI_INTR_UE, &regs->intrdisable);
  27890. +
  27891. + schedule_work (&ohci->nec_work);
  27892. + } else {
  27893. + disable (ohci);
  27894. + ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
  27895. + }
  27896. +
  27897. + ohci_dump (ohci, 1);
  27898. + ohci_usb_reset (ohci);
  27899. + }
  27900. +
  27901. + if (ints & OHCI_INTR_RHSC) {
  27902. + ohci_vdbg(ohci, "rhsc\n");
  27903. + ohci->next_statechange = jiffies + STATECHANGE_DELAY;
  27904. + ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
  27905. + &regs->intrstatus);
  27906. +
  27907. + /* NOTE: Vendors didn't always make the same implementation
  27908. + * choices for RHSC. Many followed the spec; RHSC triggers
  27909. + * on an edge, like setting and maybe clearing a port status
  27910. + * change bit. With others it's level-triggered, active
  27911. + * until khubd clears all the port status change bits. We'll
  27912. + * always disable it here and rely on polling until khubd
  27913. + * re-enables it.
  27914. + */
  27915. + ohci_writel(ohci, OHCI_INTR_RHSC, &regs->intrdisable);
  27916. + usb_hcd_poll_rh_status(hcd);
  27917. + }
  27918. +
  27919. + /* For connect and disconnect events, we expect the controller
  27920. + * to turn on RHSC along with RD. But for remote wakeup events
  27921. + * this might not happen.
  27922. + */
  27923. + else if (ints & OHCI_INTR_RD) {
  27924. + ohci_vdbg(ohci, "resume detect\n");
  27925. + ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus);
  27926. + hcd->poll_rh = 1;
  27927. + if (ohci->autostop) {
  27928. + spin_lock (&ohci->lock);
  27929. + ohci_rh_resume (ohci);
  27930. + spin_unlock (&ohci->lock);
  27931. + } else
  27932. + usb_hcd_resume_root_hub(hcd);
  27933. + }
  27934. +
  27935. + if (ints & OHCI_INTR_WDH) {
  27936. + spin_lock (&ohci->lock);
  27937. + dl_done_list (ohci);
  27938. + spin_unlock (&ohci->lock);
  27939. + }
  27940. +
  27941. + if (quirk_zfmicro(ohci) && (ints & OHCI_INTR_SF)) {
  27942. + spin_lock(&ohci->lock);
  27943. + if (ohci->ed_to_check) {
  27944. + struct ed *ed = ohci->ed_to_check;
  27945. +
  27946. + if (check_ed(ohci, ed)) {
  27947. + /* HC thinks the TD list is empty; HCD knows
  27948. + * at least one TD is outstanding
  27949. + */
  27950. + if (--ohci->zf_delay == 0) {
  27951. + struct td *td = list_entry(
  27952. + ed->td_list.next,
  27953. + struct td, td_list);
  27954. + ohci_warn(ohci,
  27955. + "Reclaiming orphan TD %p\n",
  27956. + td);
  27957. + takeback_td(ohci, td);
  27958. + ohci->ed_to_check = NULL;
  27959. + }
  27960. + } else
  27961. + ohci->ed_to_check = NULL;
  27962. + }
  27963. + spin_unlock(&ohci->lock);
  27964. + }
  27965. +
  27966. + /* could track INTR_SO to reduce available PCI/... bandwidth */
  27967. +
  27968. + /* handle any pending URB/ED unlinks, leaving INTR_SF enabled
  27969. + * when there's still unlinking to be done (next frame).
  27970. + */
  27971. + spin_lock (&ohci->lock);
  27972. + if (ohci->ed_rm_list)
  27973. + finish_unlinks (ohci, ohci_frame_no(ohci));
  27974. + if ((ints & OHCI_INTR_SF) != 0
  27975. + && !ohci->ed_rm_list
  27976. + && !ohci->ed_to_check
  27977. + && HC_IS_RUNNING(hcd->state))
  27978. + ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable);
  27979. + spin_unlock (&ohci->lock);
  27980. +
  27981. + if (HC_IS_RUNNING(hcd->state)) {
  27982. + ohci_writel (ohci, ints, &regs->intrstatus);
  27983. + ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable);
  27984. + // flush those writes
  27985. + (void) ohci_readl (ohci, &ohci->regs->control);
  27986. + }
  27987. +
  27988. + return IRQ_HANDLED;
  27989. +}
  27990. +
  27991. +/*-------------------------------------------------------------------------*/
  27992. +
  27993. +static void ohci_stop (struct usb_hcd *hcd)
  27994. +{
  27995. + struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  27996. +
  27997. + ohci_dump (ohci, 1);
  27998. +
  27999. + flush_scheduled_work();
  28000. +
  28001. + ohci_usb_reset (ohci);
  28002. + ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
  28003. + free_irq(hcd->irq, hcd);
  28004. + hcd->irq = -1;
  28005. +
  28006. + if (quirk_zfmicro(ohci))
  28007. + del_timer(&ohci->unlink_watchdog);
  28008. + if (quirk_amdiso(ohci))
  28009. + amd_iso_dev_put();
  28010. +
  28011. + remove_debug_files (ohci);
  28012. + ohci_mem_cleanup (ohci);
  28013. + if (ohci->hcca) {
  28014. + dma_free_coherent (hcd->self.controller,
  28015. + sizeof *ohci->hcca,
  28016. + ohci->hcca, ohci->hcca_dma);
  28017. + ohci->hcca = NULL;
  28018. + ohci->hcca_dma = 0;
  28019. + }
  28020. +}
  28021. +
  28022. +/*-------------------------------------------------------------------------*/
  28023. +
  28024. +#if defined(CONFIG_PM) || defined(CONFIG_PCI)
  28025. +
  28026. +/* must not be called from interrupt context */
  28027. +static int ohci_restart (struct ohci_hcd *ohci)
  28028. +{
  28029. + int temp;
  28030. + int i;
  28031. + struct urb_priv *priv;
  28032. +
  28033. + spin_lock_irq(&ohci->lock);
  28034. + disable (ohci);
  28035. +
  28036. + /* Recycle any "live" eds/tds (and urbs). */
  28037. + if (!list_empty (&ohci->pending))
  28038. + ohci_dbg(ohci, "abort schedule...\n");
  28039. + list_for_each_entry (priv, &ohci->pending, pending) {
  28040. + struct urb *urb = priv->td[0]->urb;
  28041. + struct ed *ed = priv->ed;
  28042. +
  28043. + switch (ed->state) {
  28044. + case ED_OPER:
  28045. + ed->state = ED_UNLINK;
  28046. + ed->hwINFO |= cpu_to_hc32(ohci, ED_DEQUEUE);
  28047. + ed_deschedule (ohci, ed);
  28048. +
  28049. + ed->ed_next = ohci->ed_rm_list;
  28050. + ed->ed_prev = NULL;
  28051. + ohci->ed_rm_list = ed;
  28052. + /* FALLTHROUGH */
  28053. + case ED_UNLINK:
  28054. + break;
  28055. + default:
  28056. + ohci_dbg(ohci, "bogus ed %p state %d\n",
  28057. + ed, ed->state);
  28058. + }
  28059. +
  28060. + if (!urb->unlinked)
  28061. + urb->unlinked = -ESHUTDOWN;
  28062. + }
  28063. + finish_unlinks (ohci, 0);
  28064. + spin_unlock_irq(&ohci->lock);
  28065. +
  28066. + /* paranoia, in case that didn't work: */
  28067. +
  28068. + /* empty the interrupt branches */
  28069. + for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0;
  28070. + for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0;
  28071. +
  28072. + /* no EDs to remove */
  28073. + ohci->ed_rm_list = NULL;
  28074. +
  28075. + /* empty control and bulk lists */
  28076. + ohci->ed_controltail = NULL;
  28077. + ohci->ed_bulktail = NULL;
  28078. +
  28079. + if ((temp = ohci_run (ohci)) < 0) {
  28080. + ohci_err (ohci, "can't restart, %d\n", temp);
  28081. + return temp;
  28082. + }
  28083. + ohci_dbg(ohci, "restart complete\n");
  28084. + return 0;
  28085. +}
  28086. +
  28087. +#endif
  28088. +
  28089. +/*-------------------------------------------------------------------------*/
  28090. +
  28091. +MODULE_AUTHOR (DRIVER_AUTHOR);
  28092. +MODULE_DESCRIPTION(DRIVER_DESC);
  28093. +MODULE_LICENSE ("GPL");
  28094. +
  28095. +#ifdef CONFIG_PCI
  28096. +#include "ohci-pci.c"
  28097. +#define PCI_DRIVER ohci_pci_driver
  28098. +#endif
  28099. +
  28100. +#if defined(CONFIG_ARCH_SA1100) && defined(CONFIG_SA1111)
  28101. +#include "ohci-sa1111.c"
  28102. +#define SA1111_DRIVER ohci_hcd_sa1111_driver
  28103. +#endif
  28104. +
  28105. +#if defined(CONFIG_ARCH_S3C2410) || defined(CONFIG_ARCH_S3C64XX)
  28106. +#include "ohci-s3c2410.c"
  28107. +#define PLATFORM_DRIVER ohci_hcd_s3c2410_driver
  28108. +#endif
  28109. +
  28110. +#ifdef CONFIG_USB_OHCI_HCD_OMAP1
  28111. +#include "ohci-omap.c"
  28112. +#define OMAP1_PLATFORM_DRIVER ohci_hcd_omap_driver
  28113. +#endif
  28114. +
  28115. +#ifdef CONFIG_USB_OHCI_HCD_OMAP3
  28116. +#include "ohci-omap3.c"
  28117. +#define OMAP3_PLATFORM_DRIVER ohci_hcd_omap3_driver
  28118. +#endif
  28119. +
  28120. +#ifdef CONFIG_ARCH_LH7A404
  28121. +#include "ohci-lh7a404.c"
  28122. +#define PLATFORM_DRIVER ohci_hcd_lh7a404_driver
  28123. +#endif
  28124. +
  28125. +#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
  28126. +#include "ohci-pxa27x.c"
  28127. +#define PLATFORM_DRIVER ohci_hcd_pxa27x_driver
  28128. +#endif
  28129. +
  28130. +#ifdef CONFIG_ARCH_EP93XX
  28131. +#include "ohci-ep93xx.c"
  28132. +#define PLATFORM_DRIVER ohci_hcd_ep93xx_driver
  28133. +#endif
  28134. +
  28135. +#ifdef CONFIG_SOC_AU1X00
  28136. +#include "ohci-au1xxx.c"
  28137. +#define PLATFORM_DRIVER ohci_hcd_au1xxx_driver
  28138. +#endif
  28139. +
  28140. +#ifdef CONFIG_PNX8550
  28141. +#include "ohci-pnx8550.c"
  28142. +#define PLATFORM_DRIVER ohci_hcd_pnx8550_driver
  28143. +#endif
  28144. +
  28145. +#ifdef CONFIG_USB_OHCI_HCD_PPC_SOC
  28146. +#include "ohci-ppc-soc.c"
  28147. +#define PLATFORM_DRIVER ohci_hcd_ppc_soc_driver
  28148. +#endif
  28149. +
  28150. +#ifdef CONFIG_ARCH_AT91
  28151. +#include "ohci-at91.c"
  28152. +#define PLATFORM_DRIVER ohci_hcd_at91_driver
  28153. +#endif
  28154. +
  28155. +#ifdef CONFIG_ARCH_PNX4008
  28156. +#include "ohci-pnx4008.c"
  28157. +#define PLATFORM_DRIVER usb_hcd_pnx4008_driver
  28158. +#endif
  28159. +
  28160. +#ifdef CONFIG_ARCH_DAVINCI_DA8XX
  28161. +#include "ohci-da8xx.c"
  28162. +#define PLATFORM_DRIVER ohci_hcd_da8xx_driver
  28163. +#endif
  28164. +
  28165. +#if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
  28166. + defined(CONFIG_CPU_SUBTYPE_SH7721) || \
  28167. + defined(CONFIG_CPU_SUBTYPE_SH7763) || \
  28168. + defined(CONFIG_CPU_SUBTYPE_SH7786)
  28169. +#include "ohci-sh.c"
  28170. +#define PLATFORM_DRIVER ohci_hcd_sh_driver
  28171. +#endif
  28172. +
  28173. +
  28174. +#ifdef CONFIG_USB_OHCI_HCD_PPC_OF
  28175. +#include "ohci-ppc-of.c"
  28176. +#define OF_PLATFORM_DRIVER ohci_hcd_ppc_of_driver
  28177. +#endif
  28178. +
  28179. +#ifdef CONFIG_PPC_PS3
  28180. +#include "ohci-ps3.c"
  28181. +#define PS3_SYSTEM_BUS_DRIVER ps3_ohci_driver
  28182. +#endif
  28183. +
  28184. +#ifdef CONFIG_USB_OHCI_HCD_SSB
  28185. +#include "ohci-ssb.c"
  28186. +#define SSB_OHCI_DRIVER ssb_ohci_driver
  28187. +#endif
  28188. +
  28189. +#ifdef CONFIG_MFD_SM501
  28190. +#include "ohci-sm501.c"
  28191. +#define SM501_OHCI_DRIVER ohci_hcd_sm501_driver
  28192. +#endif
  28193. +
  28194. +#ifdef CONFIG_MFD_TC6393XB
  28195. +#include "ohci-tmio.c"
  28196. +#define TMIO_OHCI_DRIVER ohci_hcd_tmio_driver
  28197. +#endif
  28198. +
  28199. +#if !defined(PCI_DRIVER) && \
  28200. + !defined(PLATFORM_DRIVER) && \
  28201. + !defined(OMAP1_PLATFORM_DRIVER) && \
  28202. + !defined(OMAP3_PLATFORM_DRIVER) && \
  28203. + !defined(OF_PLATFORM_DRIVER) && \
  28204. + !defined(SA1111_DRIVER) && \
  28205. + !defined(PS3_SYSTEM_BUS_DRIVER) && \
  28206. + !defined(SM501_OHCI_DRIVER) && \
  28207. + !defined(TMIO_OHCI_DRIVER) && \
  28208. + !defined(SSB_OHCI_DRIVER)
  28209. +#error "missing bus glue for ohci-hcd"
  28210. +#endif
  28211. +
  28212. +static int __init ohci_hcd_mod_init(void)
  28213. +{
  28214. + int retval = 0;
  28215. +
  28216. + if (usb_disabled())
  28217. + return -ENODEV;
  28218. +
  28219. + printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name);
  28220. + pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
  28221. + sizeof (struct ed), sizeof (struct td));
  28222. + set_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
  28223. +
  28224. +#ifdef DEBUG
  28225. + ohci_debug_root = debugfs_create_dir("ohci", usb_debug_root);
  28226. + if (!ohci_debug_root) {
  28227. + retval = -ENOENT;
  28228. + goto error_debug;
  28229. + }
  28230. +#endif
  28231. +
  28232. +#ifdef PS3_SYSTEM_BUS_DRIVER
  28233. + retval = ps3_ohci_driver_register(&PS3_SYSTEM_BUS_DRIVER);
  28234. + if (retval < 0)
  28235. + goto error_ps3;
  28236. +#endif
  28237. +
  28238. +#ifdef PLATFORM_DRIVER
  28239. + retval = platform_driver_register(&PLATFORM_DRIVER);
  28240. + if (retval < 0)
  28241. + goto error_platform;
  28242. +#endif
  28243. +
  28244. +#ifdef OMAP1_PLATFORM_DRIVER
  28245. + retval = platform_driver_register(&OMAP1_PLATFORM_DRIVER);
  28246. + if (retval < 0)
  28247. + goto error_omap1_platform;
  28248. +#endif
  28249. +
  28250. +#ifdef OMAP3_PLATFORM_DRIVER
  28251. + retval = platform_driver_register(&OMAP3_PLATFORM_DRIVER);
  28252. + if (retval < 0)
  28253. + goto error_omap3_platform;
  28254. +#endif
  28255. +
  28256. +#ifdef OF_PLATFORM_DRIVER
  28257. + retval = of_register_platform_driver(&OF_PLATFORM_DRIVER);
  28258. + if (retval < 0)
  28259. + goto error_of_platform;
  28260. +#endif
  28261. +
  28262. +#ifdef SA1111_DRIVER
  28263. + retval = sa1111_driver_register(&SA1111_DRIVER);
  28264. + if (retval < 0)
  28265. + goto error_sa1111;
  28266. +#endif
  28267. +
  28268. +#ifdef PCI_DRIVER
  28269. + retval = pci_register_driver(&PCI_DRIVER);
  28270. + if (retval < 0)
  28271. + goto error_pci;
  28272. +#endif
  28273. +
  28274. +#ifdef SSB_OHCI_DRIVER
  28275. + retval = ssb_driver_register(&SSB_OHCI_DRIVER);
  28276. + if (retval)
  28277. + goto error_ssb;
  28278. +#endif
  28279. +
  28280. +#ifdef SM501_OHCI_DRIVER
  28281. + retval = platform_driver_register(&SM501_OHCI_DRIVER);
  28282. + if (retval < 0)
  28283. + goto error_sm501;
  28284. +#endif
  28285. +
  28286. +#ifdef TMIO_OHCI_DRIVER
  28287. + retval = platform_driver_register(&TMIO_OHCI_DRIVER);
  28288. + if (retval < 0)
  28289. + goto error_tmio;
  28290. +#endif
  28291. +
  28292. + return retval;
  28293. +
  28294. + /* Error path */
  28295. +#ifdef TMIO_OHCI_DRIVER
  28296. + platform_driver_unregister(&TMIO_OHCI_DRIVER);
  28297. + error_tmio:
  28298. +#endif
  28299. +#ifdef SM501_OHCI_DRIVER
  28300. + platform_driver_unregister(&SM501_OHCI_DRIVER);
  28301. + error_sm501:
  28302. +#endif
  28303. +#ifdef SSB_OHCI_DRIVER
  28304. + ssb_driver_unregister(&SSB_OHCI_DRIVER);
  28305. + error_ssb:
  28306. +#endif
  28307. +#ifdef PCI_DRIVER
  28308. + pci_unregister_driver(&PCI_DRIVER);
  28309. + error_pci:
  28310. +#endif
  28311. +#ifdef SA1111_DRIVER
  28312. + sa1111_driver_unregister(&SA1111_DRIVER);
  28313. + error_sa1111:
  28314. +#endif
  28315. +#ifdef OF_PLATFORM_DRIVER
  28316. + of_unregister_platform_driver(&OF_PLATFORM_DRIVER);
  28317. + error_of_platform:
  28318. +#endif
  28319. +#ifdef PLATFORM_DRIVER
  28320. + platform_driver_unregister(&PLATFORM_DRIVER);
  28321. + error_platform:
  28322. +#endif
  28323. +#ifdef OMAP1_PLATFORM_DRIVER
  28324. + platform_driver_unregister(&OMAP1_PLATFORM_DRIVER);
  28325. + error_omap1_platform:
  28326. +#endif
  28327. +#ifdef OMAP3_PLATFORM_DRIVER
  28328. + platform_driver_unregister(&OMAP3_PLATFORM_DRIVER);
  28329. + error_omap3_platform:
  28330. +#endif
  28331. +#ifdef PS3_SYSTEM_BUS_DRIVER
  28332. + ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
  28333. + error_ps3:
  28334. +#endif
  28335. +#ifdef DEBUG
  28336. + debugfs_remove(ohci_debug_root);
  28337. + ohci_debug_root = NULL;
  28338. + error_debug:
  28339. +#endif
  28340. +
  28341. + clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
  28342. + return retval;
  28343. +}
  28344. +module_init(ohci_hcd_mod_init);
  28345. +
  28346. +static void __exit ohci_hcd_mod_exit(void)
  28347. +{
  28348. +#ifdef TMIO_OHCI_DRIVER
  28349. + platform_driver_unregister(&TMIO_OHCI_DRIVER);
  28350. +#endif
  28351. +#ifdef SM501_OHCI_DRIVER
  28352. + platform_driver_unregister(&SM501_OHCI_DRIVER);
  28353. +#endif
  28354. +#ifdef SSB_OHCI_DRIVER
  28355. + ssb_driver_unregister(&SSB_OHCI_DRIVER);
  28356. +#endif
  28357. +#ifdef PCI_DRIVER
  28358. + pci_unregister_driver(&PCI_DRIVER);
  28359. +#endif
  28360. +#ifdef SA1111_DRIVER
  28361. + sa1111_driver_unregister(&SA1111_DRIVER);
  28362. +#endif
  28363. +#ifdef OF_PLATFORM_DRIVER
  28364. + of_unregister_platform_driver(&OF_PLATFORM_DRIVER);
  28365. +#endif
  28366. +#ifdef PLATFORM_DRIVER
  28367. + platform_driver_unregister(&PLATFORM_DRIVER);
  28368. +#endif
  28369. +#ifdef PS3_SYSTEM_BUS_DRIVER
  28370. + ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
  28371. +#endif
  28372. +#ifdef DEBUG
  28373. + debugfs_remove(ohci_debug_root);
  28374. +#endif
  28375. + clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
  28376. +}
  28377. +module_exit(ohci_hcd_mod_exit);
  28378. +
  28379. diff -Nur linux-2.6.35.7.orig/drivers/watchdog/ar71xx_wdt.c linux-2.6.35.7/drivers/watchdog/ar71xx_wdt.c
  28380. --- linux-2.6.35.7.orig/drivers/watchdog/ar71xx_wdt.c 1970-01-01 01:00:00.000000000 +0100
  28381. +++ linux-2.6.35.7/drivers/watchdog/ar71xx_wdt.c 2010-10-14 20:28:01.508101380 +0200
  28382. @@ -0,0 +1,270 @@
  28383. +/*
  28384. + * Driver for the Atheros AR71xx SoC's built-in hardware watchdog timer.
  28385. + *
  28386. + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
  28387. + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  28388. + *
  28389. + * This driver was based on: drivers/watchdog/ixp4xx_wdt.c
  28390. + * Author: Deepak Saxena <dsaxena@plexity.net>
  28391. + * Copyright 2004 (c) MontaVista, Software, Inc.
  28392. + *
  28393. + * which again was based on sa1100 driver,
  28394. + * Copyright (C) 2000 Oleg Drokin <green@crimea.edu>
  28395. + *
  28396. + * This program is free software; you can redistribute it and/or modify it
  28397. + * under the terms of the GNU General Public License version 2 as published
  28398. + * by the Free Software Foundation.
  28399. + *
  28400. + */
  28401. +
  28402. +#include <linux/bitops.h>
  28403. +#include <linux/errno.h>
  28404. +#include <linux/fs.h>
  28405. +#include <linux/init.h>
  28406. +#include <linux/kernel.h>
  28407. +#include <linux/miscdevice.h>
  28408. +#include <linux/module.h>
  28409. +#include <linux/moduleparam.h>
  28410. +#include <linux/platform_device.h>
  28411. +#include <linux/types.h>
  28412. +#include <linux/watchdog.h>
  28413. +
  28414. +#include <asm/mach-ar71xx/ar71xx.h>
  28415. +
  28416. +#define DRV_NAME "ar71xx-wdt"
  28417. +#define DRV_DESC "Atheros AR71xx hardware watchdog driver"
  28418. +#define DRV_VERSION "0.1.0"
  28419. +
  28420. +#define WDT_TIMEOUT 15 /* seconds */
  28421. +
  28422. +static int nowayout = WATCHDOG_NOWAYOUT;
  28423. +
  28424. +#ifdef CONFIG_WATCHDOG_NOWAYOUT
  28425. +module_param(nowayout, int, 0);
  28426. +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
  28427. + "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
  28428. +#endif
  28429. +
  28430. +static unsigned long wdt_flags;
  28431. +
  28432. +#define WDT_FLAGS_BUSY 0
  28433. +#define WDT_FLAGS_EXPECT_CLOSE 1
  28434. +
  28435. +static int wdt_timeout = WDT_TIMEOUT;
  28436. +static int boot_status;
  28437. +static int max_timeout;
  28438. +
  28439. +static void inline ar71xx_wdt_keepalive(void)
  28440. +{
  28441. + ar71xx_reset_wr(AR71XX_RESET_REG_WDOG, ar71xx_ahb_freq * wdt_timeout);
  28442. +}
  28443. +
  28444. +static void inline ar71xx_wdt_enable(void)
  28445. +{
  28446. + printk(KERN_DEBUG DRV_NAME ": enabling watchdog timer\n");
  28447. + ar71xx_wdt_keepalive();
  28448. + ar71xx_reset_wr(AR71XX_RESET_REG_WDOG_CTRL, WDOG_CTRL_ACTION_FCR);
  28449. +}
  28450. +
  28451. +static void inline ar71xx_wdt_disable(void)
  28452. +{
  28453. + printk(KERN_DEBUG DRV_NAME ": disabling watchdog timer\n");
  28454. + ar71xx_reset_wr(AR71XX_RESET_REG_WDOG_CTRL, WDOG_CTRL_ACTION_NONE);
  28455. +}
  28456. +
  28457. +static int ar71xx_wdt_set_timeout(int val)
  28458. +{
  28459. + if (val < 1 || val > max_timeout)
  28460. + return -EINVAL;
  28461. +
  28462. + wdt_timeout = val;
  28463. + ar71xx_wdt_keepalive();
  28464. +
  28465. + printk(KERN_DEBUG DRV_NAME ": timeout=%d secs\n", wdt_timeout);
  28466. +
  28467. + return 0;
  28468. +}
  28469. +
  28470. +static int ar71xx_wdt_open(struct inode *inode, struct file *file)
  28471. +{
  28472. + if (test_and_set_bit(WDT_FLAGS_BUSY, &wdt_flags))
  28473. + return -EBUSY;
  28474. +
  28475. + clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags);
  28476. +
  28477. + ar71xx_wdt_enable();
  28478. +
  28479. + return nonseekable_open(inode, file);
  28480. +}
  28481. +
  28482. +static int ar71xx_wdt_release(struct inode *inode, struct file *file)
  28483. +{
  28484. + if (test_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags)) {
  28485. + ar71xx_wdt_disable();
  28486. + } else {
  28487. + printk(KERN_CRIT DRV_NAME ": device closed unexpectedly, "
  28488. + "watchdog timer will not stop!\n");
  28489. + }
  28490. +
  28491. + clear_bit(WDT_FLAGS_BUSY, &wdt_flags);
  28492. + clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags);
  28493. +
  28494. + return 0;
  28495. +}
  28496. +
  28497. +static ssize_t ar71xx_wdt_write(struct file *file, const char *data,
  28498. + size_t len, loff_t *ppos)
  28499. +{
  28500. + if (len) {
  28501. + if (!nowayout) {
  28502. + size_t i;
  28503. +
  28504. + clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags);
  28505. +
  28506. + for (i = 0; i != len; i++) {
  28507. + char c;
  28508. +
  28509. + if (get_user(c, data + i))
  28510. + return -EFAULT;
  28511. +
  28512. + if (c == 'V')
  28513. + set_bit(WDT_FLAGS_EXPECT_CLOSE,
  28514. + &wdt_flags);
  28515. + }
  28516. + }
  28517. +
  28518. + ar71xx_wdt_keepalive();
  28519. + }
  28520. +
  28521. + return len;
  28522. +}
  28523. +
  28524. +static struct watchdog_info ar71xx_wdt_info = {
  28525. + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
  28526. + WDIOF_MAGICCLOSE | WDIOF_CARDRESET,
  28527. + .firmware_version = 0,
  28528. + .identity = "AR71XX watchdog",
  28529. +};
  28530. +
  28531. +static int ar71xx_wdt_ioctl(struct inode *inode, struct file *file,
  28532. + unsigned int cmd, unsigned long arg)
  28533. +{
  28534. + int t;
  28535. + int ret;
  28536. +
  28537. + switch (cmd) {
  28538. + case WDIOC_GETSUPPORT:
  28539. + ret = copy_to_user((struct watchdog_info *)arg,
  28540. + &ar71xx_wdt_info,
  28541. + sizeof(&ar71xx_wdt_info)) ? -EFAULT : 0;
  28542. + break;
  28543. +
  28544. + case WDIOC_GETSTATUS:
  28545. + ret = put_user(0, (int *)arg) ? -EFAULT : 0;
  28546. + break;
  28547. +
  28548. + case WDIOC_GETBOOTSTATUS:
  28549. + ret = put_user(boot_status, (int *)arg) ? -EFAULT : 0;
  28550. + break;
  28551. +
  28552. + case WDIOC_KEEPALIVE:
  28553. + ar71xx_wdt_keepalive();
  28554. + ret = 0;
  28555. + break;
  28556. +
  28557. + case WDIOC_SETTIMEOUT:
  28558. + ret = get_user(t, (int *)arg) ? -EFAULT : 0;
  28559. + if (ret)
  28560. + break;
  28561. +
  28562. + ret = ar71xx_wdt_set_timeout(t);
  28563. + if (ret)
  28564. + break;
  28565. +
  28566. + /* fallthrough */
  28567. + case WDIOC_GETTIMEOUT:
  28568. + ret = put_user(wdt_timeout, (int *)arg) ? -EFAULT : 0;
  28569. + break;
  28570. +
  28571. + default:
  28572. + ret = -ENOTTY;
  28573. + break;
  28574. + }
  28575. +
  28576. + return ret;
  28577. +}
  28578. +
  28579. +static const struct file_operations ar71xx_wdt_fops = {
  28580. + .owner = THIS_MODULE,
  28581. + .write = ar71xx_wdt_write,
  28582. + .ioctl = ar71xx_wdt_ioctl,
  28583. + .open = ar71xx_wdt_open,
  28584. + .release = ar71xx_wdt_release,
  28585. +};
  28586. +
  28587. +static struct miscdevice ar71xx_wdt_miscdev = {
  28588. + .minor = WATCHDOG_MINOR,
  28589. + .name = "watchdog",
  28590. + .fops = &ar71xx_wdt_fops,
  28591. +};
  28592. +
  28593. +static int __devinit ar71xx_wdt_probe(struct platform_device *pdev)
  28594. +{
  28595. + int ret;
  28596. +
  28597. + max_timeout = (0xfffffffful / ar71xx_ahb_freq);
  28598. + wdt_timeout = (max_timeout < WDT_TIMEOUT) ? max_timeout : WDT_TIMEOUT;
  28599. +
  28600. + boot_status =
  28601. + (ar71xx_reset_rr(AR71XX_RESET_REG_WDOG_CTRL) & WDOG_CTRL_LAST_RESET) ?
  28602. + WDIOF_CARDRESET : 0;
  28603. +
  28604. + ret = misc_register(&ar71xx_wdt_miscdev);
  28605. + if (ret)
  28606. + goto err_out;
  28607. +
  28608. + printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
  28609. +
  28610. + printk(KERN_DEBUG DRV_NAME ": timeout=%d secs (max=%d)\n",
  28611. + wdt_timeout, max_timeout);
  28612. +
  28613. + return 0;
  28614. +
  28615. +err_out:
  28616. + return ret;
  28617. +}
  28618. +
  28619. +static int __devexit ar71xx_wdt_remove(struct platform_device *pdev)
  28620. +{
  28621. + misc_deregister(&ar71xx_wdt_miscdev);
  28622. + return 0;
  28623. +}
  28624. +
  28625. +static struct platform_driver ar71xx_wdt_driver = {
  28626. + .probe = ar71xx_wdt_probe,
  28627. + .remove = __devexit_p(ar71xx_wdt_remove),
  28628. + .driver = {
  28629. + .name = DRV_NAME,
  28630. + .owner = THIS_MODULE,
  28631. + },
  28632. +};
  28633. +
  28634. +static int __init ar71xx_wdt_init(void)
  28635. +{
  28636. + return platform_driver_register(&ar71xx_wdt_driver);
  28637. +}
  28638. +module_init(ar71xx_wdt_init);
  28639. +
  28640. +static void __exit ar71xx_wdt_exit(void)
  28641. +{
  28642. + platform_driver_unregister(&ar71xx_wdt_driver);
  28643. +}
  28644. +module_exit(ar71xx_wdt_exit);
  28645. +
  28646. +MODULE_DESCRIPTION(DRV_DESC);
  28647. +MODULE_VERSION(DRV_VERSION);
  28648. +MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org");
  28649. +MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org");
  28650. +MODULE_LICENSE("GPL v2");
  28651. +MODULE_ALIAS("platform:" DRV_NAME);
  28652. +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
  28653. diff -Nur linux-2.6.35.7.orig/drivers/watchdog/Kconfig linux-2.6.35.7/drivers/watchdog/Kconfig
  28654. --- linux-2.6.35.7.orig/drivers/watchdog/Kconfig 2010-09-29 03:09:08.000000000 +0200
  28655. +++ linux-2.6.35.7/drivers/watchdog/Kconfig 2010-10-14 20:28:01.548101099 +0200
  28656. @@ -875,6 +875,13 @@
  28657. help
  28658. Hardware driver for the built-in watchdog timer on TXx9 MIPS SoCs.
  28659. +config AR71XX_WDT
  28660. + tristate "Atheros AR71xx Watchdog Timer"
  28661. + depends on ATHEROS_AR71XX
  28662. + help
  28663. + Hardware driver for the built-in watchdog timer on the Atheros
  28664. + AR71xx SoCs.
  28665. +
  28666. # PARISC Architecture
  28667. # POWERPC Architecture
  28668. diff -Nur linux-2.6.35.7.orig/drivers/watchdog/Kconfig.orig linux-2.6.35.7/drivers/watchdog/Kconfig.orig
  28669. --- linux-2.6.35.7.orig/drivers/watchdog/Kconfig.orig 1970-01-01 01:00:00.000000000 +0100
  28670. +++ linux-2.6.35.7/drivers/watchdog/Kconfig.orig 2010-09-29 03:09:08.000000000 +0200
  28671. @@ -0,0 +1,1114 @@
  28672. +#
  28673. +# Watchdog device configuration
  28674. +#
  28675. +
  28676. +menuconfig WATCHDOG
  28677. + bool "Watchdog Timer Support"
  28678. + ---help---
  28679. + If you say Y here (and to one of the following options) and create a
  28680. + character special file /dev/watchdog with major number 10 and minor
  28681. + number 130 using mknod ("man mknod"), you will get a watchdog, i.e.:
  28682. + subsequently opening the file and then failing to write to it for
  28683. + longer than 1 minute will result in rebooting the machine. This
  28684. + could be useful for a networked machine that needs to come back
  28685. + on-line as fast as possible after a lock-up. There's both a watchdog
  28686. + implementation entirely in software (which can sometimes fail to
  28687. + reboot the machine) and a driver for hardware watchdog boards, which
  28688. + are more robust and can also keep track of the temperature inside
  28689. + your computer. For details, read
  28690. + <file:Documentation/watchdog/watchdog-api.txt> in the kernel source.
  28691. +
  28692. + The watchdog is usually used together with the watchdog daemon
  28693. + which is available from
  28694. + <ftp://ibiblio.org/pub/Linux/system/daemons/watchdog/>. This daemon can
  28695. + also monitor NFS connections and can reboot the machine when the process
  28696. + table is full.
  28697. +
  28698. + If unsure, say N.
  28699. +
  28700. +if WATCHDOG
  28701. +
  28702. +config WATCHDOG_NOWAYOUT
  28703. + bool "Disable watchdog shutdown on close"
  28704. + help
  28705. + The default watchdog behaviour (which you get if you say N here) is
  28706. + to stop the timer if the process managing it closes the file
  28707. + /dev/watchdog. It's always remotely possible that this process might
  28708. + get killed. If you say Y here, the watchdog cannot be stopped once
  28709. + it has been started.
  28710. +
  28711. +#
  28712. +# General Watchdog drivers
  28713. +#
  28714. +
  28715. +comment "Watchdog Device Drivers"
  28716. +
  28717. +# Architecture Independent
  28718. +
  28719. +config SOFT_WATCHDOG
  28720. + tristate "Software watchdog"
  28721. + help
  28722. + A software monitoring watchdog. This will fail to reboot your system
  28723. + from some situations that the hardware watchdog will recover
  28724. + from. Equally it's a lot cheaper to install.
  28725. +
  28726. + To compile this driver as a module, choose M here: the
  28727. + module will be called softdog.
  28728. +
  28729. +config WM831X_WATCHDOG
  28730. + tristate "WM831x watchdog"
  28731. + depends on MFD_WM831X
  28732. + help
  28733. + Support for the watchdog in the WM831x AudioPlus PMICs. When
  28734. + the watchdog triggers the system will be reset.
  28735. +
  28736. +config WM8350_WATCHDOG
  28737. + tristate "WM8350 watchdog"
  28738. + depends on MFD_WM8350
  28739. + help
  28740. + Support for the watchdog in the WM8350 AudioPlus PMIC. When
  28741. + the watchdog triggers the system will be reset.
  28742. +
  28743. +# ALPHA Architecture
  28744. +
  28745. +# ARM Architecture
  28746. +
  28747. +config AT91RM9200_WATCHDOG
  28748. + tristate "AT91RM9200 watchdog"
  28749. + depends on ARCH_AT91RM9200
  28750. + help
  28751. + Watchdog timer embedded into AT91RM9200 chips. This will reboot your
  28752. + system when the timeout is reached.
  28753. +
  28754. +config AT91SAM9X_WATCHDOG
  28755. + tristate "AT91SAM9X / AT91CAP9 watchdog"
  28756. + depends on ARCH_AT91 && !ARCH_AT91RM9200
  28757. + help
  28758. + Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will
  28759. + reboot your system when the timeout is reached.
  28760. +
  28761. +config 21285_WATCHDOG
  28762. + tristate "DC21285 watchdog"
  28763. + depends on FOOTBRIDGE
  28764. + help
  28765. + The Intel Footbridge chip contains a built-in watchdog circuit. Say Y
  28766. + here if you wish to use this. Alternatively say M to compile the
  28767. + driver as a module, which will be called wdt285.
  28768. +
  28769. + This driver does not work on all machines. In particular, early CATS
  28770. + boards have hardware problems that will cause the machine to simply
  28771. + lock up if the watchdog fires.
  28772. +
  28773. + "If in doubt, leave it out" - say N.
  28774. +
  28775. +config 977_WATCHDOG
  28776. + tristate "NetWinder WB83C977 watchdog"
  28777. + depends on FOOTBRIDGE && ARCH_NETWINDER
  28778. + help
  28779. + Say Y here to include support for the WB977 watchdog included in
  28780. + NetWinder machines. Alternatively say M to compile the driver as
  28781. + a module, which will be called wdt977.
  28782. +
  28783. + Not sure? It's safe to say N.
  28784. +
  28785. +config IXP2000_WATCHDOG
  28786. + tristate "IXP2000 Watchdog"
  28787. + depends on ARCH_IXP2000
  28788. + help
  28789. + Say Y here if to include support for the watchdog timer
  28790. + in the Intel IXP2000(2400, 2800, 2850) network processors.
  28791. + This driver can be built as a module by choosing M. The module
  28792. + will be called ixp2000_wdt.
  28793. +
  28794. + Say N if you are unsure.
  28795. +
  28796. +config IXP4XX_WATCHDOG
  28797. + tristate "IXP4xx Watchdog"
  28798. + depends on ARCH_IXP4XX
  28799. + help
  28800. + Say Y here if to include support for the watchdog timer
  28801. + in the Intel IXP4xx network processors. This driver can
  28802. + be built as a module by choosing M. The module will
  28803. + be called ixp4xx_wdt.
  28804. +
  28805. + Note: The internal IXP4xx watchdog does a soft CPU reset
  28806. + which doesn't reset any peripherals. There are circumstances
  28807. + where the watchdog will fail to reset the board correctly
  28808. + (e.g., if the boot ROM is in an unreadable state).
  28809. +
  28810. + Say N if you are unsure.
  28811. +
  28812. +config KS8695_WATCHDOG
  28813. + tristate "KS8695 watchdog"
  28814. + depends on ARCH_KS8695
  28815. + help
  28816. + Watchdog timer embedded into KS8695 processor. This will reboot your
  28817. + system when the timeout is reached.
  28818. +
  28819. +config HAVE_S3C2410_WATCHDOG
  28820. + bool
  28821. + help
  28822. + This will include watchdog timer support for Samsung SoCs. If
  28823. + you want to include watchdog support for any machine, kindly
  28824. + select this in the respective mach-XXXX/Kconfig file.
  28825. +
  28826. +config S3C2410_WATCHDOG
  28827. + tristate "S3C2410 Watchdog"
  28828. + depends on ARCH_S3C2410 || HAVE_S3C2410_WATCHDOG
  28829. + help
  28830. + Watchdog timer block in the Samsung SoCs. This will reboot
  28831. + the system when the timer expires with the watchdog enabled.
  28832. +
  28833. + The driver is limited by the speed of the system's PCLK
  28834. + signal, so with reasonably fast systems (PCLK around 50-66MHz)
  28835. + then watchdog intervals of over approximately 20seconds are
  28836. + unavailable.
  28837. +
  28838. + The driver can be built as a module by choosing M, and will
  28839. + be called s3c2410_wdt
  28840. +
  28841. +config SA1100_WATCHDOG
  28842. + tristate "SA1100/PXA2xx watchdog"
  28843. + depends on ARCH_SA1100 || ARCH_PXA
  28844. + help
  28845. + Watchdog timer embedded into SA11x0 and PXA2xx chips. This will
  28846. + reboot your system when timeout is reached.
  28847. +
  28848. + NOTE: once enabled, this timer cannot be disabled.
  28849. +
  28850. + To compile this driver as a module, choose M here: the
  28851. + module will be called sa1100_wdt.
  28852. +
  28853. +config MPCORE_WATCHDOG
  28854. + tristate "MPcore watchdog"
  28855. + depends on HAVE_ARM_TWD
  28856. + help
  28857. + Watchdog timer embedded into the MPcore system.
  28858. +
  28859. + To compile this driver as a module, choose M here: the
  28860. + module will be called mpcore_wdt.
  28861. +
  28862. +config EP93XX_WATCHDOG
  28863. + tristate "EP93xx Watchdog"
  28864. + depends on ARCH_EP93XX
  28865. + help
  28866. + Say Y here if to include support for the watchdog timer
  28867. + embedded in the Cirrus Logic EP93xx family of devices.
  28868. +
  28869. + To compile this driver as a module, choose M here: the
  28870. + module will be called ep93xx_wdt.
  28871. +
  28872. +config OMAP_WATCHDOG
  28873. + tristate "OMAP Watchdog"
  28874. + depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS
  28875. + help
  28876. + Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog. Say 'Y'
  28877. + here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog timer.
  28878. +
  28879. +config PNX4008_WATCHDOG
  28880. + tristate "PNX4008 Watchdog"
  28881. + depends on ARCH_PNX4008
  28882. + help
  28883. + Say Y here if to include support for the watchdog timer
  28884. + in the PNX4008 processor.
  28885. + This driver can be built as a module by choosing M. The module
  28886. + will be called pnx4008_wdt.
  28887. +
  28888. + Say N if you are unsure.
  28889. +
  28890. +config IOP_WATCHDOG
  28891. + tristate "IOP Watchdog"
  28892. + depends on PLAT_IOP
  28893. + select WATCHDOG_NOWAYOUT if (ARCH_IOP32X || ARCH_IOP33X)
  28894. + help
  28895. + Say Y here if to include support for the watchdog timer
  28896. + in the Intel IOP3XX & IOP13XX I/O Processors. This driver can
  28897. + be built as a module by choosing M. The module will
  28898. + be called iop_wdt.
  28899. +
  28900. + Note: The IOP13XX watchdog does an Internal Bus Reset which will
  28901. + affect both cores and the peripherals of the IOP. The ATU-X
  28902. + and/or ATUe configuration registers will remain intact, but if
  28903. + operating as an Root Complex and/or Central Resource, the PCI-X
  28904. + and/or PCIe busses will also be reset. THIS IS A VERY BIG HAMMER.
  28905. +
  28906. +config DAVINCI_WATCHDOG
  28907. + tristate "DaVinci watchdog"
  28908. + depends on ARCH_DAVINCI
  28909. + help
  28910. + Say Y here if to include support for the watchdog timer
  28911. + in the DaVinci DM644x/DM646x processors.
  28912. + To compile this driver as a module, choose M here: the
  28913. + module will be called davinci_wdt.
  28914. +
  28915. + NOTE: once enabled, this timer cannot be disabled.
  28916. + Say N if you are unsure.
  28917. +
  28918. +config ORION_WATCHDOG
  28919. + tristate "Orion watchdog"
  28920. + depends on ARCH_ORION5X || ARCH_KIRKWOOD
  28921. + help
  28922. + Say Y here if to include support for the watchdog timer
  28923. + in the Marvell Orion5x and Kirkwood ARM SoCs.
  28924. + To compile this driver as a module, choose M here: the
  28925. + module will be called orion_wdt.
  28926. +
  28927. +config COH901327_WATCHDOG
  28928. + bool "ST-Ericsson COH 901 327 watchdog"
  28929. + depends on ARCH_U300
  28930. + default y if MACH_U300
  28931. + help
  28932. + Say Y here to include Watchdog timer support for the
  28933. + watchdog embedded into the ST-Ericsson U300 series platforms.
  28934. + This watchdog is used to reset the system and thus cannot be
  28935. + compiled as a module.
  28936. +
  28937. +config TWL4030_WATCHDOG
  28938. + tristate "TWL4030 Watchdog"
  28939. + depends on TWL4030_CORE
  28940. + help
  28941. + Support for TI TWL4030 watchdog. Say 'Y' here to enable the
  28942. + watchdog timer support for TWL4030 chips.
  28943. +
  28944. +config STMP3XXX_WATCHDOG
  28945. + tristate "Freescale STMP3XXX watchdog"
  28946. + depends on ARCH_STMP3XXX
  28947. + help
  28948. + Say Y here if to include support for the watchdog timer
  28949. + for the Sigmatel STMP37XX/378X SoC.
  28950. + To compile this driver as a module, choose M here: the
  28951. + module will be called stmp3xxx_wdt.
  28952. +
  28953. +config NUC900_WATCHDOG
  28954. + tristate "Nuvoton NUC900 watchdog"
  28955. + depends on ARCH_W90X900
  28956. + help
  28957. + Say Y here if to include support for the watchdog timer
  28958. + for the Nuvoton NUC900 series SoCs.
  28959. + To compile this driver as a module, choose M here: the
  28960. + module will be called nuc900_wdt.
  28961. +
  28962. +config ADX_WATCHDOG
  28963. + tristate "Avionic Design Xanthos watchdog"
  28964. + depends on ARCH_PXA_ADX
  28965. + help
  28966. + Say Y here if you want support for the watchdog timer on Avionic
  28967. + Design Xanthos boards.
  28968. +
  28969. +config TS72XX_WATCHDOG
  28970. + tristate "TS-72XX SBC Watchdog"
  28971. + depends on MACH_TS72XX
  28972. + help
  28973. + Technologic Systems TS-7200, TS-7250 and TS-7260 boards have
  28974. + watchdog timer implemented in a external CPLD chip. Say Y here
  28975. + if you want to support for the watchdog timer on TS-72XX boards.
  28976. +
  28977. + To compile this driver as a module, choose M here: the
  28978. + module will be called ts72xx_wdt.
  28979. +
  28980. +config MAX63XX_WATCHDOG
  28981. + tristate "Max63xx watchdog"
  28982. + depends on ARM && HAS_IOMEM
  28983. + help
  28984. + Support for memory mapped max63{69,70,71,72,73,74} watchdog timer.
  28985. +
  28986. +config IMX2_WDT
  28987. + tristate "IMX2+ Watchdog"
  28988. + depends on ARCH_MX2 || ARCH_MX25 || ARCH_MX3 || ARCH_MX5
  28989. + help
  28990. + This is the driver for the hardware watchdog
  28991. + on the Freescale IMX2 and later processors.
  28992. + If you have one of these processors and wish to have
  28993. + watchdog support enabled, say Y, otherwise say N.
  28994. +
  28995. + To compile this driver as a module, choose M here: the
  28996. + module will be called imx2_wdt.
  28997. +
  28998. +# AVR32 Architecture
  28999. +
  29000. +config AT32AP700X_WDT
  29001. + tristate "AT32AP700x watchdog"
  29002. + depends on CPU_AT32AP700X
  29003. + help
  29004. + Watchdog timer embedded into AT32AP700x devices. This will reboot
  29005. + your system when the timeout is reached.
  29006. +
  29007. +# BLACKFIN Architecture
  29008. +
  29009. +config BFIN_WDT
  29010. + tristate "Blackfin On-Chip Watchdog Timer"
  29011. + depends on BLACKFIN
  29012. + ---help---
  29013. + If you say yes here you will get support for the Blackfin On-Chip
  29014. + Watchdog Timer. If you have one of these processors and wish to
  29015. + have watchdog support enabled, say Y, otherwise say N.
  29016. +
  29017. + To compile this driver as a module, choose M here: the
  29018. + module will be called bfin_wdt.
  29019. +
  29020. +# CRIS Architecture
  29021. +
  29022. +# FRV Architecture
  29023. +
  29024. +# H8300 Architecture
  29025. +
  29026. +# X86 (i386 + ia64 + x86_64) Architecture
  29027. +
  29028. +config ACQUIRE_WDT
  29029. + tristate "Acquire SBC Watchdog Timer"
  29030. + depends on X86
  29031. + ---help---
  29032. + This is the driver for the hardware watchdog on Single Board
  29033. + Computers produced by Acquire Inc (and others). This watchdog
  29034. + simply watches your kernel to make sure it doesn't freeze, and if
  29035. + it does, it reboots your computer after a certain amount of time.
  29036. +
  29037. + To compile this driver as a module, choose M here: the
  29038. + module will be called acquirewdt.
  29039. +
  29040. + Most people will say N.
  29041. +
  29042. +config ADVANTECH_WDT
  29043. + tristate "Advantech SBC Watchdog Timer"
  29044. + depends on X86
  29045. + help
  29046. + If you are configuring a Linux kernel for the Advantech single-board
  29047. + computer, say `Y' here to support its built-in watchdog timer
  29048. + feature. More information can be found at
  29049. + <http://www.advantech.com.tw/products/>
  29050. +
  29051. +config ALIM1535_WDT
  29052. + tristate "ALi M1535 PMU Watchdog Timer"
  29053. + depends on X86 && PCI
  29054. + ---help---
  29055. + This is the driver for the hardware watchdog on the ALi M1535 PMU.
  29056. +
  29057. + To compile this driver as a module, choose M here: the
  29058. + module will be called alim1535_wdt.
  29059. +
  29060. + Most people will say N.
  29061. +
  29062. +config ALIM7101_WDT
  29063. + tristate "ALi M7101 PMU Computer Watchdog"
  29064. + depends on PCI
  29065. + help
  29066. + This is the driver for the hardware watchdog on the ALi M7101 PMU
  29067. + as used in the x86 Cobalt servers and also found in some
  29068. + SPARC Netra servers too.
  29069. +
  29070. + To compile this driver as a module, choose M here: the
  29071. + module will be called alim7101_wdt.
  29072. +
  29073. + Most people will say N.
  29074. +
  29075. +config GEODE_WDT
  29076. + tristate "AMD Geode CS5535/CS5536 Watchdog"
  29077. + depends on CS5535_MFGPT
  29078. + help
  29079. + This driver enables a watchdog capability built into the
  29080. + CS5535/CS5536 companion chips for the AMD Geode GX and LX
  29081. + processors. This watchdog watches your kernel to make sure
  29082. + it doesn't freeze, and if it does, it reboots your computer after
  29083. + a certain amount of time.
  29084. +
  29085. + You can compile this driver directly into the kernel, or use
  29086. + it as a module. The module will be called geodewdt.
  29087. +
  29088. +config SC520_WDT
  29089. + tristate "AMD Elan SC520 processor Watchdog"
  29090. + depends on X86
  29091. + help
  29092. + This is the driver for the hardware watchdog built in to the
  29093. + AMD "Elan" SC520 microcomputer commonly used in embedded systems.
  29094. + This watchdog simply watches your kernel to make sure it doesn't
  29095. + freeze, and if it does, it reboots your computer after a certain
  29096. + amount of time.
  29097. +
  29098. + You can compile this driver directly into the kernel, or use
  29099. + it as a module. The module will be called sc520_wdt.
  29100. +
  29101. +config SBC_FITPC2_WATCHDOG
  29102. + tristate "Compulab SBC-FITPC2 watchdog"
  29103. + depends on X86
  29104. + ---help---
  29105. + This is the driver for the built-in watchdog timer on the fit-PC2,
  29106. + fit-PC2i, CM-iAM single-board computers made by Compulab.
  29107. +
  29108. + It`s possible to enable watchdog timer either from BIOS (F2) or from booted Linux.
  29109. + When "Watchdog Timer Value" enabled one can set 31-255 s operational range.
  29110. +
  29111. + Entering BIOS setup temporary disables watchdog operation regardless to current state,
  29112. + so system will not be restarted while user in BIOS setup.
  29113. +
  29114. + Once watchdog was enabled the system will be restarted every
  29115. + "Watchdog Timer Value" period, so to prevent it user can restart or
  29116. + disable the watchdog.
  29117. +
  29118. + To compile this driver as a module, choose M here: the
  29119. + module will be called sbc_fitpc2_wdt.
  29120. +
  29121. + Most people will say N.
  29122. +
  29123. +config EUROTECH_WDT
  29124. + tristate "Eurotech CPU-1220/1410 Watchdog Timer"
  29125. + depends on X86
  29126. + help
  29127. + Enable support for the watchdog timer on the Eurotech CPU-1220 and
  29128. + CPU-1410 cards. These are PC/104 SBCs. Spec sheets and product
  29129. + information are at <http://www.eurotech.it/>.
  29130. +
  29131. +config IB700_WDT
  29132. + tristate "IB700 SBC Watchdog Timer"
  29133. + depends on X86
  29134. + ---help---
  29135. + This is the driver for the hardware watchdog on the IB700 Single
  29136. + Board Computer produced by TMC Technology (www.tmc-uk.com). This watchdog
  29137. + simply watches your kernel to make sure it doesn't freeze, and if
  29138. + it does, it reboots your computer after a certain amount of time.
  29139. +
  29140. + This driver is like the WDT501 driver but for slightly different hardware.
  29141. +
  29142. + To compile this driver as a module, choose M here: the
  29143. + module will be called ib700wdt.
  29144. +
  29145. + Most people will say N.
  29146. +
  29147. +config IBMASR
  29148. + tristate "IBM Automatic Server Restart"
  29149. + depends on X86
  29150. + help
  29151. + This is the driver for the IBM Automatic Server Restart watchdog
  29152. + timer built-in into some eServer xSeries machines.
  29153. +
  29154. + To compile this driver as a module, choose M here: the
  29155. + module will be called ibmasr.
  29156. +
  29157. +config WAFER_WDT
  29158. + tristate "ICP Single Board Computer Watchdog Timer"
  29159. + depends on X86
  29160. + help
  29161. + This is a driver for the hardware watchdog on the ICP Single
  29162. + Board Computer. This driver is working on (at least) the following
  29163. + IPC SBC's: Wafer 5823, Rocky 4783, Rocky 3703 and Rocky 3782.
  29164. +
  29165. + To compile this driver as a module, choose M here: the
  29166. + module will be called wafer5823wdt.
  29167. +
  29168. +config I6300ESB_WDT
  29169. + tristate "Intel 6300ESB Timer/Watchdog"
  29170. + depends on X86 && PCI
  29171. + ---help---
  29172. + Hardware driver for the watchdog timer built into the Intel
  29173. + 6300ESB controller hub.
  29174. +
  29175. + To compile this driver as a module, choose M here: the
  29176. + module will be called i6300esb.
  29177. +
  29178. +config ITCO_WDT
  29179. + tristate "Intel TCO Timer/Watchdog"
  29180. + depends on (X86 || IA64) && PCI
  29181. + ---help---
  29182. + Hardware driver for the intel TCO timer based watchdog devices.
  29183. + These drivers are included in the Intel 82801 I/O Controller
  29184. + Hub family (from ICH0 up to ICH10) and in the Intel 63xxESB
  29185. + controller hub.
  29186. +
  29187. + The TCO (Total Cost of Ownership) timer is a watchdog timer
  29188. + that will reboot the machine after its second expiration. The
  29189. + expiration time can be configured with the "heartbeat" parameter.
  29190. +
  29191. + On some motherboards the driver may fail to reset the chipset's
  29192. + NO_REBOOT flag which prevents the watchdog from rebooting the
  29193. + machine. If this is the case you will get a kernel message like
  29194. + "failed to reset NO_REBOOT flag, reboot disabled by hardware".
  29195. +
  29196. + To compile this driver as a module, choose M here: the
  29197. + module will be called iTCO_wdt.
  29198. +
  29199. +config ITCO_VENDOR_SUPPORT
  29200. + bool "Intel TCO Timer/Watchdog Specific Vendor Support"
  29201. + depends on ITCO_WDT
  29202. + ---help---
  29203. + Add vendor specific support to the intel TCO timer based watchdog
  29204. + devices. At this moment we only have additional support for some
  29205. + SuperMicro Inc. motherboards.
  29206. +
  29207. +config IT8712F_WDT
  29208. + tristate "IT8712F (Smart Guardian) Watchdog Timer"
  29209. + depends on X86
  29210. + ---help---
  29211. + This is the driver for the built-in watchdog timer on the IT8712F
  29212. + Super I/0 chipset used on many motherboards.
  29213. +
  29214. + To compile this driver as a module, choose M here: the
  29215. + module will be called it8712f_wdt.
  29216. +
  29217. +config IT87_WDT
  29218. + tristate "IT87 Watchdog Timer"
  29219. + depends on X86 && EXPERIMENTAL
  29220. + ---help---
  29221. + This is the driver for the hardware watchdog on the ITE IT8716,
  29222. + IT8718, IT8726, IT8712(Version J,K) Super I/O chips. This watchdog
  29223. + simply watches your kernel to make sure it doesn't freeze, and if
  29224. + it does, it reboots your computer after a certain amount of time.
  29225. +
  29226. + To compile this driver as a module, choose M here: the module will
  29227. + be called it87_wdt.
  29228. +
  29229. +config HP_WATCHDOG
  29230. + tristate "HP Proliant iLO 2 Hardware Watchdog Timer"
  29231. + depends on X86
  29232. + help
  29233. + A software monitoring watchdog and NMI sourcing driver. This driver
  29234. + will detect lockups and provide stack trace. Also, when an NMI
  29235. + occurs this driver will make the necessary BIOS calls to log
  29236. + the cause of the NMI. This is a driver that will only load on a
  29237. + HP ProLiant system with a minimum of iLO2 support.
  29238. + To compile this driver as a module, choose M here: the
  29239. + module will be called hpwdt.
  29240. +
  29241. +config SC1200_WDT
  29242. + tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog"
  29243. + depends on X86
  29244. + help
  29245. + This is a driver for National Semiconductor PC87307/PC97307 hardware
  29246. + watchdog cards as found on the SC1200. This watchdog is mainly used
  29247. + for power management purposes and can be used to power down the device
  29248. + during inactivity periods (includes interrupt activity monitoring).
  29249. +
  29250. + To compile this driver as a module, choose M here: the
  29251. + module will be called sc1200wdt.
  29252. +
  29253. + Most people will say N.
  29254. +
  29255. +config SCx200_WDT
  29256. + tristate "National Semiconductor SCx200 Watchdog"
  29257. + depends on SCx200 && PCI
  29258. + help
  29259. + Enable the built-in watchdog timer support on the National
  29260. + Semiconductor SCx200 processors.
  29261. +
  29262. + If compiled as a module, it will be called scx200_wdt.
  29263. +
  29264. +config PC87413_WDT
  29265. + tristate "NS PC87413 watchdog"
  29266. + depends on X86
  29267. + ---help---
  29268. + This is the driver for the hardware watchdog on the PC87413 chipset
  29269. + This watchdog simply watches your kernel to make sure it doesn't
  29270. + freeze, and if it does, it reboots your computer after a certain
  29271. + amount of time.
  29272. +
  29273. + To compile this driver as a module, choose M here: the
  29274. + module will be called pc87413_wdt.
  29275. +
  29276. + Most people will say N.
  29277. +
  29278. +config RDC321X_WDT
  29279. + tristate "RDC R-321x SoC watchdog"
  29280. + depends on X86_RDC321X
  29281. + help
  29282. + This is the driver for the built in hardware watchdog
  29283. + in the RDC R-321x SoC.
  29284. +
  29285. + To compile this driver as a module, choose M here: the
  29286. + module will be called rdc321x_wdt.
  29287. +
  29288. +config 60XX_WDT
  29289. + tristate "SBC-60XX Watchdog Timer"
  29290. + depends on X86
  29291. + help
  29292. + This driver can be used with the watchdog timer found on some
  29293. + single board computers, namely the 6010 PII based computer.
  29294. + It may well work with other cards. It reads port 0x443 to enable
  29295. + and re-set the watchdog timer, and reads port 0x45 to disable
  29296. + the watchdog. If you have a card that behave in similar ways,
  29297. + you can probably make this driver work with your card as well.
  29298. +
  29299. + You can compile this driver directly into the kernel, or use
  29300. + it as a module. The module will be called sbc60xxwdt.
  29301. +
  29302. +config SBC8360_WDT
  29303. + tristate "SBC8360 Watchdog Timer"
  29304. + depends on X86
  29305. + ---help---
  29306. +
  29307. + This is the driver for the hardware watchdog on the SBC8360 Single
  29308. + Board Computer produced by Axiomtek Co., Ltd. (www.axiomtek.com).
  29309. +
  29310. + To compile this driver as a module, choose M here: the
  29311. + module will be called sbc8360.
  29312. +
  29313. + Most people will say N.
  29314. +
  29315. +config SBC7240_WDT
  29316. + tristate "SBC Nano 7240 Watchdog Timer"
  29317. + depends on X86_32
  29318. + ---help---
  29319. + This is the driver for the hardware watchdog found on the IEI
  29320. + single board computers EPIC Nano 7240 (and likely others). This
  29321. + watchdog simply watches your kernel to make sure it doesn't freeze,
  29322. + and if it does, it reboots your computer after a certain amount of
  29323. + time.
  29324. +
  29325. + To compile this driver as a module, choose M here: the
  29326. + module will be called sbc7240_wdt.
  29327. +
  29328. +config CPU5_WDT
  29329. + tristate "SMA CPU5 Watchdog"
  29330. + depends on X86
  29331. + ---help---
  29332. + TBD.
  29333. + To compile this driver as a module, choose M here: the
  29334. + module will be called cpu5wdt.
  29335. +
  29336. +config SMSC_SCH311X_WDT
  29337. + tristate "SMSC SCH311X Watchdog Timer"
  29338. + depends on X86
  29339. + ---help---
  29340. + This is the driver for the hardware watchdog timer on the
  29341. + SMSC SCH3112, SCH3114 and SCH3116 Super IO chipset
  29342. + (LPC IO with 8042 KBC, Reset Generation, HWM and multiple
  29343. + serial ports).
  29344. +
  29345. + To compile this driver as a module, choose M here: the
  29346. + module will be called sch311x_wdt.
  29347. +
  29348. +config SMSC37B787_WDT
  29349. + tristate "Winbond SMsC37B787 Watchdog Timer"
  29350. + depends on X86
  29351. + ---help---
  29352. + This is the driver for the hardware watchdog component on the
  29353. + Winbond SMsC37B787 chipset as used on the NetRunner Mainboard
  29354. + from Vision Systems and maybe others.
  29355. +
  29356. + This watchdog simply watches your kernel to make sure it doesn't
  29357. + freeze, and if it does, it reboots your computer after a certain
  29358. + amount of time.
  29359. +
  29360. + Usually a userspace daemon will notify the kernel WDT driver that
  29361. + userspace is still alive, at regular intervals.
  29362. +
  29363. + To compile this driver as a module, choose M here: the
  29364. + module will be called smsc37b787_wdt.
  29365. +
  29366. + Most people will say N.
  29367. +
  29368. +config W83627HF_WDT
  29369. + tristate "W83627HF Watchdog Timer"
  29370. + depends on X86
  29371. + ---help---
  29372. + This is the driver for the hardware watchdog on the W83627HF chipset
  29373. + as used in Advantech PC-9578 and Tyan S2721-533 motherboards
  29374. + (and likely others). This watchdog simply watches your kernel to
  29375. + make sure it doesn't freeze, and if it does, it reboots your computer
  29376. + after a certain amount of time.
  29377. +
  29378. + To compile this driver as a module, choose M here: the
  29379. + module will be called w83627hf_wdt.
  29380. +
  29381. + Most people will say N.
  29382. +
  29383. +config W83697HF_WDT
  29384. + tristate "W83697HF/W83697HG Watchdog Timer"
  29385. + depends on X86
  29386. + ---help---
  29387. + This is the driver for the hardware watchdog on the W83697HF/HG
  29388. + chipset as used in Dedibox/VIA motherboards (and likely others).
  29389. + This watchdog simply watches your kernel to make sure it doesn't
  29390. + freeze, and if it does, it reboots your computer after a certain
  29391. + amount of time.
  29392. +
  29393. + To compile this driver as a module, choose M here: the
  29394. + module will be called w83697hf_wdt.
  29395. +
  29396. + Most people will say N.
  29397. +
  29398. +config W83697UG_WDT
  29399. + tristate "W83697UG/W83697UF Watchdog Timer"
  29400. + depends on X86
  29401. + ---help---
  29402. + This is the driver for the hardware watchdog on the W83697UG/UF
  29403. + chipset as used in MSI Fuzzy CX700 VIA motherboards (and likely others).
  29404. + This watchdog simply watches your kernel to make sure it doesn't
  29405. + freeze, and if it does, it reboots your computer after a certain
  29406. + amount of time.
  29407. +
  29408. + To compile this driver as a module, choose M here: the
  29409. + module will be called w83697ug_wdt.
  29410. +
  29411. + Most people will say N.
  29412. +
  29413. +config W83877F_WDT
  29414. + tristate "W83877F (EMACS) Watchdog Timer"
  29415. + depends on X86
  29416. + ---help---
  29417. + This is the driver for the hardware watchdog on the W83877F chipset
  29418. + as used in EMACS PC-104 motherboards (and likely others). This
  29419. + watchdog simply watches your kernel to make sure it doesn't freeze,
  29420. + and if it does, it reboots your computer after a certain amount of
  29421. + time.
  29422. +
  29423. + To compile this driver as a module, choose M here: the
  29424. + module will be called w83877f_wdt.
  29425. +
  29426. + Most people will say N.
  29427. +
  29428. +config W83977F_WDT
  29429. + tristate "W83977F (PCM-5335) Watchdog Timer"
  29430. + depends on X86
  29431. + ---help---
  29432. + This is the driver for the hardware watchdog on the W83977F I/O chip
  29433. + as used in AAEON's PCM-5335 SBC (and likely others). This
  29434. + watchdog simply watches your kernel to make sure it doesn't freeze,
  29435. + and if it does, it reboots your computer after a certain amount of
  29436. + time.
  29437. +
  29438. + To compile this driver as a module, choose M here: the
  29439. + module will be called w83977f_wdt.
  29440. +
  29441. +config MACHZ_WDT
  29442. + tristate "ZF MachZ Watchdog"
  29443. + depends on X86
  29444. + ---help---
  29445. + If you are using a ZF Micro MachZ processor, say Y here, otherwise
  29446. + N. This is the driver for the watchdog timer built-in on that
  29447. + processor using ZF-Logic interface. This watchdog simply watches
  29448. + your kernel to make sure it doesn't freeze, and if it does, it
  29449. + reboots your computer after a certain amount of time.
  29450. +
  29451. + To compile this driver as a module, choose M here: the
  29452. + module will be called machzwd.
  29453. +
  29454. +config SBC_EPX_C3_WATCHDOG
  29455. + tristate "Winsystems SBC EPX-C3 watchdog"
  29456. + depends on X86
  29457. + ---help---
  29458. + This is the driver for the built-in watchdog timer on the EPX-C3
  29459. + Single-board computer made by Winsystems, Inc.
  29460. +
  29461. + *Note*: This hardware watchdog is not probeable and thus there
  29462. + is no way to know if writing to its IO address will corrupt
  29463. + your system or have any real effect. The only way to be sure
  29464. + that this driver does what you want is to make sure you
  29465. + are running it on an EPX-C3 from Winsystems with the watchdog
  29466. + timer at IO address 0x1ee and 0x1ef. It will write to both those
  29467. + IO ports. Basically, the assumption is made that if you compile
  29468. + this driver into your kernel and/or load it as a module, that you
  29469. + know what you are doing and that you are in fact running on an
  29470. + EPX-C3 board!
  29471. +
  29472. + To compile this driver as a module, choose M here: the
  29473. + module will be called sbc_epx_c3.
  29474. +
  29475. +# M32R Architecture
  29476. +
  29477. +# M68K Architecture
  29478. +
  29479. +# M68KNOMMU Architecture
  29480. +
  29481. +# MIPS Architecture
  29482. +
  29483. +config BCM47XX_WDT
  29484. + tristate "Broadcom BCM47xx Watchdog Timer"
  29485. + depends on BCM47XX
  29486. + help
  29487. + Hardware driver for the Broadcom BCM47xx Watchog Timer.
  29488. +
  29489. +config RC32434_WDT
  29490. + tristate "IDT RC32434 SoC Watchdog Timer"
  29491. + depends on MIKROTIK_RB532
  29492. + help
  29493. + Hardware driver for the IDT RC32434 SoC built-in
  29494. + watchdog timer.
  29495. +
  29496. + To compile this driver as a module, choose M here: the
  29497. + module will be called rc32434_wdt.
  29498. +
  29499. +config INDYDOG
  29500. + tristate "Indy/I2 Hardware Watchdog"
  29501. + depends on SGI_HAS_INDYDOG
  29502. + help
  29503. + Hardware driver for the Indy's/I2's watchdog. This is a
  29504. + watchdog timer that will reboot the machine after a 60 second
  29505. + timer expired and no process has written to /dev/watchdog during
  29506. + that time.
  29507. +
  29508. +config WDT_MTX1
  29509. + tristate "MTX-1 Hardware Watchdog"
  29510. + depends on MIPS_MTX1
  29511. + help
  29512. + Hardware driver for the MTX-1 boards. This is a watchdog timer that
  29513. + will reboot the machine after a 100 seconds timer expired.
  29514. +
  29515. +config PNX833X_WDT
  29516. + tristate "PNX833x Hardware Watchdog"
  29517. + depends on SOC_PNX8335
  29518. + help
  29519. + Hardware driver for the PNX833x's watchdog. This is a
  29520. + watchdog timer that will reboot the machine after a programable
  29521. + timer has expired and no process has written to /dev/watchdog during
  29522. + that time.
  29523. +
  29524. +config SIBYTE_WDOG
  29525. + tristate "Sibyte SoC hardware watchdog"
  29526. + depends on CPU_SB1
  29527. + help
  29528. + Watchdog driver for the built in watchdog hardware in Sibyte
  29529. + SoC processors. There are apparently two watchdog timers
  29530. + on such processors; this driver supports only the first one,
  29531. + because currently Linux only supports exporting one watchdog
  29532. + to userspace.
  29533. +
  29534. + To compile this driver as a loadable module, choose M here.
  29535. + The module will be called sb_wdog.
  29536. +
  29537. +config AR7_WDT
  29538. + tristate "TI AR7 Watchdog Timer"
  29539. + depends on AR7
  29540. + help
  29541. + Hardware driver for the TI AR7 Watchdog Timer.
  29542. +
  29543. +config TXX9_WDT
  29544. + tristate "Toshiba TXx9 Watchdog Timer"
  29545. + depends on CPU_TX39XX || CPU_TX49XX
  29546. + help
  29547. + Hardware driver for the built-in watchdog timer on TXx9 MIPS SoCs.
  29548. +
  29549. +# PARISC Architecture
  29550. +
  29551. +# POWERPC Architecture
  29552. +
  29553. +config GEF_WDT
  29554. + tristate "GE Watchdog Timer"
  29555. + depends on GEF_SBC610 || GEF_SBC310 || GEF_PPC9A
  29556. + ---help---
  29557. + Watchdog timer found in a number of GE single board computers.
  29558. +
  29559. +config MPC5200_WDT
  29560. + bool "MPC52xx Watchdog Timer"
  29561. + depends on PPC_MPC52xx
  29562. + help
  29563. + Use General Purpose Timer (GPT) 0 on the MPC5200 as Watchdog.
  29564. +
  29565. +config 8xxx_WDT
  29566. + tristate "MPC8xxx Platform Watchdog Timer"
  29567. + depends on PPC_8xx || PPC_83xx || PPC_86xx
  29568. + help
  29569. + This driver is for a SoC level watchdog that exists on some
  29570. + Freescale PowerPC processors. So far this driver supports:
  29571. + - MPC8xx watchdogs
  29572. + - MPC83xx watchdogs
  29573. + - MPC86xx watchdogs
  29574. +
  29575. + For BookE processors (MPC85xx) use the BOOKE_WDT driver instead.
  29576. +
  29577. +config MV64X60_WDT
  29578. + tristate "MV64X60 (Marvell Discovery) Watchdog Timer"
  29579. + depends on MV64X60
  29580. +
  29581. +config PIKA_WDT
  29582. + tristate "PIKA FPGA Watchdog"
  29583. + depends on WARP
  29584. + default y
  29585. + help
  29586. + This enables the watchdog in the PIKA FPGA. Currently used on
  29587. + the Warp platform.
  29588. +
  29589. +config BOOKE_WDT
  29590. + bool "PowerPC Book-E Watchdog Timer"
  29591. + depends on BOOKE || 4xx
  29592. + ---help---
  29593. + Please see Documentation/watchdog/watchdog-api.txt for
  29594. + more information.
  29595. +
  29596. +# PPC64 Architecture
  29597. +
  29598. +config WATCHDOG_RTAS
  29599. + tristate "RTAS watchdog"
  29600. + depends on PPC_RTAS
  29601. + help
  29602. + This driver adds watchdog support for the RTAS watchdog.
  29603. +
  29604. + To compile this driver as a module, choose M here. The module
  29605. + will be called wdrtas.
  29606. +
  29607. +# S390 Architecture
  29608. +
  29609. +config ZVM_WATCHDOG
  29610. + tristate "z/VM Watchdog Timer"
  29611. + depends on S390
  29612. + help
  29613. + IBM s/390 and zSeries machines running under z/VM 5.1 or later
  29614. + provide a virtual watchdog timer to their guest that cause a
  29615. + user define Control Program command to be executed after a
  29616. + timeout.
  29617. +
  29618. + To compile this driver as a module, choose M here. The module
  29619. + will be called vmwatchdog.
  29620. +
  29621. +# SUPERH (sh + sh64) Architecture
  29622. +
  29623. +config SH_WDT
  29624. + tristate "SuperH Watchdog"
  29625. + depends on SUPERH && (CPU_SH3 || CPU_SH4)
  29626. + help
  29627. + This driver adds watchdog support for the integrated watchdog in the
  29628. + SuperH processors. If you have one of these processors and wish
  29629. + to have watchdog support enabled, say Y, otherwise say N.
  29630. +
  29631. + As a side note, saying Y here will automatically boost HZ to 1000
  29632. + so that the timer has a chance to clear the overflow counter. On
  29633. + slower systems (such as the SH-2 and SH-3) this will likely yield
  29634. + some performance issues. As such, the WDT should be avoided here
  29635. + unless it is absolutely necessary.
  29636. +
  29637. + To compile this driver as a module, choose M here: the
  29638. + module will be called shwdt.
  29639. +
  29640. +config SH_WDT_MMAP
  29641. + bool "Allow mmap of SH WDT"
  29642. + default n
  29643. + depends on SH_WDT
  29644. + help
  29645. + If you say Y here, user applications will be able to mmap the
  29646. + WDT/CPG registers.
  29647. +
  29648. +# SPARC Architecture
  29649. +
  29650. +# SPARC64 Architecture
  29651. +
  29652. +config WATCHDOG_CP1XXX
  29653. + tristate "CP1XXX Hardware Watchdog support"
  29654. + depends on SPARC64 && PCI
  29655. + ---help---
  29656. + This is the driver for the hardware watchdog timers present on
  29657. + Sun Microsystems CompactPCI models CP1400 and CP1500.
  29658. +
  29659. + To compile this driver as a module, choose M here: the
  29660. + module will be called cpwatchdog.
  29661. +
  29662. + If you do not have a CompactPCI model CP1400 or CP1500, or
  29663. + another UltraSPARC-IIi-cEngine boardset with hardware watchdog,
  29664. + you should say N to this option.
  29665. +
  29666. +config WATCHDOG_RIO
  29667. + tristate "RIO Hardware Watchdog support"
  29668. + depends on SPARC64 && PCI
  29669. + help
  29670. + Say Y here to support the hardware watchdog capability on Sun RIO
  29671. + machines. The watchdog timeout period is normally one minute but
  29672. + can be changed with a boot-time parameter.
  29673. +
  29674. +# XTENSA Architecture
  29675. +
  29676. +#
  29677. +# ISA-based Watchdog Cards
  29678. +#
  29679. +
  29680. +comment "ISA-based Watchdog Cards"
  29681. + depends on ISA
  29682. +
  29683. +config PCWATCHDOG
  29684. + tristate "Berkshire Products ISA-PC Watchdog"
  29685. + depends on ISA
  29686. + ---help---
  29687. + This is the driver for the Berkshire Products ISA-PC Watchdog card.
  29688. + This card simply watches your kernel to make sure it doesn't freeze,
  29689. + and if it does, it reboots your computer after a certain amount of
  29690. + time. This driver is like the WDT501 driver but for different
  29691. + hardware. Please read <file:Documentation/watchdog/pcwd-watchdog.txt>. The PC
  29692. + watchdog cards can be ordered from <http://www.berkprod.com/>.
  29693. +
  29694. + To compile this driver as a module, choose M here: the
  29695. + module will be called pcwd.
  29696. +
  29697. + Most people will say N.
  29698. +
  29699. +config MIXCOMWD
  29700. + tristate "Mixcom Watchdog"
  29701. + depends on ISA
  29702. + ---help---
  29703. + This is a driver for the Mixcom hardware watchdog cards. This
  29704. + watchdog simply watches your kernel to make sure it doesn't freeze,
  29705. + and if it does, it reboots your computer after a certain amount of
  29706. + time.
  29707. +
  29708. + To compile this driver as a module, choose M here: the
  29709. + module will be called mixcomwd.
  29710. +
  29711. + Most people will say N.
  29712. +
  29713. +config WDT
  29714. + tristate "WDT Watchdog timer"
  29715. + depends on ISA
  29716. + ---help---
  29717. + If you have a WDT500P or WDT501P watchdog board, say Y here,
  29718. + otherwise N. It is not possible to probe for this board, which means
  29719. + that you have to inform the kernel about the IO port and IRQ that
  29720. + is needed (you can do this via the io and irq parameters)
  29721. +
  29722. + To compile this driver as a module, choose M here: the
  29723. + module will be called wdt.
  29724. +
  29725. +#
  29726. +# PCI-based Watchdog Cards
  29727. +#
  29728. +
  29729. +comment "PCI-based Watchdog Cards"
  29730. + depends on PCI
  29731. +
  29732. +config PCIPCWATCHDOG
  29733. + tristate "Berkshire Products PCI-PC Watchdog"
  29734. + depends on PCI
  29735. + ---help---
  29736. + This is the driver for the Berkshire Products PCI-PC Watchdog card.
  29737. + This card simply watches your kernel to make sure it doesn't freeze,
  29738. + and if it does, it reboots your computer after a certain amount of
  29739. + time. The card can also monitor the internal temperature of the PC.
  29740. + More info is available at <http://www.berkprod.com/pci_pc_watchdog.htm>.
  29741. +
  29742. + To compile this driver as a module, choose M here: the
  29743. + module will be called pcwd_pci.
  29744. +
  29745. + Most people will say N.
  29746. +
  29747. +config WDTPCI
  29748. + tristate "PCI-WDT500/501 Watchdog timer"
  29749. + depends on PCI
  29750. + ---help---
  29751. + If you have a PCI-WDT500/501 watchdog board, say Y here, otherwise N.
  29752. +
  29753. + If you have a PCI-WDT501 watchdog board then you can enable the
  29754. + temperature sensor by setting the type parameter to 501.
  29755. +
  29756. + If you want to enable the Fan Tachometer on the PCI-WDT501, then you
  29757. + can do this via the tachometer parameter. Only do this if you have a
  29758. + fan tachometer actually set up.
  29759. +
  29760. + To compile this driver as a module, choose M here: the
  29761. + module will be called wdt_pci.
  29762. +
  29763. +#
  29764. +# USB-based Watchdog Cards
  29765. +#
  29766. +
  29767. +comment "USB-based Watchdog Cards"
  29768. + depends on USB
  29769. +
  29770. +config USBPCWATCHDOG
  29771. + tristate "Berkshire Products USB-PC Watchdog"
  29772. + depends on USB
  29773. + ---help---
  29774. + This is the driver for the Berkshire Products USB-PC Watchdog card.
  29775. + This card simply watches your kernel to make sure it doesn't freeze,
  29776. + and if it does, it reboots your computer after a certain amount of
  29777. + time. The card can also monitor the internal temperature of the PC.
  29778. + More info is available at <http://www.berkprod.com/usb_pc_watchdog.htm>.
  29779. +
  29780. + To compile this driver as a module, choose M here: the
  29781. + module will be called pcwd_usb.
  29782. +
  29783. + Most people will say N.
  29784. +
  29785. +endif # WATCHDOG
  29786. diff -Nur linux-2.6.35.7.orig/drivers/watchdog/Makefile linux-2.6.35.7/drivers/watchdog/Makefile
  29787. --- linux-2.6.35.7.orig/drivers/watchdog/Makefile 2010-09-29 03:09:08.000000000 +0200
  29788. +++ linux-2.6.35.7/drivers/watchdog/Makefile 2010-10-14 20:28:01.588091787 +0200
  29789. @@ -114,6 +114,7 @@
  29790. obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o
  29791. obj-$(CONFIG_AR7_WDT) += ar7_wdt.o
  29792. obj-$(CONFIG_TXX9_WDT) += txx9wdt.o
  29793. +obj-$(CONFIG_AR71XX_WDT) += ar71xx_wdt.o
  29794. # PARISC Architecture
  29795. diff -Nur linux-2.6.35.7.orig/drivers/watchdog/Makefile.orig linux-2.6.35.7/drivers/watchdog/Makefile.orig
  29796. --- linux-2.6.35.7.orig/drivers/watchdog/Makefile.orig 1970-01-01 01:00:00.000000000 +0100
  29797. +++ linux-2.6.35.7/drivers/watchdog/Makefile.orig 2010-09-29 03:09:08.000000000 +0200
  29798. @@ -0,0 +1,148 @@
  29799. +#
  29800. +# Makefile for the WatchDog device drivers.
  29801. +#
  29802. +
  29803. +# Only one watchdog can succeed. We probe the ISA/PCI/USB based
  29804. +# watchdog-cards first, then the architecture specific watchdog
  29805. +# drivers and then the architecture independant "softdog" driver.
  29806. +# This means that if your ISA/PCI/USB card isn't detected that
  29807. +# you can fall back to an architecture specific driver and if
  29808. +# that also fails then you can fall back to the software watchdog
  29809. +# to give you some cover.
  29810. +
  29811. +# ISA-based Watchdog Cards
  29812. +obj-$(CONFIG_PCWATCHDOG) += pcwd.o
  29813. +obj-$(CONFIG_MIXCOMWD) += mixcomwd.o
  29814. +obj-$(CONFIG_WDT) += wdt.o
  29815. +
  29816. +# PCI-based Watchdog Cards
  29817. +obj-$(CONFIG_PCIPCWATCHDOG) += pcwd_pci.o
  29818. +obj-$(CONFIG_WDTPCI) += wdt_pci.o
  29819. +
  29820. +# USB-based Watchdog Cards
  29821. +obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o
  29822. +
  29823. +# ALPHA Architecture
  29824. +
  29825. +# ARM Architecture
  29826. +obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o
  29827. +obj-$(CONFIG_AT91SAM9X_WATCHDOG) += at91sam9_wdt.o
  29828. +obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o
  29829. +obj-$(CONFIG_TWL4030_WATCHDOG) += twl4030_wdt.o
  29830. +obj-$(CONFIG_21285_WATCHDOG) += wdt285.o
  29831. +obj-$(CONFIG_977_WATCHDOG) += wdt977.o
  29832. +obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o
  29833. +obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
  29834. +obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o
  29835. +obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
  29836. +obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
  29837. +obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o
  29838. +obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o
  29839. +obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o
  29840. +obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o
  29841. +obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o
  29842. +obj-$(CONFIG_ORION_WATCHDOG) += orion_wdt.o
  29843. +obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o
  29844. +obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o
  29845. +obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
  29846. +obj-$(CONFIG_ADX_WATCHDOG) += adx_wdt.o
  29847. +obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
  29848. +obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
  29849. +
  29850. +# AVR32 Architecture
  29851. +obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
  29852. +
  29853. +# BLACKFIN Architecture
  29854. +obj-$(CONFIG_BFIN_WDT) += bfin_wdt.o
  29855. +
  29856. +# CRIS Architecture
  29857. +
  29858. +# FRV Architecture
  29859. +
  29860. +# H8300 Architecture
  29861. +
  29862. +# X86 (i386 + ia64 + x86_64) Architecture
  29863. +obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o
  29864. +obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o
  29865. +obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o
  29866. +obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o
  29867. +obj-$(CONFIG_GEODE_WDT) += geodewdt.o
  29868. +obj-$(CONFIG_SC520_WDT) += sc520_wdt.o
  29869. +obj-$(CONFIG_SBC_FITPC2_WATCHDOG) += sbc_fitpc2_wdt.o
  29870. +obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o
  29871. +obj-$(CONFIG_IB700_WDT) += ib700wdt.o
  29872. +obj-$(CONFIG_IBMASR) += ibmasr.o
  29873. +obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o
  29874. +obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o
  29875. +obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o
  29876. +ifeq ($(CONFIG_ITCO_VENDOR_SUPPORT),y)
  29877. +obj-$(CONFIG_ITCO_WDT) += iTCO_vendor_support.o
  29878. +endif
  29879. +obj-$(CONFIG_IT8712F_WDT) += it8712f_wdt.o
  29880. +obj-$(CONFIG_IT87_WDT) += it87_wdt.o
  29881. +obj-$(CONFIG_HP_WATCHDOG) += hpwdt.o
  29882. +obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o
  29883. +obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o
  29884. +obj-$(CONFIG_PC87413_WDT) += pc87413_wdt.o
  29885. +obj-$(CONFIG_RDC321X_WDT) += rdc321x_wdt.o
  29886. +obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o
  29887. +obj-$(CONFIG_SBC8360_WDT) += sbc8360.o
  29888. +obj-$(CONFIG_SBC7240_WDT) += sbc7240_wdt.o
  29889. +obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
  29890. +obj-$(CONFIG_SMSC_SCH311X_WDT) += sch311x_wdt.o
  29891. +obj-$(CONFIG_SMSC37B787_WDT) += smsc37b787_wdt.o
  29892. +obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o
  29893. +obj-$(CONFIG_W83697HF_WDT) += w83697hf_wdt.o
  29894. +obj-$(CONFIG_W83697UG_WDT) += w83697ug_wdt.o
  29895. +obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o
  29896. +obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o
  29897. +obj-$(CONFIG_MACHZ_WDT) += machzwd.o
  29898. +obj-$(CONFIG_SBC_EPX_C3_WATCHDOG) += sbc_epx_c3.o
  29899. +
  29900. +# M32R Architecture
  29901. +
  29902. +# M68K Architecture
  29903. +
  29904. +# M68KNOMMU Architecture
  29905. +
  29906. +# MIPS Architecture
  29907. +obj-$(CONFIG_BCM47XX_WDT) += bcm47xx_wdt.o
  29908. +obj-$(CONFIG_RC32434_WDT) += rc32434_wdt.o
  29909. +obj-$(CONFIG_INDYDOG) += indydog.o
  29910. +obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o
  29911. +obj-$(CONFIG_PNX833X_WDT) += pnx833x_wdt.o
  29912. +obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o
  29913. +obj-$(CONFIG_AR7_WDT) += ar7_wdt.o
  29914. +obj-$(CONFIG_TXX9_WDT) += txx9wdt.o
  29915. +
  29916. +# PARISC Architecture
  29917. +
  29918. +# POWERPC Architecture
  29919. +obj-$(CONFIG_GEF_WDT) += gef_wdt.o
  29920. +obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
  29921. +obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
  29922. +obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
  29923. +obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
  29924. +
  29925. +# PPC64 Architecture
  29926. +obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
  29927. +
  29928. +# S390 Architecture
  29929. +
  29930. +# SUPERH (sh + sh64) Architecture
  29931. +obj-$(CONFIG_SH_WDT) += shwdt.o
  29932. +
  29933. +# SPARC Architecture
  29934. +
  29935. +# SPARC64 Architecture
  29936. +
  29937. +obj-$(CONFIG_WATCHDOG_RIO) += riowd.o
  29938. +obj-$(CONFIG_WATCHDOG_CP1XXX) += cpwd.o
  29939. +
  29940. +# XTENSA Architecture
  29941. +
  29942. +# Architecture Independant
  29943. +obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o
  29944. +obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o
  29945. +obj-$(CONFIG_MAX63XX_WATCHDOG) += max63xx_wdt.o
  29946. +obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
  29947. diff -Nur linux-2.6.35.7.orig/include/linux/ath9k_platform.h linux-2.6.35.7/include/linux/ath9k_platform.h
  29948. --- linux-2.6.35.7.orig/include/linux/ath9k_platform.h 2010-09-29 03:09:08.000000000 +0200
  29949. +++ linux-2.6.35.7/include/linux/ath9k_platform.h 2010-10-14 20:28:01.618101105 +0200
  29950. @@ -1,19 +1,11 @@
  29951. /*
  29952. - * Copyright (c) 2008 Atheros Communications Inc.
  29953. - * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
  29954. - * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org>
  29955. + * ath9k platform data defines
  29956. *
  29957. - * Permission to use, copy, modify, and/or distribute this software for any
  29958. - * purpose with or without fee is hereby granted, provided that the above
  29959. - * copyright notice and this permission notice appear in all copies.
  29960. + * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
  29961. *
  29962. - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  29963. - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  29964. - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  29965. - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  29966. - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  29967. - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  29968. - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  29969. + * This program is free software; you can redistribute it and/or modify it
  29970. + * under the terms of the GNU General Public License version 2 as published
  29971. + * by the Free Software Foundation.
  29972. */
  29973. #ifndef _LINUX_ATH9K_PLATFORM_H
  29974. @@ -23,6 +15,9 @@
  29975. struct ath9k_platform_data {
  29976. u16 eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS];
  29977. + u8 *macaddr;
  29978. +
  29979. + unsigned long quirk_wndr3700:1;
  29980. };
  29981. #endif /* _LINUX_ATH9K_PLATFORM_H */
  29982. diff -Nur linux-2.6.35.7.orig/include/linux/gpio_buttons.h linux-2.6.35.7/include/linux/gpio_buttons.h
  29983. --- linux-2.6.35.7.orig/include/linux/gpio_buttons.h 1970-01-01 01:00:00.000000000 +0100
  29984. +++ linux-2.6.35.7/include/linux/gpio_buttons.h 2010-10-14 20:28:01.679342332 +0200
  29985. @@ -0,0 +1,33 @@
  29986. +/*
  29987. + * Definitions for the GPIO buttons interface driver
  29988. + *
  29989. + * Copyright (C) 2007-2010 Gabor Juhos <juhosg@openwrt.org>
  29990. + *
  29991. + * This file was based on: /include/linux/gpio_keys.h
  29992. + * The original gpio_keys.h seems not to have a license.
  29993. + *
  29994. + * This program is free software; you can redistribute it and/or modify
  29995. + * it under the terms of the GNU General Public License version 2 as
  29996. + * published by the Free Software Foundation.
  29997. + *
  29998. + */
  29999. +
  30000. +#ifndef _GPIO_BUTTONS_H_
  30001. +#define _GPIO_BUTTONS_H_
  30002. +
  30003. +struct gpio_button {
  30004. + int gpio; /* GPIO line number */
  30005. + int active_low;
  30006. + char *desc; /* button description */
  30007. + int type; /* input event type (EV_KEY, EV_SW) */
  30008. + int code; /* input event code (KEY_*, SW_*) */
  30009. + int threshold; /* count threshold */
  30010. +};
  30011. +
  30012. +struct gpio_buttons_platform_data {
  30013. + struct gpio_button *buttons;
  30014. + int nbuttons; /* number of buttons */
  30015. + int poll_interval; /* polling interval */
  30016. +};
  30017. +
  30018. +#endif /* _GPIO_BUTTONS_H_ */
  30019. diff -Nur linux-2.6.35.7.orig/include/linux/gpio_dev.h linux-2.6.35.7/include/linux/gpio_dev.h
  30020. --- linux-2.6.35.7.orig/include/linux/gpio_dev.h 1970-01-01 01:00:00.000000000 +0100
  30021. +++ linux-2.6.35.7/include/linux/gpio_dev.h 2010-10-14 20:28:01.715601023 +0200
  30022. @@ -0,0 +1,11 @@
  30023. +#ifndef _GPIODEV_H__
  30024. +#define _GPIODEV_H__
  30025. +
  30026. +#define IOC_GPIODEV_MAGIC 'B'
  30027. +#define GPIO_GET _IO(IOC_GPIODEV_MAGIC, 10)
  30028. +#define GPIO_SET _IO(IOC_GPIODEV_MAGIC, 11)
  30029. +#define GPIO_CLEAR _IO(IOC_GPIODEV_MAGIC, 12)
  30030. +#define GPIO_DIR_IN _IO(IOC_GPIODEV_MAGIC, 13)
  30031. +#define GPIO_DIR_OUT _IO(IOC_GPIODEV_MAGIC, 14)
  30032. +
  30033. +#endif
  30034. diff -Nur linux-2.6.35.7.orig/include/linux/netdevice.h linux-2.6.35.7/include/linux/netdevice.h
  30035. --- linux-2.6.35.7.orig/include/linux/netdevice.h 2010-09-29 03:09:08.000000000 +0200
  30036. +++ linux-2.6.35.7/include/linux/netdevice.h 2010-10-14 20:28:01.758101230 +0200
  30037. @@ -932,6 +932,7 @@
  30038. void *ax25_ptr; /* AX.25 specific data */
  30039. struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data,
  30040. assign before registering */
  30041. + void *phy_ptr; /* PHY device specific data */
  30042. /*
  30043. * Cache line mostly used on receive path (including eth_type_trans())
  30044. diff -Nur linux-2.6.35.7.orig/include/linux/netdevice.h.orig linux-2.6.35.7/include/linux/netdevice.h.orig
  30045. --- linux-2.6.35.7.orig/include/linux/netdevice.h.orig 1970-01-01 01:00:00.000000000 +0100
  30046. +++ linux-2.6.35.7/include/linux/netdevice.h.orig 2010-09-29 03:09:08.000000000 +0200
  30047. @@ -0,0 +1,2349 @@
  30048. +/*
  30049. + * INET An implementation of the TCP/IP protocol suite for the LINUX
  30050. + * operating system. INET is implemented using the BSD Socket
  30051. + * interface as the means of communication with the user level.
  30052. + *
  30053. + * Definitions for the Interfaces handler.
  30054. + *
  30055. + * Version: @(#)dev.h 1.0.10 08/12/93
  30056. + *
  30057. + * Authors: Ross Biro
  30058. + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  30059. + * Corey Minyard <wf-rch!minyard@relay.EU.net>
  30060. + * Donald J. Becker, <becker@cesdis.gsfc.nasa.gov>
  30061. + * Alan Cox, <alan@lxorguk.ukuu.org.uk>
  30062. + * Bjorn Ekwall. <bj0rn@blox.se>
  30063. + * Pekka Riikonen <priikone@poseidon.pspt.fi>
  30064. + *
  30065. + * This program is free software; you can redistribute it and/or
  30066. + * modify it under the terms of the GNU General Public License
  30067. + * as published by the Free Software Foundation; either version
  30068. + * 2 of the License, or (at your option) any later version.
  30069. + *
  30070. + * Moved to /usr/include/linux for NET3
  30071. + */
  30072. +#ifndef _LINUX_NETDEVICE_H
  30073. +#define _LINUX_NETDEVICE_H
  30074. +
  30075. +#include <linux/if.h>
  30076. +#include <linux/if_ether.h>
  30077. +#include <linux/if_packet.h>
  30078. +#include <linux/if_link.h>
  30079. +
  30080. +#ifdef __KERNEL__
  30081. +#include <linux/pm_qos_params.h>
  30082. +#include <linux/timer.h>
  30083. +#include <linux/delay.h>
  30084. +#include <linux/mm.h>
  30085. +#include <asm/atomic.h>
  30086. +#include <asm/cache.h>
  30087. +#include <asm/byteorder.h>
  30088. +
  30089. +#include <linux/device.h>
  30090. +#include <linux/percpu.h>
  30091. +#include <linux/rculist.h>
  30092. +#include <linux/dmaengine.h>
  30093. +#include <linux/workqueue.h>
  30094. +
  30095. +#include <linux/ethtool.h>
  30096. +#include <net/net_namespace.h>
  30097. +#include <net/dsa.h>
  30098. +#ifdef CONFIG_DCB
  30099. +#include <net/dcbnl.h>
  30100. +#endif
  30101. +
  30102. +struct vlan_group;
  30103. +struct netpoll_info;
  30104. +/* 802.11 specific */
  30105. +struct wireless_dev;
  30106. + /* source back-compat hooks */
  30107. +#define SET_ETHTOOL_OPS(netdev,ops) \
  30108. + ( (netdev)->ethtool_ops = (ops) )
  30109. +
  30110. +#define HAVE_ALLOC_NETDEV /* feature macro: alloc_xxxdev
  30111. + functions are available. */
  30112. +#define HAVE_FREE_NETDEV /* free_netdev() */
  30113. +#define HAVE_NETDEV_PRIV /* netdev_priv() */
  30114. +
  30115. +/* Backlog congestion levels */
  30116. +#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */
  30117. +#define NET_RX_DROP 1 /* packet dropped */
  30118. +
  30119. +/*
  30120. + * Transmit return codes: transmit return codes originate from three different
  30121. + * namespaces:
  30122. + *
  30123. + * - qdisc return codes
  30124. + * - driver transmit return codes
  30125. + * - errno values
  30126. + *
  30127. + * Drivers are allowed to return any one of those in their hard_start_xmit()
  30128. + * function. Real network devices commonly used with qdiscs should only return
  30129. + * the driver transmit return codes though - when qdiscs are used, the actual
  30130. + * transmission happens asynchronously, so the value is not propagated to
  30131. + * higher layers. Virtual network devices transmit synchronously, in this case
  30132. + * the driver transmit return codes are consumed by dev_queue_xmit(), all
  30133. + * others are propagated to higher layers.
  30134. + */
  30135. +
  30136. +/* qdisc ->enqueue() return codes. */
  30137. +#define NET_XMIT_SUCCESS 0x00
  30138. +#define NET_XMIT_DROP 0x01 /* skb dropped */
  30139. +#define NET_XMIT_CN 0x02 /* congestion notification */
  30140. +#define NET_XMIT_POLICED 0x03 /* skb is shot by police */
  30141. +#define NET_XMIT_MASK 0x0f /* qdisc flags in net/sch_generic.h */
  30142. +
  30143. +/* NET_XMIT_CN is special. It does not guarantee that this packet is lost. It
  30144. + * indicates that the device will soon be dropping packets, or already drops
  30145. + * some packets of the same priority; prompting us to send less aggressively. */
  30146. +#define net_xmit_eval(e) ((e) == NET_XMIT_CN ? 0 : (e))
  30147. +#define net_xmit_errno(e) ((e) != NET_XMIT_CN ? -ENOBUFS : 0)
  30148. +
  30149. +/* Driver transmit return codes */
  30150. +#define NETDEV_TX_MASK 0xf0
  30151. +
  30152. +enum netdev_tx {
  30153. + __NETDEV_TX_MIN = INT_MIN, /* make sure enum is signed */
  30154. + NETDEV_TX_OK = 0x00, /* driver took care of packet */
  30155. + NETDEV_TX_BUSY = 0x10, /* driver tx path was busy*/
  30156. + NETDEV_TX_LOCKED = 0x20, /* driver tx lock was already taken */
  30157. +};
  30158. +typedef enum netdev_tx netdev_tx_t;
  30159. +
  30160. +/*
  30161. + * Current order: NETDEV_TX_MASK > NET_XMIT_MASK >= 0 is significant;
  30162. + * hard_start_xmit() return < NET_XMIT_MASK means skb was consumed.
  30163. + */
  30164. +static inline bool dev_xmit_complete(int rc)
  30165. +{
  30166. + /*
  30167. + * Positive cases with an skb consumed by a driver:
  30168. + * - successful transmission (rc == NETDEV_TX_OK)
  30169. + * - error while transmitting (rc < 0)
  30170. + * - error while queueing to a different device (rc & NET_XMIT_MASK)
  30171. + */
  30172. + if (likely(rc < NET_XMIT_MASK))
  30173. + return true;
  30174. +
  30175. + return false;
  30176. +}
  30177. +
  30178. +#endif
  30179. +
  30180. +#define MAX_ADDR_LEN 32 /* Largest hardware address length */
  30181. +
  30182. +#ifdef __KERNEL__
  30183. +/*
  30184. + * Compute the worst case header length according to the protocols
  30185. + * used.
  30186. + */
  30187. +
  30188. +#if defined(CONFIG_WLAN) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
  30189. +# if defined(CONFIG_MAC80211_MESH)
  30190. +# define LL_MAX_HEADER 128
  30191. +# else
  30192. +# define LL_MAX_HEADER 96
  30193. +# endif
  30194. +#elif defined(CONFIG_TR) || defined(CONFIG_TR_MODULE)
  30195. +# define LL_MAX_HEADER 48
  30196. +#else
  30197. +# define LL_MAX_HEADER 32
  30198. +#endif
  30199. +
  30200. +#if !defined(CONFIG_NET_IPIP) && !defined(CONFIG_NET_IPIP_MODULE) && \
  30201. + !defined(CONFIG_NET_IPGRE) && !defined(CONFIG_NET_IPGRE_MODULE) && \
  30202. + !defined(CONFIG_IPV6_SIT) && !defined(CONFIG_IPV6_SIT_MODULE) && \
  30203. + !defined(CONFIG_IPV6_TUNNEL) && !defined(CONFIG_IPV6_TUNNEL_MODULE)
  30204. +#define MAX_HEADER LL_MAX_HEADER
  30205. +#else
  30206. +#define MAX_HEADER (LL_MAX_HEADER + 48)
  30207. +#endif
  30208. +
  30209. +#endif /* __KERNEL__ */
  30210. +
  30211. +/*
  30212. + * Network device statistics. Akin to the 2.0 ether stats but
  30213. + * with byte counters.
  30214. + */
  30215. +
  30216. +struct net_device_stats {
  30217. + unsigned long rx_packets; /* total packets received */
  30218. + unsigned long tx_packets; /* total packets transmitted */
  30219. + unsigned long rx_bytes; /* total bytes received */
  30220. + unsigned long tx_bytes; /* total bytes transmitted */
  30221. + unsigned long rx_errors; /* bad packets received */
  30222. + unsigned long tx_errors; /* packet transmit problems */
  30223. + unsigned long rx_dropped; /* no space in linux buffers */
  30224. + unsigned long tx_dropped; /* no space available in linux */
  30225. + unsigned long multicast; /* multicast packets received */
  30226. + unsigned long collisions;
  30227. +
  30228. + /* detailed rx_errors: */
  30229. + unsigned long rx_length_errors;
  30230. + unsigned long rx_over_errors; /* receiver ring buff overflow */
  30231. + unsigned long rx_crc_errors; /* recved pkt with crc error */
  30232. + unsigned long rx_frame_errors; /* recv'd frame alignment error */
  30233. + unsigned long rx_fifo_errors; /* recv'r fifo overrun */
  30234. + unsigned long rx_missed_errors; /* receiver missed packet */
  30235. +
  30236. + /* detailed tx_errors */
  30237. + unsigned long tx_aborted_errors;
  30238. + unsigned long tx_carrier_errors;
  30239. + unsigned long tx_fifo_errors;
  30240. + unsigned long tx_heartbeat_errors;
  30241. + unsigned long tx_window_errors;
  30242. +
  30243. + /* for cslip etc */
  30244. + unsigned long rx_compressed;
  30245. + unsigned long tx_compressed;
  30246. +};
  30247. +
  30248. +
  30249. +/* Media selection options. */
  30250. +enum {
  30251. + IF_PORT_UNKNOWN = 0,
  30252. + IF_PORT_10BASE2,
  30253. + IF_PORT_10BASET,
  30254. + IF_PORT_AUI,
  30255. + IF_PORT_100BASET,
  30256. + IF_PORT_100BASETX,
  30257. + IF_PORT_100BASEFX
  30258. +};
  30259. +
  30260. +#ifdef __KERNEL__
  30261. +
  30262. +#include <linux/cache.h>
  30263. +#include <linux/skbuff.h>
  30264. +
  30265. +struct neighbour;
  30266. +struct neigh_parms;
  30267. +struct sk_buff;
  30268. +
  30269. +struct netdev_hw_addr {
  30270. + struct list_head list;
  30271. + unsigned char addr[MAX_ADDR_LEN];
  30272. + unsigned char type;
  30273. +#define NETDEV_HW_ADDR_T_LAN 1
  30274. +#define NETDEV_HW_ADDR_T_SAN 2
  30275. +#define NETDEV_HW_ADDR_T_SLAVE 3
  30276. +#define NETDEV_HW_ADDR_T_UNICAST 4
  30277. +#define NETDEV_HW_ADDR_T_MULTICAST 5
  30278. + int refcount;
  30279. + bool synced;
  30280. + bool global_use;
  30281. + struct rcu_head rcu_head;
  30282. +};
  30283. +
  30284. +struct netdev_hw_addr_list {
  30285. + struct list_head list;
  30286. + int count;
  30287. +};
  30288. +
  30289. +#define netdev_hw_addr_list_count(l) ((l)->count)
  30290. +#define netdev_hw_addr_list_empty(l) (netdev_hw_addr_list_count(l) == 0)
  30291. +#define netdev_hw_addr_list_for_each(ha, l) \
  30292. + list_for_each_entry(ha, &(l)->list, list)
  30293. +
  30294. +#define netdev_uc_count(dev) netdev_hw_addr_list_count(&(dev)->uc)
  30295. +#define netdev_uc_empty(dev) netdev_hw_addr_list_empty(&(dev)->uc)
  30296. +#define netdev_for_each_uc_addr(ha, dev) \
  30297. + netdev_hw_addr_list_for_each(ha, &(dev)->uc)
  30298. +
  30299. +#define netdev_mc_count(dev) netdev_hw_addr_list_count(&(dev)->mc)
  30300. +#define netdev_mc_empty(dev) netdev_hw_addr_list_empty(&(dev)->mc)
  30301. +#define netdev_for_each_mc_addr(ha, dev) \
  30302. + netdev_hw_addr_list_for_each(ha, &(dev)->mc)
  30303. +
  30304. +struct hh_cache {
  30305. + struct hh_cache *hh_next; /* Next entry */
  30306. + atomic_t hh_refcnt; /* number of users */
  30307. +/*
  30308. + * We want hh_output, hh_len, hh_lock and hh_data be a in a separate
  30309. + * cache line on SMP.
  30310. + * They are mostly read, but hh_refcnt may be changed quite frequently,
  30311. + * incurring cache line ping pongs.
  30312. + */
  30313. + __be16 hh_type ____cacheline_aligned_in_smp;
  30314. + /* protocol identifier, f.e ETH_P_IP
  30315. + * NOTE: For VLANs, this will be the
  30316. + * encapuslated type. --BLG
  30317. + */
  30318. + u16 hh_len; /* length of header */
  30319. + int (*hh_output)(struct sk_buff *skb);
  30320. + seqlock_t hh_lock;
  30321. +
  30322. + /* cached hardware header; allow for machine alignment needs. */
  30323. +#define HH_DATA_MOD 16
  30324. +#define HH_DATA_OFF(__len) \
  30325. + (HH_DATA_MOD - (((__len - 1) & (HH_DATA_MOD - 1)) + 1))
  30326. +#define HH_DATA_ALIGN(__len) \
  30327. + (((__len)+(HH_DATA_MOD-1))&~(HH_DATA_MOD - 1))
  30328. + unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)];
  30329. +};
  30330. +
  30331. +/* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much.
  30332. + * Alternative is:
  30333. + * dev->hard_header_len ? (dev->hard_header_len +
  30334. + * (HH_DATA_MOD - 1)) & ~(HH_DATA_MOD - 1) : 0
  30335. + *
  30336. + * We could use other alignment values, but we must maintain the
  30337. + * relationship HH alignment <= LL alignment.
  30338. + *
  30339. + * LL_ALLOCATED_SPACE also takes into account the tailroom the device
  30340. + * may need.
  30341. + */
  30342. +#define LL_RESERVED_SPACE(dev) \
  30343. + ((((dev)->hard_header_len+(dev)->needed_headroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
  30344. +#define LL_RESERVED_SPACE_EXTRA(dev,extra) \
  30345. + ((((dev)->hard_header_len+(dev)->needed_headroom+(extra))&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
  30346. +#define LL_ALLOCATED_SPACE(dev) \
  30347. + ((((dev)->hard_header_len+(dev)->needed_headroom+(dev)->needed_tailroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
  30348. +
  30349. +struct header_ops {
  30350. + int (*create) (struct sk_buff *skb, struct net_device *dev,
  30351. + unsigned short type, const void *daddr,
  30352. + const void *saddr, unsigned len);
  30353. + int (*parse)(const struct sk_buff *skb, unsigned char *haddr);
  30354. + int (*rebuild)(struct sk_buff *skb);
  30355. +#define HAVE_HEADER_CACHE
  30356. + int (*cache)(const struct neighbour *neigh, struct hh_cache *hh);
  30357. + void (*cache_update)(struct hh_cache *hh,
  30358. + const struct net_device *dev,
  30359. + const unsigned char *haddr);
  30360. +};
  30361. +
  30362. +/* These flag bits are private to the generic network queueing
  30363. + * layer, they may not be explicitly referenced by any other
  30364. + * code.
  30365. + */
  30366. +
  30367. +enum netdev_state_t {
  30368. + __LINK_STATE_START,
  30369. + __LINK_STATE_PRESENT,
  30370. + __LINK_STATE_NOCARRIER,
  30371. + __LINK_STATE_LINKWATCH_PENDING,
  30372. + __LINK_STATE_DORMANT,
  30373. +};
  30374. +
  30375. +
  30376. +/*
  30377. + * This structure holds at boot time configured netdevice settings. They
  30378. + * are then used in the device probing.
  30379. + */
  30380. +struct netdev_boot_setup {
  30381. + char name[IFNAMSIZ];
  30382. + struct ifmap map;
  30383. +};
  30384. +#define NETDEV_BOOT_SETUP_MAX 8
  30385. +
  30386. +extern int __init netdev_boot_setup(char *str);
  30387. +
  30388. +/*
  30389. + * Structure for NAPI scheduling similar to tasklet but with weighting
  30390. + */
  30391. +struct napi_struct {
  30392. + /* The poll_list must only be managed by the entity which
  30393. + * changes the state of the NAPI_STATE_SCHED bit. This means
  30394. + * whoever atomically sets that bit can add this napi_struct
  30395. + * to the per-cpu poll_list, and whoever clears that bit
  30396. + * can remove from the list right before clearing the bit.
  30397. + */
  30398. + struct list_head poll_list;
  30399. +
  30400. + unsigned long state;
  30401. + int weight;
  30402. + int (*poll)(struct napi_struct *, int);
  30403. +#ifdef CONFIG_NETPOLL
  30404. + spinlock_t poll_lock;
  30405. + int poll_owner;
  30406. +#endif
  30407. +
  30408. + unsigned int gro_count;
  30409. +
  30410. + struct net_device *dev;
  30411. + struct list_head dev_list;
  30412. + struct sk_buff *gro_list;
  30413. + struct sk_buff *skb;
  30414. +};
  30415. +
  30416. +enum {
  30417. + NAPI_STATE_SCHED, /* Poll is scheduled */
  30418. + NAPI_STATE_DISABLE, /* Disable pending */
  30419. + NAPI_STATE_NPSVC, /* Netpoll - don't dequeue from poll_list */
  30420. +};
  30421. +
  30422. +enum gro_result {
  30423. + GRO_MERGED,
  30424. + GRO_MERGED_FREE,
  30425. + GRO_HELD,
  30426. + GRO_NORMAL,
  30427. + GRO_DROP,
  30428. +};
  30429. +typedef enum gro_result gro_result_t;
  30430. +
  30431. +extern void __napi_schedule(struct napi_struct *n);
  30432. +
  30433. +static inline int napi_disable_pending(struct napi_struct *n)
  30434. +{
  30435. + return test_bit(NAPI_STATE_DISABLE, &n->state);
  30436. +}
  30437. +
  30438. +/**
  30439. + * napi_schedule_prep - check if napi can be scheduled
  30440. + * @n: napi context
  30441. + *
  30442. + * Test if NAPI routine is already running, and if not mark
  30443. + * it as running. This is used as a condition variable
  30444. + * insure only one NAPI poll instance runs. We also make
  30445. + * sure there is no pending NAPI disable.
  30446. + */
  30447. +static inline int napi_schedule_prep(struct napi_struct *n)
  30448. +{
  30449. + return !napi_disable_pending(n) &&
  30450. + !test_and_set_bit(NAPI_STATE_SCHED, &n->state);
  30451. +}
  30452. +
  30453. +/**
  30454. + * napi_schedule - schedule NAPI poll
  30455. + * @n: napi context
  30456. + *
  30457. + * Schedule NAPI poll routine to be called if it is not already
  30458. + * running.
  30459. + */
  30460. +static inline void napi_schedule(struct napi_struct *n)
  30461. +{
  30462. + if (napi_schedule_prep(n))
  30463. + __napi_schedule(n);
  30464. +}
  30465. +
  30466. +/* Try to reschedule poll. Called by dev->poll() after napi_complete(). */
  30467. +static inline int napi_reschedule(struct napi_struct *napi)
  30468. +{
  30469. + if (napi_schedule_prep(napi)) {
  30470. + __napi_schedule(napi);
  30471. + return 1;
  30472. + }
  30473. + return 0;
  30474. +}
  30475. +
  30476. +/**
  30477. + * napi_complete - NAPI processing complete
  30478. + * @n: napi context
  30479. + *
  30480. + * Mark NAPI processing as complete.
  30481. + */
  30482. +extern void __napi_complete(struct napi_struct *n);
  30483. +extern void napi_complete(struct napi_struct *n);
  30484. +
  30485. +/**
  30486. + * napi_disable - prevent NAPI from scheduling
  30487. + * @n: napi context
  30488. + *
  30489. + * Stop NAPI from being scheduled on this context.
  30490. + * Waits till any outstanding processing completes.
  30491. + */
  30492. +static inline void napi_disable(struct napi_struct *n)
  30493. +{
  30494. + set_bit(NAPI_STATE_DISABLE, &n->state);
  30495. + while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
  30496. + msleep(1);
  30497. + clear_bit(NAPI_STATE_DISABLE, &n->state);
  30498. +}
  30499. +
  30500. +/**
  30501. + * napi_enable - enable NAPI scheduling
  30502. + * @n: napi context
  30503. + *
  30504. + * Resume NAPI from being scheduled on this context.
  30505. + * Must be paired with napi_disable.
  30506. + */
  30507. +static inline void napi_enable(struct napi_struct *n)
  30508. +{
  30509. + BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state));
  30510. + smp_mb__before_clear_bit();
  30511. + clear_bit(NAPI_STATE_SCHED, &n->state);
  30512. +}
  30513. +
  30514. +#ifdef CONFIG_SMP
  30515. +/**
  30516. + * napi_synchronize - wait until NAPI is not running
  30517. + * @n: napi context
  30518. + *
  30519. + * Wait until NAPI is done being scheduled on this context.
  30520. + * Waits till any outstanding processing completes but
  30521. + * does not disable future activations.
  30522. + */
  30523. +static inline void napi_synchronize(const struct napi_struct *n)
  30524. +{
  30525. + while (test_bit(NAPI_STATE_SCHED, &n->state))
  30526. + msleep(1);
  30527. +}
  30528. +#else
  30529. +# define napi_synchronize(n) barrier()
  30530. +#endif
  30531. +
  30532. +enum netdev_queue_state_t {
  30533. + __QUEUE_STATE_XOFF,
  30534. + __QUEUE_STATE_FROZEN,
  30535. +};
  30536. +
  30537. +struct netdev_queue {
  30538. +/*
  30539. + * read mostly part
  30540. + */
  30541. + struct net_device *dev;
  30542. + struct Qdisc *qdisc;
  30543. + unsigned long state;
  30544. + struct Qdisc *qdisc_sleeping;
  30545. +/*
  30546. + * write mostly part
  30547. + */
  30548. + spinlock_t _xmit_lock ____cacheline_aligned_in_smp;
  30549. + int xmit_lock_owner;
  30550. + /*
  30551. + * please use this field instead of dev->trans_start
  30552. + */
  30553. + unsigned long trans_start;
  30554. + unsigned long tx_bytes;
  30555. + unsigned long tx_packets;
  30556. + unsigned long tx_dropped;
  30557. +} ____cacheline_aligned_in_smp;
  30558. +
  30559. +#ifdef CONFIG_RPS
  30560. +/*
  30561. + * This structure holds an RPS map which can be of variable length. The
  30562. + * map is an array of CPUs.
  30563. + */
  30564. +struct rps_map {
  30565. + unsigned int len;
  30566. + struct rcu_head rcu;
  30567. + u16 cpus[0];
  30568. +};
  30569. +#define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + (_num * sizeof(u16)))
  30570. +
  30571. +/*
  30572. + * The rps_dev_flow structure contains the mapping of a flow to a CPU and the
  30573. + * tail pointer for that CPU's input queue at the time of last enqueue.
  30574. + */
  30575. +struct rps_dev_flow {
  30576. + u16 cpu;
  30577. + u16 fill;
  30578. + unsigned int last_qtail;
  30579. +};
  30580. +
  30581. +/*
  30582. + * The rps_dev_flow_table structure contains a table of flow mappings.
  30583. + */
  30584. +struct rps_dev_flow_table {
  30585. + unsigned int mask;
  30586. + struct rcu_head rcu;
  30587. + struct work_struct free_work;
  30588. + struct rps_dev_flow flows[0];
  30589. +};
  30590. +#define RPS_DEV_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_dev_flow_table) + \
  30591. + (_num * sizeof(struct rps_dev_flow)))
  30592. +
  30593. +/*
  30594. + * The rps_sock_flow_table contains mappings of flows to the last CPU
  30595. + * on which they were processed by the application (set in recvmsg).
  30596. + */
  30597. +struct rps_sock_flow_table {
  30598. + unsigned int mask;
  30599. + u16 ents[0];
  30600. +};
  30601. +#define RPS_SOCK_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_sock_flow_table) + \
  30602. + (_num * sizeof(u16)))
  30603. +
  30604. +#define RPS_NO_CPU 0xffff
  30605. +
  30606. +static inline void rps_record_sock_flow(struct rps_sock_flow_table *table,
  30607. + u32 hash)
  30608. +{
  30609. + if (table && hash) {
  30610. + unsigned int cpu, index = hash & table->mask;
  30611. +
  30612. + /* We only give a hint, preemption can change cpu under us */
  30613. + cpu = raw_smp_processor_id();
  30614. +
  30615. + if (table->ents[index] != cpu)
  30616. + table->ents[index] = cpu;
  30617. + }
  30618. +}
  30619. +
  30620. +static inline void rps_reset_sock_flow(struct rps_sock_flow_table *table,
  30621. + u32 hash)
  30622. +{
  30623. + if (table && hash)
  30624. + table->ents[hash & table->mask] = RPS_NO_CPU;
  30625. +}
  30626. +
  30627. +extern struct rps_sock_flow_table *rps_sock_flow_table;
  30628. +
  30629. +/* This structure contains an instance of an RX queue. */
  30630. +struct netdev_rx_queue {
  30631. + struct rps_map *rps_map;
  30632. + struct rps_dev_flow_table *rps_flow_table;
  30633. + struct kobject kobj;
  30634. + struct netdev_rx_queue *first;
  30635. + atomic_t count;
  30636. +} ____cacheline_aligned_in_smp;
  30637. +#endif /* CONFIG_RPS */
  30638. +
  30639. +/*
  30640. + * This structure defines the management hooks for network devices.
  30641. + * The following hooks can be defined; unless noted otherwise, they are
  30642. + * optional and can be filled with a null pointer.
  30643. + *
  30644. + * int (*ndo_init)(struct net_device *dev);
  30645. + * This function is called once when network device is registered.
  30646. + * The network device can use this to any late stage initializaton
  30647. + * or semantic validattion. It can fail with an error code which will
  30648. + * be propogated back to register_netdev
  30649. + *
  30650. + * void (*ndo_uninit)(struct net_device *dev);
  30651. + * This function is called when device is unregistered or when registration
  30652. + * fails. It is not called if init fails.
  30653. + *
  30654. + * int (*ndo_open)(struct net_device *dev);
  30655. + * This function is called when network device transistions to the up
  30656. + * state.
  30657. + *
  30658. + * int (*ndo_stop)(struct net_device *dev);
  30659. + * This function is called when network device transistions to the down
  30660. + * state.
  30661. + *
  30662. + * netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb,
  30663. + * struct net_device *dev);
  30664. + * Called when a packet needs to be transmitted.
  30665. + * Must return NETDEV_TX_OK , NETDEV_TX_BUSY.
  30666. + * (can also return NETDEV_TX_LOCKED iff NETIF_F_LLTX)
  30667. + * Required can not be NULL.
  30668. + *
  30669. + * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb);
  30670. + * Called to decide which queue to when device supports multiple
  30671. + * transmit queues.
  30672. + *
  30673. + * void (*ndo_change_rx_flags)(struct net_device *dev, int flags);
  30674. + * This function is called to allow device receiver to make
  30675. + * changes to configuration when multicast or promiscious is enabled.
  30676. + *
  30677. + * void (*ndo_set_rx_mode)(struct net_device *dev);
  30678. + * This function is called device changes address list filtering.
  30679. + *
  30680. + * void (*ndo_set_multicast_list)(struct net_device *dev);
  30681. + * This function is called when the multicast address list changes.
  30682. + *
  30683. + * int (*ndo_set_mac_address)(struct net_device *dev, void *addr);
  30684. + * This function is called when the Media Access Control address
  30685. + * needs to be changed. If this interface is not defined, the
  30686. + * mac address can not be changed.
  30687. + *
  30688. + * int (*ndo_validate_addr)(struct net_device *dev);
  30689. + * Test if Media Access Control address is valid for the device.
  30690. + *
  30691. + * int (*ndo_do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd);
  30692. + * Called when a user request an ioctl which can't be handled by
  30693. + * the generic interface code. If not defined ioctl's return
  30694. + * not supported error code.
  30695. + *
  30696. + * int (*ndo_set_config)(struct net_device *dev, struct ifmap *map);
  30697. + * Used to set network devices bus interface parameters. This interface
  30698. + * is retained for legacy reason, new devices should use the bus
  30699. + * interface (PCI) for low level management.
  30700. + *
  30701. + * int (*ndo_change_mtu)(struct net_device *dev, int new_mtu);
  30702. + * Called when a user wants to change the Maximum Transfer Unit
  30703. + * of a device. If not defined, any request to change MTU will
  30704. + * will return an error.
  30705. + *
  30706. + * void (*ndo_tx_timeout)(struct net_device *dev);
  30707. + * Callback uses when the transmitter has not made any progress
  30708. + * for dev->watchdog ticks.
  30709. + *
  30710. + * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
  30711. + * Called when a user wants to get the network device usage
  30712. + * statistics. If not defined, the counters in dev->stats will
  30713. + * be used.
  30714. + *
  30715. + * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp);
  30716. + * If device support VLAN receive accleration
  30717. + * (ie. dev->features & NETIF_F_HW_VLAN_RX), then this function is called
  30718. + * when vlan groups for the device changes. Note: grp is NULL
  30719. + * if no vlan's groups are being used.
  30720. + *
  30721. + * void (*ndo_vlan_rx_add_vid)(struct net_device *dev, unsigned short vid);
  30722. + * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER)
  30723. + * this function is called when a VLAN id is registered.
  30724. + *
  30725. + * void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid);
  30726. + * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER)
  30727. + * this function is called when a VLAN id is unregistered.
  30728. + *
  30729. + * void (*ndo_poll_controller)(struct net_device *dev);
  30730. + *
  30731. + * SR-IOV management functions.
  30732. + * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac);
  30733. + * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos);
  30734. + * int (*ndo_set_vf_tx_rate)(struct net_device *dev, int vf, int rate);
  30735. + * int (*ndo_get_vf_config)(struct net_device *dev,
  30736. + * int vf, struct ifla_vf_info *ivf);
  30737. + * int (*ndo_set_vf_port)(struct net_device *dev, int vf,
  30738. + * struct nlattr *port[]);
  30739. + * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb);
  30740. + */
  30741. +#define HAVE_NET_DEVICE_OPS
  30742. +struct net_device_ops {
  30743. + int (*ndo_init)(struct net_device *dev);
  30744. + void (*ndo_uninit)(struct net_device *dev);
  30745. + int (*ndo_open)(struct net_device *dev);
  30746. + int (*ndo_stop)(struct net_device *dev);
  30747. + netdev_tx_t (*ndo_start_xmit) (struct sk_buff *skb,
  30748. + struct net_device *dev);
  30749. + u16 (*ndo_select_queue)(struct net_device *dev,
  30750. + struct sk_buff *skb);
  30751. + void (*ndo_change_rx_flags)(struct net_device *dev,
  30752. + int flags);
  30753. + void (*ndo_set_rx_mode)(struct net_device *dev);
  30754. + void (*ndo_set_multicast_list)(struct net_device *dev);
  30755. + int (*ndo_set_mac_address)(struct net_device *dev,
  30756. + void *addr);
  30757. + int (*ndo_validate_addr)(struct net_device *dev);
  30758. + int (*ndo_do_ioctl)(struct net_device *dev,
  30759. + struct ifreq *ifr, int cmd);
  30760. + int (*ndo_set_config)(struct net_device *dev,
  30761. + struct ifmap *map);
  30762. + int (*ndo_change_mtu)(struct net_device *dev,
  30763. + int new_mtu);
  30764. + int (*ndo_neigh_setup)(struct net_device *dev,
  30765. + struct neigh_parms *);
  30766. + void (*ndo_tx_timeout) (struct net_device *dev);
  30767. +
  30768. + struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
  30769. +
  30770. + void (*ndo_vlan_rx_register)(struct net_device *dev,
  30771. + struct vlan_group *grp);
  30772. + void (*ndo_vlan_rx_add_vid)(struct net_device *dev,
  30773. + unsigned short vid);
  30774. + void (*ndo_vlan_rx_kill_vid)(struct net_device *dev,
  30775. + unsigned short vid);
  30776. +#ifdef CONFIG_NET_POLL_CONTROLLER
  30777. + void (*ndo_poll_controller)(struct net_device *dev);
  30778. + void (*ndo_netpoll_cleanup)(struct net_device *dev);
  30779. +#endif
  30780. + int (*ndo_set_vf_mac)(struct net_device *dev,
  30781. + int queue, u8 *mac);
  30782. + int (*ndo_set_vf_vlan)(struct net_device *dev,
  30783. + int queue, u16 vlan, u8 qos);
  30784. + int (*ndo_set_vf_tx_rate)(struct net_device *dev,
  30785. + int vf, int rate);
  30786. + int (*ndo_get_vf_config)(struct net_device *dev,
  30787. + int vf,
  30788. + struct ifla_vf_info *ivf);
  30789. + int (*ndo_set_vf_port)(struct net_device *dev,
  30790. + int vf,
  30791. + struct nlattr *port[]);
  30792. + int (*ndo_get_vf_port)(struct net_device *dev,
  30793. + int vf, struct sk_buff *skb);
  30794. +#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
  30795. + int (*ndo_fcoe_enable)(struct net_device *dev);
  30796. + int (*ndo_fcoe_disable)(struct net_device *dev);
  30797. + int (*ndo_fcoe_ddp_setup)(struct net_device *dev,
  30798. + u16 xid,
  30799. + struct scatterlist *sgl,
  30800. + unsigned int sgc);
  30801. + int (*ndo_fcoe_ddp_done)(struct net_device *dev,
  30802. + u16 xid);
  30803. +#define NETDEV_FCOE_WWNN 0
  30804. +#define NETDEV_FCOE_WWPN 1
  30805. + int (*ndo_fcoe_get_wwn)(struct net_device *dev,
  30806. + u64 *wwn, int type);
  30807. +#endif
  30808. +};
  30809. +
  30810. +/*
  30811. + * The DEVICE structure.
  30812. + * Actually, this whole structure is a big mistake. It mixes I/O
  30813. + * data with strictly "high-level" data, and it has to know about
  30814. + * almost every data structure used in the INET module.
  30815. + *
  30816. + * FIXME: cleanup struct net_device such that network protocol info
  30817. + * moves out.
  30818. + */
  30819. +
  30820. +struct net_device {
  30821. +
  30822. + /*
  30823. + * This is the first field of the "visible" part of this structure
  30824. + * (i.e. as seen by users in the "Space.c" file). It is the name
  30825. + * the interface.
  30826. + */
  30827. + char name[IFNAMSIZ];
  30828. +
  30829. + struct pm_qos_request_list *pm_qos_req;
  30830. +
  30831. + /* device name hash chain */
  30832. + struct hlist_node name_hlist;
  30833. + /* snmp alias */
  30834. + char *ifalias;
  30835. +
  30836. + /*
  30837. + * I/O specific fields
  30838. + * FIXME: Merge these and struct ifmap into one
  30839. + */
  30840. + unsigned long mem_end; /* shared mem end */
  30841. + unsigned long mem_start; /* shared mem start */
  30842. + unsigned long base_addr; /* device I/O address */
  30843. + unsigned int irq; /* device IRQ number */
  30844. +
  30845. + /*
  30846. + * Some hardware also needs these fields, but they are not
  30847. + * part of the usual set specified in Space.c.
  30848. + */
  30849. +
  30850. + unsigned char if_port; /* Selectable AUI, TP,..*/
  30851. + unsigned char dma; /* DMA channel */
  30852. +
  30853. + unsigned long state;
  30854. +
  30855. + struct list_head dev_list;
  30856. + struct list_head napi_list;
  30857. + struct list_head unreg_list;
  30858. +
  30859. + /* Net device features */
  30860. + unsigned long features;
  30861. +#define NETIF_F_SG 1 /* Scatter/gather IO. */
  30862. +#define NETIF_F_IP_CSUM 2 /* Can checksum TCP/UDP over IPv4. */
  30863. +#define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */
  30864. +#define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */
  30865. +#define NETIF_F_IPV6_CSUM 16 /* Can checksum TCP/UDP over IPV6 */
  30866. +#define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */
  30867. +#define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */
  30868. +#define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */
  30869. +#define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */
  30870. +#define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */
  30871. +#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
  30872. +#define NETIF_F_GSO 2048 /* Enable software GSO. */
  30873. +#define NETIF_F_LLTX 4096 /* LockLess TX - deprecated. Please */
  30874. + /* do not use LLTX in new drivers */
  30875. +#define NETIF_F_NETNS_LOCAL 8192 /* Does not change network namespaces */
  30876. +#define NETIF_F_GRO 16384 /* Generic receive offload */
  30877. +#define NETIF_F_LRO 32768 /* large receive offload */
  30878. +
  30879. +/* the GSO_MASK reserves bits 16 through 23 */
  30880. +#define NETIF_F_FCOE_CRC (1 << 24) /* FCoE CRC32 */
  30881. +#define NETIF_F_SCTP_CSUM (1 << 25) /* SCTP checksum offload */
  30882. +#define NETIF_F_FCOE_MTU (1 << 26) /* Supports max FCoE MTU, 2158 bytes*/
  30883. +#define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */
  30884. +#define NETIF_F_RXHASH (1 << 28) /* Receive hashing offload */
  30885. +
  30886. + /* Segmentation offload features */
  30887. +#define NETIF_F_GSO_SHIFT 16
  30888. +#define NETIF_F_GSO_MASK 0x00ff0000
  30889. +#define NETIF_F_TSO (SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)
  30890. +#define NETIF_F_UFO (SKB_GSO_UDP << NETIF_F_GSO_SHIFT)
  30891. +#define NETIF_F_GSO_ROBUST (SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)
  30892. +#define NETIF_F_TSO_ECN (SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT)
  30893. +#define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)
  30894. +#define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT)
  30895. +
  30896. + /* List of features with software fallbacks. */
  30897. +#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6)
  30898. +
  30899. +
  30900. +#define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)
  30901. +#define NETIF_F_V4_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
  30902. +#define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)
  30903. +#define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
  30904. +
  30905. + /*
  30906. + * If one device supports one of these features, then enable them
  30907. + * for all in netdev_increment_features.
  30908. + */
  30909. +#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \
  30910. + NETIF_F_SG | NETIF_F_HIGHDMA | \
  30911. + NETIF_F_FRAGLIST)
  30912. +
  30913. + /* Interface index. Unique device identifier */
  30914. + int ifindex;
  30915. + int iflink;
  30916. +
  30917. + struct net_device_stats stats;
  30918. +
  30919. +#ifdef CONFIG_WIRELESS_EXT
  30920. + /* List of functions to handle Wireless Extensions (instead of ioctl).
  30921. + * See <net/iw_handler.h> for details. Jean II */
  30922. + const struct iw_handler_def * wireless_handlers;
  30923. + /* Instance data managed by the core of Wireless Extensions. */
  30924. + struct iw_public_data * wireless_data;
  30925. +#endif
  30926. + /* Management operations */
  30927. + const struct net_device_ops *netdev_ops;
  30928. + const struct ethtool_ops *ethtool_ops;
  30929. +
  30930. + /* Hardware header description */
  30931. + const struct header_ops *header_ops;
  30932. +
  30933. + unsigned int flags; /* interface flags (a la BSD) */
  30934. + unsigned short gflags;
  30935. + unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */
  30936. + unsigned short padded; /* How much padding added by alloc_netdev() */
  30937. +
  30938. + unsigned char operstate; /* RFC2863 operstate */
  30939. + unsigned char link_mode; /* mapping policy to operstate */
  30940. +
  30941. + unsigned int mtu; /* interface MTU value */
  30942. + unsigned short type; /* interface hardware type */
  30943. + unsigned short hard_header_len; /* hardware hdr length */
  30944. +
  30945. + /* extra head- and tailroom the hardware may need, but not in all cases
  30946. + * can this be guaranteed, especially tailroom. Some cases also use
  30947. + * LL_MAX_HEADER instead to allocate the skb.
  30948. + */
  30949. + unsigned short needed_headroom;
  30950. + unsigned short needed_tailroom;
  30951. +
  30952. + struct net_device *master; /* Pointer to master device of a group,
  30953. + * which this device is member of.
  30954. + */
  30955. +
  30956. + /* Interface address info. */
  30957. + unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
  30958. + unsigned char addr_len; /* hardware address length */
  30959. + unsigned short dev_id; /* for shared network cards */
  30960. +
  30961. + spinlock_t addr_list_lock;
  30962. + struct netdev_hw_addr_list uc; /* Unicast mac addresses */
  30963. + struct netdev_hw_addr_list mc; /* Multicast mac addresses */
  30964. + int uc_promisc;
  30965. + unsigned int promiscuity;
  30966. + unsigned int allmulti;
  30967. +
  30968. +
  30969. + /* Protocol specific pointers */
  30970. +
  30971. +#ifdef CONFIG_NET_DSA
  30972. + void *dsa_ptr; /* dsa specific data */
  30973. +#endif
  30974. + void *atalk_ptr; /* AppleTalk link */
  30975. + void *ip_ptr; /* IPv4 specific data */
  30976. + void *dn_ptr; /* DECnet specific data */
  30977. + void *ip6_ptr; /* IPv6 specific data */
  30978. + void *ec_ptr; /* Econet specific data */
  30979. + void *ax25_ptr; /* AX.25 specific data */
  30980. + struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data,
  30981. + assign before registering */
  30982. +
  30983. +/*
  30984. + * Cache line mostly used on receive path (including eth_type_trans())
  30985. + */
  30986. + unsigned long last_rx; /* Time of last Rx */
  30987. + /* Interface address info used in eth_type_trans() */
  30988. + unsigned char *dev_addr; /* hw address, (before bcast
  30989. + because most packets are
  30990. + unicast) */
  30991. +
  30992. + struct netdev_hw_addr_list dev_addrs; /* list of device
  30993. + hw addresses */
  30994. +
  30995. + unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
  30996. +
  30997. +#ifdef CONFIG_RPS
  30998. + struct kset *queues_kset;
  30999. +
  31000. + struct netdev_rx_queue *_rx;
  31001. +
  31002. + /* Number of RX queues allocated at alloc_netdev_mq() time */
  31003. + unsigned int num_rx_queues;
  31004. +#endif
  31005. +
  31006. + struct netdev_queue rx_queue;
  31007. +
  31008. + struct netdev_queue *_tx ____cacheline_aligned_in_smp;
  31009. +
  31010. + /* Number of TX queues allocated at alloc_netdev_mq() time */
  31011. + unsigned int num_tx_queues;
  31012. +
  31013. + /* Number of TX queues currently active in device */
  31014. + unsigned int real_num_tx_queues;
  31015. +
  31016. + /* root qdisc from userspace point of view */
  31017. + struct Qdisc *qdisc;
  31018. +
  31019. + unsigned long tx_queue_len; /* Max frames per queue allowed */
  31020. + spinlock_t tx_global_lock;
  31021. +/*
  31022. + * One part is mostly used on xmit path (device)
  31023. + */
  31024. + /* These may be needed for future network-power-down code. */
  31025. +
  31026. + /*
  31027. + * trans_start here is expensive for high speed devices on SMP,
  31028. + * please use netdev_queue->trans_start instead.
  31029. + */
  31030. + unsigned long trans_start; /* Time (in jiffies) of last Tx */
  31031. +
  31032. + int watchdog_timeo; /* used by dev_watchdog() */
  31033. + struct timer_list watchdog_timer;
  31034. +
  31035. + /* Number of references to this device */
  31036. + atomic_t refcnt ____cacheline_aligned_in_smp;
  31037. +
  31038. + /* delayed register/unregister */
  31039. + struct list_head todo_list;
  31040. + /* device index hash chain */
  31041. + struct hlist_node index_hlist;
  31042. +
  31043. + struct list_head link_watch_list;
  31044. +
  31045. + /* register/unregister state machine */
  31046. + enum { NETREG_UNINITIALIZED=0,
  31047. + NETREG_REGISTERED, /* completed register_netdevice */
  31048. + NETREG_UNREGISTERING, /* called unregister_netdevice */
  31049. + NETREG_UNREGISTERED, /* completed unregister todo */
  31050. + NETREG_RELEASED, /* called free_netdev */
  31051. + NETREG_DUMMY, /* dummy device for NAPI poll */
  31052. + } reg_state:16;
  31053. +
  31054. + enum {
  31055. + RTNL_LINK_INITIALIZED,
  31056. + RTNL_LINK_INITIALIZING,
  31057. + } rtnl_link_state:16;
  31058. +
  31059. + /* Called from unregister, can be used to call free_netdev */
  31060. + void (*destructor)(struct net_device *dev);
  31061. +
  31062. +#ifdef CONFIG_NETPOLL
  31063. + struct netpoll_info *npinfo;
  31064. +#endif
  31065. +
  31066. +#ifdef CONFIG_NET_NS
  31067. + /* Network namespace this network device is inside */
  31068. + struct net *nd_net;
  31069. +#endif
  31070. +
  31071. + /* mid-layer private */
  31072. + void *ml_priv;
  31073. +
  31074. + /* bridge stuff */
  31075. + struct net_bridge_port *br_port;
  31076. + /* macvlan */
  31077. + struct macvlan_port *macvlan_port;
  31078. + /* GARP */
  31079. + struct garp_port *garp_port;
  31080. +
  31081. + /* class/net/name entry */
  31082. + struct device dev;
  31083. + /* space for optional device, statistics, and wireless sysfs groups */
  31084. + const struct attribute_group *sysfs_groups[4];
  31085. +
  31086. + /* rtnetlink link ops */
  31087. + const struct rtnl_link_ops *rtnl_link_ops;
  31088. +
  31089. + /* VLAN feature mask */
  31090. + unsigned long vlan_features;
  31091. +
  31092. + /* for setting kernel sock attribute on TCP connection setup */
  31093. +#define GSO_MAX_SIZE 65536
  31094. + unsigned int gso_max_size;
  31095. +
  31096. +#ifdef CONFIG_DCB
  31097. + /* Data Center Bridging netlink ops */
  31098. + const struct dcbnl_rtnl_ops *dcbnl_ops;
  31099. +#endif
  31100. +
  31101. +#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
  31102. + /* max exchange id for FCoE LRO by ddp */
  31103. + unsigned int fcoe_ddp_xid;
  31104. +#endif
  31105. + /* n-tuple filter list attached to this device */
  31106. + struct ethtool_rx_ntuple_list ethtool_ntuple_list;
  31107. +};
  31108. +#define to_net_dev(d) container_of(d, struct net_device, dev)
  31109. +
  31110. +#define NETDEV_ALIGN 32
  31111. +
  31112. +static inline
  31113. +struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
  31114. + unsigned int index)
  31115. +{
  31116. + return &dev->_tx[index];
  31117. +}
  31118. +
  31119. +static inline void netdev_for_each_tx_queue(struct net_device *dev,
  31120. + void (*f)(struct net_device *,
  31121. + struct netdev_queue *,
  31122. + void *),
  31123. + void *arg)
  31124. +{
  31125. + unsigned int i;
  31126. +
  31127. + for (i = 0; i < dev->num_tx_queues; i++)
  31128. + f(dev, &dev->_tx[i], arg);
  31129. +}
  31130. +
  31131. +/*
  31132. + * Net namespace inlines
  31133. + */
  31134. +static inline
  31135. +struct net *dev_net(const struct net_device *dev)
  31136. +{
  31137. +#ifdef CONFIG_NET_NS
  31138. + return dev->nd_net;
  31139. +#else
  31140. + return &init_net;
  31141. +#endif
  31142. +}
  31143. +
  31144. +static inline
  31145. +void dev_net_set(struct net_device *dev, struct net *net)
  31146. +{
  31147. +#ifdef CONFIG_NET_NS
  31148. + release_net(dev->nd_net);
  31149. + dev->nd_net = hold_net(net);
  31150. +#endif
  31151. +}
  31152. +
  31153. +static inline bool netdev_uses_dsa_tags(struct net_device *dev)
  31154. +{
  31155. +#ifdef CONFIG_NET_DSA_TAG_DSA
  31156. + if (dev->dsa_ptr != NULL)
  31157. + return dsa_uses_dsa_tags(dev->dsa_ptr);
  31158. +#endif
  31159. +
  31160. + return 0;
  31161. +}
  31162. +
  31163. +#ifndef CONFIG_NET_NS
  31164. +static inline void skb_set_dev(struct sk_buff *skb, struct net_device *dev)
  31165. +{
  31166. + skb->dev = dev;
  31167. +}
  31168. +#else /* CONFIG_NET_NS */
  31169. +void skb_set_dev(struct sk_buff *skb, struct net_device *dev);
  31170. +#endif
  31171. +
  31172. +static inline bool netdev_uses_trailer_tags(struct net_device *dev)
  31173. +{
  31174. +#ifdef CONFIG_NET_DSA_TAG_TRAILER
  31175. + if (dev->dsa_ptr != NULL)
  31176. + return dsa_uses_trailer_tags(dev->dsa_ptr);
  31177. +#endif
  31178. +
  31179. + return 0;
  31180. +}
  31181. +
  31182. +/**
  31183. + * netdev_priv - access network device private data
  31184. + * @dev: network device
  31185. + *
  31186. + * Get network device private data
  31187. + */
  31188. +static inline void *netdev_priv(const struct net_device *dev)
  31189. +{
  31190. + return (char *)dev + ALIGN(sizeof(struct net_device), NETDEV_ALIGN);
  31191. +}
  31192. +
  31193. +/* Set the sysfs physical device reference for the network logical device
  31194. + * if set prior to registration will cause a symlink during initialization.
  31195. + */
  31196. +#define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev))
  31197. +
  31198. +/* Set the sysfs device type for the network logical device to allow
  31199. + * fin grained indentification of different network device types. For
  31200. + * example Ethernet, Wirelss LAN, Bluetooth, WiMAX etc.
  31201. + */
  31202. +#define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype))
  31203. +
  31204. +/**
  31205. + * netif_napi_add - initialize a napi context
  31206. + * @dev: network device
  31207. + * @napi: napi context
  31208. + * @poll: polling function
  31209. + * @weight: default weight
  31210. + *
  31211. + * netif_napi_add() must be used to initialize a napi context prior to calling
  31212. + * *any* of the other napi related functions.
  31213. + */
  31214. +void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
  31215. + int (*poll)(struct napi_struct *, int), int weight);
  31216. +
  31217. +/**
  31218. + * netif_napi_del - remove a napi context
  31219. + * @napi: napi context
  31220. + *
  31221. + * netif_napi_del() removes a napi context from the network device napi list
  31222. + */
  31223. +void netif_napi_del(struct napi_struct *napi);
  31224. +
  31225. +struct napi_gro_cb {
  31226. + /* Virtual address of skb_shinfo(skb)->frags[0].page + offset. */
  31227. + void *frag0;
  31228. +
  31229. + /* Length of frag0. */
  31230. + unsigned int frag0_len;
  31231. +
  31232. + /* This indicates where we are processing relative to skb->data. */
  31233. + int data_offset;
  31234. +
  31235. + /* This is non-zero if the packet may be of the same flow. */
  31236. + int same_flow;
  31237. +
  31238. + /* This is non-zero if the packet cannot be merged with the new skb. */
  31239. + int flush;
  31240. +
  31241. + /* Number of segments aggregated. */
  31242. + int count;
  31243. +
  31244. + /* Free the skb? */
  31245. + int free;
  31246. +};
  31247. +
  31248. +#define NAPI_GRO_CB(skb) ((struct napi_gro_cb *)(skb)->cb)
  31249. +
  31250. +struct packet_type {
  31251. + __be16 type; /* This is really htons(ether_type). */
  31252. + struct net_device *dev; /* NULL is wildcarded here */
  31253. + int (*func) (struct sk_buff *,
  31254. + struct net_device *,
  31255. + struct packet_type *,
  31256. + struct net_device *);
  31257. + struct sk_buff *(*gso_segment)(struct sk_buff *skb,
  31258. + int features);
  31259. + int (*gso_send_check)(struct sk_buff *skb);
  31260. + struct sk_buff **(*gro_receive)(struct sk_buff **head,
  31261. + struct sk_buff *skb);
  31262. + int (*gro_complete)(struct sk_buff *skb);
  31263. + void *af_packet_priv;
  31264. + struct list_head list;
  31265. +};
  31266. +
  31267. +#include <linux/interrupt.h>
  31268. +#include <linux/notifier.h>
  31269. +
  31270. +extern rwlock_t dev_base_lock; /* Device list lock */
  31271. +
  31272. +
  31273. +#define for_each_netdev(net, d) \
  31274. + list_for_each_entry(d, &(net)->dev_base_head, dev_list)
  31275. +#define for_each_netdev_reverse(net, d) \
  31276. + list_for_each_entry_reverse(d, &(net)->dev_base_head, dev_list)
  31277. +#define for_each_netdev_rcu(net, d) \
  31278. + list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
  31279. +#define for_each_netdev_safe(net, d, n) \
  31280. + list_for_each_entry_safe(d, n, &(net)->dev_base_head, dev_list)
  31281. +#define for_each_netdev_continue(net, d) \
  31282. + list_for_each_entry_continue(d, &(net)->dev_base_head, dev_list)
  31283. +#define for_each_netdev_continue_rcu(net, d) \
  31284. + list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list)
  31285. +#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list)
  31286. +
  31287. +static inline struct net_device *next_net_device(struct net_device *dev)
  31288. +{
  31289. + struct list_head *lh;
  31290. + struct net *net;
  31291. +
  31292. + net = dev_net(dev);
  31293. + lh = dev->dev_list.next;
  31294. + return lh == &net->dev_base_head ? NULL : net_device_entry(lh);
  31295. +}
  31296. +
  31297. +static inline struct net_device *next_net_device_rcu(struct net_device *dev)
  31298. +{
  31299. + struct list_head *lh;
  31300. + struct net *net;
  31301. +
  31302. + net = dev_net(dev);
  31303. + lh = rcu_dereference(dev->dev_list.next);
  31304. + return lh == &net->dev_base_head ? NULL : net_device_entry(lh);
  31305. +}
  31306. +
  31307. +static inline struct net_device *first_net_device(struct net *net)
  31308. +{
  31309. + return list_empty(&net->dev_base_head) ? NULL :
  31310. + net_device_entry(net->dev_base_head.next);
  31311. +}
  31312. +
  31313. +extern int netdev_boot_setup_check(struct net_device *dev);
  31314. +extern unsigned long netdev_boot_base(const char *prefix, int unit);
  31315. +extern struct net_device *dev_getbyhwaddr(struct net *net, unsigned short type, char *hwaddr);
  31316. +extern struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type);
  31317. +extern struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type);
  31318. +extern void dev_add_pack(struct packet_type *pt);
  31319. +extern void dev_remove_pack(struct packet_type *pt);
  31320. +extern void __dev_remove_pack(struct packet_type *pt);
  31321. +
  31322. +extern struct net_device *dev_get_by_flags(struct net *net, unsigned short flags,
  31323. + unsigned short mask);
  31324. +extern struct net_device *dev_get_by_name(struct net *net, const char *name);
  31325. +extern struct net_device *dev_get_by_name_rcu(struct net *net, const char *name);
  31326. +extern struct net_device *__dev_get_by_name(struct net *net, const char *name);
  31327. +extern int dev_alloc_name(struct net_device *dev, const char *name);
  31328. +extern int dev_open(struct net_device *dev);
  31329. +extern int dev_close(struct net_device *dev);
  31330. +extern void dev_disable_lro(struct net_device *dev);
  31331. +extern int dev_queue_xmit(struct sk_buff *skb);
  31332. +extern int register_netdevice(struct net_device *dev);
  31333. +extern void unregister_netdevice_queue(struct net_device *dev,
  31334. + struct list_head *head);
  31335. +extern void unregister_netdevice_many(struct list_head *head);
  31336. +static inline void unregister_netdevice(struct net_device *dev)
  31337. +{
  31338. + unregister_netdevice_queue(dev, NULL);
  31339. +}
  31340. +
  31341. +extern void free_netdev(struct net_device *dev);
  31342. +extern void synchronize_net(void);
  31343. +extern int register_netdevice_notifier(struct notifier_block *nb);
  31344. +extern int unregister_netdevice_notifier(struct notifier_block *nb);
  31345. +extern int init_dummy_netdev(struct net_device *dev);
  31346. +extern void netdev_resync_ops(struct net_device *dev);
  31347. +
  31348. +extern int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
  31349. +extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
  31350. +extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
  31351. +extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
  31352. +extern int dev_restart(struct net_device *dev);
  31353. +#ifdef CONFIG_NETPOLL_TRAP
  31354. +extern int netpoll_trap(void);
  31355. +#endif
  31356. +extern int skb_gro_receive(struct sk_buff **head,
  31357. + struct sk_buff *skb);
  31358. +extern void skb_gro_reset_offset(struct sk_buff *skb);
  31359. +
  31360. +static inline unsigned int skb_gro_offset(const struct sk_buff *skb)
  31361. +{
  31362. + return NAPI_GRO_CB(skb)->data_offset;
  31363. +}
  31364. +
  31365. +static inline unsigned int skb_gro_len(const struct sk_buff *skb)
  31366. +{
  31367. + return skb->len - NAPI_GRO_CB(skb)->data_offset;
  31368. +}
  31369. +
  31370. +static inline void skb_gro_pull(struct sk_buff *skb, unsigned int len)
  31371. +{
  31372. + NAPI_GRO_CB(skb)->data_offset += len;
  31373. +}
  31374. +
  31375. +static inline void *skb_gro_header_fast(struct sk_buff *skb,
  31376. + unsigned int offset)
  31377. +{
  31378. + return NAPI_GRO_CB(skb)->frag0 + offset;
  31379. +}
  31380. +
  31381. +static inline int skb_gro_header_hard(struct sk_buff *skb, unsigned int hlen)
  31382. +{
  31383. + return NAPI_GRO_CB(skb)->frag0_len < hlen;
  31384. +}
  31385. +
  31386. +static inline void *skb_gro_header_slow(struct sk_buff *skb, unsigned int hlen,
  31387. + unsigned int offset)
  31388. +{
  31389. + NAPI_GRO_CB(skb)->frag0 = NULL;
  31390. + NAPI_GRO_CB(skb)->frag0_len = 0;
  31391. + return pskb_may_pull(skb, hlen) ? skb->data + offset : NULL;
  31392. +}
  31393. +
  31394. +static inline void *skb_gro_mac_header(struct sk_buff *skb)
  31395. +{
  31396. + return NAPI_GRO_CB(skb)->frag0 ?: skb_mac_header(skb);
  31397. +}
  31398. +
  31399. +static inline void *skb_gro_network_header(struct sk_buff *skb)
  31400. +{
  31401. + return (NAPI_GRO_CB(skb)->frag0 ?: skb->data) +
  31402. + skb_network_offset(skb);
  31403. +}
  31404. +
  31405. +static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
  31406. + unsigned short type,
  31407. + const void *daddr, const void *saddr,
  31408. + unsigned len)
  31409. +{
  31410. + if (!dev->header_ops || !dev->header_ops->create)
  31411. + return 0;
  31412. +
  31413. + return dev->header_ops->create(skb, dev, type, daddr, saddr, len);
  31414. +}
  31415. +
  31416. +static inline int dev_parse_header(const struct sk_buff *skb,
  31417. + unsigned char *haddr)
  31418. +{
  31419. + const struct net_device *dev = skb->dev;
  31420. +
  31421. + if (!dev->header_ops || !dev->header_ops->parse)
  31422. + return 0;
  31423. + return dev->header_ops->parse(skb, haddr);
  31424. +}
  31425. +
  31426. +typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);
  31427. +extern int register_gifconf(unsigned int family, gifconf_func_t * gifconf);
  31428. +static inline int unregister_gifconf(unsigned int family)
  31429. +{
  31430. + return register_gifconf(family, NULL);
  31431. +}
  31432. +
  31433. +/*
  31434. + * Incoming packets are placed on per-cpu queues
  31435. + */
  31436. +struct softnet_data {
  31437. + struct Qdisc *output_queue;
  31438. + struct Qdisc **output_queue_tailp;
  31439. + struct list_head poll_list;
  31440. + struct sk_buff *completion_queue;
  31441. + struct sk_buff_head process_queue;
  31442. +
  31443. + /* stats */
  31444. + unsigned int processed;
  31445. + unsigned int time_squeeze;
  31446. + unsigned int cpu_collision;
  31447. + unsigned int received_rps;
  31448. +
  31449. +#ifdef CONFIG_RPS
  31450. + struct softnet_data *rps_ipi_list;
  31451. +
  31452. + /* Elements below can be accessed between CPUs for RPS */
  31453. + struct call_single_data csd ____cacheline_aligned_in_smp;
  31454. + struct softnet_data *rps_ipi_next;
  31455. + unsigned int cpu;
  31456. + unsigned int input_queue_head;
  31457. + unsigned int input_queue_tail;
  31458. +#endif
  31459. + unsigned dropped;
  31460. + struct sk_buff_head input_pkt_queue;
  31461. + struct napi_struct backlog;
  31462. +};
  31463. +
  31464. +static inline void input_queue_head_incr(struct softnet_data *sd)
  31465. +{
  31466. +#ifdef CONFIG_RPS
  31467. + sd->input_queue_head++;
  31468. +#endif
  31469. +}
  31470. +
  31471. +static inline void input_queue_tail_incr_save(struct softnet_data *sd,
  31472. + unsigned int *qtail)
  31473. +{
  31474. +#ifdef CONFIG_RPS
  31475. + *qtail = ++sd->input_queue_tail;
  31476. +#endif
  31477. +}
  31478. +
  31479. +DECLARE_PER_CPU_ALIGNED(struct softnet_data, softnet_data);
  31480. +
  31481. +#define HAVE_NETIF_QUEUE
  31482. +
  31483. +extern void __netif_schedule(struct Qdisc *q);
  31484. +
  31485. +static inline void netif_schedule_queue(struct netdev_queue *txq)
  31486. +{
  31487. + if (!test_bit(__QUEUE_STATE_XOFF, &txq->state))
  31488. + __netif_schedule(txq->qdisc);
  31489. +}
  31490. +
  31491. +static inline void netif_tx_schedule_all(struct net_device *dev)
  31492. +{
  31493. + unsigned int i;
  31494. +
  31495. + for (i = 0; i < dev->num_tx_queues; i++)
  31496. + netif_schedule_queue(netdev_get_tx_queue(dev, i));
  31497. +}
  31498. +
  31499. +static inline void netif_tx_start_queue(struct netdev_queue *dev_queue)
  31500. +{
  31501. + clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
  31502. +}
  31503. +
  31504. +/**
  31505. + * netif_start_queue - allow transmit
  31506. + * @dev: network device
  31507. + *
  31508. + * Allow upper layers to call the device hard_start_xmit routine.
  31509. + */
  31510. +static inline void netif_start_queue(struct net_device *dev)
  31511. +{
  31512. + netif_tx_start_queue(netdev_get_tx_queue(dev, 0));
  31513. +}
  31514. +
  31515. +static inline void netif_tx_start_all_queues(struct net_device *dev)
  31516. +{
  31517. + unsigned int i;
  31518. +
  31519. + for (i = 0; i < dev->num_tx_queues; i++) {
  31520. + struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
  31521. + netif_tx_start_queue(txq);
  31522. + }
  31523. +}
  31524. +
  31525. +static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)
  31526. +{
  31527. +#ifdef CONFIG_NETPOLL_TRAP
  31528. + if (netpoll_trap()) {
  31529. + netif_tx_start_queue(dev_queue);
  31530. + return;
  31531. + }
  31532. +#endif
  31533. + if (test_and_clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state))
  31534. + __netif_schedule(dev_queue->qdisc);
  31535. +}
  31536. +
  31537. +/**
  31538. + * netif_wake_queue - restart transmit
  31539. + * @dev: network device
  31540. + *
  31541. + * Allow upper layers to call the device hard_start_xmit routine.
  31542. + * Used for flow control when transmit resources are available.
  31543. + */
  31544. +static inline void netif_wake_queue(struct net_device *dev)
  31545. +{
  31546. + netif_tx_wake_queue(netdev_get_tx_queue(dev, 0));
  31547. +}
  31548. +
  31549. +static inline void netif_tx_wake_all_queues(struct net_device *dev)
  31550. +{
  31551. + unsigned int i;
  31552. +
  31553. + for (i = 0; i < dev->num_tx_queues; i++) {
  31554. + struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
  31555. + netif_tx_wake_queue(txq);
  31556. + }
  31557. +}
  31558. +
  31559. +static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
  31560. +{
  31561. + set_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
  31562. +}
  31563. +
  31564. +/**
  31565. + * netif_stop_queue - stop transmitted packets
  31566. + * @dev: network device
  31567. + *
  31568. + * Stop upper layers calling the device hard_start_xmit routine.
  31569. + * Used for flow control when transmit resources are unavailable.
  31570. + */
  31571. +static inline void netif_stop_queue(struct net_device *dev)
  31572. +{
  31573. + netif_tx_stop_queue(netdev_get_tx_queue(dev, 0));
  31574. +}
  31575. +
  31576. +static inline void netif_tx_stop_all_queues(struct net_device *dev)
  31577. +{
  31578. + unsigned int i;
  31579. +
  31580. + for (i = 0; i < dev->num_tx_queues; i++) {
  31581. + struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
  31582. + netif_tx_stop_queue(txq);
  31583. + }
  31584. +}
  31585. +
  31586. +static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue)
  31587. +{
  31588. + return test_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
  31589. +}
  31590. +
  31591. +/**
  31592. + * netif_queue_stopped - test if transmit queue is flowblocked
  31593. + * @dev: network device
  31594. + *
  31595. + * Test if transmit queue on device is currently unable to send.
  31596. + */
  31597. +static inline int netif_queue_stopped(const struct net_device *dev)
  31598. +{
  31599. + return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0));
  31600. +}
  31601. +
  31602. +static inline int netif_tx_queue_frozen(const struct netdev_queue *dev_queue)
  31603. +{
  31604. + return test_bit(__QUEUE_STATE_FROZEN, &dev_queue->state);
  31605. +}
  31606. +
  31607. +/**
  31608. + * netif_running - test if up
  31609. + * @dev: network device
  31610. + *
  31611. + * Test if the device has been brought up.
  31612. + */
  31613. +static inline int netif_running(const struct net_device *dev)
  31614. +{
  31615. + return test_bit(__LINK_STATE_START, &dev->state);
  31616. +}
  31617. +
  31618. +/*
  31619. + * Routines to manage the subqueues on a device. We only need start
  31620. + * stop, and a check if it's stopped. All other device management is
  31621. + * done at the overall netdevice level.
  31622. + * Also test the device if we're multiqueue.
  31623. + */
  31624. +
  31625. +/**
  31626. + * netif_start_subqueue - allow sending packets on subqueue
  31627. + * @dev: network device
  31628. + * @queue_index: sub queue index
  31629. + *
  31630. + * Start individual transmit queue of a device with multiple transmit queues.
  31631. + */
  31632. +static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index)
  31633. +{
  31634. + struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
  31635. +
  31636. + netif_tx_start_queue(txq);
  31637. +}
  31638. +
  31639. +/**
  31640. + * netif_stop_subqueue - stop sending packets on subqueue
  31641. + * @dev: network device
  31642. + * @queue_index: sub queue index
  31643. + *
  31644. + * Stop individual transmit queue of a device with multiple transmit queues.
  31645. + */
  31646. +static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index)
  31647. +{
  31648. + struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
  31649. +#ifdef CONFIG_NETPOLL_TRAP
  31650. + if (netpoll_trap())
  31651. + return;
  31652. +#endif
  31653. + netif_tx_stop_queue(txq);
  31654. +}
  31655. +
  31656. +/**
  31657. + * netif_subqueue_stopped - test status of subqueue
  31658. + * @dev: network device
  31659. + * @queue_index: sub queue index
  31660. + *
  31661. + * Check individual transmit queue of a device with multiple transmit queues.
  31662. + */
  31663. +static inline int __netif_subqueue_stopped(const struct net_device *dev,
  31664. + u16 queue_index)
  31665. +{
  31666. + struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
  31667. +
  31668. + return netif_tx_queue_stopped(txq);
  31669. +}
  31670. +
  31671. +static inline int netif_subqueue_stopped(const struct net_device *dev,
  31672. + struct sk_buff *skb)
  31673. +{
  31674. + return __netif_subqueue_stopped(dev, skb_get_queue_mapping(skb));
  31675. +}
  31676. +
  31677. +/**
  31678. + * netif_wake_subqueue - allow sending packets on subqueue
  31679. + * @dev: network device
  31680. + * @queue_index: sub queue index
  31681. + *
  31682. + * Resume individual transmit queue of a device with multiple transmit queues.
  31683. + */
  31684. +static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
  31685. +{
  31686. + struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
  31687. +#ifdef CONFIG_NETPOLL_TRAP
  31688. + if (netpoll_trap())
  31689. + return;
  31690. +#endif
  31691. + if (test_and_clear_bit(__QUEUE_STATE_XOFF, &txq->state))
  31692. + __netif_schedule(txq->qdisc);
  31693. +}
  31694. +
  31695. +/**
  31696. + * netif_is_multiqueue - test if device has multiple transmit queues
  31697. + * @dev: network device
  31698. + *
  31699. + * Check if device has multiple transmit queues
  31700. + */
  31701. +static inline int netif_is_multiqueue(const struct net_device *dev)
  31702. +{
  31703. + return (dev->num_tx_queues > 1);
  31704. +}
  31705. +
  31706. +extern void netif_set_real_num_tx_queues(struct net_device *dev,
  31707. + unsigned int txq);
  31708. +
  31709. +/* Use this variant when it is known for sure that it
  31710. + * is executing from hardware interrupt context or with hardware interrupts
  31711. + * disabled.
  31712. + */
  31713. +extern void dev_kfree_skb_irq(struct sk_buff *skb);
  31714. +
  31715. +/* Use this variant in places where it could be invoked
  31716. + * from either hardware interrupt or other context, with hardware interrupts
  31717. + * either disabled or enabled.
  31718. + */
  31719. +extern void dev_kfree_skb_any(struct sk_buff *skb);
  31720. +
  31721. +#define HAVE_NETIF_RX 1
  31722. +extern int netif_rx(struct sk_buff *skb);
  31723. +extern int netif_rx_ni(struct sk_buff *skb);
  31724. +#define HAVE_NETIF_RECEIVE_SKB 1
  31725. +extern int netif_receive_skb(struct sk_buff *skb);
  31726. +extern gro_result_t dev_gro_receive(struct napi_struct *napi,
  31727. + struct sk_buff *skb);
  31728. +extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb);
  31729. +extern gro_result_t napi_gro_receive(struct napi_struct *napi,
  31730. + struct sk_buff *skb);
  31731. +extern void napi_reuse_skb(struct napi_struct *napi,
  31732. + struct sk_buff *skb);
  31733. +extern struct sk_buff * napi_get_frags(struct napi_struct *napi);
  31734. +extern gro_result_t napi_frags_finish(struct napi_struct *napi,
  31735. + struct sk_buff *skb,
  31736. + gro_result_t ret);
  31737. +extern struct sk_buff * napi_frags_skb(struct napi_struct *napi);
  31738. +extern gro_result_t napi_gro_frags(struct napi_struct *napi);
  31739. +
  31740. +static inline void napi_free_frags(struct napi_struct *napi)
  31741. +{
  31742. + kfree_skb(napi->skb);
  31743. + napi->skb = NULL;
  31744. +}
  31745. +
  31746. +extern void netif_nit_deliver(struct sk_buff *skb);
  31747. +extern int dev_valid_name(const char *name);
  31748. +extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *);
  31749. +extern int dev_ethtool(struct net *net, struct ifreq *);
  31750. +extern unsigned dev_get_flags(const struct net_device *);
  31751. +extern int __dev_change_flags(struct net_device *, unsigned int flags);
  31752. +extern int dev_change_flags(struct net_device *, unsigned);
  31753. +extern void __dev_notify_flags(struct net_device *, unsigned int old_flags);
  31754. +extern int dev_change_name(struct net_device *, const char *);
  31755. +extern int dev_set_alias(struct net_device *, const char *, size_t);
  31756. +extern int dev_change_net_namespace(struct net_device *,
  31757. + struct net *, const char *);
  31758. +extern int dev_set_mtu(struct net_device *, int);
  31759. +extern int dev_set_mac_address(struct net_device *,
  31760. + struct sockaddr *);
  31761. +extern int dev_hard_start_xmit(struct sk_buff *skb,
  31762. + struct net_device *dev,
  31763. + struct netdev_queue *txq);
  31764. +extern int dev_forward_skb(struct net_device *dev,
  31765. + struct sk_buff *skb);
  31766. +
  31767. +extern int netdev_budget;
  31768. +
  31769. +/* Called by rtnetlink.c:rtnl_unlock() */
  31770. +extern void netdev_run_todo(void);
  31771. +
  31772. +/**
  31773. + * dev_put - release reference to device
  31774. + * @dev: network device
  31775. + *
  31776. + * Release reference to device to allow it to be freed.
  31777. + */
  31778. +static inline void dev_put(struct net_device *dev)
  31779. +{
  31780. + atomic_dec(&dev->refcnt);
  31781. +}
  31782. +
  31783. +/**
  31784. + * dev_hold - get reference to device
  31785. + * @dev: network device
  31786. + *
  31787. + * Hold reference to device to keep it from being freed.
  31788. + */
  31789. +static inline void dev_hold(struct net_device *dev)
  31790. +{
  31791. + atomic_inc(&dev->refcnt);
  31792. +}
  31793. +
  31794. +/* Carrier loss detection, dial on demand. The functions netif_carrier_on
  31795. + * and _off may be called from IRQ context, but it is caller
  31796. + * who is responsible for serialization of these calls.
  31797. + *
  31798. + * The name carrier is inappropriate, these functions should really be
  31799. + * called netif_lowerlayer_*() because they represent the state of any
  31800. + * kind of lower layer not just hardware media.
  31801. + */
  31802. +
  31803. +extern void linkwatch_fire_event(struct net_device *dev);
  31804. +extern void linkwatch_forget_dev(struct net_device *dev);
  31805. +
  31806. +/**
  31807. + * netif_carrier_ok - test if carrier present
  31808. + * @dev: network device
  31809. + *
  31810. + * Check if carrier is present on device
  31811. + */
  31812. +static inline int netif_carrier_ok(const struct net_device *dev)
  31813. +{
  31814. + return !test_bit(__LINK_STATE_NOCARRIER, &dev->state);
  31815. +}
  31816. +
  31817. +extern unsigned long dev_trans_start(struct net_device *dev);
  31818. +
  31819. +extern void __netdev_watchdog_up(struct net_device *dev);
  31820. +
  31821. +extern void netif_carrier_on(struct net_device *dev);
  31822. +
  31823. +extern void netif_carrier_off(struct net_device *dev);
  31824. +
  31825. +extern void netif_notify_peers(struct net_device *dev);
  31826. +
  31827. +/**
  31828. + * netif_dormant_on - mark device as dormant.
  31829. + * @dev: network device
  31830. + *
  31831. + * Mark device as dormant (as per RFC2863).
  31832. + *
  31833. + * The dormant state indicates that the relevant interface is not
  31834. + * actually in a condition to pass packets (i.e., it is not 'up') but is
  31835. + * in a "pending" state, waiting for some external event. For "on-
  31836. + * demand" interfaces, this new state identifies the situation where the
  31837. + * interface is waiting for events to place it in the up state.
  31838. + *
  31839. + */
  31840. +static inline void netif_dormant_on(struct net_device *dev)
  31841. +{
  31842. + if (!test_and_set_bit(__LINK_STATE_DORMANT, &dev->state))
  31843. + linkwatch_fire_event(dev);
  31844. +}
  31845. +
  31846. +/**
  31847. + * netif_dormant_off - set device as not dormant.
  31848. + * @dev: network device
  31849. + *
  31850. + * Device is not in dormant state.
  31851. + */
  31852. +static inline void netif_dormant_off(struct net_device *dev)
  31853. +{
  31854. + if (test_and_clear_bit(__LINK_STATE_DORMANT, &dev->state))
  31855. + linkwatch_fire_event(dev);
  31856. +}
  31857. +
  31858. +/**
  31859. + * netif_dormant - test if carrier present
  31860. + * @dev: network device
  31861. + *
  31862. + * Check if carrier is present on device
  31863. + */
  31864. +static inline int netif_dormant(const struct net_device *dev)
  31865. +{
  31866. + return test_bit(__LINK_STATE_DORMANT, &dev->state);
  31867. +}
  31868. +
  31869. +
  31870. +/**
  31871. + * netif_oper_up - test if device is operational
  31872. + * @dev: network device
  31873. + *
  31874. + * Check if carrier is operational
  31875. + */
  31876. +static inline int netif_oper_up(const struct net_device *dev)
  31877. +{
  31878. + return (dev->operstate == IF_OPER_UP ||
  31879. + dev->operstate == IF_OPER_UNKNOWN /* backward compat */);
  31880. +}
  31881. +
  31882. +/**
  31883. + * netif_device_present - is device available or removed
  31884. + * @dev: network device
  31885. + *
  31886. + * Check if device has not been removed from system.
  31887. + */
  31888. +static inline int netif_device_present(struct net_device *dev)
  31889. +{
  31890. + return test_bit(__LINK_STATE_PRESENT, &dev->state);
  31891. +}
  31892. +
  31893. +extern void netif_device_detach(struct net_device *dev);
  31894. +
  31895. +extern void netif_device_attach(struct net_device *dev);
  31896. +
  31897. +/*
  31898. + * Network interface message level settings
  31899. + */
  31900. +#define HAVE_NETIF_MSG 1
  31901. +
  31902. +enum {
  31903. + NETIF_MSG_DRV = 0x0001,
  31904. + NETIF_MSG_PROBE = 0x0002,
  31905. + NETIF_MSG_LINK = 0x0004,
  31906. + NETIF_MSG_TIMER = 0x0008,
  31907. + NETIF_MSG_IFDOWN = 0x0010,
  31908. + NETIF_MSG_IFUP = 0x0020,
  31909. + NETIF_MSG_RX_ERR = 0x0040,
  31910. + NETIF_MSG_TX_ERR = 0x0080,
  31911. + NETIF_MSG_TX_QUEUED = 0x0100,
  31912. + NETIF_MSG_INTR = 0x0200,
  31913. + NETIF_MSG_TX_DONE = 0x0400,
  31914. + NETIF_MSG_RX_STATUS = 0x0800,
  31915. + NETIF_MSG_PKTDATA = 0x1000,
  31916. + NETIF_MSG_HW = 0x2000,
  31917. + NETIF_MSG_WOL = 0x4000,
  31918. +};
  31919. +
  31920. +#define netif_msg_drv(p) ((p)->msg_enable & NETIF_MSG_DRV)
  31921. +#define netif_msg_probe(p) ((p)->msg_enable & NETIF_MSG_PROBE)
  31922. +#define netif_msg_link(p) ((p)->msg_enable & NETIF_MSG_LINK)
  31923. +#define netif_msg_timer(p) ((p)->msg_enable & NETIF_MSG_TIMER)
  31924. +#define netif_msg_ifdown(p) ((p)->msg_enable & NETIF_MSG_IFDOWN)
  31925. +#define netif_msg_ifup(p) ((p)->msg_enable & NETIF_MSG_IFUP)
  31926. +#define netif_msg_rx_err(p) ((p)->msg_enable & NETIF_MSG_RX_ERR)
  31927. +#define netif_msg_tx_err(p) ((p)->msg_enable & NETIF_MSG_TX_ERR)
  31928. +#define netif_msg_tx_queued(p) ((p)->msg_enable & NETIF_MSG_TX_QUEUED)
  31929. +#define netif_msg_intr(p) ((p)->msg_enable & NETIF_MSG_INTR)
  31930. +#define netif_msg_tx_done(p) ((p)->msg_enable & NETIF_MSG_TX_DONE)
  31931. +#define netif_msg_rx_status(p) ((p)->msg_enable & NETIF_MSG_RX_STATUS)
  31932. +#define netif_msg_pktdata(p) ((p)->msg_enable & NETIF_MSG_PKTDATA)
  31933. +#define netif_msg_hw(p) ((p)->msg_enable & NETIF_MSG_HW)
  31934. +#define netif_msg_wol(p) ((p)->msg_enable & NETIF_MSG_WOL)
  31935. +
  31936. +static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits)
  31937. +{
  31938. + /* use default */
  31939. + if (debug_value < 0 || debug_value >= (sizeof(u32) * 8))
  31940. + return default_msg_enable_bits;
  31941. + if (debug_value == 0) /* no output */
  31942. + return 0;
  31943. + /* set low N bits */
  31944. + return (1 << debug_value) - 1;
  31945. +}
  31946. +
  31947. +static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu)
  31948. +{
  31949. + spin_lock(&txq->_xmit_lock);
  31950. + txq->xmit_lock_owner = cpu;
  31951. +}
  31952. +
  31953. +static inline void __netif_tx_lock_bh(struct netdev_queue *txq)
  31954. +{
  31955. + spin_lock_bh(&txq->_xmit_lock);
  31956. + txq->xmit_lock_owner = smp_processor_id();
  31957. +}
  31958. +
  31959. +static inline int __netif_tx_trylock(struct netdev_queue *txq)
  31960. +{
  31961. + int ok = spin_trylock(&txq->_xmit_lock);
  31962. + if (likely(ok))
  31963. + txq->xmit_lock_owner = smp_processor_id();
  31964. + return ok;
  31965. +}
  31966. +
  31967. +static inline void __netif_tx_unlock(struct netdev_queue *txq)
  31968. +{
  31969. + txq->xmit_lock_owner = -1;
  31970. + spin_unlock(&txq->_xmit_lock);
  31971. +}
  31972. +
  31973. +static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
  31974. +{
  31975. + txq->xmit_lock_owner = -1;
  31976. + spin_unlock_bh(&txq->_xmit_lock);
  31977. +}
  31978. +
  31979. +static inline void txq_trans_update(struct netdev_queue *txq)
  31980. +{
  31981. + if (txq->xmit_lock_owner != -1)
  31982. + txq->trans_start = jiffies;
  31983. +}
  31984. +
  31985. +/**
  31986. + * netif_tx_lock - grab network device transmit lock
  31987. + * @dev: network device
  31988. + *
  31989. + * Get network device transmit lock
  31990. + */
  31991. +static inline void netif_tx_lock(struct net_device *dev)
  31992. +{
  31993. + unsigned int i;
  31994. + int cpu;
  31995. +
  31996. + spin_lock(&dev->tx_global_lock);
  31997. + cpu = smp_processor_id();
  31998. + for (i = 0; i < dev->num_tx_queues; i++) {
  31999. + struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
  32000. +
  32001. + /* We are the only thread of execution doing a
  32002. + * freeze, but we have to grab the _xmit_lock in
  32003. + * order to synchronize with threads which are in
  32004. + * the ->hard_start_xmit() handler and already
  32005. + * checked the frozen bit.
  32006. + */
  32007. + __netif_tx_lock(txq, cpu);
  32008. + set_bit(__QUEUE_STATE_FROZEN, &txq->state);
  32009. + __netif_tx_unlock(txq);
  32010. + }
  32011. +}
  32012. +
  32013. +static inline void netif_tx_lock_bh(struct net_device *dev)
  32014. +{
  32015. + local_bh_disable();
  32016. + netif_tx_lock(dev);
  32017. +}
  32018. +
  32019. +static inline void netif_tx_unlock(struct net_device *dev)
  32020. +{
  32021. + unsigned int i;
  32022. +
  32023. + for (i = 0; i < dev->num_tx_queues; i++) {
  32024. + struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
  32025. +
  32026. + /* No need to grab the _xmit_lock here. If the
  32027. + * queue is not stopped for another reason, we
  32028. + * force a schedule.
  32029. + */
  32030. + clear_bit(__QUEUE_STATE_FROZEN, &txq->state);
  32031. + netif_schedule_queue(txq);
  32032. + }
  32033. + spin_unlock(&dev->tx_global_lock);
  32034. +}
  32035. +
  32036. +static inline void netif_tx_unlock_bh(struct net_device *dev)
  32037. +{
  32038. + netif_tx_unlock(dev);
  32039. + local_bh_enable();
  32040. +}
  32041. +
  32042. +#define HARD_TX_LOCK(dev, txq, cpu) { \
  32043. + if ((dev->features & NETIF_F_LLTX) == 0) { \
  32044. + __netif_tx_lock(txq, cpu); \
  32045. + } \
  32046. +}
  32047. +
  32048. +#define HARD_TX_UNLOCK(dev, txq) { \
  32049. + if ((dev->features & NETIF_F_LLTX) == 0) { \
  32050. + __netif_tx_unlock(txq); \
  32051. + } \
  32052. +}
  32053. +
  32054. +static inline void netif_tx_disable(struct net_device *dev)
  32055. +{
  32056. + unsigned int i;
  32057. + int cpu;
  32058. +
  32059. + local_bh_disable();
  32060. + cpu = smp_processor_id();
  32061. + for (i = 0; i < dev->num_tx_queues; i++) {
  32062. + struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
  32063. +
  32064. + __netif_tx_lock(txq, cpu);
  32065. + netif_tx_stop_queue(txq);
  32066. + __netif_tx_unlock(txq);
  32067. + }
  32068. + local_bh_enable();
  32069. +}
  32070. +
  32071. +static inline void netif_addr_lock(struct net_device *dev)
  32072. +{
  32073. + spin_lock(&dev->addr_list_lock);
  32074. +}
  32075. +
  32076. +static inline void netif_addr_lock_bh(struct net_device *dev)
  32077. +{
  32078. + spin_lock_bh(&dev->addr_list_lock);
  32079. +}
  32080. +
  32081. +static inline void netif_addr_unlock(struct net_device *dev)
  32082. +{
  32083. + spin_unlock(&dev->addr_list_lock);
  32084. +}
  32085. +
  32086. +static inline void netif_addr_unlock_bh(struct net_device *dev)
  32087. +{
  32088. + spin_unlock_bh(&dev->addr_list_lock);
  32089. +}
  32090. +
  32091. +/*
  32092. + * dev_addrs walker. Should be used only for read access. Call with
  32093. + * rcu_read_lock held.
  32094. + */
  32095. +#define for_each_dev_addr(dev, ha) \
  32096. + list_for_each_entry_rcu(ha, &dev->dev_addrs.list, list)
  32097. +
  32098. +/* These functions live elsewhere (drivers/net/net_init.c, but related) */
  32099. +
  32100. +extern void ether_setup(struct net_device *dev);
  32101. +
  32102. +/* Support for loadable net-drivers */
  32103. +extern struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
  32104. + void (*setup)(struct net_device *),
  32105. + unsigned int queue_count);
  32106. +#define alloc_netdev(sizeof_priv, name, setup) \
  32107. + alloc_netdev_mq(sizeof_priv, name, setup, 1)
  32108. +extern int register_netdev(struct net_device *dev);
  32109. +extern void unregister_netdev(struct net_device *dev);
  32110. +
  32111. +/* General hardware address lists handling functions */
  32112. +extern int __hw_addr_add_multiple(struct netdev_hw_addr_list *to_list,
  32113. + struct netdev_hw_addr_list *from_list,
  32114. + int addr_len, unsigned char addr_type);
  32115. +extern void __hw_addr_del_multiple(struct netdev_hw_addr_list *to_list,
  32116. + struct netdev_hw_addr_list *from_list,
  32117. + int addr_len, unsigned char addr_type);
  32118. +extern int __hw_addr_sync(struct netdev_hw_addr_list *to_list,
  32119. + struct netdev_hw_addr_list *from_list,
  32120. + int addr_len);
  32121. +extern void __hw_addr_unsync(struct netdev_hw_addr_list *to_list,
  32122. + struct netdev_hw_addr_list *from_list,
  32123. + int addr_len);
  32124. +extern void __hw_addr_flush(struct netdev_hw_addr_list *list);
  32125. +extern void __hw_addr_init(struct netdev_hw_addr_list *list);
  32126. +
  32127. +/* Functions used for device addresses handling */
  32128. +extern int dev_addr_add(struct net_device *dev, unsigned char *addr,
  32129. + unsigned char addr_type);
  32130. +extern int dev_addr_del(struct net_device *dev, unsigned char *addr,
  32131. + unsigned char addr_type);
  32132. +extern int dev_addr_add_multiple(struct net_device *to_dev,
  32133. + struct net_device *from_dev,
  32134. + unsigned char addr_type);
  32135. +extern int dev_addr_del_multiple(struct net_device *to_dev,
  32136. + struct net_device *from_dev,
  32137. + unsigned char addr_type);
  32138. +extern void dev_addr_flush(struct net_device *dev);
  32139. +extern int dev_addr_init(struct net_device *dev);
  32140. +
  32141. +/* Functions used for unicast addresses handling */
  32142. +extern int dev_uc_add(struct net_device *dev, unsigned char *addr);
  32143. +extern int dev_uc_del(struct net_device *dev, unsigned char *addr);
  32144. +extern int dev_uc_sync(struct net_device *to, struct net_device *from);
  32145. +extern void dev_uc_unsync(struct net_device *to, struct net_device *from);
  32146. +extern void dev_uc_flush(struct net_device *dev);
  32147. +extern void dev_uc_init(struct net_device *dev);
  32148. +
  32149. +/* Functions used for multicast addresses handling */
  32150. +extern int dev_mc_add(struct net_device *dev, unsigned char *addr);
  32151. +extern int dev_mc_add_global(struct net_device *dev, unsigned char *addr);
  32152. +extern int dev_mc_del(struct net_device *dev, unsigned char *addr);
  32153. +extern int dev_mc_del_global(struct net_device *dev, unsigned char *addr);
  32154. +extern int dev_mc_sync(struct net_device *to, struct net_device *from);
  32155. +extern void dev_mc_unsync(struct net_device *to, struct net_device *from);
  32156. +extern void dev_mc_flush(struct net_device *dev);
  32157. +extern void dev_mc_init(struct net_device *dev);
  32158. +
  32159. +/* Functions used for secondary unicast and multicast support */
  32160. +extern void dev_set_rx_mode(struct net_device *dev);
  32161. +extern void __dev_set_rx_mode(struct net_device *dev);
  32162. +extern int dev_set_promiscuity(struct net_device *dev, int inc);
  32163. +extern int dev_set_allmulti(struct net_device *dev, int inc);
  32164. +extern void netdev_state_change(struct net_device *dev);
  32165. +extern int netdev_bonding_change(struct net_device *dev,
  32166. + unsigned long event);
  32167. +extern void netdev_features_change(struct net_device *dev);
  32168. +/* Load a device via the kmod */
  32169. +extern void dev_load(struct net *net, const char *name);
  32170. +extern void dev_mcast_init(void);
  32171. +extern const struct net_device_stats *dev_get_stats(struct net_device *dev);
  32172. +extern void dev_txq_stats_fold(const struct net_device *dev, struct net_device_stats *stats);
  32173. +
  32174. +extern int netdev_max_backlog;
  32175. +extern int netdev_tstamp_prequeue;
  32176. +extern int weight_p;
  32177. +extern int netdev_set_master(struct net_device *dev, struct net_device *master);
  32178. +extern int skb_checksum_help(struct sk_buff *skb);
  32179. +extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features);
  32180. +#ifdef CONFIG_BUG
  32181. +extern void netdev_rx_csum_fault(struct net_device *dev);
  32182. +#else
  32183. +static inline void netdev_rx_csum_fault(struct net_device *dev)
  32184. +{
  32185. +}
  32186. +#endif
  32187. +/* rx skb timestamps */
  32188. +extern void net_enable_timestamp(void);
  32189. +extern void net_disable_timestamp(void);
  32190. +
  32191. +#ifdef CONFIG_PROC_FS
  32192. +extern void *dev_seq_start(struct seq_file *seq, loff_t *pos);
  32193. +extern void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos);
  32194. +extern void dev_seq_stop(struct seq_file *seq, void *v);
  32195. +#endif
  32196. +
  32197. +extern int netdev_class_create_file(struct class_attribute *class_attr);
  32198. +extern void netdev_class_remove_file(struct class_attribute *class_attr);
  32199. +
  32200. +extern char *netdev_drivername(const struct net_device *dev, char *buffer, int len);
  32201. +
  32202. +extern void linkwatch_run_queue(void);
  32203. +
  32204. +unsigned long netdev_increment_features(unsigned long all, unsigned long one,
  32205. + unsigned long mask);
  32206. +unsigned long netdev_fix_features(unsigned long features, const char *name);
  32207. +
  32208. +void netif_stacked_transfer_operstate(const struct net_device *rootdev,
  32209. + struct net_device *dev);
  32210. +
  32211. +static inline int net_gso_ok(int features, int gso_type)
  32212. +{
  32213. + int feature = gso_type << NETIF_F_GSO_SHIFT;
  32214. + return (features & feature) == feature;
  32215. +}
  32216. +
  32217. +static inline int skb_gso_ok(struct sk_buff *skb, int features)
  32218. +{
  32219. + return net_gso_ok(features, skb_shinfo(skb)->gso_type) &&
  32220. + (!skb_has_frags(skb) || (features & NETIF_F_FRAGLIST));
  32221. +}
  32222. +
  32223. +static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
  32224. +{
  32225. + return skb_is_gso(skb) &&
  32226. + (!skb_gso_ok(skb, dev->features) ||
  32227. + unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
  32228. +}
  32229. +
  32230. +static inline void netif_set_gso_max_size(struct net_device *dev,
  32231. + unsigned int size)
  32232. +{
  32233. + dev->gso_max_size = size;
  32234. +}
  32235. +
  32236. +extern int __skb_bond_should_drop(struct sk_buff *skb,
  32237. + struct net_device *master);
  32238. +
  32239. +static inline int skb_bond_should_drop(struct sk_buff *skb,
  32240. + struct net_device *master)
  32241. +{
  32242. + if (master)
  32243. + return __skb_bond_should_drop(skb, master);
  32244. + return 0;
  32245. +}
  32246. +
  32247. +extern struct pernet_operations __net_initdata loopback_net_ops;
  32248. +
  32249. +static inline int dev_ethtool_get_settings(struct net_device *dev,
  32250. + struct ethtool_cmd *cmd)
  32251. +{
  32252. + if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings)
  32253. + return -EOPNOTSUPP;
  32254. + return dev->ethtool_ops->get_settings(dev, cmd);
  32255. +}
  32256. +
  32257. +static inline u32 dev_ethtool_get_rx_csum(struct net_device *dev)
  32258. +{
  32259. + if (!dev->ethtool_ops || !dev->ethtool_ops->get_rx_csum)
  32260. + return 0;
  32261. + return dev->ethtool_ops->get_rx_csum(dev);
  32262. +}
  32263. +
  32264. +static inline u32 dev_ethtool_get_flags(struct net_device *dev)
  32265. +{
  32266. + if (!dev->ethtool_ops || !dev->ethtool_ops->get_flags)
  32267. + return 0;
  32268. + return dev->ethtool_ops->get_flags(dev);
  32269. +}
  32270. +
  32271. +/* Logging, debugging and troubleshooting/diagnostic helpers. */
  32272. +
  32273. +/* netdev_printk helpers, similar to dev_printk */
  32274. +
  32275. +static inline const char *netdev_name(const struct net_device *dev)
  32276. +{
  32277. + if (dev->reg_state != NETREG_REGISTERED)
  32278. + return "(unregistered net_device)";
  32279. + return dev->name;
  32280. +}
  32281. +
  32282. +#define netdev_printk(level, netdev, format, args...) \
  32283. + dev_printk(level, (netdev)->dev.parent, \
  32284. + "%s: " format, \
  32285. + netdev_name(netdev), ##args)
  32286. +
  32287. +#define netdev_emerg(dev, format, args...) \
  32288. + netdev_printk(KERN_EMERG, dev, format, ##args)
  32289. +#define netdev_alert(dev, format, args...) \
  32290. + netdev_printk(KERN_ALERT, dev, format, ##args)
  32291. +#define netdev_crit(dev, format, args...) \
  32292. + netdev_printk(KERN_CRIT, dev, format, ##args)
  32293. +#define netdev_err(dev, format, args...) \
  32294. + netdev_printk(KERN_ERR, dev, format, ##args)
  32295. +#define netdev_warn(dev, format, args...) \
  32296. + netdev_printk(KERN_WARNING, dev, format, ##args)
  32297. +#define netdev_notice(dev, format, args...) \
  32298. + netdev_printk(KERN_NOTICE, dev, format, ##args)
  32299. +#define netdev_info(dev, format, args...) \
  32300. + netdev_printk(KERN_INFO, dev, format, ##args)
  32301. +
  32302. +#if defined(DEBUG)
  32303. +#define netdev_dbg(__dev, format, args...) \
  32304. + netdev_printk(KERN_DEBUG, __dev, format, ##args)
  32305. +#elif defined(CONFIG_DYNAMIC_DEBUG)
  32306. +#define netdev_dbg(__dev, format, args...) \
  32307. +do { \
  32308. + dynamic_dev_dbg((__dev)->dev.parent, "%s: " format, \
  32309. + netdev_name(__dev), ##args); \
  32310. +} while (0)
  32311. +#else
  32312. +#define netdev_dbg(__dev, format, args...) \
  32313. +({ \
  32314. + if (0) \
  32315. + netdev_printk(KERN_DEBUG, __dev, format, ##args); \
  32316. + 0; \
  32317. +})
  32318. +#endif
  32319. +
  32320. +#if defined(VERBOSE_DEBUG)
  32321. +#define netdev_vdbg netdev_dbg
  32322. +#else
  32323. +
  32324. +#define netdev_vdbg(dev, format, args...) \
  32325. +({ \
  32326. + if (0) \
  32327. + netdev_printk(KERN_DEBUG, dev, format, ##args); \
  32328. + 0; \
  32329. +})
  32330. +#endif
  32331. +
  32332. +/*
  32333. + * netdev_WARN() acts like dev_printk(), but with the key difference
  32334. + * of using a WARN/WARN_ON to get the message out, including the
  32335. + * file/line information and a backtrace.
  32336. + */
  32337. +#define netdev_WARN(dev, format, args...) \
  32338. + WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args);
  32339. +
  32340. +/* netif printk helpers, similar to netdev_printk */
  32341. +
  32342. +#define netif_printk(priv, type, level, dev, fmt, args...) \
  32343. +do { \
  32344. + if (netif_msg_##type(priv)) \
  32345. + netdev_printk(level, (dev), fmt, ##args); \
  32346. +} while (0)
  32347. +
  32348. +#define netif_emerg(priv, type, dev, fmt, args...) \
  32349. + netif_printk(priv, type, KERN_EMERG, dev, fmt, ##args)
  32350. +#define netif_alert(priv, type, dev, fmt, args...) \
  32351. + netif_printk(priv, type, KERN_ALERT, dev, fmt, ##args)
  32352. +#define netif_crit(priv, type, dev, fmt, args...) \
  32353. + netif_printk(priv, type, KERN_CRIT, dev, fmt, ##args)
  32354. +#define netif_err(priv, type, dev, fmt, args...) \
  32355. + netif_printk(priv, type, KERN_ERR, dev, fmt, ##args)
  32356. +#define netif_warn(priv, type, dev, fmt, args...) \
  32357. + netif_printk(priv, type, KERN_WARNING, dev, fmt, ##args)
  32358. +#define netif_notice(priv, type, dev, fmt, args...) \
  32359. + netif_printk(priv, type, KERN_NOTICE, dev, fmt, ##args)
  32360. +#define netif_info(priv, type, dev, fmt, args...) \
  32361. + netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args)
  32362. +
  32363. +#if defined(DEBUG)
  32364. +#define netif_dbg(priv, type, dev, format, args...) \
  32365. + netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
  32366. +#elif defined(CONFIG_DYNAMIC_DEBUG)
  32367. +#define netif_dbg(priv, type, netdev, format, args...) \
  32368. +do { \
  32369. + if (netif_msg_##type(priv)) \
  32370. + dynamic_dev_dbg((netdev)->dev.parent, \
  32371. + "%s: " format, \
  32372. + netdev_name(netdev), ##args); \
  32373. +} while (0)
  32374. +#else
  32375. +#define netif_dbg(priv, type, dev, format, args...) \
  32376. +({ \
  32377. + if (0) \
  32378. + netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
  32379. + 0; \
  32380. +})
  32381. +#endif
  32382. +
  32383. +#if defined(VERBOSE_DEBUG)
  32384. +#define netif_vdbg netif_dbg
  32385. +#else
  32386. +#define netif_vdbg(priv, type, dev, format, args...) \
  32387. +({ \
  32388. + if (0) \
  32389. + netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
  32390. + 0; \
  32391. +})
  32392. +#endif
  32393. +
  32394. +#endif /* __KERNEL__ */
  32395. +
  32396. +#endif /* _LINUX_NETDEVICE_H */
  32397. diff -Nur linux-2.6.35.7.orig/include/linux/nxp_74hc153.h linux-2.6.35.7/include/linux/nxp_74hc153.h
  32398. --- linux-2.6.35.7.orig/include/linux/nxp_74hc153.h 1970-01-01 01:00:00.000000000 +0100
  32399. +++ linux-2.6.35.7/include/linux/nxp_74hc153.h 2010-10-14 20:28:01.798101112 +0200
  32400. @@ -0,0 +1,24 @@
  32401. +/*
  32402. + * NXP 74HC153 - Dual 4-input multiplexer defines
  32403. + *
  32404. + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
  32405. + *
  32406. + * This program is free software; you can redistribute it and/or modify
  32407. + * it under the terms of the GNU General Public License version 2 as
  32408. + * published by the Free Software Foundation.
  32409. + */
  32410. +
  32411. +#ifndef _NXP_74HC153_H
  32412. +#define _NXP_74HC153_H
  32413. +
  32414. +#define NXP_74HC153_DRIVER_NAME "nxp-74hc153"
  32415. +
  32416. +struct nxp_74hc153_platform_data {
  32417. + unsigned gpio_base;
  32418. + unsigned gpio_pin_s0;
  32419. + unsigned gpio_pin_s1;
  32420. + unsigned gpio_pin_1y;
  32421. + unsigned gpio_pin_2y;
  32422. +};
  32423. +
  32424. +#endif /* _NXP_74HC153_H */
  32425. diff -Nur linux-2.6.35.7.orig/include/linux/phy.h linux-2.6.35.7/include/linux/phy.h
  32426. --- linux-2.6.35.7.orig/include/linux/phy.h 2010-09-29 03:09:08.000000000 +0200
  32427. +++ linux-2.6.35.7/include/linux/phy.h 2010-10-14 20:28:01.834368168 +0200
  32428. @@ -330,6 +330,20 @@
  32429. void (*adjust_link)(struct net_device *dev);
  32430. void (*adjust_state)(struct net_device *dev);
  32431. +
  32432. + /*
  32433. + * By default these point to the original functions
  32434. + * with the same name. adding them to the phy_device
  32435. + * allows the phy driver to override them for packet
  32436. + * mangling if the ethernet driver supports it
  32437. + * This is required to support some really horrible
  32438. + * switches such as the Marvell 88E6060
  32439. + */
  32440. + int (*netif_receive_skb)(struct sk_buff *skb);
  32441. + int (*netif_rx)(struct sk_buff *skb);
  32442. +
  32443. + /* alignment offset for packets */
  32444. + int pkt_align;
  32445. };
  32446. #define to_phy_device(d) container_of(d, struct phy_device, dev)
  32447. @@ -497,6 +511,7 @@
  32448. void phy_stop_machine(struct phy_device *phydev);
  32449. int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
  32450. int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
  32451. +int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr);
  32452. int phy_mii_ioctl(struct phy_device *phydev,
  32453. struct mii_ioctl_data *mii_data, int cmd);
  32454. int phy_start_interrupts(struct phy_device *phydev);
  32455. diff -Nur linux-2.6.35.7.orig/include/linux/phy.h.orig linux-2.6.35.7/include/linux/phy.h.orig
  32456. --- linux-2.6.35.7.orig/include/linux/phy.h.orig 1970-01-01 01:00:00.000000000 +0100
  32457. +++ linux-2.6.35.7/include/linux/phy.h.orig 2010-09-29 03:09:08.000000000 +0200
  32458. @@ -0,0 +1,519 @@
  32459. +/*
  32460. + * include/linux/phy.h
  32461. + *
  32462. + * Framework and drivers for configuring and reading different PHYs
  32463. + * Based on code in sungem_phy.c and gianfar_phy.c
  32464. + *
  32465. + * Author: Andy Fleming
  32466. + *
  32467. + * Copyright (c) 2004 Freescale Semiconductor, Inc.
  32468. + *
  32469. + * This program is free software; you can redistribute it and/or modify it
  32470. + * under the terms of the GNU General Public License as published by the
  32471. + * Free Software Foundation; either version 2 of the License, or (at your
  32472. + * option) any later version.
  32473. + *
  32474. + */
  32475. +
  32476. +#ifndef __PHY_H
  32477. +#define __PHY_H
  32478. +
  32479. +#include <linux/spinlock.h>
  32480. +#include <linux/device.h>
  32481. +#include <linux/ethtool.h>
  32482. +#include <linux/mii.h>
  32483. +#include <linux/timer.h>
  32484. +#include <linux/workqueue.h>
  32485. +#include <linux/mod_devicetable.h>
  32486. +
  32487. +#include <asm/atomic.h>
  32488. +
  32489. +#define PHY_BASIC_FEATURES (SUPPORTED_10baseT_Half | \
  32490. + SUPPORTED_10baseT_Full | \
  32491. + SUPPORTED_100baseT_Half | \
  32492. + SUPPORTED_100baseT_Full | \
  32493. + SUPPORTED_Autoneg | \
  32494. + SUPPORTED_TP | \
  32495. + SUPPORTED_MII)
  32496. +
  32497. +#define PHY_GBIT_FEATURES (PHY_BASIC_FEATURES | \
  32498. + SUPPORTED_1000baseT_Half | \
  32499. + SUPPORTED_1000baseT_Full)
  32500. +
  32501. +/*
  32502. + * Set phydev->irq to PHY_POLL if interrupts are not supported,
  32503. + * or not desired for this PHY. Set to PHY_IGNORE_INTERRUPT if
  32504. + * the attached driver handles the interrupt
  32505. + */
  32506. +#define PHY_POLL -1
  32507. +#define PHY_IGNORE_INTERRUPT -2
  32508. +
  32509. +#define PHY_HAS_INTERRUPT 0x00000001
  32510. +#define PHY_HAS_MAGICANEG 0x00000002
  32511. +
  32512. +/* Interface Mode definitions */
  32513. +typedef enum {
  32514. + PHY_INTERFACE_MODE_MII,
  32515. + PHY_INTERFACE_MODE_GMII,
  32516. + PHY_INTERFACE_MODE_SGMII,
  32517. + PHY_INTERFACE_MODE_TBI,
  32518. + PHY_INTERFACE_MODE_RMII,
  32519. + PHY_INTERFACE_MODE_RGMII,
  32520. + PHY_INTERFACE_MODE_RGMII_ID,
  32521. + PHY_INTERFACE_MODE_RGMII_RXID,
  32522. + PHY_INTERFACE_MODE_RGMII_TXID,
  32523. + PHY_INTERFACE_MODE_RTBI
  32524. +} phy_interface_t;
  32525. +
  32526. +
  32527. +#define PHY_INIT_TIMEOUT 100000
  32528. +#define PHY_STATE_TIME 1
  32529. +#define PHY_FORCE_TIMEOUT 10
  32530. +#define PHY_AN_TIMEOUT 10
  32531. +
  32532. +#define PHY_MAX_ADDR 32
  32533. +
  32534. +/* Used when trying to connect to a specific phy (mii bus id:phy device id) */
  32535. +#define PHY_ID_FMT "%s:%02x"
  32536. +
  32537. +/*
  32538. + * Need to be a little smaller than phydev->dev.bus_id to leave room
  32539. + * for the ":%02x"
  32540. + */
  32541. +#define MII_BUS_ID_SIZE (20 - 3)
  32542. +
  32543. +/* Or MII_ADDR_C45 into regnum for read/write on mii_bus to enable the 21 bit
  32544. + IEEE 802.3ae clause 45 addressing mode used by 10GIGE phy chips. */
  32545. +#define MII_ADDR_C45 (1<<30)
  32546. +
  32547. +/*
  32548. + * The Bus class for PHYs. Devices which provide access to
  32549. + * PHYs should register using this structure
  32550. + */
  32551. +struct mii_bus {
  32552. + const char *name;
  32553. + char id[MII_BUS_ID_SIZE];
  32554. + void *priv;
  32555. + int (*read)(struct mii_bus *bus, int phy_id, int regnum);
  32556. + int (*write)(struct mii_bus *bus, int phy_id, int regnum, u16 val);
  32557. + int (*reset)(struct mii_bus *bus);
  32558. +
  32559. + /*
  32560. + * A lock to ensure that only one thing can read/write
  32561. + * the MDIO bus at a time
  32562. + */
  32563. + struct mutex mdio_lock;
  32564. +
  32565. + struct device *parent;
  32566. + enum {
  32567. + MDIOBUS_ALLOCATED = 1,
  32568. + MDIOBUS_REGISTERED,
  32569. + MDIOBUS_UNREGISTERED,
  32570. + MDIOBUS_RELEASED,
  32571. + } state;
  32572. + struct device dev;
  32573. +
  32574. + /* list of all PHYs on bus */
  32575. + struct phy_device *phy_map[PHY_MAX_ADDR];
  32576. +
  32577. + /* Phy addresses to be ignored when probing */
  32578. + u32 phy_mask;
  32579. +
  32580. + /*
  32581. + * Pointer to an array of interrupts, each PHY's
  32582. + * interrupt at the index matching its address
  32583. + */
  32584. + int *irq;
  32585. +};
  32586. +#define to_mii_bus(d) container_of(d, struct mii_bus, dev)
  32587. +
  32588. +struct mii_bus *mdiobus_alloc(void);
  32589. +int mdiobus_register(struct mii_bus *bus);
  32590. +void mdiobus_unregister(struct mii_bus *bus);
  32591. +void mdiobus_free(struct mii_bus *bus);
  32592. +struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
  32593. +int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum);
  32594. +int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val);
  32595. +
  32596. +
  32597. +#define PHY_INTERRUPT_DISABLED 0x0
  32598. +#define PHY_INTERRUPT_ENABLED 0x80000000
  32599. +
  32600. +/* PHY state machine states:
  32601. + *
  32602. + * DOWN: PHY device and driver are not ready for anything. probe
  32603. + * should be called if and only if the PHY is in this state,
  32604. + * given that the PHY device exists.
  32605. + * - PHY driver probe function will, depending on the PHY, set
  32606. + * the state to STARTING or READY
  32607. + *
  32608. + * STARTING: PHY device is coming up, and the ethernet driver is
  32609. + * not ready. PHY drivers may set this in the probe function.
  32610. + * If they do, they are responsible for making sure the state is
  32611. + * eventually set to indicate whether the PHY is UP or READY,
  32612. + * depending on the state when the PHY is done starting up.
  32613. + * - PHY driver will set the state to READY
  32614. + * - start will set the state to PENDING
  32615. + *
  32616. + * READY: PHY is ready to send and receive packets, but the
  32617. + * controller is not. By default, PHYs which do not implement
  32618. + * probe will be set to this state by phy_probe(). If the PHY
  32619. + * driver knows the PHY is ready, and the PHY state is STARTING,
  32620. + * then it sets this STATE.
  32621. + * - start will set the state to UP
  32622. + *
  32623. + * PENDING: PHY device is coming up, but the ethernet driver is
  32624. + * ready. phy_start will set this state if the PHY state is
  32625. + * STARTING.
  32626. + * - PHY driver will set the state to UP when the PHY is ready
  32627. + *
  32628. + * UP: The PHY and attached device are ready to do work.
  32629. + * Interrupts should be started here.
  32630. + * - timer moves to AN
  32631. + *
  32632. + * AN: The PHY is currently negotiating the link state. Link is
  32633. + * therefore down for now. phy_timer will set this state when it
  32634. + * detects the state is UP. config_aneg will set this state
  32635. + * whenever called with phydev->autoneg set to AUTONEG_ENABLE.
  32636. + * - If autonegotiation finishes, but there's no link, it sets
  32637. + * the state to NOLINK.
  32638. + * - If aneg finishes with link, it sets the state to RUNNING,
  32639. + * and calls adjust_link
  32640. + * - If autonegotiation did not finish after an arbitrary amount
  32641. + * of time, autonegotiation should be tried again if the PHY
  32642. + * supports "magic" autonegotiation (back to AN)
  32643. + * - If it didn't finish, and no magic_aneg, move to FORCING.
  32644. + *
  32645. + * NOLINK: PHY is up, but not currently plugged in.
  32646. + * - If the timer notes that the link comes back, we move to RUNNING
  32647. + * - config_aneg moves to AN
  32648. + * - phy_stop moves to HALTED
  32649. + *
  32650. + * FORCING: PHY is being configured with forced settings
  32651. + * - if link is up, move to RUNNING
  32652. + * - If link is down, we drop to the next highest setting, and
  32653. + * retry (FORCING) after a timeout
  32654. + * - phy_stop moves to HALTED
  32655. + *
  32656. + * RUNNING: PHY is currently up, running, and possibly sending
  32657. + * and/or receiving packets
  32658. + * - timer will set CHANGELINK if we're polling (this ensures the
  32659. + * link state is polled every other cycle of this state machine,
  32660. + * which makes it every other second)
  32661. + * - irq will set CHANGELINK
  32662. + * - config_aneg will set AN
  32663. + * - phy_stop moves to HALTED
  32664. + *
  32665. + * CHANGELINK: PHY experienced a change in link state
  32666. + * - timer moves to RUNNING if link
  32667. + * - timer moves to NOLINK if the link is down
  32668. + * - phy_stop moves to HALTED
  32669. + *
  32670. + * HALTED: PHY is up, but no polling or interrupts are done. Or
  32671. + * PHY is in an error state.
  32672. + *
  32673. + * - phy_start moves to RESUMING
  32674. + *
  32675. + * RESUMING: PHY was halted, but now wants to run again.
  32676. + * - If we are forcing, or aneg is done, timer moves to RUNNING
  32677. + * - If aneg is not done, timer moves to AN
  32678. + * - phy_stop moves to HALTED
  32679. + */
  32680. +enum phy_state {
  32681. + PHY_DOWN=0,
  32682. + PHY_STARTING,
  32683. + PHY_READY,
  32684. + PHY_PENDING,
  32685. + PHY_UP,
  32686. + PHY_AN,
  32687. + PHY_RUNNING,
  32688. + PHY_NOLINK,
  32689. + PHY_FORCING,
  32690. + PHY_CHANGELINK,
  32691. + PHY_HALTED,
  32692. + PHY_RESUMING
  32693. +};
  32694. +
  32695. +/* phy_device: An instance of a PHY
  32696. + *
  32697. + * drv: Pointer to the driver for this PHY instance
  32698. + * bus: Pointer to the bus this PHY is on
  32699. + * dev: driver model device structure for this PHY
  32700. + * phy_id: UID for this device found during discovery
  32701. + * state: state of the PHY for management purposes
  32702. + * dev_flags: Device-specific flags used by the PHY driver.
  32703. + * addr: Bus address of PHY
  32704. + * link_timeout: The number of timer firings to wait before the
  32705. + * giving up on the current attempt at acquiring a link
  32706. + * irq: IRQ number of the PHY's interrupt (-1 if none)
  32707. + * phy_timer: The timer for handling the state machine
  32708. + * phy_queue: A work_queue for the interrupt
  32709. + * attached_dev: The attached enet driver's device instance ptr
  32710. + * adjust_link: Callback for the enet controller to respond to
  32711. + * changes in the link state.
  32712. + * adjust_state: Callback for the enet driver to respond to
  32713. + * changes in the state machine.
  32714. + *
  32715. + * speed, duplex, pause, supported, advertising, and
  32716. + * autoneg are used like in mii_if_info
  32717. + *
  32718. + * interrupts currently only supports enabled or disabled,
  32719. + * but could be changed in the future to support enabling
  32720. + * and disabling specific interrupts
  32721. + *
  32722. + * Contains some infrastructure for polling and interrupt
  32723. + * handling, as well as handling shifts in PHY hardware state
  32724. + */
  32725. +struct phy_device {
  32726. + /* Information about the PHY type */
  32727. + /* And management functions */
  32728. + struct phy_driver *drv;
  32729. +
  32730. + struct mii_bus *bus;
  32731. +
  32732. + struct device dev;
  32733. +
  32734. + u32 phy_id;
  32735. +
  32736. + enum phy_state state;
  32737. +
  32738. + u32 dev_flags;
  32739. +
  32740. + phy_interface_t interface;
  32741. +
  32742. + /* Bus address of the PHY (0-32) */
  32743. + int addr;
  32744. +
  32745. + /*
  32746. + * forced speed & duplex (no autoneg)
  32747. + * partner speed & duplex & pause (autoneg)
  32748. + */
  32749. + int speed;
  32750. + int duplex;
  32751. + int pause;
  32752. + int asym_pause;
  32753. +
  32754. + /* The most recently read link state */
  32755. + int link;
  32756. +
  32757. + /* Enabled Interrupts */
  32758. + u32 interrupts;
  32759. +
  32760. + /* Union of PHY and Attached devices' supported modes */
  32761. + /* See mii.h for more info */
  32762. + u32 supported;
  32763. + u32 advertising;
  32764. +
  32765. + int autoneg;
  32766. +
  32767. + int link_timeout;
  32768. +
  32769. + /*
  32770. + * Interrupt number for this PHY
  32771. + * -1 means no interrupt
  32772. + */
  32773. + int irq;
  32774. +
  32775. + /* private data pointer */
  32776. + /* For use by PHYs to maintain extra state */
  32777. + void *priv;
  32778. +
  32779. + /* Interrupt and Polling infrastructure */
  32780. + struct work_struct phy_queue;
  32781. + struct delayed_work state_queue;
  32782. + atomic_t irq_disable;
  32783. +
  32784. + struct mutex lock;
  32785. +
  32786. + struct net_device *attached_dev;
  32787. +
  32788. + void (*adjust_link)(struct net_device *dev);
  32789. +
  32790. + void (*adjust_state)(struct net_device *dev);
  32791. +};
  32792. +#define to_phy_device(d) container_of(d, struct phy_device, dev)
  32793. +
  32794. +/* struct phy_driver: Driver structure for a particular PHY type
  32795. + *
  32796. + * phy_id: The result of reading the UID registers of this PHY
  32797. + * type, and ANDing them with the phy_id_mask. This driver
  32798. + * only works for PHYs with IDs which match this field
  32799. + * name: The friendly name of this PHY type
  32800. + * phy_id_mask: Defines the important bits of the phy_id
  32801. + * features: A list of features (speed, duplex, etc) supported
  32802. + * by this PHY
  32803. + * flags: A bitfield defining certain other features this PHY
  32804. + * supports (like interrupts)
  32805. + *
  32806. + * The drivers must implement config_aneg and read_status. All
  32807. + * other functions are optional. Note that none of these
  32808. + * functions should be called from interrupt time. The goal is
  32809. + * for the bus read/write functions to be able to block when the
  32810. + * bus transaction is happening, and be freed up by an interrupt
  32811. + * (The MPC85xx has this ability, though it is not currently
  32812. + * supported in the driver).
  32813. + */
  32814. +struct phy_driver {
  32815. + u32 phy_id;
  32816. + char *name;
  32817. + unsigned int phy_id_mask;
  32818. + u32 features;
  32819. + u32 flags;
  32820. +
  32821. + /*
  32822. + * Called to initialize the PHY,
  32823. + * including after a reset
  32824. + */
  32825. + int (*config_init)(struct phy_device *phydev);
  32826. +
  32827. + /*
  32828. + * Called during discovery. Used to set
  32829. + * up device-specific structures, if any
  32830. + */
  32831. + int (*probe)(struct phy_device *phydev);
  32832. +
  32833. + /* PHY Power Management */
  32834. + int (*suspend)(struct phy_device *phydev);
  32835. + int (*resume)(struct phy_device *phydev);
  32836. +
  32837. + /*
  32838. + * Configures the advertisement and resets
  32839. + * autonegotiation if phydev->autoneg is on,
  32840. + * forces the speed to the current settings in phydev
  32841. + * if phydev->autoneg is off
  32842. + */
  32843. + int (*config_aneg)(struct phy_device *phydev);
  32844. +
  32845. + /* Determines the negotiated speed and duplex */
  32846. + int (*read_status)(struct phy_device *phydev);
  32847. +
  32848. + /* Clears any pending interrupts */
  32849. + int (*ack_interrupt)(struct phy_device *phydev);
  32850. +
  32851. + /* Enables or disables interrupts */
  32852. + int (*config_intr)(struct phy_device *phydev);
  32853. +
  32854. + /*
  32855. + * Checks if the PHY generated an interrupt.
  32856. + * For multi-PHY devices with shared PHY interrupt pin
  32857. + */
  32858. + int (*did_interrupt)(struct phy_device *phydev);
  32859. +
  32860. + /* Clears up any memory if needed */
  32861. + void (*remove)(struct phy_device *phydev);
  32862. +
  32863. + struct device_driver driver;
  32864. +};
  32865. +#define to_phy_driver(d) container_of(d, struct phy_driver, driver)
  32866. +
  32867. +#define PHY_ANY_ID "MATCH ANY PHY"
  32868. +#define PHY_ANY_UID 0xffffffff
  32869. +
  32870. +/* A Structure for boards to register fixups with the PHY Lib */
  32871. +struct phy_fixup {
  32872. + struct list_head list;
  32873. + char bus_id[20];
  32874. + u32 phy_uid;
  32875. + u32 phy_uid_mask;
  32876. + int (*run)(struct phy_device *phydev);
  32877. +};
  32878. +
  32879. +/**
  32880. + * phy_read - Convenience function for reading a given PHY register
  32881. + * @phydev: the phy_device struct
  32882. + * @regnum: register number to read
  32883. + *
  32884. + * NOTE: MUST NOT be called from interrupt context,
  32885. + * because the bus read/write functions may wait for an interrupt
  32886. + * to conclude the operation.
  32887. + */
  32888. +static inline int phy_read(struct phy_device *phydev, u32 regnum)
  32889. +{
  32890. + return mdiobus_read(phydev->bus, phydev->addr, regnum);
  32891. +}
  32892. +
  32893. +/**
  32894. + * phy_write - Convenience function for writing a given PHY register
  32895. + * @phydev: the phy_device struct
  32896. + * @regnum: register number to write
  32897. + * @val: value to write to @regnum
  32898. + *
  32899. + * NOTE: MUST NOT be called from interrupt context,
  32900. + * because the bus read/write functions may wait for an interrupt
  32901. + * to conclude the operation.
  32902. + */
  32903. +static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
  32904. +{
  32905. + return mdiobus_write(phydev->bus, phydev->addr, regnum, val);
  32906. +}
  32907. +
  32908. +int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id);
  32909. +struct phy_device* get_phy_device(struct mii_bus *bus, int addr);
  32910. +int phy_device_register(struct phy_device *phy);
  32911. +int phy_clear_interrupt(struct phy_device *phydev);
  32912. +int phy_config_interrupt(struct phy_device *phydev, u32 interrupts);
  32913. +int phy_init_hw(struct phy_device *phydev);
  32914. +int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
  32915. + u32 flags, phy_interface_t interface);
  32916. +struct phy_device * phy_attach(struct net_device *dev,
  32917. + const char *bus_id, u32 flags, phy_interface_t interface);
  32918. +struct phy_device *phy_find_first(struct mii_bus *bus);
  32919. +int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
  32920. + void (*handler)(struct net_device *), u32 flags,
  32921. + phy_interface_t interface);
  32922. +struct phy_device * phy_connect(struct net_device *dev, const char *bus_id,
  32923. + void (*handler)(struct net_device *), u32 flags,
  32924. + phy_interface_t interface);
  32925. +void phy_disconnect(struct phy_device *phydev);
  32926. +void phy_detach(struct phy_device *phydev);
  32927. +void phy_start(struct phy_device *phydev);
  32928. +void phy_stop(struct phy_device *phydev);
  32929. +int phy_start_aneg(struct phy_device *phydev);
  32930. +
  32931. +void phy_sanitize_settings(struct phy_device *phydev);
  32932. +int phy_stop_interrupts(struct phy_device *phydev);
  32933. +int phy_enable_interrupts(struct phy_device *phydev);
  32934. +int phy_disable_interrupts(struct phy_device *phydev);
  32935. +
  32936. +static inline int phy_read_status(struct phy_device *phydev) {
  32937. + return phydev->drv->read_status(phydev);
  32938. +}
  32939. +
  32940. +int genphy_config_advert(struct phy_device *phydev);
  32941. +int genphy_setup_forced(struct phy_device *phydev);
  32942. +int genphy_restart_aneg(struct phy_device *phydev);
  32943. +int genphy_config_aneg(struct phy_device *phydev);
  32944. +int genphy_update_link(struct phy_device *phydev);
  32945. +int genphy_read_status(struct phy_device *phydev);
  32946. +int genphy_suspend(struct phy_device *phydev);
  32947. +int genphy_resume(struct phy_device *phydev);
  32948. +void phy_driver_unregister(struct phy_driver *drv);
  32949. +int phy_driver_register(struct phy_driver *new_driver);
  32950. +void phy_prepare_link(struct phy_device *phydev,
  32951. + void (*adjust_link)(struct net_device *));
  32952. +void phy_state_machine(struct work_struct *work);
  32953. +void phy_start_machine(struct phy_device *phydev,
  32954. + void (*handler)(struct net_device *));
  32955. +void phy_stop_machine(struct phy_device *phydev);
  32956. +int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
  32957. +int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
  32958. +int phy_mii_ioctl(struct phy_device *phydev,
  32959. + struct mii_ioctl_data *mii_data, int cmd);
  32960. +int phy_start_interrupts(struct phy_device *phydev);
  32961. +void phy_print_status(struct phy_device *phydev);
  32962. +struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id);
  32963. +void phy_device_free(struct phy_device *phydev);
  32964. +
  32965. +int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
  32966. + int (*run)(struct phy_device *));
  32967. +int phy_register_fixup_for_id(const char *bus_id,
  32968. + int (*run)(struct phy_device *));
  32969. +int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
  32970. + int (*run)(struct phy_device *));
  32971. +int phy_scan_fixups(struct phy_device *phydev);
  32972. +
  32973. +int __init mdio_bus_init(void);
  32974. +void mdio_bus_exit(void);
  32975. +
  32976. +extern struct bus_type mdio_bus_type;
  32977. +#endif /* __PHY_H */
  32978. diff -Nur linux-2.6.35.7.orig/include/linux/spi/vsc7385.h linux-2.6.35.7/include/linux/spi/vsc7385.h
  32979. --- linux-2.6.35.7.orig/include/linux/spi/vsc7385.h 1970-01-01 01:00:00.000000000 +0100
  32980. +++ linux-2.6.35.7/include/linux/spi/vsc7385.h 2010-10-14 20:28:01.878101023 +0200
  32981. @@ -0,0 +1,19 @@
  32982. +/*
  32983. + * Platform data definition for the Vitesse VSC7385 ethernet switch driver
  32984. + *
  32985. + * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
  32986. + *
  32987. + * This program is free software; you can redistribute it and/or modify it
  32988. + * under the terms of the GNU General Public License version 2 as published
  32989. + * by the Free Software Foundation.
  32990. + */
  32991. +
  32992. +struct vsc7385_platform_data {
  32993. + void (* reset)(void);
  32994. + char *ucode_name;
  32995. + struct {
  32996. + u32 tx_ipg:5;
  32997. + u32 bit2:1;
  32998. + u32 clk_sel:3;
  32999. + } mac_cfg;
  33000. +};
  33001. diff -Nur linux-2.6.35.7.orig/net/dsa/ar7240.c linux-2.6.35.7/net/dsa/ar7240.c
  33002. --- linux-2.6.35.7.orig/net/dsa/ar7240.c 1970-01-01 01:00:00.000000000 +0100
  33003. +++ linux-2.6.35.7/net/dsa/ar7240.c 2010-10-14 20:28:01.915601104 +0200
  33004. @@ -0,0 +1,736 @@
  33005. +/*
  33006. + * DSA driver for the built-in ethernet switch of the Atheros AR7240 SoC
  33007. + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
  33008. + *
  33009. + * This file was based on:
  33010. + * net/dsa/mv88e6060.c - Driver for Marvell 88e6060 switch chips
  33011. + * Copyright (c) 2008 Marvell Semiconductor
  33012. + *
  33013. + * This program is free software; you can redistribute it and/or modify it
  33014. + * under the terms of the GNU General Public License version 2 as published
  33015. + * by the Free Software Foundation.
  33016. + *
  33017. + */
  33018. +
  33019. +#include <linux/etherdevice.h>
  33020. +#include <linux/list.h>
  33021. +#include <linux/netdevice.h>
  33022. +#include <linux/phy.h>
  33023. +#include <linux/mii.h>
  33024. +#include <linux/bitops.h>
  33025. +
  33026. +#include "dsa_priv.h"
  33027. +
  33028. +#define BITM(_count) (BIT(_count) - 1)
  33029. +
  33030. +#define AR7240_REG_MASK_CTRL 0x00
  33031. +#define AR7240_MASK_CTRL_REVISION_M BITM(8)
  33032. +#define AR7240_MASK_CTRL_VERSION_M BITM(8)
  33033. +#define AR7240_MASK_CTRL_VERSION_S 8
  33034. +#define AR7240_MASK_CTRL_SOFT_RESET BIT(31)
  33035. +
  33036. +#define AR7240_REG_MAC_ADDR0 0x20
  33037. +#define AR7240_REG_MAC_ADDR1 0x24
  33038. +
  33039. +#define AR7240_REG_FLOOD_MASK 0x2c
  33040. +#define AR7240_FLOOD_MASK_BROAD_TO_CPU BIT(26)
  33041. +
  33042. +#define AR7240_REG_GLOBAL_CTRL 0x30
  33043. +#define AR7240_GLOBAL_CTRL_MTU_M BITM(12)
  33044. +
  33045. +#define AR7240_REG_AT_CTRL 0x5c
  33046. +#define AR7240_AT_CTRL_ARP_EN BIT(20)
  33047. +
  33048. +#define AR7240_REG_TAG_PRIORITY 0x70
  33049. +
  33050. +#define AR7240_REG_SERVICE_TAG 0x74
  33051. +#define AR7240_SERVICE_TAG_M BITM(16)
  33052. +
  33053. +#define AR7240_REG_CPU_PORT 0x78
  33054. +#define AR7240_MIRROR_PORT_S 4
  33055. +#define AR7240_CPU_PORT_EN BIT(8)
  33056. +
  33057. +#define AR7240_REG_MIB_FUNCTION0 0x80
  33058. +#define AR7240_MIB_TIMER_M BITM(16)
  33059. +#define AR7240_MIB_AT_HALF_EN BIT(16)
  33060. +#define AR7240_MIB_BUSY BIT(17)
  33061. +#define AR7240_MIB_FUNC_S 24
  33062. +#define AR7240_MIB_FUNC_NO_OP 0x0
  33063. +#define AR7240_MIB_FUNC_FLUSH 0x1
  33064. +#define AR7240_MIB_FUNC_CAPTURE 0x3
  33065. +
  33066. +#define AR7240_REG_MDIO_CTRL 0x98
  33067. +#define AR7240_MDIO_CTRL_DATA_M BITM(16)
  33068. +#define AR7240_MDIO_CTRL_REG_ADDR_S 16
  33069. +#define AR7240_MDIO_CTRL_PHY_ADDR_S 21
  33070. +#define AR7240_MDIO_CTRL_CMD_WRITE 0
  33071. +#define AR7240_MDIO_CTRL_CMD_READ BIT(27)
  33072. +#define AR7240_MDIO_CTRL_MASTER_EN BIT(30)
  33073. +#define AR7240_MDIO_CTRL_BUSY BIT(31)
  33074. +
  33075. +#define AR7240_REG_PORT_BASE(_port) (0x100 + (_port) * 0x100)
  33076. +
  33077. +#define AR7240_REG_PORT_STATUS(_port) (AR7240_REG_PORT_BASE((_port)) + 0x00)
  33078. +#define AR7240_PORT_STATUS_SPEED_M BITM(2)
  33079. +#define AR7240_PORT_STATUS_SPEED_10 0
  33080. +#define AR7240_PORT_STATUS_SPEED_100 1
  33081. +#define AR7240_PORT_STATUS_SPEED_1000 2
  33082. +#define AR7240_PORT_STATUS_TXMAC BIT(2)
  33083. +#define AR7240_PORT_STATUS_RXMAC BIT(3)
  33084. +#define AR7240_PORT_STATUS_TXFLOW BIT(4)
  33085. +#define AR7240_PORT_STATUS_RXFLOW BIT(5)
  33086. +#define AR7240_PORT_STATUS_DUPLEX BIT(6)
  33087. +#define AR7240_PORT_STATUS_LINK_UP BIT(8)
  33088. +#define AR7240_PORT_STATUS_LINK_AUTO BIT(9)
  33089. +#define AR7240_PORT_STATUS_LINK_PAUSE BIT(10)
  33090. +
  33091. +#define AR7240_REG_PORT_CTRL(_port) (AR7240_REG_PORT_BASE((_port)) + 0x04)
  33092. +#define AR7240_PORT_CTRL_STATE_M BITM(3)
  33093. +#define AR7240_PORT_CTRL_STATE_DISABLED 0
  33094. +#define AR7240_PORT_CTRL_STATE_BLOCK 1
  33095. +#define AR7240_PORT_CTRL_STATE_LISTEN 2
  33096. +#define AR7240_PORT_CTRL_STATE_LEARN 3
  33097. +#define AR7240_PORT_CTRL_STATE_FORWARD 4
  33098. +#define AR7240_PORT_CTRL_LEARN_LOCK BIT(7)
  33099. +#define AR7240_PORT_CTRL_VLAN_MODE_S 8
  33100. +#define AR7240_PORT_CTRL_VLAN_MODE_KEEP 0
  33101. +#define AR7240_PORT_CTRL_VLAN_MODE_STRIP 1
  33102. +#define AR7240_PORT_CTRL_VLAN_MODE_ADD 2
  33103. +#define AR7240_PORT_CTRL_VLAN_MODE_DOUBLE_TAG 3
  33104. +#define AR7240_PORT_CTRL_IGMP_SNOOP BIT(10)
  33105. +#define AR7240_PORT_CTRL_HEADER BIT(11)
  33106. +#define AR7240_PORT_CTRL_MAC_LOOP BIT(12)
  33107. +#define AR7240_PORT_CTRL_SINGLE_VLAN BIT(13)
  33108. +#define AR7240_PORT_CTRL_LEARN BIT(14)
  33109. +#define AR7240_PORT_CTRL_DOUBLE_TAG BIT(15)
  33110. +#define AR7240_PORT_CTRL_MIRROR_TX BIT(16)
  33111. +#define AR7240_PORT_CTRL_MIRROR_RX BIT(17)
  33112. +
  33113. +#define AR7240_REG_PORT_VLAN(_port) (AR7240_REG_PORT_BASE((_port)) + 0x08)
  33114. +
  33115. +#define AR7240_PORT_VLAN_DEFAULT_ID_S 0
  33116. +#define AR7240_PORT_VLAN_DEST_PORTS_S 16
  33117. +
  33118. +#define AR7240_REG_STATS_BASE(_port) (0x20000 + (_port) * 0x100)
  33119. +
  33120. +#define AR7240_STATS_RXBROAD 0x00
  33121. +#define AR7240_STATS_RXPAUSE 0x04
  33122. +#define AR7240_STATS_RXMULTI 0x08
  33123. +#define AR7240_STATS_RXFCSERR 0x0c
  33124. +#define AR7240_STATS_RXALIGNERR 0x10
  33125. +#define AR7240_STATS_RXRUNT 0x14
  33126. +#define AR7240_STATS_RXFRAGMENT 0x18
  33127. +#define AR7240_STATS_RX64BYTE 0x1c
  33128. +#define AR7240_STATS_RX128BYTE 0x20
  33129. +#define AR7240_STATS_RX256BYTE 0x24
  33130. +#define AR7240_STATS_RX512BYTE 0x28
  33131. +#define AR7240_STATS_RX1024BYTE 0x2c
  33132. +#define AR7240_STATS_RX1518BYTE 0x30
  33133. +#define AR7240_STATS_RXMAXBYTE 0x34
  33134. +#define AR7240_STATS_RXTOOLONG 0x38
  33135. +#define AR7240_STATS_RXGOODBYTE 0x3c
  33136. +#define AR7240_STATS_RXBADBYTE 0x44
  33137. +#define AR7240_STATS_RXOVERFLOW 0x4c
  33138. +#define AR7240_STATS_FILTERED 0x50
  33139. +#define AR7240_STATS_TXBROAD 0x54
  33140. +#define AR7240_STATS_TXPAUSE 0x58
  33141. +#define AR7240_STATS_TXMULTI 0x5c
  33142. +#define AR7240_STATS_TXUNDERRUN 0x60
  33143. +#define AR7240_STATS_TX64BYTE 0x64
  33144. +#define AR7240_STATS_TX128BYTE 0x68
  33145. +#define AR7240_STATS_TX256BYTE 0x6c
  33146. +#define AR7240_STATS_TX512BYTE 0x70
  33147. +#define AR7240_STATS_TX1024BYTE 0x74
  33148. +#define AR7240_STATS_TX1518BYTE 0x78
  33149. +#define AR7240_STATS_TXMAXBYTE 0x7c
  33150. +#define AR7240_STATS_TXOVERSIZE 0x80
  33151. +#define AR7240_STATS_TXBYTE 0x84
  33152. +#define AR7240_STATS_TXCOLLISION 0x8c
  33153. +#define AR7240_STATS_TXABORTCOL 0x90
  33154. +#define AR7240_STATS_TXMULTICOL 0x94
  33155. +#define AR7240_STATS_TXSINGLECOL 0x98
  33156. +#define AR7240_STATS_TXEXCDEFER 0x9c
  33157. +#define AR7240_STATS_TXDEFER 0xa0
  33158. +#define AR7240_STATS_TXLATECOL 0xa4
  33159. +
  33160. +#define AR7240_PORT_CPU 0
  33161. +#define AR7240_NUM_PORTS 6
  33162. +#define AR7240_NUM_PHYS 5
  33163. +
  33164. +#define AR7240_PHY_ID1 0x004d
  33165. +#define AR7240_PHY_ID2 0xd041
  33166. +
  33167. +#define AR7240_PORT_MASK(_port) BIT((_port))
  33168. +#define AR7240_PORT_MASK_ALL BITM(AR7240_NUM_PORTS)
  33169. +#define AR7240_PORT_MASK_BUT(_port) (AR7240_PORT_MASK_ALL & ~BIT((_port)))
  33170. +
  33171. +struct ar7240sw {
  33172. + struct mii_bus *mii_bus;
  33173. + struct mutex reg_mutex;
  33174. + struct mutex stats_mutex;
  33175. +};
  33176. +
  33177. +struct ar7240sw_hw_stat {
  33178. + char string[ETH_GSTRING_LEN];
  33179. + int sizeof_stat;
  33180. + int reg;
  33181. +};
  33182. +
  33183. +static inline struct ar7240sw *dsa_to_ar7240sw(struct dsa_switch *ds)
  33184. +{
  33185. + return (struct ar7240sw *)(ds + 1);
  33186. +}
  33187. +
  33188. +static inline void ar7240sw_init(struct ar7240sw *as, struct mii_bus *mii)
  33189. +{
  33190. + as->mii_bus = mii;
  33191. + mutex_init(&as->reg_mutex);
  33192. + mutex_init(&as->stats_mutex);
  33193. +}
  33194. +
  33195. +static inline u16 mk_phy_addr(u32 reg)
  33196. +{
  33197. + return (0x17 & ((reg >> 4) | 0x10));
  33198. +}
  33199. +
  33200. +static inline u16 mk_phy_reg(u32 reg)
  33201. +{
  33202. + return ((reg << 1) & 0x1e);
  33203. +}
  33204. +
  33205. +static inline u16 mk_high_addr(u32 reg)
  33206. +{
  33207. + return ((reg >> 7) & 0x1ff);
  33208. +}
  33209. +
  33210. +static u32 __ar7240sw_reg_read(struct ar7240sw *as, u32 reg)
  33211. +{
  33212. + struct mii_bus *mii = as->mii_bus;
  33213. + u16 phy_addr;
  33214. + u16 phy_reg;
  33215. + u32 hi, lo;
  33216. +
  33217. + reg = (reg & 0xfffffffc) >> 2;
  33218. +
  33219. + mdiobus_write(mii, 0x1f, 0x10, mk_high_addr(reg));
  33220. +
  33221. + phy_addr = mk_phy_addr(reg);
  33222. + phy_reg = mk_phy_reg(reg);
  33223. +
  33224. + lo = (u32) mdiobus_read(mii, phy_addr, phy_reg);
  33225. + hi = (u32) mdiobus_read(mii, phy_addr, phy_reg + 1);
  33226. +
  33227. + return ((hi << 16) | lo);
  33228. +}
  33229. +
  33230. +static void __ar7240sw_reg_write(struct ar7240sw *as, u32 reg, u32 val)
  33231. +{
  33232. + struct mii_bus *mii = as->mii_bus;
  33233. + u16 phy_addr;
  33234. + u16 phy_reg;
  33235. +
  33236. + reg = (reg & 0xfffffffc) >> 2;
  33237. +
  33238. + mdiobus_write(mii, 0x1f, 0x10, mk_high_addr(reg));
  33239. +
  33240. + phy_addr = mk_phy_addr(reg);
  33241. + phy_reg = mk_phy_reg(reg);
  33242. +
  33243. + mdiobus_write(mii, phy_addr, phy_reg + 1, (val >> 16));
  33244. + mdiobus_write(mii, phy_addr, phy_reg, (val & 0xffff));
  33245. +}
  33246. +
  33247. +static u32 ar7240sw_reg_read(struct ar7240sw *as, u32 reg_addr)
  33248. +{
  33249. + u32 ret;
  33250. +
  33251. + mutex_lock(&as->reg_mutex);
  33252. + ret = __ar7240sw_reg_read(as, reg_addr);
  33253. + mutex_unlock(&as->reg_mutex);
  33254. +
  33255. + return ret;
  33256. +}
  33257. +
  33258. +static void ar7240sw_reg_write(struct ar7240sw *as, u32 reg_addr, u32 reg_val)
  33259. +{
  33260. + mutex_lock(&as->reg_mutex);
  33261. + __ar7240sw_reg_write(as, reg_addr, reg_val);
  33262. + mutex_unlock(&as->reg_mutex);
  33263. +}
  33264. +
  33265. +static u32 ar7240sw_reg_rmw(struct ar7240sw *as, u32 reg, u32 mask, u32 val)
  33266. +{
  33267. + u32 t;
  33268. +
  33269. + mutex_lock(&as->reg_mutex);
  33270. + t = __ar7240sw_reg_read(as, reg);
  33271. + t &= ~mask;
  33272. + t |= val;
  33273. + __ar7240sw_reg_write(as, reg, t);
  33274. + mutex_unlock(&as->reg_mutex);
  33275. +
  33276. + return t;
  33277. +}
  33278. +
  33279. +static void ar7240sw_reg_set(struct ar7240sw *as, u32 reg, u32 val)
  33280. +{
  33281. + u32 t;
  33282. +
  33283. + mutex_lock(&as->reg_mutex);
  33284. + t = __ar7240sw_reg_read(as, reg);
  33285. + t |= val;
  33286. + __ar7240sw_reg_write(as, reg, t);
  33287. + mutex_unlock(&as->reg_mutex);
  33288. +}
  33289. +
  33290. +static int ar7240sw_reg_wait(struct ar7240sw *as, u32 reg, u32 mask, u32 val,
  33291. + unsigned timeout)
  33292. +{
  33293. + int i;
  33294. +
  33295. + for (i = 0; i < timeout; i++) {
  33296. + u32 t;
  33297. +
  33298. + t = ar7240sw_reg_read(as, reg);
  33299. + if ((t & mask) == val)
  33300. + return 0;
  33301. +
  33302. + msleep(1);
  33303. + }
  33304. +
  33305. + return -ETIMEDOUT;
  33306. +}
  33307. +
  33308. +static u16 ar7240sw_phy_read(struct ar7240sw *as, unsigned phy_addr,
  33309. + unsigned reg_addr)
  33310. +{
  33311. + u32 t;
  33312. + int err;
  33313. +
  33314. + if (phy_addr >= AR7240_NUM_PHYS)
  33315. + return 0xffff;
  33316. +
  33317. + t = (reg_addr << AR7240_MDIO_CTRL_REG_ADDR_S) |
  33318. + (phy_addr << AR7240_MDIO_CTRL_PHY_ADDR_S) |
  33319. + AR7240_MDIO_CTRL_MASTER_EN |
  33320. + AR7240_MDIO_CTRL_BUSY |
  33321. + AR7240_MDIO_CTRL_CMD_READ;
  33322. +
  33323. + ar7240sw_reg_write(as, AR7240_REG_MDIO_CTRL, t);
  33324. + err = ar7240sw_reg_wait(as, AR7240_REG_MDIO_CTRL,
  33325. + AR7240_MDIO_CTRL_BUSY, 0, 5);
  33326. + if (err)
  33327. + return 0xffff;
  33328. +
  33329. + t = ar7240sw_reg_read(as, AR7240_REG_MDIO_CTRL);
  33330. + return (t & AR7240_MDIO_CTRL_DATA_M);
  33331. +}
  33332. +
  33333. +static int ar7240sw_phy_write(struct ar7240sw *as, unsigned phy_addr,
  33334. + unsigned reg_addr, u16 reg_val)
  33335. +{
  33336. + u32 t;
  33337. + int ret;
  33338. +
  33339. + if (phy_addr >= AR7240_NUM_PHYS)
  33340. + return -EINVAL;
  33341. +
  33342. + t = (phy_addr << AR7240_MDIO_CTRL_PHY_ADDR_S) |
  33343. + (reg_addr << AR7240_MDIO_CTRL_REG_ADDR_S) |
  33344. + AR7240_MDIO_CTRL_MASTER_EN |
  33345. + AR7240_MDIO_CTRL_BUSY |
  33346. + AR7240_MDIO_CTRL_CMD_WRITE |
  33347. + reg_val;
  33348. +
  33349. + ar7240sw_reg_write(as, AR7240_REG_MDIO_CTRL, t);
  33350. + ret = ar7240sw_reg_wait(as, AR7240_REG_MDIO_CTRL,
  33351. + AR7240_MDIO_CTRL_BUSY, 0, 5);
  33352. + return ret;
  33353. +}
  33354. +
  33355. +static int ar7240sw_capture_stats(struct ar7240sw *as)
  33356. +{
  33357. + int ret;
  33358. +
  33359. + /* Capture the hardware statistics for all ports */
  33360. + ar7240sw_reg_write(as, AR7240_REG_MIB_FUNCTION0,
  33361. + (AR7240_MIB_FUNC_CAPTURE << AR7240_MIB_FUNC_S));
  33362. +
  33363. + /* Wait for the capturing to complete. */
  33364. + ret = ar7240sw_reg_wait(as, AR7240_REG_MIB_FUNCTION0,
  33365. + AR7240_MIB_BUSY, 0, 10);
  33366. + return ret;
  33367. +}
  33368. +
  33369. +static void ar7240sw_disable_port(struct ar7240sw *as, unsigned port)
  33370. +{
  33371. + ar7240sw_reg_write(as, AR7240_REG_PORT_CTRL(port),
  33372. + AR7240_PORT_CTRL_STATE_DISABLED);
  33373. +}
  33374. +
  33375. +static int ar7240sw_reset(struct ar7240sw *as)
  33376. +{
  33377. + int ret;
  33378. + int i;
  33379. +
  33380. + /* Set all ports to disabled state. */
  33381. + for (i = 0; i < AR7240_NUM_PORTS; i++)
  33382. + ar7240sw_disable_port(as, i);
  33383. +
  33384. + /* Wait for transmit queues to drain. */
  33385. + msleep(2);
  33386. +
  33387. + /* Reset the switch. */
  33388. + ar7240sw_reg_write(as, AR7240_REG_MASK_CTRL,
  33389. + AR7240_MASK_CTRL_SOFT_RESET);
  33390. +
  33391. + ret = ar7240sw_reg_wait(as, AR7240_REG_MASK_CTRL,
  33392. + AR7240_MASK_CTRL_SOFT_RESET, 0, 1000);
  33393. + return ret;
  33394. +}
  33395. +
  33396. +static void ar7240sw_setup(struct ar7240sw *as)
  33397. +{
  33398. + /* Enable CPU port, and disable mirror port */
  33399. + ar7240sw_reg_write(as, AR7240_REG_CPU_PORT,
  33400. + AR7240_CPU_PORT_EN |
  33401. + (15 << AR7240_MIRROR_PORT_S));
  33402. +
  33403. + /* Setup TAG priority mapping */
  33404. + ar7240sw_reg_write(as, AR7240_REG_TAG_PRIORITY, 0xfa50);
  33405. +
  33406. + /* Enable ARP frame acknowledge */
  33407. + ar7240sw_reg_set(as, AR7240_REG_AT_CTRL, AR7240_AT_CTRL_ARP_EN);
  33408. +
  33409. + /* Enable Broadcast frames transmitted to the CPU */
  33410. + ar7240sw_reg_set(as, AR7240_REG_FLOOD_MASK,
  33411. + AR7240_FLOOD_MASK_BROAD_TO_CPU);
  33412. +
  33413. + /* setup MTU */
  33414. + ar7240sw_reg_rmw(as, AR7240_REG_GLOBAL_CTRL, AR7240_GLOBAL_CTRL_MTU_M,
  33415. + 1536);
  33416. +
  33417. + /* setup Service TAG */
  33418. + ar7240sw_reg_rmw(as, AR7240_REG_SERVICE_TAG, AR7240_SERVICE_TAG_M,
  33419. + ETH_P_QINQ);
  33420. +}
  33421. +
  33422. +static void ar7240sw_setup_port(struct ar7240sw *as, unsigned port)
  33423. +{
  33424. + u32 ctrl;
  33425. + u32 dest_ports;
  33426. + u32 vlan;
  33427. +
  33428. + ctrl = AR7240_PORT_CTRL_STATE_FORWARD;
  33429. +
  33430. + if (port == AR7240_PORT_CPU) {
  33431. + ar7240sw_reg_write(as, AR7240_REG_PORT_STATUS(port),
  33432. + AR7240_PORT_STATUS_SPEED_1000 |
  33433. + AR7240_PORT_STATUS_TXFLOW |
  33434. + AR7240_PORT_STATUS_RXFLOW |
  33435. + AR7240_PORT_STATUS_TXMAC |
  33436. + AR7240_PORT_STATUS_RXMAC |
  33437. + AR7240_PORT_STATUS_DUPLEX);
  33438. +
  33439. + /* allow the CPU port to talk to each of the 'real' ports */
  33440. + dest_ports = AR7240_PORT_MASK_BUT(port);
  33441. +
  33442. + /* remove service tag from ingress frames */
  33443. + ctrl |= AR7240_PORT_CTRL_DOUBLE_TAG;
  33444. + } else {
  33445. + ar7240sw_reg_write(as, AR7240_REG_PORT_STATUS(port),
  33446. + AR7240_PORT_STATUS_LINK_AUTO);
  33447. +
  33448. + /*
  33449. + * allow each of the 'real' ports to only talk to the CPU
  33450. + * port.
  33451. + */
  33452. + dest_ports = AR7240_PORT_MASK(port) |
  33453. + AR7240_PORT_MASK(AR7240_PORT_CPU);
  33454. +
  33455. + /* add service tag to egress frames */
  33456. + ctrl |= (AR7240_PORT_CTRL_VLAN_MODE_DOUBLE_TAG <<
  33457. + AR7240_PORT_CTRL_VLAN_MODE_S);
  33458. + }
  33459. +
  33460. + /* set default VID and and destination ports for this VLAN */
  33461. + vlan = port;
  33462. + vlan |= (dest_ports << AR7240_PORT_VLAN_DEST_PORTS_S);
  33463. +
  33464. + ar7240sw_reg_write(as, AR7240_REG_PORT_CTRL(port), ctrl);
  33465. + ar7240sw_reg_write(as, AR7240_REG_PORT_VLAN(port), vlan);
  33466. +}
  33467. +
  33468. +static char *ar7240_dsa_probe(struct mii_bus *mii, int sw_addr)
  33469. +{
  33470. + struct ar7240sw as;
  33471. + u32 ctrl;
  33472. + u16 phy_id1;
  33473. + u16 phy_id2;
  33474. + u8 ver;
  33475. +
  33476. + ar7240sw_init(&as, mii);
  33477. +
  33478. + ctrl = ar7240sw_reg_read(&as, AR7240_REG_MASK_CTRL);
  33479. +
  33480. + ver = (ctrl >> AR7240_MASK_CTRL_VERSION_S) & AR7240_MASK_CTRL_VERSION_M;
  33481. + if (ver != 1) {
  33482. + pr_err("ar7240_dsa: unsupported chip, ctrl=%08x\n", ctrl);
  33483. + return NULL;
  33484. + }
  33485. +
  33486. + phy_id1 = ar7240sw_phy_read(&as, 0, MII_PHYSID1);
  33487. + phy_id2 = ar7240sw_phy_read(&as, 0, MII_PHYSID2);
  33488. + if (phy_id1 != AR7240_PHY_ID1 || phy_id2 != AR7240_PHY_ID2) {
  33489. + pr_err("ar7240_dsa: unknown phy id '%04x:%04x'\n",
  33490. + phy_id1, phy_id2);
  33491. + return NULL;
  33492. + }
  33493. +
  33494. + return "Atheros AR7240 built-in";
  33495. +}
  33496. +
  33497. +static int ar7240_dsa_setup(struct dsa_switch *ds)
  33498. +{
  33499. + struct ar7240sw *as = dsa_to_ar7240sw(ds);
  33500. + int i;
  33501. + int ret;
  33502. +
  33503. + ar7240sw_init(as, ds->master_mii_bus);
  33504. +
  33505. + ret = ar7240sw_reset(as);
  33506. + if (ret)
  33507. + return ret;
  33508. +
  33509. + ar7240sw_setup(as);
  33510. +
  33511. + for (i = 0; i < AR7240_NUM_PORTS; i++) {
  33512. + if (dsa_is_cpu_port(ds, i) || (ds->phys_port_mask & (1 << i)))
  33513. + ar7240sw_setup_port(as, i);
  33514. + else
  33515. + ar7240sw_disable_port(as, i);
  33516. + }
  33517. +
  33518. + return 0;
  33519. +}
  33520. +
  33521. +static int ar7240_dsa_set_addr(struct dsa_switch *ds, u8 *addr)
  33522. +{
  33523. + struct ar7240sw *as = dsa_to_ar7240sw(ds);
  33524. + u32 t;
  33525. +
  33526. + t = (addr[4] << 8) | addr[5];
  33527. + ar7240sw_reg_write(as, AR7240_REG_MAC_ADDR0, t);
  33528. +
  33529. + t = (addr[0] << 24) | (addr[1] << 16) | (addr[2] << 8) | addr[3];
  33530. + ar7240sw_reg_write(as, AR7240_REG_MAC_ADDR1, t);
  33531. +
  33532. + return 0;
  33533. +}
  33534. +
  33535. +static int ar7240_iort_to_phy_addr(int port)
  33536. +{
  33537. + if (port > 0 && port < AR7240_NUM_PORTS)
  33538. + return port - 1;
  33539. +
  33540. + return -EINVAL;
  33541. +}
  33542. +
  33543. +static int ar7240_dsa_phy_read(struct dsa_switch *ds, int port, int regnum)
  33544. +{
  33545. + struct ar7240sw *as = dsa_to_ar7240sw(ds);
  33546. + int phy_addr;
  33547. +
  33548. + phy_addr = ar7240_iort_to_phy_addr(port);
  33549. + if (phy_addr < 0)
  33550. + return 0xffff;
  33551. +
  33552. + return ar7240sw_phy_read(as, phy_addr, regnum);
  33553. +}
  33554. +
  33555. +static int ar7240_dsa_phy_write(struct dsa_switch *ds, int port, int regnum,
  33556. + u16 val)
  33557. +{
  33558. + struct ar7240sw *as = dsa_to_ar7240sw(ds);
  33559. + int phy_addr;
  33560. +
  33561. + phy_addr = ar7240_iort_to_phy_addr(port);
  33562. + if (phy_addr < 0)
  33563. + return 0xffff;
  33564. +
  33565. + return ar7240sw_phy_write(as, phy_addr, regnum, val);
  33566. +}
  33567. +
  33568. +static const char *ar7240sw_speed_str(unsigned speed)
  33569. +{
  33570. + switch (speed) {
  33571. + case AR7240_PORT_STATUS_SPEED_10:
  33572. + return "10";
  33573. + case AR7240_PORT_STATUS_SPEED_100:
  33574. + return "100";
  33575. + case AR7240_PORT_STATUS_SPEED_1000:
  33576. + return "1000";
  33577. + }
  33578. +
  33579. + return "????";
  33580. +}
  33581. +
  33582. +static void ar7240_dsa_poll_link(struct dsa_switch *ds)
  33583. +{
  33584. + struct ar7240sw *as = dsa_to_ar7240sw(ds);
  33585. + int i;
  33586. +
  33587. + for (i = 0; i < DSA_MAX_PORTS; i++) {
  33588. + struct net_device *dev;
  33589. + u32 status;
  33590. + int link;
  33591. + unsigned speed;
  33592. + int duplex;
  33593. +
  33594. + dev = ds->ports[i];
  33595. + if (dev == NULL)
  33596. + continue;
  33597. +
  33598. + link = 0;
  33599. + if (dev->flags & IFF_UP) {
  33600. + status = ar7240sw_reg_read(as,
  33601. + AR7240_REG_PORT_STATUS(i));
  33602. + link = !!(status & AR7240_PORT_STATUS_LINK_UP);
  33603. + }
  33604. +
  33605. + if (!link) {
  33606. + if (netif_carrier_ok(dev)) {
  33607. + pr_info("%s: link down\n", dev->name);
  33608. + netif_carrier_off(dev);
  33609. + }
  33610. + continue;
  33611. + }
  33612. +
  33613. + speed = (status & AR7240_PORT_STATUS_SPEED_M);
  33614. + duplex = (status & AR7240_PORT_STATUS_DUPLEX) ? 1 : 0;
  33615. + if (!netif_carrier_ok(dev)) {
  33616. + pr_info("%s: link up, %sMb/s, %s duplex",
  33617. + dev->name,
  33618. + ar7240sw_speed_str(speed),
  33619. + duplex ? "full" : "half");
  33620. + netif_carrier_on(dev);
  33621. + }
  33622. + }
  33623. +}
  33624. +
  33625. +static const struct ar7240sw_hw_stat ar7240_hw_stats[] = {
  33626. + { "rx_broadcast" , 4, AR7240_STATS_RXBROAD, },
  33627. + { "rx_pause" , 4, AR7240_STATS_RXPAUSE, },
  33628. + { "rx_multicast" , 4, AR7240_STATS_RXMULTI, },
  33629. + { "rx_fcs_error" , 4, AR7240_STATS_RXFCSERR, },
  33630. + { "rx_align_error" , 4, AR7240_STATS_RXALIGNERR, },
  33631. + { "rx_undersize" , 4, AR7240_STATS_RXRUNT, },
  33632. + { "rx_fragments" , 4, AR7240_STATS_RXFRAGMENT, },
  33633. + { "rx_64bytes" , 4, AR7240_STATS_RX64BYTE, },
  33634. + { "rx_65_127bytes" , 4, AR7240_STATS_RX128BYTE, },
  33635. + { "rx_128_255bytes" , 4, AR7240_STATS_RX256BYTE, },
  33636. + { "rx_256_511bytes" , 4, AR7240_STATS_RX512BYTE, },
  33637. + { "rx_512_1023bytes" , 4, AR7240_STATS_RX1024BYTE, },
  33638. + { "rx_1024_1518bytes" , 4, AR7240_STATS_RX1518BYTE, },
  33639. + { "rx_1519_max_bytes" , 4, AR7240_STATS_RXMAXBYTE, },
  33640. + { "rx_oversize" , 4, AR7240_STATS_RXTOOLONG, },
  33641. + { "rx_good_bytes" , 8, AR7240_STATS_RXGOODBYTE, },
  33642. + { "rx_bad_bytes" , 8, AR7240_STATS_RXBADBYTE, },
  33643. + { "rx_overflow" , 4, AR7240_STATS_RXOVERFLOW, },
  33644. + { "filtered" , 4, AR7240_STATS_FILTERED, },
  33645. + { "tx_broadcast" , 4, AR7240_STATS_TXBROAD, },
  33646. + { "tx_pause" , 4, AR7240_STATS_TXPAUSE, },
  33647. + { "tx_multicast" , 4, AR7240_STATS_TXMULTI, },
  33648. + { "tx_underrun" , 4, AR7240_STATS_TXUNDERRUN, },
  33649. + { "tx_64bytes" , 4, AR7240_STATS_TX64BYTE, },
  33650. + { "tx_65_127bytes" , 4, AR7240_STATS_TX128BYTE, },
  33651. + { "tx_128_255bytes" , 4, AR7240_STATS_TX256BYTE, },
  33652. + { "tx_256_511bytes" , 4, AR7240_STATS_TX512BYTE, },
  33653. + { "tx_512_1023bytes" , 4, AR7240_STATS_TX1024BYTE, },
  33654. + { "tx_1024_1518bytes" , 4, AR7240_STATS_TX1518BYTE, },
  33655. + { "tx_1519_max_bytes" , 4, AR7240_STATS_TXMAXBYTE, },
  33656. + { "tx_oversize" , 4, AR7240_STATS_TXOVERSIZE, },
  33657. + { "tx_bytes" , 8, AR7240_STATS_TXBYTE, },
  33658. + { "tx_collisions" , 4, AR7240_STATS_TXCOLLISION, },
  33659. + { "tx_abort_collisions" , 4, AR7240_STATS_TXABORTCOL, },
  33660. + { "tx_multi_collisions" , 4, AR7240_STATS_TXMULTICOL, },
  33661. + { "tx_single_collisions", 4, AR7240_STATS_TXSINGLECOL, },
  33662. + { "tx_excessive_deferred", 4, AR7240_STATS_TXEXCDEFER, },
  33663. + { "tx_deferred" , 4, AR7240_STATS_TXDEFER, },
  33664. + { "tx_late_collisions" , 4, AR7240_STATS_TXLATECOL, },
  33665. +};
  33666. +
  33667. +static void ar7240_dsa_get_strings(struct dsa_switch *ds, int port,
  33668. + uint8_t *data)
  33669. +{
  33670. + int i;
  33671. +
  33672. + for (i = 0; i < ARRAY_SIZE(ar7240_hw_stats); i++) {
  33673. + memcpy(data + i * ETH_GSTRING_LEN,
  33674. + ar7240_hw_stats[i].string, ETH_GSTRING_LEN);
  33675. + }
  33676. +}
  33677. +
  33678. +static void ar7240_dsa_get_ethtool_stats(struct dsa_switch *ds, int port,
  33679. + uint64_t *data)
  33680. +{
  33681. + struct ar7240sw *as = dsa_to_ar7240sw(ds);
  33682. + int err;
  33683. + int i;
  33684. +
  33685. + mutex_lock(&as->stats_mutex);
  33686. +
  33687. + err = ar7240sw_capture_stats(as);
  33688. + if (err)
  33689. + goto unlock;
  33690. +
  33691. + for (i = 0; i < ARRAY_SIZE(ar7240_hw_stats); i++) {
  33692. + const struct ar7240sw_hw_stat *s = &ar7240_hw_stats[i];
  33693. + u32 reg = AR7240_REG_STATS_BASE(port);
  33694. + u32 low;
  33695. + u32 high;
  33696. +
  33697. + low = ar7240sw_reg_read(as, reg + s->reg);
  33698. + if (s->sizeof_stat == 8)
  33699. + high = ar7240sw_reg_read(as, reg + s->reg);
  33700. + else
  33701. + high = 0;
  33702. +
  33703. + data[i] = (((u64) high) << 32) | low;
  33704. + }
  33705. +
  33706. + unlock:
  33707. + mutex_unlock(&as->stats_mutex);
  33708. +}
  33709. +
  33710. +static int ar7240_dsa_get_sset_count(struct dsa_switch *ds)
  33711. +{
  33712. + return ARRAY_SIZE(ar7240_hw_stats);
  33713. +}
  33714. +
  33715. +static struct dsa_switch_driver ar7240_dsa_driver = {
  33716. + .tag_protocol = htons(ETH_P_QINQ),
  33717. + .priv_size = sizeof(struct ar7240sw),
  33718. + .probe = ar7240_dsa_probe,
  33719. + .setup = ar7240_dsa_setup,
  33720. + .set_addr = ar7240_dsa_set_addr,
  33721. + .phy_read = ar7240_dsa_phy_read,
  33722. + .phy_write = ar7240_dsa_phy_write,
  33723. + .poll_link = ar7240_dsa_poll_link,
  33724. + .get_strings = ar7240_dsa_get_strings,
  33725. + .get_ethtool_stats = ar7240_dsa_get_ethtool_stats,
  33726. + .get_sset_count = ar7240_dsa_get_sset_count,
  33727. +};
  33728. +
  33729. +int __init dsa_ar7240_init(void)
  33730. +{
  33731. + register_switch_driver(&ar7240_dsa_driver);
  33732. + return 0;
  33733. +}
  33734. +module_init(dsa_ar7240_init);
  33735. +
  33736. +void __exit dsa_ar7240_cleanup(void)
  33737. +{
  33738. + unregister_switch_driver(&ar7240_dsa_driver);
  33739. +}
  33740. +module_exit(dsa_ar7240_cleanup);
  33741. diff -Nur linux-2.6.35.7.orig/net/dsa/mv88e6063.c linux-2.6.35.7/net/dsa/mv88e6063.c
  33742. --- linux-2.6.35.7.orig/net/dsa/mv88e6063.c 1970-01-01 01:00:00.000000000 +0100
  33743. +++ linux-2.6.35.7/net/dsa/mv88e6063.c 2010-10-14 20:28:01.954381749 +0200
  33744. @@ -0,0 +1,294 @@
  33745. +/*
  33746. + * net/dsa/mv88e6063.c - Driver for Marvell 88e6063 switch chips
  33747. + * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
  33748. + *
  33749. + * This driver was base on: net/dsa/mv88e6060.c
  33750. + * net/dsa/mv88e6063.c - Driver for Marvell 88e6060 switch chips
  33751. + * Copyright (c) 2008-2009 Marvell Semiconductor
  33752. + *
  33753. + * This program is free software; you can redistribute it and/or modify
  33754. + * it under the terms of the GNU General Public License as published by
  33755. + * the Free Software Foundation; either version 2 of the License, or
  33756. + * (at your option) any later version.
  33757. + */
  33758. +
  33759. +#include <linux/list.h>
  33760. +#include <linux/netdevice.h>
  33761. +#include <linux/phy.h>
  33762. +#include "dsa_priv.h"
  33763. +
  33764. +#define REG_BASE 0x10
  33765. +#define REG_PHY(p) (REG_BASE + (p))
  33766. +#define REG_PORT(p) (REG_BASE + 8 + (p))
  33767. +#define REG_GLOBAL (REG_BASE + 0x0f)
  33768. +#define NUM_PORTS 7
  33769. +
  33770. +static int reg_read(struct dsa_switch *ds, int addr, int reg)
  33771. +{
  33772. + return mdiobus_read(ds->master_mii_bus, addr, reg);
  33773. +}
  33774. +
  33775. +#define REG_READ(addr, reg) \
  33776. + ({ \
  33777. + int __ret; \
  33778. + \
  33779. + __ret = reg_read(ds, addr, reg); \
  33780. + if (__ret < 0) \
  33781. + return __ret; \
  33782. + __ret; \
  33783. + })
  33784. +
  33785. +
  33786. +static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
  33787. +{
  33788. + return mdiobus_write(ds->master_mii_bus, addr, reg, val);
  33789. +}
  33790. +
  33791. +#define REG_WRITE(addr, reg, val) \
  33792. + ({ \
  33793. + int __ret; \
  33794. + \
  33795. + __ret = reg_write(ds, addr, reg, val); \
  33796. + if (__ret < 0) \
  33797. + return __ret; \
  33798. + })
  33799. +
  33800. +static char *mv88e6063_probe(struct mii_bus *bus, int sw_addr)
  33801. +{
  33802. + int ret;
  33803. +
  33804. + ret = mdiobus_read(bus, REG_PORT(0), 0x03);
  33805. + if (ret >= 0) {
  33806. + ret &= 0xfff0;
  33807. + if (ret == 0x1530)
  33808. + return "Marvell 88E6063";
  33809. + }
  33810. +
  33811. + return NULL;
  33812. +}
  33813. +
  33814. +static int mv88e6063_switch_reset(struct dsa_switch *ds)
  33815. +{
  33816. + int i;
  33817. + int ret;
  33818. +
  33819. + /*
  33820. + * Set all ports to the disabled state.
  33821. + */
  33822. + for (i = 0; i < NUM_PORTS; i++) {
  33823. + ret = REG_READ(REG_PORT(i), 0x04);
  33824. + REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
  33825. + }
  33826. +
  33827. + /*
  33828. + * Wait for transmit queues to drain.
  33829. + */
  33830. + msleep(2);
  33831. +
  33832. + /*
  33833. + * Reset the switch.
  33834. + */
  33835. + REG_WRITE(REG_GLOBAL, 0x0a, 0xa130);
  33836. +
  33837. + /*
  33838. + * Wait up to one second for reset to complete.
  33839. + */
  33840. + for (i = 0; i < 1000; i++) {
  33841. + ret = REG_READ(REG_GLOBAL, 0x00);
  33842. + if ((ret & 0x8000) == 0x0000)
  33843. + break;
  33844. +
  33845. + msleep(1);
  33846. + }
  33847. + if (i == 1000)
  33848. + return -ETIMEDOUT;
  33849. +
  33850. + return 0;
  33851. +}
  33852. +
  33853. +static int mv88e6063_setup_global(struct dsa_switch *ds)
  33854. +{
  33855. + /*
  33856. + * Disable discarding of frames with excessive collisions,
  33857. + * set the maximum frame size to 1536 bytes, and mask all
  33858. + * interrupt sources.
  33859. + */
  33860. + REG_WRITE(REG_GLOBAL, 0x04, 0x0800);
  33861. +
  33862. + /*
  33863. + * Enable automatic address learning, set the address
  33864. + * database size to 1024 entries, and set the default aging
  33865. + * time to 5 minutes.
  33866. + */
  33867. + REG_WRITE(REG_GLOBAL, 0x0a, 0x2130);
  33868. +
  33869. + return 0;
  33870. +}
  33871. +
  33872. +static int mv88e6063_setup_port(struct dsa_switch *ds, int p)
  33873. +{
  33874. + int addr = REG_PORT(p);
  33875. +
  33876. + /*
  33877. + * Do not force flow control, disable Ingress and Egress
  33878. + * Header tagging, disable VLAN tunneling, and set the port
  33879. + * state to Forwarding. Additionally, if this is the CPU
  33880. + * port, enable Ingress and Egress Trailer tagging mode.
  33881. + */
  33882. + REG_WRITE(addr, 0x04, dsa_is_cpu_port(ds, p) ? 0x4103 : 0x0003);
  33883. +
  33884. + /*
  33885. + * Port based VLAN map: give each port its own address
  33886. + * database, allow the CPU port to talk to each of the 'real'
  33887. + * ports, and allow each of the 'real' ports to only talk to
  33888. + * the CPU port.
  33889. + */
  33890. + REG_WRITE(addr, 0x06,
  33891. + ((p & 0xf) << 12) |
  33892. + (dsa_is_cpu_port(ds, p) ?
  33893. + ds->phys_port_mask :
  33894. + (1 << ds->dst->cpu_port)));
  33895. +
  33896. + /*
  33897. + * Port Association Vector: when learning source addresses
  33898. + * of packets, add the address to the address database using
  33899. + * a port bitmap that has only the bit for this port set and
  33900. + * the other bits clear.
  33901. + */
  33902. + REG_WRITE(addr, 0x0b, 1 << p);
  33903. +
  33904. + return 0;
  33905. +}
  33906. +
  33907. +static int mv88e6063_setup(struct dsa_switch *ds)
  33908. +{
  33909. + int i;
  33910. + int ret;
  33911. +
  33912. + ret = mv88e6063_switch_reset(ds);
  33913. + if (ret < 0)
  33914. + return ret;
  33915. +
  33916. + /* @@@ initialise atu */
  33917. +
  33918. + ret = mv88e6063_setup_global(ds);
  33919. + if (ret < 0)
  33920. + return ret;
  33921. +
  33922. + for (i = 0; i < NUM_PORTS; i++) {
  33923. + ret = mv88e6063_setup_port(ds, i);
  33924. + if (ret < 0)
  33925. + return ret;
  33926. + }
  33927. +
  33928. + return 0;
  33929. +}
  33930. +
  33931. +static int mv88e6063_set_addr(struct dsa_switch *ds, u8 *addr)
  33932. +{
  33933. + REG_WRITE(REG_GLOBAL, 0x01, (addr[0] << 8) | addr[1]);
  33934. + REG_WRITE(REG_GLOBAL, 0x02, (addr[2] << 8) | addr[3]);
  33935. + REG_WRITE(REG_GLOBAL, 0x03, (addr[4] << 8) | addr[5]);
  33936. +
  33937. + return 0;
  33938. +}
  33939. +
  33940. +static int mv88e6063_port_to_phy_addr(int port)
  33941. +{
  33942. + if (port >= 0 && port <= NUM_PORTS)
  33943. + return REG_PHY(port);
  33944. + return -1;
  33945. +}
  33946. +
  33947. +static int mv88e6063_phy_read(struct dsa_switch *ds, int port, int regnum)
  33948. +{
  33949. + int addr;
  33950. +
  33951. + addr = mv88e6063_port_to_phy_addr(port);
  33952. + if (addr == -1)
  33953. + return 0xffff;
  33954. +
  33955. + return reg_read(ds, addr, regnum);
  33956. +}
  33957. +
  33958. +static int
  33959. +mv88e6063_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
  33960. +{
  33961. + int addr;
  33962. +
  33963. + addr = mv88e6063_port_to_phy_addr(port);
  33964. + if (addr == -1)
  33965. + return 0xffff;
  33966. +
  33967. + return reg_write(ds, addr, regnum, val);
  33968. +}
  33969. +
  33970. +static void mv88e6063_poll_link(struct dsa_switch *ds)
  33971. +{
  33972. + int i;
  33973. +
  33974. + for (i = 0; i < DSA_MAX_PORTS; i++) {
  33975. + struct net_device *dev;
  33976. + int uninitialized_var(port_status);
  33977. + int link;
  33978. + int speed;
  33979. + int duplex;
  33980. + int fc;
  33981. +
  33982. + dev = ds->ports[i];
  33983. + if (dev == NULL)
  33984. + continue;
  33985. +
  33986. + link = 0;
  33987. + if (dev->flags & IFF_UP) {
  33988. + port_status = reg_read(ds, REG_PORT(i), 0x00);
  33989. + if (port_status < 0)
  33990. + continue;
  33991. +
  33992. + link = !!(port_status & 0x1000);
  33993. + }
  33994. +
  33995. + if (!link) {
  33996. + if (netif_carrier_ok(dev)) {
  33997. + printk(KERN_INFO "%s: link down\n", dev->name);
  33998. + netif_carrier_off(dev);
  33999. + }
  34000. + continue;
  34001. + }
  34002. +
  34003. + speed = (port_status & 0x0100) ? 100 : 10;
  34004. + duplex = (port_status & 0x0200) ? 1 : 0;
  34005. + fc = ((port_status & 0xc000) == 0xc000) ? 1 : 0;
  34006. +
  34007. + if (!netif_carrier_ok(dev)) {
  34008. + printk(KERN_INFO "%s: link up, %d Mb/s, %s duplex, "
  34009. + "flow control %sabled\n", dev->name,
  34010. + speed, duplex ? "full" : "half",
  34011. + fc ? "en" : "dis");
  34012. + netif_carrier_on(dev);
  34013. + }
  34014. + }
  34015. +}
  34016. +
  34017. +static struct dsa_switch_driver mv88e6063_switch_driver = {
  34018. + .tag_protocol = htons(ETH_P_TRAILER),
  34019. + .probe = mv88e6063_probe,
  34020. + .setup = mv88e6063_setup,
  34021. + .set_addr = mv88e6063_set_addr,
  34022. + .phy_read = mv88e6063_phy_read,
  34023. + .phy_write = mv88e6063_phy_write,
  34024. + .poll_link = mv88e6063_poll_link,
  34025. +};
  34026. +
  34027. +static int __init mv88e6063_init(void)
  34028. +{
  34029. + register_switch_driver(&mv88e6063_switch_driver);
  34030. + return 0;
  34031. +}
  34032. +module_init(mv88e6063_init);
  34033. +
  34034. +static void __exit mv88e6063_cleanup(void)
  34035. +{
  34036. + unregister_switch_driver(&mv88e6063_switch_driver);
  34037. +}
  34038. +module_exit(mv88e6063_cleanup);
  34039. diff -Nur linux-2.6.35.7.orig/net/dsa/tag_qinq.c linux-2.6.35.7/net/dsa/tag_qinq.c
  34040. --- linux-2.6.35.7.orig/net/dsa/tag_qinq.c 1970-01-01 01:00:00.000000000 +0100
  34041. +++ linux-2.6.35.7/net/dsa/tag_qinq.c 2010-10-14 20:28:01.998101297 +0200
  34042. @@ -0,0 +1,127 @@
  34043. +/*
  34044. + * net/dsa/tag_qinq.c - QinQ tag format handling
  34045. + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
  34046. + *
  34047. + * This file was based on:
  34048. + * net/dsa/tag_edsa.c - Ethertype DSA tagging
  34049. + * Copyright (c) 2008-2009 Marvell Semiconductor
  34050. + *
  34051. + * This program is free software; you can redistribute it and/or modify
  34052. + * it under the terms of the GNU General Public License as published by
  34053. + * the Free Software Foundation; either version 2 of the License, or
  34054. + * (at your option) any later version.
  34055. + */
  34056. +
  34057. +#include <linux/etherdevice.h>
  34058. +#include <linux/list.h>
  34059. +#include <linux/netdevice.h>
  34060. +#include <linux/if_vlan.h>
  34061. +
  34062. +#include "dsa_priv.h"
  34063. +
  34064. +netdev_tx_t qinq_xmit(struct sk_buff *skb, struct net_device *dev)
  34065. +{
  34066. + struct dsa_slave_priv *p = netdev_priv(dev);
  34067. + struct vlan_ethhdr *veth;
  34068. + unsigned int len;
  34069. + int ret;
  34070. +
  34071. + if (skb_cow_head(skb, VLAN_HLEN) < 0)
  34072. + goto out_free_skb;
  34073. +
  34074. + veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
  34075. +
  34076. + /* Move the mac addresses to the beginning of the new header. */
  34077. + memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
  34078. + skb->mac_header -= VLAN_HLEN;
  34079. +
  34080. + /* setup VLAN header fields */
  34081. + veth->h_vlan_proto = htons(ETH_P_QINQ);
  34082. + veth->h_vlan_TCI = htons(p->port);
  34083. +
  34084. + len = skb->len;
  34085. + skb->protocol = htons(ETH_P_QINQ);
  34086. + skb->dev = p->parent->dst->master_netdev;
  34087. +
  34088. + ret = dev_queue_xmit(skb);
  34089. + if (unlikely(ret != NET_XMIT_SUCCESS))
  34090. + goto out_dropped;
  34091. +
  34092. + dev->stats.tx_packets++;
  34093. + dev->stats.tx_bytes += len;
  34094. +
  34095. + return NETDEV_TX_OK;
  34096. +
  34097. + out_free_skb:
  34098. + kfree_skb(skb);
  34099. + out_dropped:
  34100. + dev->stats.tx_dropped++;
  34101. + return NETDEV_TX_OK;
  34102. +}
  34103. +
  34104. +static int qinq_rcv(struct sk_buff *skb, struct net_device *dev,
  34105. + struct packet_type *pt, struct net_device *orig_dev)
  34106. +{
  34107. + struct dsa_switch_tree *dst;
  34108. + struct dsa_switch *ds;
  34109. + struct vlan_hdr *vhdr;
  34110. + int source_port;
  34111. +
  34112. + dst = dev->dsa_ptr;
  34113. + if (unlikely(dst == NULL))
  34114. + goto out_drop;
  34115. + ds = dst->ds[0];
  34116. +
  34117. + skb = skb_unshare(skb, GFP_ATOMIC);
  34118. + if (skb == NULL)
  34119. + goto out;
  34120. +
  34121. + if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
  34122. + goto out_drop;
  34123. +
  34124. + vhdr = (struct vlan_hdr *)skb->data;
  34125. + source_port = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
  34126. + if (source_port >= DSA_MAX_PORTS || ds->ports[source_port] == NULL)
  34127. + goto out_drop;
  34128. +
  34129. + /* Remove the outermost VLAN tag and update checksum. */
  34130. + skb_pull_rcsum(skb, VLAN_HLEN);
  34131. + memmove(skb->data - ETH_HLEN,
  34132. + skb->data - ETH_HLEN - VLAN_HLEN,
  34133. + 2 * ETH_ALEN);
  34134. +
  34135. + skb->dev = ds->ports[source_port];
  34136. + skb_push(skb, ETH_HLEN);
  34137. + skb->pkt_type = PACKET_HOST;
  34138. + skb->protocol = eth_type_trans(skb, skb->dev);
  34139. +
  34140. + skb->dev->stats.rx_packets++;
  34141. + skb->dev->stats.rx_bytes += skb->len;
  34142. +
  34143. + netif_receive_skb(skb);
  34144. +
  34145. + return 0;
  34146. +
  34147. + out_drop:
  34148. + kfree_skb(skb);
  34149. + out:
  34150. + return 0;
  34151. +}
  34152. +
  34153. +static struct packet_type qinq_packet_type __read_mostly = {
  34154. + .type = cpu_to_be16(ETH_P_QINQ),
  34155. + .func = qinq_rcv,
  34156. +};
  34157. +
  34158. +static int __init qinq_init_module(void)
  34159. +{
  34160. + dev_add_pack(&qinq_packet_type);
  34161. + return 0;
  34162. +}
  34163. +module_init(qinq_init_module);
  34164. +
  34165. +static void __exit qinq_cleanup_module(void)
  34166. +{
  34167. + dev_remove_pack(&qinq_packet_type);
  34168. +}
  34169. +module_exit(qinq_cleanup_module);